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.

%b

End boldfacing.

%B

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>.

%C

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

%d

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

%D

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

%h, %!, !

Number of current history event.

%j

The number of jobs.

%l

Current tty.

%L

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

%m

First component of hostname.

%M

Fully qualified hostname.

%n

Username.

%p

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

%P

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

%R

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

%s

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.