1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-23 14:20:08 +00:00

Fixed an artifact from merge and some bugs in agnoster theme

For some reason i forgot to save the file in my editor, leading to the code not working. Luckily i looked through the changed files on github again and i found this. This is what happens if you don't care to actually test your code for once
Due to some more lack of testing i totall missed that my earlier fix did not work. This is now really fixed. (i should not write code when tired.)
This commit is contained in:
Kilobyte22 2015-07-27 23:26:49 +02:00 committed by Stephen Gelman
parent 61af29b967
commit 3c307e8479

View file

@ -127,6 +127,18 @@ prompt_end() {
CURRENT_BG=''
}
git_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)
if [[ $repo_root = '.' ]]; then
repo_root=$(pwd)
fi
fi
echo -n $repo_root
}
### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown
@ -138,11 +150,7 @@ 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 repo_root=$(git_toplevel)
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"
@ -276,7 +284,7 @@ prompt_hg() {
prompt_dir() {
if [[ $AGNOSTER_GIT_INLINE == 'true' ]] && $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
# Git repo and inline path enabled, hence only show the git root
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$(git rev-parse --show-toplevel | sed "s:^$HOME:~:")"
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$(git_toplevel | sed "s:^$HOME:~:")"
else
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" '%~'
fi