fish-shell/share/functions/__fish_git_branch_prompt.fish
Shaun Reich d38de7365a Change git-symbolic-ref to git symbolic-ref.
On my system at least (fedora 15), git-symbolic-ref is an invalid
command. Not sure if it's a BIC change from git itself, a distribution
thing, or a mistake on my end. Either way, no harm in using the
extended version. Now I get git branch status (yay).
2011-06-19 14:14:40 -04:00

22 lines
460 B
Fish

# Prints the current git branch, if any
function __fish_git_branch_prompt
set gitdir (git rev-parse --git-dir 2>/dev/null)
if [ -z $gitdir ]
return 0
end
set branch (git symbolic-ref HEAD 2>/dev/null| cut -d / -f 3)
# check for rebase, bisect, etc
# TODO
# no branch, print hash of HEAD
if [ -z $branch ]
set branch (git log HEAD\^..HEAD --pretty=format:%h 2>/dev/null)
end
if [ ! -z $branch ]
echo " ($branch) "
end
end