Skip to content
Shell
1.4 KB
Raw Blame
#!/bin/bash

# Read JSON input from stdin
input=$(cat)

# Extract values from JSON
current_dir=$(echo "$input" | jq -r '.workspace.current_dir')
model_name=$(echo "$input" | jq -r '.model.display_name')

# Get username and hostname
username=$(whoami)
hostname=$(hostname -s)

# Get timestamp
timestamp=$(date "+%H:%M:%S")

# Get git branch and status (if in a git repo)
git_info=""
if git -C "$current_dir" rev-parse --git-dir > /dev/null 2>&1; then
    branch=$(git -C "$current_dir" --no-optional-locks branch --show-current 2>/dev/null)
    
    # Check for uncommitted changes
    if ! git -C "$current_dir" --no-optional-locks diff-index --quiet HEAD -- 2>/dev/null; then
        status="*"
    else
        status=""
    fi
    
    # Check for untracked files
    if [ -n "$(git -C "$current_dir" --no-optional-locks ls-files --others --exclude-standard 2>/dev/null)" ]; then
        if [ -n "$status" ]; then
            status="${status}+"
        else
            status="+"
        fi
    fi
    
    if [ -n "$branch" ]; then
        # Color all branches in salmon for visibility
        git_info=" [git: \033[38;5;210m${branch}\033[2m${status}]"
    fi
fi

# Build status line with dim colors
# Format: [timestamp] username@hostname | directory | git info | model
printf "\033[2m[%s] %s@%s | %s%s | %s\033[0m" \
    "$timestamp" \
    "$username" \
    "$hostname" \
    "$current_dir" \
    "$git_info" \
    "$model_name"