From 122a4ba97ea8b6098eb8b569d6586283f42cffe4 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Thu, 14 Aug 2014 01:15:55 +0200 Subject: 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 --- zsh/.zshrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'zsh') 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 -- cgit v1.2.3-70-g09d2