From f02987a4d7bf499641c82f7195c04b054a24e186 Mon Sep 17 00:00:00 2001 From: yage Date: Wed, 10 Aug 2022 00:13:49 -0600 Subject: [PATCH] resolve symlinks when doing git-root-relative PS1 string --- zsh/ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zsh/ps1 b/zsh/ps1 index d98f5e3..7034350 100644 --- a/zsh/ps1 +++ b/zsh/ps1 @@ -7,7 +7,8 @@ PS1__GET_DIRECTORY() { local PROJECT_NAME=$(basename $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~' _DIRECTORY="%B%F{green}$PROJECT_NAME%B%F{yellow}:$RELATIVE_DIRECTORY"