change: migrate SSH integration from standalone option to shell-integration-features flags

- Add ssh_env and ssh_terminfo flags to ShellIntegrationFeatures
- Remove SSHIntegration enum and ssh-integration config option
- Update setupFeatures to handle new flags via reflection
- Remove setupSSHIntegration function and all references

Integrates SSH functionality into existing shell-integration-features
system for better consistency and user control.
This commit is contained in:
Jason Rayne
2025-06-23 22:34:32 -07:00
parent ddd3da487e
commit e73313ed40
5 changed files with 11 additions and 55 deletions

View File

@ -545,7 +545,6 @@ pub fn init(
.env_override = config.env, .env_override = config.env,
.shell_integration = config.@"shell-integration", .shell_integration = config.@"shell-integration",
.shell_integration_features = config.@"shell-integration-features", .shell_integration_features = config.@"shell-integration-features",
.ssh_integration = config.@"ssh-integration",
.working_directory = config.@"working-directory", .working_directory = config.@"working-directory",
.resources_dir = global_state.resources_dir.host(), .resources_dir = global_state.resources_dir.host(),
.term = config.term, .term = config.term,

View File

@ -33,7 +33,6 @@ pub const RepeatableStringMap = @import("config/RepeatableStringMap.zig");
pub const RepeatablePath = Config.RepeatablePath; pub const RepeatablePath = Config.RepeatablePath;
pub const Path = Config.Path; pub const Path = Config.Path;
pub const ShellIntegrationFeatures = Config.ShellIntegrationFeatures; pub const ShellIntegrationFeatures = Config.ShellIntegrationFeatures;
pub const SSHIntegration = Config.SSHIntegration;
pub const WindowPaddingColor = Config.WindowPaddingColor; pub const WindowPaddingColor = Config.WindowPaddingColor;
pub const BackgroundImagePosition = Config.BackgroundImagePosition; pub const BackgroundImagePosition = Config.BackgroundImagePosition;
pub const BackgroundImageFit = Config.BackgroundImageFit; pub const BackgroundImageFit = Config.BackgroundImageFit;

View File

@ -1972,39 +1972,17 @@ keybind: Keybinds = .{},
/// ///
/// * `title` - Set the window title via shell integration. /// * `title` - Set the window title via shell integration.
/// ///
/// * `ssh-env` - Enable SSH environment variable compatibility. Automatically
/// converts TERM from `xterm-ghostty` to `xterm-256color` when connecting to
/// remote hosts and propagates COLORTERM, TERM_PROGRAM, and TERM_PROGRAM_VERSION.
///
/// * `ssh-terminfo` - Enable automatic terminfo installation on remote hosts.
/// Attempts to install Ghostty's terminfo entry using `infocmp` and `tic` when
/// connecting to hosts that lack it.
///
/// Example: `cursor`, `no-cursor`, `sudo`, `no-sudo`, `title`, `no-title` /// Example: `cursor`, `no-cursor`, `sudo`, `no-sudo`, `title`, `no-title`
@"shell-integration-features": ShellIntegrationFeatures = .{}, @"shell-integration-features": ShellIntegrationFeatures = .{},
/// SSH integration configuration for shell integration.
///
/// When enabled (any value other than `off`), Ghostty replaces the `ssh` command
/// with a shell function to provide enhanced terminal compatibility and feature
/// propagation when connecting to remote hosts. Users can verify this by running
/// `type ssh` which will show "ssh is a shell function" instead of the binary path.
///
/// Allowable values are:
///
/// * `off` - No SSH integration, use standard ssh binary.
///
/// * `term-only` - Automatically converts TERM from `xterm-ghostty` to `xterm-256color`
/// when connecting to remote hosts. This prevents "unknown terminal type" errors
/// on systems that lack Ghostty's terminfo entry, but sacrifices Ghostty-specific
/// terminal features like enhanced cursor reporting and shell integration markers.
/// See: https://ghostty.org/docs/help/terminfo
///
/// * `basic` - TERM compatibility fix plus environment variable propagation.
/// Forwards `GHOSTTY_SHELL_FEATURES` to enable shell integration features on
/// remote systems that have Ghostty installed and configured.
///
/// * `full` - All basic features plus automatic terminfo installation. Attempts
/// to install Ghostty's terminfo entry on the remote host using `infocmp` and `tic`,
/// then connects with full `xterm-ghostty` support. Requires two SSH authentications
/// (one for installation, one for the session) but enables complete Ghostty
/// terminal functionality on the remote system.
///
/// The default value is `off`.
@"ssh-integration": SSHIntegration = .off,
/// 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), OSC 11 (background), and /// Ghostty currently supports OSC 10 (foreground), OSC 11 (background), and
/// OSC 4 (256 color palette) queries, and by default the reported values /// OSC 4 (256 color palette) queries, and by default the reported values
@ -6126,14 +6104,8 @@ pub const ShellIntegrationFeatures = packed struct {
cursor: bool = true, cursor: bool = true,
sudo: bool = false, sudo: bool = false,
title: bool = true, title: bool = true,
}; @"ssh-env": bool = false,
@"ssh-terminfo": bool = false,
/// See ssh-integration
pub const SSHIntegration = enum {
off,
@"term-only",
basic,
full,
}; };
/// OSC 4, 10, 11, and 12 default color reporting format. /// OSC 4, 10, 11, and 12 default color reporting format.

