This solution is a little hackish, but I think it will do what you're looking for. You will need xdotool
and wmctrl
installed for this to work.
First you have to edit your ~/.bashrc
file because by default the terminal resets its title after every line, rendering command line title sets useless.
Right after: xterm*|rxvt*)
Replace: PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
With: PS1="${debian_chroot:+($debian_chroot)}\u@\h \w\a$ "
Next we're going to create a custom ssh
script called whatever you want, but for this answer I'll be calling mine tab-ssh
. Open a text editor and save the following as tab-ssh
:
#!/usr/bin/env bash
WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
xdotool windowfocus $WID
xdotool key ctrl+shift+t
wmctrl -i -a $WID
sleep 1
title=$(echo "$*" | sed s/.*@//g)
xdotool type --delay 1 --clearmodifiers 'echo -en "\033]0;"'"${title}"'"\a"'
xdotool key Return
sleep 1
xdotool type --delay 1 --clearmodifiers "ssh $*"
xdotool key Return
Then make it executable:
chmod +x tab-ssh
Now, assuming you're using bash
and gnome-terminal
, running the script should open a new tab, rename it, and start the ssh
session. For exmaple:
tab-ssh [email protected]
will open a new tab, rename it to 0.0.0.0
(i.e. everything following the "@" sign), then execute [email protected]
.
Created using the following:
user@hostname
on the first host i connect. i would like to see the ip address. also, if i jump fromserver1
toserver2
, the tab doesn't change names.