Mac OS X Change the Terminal Window Title

Posted September 22, 2004 by macster in Apple Mac

The title of the Mac OS X terminal window can easily be changed. Changing the title can be useful when running a script or when using multiple terminal windows for different purposes in order to identify them easily when switching between applications and windows.


In the terminal window, from a bash prompt (the default shell) or in a bash shell script, use the following command to change the terminal window title to Tech-Recipes rules:

echo -n -e "\033]0;Tech-Recipes rules\007"

You can place (just about) any text in place of “Tech-Recipes rules” including the contents of a variable. Consider the following example:

name=`hostname`
echo -n -e "\033]0;$name\007"

This will change the title of the terminal to the hostname of the computer running the shell.

The Conversation

Follow the reactions below and share your own thoughts.