aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-07-03 15:02:27 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-07-03 15:02:27 +1200
commit7cbd9d8307b09904e7f7b7ed37532ae08f20ac13 (patch)
tree4e0fe12f2c7a2182878b137c230a50bbd4192773 /bash
parentMuch-improved git prompt function (diff)
downloaddotfiles-7cbd9d8307b09904e7f7b7ed37532ae08f20ac13.tar.gz
dotfiles-7cbd9d8307b09904e7f7b7ed37532ae08f20ac13.zip
Much smarter Git branch finding
Diffstat (limited to 'bash')
-rw-r--r--bash/bashrc.d/prompt.bash5
1 files changed, 3 insertions, 2 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 37d25ff3..67efbd70 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -33,8 +33,9 @@ function prompt {
&& return 1
$(git rev-parse --is-inside-work-tree 2>/dev/null ) \
|| return 1
- head="$(git symbolic-ref HEAD 2>/dev/null)"
- branch="${head##*/}"
+ branch=$(git symbolic-ref --quiet --short HEAD 2> /dev/null ) \
+ || branch=$(git rev-parse --short HEAD 2>/dev/null ) \
+ || branch="(unknown)"
$(git diff --quiet --ignore-submodules --cached ) \
|| state=${state}+
$(git diff-files --quiet --ignore-submodules -- ) \