mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
config: switch shell-integration-features
This commit is contained in:
@ -9,6 +9,7 @@ pub const Keybinds = Config.Keybinds;
|
|||||||
pub const MouseShiftCapture = Config.MouseShiftCapture;
|
pub const MouseShiftCapture = Config.MouseShiftCapture;
|
||||||
pub const NonNativeFullscreen = Config.NonNativeFullscreen;
|
pub const NonNativeFullscreen = Config.NonNativeFullscreen;
|
||||||
pub const OptionAsAlt = Config.OptionAsAlt;
|
pub const OptionAsAlt = Config.OptionAsAlt;
|
||||||
|
pub const ShellIntegrationFeatures = Config.ShellIntegrationFeatures;
|
||||||
|
|
||||||
// Alternate APIs
|
// Alternate APIs
|
||||||
pub const CAPI = @import("config/CAPI.zig");
|
pub const CAPI = @import("config/CAPI.zig");
|
||||||
|
@ -532,12 +532,23 @@ keybind: Keybinds = .{},
|
|||||||
/// configure your shell to enable the integration.
|
/// configure your shell to enable the integration.
|
||||||
/// * "detect" - Detect the shell based on the filename.
|
/// * "detect" - Detect the shell based on the filename.
|
||||||
/// * "fish", "zsh" - Use this specific shell injection scheme.
|
/// * "fish", "zsh" - Use this specific shell injection scheme.
|
||||||
/// * "no-cursor" - Detect the shell as in 'detect', but doesn't set cursor
|
|
||||||
/// shapes
|
|
||||||
///
|
///
|
||||||
/// The default value is "detect".
|
/// The default value is "detect".
|
||||||
@"shell-integration": ShellIntegration = .detect,
|
@"shell-integration": ShellIntegration = .detect,
|
||||||
|
|
||||||
|
/// Shell integration features to enable if shell integration itself is enabled.
|
||||||
|
/// The format of this is a list of features to enable separated by commas.
|
||||||
|
/// If you prefix a feature with "no-" then it is disabled. If you omit
|
||||||
|
/// a feature, its default value is used, so you must explicitly disable
|
||||||
|
/// features you don't want.
|
||||||
|
///
|
||||||
|
/// Available features:
|
||||||
|
///
|
||||||
|
/// - "cursor" - Set the cursor to a blinking bar at the prompt.
|
||||||
|
///
|
||||||
|
/// Example: "cursor", "no-cursor"
|
||||||
|
@"shell-integration-features": ShellIntegrationFeatures = .{},
|
||||||
|
|
||||||
/// Sets the reporting format for OSC sequences that request color information.
|
/// Sets the reporting format for OSC sequences that request color information.
|
||||||
/// Ghostty currently supports OSC 10 (foreground) and OSC 11 (background) queries,
|
/// Ghostty currently supports OSC 10 (foreground) and OSC 11 (background) queries,
|
||||||
/// and by default the reported values are scaled-up RGB values, where each component
|
/// and by default the reported values are scaled-up RGB values, where each component
|
||||||
@ -2184,7 +2195,6 @@ pub const ShellIntegration = enum {
|
|||||||
detect,
|
detect,
|
||||||
fish,
|
fish,
|
||||||
zsh,
|
zsh,
|
||||||
@"no-cursor",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Shell integration features
|
/// Shell integration features
|
||||||
|
@ -812,13 +812,6 @@ const Subprocess = struct {
|
|||||||
.detect => null,
|
.detect => null,
|
||||||
.fish => .fish,
|
.fish => .fish,
|
||||||
.zsh => .zsh,
|
.zsh => .zsh,
|
||||||
.@"no-cursor" => nc: {
|
|
||||||
// We add an environment variable for the shell integration
|
|
||||||
// scripts to pick up to prevent setting cursor shapes.
|
|
||||||
// Setting to "no_cursor" means we will detect the shell
|
|
||||||
try env.put("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR", "1");
|
|
||||||
break :nc null;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const dir = opts.resources_dir orelse break :shell null;
|
const dir = opts.resources_dir orelse break :shell null;
|
||||||
@ -827,6 +820,7 @@ const Subprocess = struct {
|
|||||||
final_path,
|
final_path,
|
||||||
&env,
|
&env,
|
||||||
force,
|
force,
|
||||||
|
opts.full_config.@"shell-integration-features",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
if (shell_integrated) |shell| {
|
if (shell_integrated) |shell| {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const EnvMap = std.process.EnvMap;
|
const EnvMap = std.process.EnvMap;
|
||||||
|
const config = @import("../config.zig");
|
||||||
|
|
||||||
const log = std.log.scoped(.shell_integration);
|
const log = std.log.scoped(.shell_integration);
|
||||||
|
|
||||||
@ -18,23 +19,31 @@ pub fn setup(
|
|||||||
command_path: []const u8,
|
command_path: []const u8,
|
||||||
env: *EnvMap,
|
env: *EnvMap,
|
||||||
force_shell: ?Shell,
|
force_shell: ?Shell,
|
||||||
|
features: config.ShellIntegrationFeatures,
|
||||||
) !?Shell {
|
) !?Shell {
|
||||||
const exe = if (force_shell) |shell| switch (shell) {
|
const exe = if (force_shell) |shell| switch (shell) {
|
||||||
.fish => "/fish",
|
.fish => "/fish",
|
||||||
.zsh => "/zsh",
|
.zsh => "/zsh",
|
||||||
} else std.fs.path.basename(command_path);
|
} else std.fs.path.basename(command_path);
|
||||||
|
|
||||||
if (std.mem.eql(u8, "fish", exe)) {
|
const shell: Shell = shell: {
|
||||||
try setupFish(resource_dir, env);
|
if (std.mem.eql(u8, "fish", exe)) {
|
||||||
return .fish;
|
try setupFish(resource_dir, env);
|
||||||
}
|
break :shell .fish;
|
||||||
|
}
|
||||||
|
|
||||||
if (std.mem.eql(u8, "zsh", exe)) {
|
if (std.mem.eql(u8, "zsh", exe)) {
|
||||||
try setupZsh(resource_dir, env);
|
try setupZsh(resource_dir, env);
|
||||||
return .zsh;
|
break :shell .zsh;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Setup our feature env vars
|
||||||
|
if (!features.cursor) try env.put("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR", "1");
|
||||||
|
|
||||||
|
return shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setup the fish automatic shell integration. This works by
|
/// Setup the fish automatic shell integration. This works by
|
||||||
|
Reference in New Issue
Block a user