Formatting for the Prompt Variable

tcsh provides a list of substitutions that can be used in formatting the prompt. The list of available substitutions includes:


Literal %.


The present working directory.


The present working directory, in ~ notation.


# for the superuser, > for others.


Previous command’s exit status.

%$ var

The value of the shell or environment variable var.

%{ string %}

Include string as a literal escape sequence to change terminal attributes (but should not move the cursor location); cannot be the last sequence in the prompt.

\c, ^c

Parse c as in the bindkey built-in command.


End boldfacing.


Begin boldfacing.

%c[[0]n], %.[[0]n]

The last n (default 1) components of the present working directory; if a leading 0 is specified, replace removed components with /<skipped>.


Similar to %c, but use full pathnames instead of ~ notation.


Day of the week (e.g., Mon, Tue).


Day of month (e.g., 09, 10).

%h, %!, !

Number of current history event.


The number of jobs.


Current tty.


Clear from the end of the prompt to the end of the display or the line.


First component of hostname.


Fully qualified hostname.




Current time, with seconds (12-hour mode).


Current time, with seconds (24-hour format).


In prompt2, the parser status; in prompt3, the corrected string; and in history, the history string.


End standout mode (reverse video). ...

Get Unix in a Nutshell, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.