Shell completions
gwm completions <shell> prints a static completion script (generated from the live clap argument tree, so it never drifts from the actual subcommands). Supported shells: zsh, bash, fish, powershell, elvish.
Install
Section titled “Install”# zsh — drop into the first writable fpath entrygwm completions zsh > "${fpath[1]}/_gwm"
# bash — system-widegwm completions bash | sudo tee /etc/bash_completion.d/gwm > /dev/null# bash — per-usergwm completions bash > ~/.local/share/bash-completion/completions/gwm
# fishgwm completions fish > ~/.config/fish/completions/gwm.fish
# PowerShell — load into the current session (ephemeral)gwm completions powershell | Out-String | Invoke-Expression# PowerShell — persist by appending to $PROFILEgwm completions powershell | Out-File -Append -Encoding utf8 $PROFILE
# elvishgwm completions elvish > ~/.config/elvish/lib/gwm.elvOpen a fresh shell (or source your rc file) and tab completion is live for every subcommand, flag, and value-enum (e.g. gwm list --format=<TAB> offers table / names).
Dynamic worktree-name completion
Section titled “Dynamic worktree-name completion”The static script knows about subcommands and flags but not about the worktrees in your repo, which change every time you run gwm create / remove. Wire a custom completer to gwm list --format=names for live completion of the worktree-name arg on path / cd / remove / bootstrap / sync / tmux / zellij / herdr / exec / clean (all of which resolve their positional through the same fuzzy matcher).
_gwm_worktrees() { compadd $(gwm list --format=names 2>/dev/null) }compdef _gwm_worktrees gwm-path gwm-cd gwm-remove gwm-bootstrap gwm-sync gwm-tmux gwm-zellij gwm-herdr gwm-exec gwm-clean(gwm-path, gwm-cd, etc. are the auto-generated function names the static _gwm completer registers per-subcommand.)
_gwm_worktrees() { local cur="${COMP_WORDS[COMP_CWORD]}" COMPREPLY=($(compgen -W "$(gwm list --format=names 2>/dev/null)" -- "$cur"))}complete -F _gwm_worktrees -o default gwmcomplete -c gwm -n "__fish_seen_subcommand_from path cd remove bootstrap sync tmux zellij herdr exec clean" \ -f -a "(gwm list --format=names 2>/dev/null)"See also
Section titled “See also”- Getting started → Shell init: the
gcdwrapper that ships alongsidecompletions - CLI → Subcommand reference: the
--format=namesoutput used by the completers