forked from tcsh-org/tcsh
-
Notifications
You must be signed in to change notification settings - Fork 2
Home
amoldeshpande edited this page Oct 22, 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 git and windows tcsh to play nice, so here's a windows-only way to do it.
setenv GIT_BRANCH_CMD "cmd /c ~/gitprompt.cmd 2>NUL"
set branch_exists = `$GIT_BRANCH_CMD`
if ("$branch_exists" != "" ) then
set prompt="%B%{\033[38;5;21m%}%c03(%{\033[31m%}$branch_exists%{\033[38;5;21m%})[%P]\>%{\033[0m%}%b"
else
set prompt="%B%{\033[38;5;21m%}%c03[%P]\>%{\033[0m%}%b"
endif
where gitprompt.cmd is:
@echo off
for /f "usebackq tokens=2 " %%f in (`git branch`) do echo %%f