3

I can change the text color in the terminal permanently by adding this:

export PS1="\e[0;31m[\u@\h \W]\$ \e[m"

to the .bashrc file.

Now I have to go into cshell, what is the corresponding way?

3
  • Are you using csh or tcsh?
    – terdon
    Jan 23 '14 at 17:26
  • csh is the shell taht I am using.
    – colddie
    Jan 24 '14 at 15:49
  • I'm not sure that csh supports colors, does Anthon's solution work for you?
    – terdon
    Jan 24 '14 at 15:57
2

Setting the prompt is done with:

set prompt="some string"

in your case you need to notify csh that certain elements have zero width by enclosing them in {% and %}:

set prompt="\n%{\e[0;31m%}\[`whoami`\@`hostname -s` $PWD:t\]$ %{\e[m%}"

You can find some more info and comparison of in this table, on that page you also find some info on the various colours.

The C-shell (both csh and tcsh) equivalent of .bashrc is .cshrc. Create it, if it doesn't exist, and add that line to it.

4
  • These don't work for me on csh (they do for tcsh), I also get this error: CWD: Undefined variable.
    – terdon
    Jan 23 '14 at 17:26
  • @terdon, I fixed the obvious errors, but I don't have a real csh installed to test.
    – Anthon
    Jan 23 '14 at 17:39
  • I've never used csh but I have it installed and none of the examples I find online allow me to color the prompt. They, like yours, actually print instead of interpreting the escape codes. Perhaps this is not possible on pure csh.
    – terdon
    Jan 23 '14 at 17:41
  • @terdon It's been 25+ years for me since I actively used it, after that tcsh and then bash. Could be that the \e has to be octal ( \033 ), now I am not sure anymore.
    – Anthon
    Jan 23 '14 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.