Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/statusline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For more details on how to use and configure the statusline script, please refer
## How it works

The `statusline.sh` script reads a JSON payload from standard input, containing various state information from the CLI. It then:
1. Extracts multiple fields like `agent_state`, `vcs` info, context usage, and terminal dimensions using `jq`.
1. Extracts multiple fields like `agent_state`, `conversation_name`, `vcs` info, context usage, and terminal dimensions using `jq`.
2. Computes visual indicators, such as a Unicode progress bar for context window usage.
3. Formats the data with standard ANSI 16-color codes for visual distinction.
4. Dynamically adjusts the layout to be 1 or 2 lines based on the available terminal width.
Expand Down
14 changes: 11 additions & 3 deletions examples/statusline/statusline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ NUM_COLOR="${FG_BRIGHT_WHITE}${B}"
# Extract all fields in one pass to prevent spawning jq 8 times.
{
read -r STATE
read -r CONV_NAME
read -r USED_PCT
read -r VCS_BRANCH
read -r VCS_DIRTY
Expand All @@ -45,6 +46,7 @@ NUM_COLOR="${FG_BRIGHT_WHITE}${B}"
} <<< "$(
jq -r '
(.agent_state // "idle"),
(.conversation_name // ""),
(.context_window.used_percentage // 0),
(.vcs.branch // ""),
(.vcs.dirty // false),
Expand All @@ -54,7 +56,7 @@ NUM_COLOR="${FG_BRIGHT_WHITE}${B}"
(.task_count // 0),
(.model.display_name // ""),
(.terminal_width // 80)
' 2>/dev/null || printf "idle\n0\n\nfalse\nfalse\n0\n0\n0\n\n80\n"
' 2>/dev/null || printf "idle\n\n0\n\nfalse\nfalse\n0\n0\n0\n\n80\n"
)"

# ─── Computed Values ─────────────────────────────────────────────────────────
Expand All @@ -71,6 +73,12 @@ case "$STATE" in
*) S="${FG_WHITE}${B}⏳ $(echo "$STATE" | tr '[:lower:]' '[:upper:]')${R}" ;;
esac

# ─── Conversation Name ───────────────────────────────────────────────────────
C=""
if [ -n "$CONV_NAME" ]; then
C="${FG_GRAY} ╱ ${FG_BRIGHT_CYAN}${CONV_NAME}${R}"
fi

# ─── VCS Branch ──────────────────────────────────────────────────────────────
V=""
if [ -n "$VCS_BRANCH" ]; then
Expand Down Expand Up @@ -138,7 +146,7 @@ BG_FMT="${FG_GRAY}tasks ${NUM_COLOR}${BG_TASKS}${R}"
DOT="${FG_GRAY} · ${R}"

# ─── Output ──────────────────────────────────────────────────────────────────
LINE1="${S}${M}${V}"
LINE1="${S}${C}${M}${V}"
LINE2=" ${CTX}${DOT}${ART_FMT}${DOT}${SUB_FMT}${DOT}${BG_FMT}${DOT}${SB}"

if [ "$COLS" -ge 120 ]; then
Expand All @@ -150,6 +158,6 @@ elif [ "$COLS" -ge 80 ]; then
echo -e "${FG_GRAY}╰─${R}${LINE2}"
else
# Narrow: compact two-line, minimal chrome
echo -e "${S}${M}"
echo -e "${S}${C}${M}"
echo -e "${CTX}${DOT}${BG_FMT}"
fi