84 lines
2.4 KiB
Bash
Executable File
84 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
# Read JSON input from stdin
|
|
input=$(cat)
|
|
|
|
# Extract values using jq
|
|
model=$(echo "$input" | jq -r '.model.display_name // empty')
|
|
dir=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty')
|
|
remaining=$(echo "$input" | jq -r '.context_window.remaining_percentage // empty')
|
|
output_style=$(echo "$input" | jq -r '.output_style.name // empty')
|
|
vim_mode=$(echo "$input" | jq -r '.vim.mode // empty')
|
|
|
|
# Get git information (GIT_OPTIONAL_LOCKS=0 to skip optional locks)
|
|
branch=""
|
|
git_status=""
|
|
if [ -n "$dir" ] && [ -d "$dir" ]; then
|
|
branch=$(GIT_OPTIONAL_LOCKS=0 git -C "$dir" branch --show-current 2>/dev/null)
|
|
if [ -n "$branch" ]; then
|
|
if GIT_OPTIONAL_LOCKS=0 git -C "$dir" diff --quiet 2>/dev/null && \
|
|
GIT_OPTIONAL_LOCKS=0 git -C "$dir" diff --cached --quiet 2>/dev/null; then
|
|
git_status=""
|
|
else
|
|
git_status="*"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# --- Build status line styled after your zsh PROMPT ---
|
|
# PROMPT='%F{cyan}%n@%m %F{yellow}%1~ %F{green}$(git_prompt_info)%f %# '
|
|
#
|
|
# user@host in cyan | last dir component in yellow | git branch in green
|
|
# followed by: model, context %, output style, vim mode
|
|
|
|
# user@host in cyan
|
|
user_host="$(whoami)@$(hostname -s)"
|
|
output="\033[36m${user_host}\033[0m"
|
|
|
|
# Last directory component in yellow
|
|
if [ -n "$dir" ]; then
|
|
short_dir=$(basename "$dir")
|
|
output="$output \033[33m${short_dir}\033[0m"
|
|
fi
|
|
|
|
# Git branch in green (matches git_prompt_info style)
|
|
if [ -n "$branch" ]; then
|
|
output="$output \033[32m(${branch}${git_status})\033[0m"
|
|
fi
|
|
|
|
# Separator before Claude-specific info
|
|
output="$output \033[90m|\033[0m"
|
|
|
|
# Model name in green
|
|
if [ -n "$model" ]; then
|
|
output="$output \033[32m${model}\033[0m"
|
|
fi
|
|
|
|
# Output style in purple (if not default)
|
|
if [ -n "$output_style" ] && [ "$output_style" != "default" ]; then
|
|
output="$output \033[35m[${output_style}]\033[0m"
|
|
fi
|
|
|
|
# Context remaining percentage
|
|
if [ -n "$remaining" ]; then
|
|
remaining_int=$(printf "%.0f" "$remaining")
|
|
if [ "$remaining_int" -lt 20 ]; then
|
|
# Red if low
|
|
output="$output \033[31mctx:${remaining_int}%\033[0m"
|
|
else
|
|
# Yellow otherwise
|
|
output="$output \033[33mctx:${remaining_int}%\033[0m"
|
|
fi
|
|
fi
|
|
|
|
# Vim mode indicator if enabled
|
|
if [ -n "$vim_mode" ]; then
|
|
if [ "$vim_mode" = "INSERT" ]; then
|
|
output="$output \033[32m[I]\033[0m"
|
|
else
|
|
output="$output \033[36m[N]\033[0m"
|
|
fi
|
|
fi
|
|
|
|
printf "%b\n" "$output"
|