Skip to content
amoldeshpande edited this page Nov 4, 2019 · 4 revisions

miscellaneous

git prompt:

In .tcshrc:

alias precmd "source ~/gitprompt.csh"

gitprompt.csh: There's something goofy about backticks and double quotes, which I'll debug some day.

# inspired by https://gist.github.com/nicwolff/2925803
# though I couldn't get Sourcetree's bash and windows tcsh to play nice, so here's a windows-only way to do it.
# note that extended ANSI colors are not supported by windows tcsh (yet?)
setenv GIT_BRANCH_CMD "cmd /c ~/gitprompt.cmd 2>NUL"
set branch_exists = `$GIT_BRANCH_CMD`
if ("$branch_exists" != "" ) then
set prompt="%B%{\033[94m%}%c03(%{\033[91m%}$branch_exists%{\033[38;30m%})[%P]%{\033[0m%}%b\>"
else
set prompt="%B%{\033[94m%}%c03[%P]%{\033[0m%}%b\>"
endif

where gitprompt.cmd is:

@echo off
for /f "usebackq tokens=2 " %%f in (`git branch`) do echo %%f
Clone this wiki locally