Custom commands take precedence over built-in keys. For example, defining a custom
s command will override the built-in sort toggle.Default Commands
LazyWorktree includes two default custom commands:t- Create/attach to tmux sessionZ- Create/attach to zellij session
custom_commands.t or custom_commands.Z in your config.
Configuration Format
Define commands in yourconfig.yaml:
Field Reference
The command to execute. Can include environment variables.Example:
make test, git status -sb, nvimDescription shown in help screen and command palette.
Show in help screen (triggered with
?) and footer hints.Wait for keypress after command completes. Useful for quick commands where you want to see output before returning to TUI.
Display command output in the pager instead of running interactively. When true, stdout/stderr are captured and shown in the configured pager. Ignores
wait setting.Example use case: git status, git log, or other read-only commandsLaunch command in a new terminal tab. Works with Kitty (with remote control enabled), WezTerm, and iTerm. Can be combined with
tmux or zellij configuration.Configure tmux session for this command. See Tmux Configuration below.
Configure zellij session for this command. See Zellij Configuration below.
Environment Variables
All commands have access to these environment variables:| Variable | Description | Example |
|---|---|---|
WORKTREE_PATH | Path to the worktree | /home/user/.local/share/worktrees/org-repo/feature-x |
WORKTREE_BRANCH | Git branch name | feature-x |
WORKTREE_NAME | Worktree directory name | feature-x |
MAIN_WORKTREE_PATH | Main repository path | /home/user/projects/repo |
REPO_NAME | Repository identifier | chmouel-lazyworktree |
Example Usage
Tmux Configuration
Create or attach to tmux sessions with multiple windows:Tmux Fields
Session name. Environment variables are expanded. Special characters are replaced with hyphens.
Attach immediately to the session. If
false, shows a modal with attachment instructions.Behaviour when session already exists.Options:
switch- Switch to existing sessionattach- Attach to existing sessionkill- Kill existing session and create new onenew- Create new session with incremented name
Window definitions for the session. If empty, creates a single “shell” window.
Tmux Window Fields
Window name. Supports environment variables.
Command to run in the window. Empty uses your default shell.
Working directory for the window. Supports environment variables.
Zellij Configuration
Create or attach to zellij sessions with multiple tabs:Zellij Fields
Session name. Environment variables are expanded. Characters
/, \, : are replaced with hyphens.Attach immediately to the session. If
false, shows a modal with attachment instructions.Behaviour when session already exists.Options:
switch- Switch to existing sessionattach- Attach to existing sessionkill- Kill existing session and create new onenew- Create new session with incremented name
Tab definitions for the session. If empty, creates a single “shell” tab.
Zellij Window Fields
Tab name. Supports environment variables.
Command to run in the tab. Empty uses your default shell.
Working directory for the tab. Supports environment variables.
Key Formats
Supported key formats:Single Keys
Modifier Combinations
Special Keys
Complete Examples
Simple Commands
Tmux Session with Multiple Windows
Zellij Session with Custom Working Directories
Open in New Terminal Tab
The
new_tab feature requires:- Kitty with remote control enabled
- WezTerm
- iTerm
Show Output in Pager
Session Prefix
The command palette lists tmux/zellij sessions matching thesession_prefix (default: wt-):
Key Precedence
Built-in keys that are commonly overridden:s- Sort mode togglet- Default tmux commandZ- Default zellij commandl- Layout toggle
ctrl+s) to avoid conflicts with built-in keys.