From 033babcfbd3f7729c3632926554ed0853ed91789 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Sun, 17 Dec 2023 23:45:28 -0500 Subject: [PATCH] Use more efficient way to find current branch name This might have drawbacks in case we are in "detached head" state --- zshrc.org | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zshrc.org b/zshrc.org index 08b9dff..aa9cc76 100644 --- a/zshrc.org +++ b/zshrc.org @@ -439,7 +439,10 @@ This needs to be diff'd among the versions } function git-current-branch () { - git status -b | head -n 1 | awk {'print $3'} + # do I want to give up on revision numbers in detached-head state? + git rev-parse --abbrev-ref HEAD | grep -v HEAD || \ + git describe --exact-match HEAD 2> /dev/null || \ + git rev-parse HEAD } #+end_src