mirror of
https://gitea.zaclys.com/yannic/dotfiles.git
synced 2026-06-15 11:11:57 +02:00
Change Tmux title on SSH client connection
This commit is contained in:
+28
-7
@@ -92,13 +92,34 @@ fi
|
|||||||
alias cdd='cd {{ .deploydir }}'
|
alias cdd='cd {{ .deploydir }}'
|
||||||
export cdd={{ .deploydir }}
|
export cdd={{ .deploydir }}
|
||||||
|
|
||||||
sshloop() {
|
# ---------------------------------------------------------------------------
|
||||||
while :
|
# TMUX
|
||||||
do
|
# ---------------------------------------------------------------------------
|
||||||
ssh $1
|
|
||||||
echo "Reconnection in 5 seconds"
|
# Function to set tmux window title
|
||||||
sleep 5
|
function set_tmux_title {
|
||||||
done
|
if [ -n "$TMUX" ]; then
|
||||||
|
tmux rename-window "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# SSH wrapper to change the tmux title locally
|
||||||
|
function ssh() {
|
||||||
|
if [ -n "$TMUX" ]; then
|
||||||
|
# Save the original tmux window title
|
||||||
|
original_title=$(tmux display-message -p '#W')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change tmux title before connecting
|
||||||
|
set_tmux_title "SSH: $1"
|
||||||
|
|
||||||
|
# Run the actual ssh command with all arguments
|
||||||
|
command ssh "$@"
|
||||||
|
|
||||||
|
# Restore the original tmux window title after disconnecting
|
||||||
|
if [ -n "$TMUX" ]; then
|
||||||
|
set_tmux_title "$original_title"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user