How do I change the title bar of a Mac OS/X Terminal window?

By Alvin J. Alexander, devdaily.com

I've been working on a project where I have three Mac OS X Terminal windows open at one time, and I found it was much easier to work this way when I changed the title of each Terminal window to identify what I was doing in each window.

The basic escape sequence you need is this:

echo -n -e "\033]0;YOUR TITLE HERE\007"

When you issue this command from the command line of a Terminal window it will change the title in the Terminal's title bar to "YOUR TITLE HERE."

In the real world ... what I did was label one of my Terminal windows as "CLIENT", one as "SERVER", and the other as "BUILD". I did this by issuing commands like this:

Terminal window #1:

echo -n -e "\033]0;CLIENT\007"

Terminal window #2:

echo -n -e "\033]0;SERVER\007"

Terminal window #3:

echo -n -e "\033]0;BUILD\007"

Note that you can also create a Bourne shell (bash) function to make this process easier, i.e., so you can just type maketitle "SERVER". I'll cover the creation of that shell script in a future tip.


devdaily logo