Skip to content

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

fix: Make bash completion nosort option conditional for macOS (#37)

Maximilian Roos1407051e35d1
diff --git a/templates/bash.sh b/templates/bash.sh
index cf65ab815..9fca97087 100644
--- a/templates/bash.sh
+++ b/templates/bash.sh
@@ -73,5 +73,10 @@ if command -v {{ cmd_prefix }} >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]];
_clap_complete_{{ cmd_prefix }}
fi
}
- complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete {{ cmd_prefix }}
+ # nosort requires Bash 4.4+ (macOS ships with 3.2)
+ if [[ ${BASH_VERSINFO[0]} -gt 4 || (${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 4) ]]; then
+ complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete {{ cmd_prefix }}
+ else
+ complete -o nospace -o bashdefault -F _wt_lazy_complete {{ cmd_prefix }}
+ fi
fi
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index d2e6d8260..b97f94877 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -185,7 +185,12 @@ wt_exec() {
_clap_complete_wt
fi
}
- complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete wt
+ # nosort requires Bash 4.4+ (macOS ships with 3.2)
+ if [[ ${BASH_VERSINFO[0]} -gt 4 || (${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 4) ]]; then
+ complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete wt
+ else
+ complete -o nospace -o bashdefault -F _wt_lazy_complete wt
+ fi
fi
----- stderr -----