wt cd
Print the absolute path to a worktree for use with command substitution.
Synopsis
Description
wt cd prints the absolute path to a worktree. Use it with command substitution to navigate directly to any worktree by (partial) branch name.
wt cd writes the path to stdout and all other output to stderr, so the path can be captured cleanly in scripts.
Arguments
| Argument | Description |
|---|---|
<branch> | Branch name (partial matching supported) |
Examples
Recommended Shell Function
Add this to ~/.zshrc or ~/.bashrc:
Then wtcd feat navigates directly without quoting.
Exit Codes
| Code | Meaning |
|---|---|
0 | Success (path printed to stdout) |
1 | No match or ambiguous match |
Partial Matching
Partial matching resolves unambiguously when only one worktree contains the given string. If multiple worktrees match, wt cd exits with code 1 and prints the ambiguous matches to stderr.