[machinename:~] username%
You can modify the prompt with the set prompt = command (subtle, I know!). Over on the MacNN forums, this thread includes a great tutorial (written by blanalex) on how to generate some unique and useful prompt strings, including those with colored foregrounds and backgrounds.
I've reproduced the final how-to from the discussion in the remainder of this article, in case the MacNN posting goes away anytime soon.
Posted by blanalex on 01-05-2001 02:26 PM
------------------------------------------------------------------------
"Here's the quick-and-dirty tcsh prompt how-to!
1- The first thing I suggest is to consult the man page of tcsh, in the ``Special Shell Variables'' somewhat near the end. There you will see what are the special symbols that can be used in the prompt. The most used symbols are:
%/ Current working directory
%~ Same as the above, but it will replace /Users/Username with ~
%M FQDN (fully qualified domain name, such as panoramix.scoeur.csvdc.qc.ca)
%m domain name (the 'panoramix' part in the adress above)
%t,%T time of the day in 12- and 24-hour format respectively
%p,%P time of the day, with seconds, in 12- and 24-hour format respectively
%n user name
%# 'default' character prompt:
expands to '$' for normal users
expands to '#' for root user
2- Using those symbols you can start to play a bit:
set PROMPT="[%m:%c3] %n%#"
is the default prompt is tcsh
set PROMPT="[%T][%n@%m %c3] %#"
gives my favorite prompt, such as: [13:40][blanalex@panoramix ~] $
To save your new prompt, you just have to write your set PROMPT= in ~/.tcshrc, and now each time you will open a terminal window, your prompt will be displayed.
3- Colors
Now when you want to add colors to your prompt, you have to use ANSI sequences. Those are a bit more complicated to use, but we'll get through.
There is many ANSI commands. There's some commands to move the cursors, others to assign command to keys, others to set the title of the terminal window, other to set the graphic mode and many, many others.
For changing the graphic mode (mainly the color and the background of the text), the ANSI command is 'm'.
For using ANSI commands in your prompt, you must inclose them between %{ and %} to tell tcsh that the text between those two delimiters will not be displayed. All ANSI sequences begins with \033[ and there is no special ending delimiter other than the command itself
So for example, if you want your prompt to be blue, you would have to do:
set PROMPT="%{\033[34m%}[%T][%n@%m %c3] %#"
First, you see the %{\033[34m%} at the beginning to put the text in blue and you may remark near the end the %{\033[0m%} to reset the graphic mode and return to normal (grey) text.
The color codes you can use with this ANSI command are the following:
0 Reset colors to 37;40
1 Bold text. In reality, it's not really bold, text is only brighter.
5 Blinking text. Many terminal apps don't support this
7 Reverse video, inverts the background and the foreground colors
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
40 Black background
41 Red background
42 Green background
43 Yellow background
44 Blue background
45 Magenta background
46 Cyan background
47 White background
You can combine many color codes in the same command by separating them with a semi-comma (';'), for example, to have a bright blue text on red background you would insert this : %{\033[1;34;41m%}
That's it for this how-to, for more information, I suggest you to read the Bash Prompt Howto, because, almost all the magic is the same between the two, only some variable changes."

