This commit is contained in:
Johannes Findeisen 2025-07-23 02:02:50 +02:00
commit 05ed36ac92

View file

@ -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 "$@"