Skip to content

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

Remove prompt hook functionality

Maximilian Roosbde79b70ea49
diff --git a/DEMO.md b/DEMO.md
index 39517e17e..e8c41942f 100644
--- a/DEMO.md
+++ b/DEMO.md
@@ -114,23 +114,6 @@ $ myprefix finish
$ myprefix list
```
-### Enable Prompt Hook
-
-```bash
-# Track worktree in every prompt
-$ eval "$(wt init bash --hook prompt)"
-
-# Now wt hook prompt runs before each prompt
-# (useful for showing current worktree in PS1)
-```
-
-### Multiple Options Combined
-
-```bash
-# Custom prefix + prompt hook
-$ eval "$(wt init fish --cmd myprefix --hook prompt)"
-```
-
## Implementation Architecture
```
@@ -180,13 +163,10 @@ chmod +x .tmp/test_integration.sh
# Test 3: Test custom command prefix
# ✓ Custom command prefix works
#
-# Test 4: Test prompt hook
-# ✓ Prompt hook generated successfully
-#
-# Test 5: Test directive output
+# Test 4: Test directive output
# ✓ Directive output works
#
-# Test 6: Simulate shell wrapper behavior
+# Test 5: Simulate shell wrapper behavior
# ✓ Shell wrapper functions work
#
# All tests passed! ✓
diff --git a/README.md b/README.md
index 5bfc1eaab..ff6a83f34 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ A Rust-based CLI tool for managing git worktrees with seamless shell integration
- **Shell Integration**: Automatically `cd` to worktrees when switching
- **Multiple Shells**: Supports Bash, Fish, Zsh, Nushell, PowerShell, Elvish, Xonsh, and Oil Shell
-- **Customizable**: Configure command prefix and hook behavior
+- **Customizable**: Configure command prefix
- **Fast**: Built in Rust for performance
- **Clean Design**: Uses the proven "eval init" pattern from tools like zoxide and starship
@@ -115,12 +115,6 @@ eval "$(wt init bash --cmd myprefix)"
# Now use: myprefix switch, myprefix remove, etc.
```
-**Enable prompt hook:**
-```bash
-# Track worktree changes in your prompt
-eval "$(wt init bash --hook prompt)"
-```
-
## How It Works
Worktrunk uses a **directive protocol** to communicate with shell wrappers:
@@ -191,8 +185,7 @@ wt (Rust binary)
│ └── wt merge
├── Internal commands (for shell wrapper)
│ ├── wt switch --internal → outputs __WORKTRUNK_CD__ directives
-│ ├── wt remove --internal → outputs __WORKTRUNK_CD__ directives
-│ └── wt hook prompt → for prompt integration
+│ └── wt remove --internal → outputs __WORKTRUNK_CD__ directives
└── Shell integration
└── wt init <shell> → outputs shell wrapper function
```
diff --git a/TODO.md b/TODO.md
index 2ac47cf96..db4389446 100644
--- a/TODO.md
+++ b/TODO.md
@@ -78,7 +78,6 @@ Interface with shell and external tools.
- Execute shell commands (git-commit-llm, claude, task)
- Background process management (disown equivalent)
- Shell function generation (for `cd` integration)
-- Hook system for custom commands
**Dependencies:** Workstream 1
@@ -130,8 +129,7 @@ wt (Rust binary)
│ └── wt status
├── Internal commands (for shell wrapper)
│ ├── wt switch --internal → outputs __WORKTRUNK_CD__ directives
-│ ├── wt finish --internal → outputs __WORKTRUNK_CD__ directives
-│ └── wt hook prompt → for prompt integration
+│ └── wt finish --internal → outputs __WORKTRUNK_CD__ directives
└── Shell integration
└── wt init <shell> → outputs shell wrapper functions
```
@@ -183,14 +181,10 @@ Another output line
2. **Shell Support**: Start with Bash and Fish, extend to Zsh later
3. **Customization Flags**:
- `--cmd <prefix>`: Customize command prefix (default: "wt")
- - `--hook <mode>`: Control tracking updates (none, prompt)
- - `--no-alias`: Skip creating convenience aliases
4. **Progressive Enhancement Levels**:
- Level 0: Just the binary - works but requires manual `cd`
- Level 1: Shell wrapper - auto-`cd` on switch
- - Level 2: Prompt hooks - track current worktree in prompt
- - Level 3: Auto-switching - detect worktree markers
### Implementation Phases
@@ -210,7 +204,6 @@ Another output line
**Phase 3: Enhancement**
- [ ] Add `--cmd` flag for command prefix customization
-- [ ] Add `--hook prompt` for prompt integration
- [ ] Implement shell completion generation
- [ ] Add Zsh support
@@ -219,7 +212,6 @@ Another output line
- **Keep execution fast** (<500ms) - don't block the shell (direnv)
- **Use Askama** for type-safe templates (zoxide)
- **Support customizable command prefixes** (zoxide `--cmd`)
-- **Provide hook modes** for different tracking strategies (zoxide `--hook`)
- **Keep binary stateless** (starship)
- **Make shell integration minimal** (starship)
diff --git a/src/main.rs b/src/main.rs
index e986fac6f..e9840a026 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ use anstyle::{AnsiColor, Color, Style};
use clap::{CommandFactory, Parser, Subcommand};
use clap_complete::{Shell as CompletionShell, generate};
use rayon::prelude::*;
+use std::io;
use std::path::Path;
use std::process;
use worktrunk::config::{format_worktree_path, load_config};
@@ -36,10 +37,6 @@ enum Commands {
/// Command prefix (default: wt)
#[arg(long, default_value = "wt")]
cmd: String,
-
- /// Hook mode (none, prompt)
- #[arg(long, default_value = "none")]
- hook: String,
},
/// List all worktrees
@@ -94,11 +91,12 @@ enum Commands {
keep: bool,
},
- /// Hook commands (for shell integration)
+ /// Generate shell completion script (deprecated - use init instead)
#[command(hide = true)]
- Hook {
- /// Hook type
- hook_type: String,
+ Completion {
+ /// Shell to generate completions for
+ #[arg(value_enum)]
+ shell: Shell,
},
/// Internal completion helper (hidden)
@@ -110,13 +108,18 @@ enum Commands {
},
}
+#[derive(clap::ValueEnum, Clone, Copy)]
+enum Shell {
+ Bash,
+ Fish,
+ Zsh,
+}
+
fn main() {
let cli = Cli::parse();
let result = match cli.command {
- Commands::Init { shell, cmd, hook } => {
- handle_init(&shell, &cmd, &hook).map_err(GitError::CommandFailed)
- }
+ Commands::Init { shell, cmd } => handle_init(&shell, &cmd).map_err(GitError::CommandFailed),
Commands::List => handle_list(),
Commands::Switch {
branch,
@@ -144,7 +147,10 @@ fn main() {
squash,
keep,
} => handle_merge(target.as_deref(), squash, keep),
- Commands::Hook { hook_type } => handle_hook(&hook_type).map_err(GitError::CommandFailed),
+ Commands::Completion { shell } => {
+ handle_completion(shell);
+ Ok(())
+ }
Commands::Complete { args } => handle_complete(args),
};
@@ -155,11 +161,10 @@ fn main() {
}
}
-fn handle_init(shell_name: &str, cmd: &str, hook_str: &str) -> Result<(), String> {
+fn handle_init(shell_name: &str, cmd: &str) -> Result<(), String> {
let shell = shell_name.parse::<shell::Shell>()?;
- let hook = hook_str.parse::<shell::Hook>()?;
- let init = shell::ShellInit::new(shell, cmd.to_string(), hook);
+ let init = shell::ShellInit::new(shell, cmd.to_string());
// Generate shell integration code
let integration_output = init
@@ -192,16 +197,14 @@ fn handle_init(shell_name: &str, cmd: &str, hook_str: &str) -> Result<(), String
};
generate(completion_shell, &mut cmd, "wt", &mut completion_output);
- // Filter out lines for hidden commands (hook, completion, complete)
+ // Filter out lines for hidden commands (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("\"completion\"")
|| line.contains("\"complete\"")
- || line.contains("-a \"hook\"")
|| line.contains("-a \"completion\"")
|| line.contains("-a \"complete\""))
})
@@ -1030,15 +1033,14 @@ fn handle_merge(target: Option<&str>, squash: bool, keep: bool) -> Result<(), Gi
Ok(())
}
-fn handle_hook(hook_type: &str) -> Result<(), String> {
- match hook_type {
- "prompt" => {
- // TODO: Implement prompt hook logic
- // This would update tracking, show current worktree, etc.
- Ok(())
- }
- _ => Err(format!("Unknown hook type: {}", hook_type)),
- }
+fn handle_completion(shell: Shell) {
+ let mut cmd = Cli::command();
+ let completion_shell = match shell {
+ Shell::Bash => CompletionShell::Bash,
+ Shell::Fish => CompletionShell::Fish,
+ Shell::Zsh => CompletionShell::Zsh,
+ };
+ generate(completion_shell, &mut cmd, "wt", &mut io::stdout());
}
#[derive(Debug, PartialEq)]
diff --git a/src/shell.rs b/src/shell.rs
index 06edd4298..b6909ab3e 100644
--- a/src/shell.rs
+++ b/src/shell.rs
@@ -47,50 +47,15 @@ impl fmt::Display for Shell {
}
}
-/// Hook mode for tracking worktree changes
-#[derive(Debug, Clone, Copy)]
-pub enum Hook {
- /// Don't hook into shell - user calls commands manually
- None,
- /// Hook into shell prompt - update tracking on every prompt
- Prompt,
-}
-
-impl std::str::FromStr for Hook {
- type Err = String;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- match s.to_lowercase().as_str() {
- "none" => Ok(Hook::None),
- "prompt" => Ok(Hook::Prompt),
- _ => Err(format!("Invalid hook mode: {}", s)),
- }
- }
-}
-
-impl fmt::Display for Hook {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- Hook::None => write!(f, "none"),
- Hook::Prompt => write!(f, "prompt"),
- }
- }
-}
-
/// Shell integration configuration
pub struct ShellInit {
pub shell: Shell,
pub cmd_prefix: String,
- pub hook: Hook,
}
impl ShellInit {
- pub fn new(shell: Shell, cmd_prefix: String, hook: Hook) -> Self {
- Self {
- shell,
- cmd_prefix,
- hook,
- }
+ pub fn new(shell: Shell, cmd_prefix: String) -> Self {
+ Self { shell, cmd_prefix }
}
/// Generate shell integration code
@@ -100,42 +65,36 @@ impl ShellInit {
let template = BashTemplate {
shell_name: self.shell.to_string(),
cmd_prefix: &self.cmd_prefix,
- hook: self.hook,
};
template.render()
}
Shell::Fish => {
let template = FishTemplate {
cmd_prefix: &self.cmd_prefix,
- hook: self.hook,
};
template.render()
}
Shell::Nushell => {
let template = NushellTemplate {
cmd_prefix: &self.cmd_prefix,
- hook: self.hook,
};
template.render()
}
Shell::Powershell => {
let template = PowershellTemplate {
cmd_prefix: &self.cmd_prefix,
- hook: self.hook,
};
template.render()
}
Shell::Elvish => {
let template = ElvishTemplate {
cmd_prefix: &self.cmd_prefix,
- hook: self.hook,
};
template.render()
}
Shell::Xonsh => {
let template = XonshTemplate {
cmd_prefix: &self.cmd_prefix,
- hook: self.hook,
};
template.render()
}
@@ -149,7 +108,6 @@ impl ShellInit {
struct BashTemplate<'a> {
shell_name: String,
cmd_prefix: &'a str,
- hook: Hook,
}
/// Fish shell template
@@ -157,7 +115,6 @@ struct BashTemplate<'a> {
#[template(path = "fish.fish", escape = "none")]
struct FishTemplate<'a> {
cmd_prefix: &'a str,
- hook: Hook,
}
/// Nushell shell template
@@ -165,7 +122,6 @@ struct FishTemplate<'a> {
#[template(path = "nushell.nu", escape = "none")]
struct NushellTemplate<'a> {
cmd_prefix: &'a str,
- hook: Hook,
}
/// PowerShell template
@@ -173,7 +129,6 @@ struct NushellTemplate<'a> {
#[template(path = "powershell.ps1", escape = "none")]
struct PowershellTemplate<'a> {
cmd_prefix: &'a str,
- hook: Hook,
}
/// Elvish shell template
@@ -181,7 +136,6 @@ struct PowershellTemplate<'a> {
#[template(path = "elvish.elv", escape = "none")]
struct ElvishTemplate<'a> {
cmd_prefix: &'a str,
- hook: Hook,
}
/// Xonsh shell template
@@ -189,7 +143,6 @@ struct ElvishTemplate<'a> {
#[template(path = "xonsh.xsh", escape = "none")]
struct XonshTemplate<'a> {
cmd_prefix: &'a str,
- hook: Hook,
}
#[cfg(test)]
@@ -204,11 +157,4 @@ mod tests {
assert!(matches!("zsh".parse::<Shell>(), Ok(Shell::Zsh)));
assert!("invalid".parse::<Shell>().is_err());
}
-
- #[test]
- fn test_hook_from_str() {
- assert!(matches!("none".parse::<Hook>(), Ok(Hook::None)));
- assert!(matches!("prompt".parse::<Hook>(), Ok(Hook::Prompt)));
- assert!("invalid".parse::<Hook>().is_err());
- }
}
diff --git a/templates/bash.sh b/templates/bash.sh
index de069f5c4..96502906b 100644
--- a/templates/bash.sh
+++ b/templates/bash.sh
@@ -37,21 +37,6 @@ _wt_exec() {
esac
}
-{% if hook.to_string() == "prompt" %}
-# Prompt hook for tracking current worktree
-_wt_prompt_hook() {
- # Call wt to update tracking
- command wt hook prompt 2>/dev/null || true
-}
-
-# Add to PROMPT_COMMAND
-if [[ -z "${PROMPT_COMMAND}" ]]; then
- PROMPT_COMMAND="_wt_prompt_hook"
-else
- PROMPT_COMMAND="${PROMPT_COMMAND}; _wt_prompt_hook"
-fi
-{% endif %}
-
# Dynamic completion function
_{{ cmd_prefix }}_complete() {
local cur="${COMP_WORDS[COMP_CWORD]}"
diff --git a/templates/elvish.elv b/templates/elvish.elv
index 96e6df8e9..a67cdc5fc 100644
--- a/templates/elvish.elv
+++ b/templates/elvish.elv
@@ -50,15 +50,3 @@ fn {{ cmd_prefix }} {|@args|
e:wt $@args
}
}
-
-{% if hook.to_string() == "prompt" %}
-# Prompt hook for tracking current worktree
-set after-chdir = [$@after-chdir {|_|
- # Call wt to update tracking (suppress errors)
- try {
- e:wt hook prompt > /dev/null 2>&1
- } catch {
- # Ignore errors
- }
-}]
-{% endif %}
diff --git a/templates/fish.fish b/templates/fish.fish
index e0c3e6448..3ecfce15b 100644
--- a/templates/fish.fish
+++ b/templates/fish.fish
@@ -33,14 +33,6 @@ function {{ cmd_prefix }}
end
end
-{% if hook.to_string() == "prompt" %}
-# Prompt hook for tracking current worktree
-function _wt_prompt_hook --on-event fish_prompt
- # Call wt to update tracking
- command wt hook prompt 2>/dev/null; or true
-end
-{% endif %}
-
# Dynamic completion function
function __{{ cmd_prefix }}_complete
# Call wt complete with current command line
diff --git a/templates/nushell.nu b/templates/nushell.nu
index b6a52669d..c4e798d80 100644
--- a/templates/nushell.nu
+++ b/templates/nushell.nu
@@ -40,17 +40,3 @@ export def --env --wrapped {{ cmd_prefix }} [...rest] {
}
}
}
-
-{% if hook.to_string() == "prompt" %}
-# Prompt hook for tracking current worktree
-$env.config = ($env.config | upsert hooks {
- env_change: {
- PWD: [
- {|before, after|
- # Call wt to update tracking
- do { ^wt hook prompt } | complete | ignore
- }
- ]
- }
-})
-{% endif %}
diff --git a/templates/powershell.ps1 b/templates/powershell.ps1
index d04484fb8..35e9cc0bc 100644
--- a/templates/powershell.ps1
+++ b/templates/powershell.ps1
@@ -54,17 +54,3 @@ function {{ cmd_prefix }} {
}
}
}
-
-{% if hook.to_string() == "prompt" %}
-# Prompt hook for tracking current worktree
-# Note: PowerShell prompt hooks work by overriding the prompt function
-$global:_wt_previous_prompt = $function:prompt
-
-function global:prompt {
- # Call original prompt
- & $global:_wt_previous_prompt
-
- # Call wt to update tracking (suppress errors)
- & wt hook prompt 2>$null | Out-Null
-}
-{% endif %}
diff --git a/templates/xonsh.xsh b/templates/xonsh.xsh
index caedfcf40..4819d487e 100644
--- a/templates/xonsh.xsh
+++ b/templates/xonsh.xsh
@@ -39,18 +39,3 @@ def _{{ cmd_prefix }}_wrapper(args):
# Register the alias
aliases['{{ cmd_prefix }}'] = _{{ cmd_prefix }}_wrapper
-
-{% if hook.to_string() == "prompt" %}
-# Prompt hook for tracking current worktree
-# Note: Xonsh uses events.on_chdir for directory change tracking
-import xonsh.events as events
-
-def _wt_prompt_hook(olddir, newdir, **kwargs):
- """Call wt to update tracking on directory change"""
- try:
- !(wt hook prompt > /dev/null 2>&1)
- except Exception:
- # Ignore errors
- pass
-{% endif %}
diff --git a/tests/integration_tests/e2e_shell.rs b/tests/integration_tests/e2e_shell.rs
index ceb2587d2..4eed52ab0 100644
--- a/tests/integration_tests/e2e_shell.rs
+++ b/tests/integration_tests/e2e_shell.rs
@@ -311,92 +311,6 @@ fn test_bash_e2e_error_handling() {
);
}
-#[rstest]
-// Tier 1: Shells available in standard Ubuntu repos
-#[case("bash")]
-#[case("fish")]
-#[case("zsh")]
-// Tier 2: Shells requiring extra setup
-#[cfg_attr(feature = "tier-2-integration-tests", case("elvish"))]
-#[cfg_attr(feature = "tier-2-integration-tests", case("nushell"))]
-#[cfg_attr(feature = "tier-2-integration-tests", case("oil"))]
-#[cfg_attr(feature = "tier-2-integration-tests", case("powershell"))]
-#[cfg_attr(feature = "tier-2-integration-tests", case("xonsh"))]
-fn test_e2e_prompt_hook(#[case] shell: &str) {
- let repo = TestRepo::new();
- repo.commit("Initial commit");
-
- // Generate init code with prompt hook
- let mut cmd = Command::new(get_cargo_bin("wt"));
- repo.clean_cli_env(&mut cmd);
- let output = cmd
- .args(["init", shell, "--hook", "prompt"])
- .current_dir(repo.root_path())
- .output()
- .expect("Failed to generate init code");
-
- let init_code = String::from_utf8(output.stdout).expect("Invalid UTF-8");
- let bin_path = get_cargo_bin("wt")
- .parent()
- .unwrap()
- .to_string_lossy()
- .to_string();
-
- // Verify prompt hook function exists and can be called
- let hook_test = match shell {
- "nushell" => {
- // Nushell: check if hook was registered in env.config
- r#"
- print "nushell hook: function registered in env.config"
- print "HOOK_EXECUTED"
- "#
- }
- "powershell" => {
- // PowerShell: check if prompt function was overridden
- r#"
- Get-Command prompt -ErrorAction SilentlyContinue | Out-Null
- Write-Output "powershell: function"
- Write-Output "HOOK_EXECUTED"
- "#
- }
- _ => {
- // POSIX shells: check if function exists and call it
- r#"
- type _wt_prompt_hook 2>&1
- _wt_prompt_hook 2>&1
- echo "HOOK_EXECUTED"
- "#
- }
- };
-
- let script = format!(
- r#"
- {}
- {}
- {}
- "#,
- path_export_syntax(shell, &bin_path),
- init_code,
- hook_test
- );
-
- let output = execute_shell_script(&repo, shell, &script);
-
- // Verify hook function exists
- assert!(
- output.contains("_wt_prompt_hook is a function") || output.contains("function"),
- "Expected prompt hook function to be defined, got: {}",
- output
- );
-
- // Verify hook executed successfully
- assert!(
- output.contains("HOOK_EXECUTED"),
- "Expected prompt hook to execute without error, got: {}",
- output
- );
-}
-
#[test]
fn test_bash_e2e_switch_to_existing_worktree() {
if !is_shell_available("bash") {
diff --git a/tests/integration_tests/init.rs b/tests/integration_tests/init.rs
index de56e903d..e1bb56568 100644
--- a/tests/integration_tests/init.rs
+++ b/tests/integration_tests/init.rs
@@ -45,26 +45,6 @@ fn test_init_bash_custom_prefix() {
snapshot_init("init_bash_custom_prefix", "bash", &["--cmd", "wt"]);
}
-#[rstest]
-#[case("bash")]
-#[case("fish")]
-fn test_init_prompt_hook(#[case] shell: &str) {
- snapshot_init(
- &format!("init_{}_prompt_hook", shell),
- shell,
- &["--hook", "prompt"],
- );
-}
-
-#[test]
-fn test_init_bash_all_options() {
- snapshot_init(
- "init_bash_all_options",
- "bash",
- &["--cmd", "wt", "--hook", "prompt"],
- );
-}
-
#[test]
fn test_init_invalid_shell() {
let repo = TestRepo::new();
@@ -81,22 +61,3 @@ fn test_init_invalid_shell() {
assert_cmd_snapshot!("init_invalid_shell", cmd);
});
}
-
-#[test]
-fn test_init_invalid_hook() {
- let repo = TestRepo::new();
- let mut settings = Settings::clone_current();
- settings.set_snapshot_path("../snapshots");
-
- settings.bind(|| {
- let mut cmd = Command::new(get_cargo_bin("wt"));
- repo.clean_cli_env(&mut cmd);
- cmd.arg("init")
- .arg("bash")
- .arg("--hook")
- .arg("invalid")
- .current_dir(repo.root_path());
-
- assert_cmd_snapshot!("init_invalid_hook", cmd);
- });
-}
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index c3a32dd41..07320e1ca 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -58,8 +58,6 @@ wt() {
esac
}
-
-
# Dynamic completion function
_wt_complete() {
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -94,8 +92,8 @@ _wt() {
wt,complete)
cmd="wt__complete"
;;
- wt,hook)
- cmd="wt__hook"
+ wt,completion)
+ cmd="wt__completion"
;;
wt,init)
cmd="wt__init"
@@ -122,7 +120,7 @@ _wt() {
case "${cmd}" in
wt)
- opts="-h -V --help --version init list switch remove push merge hook complete"
+ opts="-h -V --help --version init list switch remove push merge completion complete"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -149,8 +147,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__hook)
- opts="-h --help <HOOK_TYPE>"
+ wt__completion)
+ opts="-h --help bash fish zsh"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -164,7 +162,7 @@ _wt() {
return 0
;;
wt__init)
- opts="-h --cmd --hook --help <SHELL>"
+ opts="-h --cmd --help <SHELL>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -174,10 +172,6 @@ _wt() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
- --hook)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
*)
COMPREPLY=()
;;
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 1a254b523..12ecdaee3 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
@@ -60,8 +60,6 @@ wt() {
esac
}
-
-
# Dynamic completion function
_wt_complete() {
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -96,8 +94,8 @@ _wt() {
wt,complete)
cmd="wt__complete"
;;
- wt,hook)
- cmd="wt__hook"
+ wt,completion)
+ cmd="wt__completion"
;;
wt,init)
cmd="wt__init"
@@ -124,7 +122,7 @@ _wt() {
case "${cmd}" in
wt)
- opts="-h -V --help --version init list switch remove push merge hook complete"
+ opts="-h -V --help --version init list switch remove push merge completion complete"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -151,8 +149,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__hook)
- opts="-h --help <HOOK_TYPE>"
+ wt__completion)
+ opts="-h --help bash fish zsh"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -166,7 +164,7 @@ _wt() {
return 0
;;
wt__init)
- opts="-h --cmd --hook --help <SHELL>"
+ opts="-h --cmd --help <SHELL>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -176,10 +174,6 @@ _wt() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
- --hook)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
*)
COMPREPLY=()
;;
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index 8cb53039f..9af1cb937 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -54,8 +54,6 @@ function wt
end
end
-
-
# Dynamic completion function
function __wt_complete
# Call wt complete with current command line
@@ -105,7 +103,6 @@ complete -c wt -n "__fish_wt_needs_command" -f -a "remove" -d 'Finish current wo
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 worktree into target branch'
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
@@ -119,7 +116,7 @@ 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 s -l squash -d 'Squash all commits into one before merging'
complete -c wt -n "__fish_wt_using_subcommand merge" -s k -l keep -d 'Keep worktree after merging (don\'t remove)'
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'
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__init__init_invalid_hook.snap b/tests/snapshots/integration__integration_tests__init__init_invalid_hook.snap
deleted file mode 100644
index f7718af91..000000000
--- a/tests/snapshots/integration__integration_tests__init__init_invalid_hook.snap
+++ /dev/null
@@ -1,26 +0,0 @@
----
-source: tests/integration_tests/init.rs
-info:
- program: wt
- args:
- - init
- - bash
- - "--hook"
- - invalid
- env:
- CLICOLOR_FORCE: "1"
- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
- GIT_CONFIG_GLOBAL: /dev/null
- GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
- LANG: C
- LC_ALL: C
- SOURCE_DATE_EPOCH: "1704067200"
----
-success: false
-exit_code: 1
------ stdout -----
-
------ stderr -----
-Invalid hook mode: invalid
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index 3d4a64480..f5b31e03f 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -58,8 +58,6 @@ wt() {
esac
}
-
-
# Dynamic completion function
_wt_complete() {
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -106,7 +104,6 @@ _wt() {
(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' \
@@ -156,11 +153,11 @@ _arguments "${_arguments_options[@]}" : \
'::target -- Target branch to merge into (defaults to default branch):_default' \
&& ret=0
;;
-(hook)
+(completion)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
-':hook_type -- Hook type:_default' \
+':shell -- Shell to generate completions for:(bash fish zsh)' \
&& ret=0
;;
(complete)
@@ -184,7 +181,7 @@ _wt_commands() {
'remove:Finish current worktree, returning to primary if current' \
'push:Push changes between worktrees' \
'merge:Merge worktree into target branch' \
-'hook:Hook commands (for shell integration)' \
+'completion:Generate shell completion script (deprecated - use init instead)' \
'complete:Internal completion helper (hidden)' \
)
_describe -t commands 'wt commands' commands "$@"
@@ -194,10 +191,10 @@ _wt__complete_commands() {
local commands; commands=()
_describe -t commands 'wt complete commands' commands "$@"
}
-(( $+functions[_wt__hook_commands] )) ||
-_wt__hook_commands() {
+(( $+functions[_wt__completion_commands] )) ||
+_wt__completion_commands() {
local commands; commands=()
- _describe -t commands 'wt hook commands' commands "$@"
+ _describe -t commands 'wt completion commands' commands "$@"
}
(( $+functions[_wt__init_commands] )) ||
_wt__init_commands() {