Simple Git Trick for Bash
Chris Cormack shared this useful trick for keeping track of what git repo you are currently using/editing. Stick it in your .bash_profile to have your prompt adapt to the repo you are in!
function parse_git_branch { ref=$(git-symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" }RED ="\[\033[0;31m\]" YELLOW ="\[\033[0;33m\]" GREEN ="\[\033[0;32m\]"PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ "

April 10th, 2009 at 2:23 pm
The colours of course are optional
The green makes me feel like im back in 1985
April 13th, 2009 at 4:56 am
I didn’t even have a computer in 1985.
April 13th, 2009 at 5:17 am
Hmm in 1985 it would have been an apple IIe. Having just sold my zx spectrum
April 13th, 2009 at 7:56 am
Cool trick, although it didn’t show up until I’d logged out and logged back in. I think I’ll tweak the colors: 1985 was amber for me, not green