Shell integration
A binary cannot change its parent shell’s directory, so twig ships a tiny shell function instead (the direnv/zoxide trick):
eval "$(twig shell-init zsh)"Now:
tw matsumoto # cd's this shell into the worktree, then runs `twig enter`tw # inside a repo: pick a worktree, then cdtw -r fix-login # flags pass through to resolution (remote pickup here)The function is three lines:
tw() { local dir dir="$(twig cd "$@")" || return $? cd "$dir" || return $? twig enter}twig cd prints only the path on stdout; prompts, pickers, and errors go
to the terminal directly. That’s what makes the command substitution
safe. twig enter then applies the same trust-gated setup as every other
arrival path.
Supported shells: zsh, bash, fish. Rename the function with
--cmd:
eval "$(twig shell-init zsh --cmd j)"Three ways in, one behavior
Section titled “Three ways in, one behavior”| You do | What happens |
|---|---|
twig foo | new terminal window (plus other openers), setup inside it |
tw foo | current shell cd’s there, setup runs right here |
cd ... by hand, then twig enter | same setup logic, fully manual |
setup.auto = false in config makes all of them skip setup unless you
pass --setup.