From 675bd7c85727621dccc9ea014082b1317859f4cf Mon Sep 17 00:00:00 2001 From: hanez Date: Wed, 23 Jul 2025 01:53:01 +0200 Subject: [PATCH] zsh --- .zsh/functions.d/s.sh | 25 +++++++++++++++++++++++-- .zshrc | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.zsh/functions.d/s.sh b/.zsh/functions.d/s.sh index aeb62923..67a3db0e 100644 --- a/.zsh/functions.d/s.sh +++ b/.zsh/functions.d/s.sh @@ -19,8 +19,29 @@ s() { # 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 +} + +sshr() { + if [ -n "$TMUX" ]; then + local original_name + original_name=$(tmux display-message -p '#W') + + local ssh_host="$1" + ssh_host="${ssh_host#*@}" + ssh_host="${ssh_host%%:*}" + ssh_host="${ssh_host%% *}" + + # Emit title update BEFORE ssh + printf '\033k%s\033\\' "${ssh_host%%.*}" + + command ssh "$@" + + else command ssh "$@" fi diff --git a/.zshrc b/.zshrc index c8c5ef0b..686c23d7 100644 --- a/.zshrc +++ b/.zshrc @@ -2,6 +2,7 @@ source ~/.env # Source some private stuff or custom things that are different on my systems. +# This file is not in the Git repository! source ~/.penv # Do some exports!