cc-minimal-statusline 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alex Legarda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # cc-minimal-statusline
2
+
3
+ A minimal status line for [Claude Code](https://github.com/anthropics/claude-code).
4
+
5
+ ![Preview](preview.png)
6
+
7
+ ## Features
8
+
9
+ - Version with update indicator (↑)
10
+ - Model name
11
+ - Smart path truncation (`~code/project/…/current`)
12
+ - Git branch + worktree indicator
13
+ - File & line changes (includes untracked files, unlike Claude Code's footer)
14
+ - Context usage with gradient bar + autocompact indicator
15
+
16
+ ## Install
17
+
18
+ Requires a [Nerd Font](https://www.nerdfonts.com/). To install Meslo:
19
+
20
+ ```bash
21
+ brew install --cask font-meslo-lg-nerd-font
22
+ ```
23
+
24
+ Then select "MesloLGM Nerd Font" in your terminal settings.
25
+
26
+ ```bash
27
+ npm install -g cc-minimal-statusline
28
+ ```
29
+
30
+ Add to `~/.claude/settings.json`:
31
+
32
+ ```json
33
+ {
34
+ "statusLine": {
35
+ "type": "command",
36
+ "command": "cc-minimal-statusline",
37
+ "padding": 0
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Colors
43
+
44
+ Edit these variables in the script:
45
+
46
+ | Element | Variable | Default |
47
+ |---------|----------|---------|
48
+ | Version/separators | `C_DIM` | Gray (239) |
49
+ | Model | `C_ORANGE` | #E6714E |
50
+ | Directory | `C_BLUE` | Blue (75) |
51
+ | Worktree | `C_CYAN` | Cyan (80) |
52
+ | Branch | `C_PURPLE` | Purple (141) |
53
+ | +lines | `C_GREEN` | Green (108) |
54
+ | -lines | `C_RED` | Red (167) |
55
+
56
+ ## License
57
+
58
+ MIT
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "cc-minimal-statusline",
3
+ "version": "1.0.0",
4
+ "description": "A minimal, elegant status line for Claude Code with gradient progress bar, git integration, and update notifications",
5
+ "main": "statusline.sh",
6
+ "bin": {
7
+ "cc-minimal-statusline": "statusline.sh"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node scripts/postinstall.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/runsonmypc/cc-minimal-statusline.git"
15
+ },
16
+ "keywords": [
17
+ "claude",
18
+ "claude-code",
19
+ "statusline",
20
+ "status-line",
21
+ "terminal",
22
+ "cli"
23
+ ],
24
+ "author": "Alex Legarda",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/runsonmypc/cc-minimal-statusline/issues"
28
+ },
29
+ "homepage": "https://github.com/runsonmypc/cc-minimal-statusline#readme",
30
+ "engines": {
31
+ "node": ">=14.0.0"
32
+ }
33
+ }
package/preview.png ADDED
Binary file
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ const scriptPath = path.join(__dirname, '..', 'statusline.sh');
8
+ const configDir = path.join(os.homedir(), '.claude');
9
+ const settingsPath = path.join(configDir, 'settings.json');
10
+
11
+ console.log('\nšŸ“Š cc-minimal-statusline installed!\n');
12
+ console.log('To enable, add this to your ~/.claude/settings.json:\n');
13
+ console.log(`{
14
+ "statusLine": {
15
+ "type": "command",
16
+ "command": "${scriptPath}",
17
+ "padding": 0
18
+ }
19
+ }`);
20
+ console.log('\nšŸ’” Tip: Make sure you have a Nerd Font installed for icons to display correctly.');
21
+ console.log(' brew install --cask font-meslo-lg-nerd-font\n');
package/statusline.sh ADDED
@@ -0,0 +1,300 @@
1
+ #!/bin/bash
2
+
3
+ # Claude Code Status Line - Sunset Minimal Design
4
+ # Reads JSON from stdin and outputs a formatted status line
5
+
6
+ # Read JSON from stdin
7
+ json=$(cat)
8
+
9
+ # Parse JSON fields - extract string value after a key
10
+ get_string_value() {
11
+ echo "$json" | sed -n 's/.*"'"$1"'"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1
12
+ }
13
+
14
+ get_number_value() {
15
+ echo "$json" | sed -n 's/.*"'"$1"'"[[:space:]]*:[[:space:]]*\([0-9]*\).*/\1/p' | head -1
16
+ }
17
+
18
+ # Extract fields
19
+ version=$(get_string_value "version")
20
+ model=$(get_string_value "display_name")
21
+ used_pct=$(get_number_value "used_percentage")
22
+ lines_added=$(get_number_value "total_lines_added")
23
+ lines_removed=$(get_number_value "total_lines_removed")
24
+ current_dir=$(get_string_value "current_dir")
25
+
26
+ # Fallback values
27
+ [ -z "$version" ] && version="?.?.?"
28
+ [ -z "$model" ] && model="Claude"
29
+ [ -z "$used_pct" ] && used_pct="0"
30
+ [ -z "$lines_added" ] && lines_added="0"
31
+ [ -z "$lines_removed" ] && lines_removed="0"
32
+ [ -z "$current_dir" ] && current_dir="$PWD"
33
+
34
+ # Check if we're on latest version (cached, background refresh)
35
+ is_outdated="false"
36
+ cache_file="/tmp/.claude-code-latest-version"
37
+ cache_max_age=3600 # 1 hour
38
+
39
+ check_latest_version() {
40
+ local now=$(date +%s)
41
+ local cached_version=""
42
+ local cached_time=0
43
+
44
+ # Read cache if it exists
45
+ if [ -f "$cache_file" ]; then
46
+ cached_time=$(head -1 "$cache_file" 2>/dev/null)
47
+ cached_version=$(tail -1 "$cache_file" 2>/dev/null)
48
+ fi
49
+
50
+ # If cache is stale, trigger background refresh (non-blocking)
51
+ if [ $((now - cached_time)) -gt $cache_max_age ] || [ -z "$cached_version" ]; then
52
+ # Background fetch - writes to cache, doesn't block
53
+ (npm show @anthropic-ai/claude-code version 2>/dev/null | {
54
+ read latest
55
+ if [ -n "$latest" ]; then
56
+ echo "$(date +%s)" > "$cache_file"
57
+ echo "$latest" >> "$cache_file"
58
+ fi
59
+ }) &>/dev/null &
60
+ fi
61
+
62
+ # Compare using cached version (may be stale, that's ok)
63
+ if [ -n "$cached_version" ] && [ "$version" != "$cached_version" ]; then
64
+ # Check if current < latest
65
+ if [ "$(printf '%s\n' "$version" "$cached_version" | sort -V | head -1)" = "$version" ] && [ "$version" != "$cached_version" ]; then
66
+ echo "true"
67
+ return
68
+ fi
69
+ fi
70
+ echo "false"
71
+ }
72
+
73
+ is_outdated=$(check_latest_version)
74
+
75
+ # Check if autocompact is enabled (default: true)
76
+ # Can be disabled via settings.json: "autoCompactEnabled": false
77
+ autocompact_enabled="true"
78
+ if grep -q '"autoCompactEnabled"[[:space:]]*:[[:space:]]*false' ~/.claude/settings.json 2>/dev/null; then
79
+ autocompact_enabled="false"
80
+ fi
81
+
82
+ # Adjust for autocompact buffer (22.5% reserved = 77.5% usable)
83
+ # Only apply when autocompact is enabled
84
+ if [ "$autocompact_enabled" = "true" ] && [ "$used_pct" -gt 0 ] 2>/dev/null; then
85
+ used_pct=$((used_pct * 100 / 77))
86
+ [ "$used_pct" -gt 100 ] && used_pct=100
87
+ fi
88
+
89
+ # ANSI 256 color codes (as literal strings - interpreted only at final echo -e)
90
+ C_RESET='\033[0m'
91
+ C_DIM='\033[38;5;239m' # Dim gray - version, separators
92
+ C_ORANGE='\033[38;2;230;113;78m' # #E6714E - model
93
+ C_BLUE='\033[38;5;75m' # Soft blue - directory
94
+ C_CYAN='\033[38;5;80m' # Cyan - worktree flask
95
+ C_PURPLE='\033[38;5;141m' # Purple - branch
96
+ C_GREEN='\033[38;5;108m' # Muted green - lines added
97
+ C_RED='\033[38;5;167m' # Muted red - lines removed
98
+
99
+ # Nerd Font icons (using printf for reliable UTF-8 output)
100
+ ICON_BRANCH=$(printf '\xee\x9c\xa5') # U+E725 git branch
101
+ ICON_WORKTREE=$(printf '\xef\x83\x83') # U+F0C3 flask
102
+ ICON_FILES=$(printf '\xef\x85\x9b') # U+F15B file
103
+ ICON_UPDATE=$(printf '\xef\x81\xa2') # U+F062 fa-arrow-up
104
+ ICON_COMPACT=$(printf '\xef\x81\xa6') # U+F066 fa-compress
105
+ # Bar colors - 20-step gradient (every 5%)
106
+ # Green (0%) → Gold (50%) → Model color #C15F3C (75%) → Red (100%)
107
+ BAR_COLORS=(
108
+ '\033[38;2;70;200;70m' # 0-4%: Green
109
+ '\033[38;2;89;200;63m' # 5-9%
110
+ '\033[38;2;107;200;56m' # 10-14%
111
+ '\033[38;2;126;200;49m' # 15-19%
112
+ '\033[38;2;144;200;42m' # 20-24%
113
+ '\033[38;2;163;200;35m' # 25-29%
114
+ '\033[38;2;181;200;28m' # 30-34%
115
+ '\033[38;2;200;200;21m' # 35-39%
116
+ '\033[38;2;218;200;14m' # 40-44%
117
+ '\033[38;2;237;200;7m' # 45-49%
118
+ '\033[38;2;255;200;0m' # 50-54%: Gold
119
+ '\033[38;2;243;179;12m' # 55-59%
120
+ '\033[38;2;230;158;24m' # 60-64%
121
+ '\033[38;2;218;137;36m' # 65-69%
122
+ '\033[38;2;205;116;48m' # 70-74%
123
+ '\033[38;2;193;95;60m' # 75-79%: Model color
124
+ '\033[38;2;200;86;60m' # 80-84%
125
+ '\033[38;2;207;78;60m' # 85-89%
126
+ '\033[38;2;213;69;60m' # 90-94%
127
+ '\033[38;2;220;60;60m' # 95-100%: Red
128
+ )
129
+
130
+ # Smart directory truncation
131
+ truncate_path() {
132
+ local path="$1"
133
+ # Remove home directory prefix
134
+ path="${path/#$HOME/~}"
135
+
136
+ if [ ${#path} -le 20 ]; then
137
+ echo "$path"
138
+ return
139
+ fi
140
+
141
+ # Split into segments
142
+ IFS='/' read -ra segments <<< "$path"
143
+ local count=${#segments[@]}
144
+
145
+ # For ~ paths, need at least 4 segments to truncate (~ + 3 dirs)
146
+ # For other paths, need at least 3 segments
147
+ if [[ "$path" == ~* ]]; then
148
+ [ $count -le 4 ] && { echo "$path"; return; }
149
+ else
150
+ [ $count -le 2 ] && { echo "$path"; return; }
151
+ fi
152
+
153
+ local last="${segments[$((count-1))]}"
154
+
155
+ # For paths starting with ~, show ~/first/second/…/last
156
+ if [[ "$path" == ~* ]]; then
157
+ local dirs=()
158
+ for ((i=0; i<count; i++)); do
159
+ if [ -n "${segments[$i]}" ] && [ "${segments[$i]}" != "~" ]; then
160
+ dirs+=("${segments[$i]}")
161
+ [ ${#dirs[@]} -ge 2 ] && break
162
+ fi
163
+ done
164
+ echo "~${dirs[0]}/${dirs[1]}/…/$last"
165
+ else
166
+ local first="${segments[0]}"
167
+ [ -z "$first" ] && first="${segments[1]}"
168
+ echo "$first/…/$last"
169
+ fi
170
+ }
171
+
172
+ # Get git info (includes untracked files, unlike Claude Code's built-in footer)
173
+ get_git_info() {
174
+ local dir="$1"
175
+ [ -z "$dir" ] && return
176
+
177
+ local branch=$(git -C "$dir" branch --show-current 2>/dev/null)
178
+ [ -z "$branch" ] && return
179
+
180
+ # Check if we're in a worktree (not main working tree)
181
+ local git_dir=$(git -C "$dir" rev-parse --git-dir 2>/dev/null)
182
+ local worktree_name=""
183
+
184
+ if [[ "$git_dir" == *".git/worktrees/"* ]]; then
185
+ # Extract worktree name from path (git_dir is like /repo/.git/worktrees/wt-name)
186
+ worktree_name=$(basename "$git_dir" 2>/dev/null)
187
+ fi
188
+
189
+ # Get current uncommitted changes (staged + unstaged)
190
+ local diff_stat=$(git -C "$dir" diff --numstat HEAD 2>/dev/null | awk '{files++; add+=$1; del+=$2} END {print files"|"add"|"del}')
191
+ local tracked_files="${diff_stat%%|*}"
192
+ local rest="${diff_stat#*|}"
193
+ local added="${rest%%|*}"
194
+ local removed="${rest##*|}"
195
+ [ -z "$tracked_files" ] && tracked_files="0"
196
+ [ -z "$added" ] && added="0"
197
+ [ -z "$removed" ] && removed="0"
198
+
199
+ # Count untracked files and their lines
200
+ local untracked_files=$(git -C "$dir" ls-files --others --exclude-standard 2>/dev/null)
201
+ local untracked=0
202
+ local untracked_lines=0
203
+ if [ -n "$untracked_files" ]; then
204
+ untracked=$(echo "$untracked_files" | wc -l | tr -d ' ')
205
+ # Count lines in untracked files (all count as additions)
206
+ untracked_lines=$(echo "$untracked_files" | while IFS= read -r f; do
207
+ wc -l < "$dir/$f" 2>/dev/null
208
+ done | awk '{sum+=$1} END {print sum+0}')
209
+ fi
210
+ local files=$((tracked_files + untracked))
211
+ added=$((added + untracked_lines))
212
+
213
+ echo "${branch}|${worktree_name}|${files}|${added}|${removed}"
214
+ }
215
+
216
+ # Generate progress bar (returns literal escape sequences, not interpreted)
217
+ generate_bar() {
218
+ local pct=$1
219
+ local bar_len=30
220
+ local filled=$((bar_len * pct / 100))
221
+ [ $filled -gt $bar_len ] && filled=$bar_len
222
+ local empty=$((bar_len - filled))
223
+
224
+ # Select color based on percentage (20 color stages, every 5%)
225
+ local idx=$((pct / 5))
226
+ [ $idx -gt 19 ] && idx=19
227
+ local bar_color="${BAR_COLORS[$idx]}"
228
+
229
+ # Build bar with literal escape sequences
230
+ local bar=""
231
+ if [ $filled -gt 0 ]; then
232
+ bar="${bar_color}$(printf '━%.0s' $(seq 1 $filled))"
233
+ fi
234
+ if [ $empty -gt 0 ]; then
235
+ bar="${bar}${C_DIM}$(printf '━%.0s' $(seq 1 $empty))"
236
+ fi
237
+
238
+ # Return literal string (no echo -e here!)
239
+ printf '%s' "$bar"
240
+ }
241
+
242
+ # Build the status line
243
+ build_status() {
244
+ local sep="${C_DIM}│${C_RESET}"
245
+ local path_display=$(truncate_path "$current_dir")
246
+ local git_info=$(get_git_info "$current_dir")
247
+ local bar=$(generate_bar "$used_pct")
248
+
249
+ # Parse git info (branch|worktree|files|added|removed)
250
+ local branch=""
251
+ local worktree=""
252
+ local git_files="0"
253
+ local git_added="0"
254
+ local git_removed="0"
255
+ if [ -n "$git_info" ]; then
256
+ branch=$(echo "$git_info" | cut -d'|' -f1)
257
+ worktree=$(echo "$git_info" | cut -d'|' -f2)
258
+ git_files=$(echo "$git_info" | cut -d'|' -f3)
259
+ git_added=$(echo "$git_info" | cut -d'|' -f4)
260
+ git_removed=$(echo "$git_info" | cut -d'|' -f5)
261
+ [ -z "$git_files" ] && git_files="0"
262
+ [ -z "$git_added" ] && git_added="0"
263
+ [ -z "$git_removed" ] && git_removed="0"
264
+ fi
265
+
266
+ # Version (with update icon if outdated)
267
+ local version_display="v${version}"
268
+ [ "$is_outdated" = "true" ] && version_display="${version_display} ${C_ORANGE}${ICON_UPDATE}"
269
+ local out="${C_DIM}${version_display}${C_RESET}"
270
+
271
+ # Model
272
+ out="${out} ${sep} ${C_ORANGE}${model}${C_RESET}"
273
+
274
+ # Directory (blue) - prepend cyan flask icon if in worktree
275
+ if [ -n "$worktree" ]; then
276
+ path_display="${C_CYAN}${ICON_WORKTREE}${C_BLUE}${path_display}"
277
+ fi
278
+ out="${out} ${sep} ${C_BLUE}${path_display}${C_RESET}"
279
+
280
+ # Branch (purple)
281
+ if [ -n "$branch" ]; then
282
+ out="${out} ${C_PURPLE}${ICON_BRANCH}${branch}${C_RESET}"
283
+ fi
284
+
285
+ # Files and lines changed from git status (only show if there are uncommitted changes)
286
+ if [ "$git_files" != "0" ] || [ "$git_added" != "0" ] || [ "$git_removed" != "0" ]; then
287
+ out="${out} ${sep} ${C_DIM}${ICON_FILES}${git_files}${C_RESET} ${C_GREEN}+${git_added}${C_DIM}/${C_RED}-${git_removed}${C_RESET}"
288
+ fi
289
+
290
+ # Context percentage and bar (with compress icon if autocompact enabled)
291
+ local compact_indicator=""
292
+ [ "$autocompact_enabled" = "true" ] && compact_indicator=" ${C_DIM}${ICON_COMPACT}"
293
+ out="${out} ${sep} ${C_DIM}${used_pct}%${C_RESET} ${bar}${compact_indicator}${C_RESET}"
294
+
295
+ # Single echo -e at the end interprets ALL escape sequences
296
+ echo -e "$out"
297
+ }
298
+
299
+ # Output the status line
300
+ build_status