Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

A4orce84

macrumors 6502
Original poster
Apr 17, 2012
433
46
Hey Everyone,

I've been trying to figure out how to get the hostnames of servers I ssh into as titles on my Terminal Tabs like Linux does:

Linux Terminal:
ethdisable.png


OSX Terminal:
TerminalTabNames.png


As you can see having tabs that say "ssh" isn't really useful when I have multiple tabs open with ssh connections in each one. I've found the following instructions online on how to update this automagically here:
http://www.cnet.com/news/how-to-use-ssh-host-names-for-tabs-in-the-os-x-terminal/

But it doesn't seem to be working in mavericks correctly. Has anyone gotten this working? Ideally, I just want to SSH into any server, and automagically have the title update to user@host in my title bar.

Any help would be greatly appreciated, thanks guys!

--Asif
 
My tabs are getting the username and server name in them when I ssh to my Linux box. I didn't do anything special to set that up. It just seems to be happening. It's a little annoying because when I disconnect the tab title does not clear. It stays as 'uuuuu@host:~'

This implies to me that the tab name is getting set from the shell on the remote host, not the local one. My guess would be that the 'set status string' control sequence must be getting sent from the remote host. Maybe from SSH or bash on the remote host. Not sure which.

Quick edit... I found something which may be contributing. On my Linux box, I noticed the following env variable in bash:

Code:
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'

Yep, just confirmed this on my Terminal window. When I exported the PROMPT_COMMAND variable on the Mac bash, it started updating the tab with the information. So it appears you should set that env variable on the host you are connecting to. Edit as you see fit.

Also, that variable is a feature of bash. So if you aren't using bash on the remote machine, it's not going to work unless there are similar features in other shells. Read man pages as appropriate.
 
Last edited:
Thanks mfram! That was EXACTLY what I needed. I exported that command to my "remote" .bash_profile, so now the specific boxes I ssh into, my tabs update auto-magically. THANK YOU SIR!!!!!!!! =)

Follow-up Question: If you find out a way to clear the tabs (when I exit back into my local Mac), please let me know.

Thanks again,
Asif
 
Last edited:
echo -ne "\033]0;\007" will clear the title banner.

Make an alias for it, or, .bash_logout file.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.