wt: exec shell vs shell integration (opens in new tab)
Problem statement: my cd subcommand does not survive a terminal split — the new pane opens at the original directory, not the worktree. wt does(!) A subprocess cannot change its parent’s working directory (PWD). wt.sh works around it by replacing the script process with a fresh shell: cd "$target_path" || exit 1 exec "$SHELL" The exec "$SHELL" is the culprit. The interactive shell process is gone, replaced by a new one rooted in the worktree. The terminal emulator’s record of “what shell is (...
Read the original article