How to set the MacOS Terminal title | Mac Terminal titlebar

I like to set the title (titlebar) on the MacOS Terminal application so I can tell one tab from another. For instance, I may have the Play Framework running in one tab, SBT in another, Git in another, etc. Setting the title on each Terminal tab makes my life a little easier.

To set the Terminal title, I use a script I’ve named settitle:


# settitle: set the Mac Terminal title
# usage:    to set the titlebar to 'PLAY', type:  settitle PLAY

echo "\033]0;${1}\007\c"

This lets me set the Terminal titlebar like this:

$ settitle PLAY

and this:

$ settitle GIT

I typically use all-caps to make the titles stand out, but do whatever you like best.

The important part of this post is knowing about the magic echo command. You can also use AppleScript to achieve the same effect, but using echo is easier.