From 5f2f60f0c12170e7befe4673b83674c4c04a7809 Mon Sep 17 00:00:00 2001 From: Kilobyte22 Date: Mon, 27 Jul 2015 23:11:25 +0200 Subject: [PATCH] Agnoster theme now properly handles bare git repos Up until now the agnoster theme with enabled inline git branch display did not work properly for bare repos. This was caused by `git rev-parse --show-toplevel` returning empty string for bare repos. In that case it now uses the git directory as root. Your bare repo should be displayed properly (although you usually won't really navigate through a bare git repo, this is nice to have. --- themes/agnoster.zsh-theme | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 8a717d6b3..d7c9d56c7 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -111,6 +111,10 @@ prompt_context() { prompt_git_relative() { local repo_root=$(git rev-parse --show-toplevel) + if [[ $repo_root = '' ]]; then + # We are in a bare repo. Use git dir as root + repo_root=$(git rev-parse --git-dir) + fi local path_in_repo=$(pwd | sed "s/^$(echo "$repo_root" | sed 's:/:\\/:g;s/\$/\\$/g')//;s:^/::;s:/$::;") if [[ $path_in_repo != '' ]]; then prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$path_in_repo"