Inspired by this question, I wanted to try to change my command prompt in this manner

  1. Enter this line into ~/.cshrc

    a. setenv PS1 "\[\e[32m\][\[\e[m\]\[\e[31m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]:\[\e[36m\]\w\[\e[m\]\[\e[32m\]]\[\e[m\]\[\e[32;47m\]\\$\[\e[m\] "

    b. I used setenv because it is the csh equivalent of export and is the closest thing to this procedure, which uses the bash command export.

  2. Source ~/.cshrc

However, this did not work. setenv threw the error:

Variable name must contain alphanumeric characters.


How do I change my cshell prompt to modify the colors and what text is displayed?

1 Answer 1


For csh or tcsh, the environment variable PS1 is meaningless: the prompt is actually configured using a shell variable named prompt.

So the syntax you'll need is:

set prompt = "your prompt string here"

Also, the list of prompt formatting sequences is different: for example, while bash uses \[...\] to indicate sequences of non-printing characters, csh might not have an equivalent at all, and tcsh uses %{ ... %} instead.

Google can find you a lot of tcsh-specific examples, like this question here on Unix&Linux.SE and this very well commented example. This might be helpful too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .