Hi all,
Can you tell me how to change the prompt color (only the path part) when I chnange directory with "cd"?
I use the sequence below in ".bashrc" (Solaris 8) to change my prompt colors and I'd like to modify it to change the path color when I cange directory.
PSC() { echo -ne "\[\033[${1:-0;34}m\]"; }
function PWD() { echo "$*" |perl -pne \
's:^'"$HOME"':~:;s:^(.{8}).{4}.*(.{20})$:$1...$2:;'
}
PR="0;34" # this is blue
PSbase="$(PSC $sudo)\u$(PSC $PR)@\h $(PSC 33)\$(PWD \w)"
PS1[1]="$PSbase$(PSC $PR)\$ $(PSC)\e[0m"
PS1="${PS1[1]}"
unset sudo PR PSbase
The results are(the text colored in black is actually white):
root@localhost ~/dir1/d..._dir/really_long_dir$ pwd
/root/dir1/ddd/aaaaaaaaaaaaaaaaaaaaaaa/verry_long_dir/really_long_dir
root@localhost ~/dir1/d..._dir/really_long_dir$
The desired result is:
root@localhost ~/dir1/d..._dir/really_long_dir$ cd new_dir/
root@localhost ~/dir1/d...lly_long_dir/new_dir$
And if I change again the directory it should turn back to green.
Any ideea how to do this?
Thanks.