git🐮 Keep as much relative offset as possible

This commit is contained in:
2025-09-15 13:41:16 +02:00
parent 65d99c40e8
commit d8859bc709

View File

@@ -55,7 +55,10 @@ trap '
cwd_offset="${${PWD#$(git rev-parse --show-toplevel)}#/}"
pushd -q "$WORKTREE_PATH"
[[ ! -d $cwd_offset ]] || cd "$cwd_offset"
until [[ -d $cwd_offset || -z $cwd_offset ]]; do
cwd_offset="${cwd_offset:h}"
done
[[ -z $cwd_offset ]] || cd "$cwd_offset"
"$SHELL" && errc=$? || errc=$?
(( !errc )) || echo "shell exited with $errc"