1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-10-16 11:40:46 +00:00

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.
This commit is contained in:
Kilobyte22 2015-07-27 23:11:25 +02:00 committed by Stephen Gelman
parent 1ff9752c26
commit 61af29b967

View file

@ -139,6 +139,10 @@ prompt_context() {
prompt_git_relative() { prompt_git_relative() {
local repo_root=$(git rev-parse --show-toplevel) 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:/$::;") local path_in_repo=$(pwd | sed "s/^$(echo "$repo_root" | sed 's:/:\\/:g;s/\$/\\$/g')//;s:^/::;s:/$::;")
if [[ $path_in_repo != '' ]]; then if [[ $path_in_repo != '' ]]; then
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$path_in_repo" prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$path_in_repo"