aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-11 11:35:45 -0500
committerCraig Jennings <c@cjennings.net>2026-06-11 11:35:45 -0500
commit3df14fc985ddad041c290c732b5b5b8eae41f68e (patch)
treebf549dd862d5dda2cd7b833d11eb8501368609dd /scripts
parentd576fc217ba304b48dfb1c54b92bc1849397fd9b (diff)
downloadrulesets-3df14fc985ddad041c290c732b5b5b8eae41f68e.tar.gz
rulesets-3df14fc985ddad041c290c732b5b5b8eae41f68e.zip
feat(install): adopt the statusline script into the managed set
An archsetup session added a statusLine entry to the tracked settings.json on 2026-06-11 (Craig's request), pointing at ~/.claude/statusline-command.sh, but the script itself lived outside the repo on one machine. This commits the settings entry and brings the script into .claude/, linked by make install like the rest of the config, so it reaches every machine on the next session. Two fixes over the original: uname -n instead of hostname (Arch doesn't ship hostname by default, so the host rendered empty with stderr noise), and the tilde replacement is escaped (unquoted, bash expands the replacement ~ straight back to $HOME, which defeated the abbreviation). scripts/tests/statusline-command.bats covers the format, branch handling, and the no-stderr contract.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/tests/statusline-command.bats51
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/tests/statusline-command.bats b/scripts/tests/statusline-command.bats
new file mode 100644
index 0000000..6a8725a
--- /dev/null
+++ b/scripts/tests/statusline-command.bats
@@ -0,0 +1,51 @@
+#!/usr/bin/env bats
+# .claude/statusline-command.sh — Claude Code status line mirroring the zsh
+# prompt: [yy-mm-dd HH:MM:SS] user host:~/path on <branch>
+
+setup() {
+ REPO_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"
+ SCRIPT="$REPO_ROOT/.claude/statusline-command.sh"
+ TMPDIR_T="$(mktemp -d)"
+}
+
+teardown() {
+ rm -rf "$TMPDIR_T"
+}
+
+run_statusline() {
+ printf '{"cwd":"%s"}' "$1" | sh "$SCRIPT"
+}
+
+@test "statusline renders date, user, host, and tilde-abbreviated cwd" {
+ dir="$HOME/.cache"
+ run run_statusline "$dir"
+ [ "$status" -eq 0 ]
+ host="$(uname -n)"
+ user="$(whoami)"
+ [[ "$output" =~ ^\[[0-9]{2}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}\]\ $user\ $host:~/\.cache$ ]]
+}
+
+@test "statusline appends the git branch inside a repo" {
+ git -C "$TMPDIR_T" init -q -b trunk
+ run run_statusline "$TMPDIR_T"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *" on trunk" ]]
+}
+
+@test "statusline omits the branch part outside a git repo" {
+ mkdir -p "$TMPDIR_T/plain"
+ run run_statusline "$TMPDIR_T/plain"
+ [ "$status" -eq 0 ]
+ [[ "$output" != *" on "* ]]
+}
+
+@test "statusline leaves a cwd outside HOME unabbreviated" {
+ run run_statusline "/tmp"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *":/tmp" ]]
+}
+
+@test "statusline emits no stderr noise" {
+ err="$(printf '{"cwd":"%s"}' "$HOME" | sh "$SCRIPT" 2>&1 >/dev/null)"
+ [ -z "$err" ]
+}