aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-08-14 01:15:55 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2014-08-14 01:18:34 +0200
commit122a4ba97ea8b6098eb8b569d6586283f42cffe4 (patch)
treeae7c991f75166dc36eec9966970b3aae2e65be21
parenta7b75428089c54b6544be51699de41789a56c47c (diff)
downloaddotfiles-122a4ba97ea8b6098eb8b569d6586283f42cffe4.tar.xz
zshrc: get_git_branch: Check HEAD file directly
This fixes errors from git when in a repo without any commits. Stolen (again) from Earnestly/dotfiles@a855e6bf Original-work-by: Earnestly <zibeon@gmail.com>
-rw-r--r--zsh/.zshrc3
1 files changed, 2 insertions, 1 deletions
diff --git a/zsh/.zshrc b/zsh/.zshrc
index 8d5a15c..15a02f6 100644
--- a/zsh/.zshrc
+++ b/zsh/.zshrc
@@ -60,7 +60,8 @@ $(yellow "└─╼") "
function get_git_branch {
if [[ -d .git ]]; then
- branch="$(git rev-parse --abbrev-ref HEAD) "
+ branch="$(< .git/HEAD)"
+ branch="${branch##*/} "
else
branch=""
fi