Tiny zsh helper for switching to existing git worktrees or creating a new one from a branch name.
zshgitfzf(required for interactivewtpicker mode; not required forwt <branch-name>)
Pick one of these installation paths.
git clone https://github.com/RyanJamesCaldwell/wt.git ~/.config/wt
echo 'source ~/.config/wt/wt.zsh' >> ~/.zshrc
source ~/.zshrcwt.plugin.zsh exists for plugin-manager compatibility and sources wt.zsh.
# zinit
zinit light RyanJamesCaldwell/wt
# antigen
antigen bundle RyanJamesCaldwell/wt
# zplug
zplug "RyanJamesCaldwell/wt"mkdir -p ~/.config/wt
curl -fsSL https://raw.githubusercontent.com/RyanJamesCaldwell/wt/main/wt.zsh -o ~/.config/wt/wt.zsh
echo 'source ~/.config/wt/wt.zsh' >> ~/.zshrc
source ~/.zshrcManual source example:
# ~/.zshrc
source /absolute/path/to/wt.zsh
# or
source /absolute/path/to/wt.plugin.zshDo not run ./wt.zsh directly; it defines a shell function and must be sourced.
wt- Opens an
fzfpicker of existing worktrees andcds to the selection. Ctrl-N: prompt for branch name, create/switch worktree.Ctrl-D: remove selected worktree (with confirmation; main worktree is protected).
- Opens an
wt <branch-name>- If that branch already has a worktree, switches to it.
- Otherwise creates a new worktree at
../<repo>-worktrees/<branch-name>and switches to it. - Branch names with
/are preserved as nested directories (for exampleteam/feature->../<repo>-worktrees/team/feature).
When wt <branch-name> creates a new worktree, it copies these files from the main worktree root if they exist and are not already present in the new path:
.mise.toml.node-version.nvmrc.python-version.ruby-version.tool-versions
Sensitive files are not copied by default:
.env.env.local.envrc.npmrc
Enable sensitive-file copying:
WT_COPY_SENSITIVE_DOTFILES=1You can set that flag either before sourcing wt.zsh or later in an existing shell session, as long as it is set before running wt <branch-name>.
Or fully override the copy list:
WT_DOTFILES_TO_COPY=(.nvmrc .tool-versions .env.local)
source /absolute/path/to/wt.zsh- macOS with zsh 5.9
