summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <victortoso@redhat.com>2015-12-30 22:42:36 +0100
committerVictor Toso <victortoso@redhat.com>2015-12-30 23:11:49 +0100
commit92701c65fa11ca7125d98775d8a79a01423246bd (patch)
tree1cb29d62e7296c6e2ca6c237621b6b7d58fe1310
parentf6442a016b7c67150e7221aff35ef21913dfee75 (diff)
bash: more reliable to get git branch
-rw-r--r--bashrc7
1 files changed, 2 insertions, 5 deletions
diff --git a/bashrc b/bashrc
index edfcb43..4175276 100644
--- a/bashrc
+++ b/bashrc
@@ -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