Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Integrate static completions into `wt init` for simpler setup

Maximilian Roos281fe04c8b5f
diff --git a/README.md b/README.md
index b3af2a2bd..3ccc2e9d1 100644
--- a/README.md
+++ b/README.md
@@ -19,11 +19,7 @@ cargo build --release
## Setup
-Worktrunk requires a two-step setup for full functionality:
-
-### 1. Shell Integration (for automatic `cd`)
-
-This enables `wt switch` and `wt finish` to automatically change directories.
+One-command setup that includes shell integration and completions:
**Bash** - Add to `~/.bashrc`:
```bash
@@ -40,34 +36,9 @@ wt init fish | source
eval "$(wt init zsh)"
```
-### 2. Shell Completion (for TAB completion)
-
-This enables completion for commands, flags, and branch names.
-
-**Fish:**
-```fish
-wt completion fish > ~/.config/fish/completions/wt.fish
-```
-
-**Bash** - Add to `~/.bashrc` (after the init line):
-```bash
-eval "$(wt completion bash)"
-```
-
-**Zsh** - Add to `~/.zshrc` (after the init line):
-```bash
-eval "$(wt completion zsh)"
-```
-
-### Complete Setup Example (Fish)
-
-```fish
-# In ~/.config/fish/config.fish
-wt init fish | source
-
-# Run once to install completions
-wt completion fish > ~/.config/fish/completions/wt.fish
-```
+This single command provides:
+- Shell integration for automatic `cd` on `wt switch` and `wt finish`
+- TAB completion for commands, flags, and branch names
### What Gets Completed
@@ -78,7 +49,7 @@ wt completion fish > ~/.config/fish/completions/wt.fish
**Notes:**
- Zsh currently uses Bash-compatible completion syntax. Dynamic branch completion may require `bashcompinit`. For best results, use Fish or Bash.
-- Regenerate completion scripts after updating `wt`
+- After updating `wt`, restart your shell or re-run the init command to get new completions
- Debug completion: Set `WT_DEBUG_COMPLETION=1` to see errors
- Performance: Run `cargo bench` to measure completion performance on your system
diff --git a/src/main.rs b/src/main.rs
index c708f8fdb..336cfc0ac 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -86,12 +86,14 @@ enum Commands {
},
/// Hook commands (for shell integration)
+ #[command(hide = true)]
Hook {
/// Hook type
hook_type: String,
},
- /// Generate shell completion script
+ /// Generate shell completion script (deprecated - use init instead)
+ #[command(hide = true)]
Completion {
/// Shell to generate completions for
#[arg(value_enum)]
@@ -154,11 +156,46 @@ fn handle_init(shell_name: &str, cmd: &str, hook_str: &str) -> Result<(), String
let init = shell::ShellInit::new(shell, cmd.to_string(), hook);
- let output = init
+ // Generate shell integration code
+ let integration_output = init
.generate()
.map_err(|e| format!("Failed to generate shell code: {}", e))?;
- println!("{}", output);
+ println!("{}", integration_output);
+
+ // Generate and append static completions
+ println!();
+ println!("# Static completions (commands and flags)");
+
+ // Generate completions to a string so we can filter out hidden commands
+ let mut completion_output = Vec::new();
+ let mut cmd = Cli::command();
+ let completion_shell = match shell {
+ shell::Shell::Bash => CompletionShell::Bash,
+ shell::Shell::Fish => CompletionShell::Fish,
+ shell::Shell::Zsh => CompletionShell::Zsh,
+ };
+ generate(completion_shell, &mut cmd, "wt", &mut completion_output);
+
+ // Filter out lines for hidden commands (hook, completion, complete)
+ let completion_str = String::from_utf8_lossy(&completion_output);
+ let filtered: Vec<&str> = completion_str
+ .lines()
+ .filter(|line| {
+ // Remove lines that complete the hidden commands
+ !(line.contains("\"hook\"")
+ || line.contains("\"completion\"")
+ || line.contains("\"complete\"")
+ || line.contains("-a \"hook\"")
+ || line.contains("-a \"completion\"")
+ || line.contains("-a \"complete\""))
+ })
+ .collect();
+
+ for line in filtered {
+ println!("{}", line);
+ }
+
Ok(())
}
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index 84a39d7b8..a2168c56c 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -71,4 +71,408 @@ _wt_complete() {
# Register dynamic completion
complete -F _wt_complete wt
+# Static completions (commands and flags)
+_wt() {
+ local i cur prev opts cmd
+ COMPREPLY=()
+ if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
+ cur="$2"
+ else
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ fi
+ prev="$3"
+ cmd=""
+ opts=""
+
+ for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
+ do
+ case "${cmd},${i}" in
+ ",$1")
+ cmd="wt"
+ ;;
+ wt,complete)
+ cmd="wt__complete"
+ ;;
+ wt,completion)
+ cmd="wt__completion"
+ ;;
+ wt,finish)
+ cmd="wt__finish"
+ ;;
+ wt,help)
+ cmd="wt__help"
+ ;;
+ wt,hook)
+ cmd="wt__hook"
+ ;;
+ wt,init)
+ cmd="wt__init"
+ ;;
+ wt,list)
+ cmd="wt__list"
+ ;;
+ wt,merge)
+ cmd="wt__merge"
+ ;;
+ wt,push)
+ cmd="wt__push"
+ ;;
+ wt,switch)
+ cmd="wt__switch"
+ ;;
+ wt__help,complete)
+ cmd="wt__help__complete"
+ ;;
+ wt__help,completion)
+ cmd="wt__help__completion"
+ ;;
+ wt__help,finish)
+ cmd="wt__help__finish"
+ ;;
+ wt__help,help)
+ cmd="wt__help__help"
+ ;;
+ wt__help,hook)
+ cmd="wt__help__hook"
+ ;;
+ wt__help,init)
+ cmd="wt__help__init"
+ ;;
+ wt__help,list)
+ cmd="wt__help__list"
+ ;;
+ wt__help,merge)
+ cmd="wt__help__merge"
+ ;;
+ wt__help,push)
+ cmd="wt__help__push"
+ ;;
+ wt__help,switch)
+ cmd="wt__help__switch"
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ case "${cmd}" in
+ wt)
+ opts="-h -V --help --version init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__complete)
+ opts="-h --help [ARGS]..."
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__completion)
+ opts="-h --help bash fish zsh"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__finish)
+ opts="-h --internal --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help)
+ opts="init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__complete)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__completion)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__finish)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__help)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__hook)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__init)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__list)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__merge)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__push)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__switch)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__hook)
+ opts="-h --help <HOOK_TYPE>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__init)
+ opts="-h --cmd --hook --help <SHELL>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --cmd)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ --hook)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__list)
+ opts="-h --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__merge)
+ opts="-k -h --keep --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__push)
+ opts="-h --allow-merge-commits --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__switch)
+ opts="-c -b -h --create --base --internal --help <BRANCH>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --base)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ -b)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ esac
+}
+
+if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
+ complete -F _wt -o nosort -o bashdefault -o default wt
+else
+ complete -F _wt -o bashdefault -o default wt
+fi
+
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap b/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap
index 37fbe2f7f..28ac1c01c 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap
@@ -88,4 +88,408 @@ _wt_complete() {
# Register dynamic completion
complete -F _wt_complete wt
+# Static completions (commands and flags)
+_wt() {
+ local i cur prev opts cmd
+ COMPREPLY=()
+ if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
+ cur="$2"
+ else
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ fi
+ prev="$3"
+ cmd=""
+ opts=""
+
+ for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
+ do
+ case "${cmd},${i}" in
+ ",$1")
+ cmd="wt"
+ ;;
+ wt,complete)
+ cmd="wt__complete"
+ ;;
+ wt,completion)
+ cmd="wt__completion"
+ ;;
+ wt,finish)
+ cmd="wt__finish"
+ ;;
+ wt,help)
+ cmd="wt__help"
+ ;;
+ wt,hook)
+ cmd="wt__hook"
+ ;;
+ wt,init)
+ cmd="wt__init"
+ ;;
+ wt,list)
+ cmd="wt__list"
+ ;;
+ wt,merge)
+ cmd="wt__merge"
+ ;;
+ wt,push)
+ cmd="wt__push"
+ ;;
+ wt,switch)
+ cmd="wt__switch"
+ ;;
+ wt__help,complete)
+ cmd="wt__help__complete"
+ ;;
+ wt__help,completion)
+ cmd="wt__help__completion"
+ ;;
+ wt__help,finish)
+ cmd="wt__help__finish"
+ ;;
+ wt__help,help)
+ cmd="wt__help__help"
+ ;;
+ wt__help,hook)
+ cmd="wt__help__hook"
+ ;;
+ wt__help,init)
+ cmd="wt__help__init"
+ ;;
+ wt__help,list)
+ cmd="wt__help__list"
+ ;;
+ wt__help,merge)
+ cmd="wt__help__merge"
+ ;;
+ wt__help,push)
+ cmd="wt__help__push"
+ ;;
+ wt__help,switch)
+ cmd="wt__help__switch"
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ case "${cmd}" in
+ wt)
+ opts="-h -V --help --version init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__complete)
+ opts="-h --help [ARGS]..."
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__completion)
+ opts="-h --help bash fish zsh"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__finish)
+ opts="-h --internal --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help)
+ opts="init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__complete)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__completion)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__finish)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__help)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__hook)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__init)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__list)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__merge)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__push)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__switch)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__hook)
+ opts="-h --help <HOOK_TYPE>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__init)
+ opts="-h --cmd --hook --help <SHELL>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --cmd)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ --hook)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__list)
+ opts="-h --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__merge)
+ opts="-k -h --keep --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__push)
+ opts="-h --allow-merge-commits --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__switch)
+ opts="-c -b -h --create --base --internal --help <BRANCH>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --base)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ -b)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ esac
+}
+
+if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
+ complete -F _wt -o nosort -o bashdefault -o default wt
+else
+ complete -F _wt -o bashdefault -o default wt
+fi
+
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap
index 4603bc2ff..f0fd2790d 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap
@@ -73,4 +73,408 @@ _wt_complete() {
# Register dynamic completion
complete -F _wt_complete wt
+# Static completions (commands and flags)
+_wt() {
+ local i cur prev opts cmd
+ COMPREPLY=()
+ if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
+ cur="$2"
+ else
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ fi
+ prev="$3"
+ cmd=""
+ opts=""
+
+ for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
+ do
+ case "${cmd},${i}" in
+ ",$1")
+ cmd="wt"
+ ;;
+ wt,complete)
+ cmd="wt__complete"
+ ;;
+ wt,completion)
+ cmd="wt__completion"
+ ;;
+ wt,finish)
+ cmd="wt__finish"
+ ;;
+ wt,help)
+ cmd="wt__help"
+ ;;
+ wt,hook)
+ cmd="wt__hook"
+ ;;
+ wt,init)
+ cmd="wt__init"
+ ;;
+ wt,list)
+ cmd="wt__list"
+ ;;
+ wt,merge)
+ cmd="wt__merge"
+ ;;
+ wt,push)
+ cmd="wt__push"
+ ;;
+ wt,switch)
+ cmd="wt__switch"
+ ;;
+ wt__help,complete)
+ cmd="wt__help__complete"
+ ;;
+ wt__help,completion)
+ cmd="wt__help__completion"
+ ;;
+ wt__help,finish)
+ cmd="wt__help__finish"
+ ;;
+ wt__help,help)
+ cmd="wt__help__help"
+ ;;
+ wt__help,hook)
+ cmd="wt__help__hook"
+ ;;
+ wt__help,init)
+ cmd="wt__help__init"
+ ;;
+ wt__help,list)
+ cmd="wt__help__list"
+ ;;
+ wt__help,merge)
+ cmd="wt__help__merge"
+ ;;
+ wt__help,push)
+ cmd="wt__help__push"
+ ;;
+ wt__help,switch)
+ cmd="wt__help__switch"
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ case "${cmd}" in
+ wt)
+ opts="-h -V --help --version init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__complete)
+ opts="-h --help [ARGS]..."
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__completion)
+ opts="-h --help bash fish zsh"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__finish)
+ opts="-h --internal --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help)
+ opts="init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__complete)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__completion)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__finish)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__help)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__hook)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__init)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__list)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__merge)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__push)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__switch)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__hook)
+ opts="-h --help <HOOK_TYPE>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__init)
+ opts="-h --cmd --hook --help <SHELL>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --cmd)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ --hook)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__list)
+ opts="-h --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__merge)
+ opts="-k -h --keep --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__push)
+ opts="-h --allow-merge-commits --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__switch)
+ opts="-c -b -h --create --base --internal --help <BRANCH>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --base)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ -b)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ esac
+}
+
+if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
+ complete -F _wt -o nosort -o bashdefault -o default wt
+else
+ complete -F _wt -o bashdefault -o default wt
+fi
+
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap b/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap
index 7ee57dd24..81b7e9845 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap
@@ -86,4 +86,408 @@ _wt_complete() {
# Register dynamic completion
complete -F _wt_complete wt
+# Static completions (commands and flags)
+_wt() {
+ local i cur prev opts cmd
+ COMPREPLY=()
+ if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
+ cur="$2"
+ else
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ fi
+ prev="$3"
+ cmd=""
+ opts=""
+
+ for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
+ do
+ case "${cmd},${i}" in
+ ",$1")
+ cmd="wt"
+ ;;
+ wt,complete)
+ cmd="wt__complete"
+ ;;
+ wt,completion)
+ cmd="wt__completion"
+ ;;
+ wt,finish)
+ cmd="wt__finish"
+ ;;
+ wt,help)
+ cmd="wt__help"
+ ;;
+ wt,hook)
+ cmd="wt__hook"
+ ;;
+ wt,init)
+ cmd="wt__init"
+ ;;
+ wt,list)
+ cmd="wt__list"
+ ;;
+ wt,merge)
+ cmd="wt__merge"
+ ;;
+ wt,push)
+ cmd="wt__push"
+ ;;
+ wt,switch)
+ cmd="wt__switch"
+ ;;
+ wt__help,complete)
+ cmd="wt__help__complete"
+ ;;
+ wt__help,completion)
+ cmd="wt__help__completion"
+ ;;
+ wt__help,finish)
+ cmd="wt__help__finish"
+ ;;
+ wt__help,help)
+ cmd="wt__help__help"
+ ;;
+ wt__help,hook)
+ cmd="wt__help__hook"
+ ;;
+ wt__help,init)
+ cmd="wt__help__init"
+ ;;
+ wt__help,list)
+ cmd="wt__help__list"
+ ;;
+ wt__help,merge)
+ cmd="wt__help__merge"
+ ;;
+ wt__help,push)
+ cmd="wt__help__push"
+ ;;
+ wt__help,switch)
+ cmd="wt__help__switch"
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ case "${cmd}" in
+ wt)
+ opts="-h -V --help --version init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__complete)
+ opts="-h --help [ARGS]..."
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__completion)
+ opts="-h --help bash fish zsh"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__finish)
+ opts="-h --internal --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help)
+ opts="init list switch finish push merge hook completion complete help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__complete)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__completion)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__finish)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__help)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__hook)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__init)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__list)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__merge)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__push)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__help__switch)
+ opts=""
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__hook)
+ opts="-h --help <HOOK_TYPE>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__init)
+ opts="-h --cmd --hook --help <SHELL>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --cmd)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ --hook)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__list)
+ opts="-h --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__merge)
+ opts="-k -h --keep --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__push)
+ opts="-h --allow-merge-commits --help [TARGET]"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__switch)
+ opts="-c -b -h --create --base --internal --help <BRANCH>"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ --base)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ -b)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ esac
+}
+
+if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
+ complete -F _wt -o nosort -o bashdefault -o default wt
+else
+ complete -F _wt -o bashdefault -o default wt
+fi
+
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index 6a7d00bab..b21e558e4 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -68,4 +68,65 @@ complete -c wt -n '__fish_seen_subcommand_from push' -f -a '(__wt_complete)' -d
complete -c wt -n '__fish_seen_subcommand_from merge' -f -a '(__wt_complete)' -d 'Target branch'
complete -c wt -l base -f -a '(__wt_complete)' -d 'Base branch'
+# Static completions (commands and flags)
+# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
+function __fish_wt_global_optspecs
+ string join \n h/help V/version
+end
+
+function __fish_wt_needs_command
+ # Figure out if the current invocation already has a command.
+ set -l cmd (commandline -opc)
+ set -e cmd[1]
+ argparse -s (__fish_wt_global_optspecs) -- $cmd 2>/dev/null
+ or return
+ if set -q argv[1]
+ # Also print the command, so this can be used to figure out what it is.
+ echo $argv[1]
+ return 1
+ end
+ return 0
+end
+
+function __fish_wt_using_subcommand
+ set -l cmd (__fish_wt_needs_command)
+ test -z "$cmd"
+ and return 1
+ contains -- $cmd[1] $argv
+end
+
+complete -c wt -n "__fish_wt_needs_command" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_needs_command" -s V -l version -d 'Print version'
+complete -c wt -n "__fish_wt_needs_command" -f -a "init" -d 'Generate shell integration code'
+complete -c wt -n "__fish_wt_needs_command" -f -a "list" -d 'List all worktrees'
+complete -c wt -n "__fish_wt_needs_command" -f -a "switch" -d 'Switch to a worktree (creates if doesn\'t exist)'
+complete -c wt -n "__fish_wt_needs_command" -f -a "finish" -d 'Finish current worktree and return to primary'
+complete -c wt -n "__fish_wt_needs_command" -f -a "push" -d 'Push changes between worktrees'
+complete -c wt -n "__fish_wt_needs_command" -f -a "merge" -d 'Merge and cleanup worktree'
+complete -c wt -n "__fish_wt_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
+complete -c wt -n "__fish_wt_using_subcommand init" -l cmd -d 'Command prefix (default: wt)' -r
+complete -c wt -n "__fish_wt_using_subcommand init" -l hook -d 'Hook mode (none, prompt)' -r
+complete -c wt -n "__fish_wt_using_subcommand init" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand list" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand switch" -s b -l base -d 'Base branch to create from (only with --create)' -r
+complete -c wt -n "__fish_wt_using_subcommand switch" -s c -l create -d 'Create a new branch'
+complete -c wt -n "__fish_wt_using_subcommand switch" -l internal -d 'Use internal mode (outputs directives for shell wrapper)'
+complete -c wt -n "__fish_wt_using_subcommand switch" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand finish" -l internal -d 'Use internal mode (outputs directives for shell wrapper)'
+complete -c wt -n "__fish_wt_using_subcommand finish" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand push" -l allow-merge-commits -d 'Allow pushing merge commits (non-linear history)'
+complete -c wt -n "__fish_wt_using_subcommand push" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand merge" -s k -l keep -d 'Keep worktree after merging (don\'t finish)'
+complete -c wt -n "__fish_wt_using_subcommand merge" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand hook" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand completion" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand complete" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "init" -d 'Generate shell integration code'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "list" -d 'List all worktrees'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "switch" -d 'Switch to a worktree (creates if doesn\'t exist)'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "finish" -d 'Finish current worktree and return to primary'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "push" -d 'Push changes between worktrees'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "merge" -d 'Merge and cleanup worktree'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
+
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap b/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap
index 46825b106..22e679e97 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap
@@ -76,4 +76,65 @@ complete -c wt -n '__fish_seen_subcommand_from push' -f -a '(__wt_complete)' -d
complete -c wt -n '__fish_seen_subcommand_from merge' -f -a '(__wt_complete)' -d 'Target branch'
complete -c wt -l base -f -a '(__wt_complete)' -d 'Base branch'
+# Static completions (commands and flags)
+# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
+function __fish_wt_global_optspecs
+ string join \n h/help V/version
+end
+
+function __fish_wt_needs_command
+ # Figure out if the current invocation already has a command.
+ set -l cmd (commandline -opc)
+ set -e cmd[1]
+ argparse -s (__fish_wt_global_optspecs) -- $cmd 2>/dev/null
+ or return
+ if set -q argv[1]
+ # Also print the command, so this can be used to figure out what it is.
+ echo $argv[1]
+ return 1
+ end
+ return 0
+end
+
+function __fish_wt_using_subcommand
+ set -l cmd (__fish_wt_needs_command)
+ test -z "$cmd"
+ and return 1
+ contains -- $cmd[1] $argv
+end
+
+complete -c wt -n "__fish_wt_needs_command" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_needs_command" -s V -l version -d 'Print version'
+complete -c wt -n "__fish_wt_needs_command" -f -a "init" -d 'Generate shell integration code'
+complete -c wt -n "__fish_wt_needs_command" -f -a "list" -d 'List all worktrees'
+complete -c wt -n "__fish_wt_needs_command" -f -a "switch" -d 'Switch to a worktree (creates if doesn\'t exist)'
+complete -c wt -n "__fish_wt_needs_command" -f -a "finish" -d 'Finish current worktree and return to primary'
+complete -c wt -n "__fish_wt_needs_command" -f -a "push" -d 'Push changes between worktrees'
+complete -c wt -n "__fish_wt_needs_command" -f -a "merge" -d 'Merge and cleanup worktree'
+complete -c wt -n "__fish_wt_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
+complete -c wt -n "__fish_wt_using_subcommand init" -l cmd -d 'Command prefix (default: wt)' -r
+complete -c wt -n "__fish_wt_using_subcommand init" -l hook -d 'Hook mode (none, prompt)' -r
+complete -c wt -n "__fish_wt_using_subcommand init" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand list" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand switch" -s b -l base -d 'Base branch to create from (only with --create)' -r
+complete -c wt -n "__fish_wt_using_subcommand switch" -s c -l create -d 'Create a new branch'
+complete -c wt -n "__fish_wt_using_subcommand switch" -l internal -d 'Use internal mode (outputs directives for shell wrapper)'
+complete -c wt -n "__fish_wt_using_subcommand switch" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand finish" -l internal -d 'Use internal mode (outputs directives for shell wrapper)'
+complete -c wt -n "__fish_wt_using_subcommand finish" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand push" -l allow-merge-commits -d 'Allow pushing merge commits (non-linear history)'
+complete -c wt -n "__fish_wt_using_subcommand push" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand merge" -s k -l keep -d 'Keep worktree after merging (don\'t finish)'
+complete -c wt -n "__fish_wt_using_subcommand merge" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand hook" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand completion" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand complete" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "init" -d 'Generate shell integration code'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "list" -d 'List all worktrees'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "switch" -d 'Switch to a worktree (creates if doesn\'t exist)'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "finish" -d 'Finish current worktree and return to primary'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "push" -d 'Push changes between worktrees'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "merge" -d 'Merge and cleanup worktree'
+complete -c wt -n "__fish_wt_using_subcommand help; and not __fish_seen_subcommand_from init list switch finish push merge hook completion complete help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
+
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index 9cbb4f7a9..c9e38e23d 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -71,4 +71,302 @@ _wt_complete() {
# Register dynamic completion
complete -F _wt_complete wt
+# Static completions (commands and flags)
+#compdef wt
+
+autoload -U is-at-least
+
+_wt() {
+ typeset -A opt_args
+ typeset -a _arguments_options
+ local ret=1
+
+ if is-at-least 5.2; then
+ _arguments_options=(-s -S -C)
+ else
+ _arguments_options=(-s -C)
+ fi
+
+ local context curcontext="$curcontext" state line
+ _arguments "${_arguments_options[@]}" : \
+'-h[Print help]' \
+'--help[Print help]' \
+'-V[Print version]' \
+'--version[Print version]' \
+":: :_wt_commands" \
+"*::: :->wt" \
+&& ret=0
+ case $state in
+ (wt)
+ words=($line[1] "${words[@]}")
+ (( CURRENT += 1 ))
+ curcontext="${curcontext%:*:*}:wt-command-$line[1]:"
+ case $line[1] in
+ (init)
+_arguments "${_arguments_options[@]}" : \
+'--cmd=[Command prefix (default\: wt)]:CMD:_default' \
+'--hook=[Hook mode (none, prompt)]:HOOK:_default' \
+'-h[Print help]' \
+'--help[Print help]' \
+':shell -- Shell to generate code for (bash, fish, zsh):_default' \
+&& ret=0
+;;
+(list)
+_arguments "${_arguments_options[@]}" : \
+'-h[Print help]' \
+'--help[Print help]' \
+&& ret=0
+;;
+(switch)
+_arguments "${_arguments_options[@]}" : \
+'-b+[Base branch to create from (only with --create)]:BASE:_default' \
+'--base=[Base branch to create from (only with --create)]:BASE:_default' \
+'-c[Create a new branch]' \
+'--create[Create a new branch]' \
+'--internal[Use internal mode (outputs directives for shell wrapper)]' \
+'-h[Print help]' \
+'--help[Print help]' \
+':branch -- Branch name or worktree path:_default' \
+&& ret=0
+;;
+(finish)
+_arguments "${_arguments_options[@]}" : \
+'--internal[Use internal mode (outputs directives for shell wrapper)]' \
+'-h[Print help]' \
+'--help[Print help]' \
+&& ret=0
+;;
+(push)
+_arguments "${_arguments_options[@]}" : \
+'--allow-merge-commits[Allow pushing merge commits (non-linear history)]' \
+'-h[Print help]' \
+'--help[Print help]' \
+'::target -- Target branch (defaults to default branch):_default' \
+&& ret=0
+;;
+(merge)
+_arguments "${_arguments_options[@]}" : \
+'-k[Keep worktree after merging (don'\''t finish)]' \
+'--keep[Keep worktree after merging (don'\''t finish)]' \
+'-h[Print help]' \
+'--help[Print help]' \
+'::target -- Target branch to merge into (defaults to default branch):_default' \
+&& ret=0
+;;
+(hook)
+_arguments "${_arguments_options[@]}" : \
+'-h[Print help]' \
+'--help[Print help]' \
+':hook_type -- Hook type:_default' \
+&& ret=0
+;;
+(completion)
+_arguments "${_arguments_options[@]}" : \
+'-h[Print help]' \
+'--help[Print help]' \
+':shell -- Shell to generate completions for:(bash fish zsh)' \
+&& ret=0
+;;
+(complete)
+_arguments "${_arguments_options[@]}" : \
+'-h[Print help]' \
+'--help[Print help]' \
+'*::args -- Arguments to complete:_default' \
+&& ret=0
+;;
+(help)
+_arguments "${_arguments_options[@]}" : \
+":: :_wt__help_commands" \
+"*::: :->help" \
+&& ret=0
+
+ case $state in
+ (help)
+ words=($line[1] "${words[@]}")
+ (( CURRENT += 1 ))
+ curcontext="${curcontext%:*:*}:wt-help-command-$line[1]:"
+ case $line[1] in
+ (init)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(list)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(switch)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(finish)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(push)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(merge)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(hook)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(completion)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(complete)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+(help)
+_arguments "${_arguments_options[@]}" : \
+&& ret=0
+;;
+ esac
+ ;;
+esac
+;;
+ esac
+ ;;
+esac
+}
+
+(( $+functions[_wt_commands] )) ||
+_wt_commands() {
+ local commands; commands=(
+'init:Generate shell integration code' \
+'list:List all worktrees' \
+'switch:Switch to a worktree (creates if doesn'\''t exist)' \
+'finish:Finish current worktree and return to primary' \
+'push:Push changes between worktrees' \
+'merge:Merge and cleanup worktree' \
+'hook:Hook commands (for shell integration)' \
+'completion:Generate shell completion script (deprecated - use init instead)' \
+'complete:Internal completion helper (hidden)' \
+'help:Print this message or the help of the given subcommand(s)' \
+ )
+ _describe -t commands 'wt commands' commands "$@"
+}
+(( $+functions[_wt__complete_commands] )) ||
+_wt__complete_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt complete commands' commands "$@"
+}
+(( $+functions[_wt__completion_commands] )) ||
+_wt__completion_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt completion commands' commands "$@"
+}
+(( $+functions[_wt__finish_commands] )) ||
+_wt__finish_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt finish commands' commands "$@"
+}
+(( $+functions[_wt__help_commands] )) ||
+_wt__help_commands() {
+ local commands; commands=(
+'init:Generate shell integration code' \
+'list:List all worktrees' \
+'switch:Switch to a worktree (creates if doesn'\''t exist)' \
+'finish:Finish current worktree and return to primary' \
+'push:Push changes between worktrees' \
+'merge:Merge and cleanup worktree' \
+'hook:Hook commands (for shell integration)' \
+'completion:Generate shell completion script (deprecated - use init instead)' \
+'complete:Internal completion helper (hidden)' \
+'help:Print this message or the help of the given subcommand(s)' \
+ )
+ _describe -t commands 'wt help commands' commands "$@"
+}
+(( $+functions[_wt__help__complete_commands] )) ||
+_wt__help__complete_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help complete commands' commands "$@"
+}
+(( $+functions[_wt__help__completion_commands] )) ||
+_wt__help__completion_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help completion commands' commands "$@"
+}
+(( $+functions[_wt__help__finish_commands] )) ||
+_wt__help__finish_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help finish commands' commands "$@"
+}
+(( $+functions[_wt__help__help_commands] )) ||
+_wt__help__help_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help help commands' commands "$@"
+}
+(( $+functions[_wt__help__hook_commands] )) ||
+_wt__help__hook_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help hook commands' commands "$@"
+}
+(( $+functions[_wt__help__init_commands] )) ||
+_wt__help__init_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help init commands' commands "$@"
+}
+(( $+functions[_wt__help__list_commands] )) ||
+_wt__help__list_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help list commands' commands "$@"
+}
+(( $+functions[_wt__help__merge_commands] )) ||
+_wt__help__merge_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help merge commands' commands "$@"
+}
+(( $+functions[_wt__help__push_commands] )) ||
+_wt__help__push_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help push commands' commands "$@"
+}
+(( $+functions[_wt__help__switch_commands] )) ||
+_wt__help__switch_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt help switch commands' commands "$@"
+}
+(( $+functions[_wt__hook_commands] )) ||
+_wt__hook_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt hook commands' commands "$@"
+}
+(( $+functions[_wt__init_commands] )) ||
+_wt__init_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt init commands' commands "$@"
+}
+(( $+functions[_wt__list_commands] )) ||
+_wt__list_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt list commands' commands "$@"
+}
+(( $+functions[_wt__merge_commands] )) ||
+_wt__merge_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt merge commands' commands "$@"
+}
+(( $+functions[_wt__push_commands] )) ||
+_wt__push_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt push commands' commands "$@"
+}
+(( $+functions[_wt__switch_commands] )) ||
+_wt__switch_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt switch commands' commands "$@"
+}
+
+if [ "$funcstack[1]" = "_wt" ]; then
+ _wt "$@"
+else
+ compdef _wt wt
+fi
+
----- stderr -----