Config Overrides
You can override configuration values directly from the command line using the--config flag:
Listing Worktrees
Table Output (Default)
The default list format provides a human-readable table:Pristine Output (Scripting)
For scripting purposes, use--pristine to output only worktree paths, one per line:
JSON Output
For structured data consumption, use--json to output worktree information in JSON format:
The
--pristine and --json flags are mutually exclusive. Use one or the other depending on your needs.Creating Worktrees
LazyWorktree provides flexible worktree creation with multiple options:Basic Creation
From Branch
From Pull Request
PR creation always uses the generated worktree name. The local branch name is conditional: if you are the PR author, LazyWorktree keeps the PR branch name; otherwise it uses the generated name. When requester identity cannot be resolved, LazyWorktree falls back to the PR branch name.
From Issue
Branch Only (No Worktree)
Sometimes you want to create a branch without creating a worktree directory:Post-Creation Commands
Run a command after successful worktree creation using--exec:
The
--exec command runs in the new worktree directory, or in the current directory when used with --no-workspace. The shell mode follows your current shell (zsh -ilc, bash -ic, or -lc otherwise).Deleting Worktrees
Delete worktrees with optional branch retention:Renaming Worktrees
Rename worktrees and their associated branches:When renaming, the branch is renamed only if the current worktree directory name matches the branch name. This prevents accidentally renaming branches that don’t follow the naming convention.
Running Commands in Worktrees
Theexec command allows you to execute shell commands or trigger custom command keys in worktrees from the CLI.
Execute Shell Commands
Run arbitrary shell commands in a specific worktree:Trigger Custom Command Keys
Trigger custom command key actions (like tmux or zellij sessions) from the CLI:How exec Works
--workspace(or-w) - Specify target worktree by name or path- Auto-detection - If
--workspaceis not provided, the worktree is detected from the current directory - Command argument - Shell command to execute (positional argument)
--key(or-k) - Trigger a custom command key instead of running a shell command- Environment variables - Sets
WORKTREE_*environment variables (same as custom commands in the TUI)
The
exec command supports all custom command types: shell, tmux, zellij, and show-output. However, new-tab commands are not supported in CLI mode.Examples
Environment Variables
When using--exec or the exec command, the following environment variables are available:
WORKTREE_BRANCH- The branch name for the worktreeWORKTREE_PATH- Full path to the worktree directoryWORKTREE_NAME- Name of the worktreeMAIN_WORKTREE_PATH- Path to the main/root worktreeREPO_NAME- Name of the repository
Scripting Examples
Clean Up Merged Worktrees
Batch Command Execution
JSON Processing
Complete CLI Documentation
For the complete CLI reference including all flags and options, consult:man lazyworktree- Full man page documentationlazyworktree --help- Quick help outputlazyworktree <command> --help- Command-specific help