mirror of
https://github.com/fish-shell/fish-shell
synced 2024-09-21 06:51:58 +00:00
function to put current git branch on the fish prompt
Ignore-this: 841402742571f399e012514315b8e4f0 darcs-hash:20090204190358-69c1e-2ebcf761a4e55bc049ff1d5bba272d722b2d4501.gz
This commit is contained in:
parent
07dec5c3ed
commit
dfd70057b3
1 changed files with 22 additions and 0 deletions
22
share/functions/__fish_git_branch_prompt.fish
Normal file
22
share/functions/__fish_git_branch_prompt.fish
Normal file
|
@ -0,0 +1,22 @@
|
|||
# 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
|
||||
|
Loading…
Reference in a new issue