Using Your Prompt

The default prompt string is usually % or >, which is pretty dull. This section illustrates some ways to make your prompt more informative.

You set your prompt by assigning a value to the prompt shell variable. The following command sets the prompt to the string Yeah?:

set prompt = "Yeah? "

The quotes prevent the shell from interpreting the ? as a filename pattern character and allow the trailing space to be included in the prompt.

It's best to experiment with set prompt commands from the command line. When you find a prompt that you like, put it in your ˜/.cshrc file, replacing any existing prompt setting. (You should also delete any set prompt command you find in your ˜/.login file.)

One simple way to make your prompt more useful is to include the current command number, by putting \! in the prompt string:

% set prompt = "\! -> "          Set prompt to command number followed by ->
44   -> echo hello
hello
45  -> date
Fri Apr 28 23:32:21 CDT 1995
46  ->

A prompt that includes the command number makes it easier to use !n to repeat commands that are still visible on your screen, because you can also see the command numbers.

Using tcsh Prompt Formatting Sequences

Interpreting \! in the prompt string is the only special thing that csh can do. tcsh can do that and more, using special formatting sequences in the string. Some of the possibilities are illustrated below. (The tcsh manual page lists all available sequences.)

Put a clock in your prompt

The sequence %t displays the time. %p

Get Using csh & tcsh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.