GNU screen window title and SSH

If you want to keep track of all your GNU screen sessions, it’s helpful to set the window title to the current machine you ssh‘d into. One way to achieve this is to put this into your .zshrc (.profile should work too):

# Set/reset hostname in screen window title SSH’d machine:
if [ $TERM = “screen” ] ; then
function ssh () {
args=$@
echo -n -e “33k${args##* }33\\”
command ssh “$@”;
echo -n -e “33k${HOST}33\\”
}
# Set it initially for new windows:
echo -n -e “33k${HOST}33\\”
fi

There are other ways, too…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s