Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Force colors when stdout is a TTY
Maximilian Roosb554d648e1bd
diff --git a/templates/bash.sh b/templates/bash.shindex 7bade8837..778b5d34e 100644--- a/templates/bash.sh+++ b/templates/bash.sh@@ -76,6 +76,11 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then_WORKTRUNK_CMD="./target/debug/wt"fi+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if [[ -z "${NO_COLOR:-}" && -z "${CLICOLOR_FORCE:-}" ]]; then+ if [[ -t 1 ]]; then export CLICOLOR_FORCE=1; fi+ fi+# Always use --internal mode for directive support_wt_exec --internal "${args[@]}"diff --git a/templates/elvish.elv b/templates/elvish.elvindex 74ad3eb5f..a1f69d6b4 100644--- a/templates/elvish.elv+++ b/templates/elvish.elv@@ -79,6 +79,13 @@ if (or (has-external wt) (has-env WORKTRUNK_BIN)) {set _WORKTRUNK_CMD = ./target/debug/wt}+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if (and (not (has-env NO_COLOR)) (not (has-env CLICOLOR_FORCE))) {+ if (isatty stdout) {+ set E:CLICOLOR_FORCE = 1+ }+ }+# Always use --internal mode for directive support_wt_exec --internal $@filtered-argsdiff --git a/templates/fish.fish b/templates/fish.fishindex fedf7ecaf..644a4cd52 100644--- a/templates/fish.fish+++ b/templates/fish.fish@@ -112,6 +112,13 @@ if type -q {{ cmd_prefix }}; or set -q WORKTRUNK_BINset _WORKTRUNK_CMD ./target/debug/wtend+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if not set -q NO_COLOR; and not set -q CLICOLOR_FORCE+ if isatty stdout+ set -x CLICOLOR_FORCE 1+ end+ end+# Always use --internal mode for directive support_wt_exec --internal $argsdiff --git a/templates/nushell.nu b/templates/nushell.nuindex 136469483..b12b531fc 100644--- a/templates/nushell.nu+++ b/templates/nushell.nu@@ -64,6 +64,13 @@ if (which wt | is-not-empty) or ($env.WORKTRUNK_BIN? | is-not-empty) {$_WORKTRUNK_CMD}+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if ($env.NO_COLOR? | is-empty) and ($env.CLICOLOR_FORCE? | is-empty) {+ if (do -i { term size } | is-not-empty) {+ load-env { CLICOLOR_FORCE: "1" }+ }+ }+# Always use --internal mode for directive supportlet internal_args = (["--internal"] | append $filtered_args)let exit_code = (_wt_exec $cmd ...$internal_args)diff --git a/templates/powershell.ps1 b/templates/powershell.ps1index 7eb879240..c4c595877 100644--- a/templates/powershell.ps1+++ b/templates/powershell.ps1@@ -80,6 +80,13 @@ if ((Get-Command wt -ErrorAction SilentlyContinue) -or $env:WORKTRUNK_BIN) {$cmd = $script:_WORKTRUNK_CMD}+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if (-not $env:NO_COLOR -and -not $env:CLICOLOR_FORCE) {+ if ([Console]::IsOutputRedirected -eq $false) {+ $env:CLICOLOR_FORCE = "1"+ }+ }+# Always use --internal mode for directive support$exitCode = _wt_exec -Command $cmd --internal @filteredArgsreturn $exitCodediff --git a/templates/xonsh.xsh b/templates/xonsh.xshindex 6df60a7cd..f2fe4c71e 100644--- a/templates/xonsh.xsh+++ b/templates/xonsh.xsh@@ -62,6 +62,11 @@ if shutil.which("wt") is not None or os.environ.get('WORKTRUNK_BIN'):else:cmd = _WORKTRUNK_CMD+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if 'NO_COLOR' not in os.environ and 'CLICOLOR_FORCE' not in os.environ:+ if sys.stdout.isatty():+ os.environ['CLICOLOR_FORCE'] = '1'+# Always use --internal mode for directive supportreturn _wt_exec(["--internal"] + filtered_args, cmd=cmd)diff --git a/templates/zsh.zsh b/templates/zsh.zshindex 48a194136..2938ac8d3 100644--- a/templates/zsh.zsh+++ b/templates/zsh.zsh@@ -81,6 +81,11 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then_WORKTRUNK_CMD="./target/debug/wt"fi+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if [[ -z "${NO_COLOR:-}" && -z "${CLICOLOR_FORCE:-}" ]]; then+ if [[ -t 1 ]]; then export CLICOLOR_FORCE=1; fi+ fi+# Always use --internal mode for directive support_wt_exec --internal "${args[@]}"diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapindex 459cf880f..40d2e6730 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -12,11 +12,10 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpGnboC0/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpYm4xND/test-config.toml---success: trueexit_code: 0@@ -99,6 +98,11 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then_WORKTRUNK_CMD="./target/debug/wt"fi+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if [[ -z "${NO_COLOR:-}" && -z "${CLICOLOR_FORCE:-}" ]]; then+ if [[ -t 1 ]]; then export CLICOLOR_FORCE=1; fi+ fi+# Always use --internal mode for directive support_wt_exec --internal "${args[@]}"diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snapindex b20ea5f69..f7318da97 100644--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap@@ -12,11 +12,10 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpdGN32C/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpZuEIMN/test-config.toml---success: trueexit_code: 0@@ -135,6 +134,13 @@ if type -q wt; or set -q WORKTRUNK_BINset _WORKTRUNK_CMD ./target/debug/wtend+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if not set -q NO_COLOR; and not set -q CLICOLOR_FORCE+ if isatty stdout+ set -x CLICOLOR_FORCE 1+ end+ end+# Always use --internal mode for directive support_wt_exec --internal $argsdiff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapindex 2f0d1c31c..ebbb4e12b 100644--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -12,11 +12,10 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNc56zW/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmphanjUv/test-config.toml---success: trueexit_code: 0@@ -104,6 +103,11 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then_WORKTRUNK_CMD="./target/debug/wt"fi+ # Force colors if wrapper's stdout is a TTY (respects NO_COLOR and explicit CLICOLOR_FORCE)+ if [[ -z "${NO_COLOR:-}" && -z "${CLICOLOR_FORCE:-}" ]]; then+ if [[ -t 1 ]]; then export CLICOLOR_FORCE=1; fi+ fi+# Always use --internal mode for directive support_wt_exec --internal "${args[@]}"