LazyWorktree’s custom command system lets you define keybindings that execute commands, manage tmux/zellij sessions, and create per-repository workflows.
Define custom commands in ~/.config/lazyworktree/config.yaml:
config.yaml (Basic Command)
config.yaml (Run Tests)
config.yaml (Show Output)
custom_commands :
e :
command : nvim
description : Editor
show_help : true
Field Reference
Field Type Default Description commandstring required Command to execute descriptionstring ""Shown in help and palette show_helpbool falseShow in help screen (?) and footer waitbool falseWait for keypress after completion show_outputbool falseShow stdout/stderr in pager (ignores wait) new_tabbool falseLaunch in new terminal tab (Kitty, WezTerm, iTerm) tmuxobject nullConfigure tmux session zellijobject nullConfigure zellij session
Interactive TUI Suspension
Commands run interactively, suspending the TUI. After execution, LazyWorktree resumes.
config.yaml (Shell)
config.yaml (Run Tests with Wait)
custom_commands :
s :
command : zsh
description : Shell
show_help : true
Set wait: true to pause after command completion, useful for reviewing output before returning to the TUI.
Environment Variables
Custom commands have access to worktree environment variables:
WORKTREE_BRANCH - Current worktree’s branch name
WORKTREE_PATH - Absolute path to worktree directory
WORKTREE_NAME - Worktree directory name
MAIN_WORKTREE_PATH - Path to main worktree
REPO_NAME - Repository name
config.yaml (Using Environment Variables)
custom_commands :
b :
command : echo "Branch : $WORKTREE_BRANCH in $WORKTREE_PATH"
description : Show branch info
show_output : true
tmux Session Management
Define tmux session layouts with multiple windows:
config.yaml (tmux Session)
custom_commands :
t :
description : Tmux
show_help : true
tmux :
session_name : "wt:$WORKTREE_NAME"
attach : true
on_exists : switch
windows :
- name : claude
command : claude
- name : shell
command : zsh
- name : lazygit
command : lazygit
tmux Fields
Field Type Default Description session_namestring wt:$WORKTREE_NAMESession name (env vars supported, special chars replaced) attachbool trueAttach immediately; if false, show modal with instructions on_existsstring switchBehaviour if session exists: switch, attach, kill, new windowslist [ { name: "shell" } ]Window definitions for the session
tmux Window Fields
Field Type Default Description namestring window-NWindow name (supports env vars) commandstring ""Command to run in the window (empty uses default shell) cwdstring $WORKTREE_PATHWorking directory for the window (supports env vars)
If windows is empty, creates a single shell window.
on_exists Behaviour
switch - Switch to existing session (default)
attach - Attach to existing session
kill - Kill existing session and create new
new - Create new session with incremented name (e.g., wt:feature-1)
zellij Session Management
Define zellij session layouts with multiple tabs:
config.yaml (zellij Session)
custom_commands :
z :
description : Zellij
show_help : true
zellij :
session_name : "wt:$WORKTREE_NAME"
attach : true
on_exists : switch
windows :
- name : editor
command : nvim
- name : shell
command : zsh
- name : tests
command : npm test -- --watch
zellij Fields
Field Type Default Description session_namestring wt:$WORKTREE_NAMESession name (env vars supported, special chars replaced) attachbool trueAttach immediately; if false, show modal with instructions on_existsstring switchBehaviour if session exists: switch, attach, kill, new windowslist [ { name: "shell" } ]Tab definitions for the session
zellij Window Fields
Field Type Default Description namestring window-NTab name (supports env vars) commandstring ""Command to run in the tab (empty uses default shell) cwdstring $WORKTREE_PATHWorking directory for the tab (supports env vars)
Session names with /, \, : are replaced with - for filesystem compatibility.
Terminal Tab Commands
Launch commands in a new terminal tab (Kitty, WezTerm, iTerm):
config.yaml (New Terminal Tab)
custom_commands :
c :
command : claude
description : Claude Code
new_tab : true
show_help : true
new_tab requires:
Kitty with remote control enabled
WezTerm
iTerm2
Other terminals are not supported.
Custom commands support:
Single keys : e, s, T
Modifiers : ctrl+e, alt+t
Special keys : enter, esc, tab, space
config.yaml (Modifier Keys)
custom_commands :
"ctrl+e" :
command : nvim
description : Open editor with Ctrl+E
"alt+t" :
command : make test
description : Run tests with Alt+T
wait : true
Custom commands override built-in keys . Use caution when redefining core bindings.
Default tmux/zellij Bindings
LazyWorktree provides default bindings:
t - tmux session
Z - zellij session
Override via custom_commands.t or custom_commands.Z.
Session Prefix
Configure the session name prefix:
session_prefix : "wt-" # Default: "wt-"
The command palette filters sessions by this prefix.
Command Palette Integration
Custom commands appear in the command palette (press Ctrl+p or : ).
Enable MRU (Most Recently Used) sorting:
palette_mru : true # Enable MRU sorting (default: true)
palette_mru_limit : 5 # Number of recent commands to show (default: 5)
Recently used commands appear at the top of the palette for quick access.
Real-World Examples
Run Tests
custom_commands :
t :
command : make test
description : Run tests
show_help : true
wait : true
Open Editor
custom_commands :
e :
command : nvim
description : Editor
show_help : true
Claude Code in New Tab
custom_commands :
c :
command : claude
description : Claude Code
new_tab : true
show_help : true
tmux Session with Multiple Windows
custom_commands :
t :
description : Tmux
show_help : true
tmux :
session_name : "wt:$WORKTREE_NAME"
attach : true
on_exists : switch
windows :
- name : claude
command : claude
- name : shell
command : zsh
- name : lazygit
command : lazygit
custom_commands :
o :
command : git status -sb
description : Status
show_help : true
show_output : true