mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
d38de7365a
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).
22 lines
460 B
Fish
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
|
|
|