shell-integration: simplify "ssh target" checks

This value is always set to a non-empty string, and we only need this
value after we've determined that 'ssh_hostname' is non-empty.

In bash and zsh, we also don't need to check for the 'ghostty' command
before we attempt to add the target to the cache. That command will
safely fail silently if it's not available.
This commit is contained in:
Jon Parise
2025-07-09 15:59:59 -04:00
parent 9ba9e29843
commit e522d54d7b
4 changed files with 10 additions and 14 deletions

View File

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