X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=.zsh%2Fzshrc%2F60_vcsprompt;h=f7f80ca807acf818da50d8ba91d211417d99f561;hb=929a2738768030f0e46f3c13a26d9cde7cd38c62;hp=b5ab68ca5b1d31d902e1262be87fff4a486cbe72;hpb=47e33e38ed0ae2e2d57b506399e1feeee7f2f026;p=zsh.git diff --git a/.zsh/zshrc/60_vcsprompt b/.zsh/zshrc/60_vcsprompt index b5ab68c..f7f80ca 100644 --- a/.zsh/zshrc/60_vcsprompt +++ b/.zsh/zshrc/60_vcsprompt @@ -16,13 +16,9 @@ __git_get_reporoot() { # return the full path to the root of the current git repository [ -d "$GIT_DIR" ] && echo "$GIT_DIR" && return 0 - local relroot - relroot="$(git rev-parse --show-cdup 2>/dev/null)" || return 1 - if [ -n "$relroot" ]; then - readlink -f "$relroot" - else - echo $PWD - fi + local dir; dir="$PWD/$(git rev-parse --show-cdup)" + # do not use --show-toplevel because it resolves symlinks + echo $dir:a } __git_get_branch() @@ -160,12 +156,19 @@ __vcs_set_prompt_variables() { error "could not determine git repository root"; return 1 } branch="$(__git_get_branch)" || { error "could not determine git branch"; return 1 } - eval set -- $(__vcs_get_prompt_path_components "$reporoot" "$branch") - if [ -d "$GIT_DIR" ]; then - # poor man's replace until I find out how to do named dirs properly - # here: - local _D="${GIT_DIR/$HOME/~}" - set -- "$_D" "$2" "${${1#$_D}%/}" + if [ -n "$VCSH_REPO_NAME" ]; then + # if vcsh is used to get a subshell, then the repo root is the home + # directory, but we want to indicate the vcsh context too: + eval set -- $(__vcs_get_prompt_path_components "$HOME" "$branch") + set -- "vcsh:$VCSH_REPO_NAME" "$2" "$3" + else + eval set -- $(__vcs_get_prompt_path_components "$reporoot" "$branch") + if [ -d "$GIT_DIR" ]; then + # poor man's replace until I find out how to do named dirs properly + # here: + local _D="${GIT_DIR/$HOME/~}" + set -- "$_D" "$2" "${${1#$_D}%/}" + fi fi ;; hg)