Skip to content

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

Add bash syntax highlighting to shell command gutters

Maximilian Roos27087472d966
diff --git a/.claude/rules/cli-output-formatting.md b/.claude/rules/cli-output-formatting.md
index 420ef572b..f3ca14deb 100644
--- a/.claude/rules/cli-output-formatting.md
+++ b/.claude/rules/cli-output-formatting.md
@@ -359,14 +359,18 @@ See `src/commands/list/render.rs` for advanced usage.
## Gutter Formatting for Quoted Content
-Use `format_with_gutter()` for **external data** — anything read from outside
-the application: git output, shell commands, commit messages, config values,
-cached data. Gutter visually quotes this content to distinguish it from
-application-generated output.
+Use gutter formatting for **quoted content** — anything that should be visually
+distinguished from application prose:
+
+- **External data**: git output, commit messages, config values, cached data
+- **Suggested commands**: shell commands the user might run
+
+Use `format_bash_with_gutter()` for shell commands (applies dimming + syntax
+highlighting). Use `format_with_gutter()` for other content (no dimming).
**Gutter vs Table:** Tabular data structured by the application should use
`output::table()` with markdown formatting via `render_markdown_in_help()`.
-Tables are artifacts; gutter is for quoting external data.
+Tables are artifacts; gutter is for quoting content.
**Linebreaks:** Gutter requires a single newline before it, never double.
`output::print()` adds a trailing newline, so messages should not include `\n`:
diff --git a/src/git/error.rs b/src/git/error.rs
index 22d1251e7..0c82a8812 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -16,7 +16,8 @@ use color_print::{cformat, cwrite};
use super::HookType;
use crate::path::format_path_for_display;
use crate::styling::{
- ERROR_EMOJI, HINT_EMOJI, error_message, format_with_gutter, hint_message, info_message,
+ ERROR_EMOJI, HINT_EMOJI, error_message, format_bash_with_gutter, format_with_gutter,
+ hint_message, info_message,
};
/// Domain errors for git and worktree operations.
@@ -244,7 +245,7 @@ impl std::fmt::Display for GitError {
"Cannot create worktree for <bold>{branch}</>: {error_detail}"
)),
hint,
- format_with_gutter(&command, "", None)
+ format_bash_with_gutter(&command, "")
)
}
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap
index ca417e21b..ccd385f63 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap
@@ -5,4 +5,4 @@ expression: err.to_string()
❌ Cannot create worktree for feature-z: existing worktree at /tmp/repo.feature-z on other-branch
💡 Switch the worktree at /tmp/repo.feature-z to feature-z
-  cd /tmp/repo.feature-z && git switch feature-z
+  cd /tmp/repo.feature-z && git switch feature-z
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap
index 8246e5a31..59f569694 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap
@@ -15,6 +15,7 @@ info:
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
HOME: "[TEST_HOME]"
LANG: C
LC_ALL: C
@@ -32,4 +33,4 @@ exit_code: 1
❌ Cannot create worktree for main: existing worktree at [REPO] on feature
💡 Switch the worktree at [REPO] to main
-  cd [REPO] && git switch main
+  cd [REPO] && git switch main
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap
index 0349da267..084993507 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap
@@ -15,6 +15,7 @@ info:
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
HOME: "[TEST_HOME]"
LANG: C
LC_ALL: C
@@ -32,4 +33,4 @@ exit_code: 1
❌ Cannot create worktree for feature: existing worktree at [REPO].feature, detached
💡 Switch the worktree at [REPO].feature to feature
-  cd [REPO].feature && git switch feature
+  cd [REPO].feature && git switch feature
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap
index b297f3030..e6bafbcce 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap
@@ -15,6 +15,7 @@ info:
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
HOME: "[TEST_HOME]"
LANG: C
LC_ALL: C
@@ -32,4 +33,4 @@ exit_code: 1
❌ Cannot create worktree for feature: existing worktree at [REPO].feature on bugfix
💡 Switch the worktree at [REPO].feature to feature
-  cd [REPO].feature && git switch feature
+  cd [REPO].feature && git switch feature