aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar terceiro <terceiro@softwarelivre.org>2009-02-05 05:03:58 +1000
committerGravatar terceiro <terceiro@softwarelivre.org>2009-02-05 05:03:58 +1000
commitdfd70057b30e811b9895e9f735bb1bccc662b642 (patch)
tree074c702811939e522dca360b32df569b40367a0e
parent07dec5c3ed5a2a524193afbb1dd34fa8f5498652 (diff)
function to put current git branch on the fish prompt
Ignore-this: 841402742571f399e012514315b8e4f0 darcs-hash:20090204190358-69c1e-2ebcf761a4e55bc049ff1d5bba272d722b2d4501.gz
-rw-r--r--share/functions/__fish_git_branch_prompt.fish22
1 files changed, 22 insertions, 0 deletions
diff --git a/share/functions/__fish_git_branch_prompt.fish b/share/functions/__fish_git_branch_prompt.fish
new file mode 100644
index 00000000..e2026f6e
--- /dev/null
+++ b/share/functions/__fish_git_branch_prompt.fish
@@ -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
+