Skip to content

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

Fix: Make generated shell completions portable

Maximilian Roos2cc4290dc99f
diff --git a/src/completion.rs b/src/completion.rs
index a6b75ce3d..61b0e0789 100644
--- a/src/completion.rs
+++ b/src/completion.rs
@@ -36,21 +36,22 @@ pub fn generate_completions(shell: Shell) -> io::Result<()> {
/// Generate completion script to a writer (for writing to files)
pub fn generate_completions_to_writer(shell: Shell, writer: &mut dyn io::Write) -> io::Result<()> {
- let completer = std::env::current_exe()?;
- let completer = completer.to_string_lossy();
+ // Use "wt" instead of absolute path - the shell will find it via PATH.
+ // This makes completions portable (work regardless of where wt is installed).
+ let completer = "wt";
let var = "COMPLETE";
// Use the shell-specific EnvCompleter to write the registration script
// Parameters: var, name (shell context), bin (user display - same as name), completer (binary path)
match shell {
Shell::Bash => {
- clap_complete::env::Bash.write_registration(var, "wt", "wt", &completer, writer)
+ clap_complete::env::Bash.write_registration(var, "wt", "wt", completer, writer)
}
Shell::Zsh => {
- clap_complete::env::Zsh.write_registration(var, "wt", "wt", &completer, writer)
+ clap_complete::env::Zsh.write_registration(var, "wt", "wt", completer, writer)
}
Shell::Fish => {
- clap_complete::env::Fish.write_registration(var, "wt", "wt", &completer, writer)
+ clap_complete::env::Fish.write_registration(var, "wt", "wt", completer, writer)
}
}
}