Shell integration

February 20, 2026 ยท View on GitHub

Lazyworktree provides shell integration helpers to enhance your workflow when working with Git worktrees. The "jump" helper changes your current directory to the selected worktree on exit, using --output-selection to write the selected path to a temporary file.

Shell integration scripts are available for Bash, Zsh, and Fish.

Bash

Option A: Source the helper from a local clone:

# Add to .bashrc
source /path/to/lazyworktree/shell/functions.bash

jt() { worktree_jump $(git rev-parse --show-toplevel) "$@"; }

Option B: Download the helper:

mkdir -p ~/.shell/functions
curl -sL https://raw.githubusercontent.com/chmouel/lazyworktree/refs/heads/main/shell/functions.bash -o ~/.shell/functions/lazyworktree.bash

# Add to .bashrc
source ~/.shell/functions/lazyworktree.bash

jt() { worktree_jump $(git rev-parse --show-toplevel) "$@"; }

With completion:

source /path/to/lazyworktree/shell/functions.bash

jt() { worktree_jump $(git rev-parse --show-toplevel) "$@"; }
_jt() { _worktree_jump $(git rev-parse --show-toplevel); }
complete -o nospace -F _jt jt

To add a shortcut to the last-selected worktree:

alias pl='worktree_go_last $(git rev-parse --show-toplevel)'

Zsh

Option A: Source the helper from a local clone:

# Add to .zshrc
source /path/to/lazyworktree/shell/functions.zsh

jt() { worktree_jump $(git rev-parse --show-toplevel) "$@"; }

Option B: Download the helper:

mkdir -p ~/.shell/functions
curl -sL https://raw.githubusercontent.com/chmouel/lazyworktree/refs/heads/main/shell/functions.zsh -o ~/.shell/functions/lazyworktree.zsh

# Add to .zshrc
source ~/.shell/functions/lazyworktree.zsh

jt() { worktree_jump $(git rev-parse --show-toplevel) "$@"; }

With completion:

source /path/to/lazyworktree/shell/functions.zsh

jt() { worktree_jump $(git rev-parse --show-toplevel) "$@"; }
_jt() { _worktree_jump $(git rev-parse --show-toplevel); }
compdef _jt jt

To add a shortcut to the last-selected worktree:

alias pl='worktree_go_last $(git rev-parse --show-toplevel)'

Fish

Option A: Source the helper from a local clone:

# Add to ~/.config/fish/config.fish
source /path/to/lazyworktree/shell/functions.fish

function jt
    worktree_jump $(git rev-parse --show-toplevel) $argv
end

Option B: Download the helper:

mkdir -p ~/.config/fish/conf.d
curl -sL https://raw.githubusercontent.com/chmouel/lazyworktree/refs/heads/main/shell/functions.fish -o ~/.config/fish/conf.d/lazyworktree.fish

# Add to ~/.config/fish/config.fish
function jt
    worktree_jump $(git rev-parse --show-toplevel) $argv
end

With completion:

source /path/to/lazyworktree/shell/functions.fish

function jt
    worktree_jump $(git rev-parse --show-toplevel) $argv
end

complete -c jt -f -a '(_worktree_jump $(git rev-parse --show-toplevel))'

To add a shortcut to the last-selected worktree:

function pl
    worktree_go_last $(git rev-parse --show-toplevel)
end

Shell Completion

Generate completion scripts for bash, zsh, or fish:

# Bash
eval "$(lazyworktree completion bash --code)"

# Zsh
eval "$(lazyworktree completion zsh --code)"

# Fish
lazyworktree completion fish --code > ~/.config/fish/completions/lazyworktree.fish

Or simply run lazyworktree completion to see instructions for your shell.

Package manager installations (deb, rpm, AUR) include completions automatically.