diff --git a/.config/zsh/autoload/git/git-checkout-worktree b/.config/zsh/autoload/git/git-checkout-worktree index 424a097..9ee2744 100755 --- a/.config/zsh/autoload/git/git-checkout-worktree +++ b/.config/zsh/autoload/git/git-checkout-worktree @@ -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"