From 69554f414c1402a69d4648952aa13ad5bf43b673 Mon Sep 17 00:00:00 2001 From: John Mars Date: Sun, 15 Mar 2026 01:50:32 -0400 Subject: [PATCH] shell-integration: fix ssh-env SetEnv clobbering user SSH config --- src/shell-integration/bash/ghostty.bash | 5 ++--- src/shell-integration/elvish/lib/ghostty-integration.elv | 5 ++--- .../fish/vendor_conf.d/ghostty-shell-integration.fish | 5 ++--- src/shell-integration/nushell/vendor/autoload/ghostty.nu | 4 ++-- src/shell-integration/zsh/ghostty-integration | 5 ++--- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/shell-integration/bash/ghostty.bash b/src/shell-integration/bash/ghostty.bash index 48c89164b..4be662ddf 100644 --- a/src/shell-integration/bash/ghostty.bash +++ b/src/shell-integration/bash/ghostty.bash @@ -123,8 +123,7 @@ if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-* ]]; then # Configure environment variables for remote session if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-env* ]]; then - ssh_opts+=(-o "SetEnv COLORTERM=truecolor") - ssh_opts+=(-o "SendEnv TERM_PROGRAM TERM_PROGRAM_VERSION") + ssh_opts+=(-o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION") fi # Install terminfo on remote host if needed @@ -180,7 +179,7 @@ if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-* ]]; then fi # Execute SSH with TERM environment variable - TERM="$ssh_term" builtin command ssh "${ssh_opts[@]}" "$@" + TERM="$ssh_term" COLORTERM=truecolor builtin command ssh "${ssh_opts[@]}" "$@" } fi diff --git a/src/shell-integration/elvish/lib/ghostty-integration.elv b/src/shell-integration/elvish/lib/ghostty-integration.elv index 87fd0a902..31ebf0941 100644 --- a/src/shell-integration/elvish/lib/ghostty-integration.elv +++ b/src/shell-integration/elvish/lib/ghostty-integration.elv @@ -83,8 +83,7 @@ # Configure environment variables for remote session if (has-value $features ssh-env) { set ssh-opts = (conj $ssh-opts ^ - -o "SetEnv COLORTERM=truecolor" ^ - -o "SendEnv TERM_PROGRAM TERM_PROGRAM_VERSION") + -o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION") } if (has-value $features ssh-terminfo) { @@ -148,7 +147,7 @@ } } - with [E:TERM = $ssh-term] { + with [E:TERM = $ssh-term E:COLORTERM = truecolor] { (external ssh) $@ssh-opts $@args } } diff --git a/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish b/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish index 3f1f6099e..f8bfe0910 100644 --- a/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish +++ b/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish @@ -129,8 +129,7 @@ function __ghostty_setup --on-event fish_prompt -d "Setup ghostty integration" # Configure environment variables for remote session if contains ssh-env $features - set -a ssh_opts -o "SetEnv COLORTERM=truecolor" - set -a ssh_opts -o "SendEnv TERM_PROGRAM TERM_PROGRAM_VERSION" + set -a ssh_opts -o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION" end # Install terminfo on remote host if needed @@ -198,7 +197,7 @@ function __ghostty_setup --on-event fish_prompt -d "Setup ghostty integration" end # Execute SSH with TERM environment variable - TERM="$ssh_term" command ssh $ssh_opts $argv + TERM="$ssh_term" COLORTERM=truecolor command ssh $ssh_opts $argv end end diff --git a/src/shell-integration/nushell/vendor/autoload/ghostty.nu b/src/shell-integration/nushell/vendor/autoload/ghostty.nu index 78c981ebe..17970f513 100644 --- a/src/shell-integration/nushell/vendor/autoload/ghostty.nu +++ b/src/shell-integration/nushell/vendor/autoload/ghostty.nu @@ -12,9 +12,9 @@ export module ghostty { # `ssh-env`: use xterm-256color and propagate COLORTERM/TERM_PROGRAM vars if (has_feature "ssh-env") { $ssh_env.TERM = "xterm-256color" + $ssh_env.COLORTERM = "truecolor" $ssh_opts = [ - "-o" "SetEnv COLORTERM=truecolor" - "-o" "SendEnv TERM_PROGRAM TERM_PROGRAM_VERSION" + "-o" "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION" ] } diff --git a/src/shell-integration/zsh/ghostty-integration b/src/shell-integration/zsh/ghostty-integration index dc9bd1605..c55b2f51d 100644 --- a/src/shell-integration/zsh/ghostty-integration +++ b/src/shell-integration/zsh/ghostty-integration @@ -325,8 +325,7 @@ _ghostty_deferred_init() { # Configure environment variables for remote session if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-env* ]]; then - ssh_opts+=(-o "SetEnv COLORTERM=truecolor") - ssh_opts+=(-o "SendEnv TERM_PROGRAM TERM_PROGRAM_VERSION") + ssh_opts+=(-o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION") fi # Install terminfo on remote host if needed @@ -382,7 +381,7 @@ _ghostty_deferred_init() { fi # Execute SSH with TERM environment variable - TERM="$ssh_term" command ssh "${ssh_opts[@]}" "$@" + TERM="$ssh_term" COLORTERM=truecolor command ssh "${ssh_opts[@]}" "$@" } fi