resolve symlinks when doing git-root-relative PS1 string

This commit is contained in:
Wryn (yage) Wagner 2022-08-10 00:13:49 -06:00
parent a419b394f7
commit f02987a4d7

View File

@ -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"