Auto naming terminal tabs

I use Ubuntu on the whole for my desktops and servers and the more recent versions have Byobu which customises Screen rather nicely. I am still running 8.04 LTS on one server at the moment which is too old to have Byobu in the standard repositories (yes it is on my todo list to upgrade!), but one of the most useful features is quite easy to implement without Byobu.

When I have multiple terminal tabs open with various local and remote (via SSH) command lines running it is nice to know which is which. Byobu thoughtfully changes the title as you log in, but Screen does not (I have both configured to automatically launch when I log in). One line added to my .bash_profile does the trick though:


printf "\033]0;${USER}@$(hostname) - screen\007"
screen -xRR

The first printf line is the one that does the trick and tells me who I’ve logged in as and to what machine, as well as reminding me I’m in Screen. The second screen line simply starts Screen if it is not already running, or connects to the existing instance if it is.

Leave a Comment

Your email address will not be published. Required fields are marked *