Tag Archives: csh

csh woes

One thing I hate about the C Shell is the lack of function support. You’re left with aliases but they don’t work out all the time.

The other I wanted to add the git branch you’re on to the csh (tcsh, in fact) prompt. I tried out adding the following to the .cshrc:

alias GIT_BRANCH_CMD "sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* (.*)/(1)/'"
alias cd 'chdir !*;set prompt=`whoami`@`hostname`": %~"`GIT_BRANCH_CMD`" > "'
cd ~

But it only works when you cd to the directory. Out of luck when you git checkout, etc. To my knowledge csh has no advantage over bash, so the lesson is to use bash whenever possible.