View File

@ -733,7 +733,6 @@ pub const Config = struct {
env_override: configpkg.RepeatableStringMap = .{}, env_override: configpkg.RepeatableStringMap = .{},
shell_integration: configpkg.Config.ShellIntegration = .detect, shell_integration: configpkg.Config.ShellIntegration = .detect,
shell_integration_features: configpkg.Config.ShellIntegrationFeatures = .{}, shell_integration_features: configpkg.Config.ShellIntegrationFeatures = .{},
ssh_integration: configpkg.SSHIntegration,
working_directory: ?[]const u8 = null, working_directory: ?[]const u8 = null,
resources_dir: ?[]const u8, resources_dir: ?[]const u8,
term: []const u8, term: []const u8,
@ -938,7 +937,6 @@ const Subprocess = struct {
&env, &env,
force, force,
cfg.shell_integration_features, cfg.shell_integration_features,
cfg.ssh_integration,
) orelse { ) orelse {
log.warn("shell could not be detected, no automatic shell integration will be injected", .{}); log.warn("shell could not be detected, no automatic shell integration will be injected", .{});
break :shell default_shell_command; break :shell default_shell_command;

View File

@ -45,7 +45,6 @@ pub fn setup(
env: *EnvMap, env: *EnvMap,
force_shell: ?Shell, force_shell: ?Shell,
features: config.ShellIntegrationFeatures, features: config.ShellIntegrationFeatures,
ssh_integration: config.SSHIntegration,
) !?ShellIntegration { ) !?ShellIntegration {
const exe = if (force_shell) |shell| switch (shell) { const exe = if (force_shell) |shell| switch (shell) {
.bash => "bash", .bash => "bash",
@ -71,9 +70,8 @@ pub fn setup(
exe, exe,
); );
// Setup our feature env vars and SSH integration // Setup our feature env vars
try setupFeatures(env, features); try setupFeatures(env, features);
try setupSSHIntegration(env, ssh_integration);
return result; return result;
} }
@ -161,7 +159,6 @@ test "force shell" {
&env, &env,
shell, shell,
.{}, .{},
.off,
); );
try testing.expectEqual(shell, result.?.shell); try testing.expectEqual(shell, result.?.shell);
} }
@ -227,15 +224,6 @@ test "setup features" {
} }
} }
pub fn setupSSHIntegration(
env: *EnvMap,
ssh_integration: config.SSHIntegration,
) !void {
if (ssh_integration != .off) {
try env.put("GHOSTTY_SSH_INTEGRATION", @tagName(ssh_integration));
}
}
/// Setup the bash automatic shell integration. This works by /// Setup the bash automatic shell integration. This works by
/// starting bash in POSIX mode and using the ENV environment /// starting bash in POSIX mode and using the ENV environment
/// variable to load our bash integration script. This prevents /// variable to load our bash integration script. This prevents