more strict regex for path

This commit is contained in:
Wryn Wagner 2021-09-21 11:51:02 -06:00
parent caa0d7b85c
commit be3daa90e3

View File

@ -10,7 +10,7 @@ PS1__GET_DIRECTORY() {
local GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
[ $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}
[[ ${#${RELATIVE_DIRECTORY//[^\/]}} -gt 3 ]] && RELATIVE_DIRECTORY='*/%4~'