resolve symlinks when doing git-root-relative PS1 string
This commit is contained in:
parent
a419b394f7
commit
f02987a4d7
3
zsh/ps1
3
zsh/ps1
@ -7,7 +7,8 @@ PS1__GET_DIRECTORY() {
|
|||||||
local PROJECT_NAME=$(basename $GIT_ROOT)
|
local PROJECT_NAME=$(basename $GIT_ROOT)
|
||||||
[[ $PROJECT_NAME =~ ^code$ ]] && PROJECT_NAME=$(basename $(dirname $GIT_ROOT))
|
[[ $PROJECT_NAME =~ ^code$ ]] && PROJECT_NAME=$(basename $(dirname $GIT_ROOT))
|
||||||
|
|
||||||
local RELATIVE_DIRECTORY=${${PWD#$GIT_ROOT}:1}
|
local RESOLVED_WD=$(readlink -f "$(pwd)")
|
||||||
|
local RELATIVE_DIRECTORY=${${RESOLVED_WD#$GIT_ROOT}:1}
|
||||||
[[ ${#${RELATIVE_DIRECTORY//[^\/]}} -gt 3 ]] && RELATIVE_DIRECTORY='*/%4~'
|
[[ ${#${RELATIVE_DIRECTORY//[^\/]}} -gt 3 ]] && RELATIVE_DIRECTORY='*/%4~'
|
||||||
|
|
||||||
_DIRECTORY="%B%F{green}$PROJECT_NAME%B%F{yellow}:$RELATIVE_DIRECTORY"
|
_DIRECTORY="%B%F{green}$PROJECT_NAME%B%F{yellow}:$RELATIVE_DIRECTORY"
|
||||||
|
Loading…
Reference in New Issue
Block a user