Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Initialize _WORKTRUNK_CMD in wt() function for snapshot compatibility
Maximilian Roosdbc2fcc5dfa7
diff --git a/templates/bash.sh b/templates/bash.shindex 90ebae1e7..fbc02dd44 100644--- a/templates/bash.sh+++ b/templates/bash.sh@@ -10,6 +10,11 @@ if command -v {{ cmd_prefix }} >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]];# Override {{ cmd_prefix }} command to add --internal flag{{ cmd_prefix }}() {+ # Initialize _WORKTRUNK_CMD if not set (e.g., after shell snapshot restore)+ if [[ -z "$_WORKTRUNK_CMD" ]]; then+ _WORKTRUNK_CMD="${WORKTRUNK_BIN:-{{ cmd_prefix }}}"+ fi+local use_source=falselocal args=()local saved_cmd="$_WORKTRUNK_CMD"diff --git a/templates/zsh.zsh b/templates/zsh.zshindex 0902d2540..87bf327b1 100644--- a/templates/zsh.zsh+++ b/templates/zsh.zsh@@ -10,6 +10,11 @@ if command -v {{ cmd_prefix }} >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]];# Override {{ cmd_prefix }} command to add --internal flag{{ cmd_prefix }}() {+ # Initialize _WORKTRUNK_CMD if not set (e.g., after shell snapshot restore)+ if [[ -z "$_WORKTRUNK_CMD" ]]; then+ _WORKTRUNK_CMD="${WORKTRUNK_BIN:-{{ cmd_prefix }}}"+ fi+local use_source=falselocal -a argslocal saved_cmd="$_WORKTRUNK_CMD"diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapindex 899db461f..1fc81de64 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpuSx06y/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpl6vlQ1/test-config.toml---success: trueexit_code: 0@@ -93,6 +93,11 @@ wt_exec() {# Override wt command to add --internal flagwt() {+ # Initialize _WORKTRUNK_CMD if not set (e.g., after shell snapshot restore)+ if [[ -z "$_WORKTRUNK_CMD" ]]; then+ _WORKTRUNK_CMD="${WORKTRUNK_BIN:-wt}"+ fi+local use_source=falselocal args=()local saved_cmd="$_WORKTRUNK_CMD"diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapindex 34e91f798..8a127258d 100644--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUvdB1W/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpTOuQ5R/test-config.toml---success: trueexit_code: 0@@ -93,6 +93,11 @@ wt_exec() {# Override wt command to add --internal flagwt() {+ # Initialize _WORKTRUNK_CMD if not set (e.g., after shell snapshot restore)+ if [[ -z "$_WORKTRUNK_CMD" ]]; then+ _WORKTRUNK_CMD="${WORKTRUNK_BIN:-wt}"+ fi+local use_source=falselocal -a argslocal saved_cmd="$_WORKTRUNK_CMD"