diff options
author | Victor Toso <victortoso@redhat.com> | 2015-12-30 22:42:36 +0100 |
---|---|---|
committer | Victor Toso <victortoso@redhat.com> | 2015-12-30 23:11:49 +0100 |
commit | 92701c65fa11ca7125d98775d8a79a01423246bd (patch) | |
tree | 1cb29d62e7296c6e2ca6c237621b6b7d58fe1310 | |
parent | f6442a016b7c67150e7221aff35ef21913dfee75 (diff) |
bash: more reliable to get git branch
-rw-r--r-- | bashrc | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -41,11 +41,8 @@ fi # ---------------------------------------------------------------------------- # function get_git_branch() { - if [ -d "$PWD/.git" ] - then - branch=`cat $PWD/.git/HEAD | cut -d'/' -f 3` - eval "$1='$branch'" - fi + branch=`git branch -a 2> /dev/null | grep \* | cut -d' ' -f 2` + eval "$1='$branch'" } PATH=$HOME/.local/bin:$PATH |