#!/usr/bin/env bash # Claude Code status line — inspired by Powerlevel10k/Tide layout # Segments: user@host cwd git branch model context % input=$(cat) cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // ""') model=$(echo "$input" | jq -r '.model.display_name // ""') used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') # --- user@host --- user=$(whoami) host=$(hostname -s) # --- pretty cwd: replace $HOME with ~ --- home="$HOME" short_cwd="${cwd/#$home/\~}" # --- git branch (skip optional locks) --- git_branch="" if git_out=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null); then git_branch="$git_out" elif git_out=$(git -C "$cwd" --no-optional-locks rev-parse --short HEAD 2>/dev/null); then git_branch="$git_out" fi # --- context bar --- context_str="" if [ -n "$used_pct" ]; then used_int=${used_pct%.*} if [ "${used_int:-0}" -ge 80 ]; then ctx_color="\033[31m" # red elif [ "${used_int:-0}" -ge 50 ]; then ctx_color="\033[33m" # yellow else ctx_color="\033[32m" # green fi context_str=" ${ctx_color}ctx:${used_pct%.*}%\033[0m" fi # --- assemble --- # user@host in cyan, cwd in bold, git branch in magenta, model in dim printf "\033[36m%s@%s\033[0m \033[1m%s\033[0m" "$user" "$host" "$short_cwd" if [ -n "$git_branch" ]; then printf " \033[35m\ue0a0 %s\033[0m" "$git_branch" fi if [ -n "$model" ]; then printf " \033[2m%s\033[0m" "$model" fi if [ -n "$context_str" ]; then printf "%b" "$context_str" fi