The new Terminal.app on Leopard finally delivers tabbed command line goodness to Mac users. It is a welcome feature that I’ve been using with gusto.
But, if you use the new Terminal with any sort of regularity you’ve probably run into the confusing situation where you have multiple shell sessions open in various Terminal windows or tabs, each logged into a different server, user account, or local folder.
How do you keep them straight? How do you tell the difference between the session logged in as root on your web server vs. the one logged in as a guest user on your local Mac?
While looking for a solution, I found this article on IBM’s developerWorks site: Tip: Prompt Magic. The article describes all kinds of shell prompt trickery that lets you customize the UNIX shell prompt with colors, host names, paths, and even dates.
If you don’t feel like reading through all the technical details of the article, here is a quick copy and paste solution that will give you a simple, but informative shell prompt and change your Terminal window’s title to display host and location information for easy identification.
Copy and paste the following lines into the file named “.bash_profile” in your user’s home directory. You will need to create the file if it doesn’t already exist.
# Set title and prompt: "username@hostname/directory/tree $ "
export PS1="[e]2;u@H wae[34mu@H:w $e[0m "
Once the file is saved, type the following command into the command line to apply the new settings.
. .bash_profile
You’ll need to follow these steps with each user account you use on your local and remote machines.
Now you should have less trouble identifying where and how you are logged in through Terminal.app.
Comments
One response to “Quick Tip: Terminal.app”
Nice tip, thanks!