Configure Claude Code's statusline with a Powerlevel10k-inspired theme showing directory, git branch, lines changed, and context usage progress bar.
This skill configures Claude Code's statusline with a Powerlevel10k-inspired theme that displays:
~/currentDir format+N) and deletions (red -N)[██ ] 23% · 2h 15m left)Before installing, you MUST check for existing configurations:
Read ~/.claude/settings.json and check if a key already exists.
statusLineCheck if ~/.claude/statusline-command.sh already exists.
If either an existing statusLine configuration OR an existing script is found:
Use the AskUserQuestion tool to ask the user:
Question: "You already have a statusline configuration. Do you want to replace it with the Powerlevel10k-inspired theme?"
Options:
- "Yes, replace it" - Proceed with installation
- "No, keep my current setup" - Abort installation
If the user chooses to replace AND an existing script file exists at a different path:
Use the AskUserQuestion tool to ask:
Question: "Should I delete your old statusline script?"
Options:
- "Yes, delete it" - Delete the old script file
- "No, keep it" - Leave the old script file in place
If the user chooses not to replace: Stop here and inform the user that the existing configuration has been preserved.
Follow these steps to configure the statusline:
Write the following bash script to ~/.claude/statusline-command.sh:
#!/bin/bash
# Read JSON input from stdin
input=$(cat)
# Extract current working directory
cwd=$(echo "$input" | jq -r '.workspace.current_dir')
# Shortened directory format: ~/currentDir
home="$HOME"
if [[ "$cwd" == "$home" ]]; then
short_dir="~"
elif [[ "$cwd" == "$home"/* ]]; then
short_dir="~/$(basename "$cwd")"
else
short_dir="$(basename "$cwd")"
fi
# Get git branch
cd "$cwd" 2>/dev/null || true
git_branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo '')
git_status_str=""
if [ -n "$git_branch" ]; then
git_status_str=" $git_branch"
fi
# Get Claude's session lines added/removed
lines_added=$(echo "$input" | jq -r '.cost.total_lines_added // 0')
lines_removed=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')
lines_added_str=""
lines_removed_str=""
[ "$lines_added" != "0" ] && lines_added_str="+$lines_added"
[ "$lines_removed" != "0" ] && lines_removed_str="-$lines_removed"
# Extract context used percentage and create progress bar
context_used=$(echo "$input" | jq -r '.context_window.used_percentage // empty')
context_str=""
if [ -n "$context_used" ]; then
used_int=$(printf "%.0f" "$context_used")
if (( $(echo "$context_used < 50" | bc -l) )); then
bar_color=$'\033[32m' # Green for 0-50%
elif (( $(echo "$context_used < 75" | bc -l) )); then
bar_color=$'\033[33m' # Yellow for 50-75%
else
bar_color=$'\033[31m' # Red for 75-100%
fi
bar_length=10
total_blocks=$(echo "$context_used * $bar_length / 100" | bc -l)
full_blocks=$(printf "%.0f" "$(echo "$total_blocks" | bc -l | awk '{print int($1)}')")
fraction=$(echo "$total_blocks - $full_blocks" | bc -l)
shade_char=""
if (( $(echo "$fraction >= 0.875" | bc -l) )); then
shade_char="█"
full_blocks=$((full_blocks + 1))
elif (( $(echo "$fraction >= 0.625" | bc -l) )); then
shade_char="▓"
elif (( $(echo "$fraction >= 0.375" | bc -l) )); then
shade_char="▒"
elif (( $(echo "$fraction >= 0.125" | bc -l) )); then
shade_char="░"
fi
bar=$'\033[0m'"["
bar+="${bar_color}"
for ((i=0; i<full_blocks; i++)); do bar+="█"; done
[ -n "$shade_char" ] && [ "$full_blocks" -lt "$bar_length" ] && bar+="$shade_char"
bar+=$'\033[0m'
current_length=$full_blocks
[ -n "$shade_char" ] && [ "$full_blocks" -lt "$bar_length" ] && current_length=$((current_length + 1))
empty=$((bar_length - current_length))
for ((i=0; i<empty; i++)); do bar+=" "; done
bar+="]"
context_str=" $bar ${used_int}%"
fi
# Extract 5-hour rate limit data
rate_used=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
rate_resets_at=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
rate_str=""
if [ -n "$rate_used" ]; then
rate_int=$(printf "%.0f" "$rate_used")
if (( $(echo "$rate_used < 50" | bc -l) )); then
rate_color=$'\033[32m' # Green for 0-50%
elif (( $(echo "$rate_used < 75" | bc -l) )); then
rate_color=$'\033[33m' # Yellow for 50-75%
else
rate_color=$'\033[31m' # Red for 75-100%
fi
bar_length=10
total_blocks=$(echo "$rate_used * $bar_length / 100" | bc -l)
full_blocks=$(printf "%.0f" "$(echo "$total_blocks" | bc -l | awk '{print int($1)}')")
fraction=$(echo "$total_blocks - $full_blocks" | bc -l)
shade_char=""
if (( $(echo "$fraction >= 0.875" | bc -l) )); then
shade_char="█"
full_blocks=$((full_blocks + 1))
elif (( $(echo "$fraction >= 0.625" | bc -l) )); then
shade_char="▓"
elif (( $(echo "$fraction >= 0.375" | bc -l) )); then
shade_char="▒"
elif (( $(echo "$fraction >= 0.125" | bc -l) )); then
shade_char="░"
fi
rate_bar=$'\033[0m'"["
rate_bar+="${rate_color}"
for ((i=0; i<full_blocks; i++)); do rate_bar+="█"; done
[ -n "$shade_char" ] && [ "$full_blocks" -lt "$bar_length" ] && rate_bar+="$shade_char"
rate_bar+=$'\033[0m'
current_length=$full_blocks
[ -n "$shade_char" ] && [ "$full_blocks" -lt "$bar_length" ] && current_length=$((current_length + 1))
empty=$((bar_length - current_length))
for ((i=0; i<empty; i++)); do rate_bar+=" "; done
rate_bar+="]"
time_str=""
if [ -n "$rate_resets_at" ]; then
now=$(date +%s)
remaining_secs=$((rate_resets_at - now))
if [ "$remaining_secs" -gt 0 ]; then
hours=$((remaining_secs / 3600))
mins=$(( (remaining_secs % 3600) / 60 ))
if [ "$hours" -gt 0 ]; then
time_str=" · ${hours}h ${mins}m left"
else
time_str=" · ${mins}m left"
fi
fi
fi
rate_str=" $rate_bar ${rate_int}%${time_str}"
fi
# Output
printf "\033[36m%s\033[0m" "$short_dir"
[ -n "$git_status_str" ] && printf "\033[34m%s\033[0m" "$git_status_str"
if [ -n "$lines_added_str" ] || [ -n "$lines_removed_str" ]; then
printf " "
[ -n "$lines_added_str" ] && printf "\033[32m%s\033[0m" "$lines_added_str"
[ -n "$lines_added_str" ] && [ -n "$lines_removed_str" ] && printf " "
[ -n "$lines_removed_str" ] && printf "\033[31m%s\033[0m" "$lines_removed_str"
fi
[ -n "$context_str" ] && printf "\033[33m%s\033[0m" "$context_str"
[ -n "$rate_str" ] && printf "\033[33m%s\033[0m" "$rate_str"
chmod +x ~/.claude/statusline-command.sh
Add or merge the following configuration into ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline-command.sh"
}
}
If the file already exists, merge the statusLine key into the existing configuration.
After installation:
[██ ] 23% · 2h 15m left) — only visible for Pro/Max subscribers after the first API responseYou can modify ~/.claude/statusline-command.sh to customize:
bar_width variable)█ and ░)get_short_dir function)