shell-integration: simplify "ssh target" checks (#7884)

This commit is contained in:
Jon Parise
2025-07-09 16:32:11 -04:00
committed by GitHub
4 changed files with 10 additions and 14 deletions

View File

@ -120,9 +120,9 @@ if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-* ]]; then
[[ -n "$ssh_user" && -n "$ssh_hostname" ]] && break [[ -n "$ssh_user" && -n "$ssh_hostname" ]] && break
done < <(builtin command ssh -G "$@" 2>/dev/null) done < <(builtin command ssh -G "$@" 2>/dev/null)
if [[ -n "$ssh_hostname" ]]; then
builtin local ssh_target="${ssh_user}@${ssh_hostname}" builtin local ssh_target="${ssh_user}@${ssh_hostname}"
if [[ -n "$ssh_hostname" ]]; then
# Check if terminfo is already cached # Check if terminfo is already cached
if ghostty +ssh-cache --host="$ssh_target" >/dev/null 2>&1; then if ghostty +ssh-cache --host="$ssh_target" >/dev/null 2>&1; then
ssh_term="xterm-ghostty" ssh_term="xterm-ghostty"
@ -147,9 +147,7 @@ if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-* ]]; then
ssh_opts+=(-o "ControlPath=$ssh_cpath") ssh_opts+=(-o "ControlPath=$ssh_cpath")
# Cache successful installation # Cache successful installation
if [[ -n "$ssh_target" ]] && builtin command -v ghostty >/dev/null 2>&1; then
ghostty +ssh-cache --add="$ssh_target" >/dev/null 2>&1 || true ghostty +ssh-cache --add="$ssh_target" >/dev/null 2>&1 || true
fi
else else
builtin echo "Warning: Failed to install terminfo." >&2 builtin echo "Warning: Failed to install terminfo." >&2
fi fi

View File

@ -137,9 +137,9 @@
} }
} }
if (not-eq $ssh-hostname "") {
var ssh-target = $ssh-user"@"$ssh-hostname var ssh-target = $ssh-user"@"$ssh-hostname
if (not-eq $ssh-hostname "") {
# Check if terminfo is already cached # Check if terminfo is already cached
if (and (has-external ghostty) (bool ?(external ghostty +ssh-cache --host=$ssh-target >/dev/null 2>&1))) { if (and (has-external ghostty) (bool ?(external ghostty +ssh-cache --host=$ssh-target >/dev/null 2>&1))) {
set ssh-term = "xterm-ghostty" set ssh-term = "xterm-ghostty"
@ -167,7 +167,7 @@
set ssh-opts = (conj $ssh-opts -o ControlPath=$ssh-cpath) set ssh-opts = (conj $ssh-opts -o ControlPath=$ssh-cpath)
# Cache successful installation # Cache successful installation
if (and (not-eq $ssh-target "") (has-external ghostty)) { if (has-external ghostty) {
external ghostty +ssh-cache --add=$ssh-target >/dev/null 2>&1 external ghostty +ssh-cache --add=$ssh-target >/dev/null 2>&1
} }
} else { } else {

View File

@ -149,7 +149,7 @@ function __ghostty_setup --on-event fish_prompt -d "Setup ghostty integration"
set -a ssh_opts -o "ControlPath=$ssh_cpath" set -a ssh_opts -o "ControlPath=$ssh_cpath"
# Cache successful installation # Cache successful installation
if test -n "$ssh_target"; and command -q ghostty if command -q ghostty
ghostty +ssh-cache --add="$ssh_target" >/dev/null 2>&1; or true ghostty +ssh-cache --add="$ssh_target" >/dev/null 2>&1; or true
end end
else else

View File

@ -272,9 +272,9 @@ _ghostty_deferred_init() {
[[ -n "$ssh_user" && -n "$ssh_hostname" ]] && break [[ -n "$ssh_user" && -n "$ssh_hostname" ]] && break
done < <(command ssh -G "$@" 2>/dev/null) done < <(command ssh -G "$@" 2>/dev/null)
if [[ -n "$ssh_hostname" ]]; then
local ssh_target="${ssh_user}@${ssh_hostname}" local ssh_target="${ssh_user}@${ssh_hostname}"
if [[ -n "$ssh_hostname" ]]; then
# Check if terminfo is already cached # Check if terminfo is already cached
if (( $+commands[ghostty] )) && ghostty +ssh-cache --host="$ssh_target" >/dev/null 2>&1; then if (( $+commands[ghostty] )) && ghostty +ssh-cache --host="$ssh_target" >/dev/null 2>&1; then
ssh_term="xterm-ghostty" ssh_term="xterm-ghostty"
@ -299,9 +299,7 @@ _ghostty_deferred_init() {
ssh_opts+=(-o "ControlPath=$ssh_cpath") ssh_opts+=(-o "ControlPath=$ssh_cpath")
# Cache successful installation # Cache successful installation
if [[ -n "$ssh_target" ]] && (( $+commands[ghostty] )); then
ghostty +ssh-cache --add="$ssh_target" >/dev/null 2>&1 || true ghostty +ssh-cache --add="$ssh_target" >/dev/null 2>&1 || true
fi
else else
print "Warning: Failed to install terminfo." >&2 print "Warning: Failed to install terminfo." >&2
fi fi