From 3df14fc985ddad041c290c732b5b5b8eae41f68e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 11 Jun 2026 11:35:45 -0500 Subject: 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. --- scripts/tests/statusline-command.bats | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/tests/statusline-command.bats (limited to 'scripts/tests') 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 + +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" ] +} -- cgit v1.2.3