Unix/Linux cshrc Prompt and color setting

Hao-Wei
May 29, 2021

--

In terminal commnad line, prompt current path and color the segment as wanted.

C Shell (csh):

### Initial color as variableset     red="%{\033[1;31m%}"
set green="%{\033[0;32m%}"
set yellow="%{\033[1;33m%}"
set blue="%{\033[1;34m%}"
set magenta="%{\033[1;35m%}"
set cyan="%{\033[1;36m%}"
set white="%{\033[0;37m%}"
set end="%{\033[0m%}" # This is needed at the end... :(
### Initail "setprompt"alias setprompt 'set prompt="${red}`whoami`${cyan}\@${yellow}`hostname` ${end}`pwd` % "'setpromptalias cd 'chdir \!* && setprompt'---------------------------------------------------------------You got:USER@SERVER /dev/null %Note:alias setprompt 'set prompt="${red}`whoami`${cyan}\@${yellow}`hostname` ${end}${cwd} % "'${red}`whoami`Using `whoami` to get username, and color Red.${cyan}\@Using \ escape @, and color cray.${yellow}`hostname`Using `hostname` get server, and color yellow.---------------------------------------------------------------

Reference:

https://www.cs.umd.edu/~srhuang/teaching/code_snippets/prompt_color.tcsh.html

http://hkbsd.net/www/unixfaq/node12.html

--

--