Skip to content

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

Add newline to regular `wt` output in shell integrations

Maximilian Roos80bca2c72abb
diff --git a/templates/bash.sh b/templates/bash.sh
index ce127b9b6..25164883a 100644
--- a/templates/bash.sh
+++ b/templates/bash.sh
@@ -26,8 +26,8 @@ if command -v wt >/dev/null 2>&1; then
# EXEC directive - extract command (may contain newlines)
exec_cmd="${chunk#__WORKTRUNK_EXEC__}"
else
- # Regular output - print it (preserving newlines)
- printf '%s' "$chunk"
+ # Regular output - print it with newline
+ printf '%s\n' "$chunk"
fi
done < <(command "$_WORKTRUNK_CMD" "$@"; echo "$?" > "$exit_code_file")
diff --git a/templates/fish.fish b/templates/fish.fish
index 95327dc92..d1ad5c208 100644
--- a/templates/fish.fish
+++ b/templates/fish.fish
@@ -59,11 +59,11 @@ if type -q {{ cmd_prefix }}
echo "[DEBUG] EXEC directive: $exec_cmd" >&2
end
else if test -n "$chunk"
- # Regular output - print it (preserving newlines)
+ # Regular output - print it with newline
if test $debug_mode -eq 1
echo "[DEBUG] Message chunk" >&2
end
- printf '%s' $chunk
+ printf '%s\n' $chunk
end
end < (begin; command $_WORKTRUNK_CMD $argv; echo $status > $exit_code_file; end | psub)
diff --git a/templates/nushell.nu b/templates/nushell.nu
index 32b70ad68..84f3607ad 100644
--- a/templates/nushell.nu
+++ b/templates/nushell.nu
@@ -24,8 +24,8 @@ if (which wt | is-not-empty) {
# TODO: Use str replace instead of hard-coded offset (fragile if prefix changes)
$exec_cmd = ($chunk | str substring 18..)
} else if ($chunk | str length) > 0 {
- # Regular output - print it (preserving newlines)
- print -n $chunk
+ # Regular output - print it with newline
+ print $chunk
}
}
diff --git a/templates/powershell.ps1 b/templates/powershell.ps1
index 9e8dc615e..0432c0bee 100644
--- a/templates/powershell.ps1
+++ b/templates/powershell.ps1
@@ -30,9 +30,9 @@ if (Get-Command wt -ErrorAction SilentlyContinue) {
# EXEC directive - extract command (may contain newlines)
$execCmd = $chunk -replace '^__WORKTRUNK_EXEC__', ''
} elseif ($chunk) {
- # Regular output - write it (preserving newlines)
+ # Regular output - write it with newline
# TODO: Use Write-Output instead of Write-Host for redirectable output
- Write-Host -NoNewline $chunk
+ Write-Host $chunk
}
}
diff --git a/templates/xonsh.xsh b/templates/xonsh.xsh
index 6648d851e..bc6e1165e 100644
--- a/templates/xonsh.xsh
+++ b/templates/xonsh.xsh
@@ -28,8 +28,8 @@ if shutil.which("wt") is not None:
# TODO: Use str.replace instead of hard-coded offset (fragile if prefix changes)
exec_cmd = chunk[18:] # Remove prefix
elif chunk:
- # Regular output - print it (preserving newlines)
- print(chunk, end='')
+ # Regular output - print it with newline
+ print(chunk)
# Execute command if one was specified
if exec_cmd:
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index 176e8301b..1d7e1ad74 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -14,7 +14,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpig4dTj/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpiVd1K8/test-config.toml
---
success: true
exit_code: 0
@@ -47,8 +47,8 @@ if command -v wt >/dev/null 2>&1; then
# EXEC directive - extract command (may contain newlines)
exec_cmd="${chunk#__WORKTRUNK_EXEC__}"
else
- # Regular output - print it (preserving newlines)
- printf '%s' "$chunk"
+ # Regular output - print it with newline
+ printf '%s\n' "$chunk"
fi
done < <(command "$_WORKTRUNK_CMD" "$@"; echo "$?" > "$exit_code_file")
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 a74862b7e..6c678bec8 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
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpXFi2Dc/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpehaTjD/test-config.toml
---
success: true
exit_code: 0
@@ -49,8 +49,8 @@ if command -v wt >/dev/null 2>&1; then
# EXEC directive - extract command (may contain newlines)
exec_cmd="${chunk#__WORKTRUNK_EXEC__}"
else
- # Regular output - print it (preserving newlines)
- printf '%s' "$chunk"
+ # Regular output - print it with newline
+ printf '%s\n' "$chunk"
fi
done < <(command "$_WORKTRUNK_CMD" "$@"; echo "$?" > "$exit_code_file")
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index b6caccaa4..8b4c5bde0 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -14,7 +14,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpSv8CTr/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpZgorwu/test-config.toml
---
success: true
exit_code: 0
@@ -80,11 +80,11 @@ if type -q wt
echo "[DEBUG] EXEC directive: $exec_cmd" >&2
end
else if test -n "$chunk"
- # Regular output - print it (preserving newlines)
+ # Regular output - print it with newline
if test $debug_mode -eq 1
echo "[DEBUG] Message chunk" >&2
end
- printf '%s' $chunk
+ printf '%s\n' $chunk
end
end < (begin; command $_WORKTRUNK_CMD $argv; echo $status > $exit_code_file; end | psub)
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index c36a20d0d..4930f074e 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -14,7 +14,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpTpN3ZR/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpmY4L7S/test-config.toml
---
success: true
exit_code: 0
@@ -47,8 +47,8 @@ if command -v wt >/dev/null 2>&1; then
# EXEC directive - extract command (may contain newlines)
exec_cmd="${chunk#__WORKTRUNK_EXEC__}"
else
- # Regular output - print it (preserving newlines)
- printf '%s' "$chunk"
+ # Regular output - print it with newline
+ printf '%s\n' "$chunk"
fi
done < <(command "$_WORKTRUNK_CMD" "$@"; echo "$?" > "$exit_code_file")
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_stdout_stderr_ordering.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_stdout_stderr_ordering.snap
index 0951aa78b..17f3aca88 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_stdout_stderr_ordering.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_check_stdout_stderr_ordering.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUgOch7/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp9QAkUl/test-config.toml
---
success: true
exit_code: 0
@@ -33,7 +33,7 @@ exit_code: 0
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
-* e647aed (HEAD -> feature) Add feature file
+* a334407 (HEAD -> feature) Add feature file
feature.txt | 1 +
1 file changed, 1 insertion(+)