Skip to content

Commit 1267861

Browse files
committed
fix statusline script, some macOS issue and tmux rename useless feature
1 parent 0d17f10 commit 1267861

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

scripts/statusline.sh

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# will generally not involve changes to this script.
1515
#
1616
# Claude Code Status Line - Display usage information
17-
# Format: <model> [<cwd>] <branch> | $X.XX @ Xh:Ym:Zs | lines: +X, -X | Session: <name> | Fast: <On/Off> | RLCR: <status>
17+
# Format: <model> | [context bar] | $X.XX @ Xh:Ym:Zs
1818

1919
input=$(cat)
2020

@@ -104,7 +104,7 @@ get_rlcr_status() {
104104
fi
105105
[[ -z "$any_state" ]] && continue
106106
local stored_sid
107-
stored_sid=$(sed -n '/^---$/,/^---$/{ /^session_id:/{ s/session_id: *//; p; } }' "$any_state" 2>/dev/null | tr -d ' ')
107+
stored_sid=$(awk '/^---$/{n++; next} n==1 && /^session_id:/{sub(/^session_id: */, ""); gsub(/ /, ""); print; exit}' "$any_state" 2>/dev/null)
108108
if [[ -n "$stored_sid" ]]; then
109109
_resolve_rlcr_display "$trimmed"
110110
return
@@ -133,7 +133,7 @@ get_rlcr_status() {
133133

134134
# Extract stored session_id from YAML frontmatter
135135
local stored_sid
136-
stored_sid=$(sed -n '/^---$/,/^---$/{ /^session_id:/{ s/session_id: *//; p; } }' "$any_state" 2>/dev/null | tr -d ' ')
136+
stored_sid=$(awk '/^---$/{n++; next} n==1 && /^session_id:/{sub(/^session_id: */, ""); gsub(/ /, ""); print; exit}' "$any_state" 2>/dev/null)
137137

138138
# Skip session-unaware entries when session-aware ones exist
139139
if [[ -z "$stored_sid" ]]; then
@@ -328,28 +328,18 @@ BLUE="\e[34m" # Label - for Session
328328
MAGENTA="\e[35m" # Label - for RLCR and Fast
329329
RESET="\e[0m"
330330

331-
# Auto-rename tmux window to session customTitle if inside tmux
332-
if [[ -n "$TMUX" && -n "$SESSION_DISPLAY" ]]; then
333-
# UUID pattern: 8-4-4-4-12 hex chars
334-
if [[ ! "$SESSION_DISPLAY" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]]; then
335-
tmux rename-window "$SESSION_DISPLAY" 2>/dev/null
336-
fi
337-
fi
338-
339331
# Shorten CWD: replace $HOME with ~
340332
TILDE='~'
341333
CWD_SHORT="${CWD/#$HOME/$TILDE}"
342334

343-
# Line 1: model | cost @ duration
344-
printf "%b%s%b | %b\$%s%b @ %s\n" \
335+
# Line 1: model | context bar | cost @ duration
336+
printf "%b%s%b | %b | %b\$%s%b @ %s\n" \
345337
"$CORAL" "${MODEL:-?}" "$RESET" \
338+
"$CONTEXT_BAR" \
346339
"$GREEN" "$COST_STR" "$RESET" \
347340
"$DURATION_STR"
348341

349-
# Line 2: context bar
350-
printf "%b\n" "$CONTEXT_BAR"
351-
352-
# Line 3: cwd [branch] | lines
342+
# Line 2: cwd [branch] | lines
353343
printf "%b%s%b [%b%s%b] | lines: %b+%s%b, %b-%s%b\n" \
354344
"$CYAN" "${CWD_SHORT:-?}" "$RESET" \
355345
"$YELLOW" "$BRANCH" "$RESET" \

0 commit comments

Comments
 (0)