Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Fix: Correctly load wt binary in Fish shell integration
Maximilian Roosfa512406e458
diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex 853fbe60f..1e2c4183f 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -555,16 +555,16 @@ fn prompt_yes_no() -> Result<bool, String> {Ok(response == "y" || response == "yes")}-/// Fish completion content - uses $WORKTRUNK_BIN to bypass shell wrapper-const FISH_COMPLETION: &str = r#"# worktrunk completions for fish - uses $WORKTRUNK_BIN to bypass shell wrapper-complete --keep-order --exclusive --command wt --arguments "(COMPLETE=fish \$WORKTRUNK_BIN -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"+/// Fish completion content - finds wt in PATH, with WORKTRUNK_BIN as optional override+const FISH_COMPLETION: &str = r#"# worktrunk completions for fish+complete --keep-order --exclusive --command wt --arguments "(set -q WORKTRUNK_BIN; or set -l WORKTRUNK_BIN (type -P wt); COMPLETE=fish \$WORKTRUNK_BIN -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#;/// Process shell completions - either preview or write based on dry_run flag////// Note: Bash and Zsh use inline lazy completions in the init script./// Fish uses a separate completion file at ~/.config/fish/completions/wt.fish-/// that calls $WORKTRUNK_BIN directly to bypass the shell wrapper.+/// that finds wt in PATH (with WORKTRUNK_BIN as optional override) to bypass the shell wrapper.pub fn process_shell_completions(shells: &[Shell],dry_run: bool,diff --git a/templates/fish.fish b/templates/fish.fishindex e28bdb6e7..c1c891876 100644--- a/templates/fish.fish+++ b/templates/fish.fish@@ -2,15 +2,10 @@# Only initialize if {{ cmd_prefix }} is available (in PATH or via WORKTRUNK_BIN)if type -q {{ cmd_prefix }}; or set -q WORKTRUNK_BIN- # TODO: Consider time-of-use pattern like bash/zsh instead of init-time setup.- # Fish lacks ${:-} syntax; would require verbose workaround at each call site.- if not set -q WORKTRUNK_BIN- set -gx WORKTRUNK_BIN (type -p {{ cmd_prefix }})- end-# Capture stdout (shell script), eval in parent shell. stderr streams to terminal.# WORKTRUNK_BIN can override the binary path (for testing dev builds).function wt_exec+ set -q WORKTRUNK_BIN; or set -l WORKTRUNK_BIN (type -P {{ cmd_prefix }})set -l script (command $WORKTRUNK_BIN $argv | string collect)set -l exit_code $pipestatus[1]diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex 9e1c4f3dc..9aaec17fb 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -226,7 +226,7 @@ fn test_configure_shell_fish_extension_exists() {");});- // Fish completions should be in a separate file using $WORKTRUNK_BIN+ // Fish completions should be in a separate file with WORKTRUNK_BIN fallbacklet completions_file = temp_home.path().join(".config/fish/completions/wt.fish");assert!(completions_file.exists(),@@ -234,8 +234,8 @@ fn test_configure_shell_fish_extension_exists() {);let contents = std::fs::read_to_string(&completions_file).unwrap();assert!(- contents.contains("$WORKTRUNK_BIN"),- "Fish completions should use $WORKTRUNK_BIN to bypass shell wrapper"+ contents.contains("set -q WORKTRUNK_BIN; or set -l WORKTRUNK_BIN"),+ "Fish completions should use WORKTRUNK_BIN with fallback");}diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snapindex c912a0a5b..7c345c97c 100644--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap@@ -17,7 +17,7 @@ info:GIT_EDITOR: ""LANG: CLC_ALL: C- SOURCE_DATE_EPOCH: "1761609600"+ SOURCE_DATE_EPOCH: "1735776000"WORKTRUNK_BIN: ""WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"---@@ -28,15 +28,10 @@ exit_code: 0# Only initialize if wt is available (in PATH or via WORKTRUNK_BIN)if type -q wt; or set -q WORKTRUNK_BIN- # TODO: Consider time-of-use pattern like bash/zsh instead of init-time setup.- # Fish lacks ${:-} syntax; would require verbose workaround at each call site.- if not set -q WORKTRUNK_BIN- set -gx WORKTRUNK_BIN (type -p wt)- end-# Capture stdout (shell script), eval in parent shell. stderr streams to terminal.# WORKTRUNK_BIN can override the binary path (for testing dev builds).function wt_exec+ set -q WORKTRUNK_BIN; or set -l WORKTRUNK_BIN (type -P wt)set -l script (command $WORKTRUNK_BIN $argv | string collect)set -l exit_code $pipestatus[1]