Last active
October 25, 2025 07:10
-
-
Save FradSer/0ae34e211c8a61db756d5aca8743cc96 to your computer and use it in GitHub Desktop.
$HOME/.claude/statusline.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Claude Code Status Line - inspired by Starship configuration | |
| # Reads JSON input from stdin and displays contextual information | |
| input=$(cat) | |
| # Extract information from JSON input | |
| model_name=$(echo "$input" | jq -r '.model.display_name // "Claude"') | |
| current_dir=$(echo "$input" | jq -r '.workspace.current_dir // ""') | |
| project_dir=$(echo "$input" | jq -r '.workspace.project_dir // ""') | |
| output_style=$(echo "$input" | jq -r '.output_style.name // ""') | |
| # Get current provider | |
| PROVIDER="${ANTHROPIC_BASE_URL:-none}" | |
| # Extract provider name from URL | |
| if [[ "$PROVIDER" != "none" && -n "$PROVIDER" ]]; then | |
| # Extract domain from URL and remove www prefix and API path | |
| DOMAIN=$(echo "$PROVIDER" | sed 's|https://||' | sed 's|/.*||' | sed 's|^www\.||' | head -1) | |
| if [[ -n "$DOMAIN" ]]; then | |
| # Extract main domain name (second-level domain) | |
| PROVIDER_NAME=$(echo "$DOMAIN" | awk -F. '{if (NF>=2) print $(NF-1); else print $1}') | |
| else | |
| # Fallback: extract from path | |
| PROVIDER_NAME=$(echo "$PROVIDER" | sed 's|.*/||') | |
| fi | |
| else | |
| PROVIDER_NAME="unknown" | |
| fi | |
| # Adjust model display name based on provider | |
| if [[ "$PROVIDER_NAME" == "streamlake" ]]; then | |
| model_name="KAT-Coder" | |
| fi | |
| # Display current directory (only show project folder name) | |
| display_dir=$(basename "$current_dir") | |
| # Get git information (skip locks to avoid blocking) | |
| git_info="" | |
| if git -C "$current_dir" rev-parse --git-dir >/dev/null 2>&1; then | |
| # Get branch name | |
| branch=$(git -C "$current_dir" branch --show-current 2>/dev/null || echo "HEAD") | |
| # Get git status (abbreviated) | |
| git_status="" | |
| if ! git -C "$current_dir" diff-index --quiet HEAD -- 2>/dev/null; then | |
| git_status=" *" | |
| fi | |
| # Check for untracked files | |
| if [[ -n $(git -C "$current_dir" ls-files --others --exclude-standard 2>/dev/null) ]]; then | |
| git_status="${git_status}?" | |
| fi | |
| # Check for stashed changes | |
| if git -C "$current_dir" rev-parse --verify refs/stash >/dev/null 2>&1; then | |
| git_status="${git_status}S" | |
| fi | |
| git_info=" $branch$git_status" | |
| fi | |
| # Show project indicator if we're in a project directory | |
| project_indicator="" | |
| if [[ -n "$project_dir" && "$current_dir" != "$project_dir" ]]; then | |
| relative_path=$(realpath --relative-to="$project_dir" "$current_dir" 2>/dev/null || echo "$display_dir") | |
| if [[ "$relative_path" != "." ]]; then | |
| project_indicator=" ($relative_path)" | |
| fi | |
| fi | |
| # Show output style if it's not the default | |
| style_indicator="" | |
| if [[ "$output_style" != "default" && -n "$output_style" ]]; then | |
| style_indicator=" [$output_style]" | |
| fi | |
| # Build the status line using printf for colors | |
| printf "\033[36m%s\033[0m\033[90m in %s\033[0m\033[90m on\033[0m\033[32m%s\033[0m\033[34m%s\033[0m" \ | |
| "$model_name" \ | |
| "$display_dir" \ | |
| "$git_info" \ | |
| "$project_indicator$style_indicator" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment