Jamie Hill
Photo of Jamie Hill

UX Designer, CSS Wizard, Ruby on Rails Developer.

Naming your Terminal tabs in OSX

If you find yourself in the Terminal app with a bunch of tabs open, the default name of “bash” isn’t very useful when navigating between them.

You can change the tab name via the UI by right clicking the tab, then clicking “Inspect Tab” and changing the window or tab names but this is somewhat long winded.

Below are a couple of bash functions I have in my “.profile” file to make this easier:

function tabname {
  # Uses current dir name if called without arg.
  printf "\e]1;${1-$(basename `pwd`)}\a"
}
function winname {
  # Uses current dir name if called without arg.
  printf "\e]2;${1-$(basename `pwd`)}\a"
}

Now you can easily name your tabs or windows with the following:

Rename tab

tabname “Funky Tab”

Rename window

winname “Funky Window”  

Thanks to Bubu and Chris Page on the SuperUser site for the right codes.