How can I customize my prompt?
On this page:
Overview
The procedure for customizing your prompt differs depending on whether or not your shell is "bash" or "tcsh". If you're unsure which shell you're using, please see How can I figure out what my default Athena shell is?.
tcsh
Your prompt is determined by the 'prompt' variable which is set for you in your .cshrc file. By default your prompt is set to "athena% " however, you can change it to any string you wish. You can experiment with different prompts by simply typing:
set prompt = 'something'
at your existing prompt. (See below for a list of formatting codes) Once you are happy with your prompt, then you can add the set prompt command to your .cshrc.mine configuration file.
bash
Your prompt is determined by the 'PS1' variable which is set for you in your .bashrc file. By default your prompt is set to "athena$ " however, you can change it to any string you wish. You can experiment with different prompts by simply typing:
PS1='something'
at your existing prompt. (See below for a list of formatting codes) Once you are happy with your prompt, then you can add the set prompt command to your .bashrc.mine configuration file.
Below are some of the available codes you can use in your prompt; for a more complete description and explanation, type "man bash" at your prompt and scroll to the "PROMPTING" section.
Formatting Codes
Here are some of the available codes you can use in your prompt; for a more complete description and explanation, view the appropriate manual page for your shell ("man bash" or "man tcsh")
tcsh | bash | Meaning |
---|---|---|
%~ or %d | \w | Current directory (cwd), replacing $HOME by ~. |
%c or %. | \W | Trailing component of cwd, replacing $HOME with ~. |
%/ | (n/a) | Cwd, no ~ substitution. |
%C | (n/a) | Trailing component of cwd, no ~ substitution. |
%h or %! or ! | \! | Current history event number. |
%M | \h | The full machine hostname. |
%m | \H | The hostname up to the first ".". |
%S (%s) | (n/a) | Start (stop) standout mode. |
%B (%b) | (n/a) | Start (stop) boldfacing mode. |
%U (%u) | (n/a) | Start (stop) underline mode. |
%t or %@ | \@ | Current time of day, in 12-hour, am/pm format. |
%T | \A | Current time of day, in 24-hour format. |
(n/a) | \T | Current time of day, in 12-hour format including seconds |
(n/a) | \t | Current time of day, in 24-hour format including seconds. |
%% | % | A single %. |
\ | \\ | A single \ . |
%n | \u | The user name, contents of $user. |
%k | (n/a) | The weekday in <Day> format. |
%D | (n/a) | The day in dd format. |
%w | (n/a) | The month in <Mon> format. |
%W | (n/a) | The month in mm format. |
%y | (n/a) | The year in yy format. |
%Y | (n/a) | The year in yyyy format. |
(n/a) | \d | The date in "Weekday Month Date" format (e.g. "Tue May 26") |
%l | \l | The line (tty) the user is logged on. |
%L | (n/a) | clear from prompt to end of display or end of line. |
%# | \$ | A `#' if tcsh is run as a root shell, a `>' if not. |
\n | \n | prints a new line |
\t | \t | prints a tab |