diff --git a/.zsh/functions.d/s.sh b/.zsh/functions.d/s.sh index 2e26ea3a..c5acccdb 100644 --- a/.zsh/functions.d/s.sh +++ b/.zsh/functions.d/s.sh @@ -13,14 +13,11 @@ s() { tmux rename-window "${ssh_host%%.*}" # short hostname - # Emit title update BEFORE ssh - printf '\033k%s\033\\' "${ssh_host%%.*}" - # Run SSH session command ssh "$@" - # Restore after disconnect - printf '\033k%s\033\\' "$original_name" + # Restore previous tmux window name + tmux rename-window "$original_name" else command ssh "$@" fi @@ -36,14 +33,12 @@ sshr() { ssh_host="${ssh_host%%:*}" ssh_host="${ssh_host%% *}" + # Emit title update BEFORE ssh printf '\033k%s\033\\' "${ssh_host%%.*}" - # Set up trap to restore title even if interrupted - trap 'printf "\033k%s\033\\n" "$original_name"' EXIT - command ssh "$@" - trap - EXIT # cleanup trap if ssh exited normally + # Restore after disconnect printf '\033k%s\033\\' "$original_name" else command ssh "$@"