Last active
September 12, 2024 07:12
-
-
Save thomascharbonnel/7fe3c1c26c6bad1d7758d1f5f6e18f76 to your computer and use it in GitHub Desktop.
Set tmux pane title to short hostname on ssh connections for Fish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy that into your ~/.config/fish/config.fish | |
function ssh | |
set ps_res (ps -p (ps -p %self -o ppid= | xargs) -o comm=) | |
if [ "$ps_res" = "tmux" ] | |
tmux rename-window (echo $argv | cut -d . -f 1) | |
command ssh "$argv" | |
tmux set-window-option automatic-rename "on" 1>/dev/null | |
else | |
command ssh "$argv" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added some of the recs from the comments and also made this support ssh arguments such as -X or -L.
Note that this version assumes that the first arg not starting with a dash is the hostname, so if will be wrong if you do something like
ssh -L 5901:192.168.1.42:5901 hostname
. Instead, you have to dossh hostname -L 5901.192.168.1.42:5901