1

I'm using the directions here to customize my CSH prompt. Here's what I'm using:

set prompt="\n%{\033[1;32m%}%m %{\033[36m%}${cwd}$ %{\033[0m%} "

First of all, the ${cwd} part isn't giving the full path to the directory I'm in, only the full path to the directory I'm in when .cshrc was sourced. How do I display the current directory?

Secondly, if I don't include the space at the end of the string the color of the text I type is changed to the color of the directory from the previous part. Is there anyway to do this without adding the space?

3

The following code solved both of my problems.

set prompt="\n%{\033[0;32m%}%n@%m:%{\033[0;33m%}%~%{\033[1;30m%}>%{\033\[1;37m%} "
| improve this answer | |
  • So, in other words, you used %~? Could you make that explicit in your answer? – Fund Monica's Lawsuit Sep 21 '16 at 0:34
1

In C Shell, add the following lines to your .cshrc:

make a command doprompt that sets the prompt to the working directory

alias doprompt 'set prompt="`pwd` "'

set the prompt the first time around

doprompt

alias the cd command to change directories and reset the prompt

alias cd 'chdir !* || doprompt'
| improve this answer | |
  • The doprompt command works fine. However, the cd alias causes problems. When I add that alias to my .cshrc, when I type cd it says .cshrc: Not a directory. – gsingh2011 Mar 11 '12 at 7: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.