diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-23 10:40:52 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-23 10:40:52 +1200 |
commit | 17eb15a214645ccf2bdb55967ea286bec31af8a2 (patch) | |
tree | 6cf6d658fef5251f2cd47981e8fb376d5aa08845 /bash | |
parent | Unused abbreviation and I actually do want c_C-F (diff) | |
download | dotfiles-17eb15a214645ccf2bdb55967ea286bec31af8a2.tar.gz dotfiles-17eb15a214645ccf2bdb55967ea286bec31af8a2.zip |
Clarify git branch/commit detection
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/prompt.bash | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 3f658fa2..e28b2dda 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -63,9 +63,13 @@ prompt() { # Attempt to determine git branch, bail if we can't local branch - branch=$(git symbolic-ref --quiet HEAD 2>/dev/null) \ - || branch=$(git rev-parse --short HEAD 2>/dev/null) \ - || return 1 + branch=$( { + git symbolic-ref --quiet HEAD \ + || git rev-parse --short HEAD + } 2>/dev/null ); + if ! [[ $branch ]]; then + return 1 + fi branch=${branch##*/} # Safely read status with -z --porcelain |