Bash-ful Colors

by Robert Daeley

“Colors and Prompts in BASH” is a quick how-to on putting some color and utility into the otherwise austere command line prompt for the popular shell.

Bourne Again Shell offers a lot of power, flexiblity and fun. Many new Unix users do not realize the flexibility of the shell environment; indeed; many new Unix users regard the shell as primitive and too restricted: nothing could be further from the truth. With very little time investment a new Unix user can learn how not to just make their work environment in the shell more productive but even a little fun.

Since bash has been the default shell on Mac OS X for at least a couple of cats now, this guide does the trick for us as well.

At the end, the post links to the mother of all prompt articles, the aptly named “Bash Prompt HOWTO” at faqs.org. Coming in at 140KB and over 17,000 words, this awesome guide will enable you to make all kinds of useful tweaks.

Most Linux systems have a default prompt in one colour (usually gray) that tells you your user name, the name of the machine you’re working on, and some indication of your current working directory. This is all useful information, but you can do much more with the prompt: all sorts of information can be displayed (tty number, time, date, load, number of users, uptime …) and the prompt can use ANSI colours, either to make it look interesting, or to make certain information stand out….

While you're messing around on the command line, go grab a download of the "new" iTerm beta, version 0.9.5. I say "new" since it was released at the beginning of February, but I didn't come across it until yesterday. :) Unfortunately, I kinda got distracted and otherwise occupied right about then, so I missed the update. Only been a day, but it seems to be operating better already. I did trash the old 0.9.0 preference and Application Support files before launching, but I don't know if that was strictly necessary.

(Via rootprompt.org)


2 Comments

Ian
2007-03-12 05:25:16
Wow I did not know about the new version of iTerm, full screen rocks!
Nemo
2007-03-12 11:36:31
I actually prefer Mac's own terminal to the iTerm. I know, I know, people love the tabbed terminals, but I prefer to have multiple terminal windows open rather than one with tabs.


On another note, here is a cool trick. Stick the following line in your .profile file (and remove the title from Mac terminal's own settings), and you get a title that lists the current working directory and changes as you move (i.e. - pwd for wherever you are):


PROMPT_COMMAND='echo -ne "\033]0;${PWD}\007"'


You can stick whatever else you want between {}, e.g. {$USER@$HOST:PWD}. Man I love *nix...