diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2017-02-11 18:12:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-11 18:12:17 +0300 |
commit | da75345275b80af131852cbd0ba644bb6e4fd904 (patch) | |
tree | eb34bcdb91d62603282cd8bb8868d29ae49bdc7e /powerlevel9k.zsh-theme | |
parent | ddcbc62a052106fa13042fa845524de1d95dd46c (diff) | |
parent | a576a157599ef3b41b939c4e8dc5df8656c30023 (diff) |
Merge pull request #387 from dritter/fix_truncate_with_package_name
Fix error with truncating package name if repo is symlinked
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0df17de0..044a0320 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -597,7 +597,14 @@ prompt_dir() { # Get the path of the Git repo, which should have the package.json file if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then - package_path=$(git rev-parse --show-toplevel) + # Get path from the root of the git repository to the current dir + local gitPath=$(git rev-parse --show-prefix) + # Remove trailing slash from git path, so that we can + # remove that git path from the pwd. + gitPath=${gitPath%/} + package_path=${$(pwd)%%$gitPath} + # Remove trailing slash + package_path=${package_path%/} elif [[ $(git rev-parse --is-inside-git-dir 2> /dev/null) == "true" ]]; then package_path=${$(pwd)%%/.git*} fi |