# cc-statusline **Repository Path**: masx201/cc-statusline ## Basic Information - **Project Name**: cc-statusline - **Description**: https://github.com/chongdashu/cc-statusline - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2025-09-24 - **Last Updated**: 2025-09-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cc-statusline
*Real-time directory, git branch, model info, costs, and session time tracking*
[](https://www.npmjs.com/package/@chongdashu/cc-statusline)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
## โจ What You Get
Enhance your Claude Code terminal with useful information:
- **๐ Directory Display** - Current folder with `~` abbreviation
- **๐ฟ Git Integration** - Current branch name
- **๐ค Model Info** - Shows which Claude model you're using plus Claude Code version
- **๐ง Context Usage** - Real-time context window usage with progress bars **(requires jq)**
- **๐ฐ Cost Tracking** - Live cost monitoring with burn rates via ccusage **(partial without jq)**
- **โ Session Timer** - Time remaining until usage limit resets **(requires jq)**
- **๐ Token Analytics** - Token consumption and burn rate metrics **(requires jq)**
- **๐จ Color Support** - 256-color palette for Claude Code terminals
- **โก Fast Execution** - Optimized bash script with <100ms execution time
## ๐๏ธ Features Overview
### ๐ Installation Options (v1.2.4+)
- **๐ Global Installation** (`~/.claude/`) - Use across all your projects
- **๐ Project Installation** (`./.claude/`) - Keep settings project-specific
### ๐ฅ Default Features (All Pre-selected in v1.2.2+)
| Feature | Description | Example |
|---------|-------------|---------|
| ๐ **Directory** | Current working directory | `~/my-project` |
| ๐ฟ **Git Branch** | Active git branch | `feature/statusline` |
| ๐ค **Model** | Claude model name & version | `Sonnet 4` |
| ๐ **Claude Code** | Claude Code version | `v1.0.85` |
| ๐จ **Output Style** | Current output style setting | `default` |
| ๐ง **Context** | Remaining context with progress bar | `83% [========--]` |
| ๐ฐ **Cost** | Live costs with highlighted burn rate | `$49.00 ($16.55/h)` |
| โ **Session** | Time until reset with progress | `3h 7m until reset at 01:00 (37%) [===-------]` |
### ๐ Power Features (Also Pre-selected)
| Feature | Description | Example |
|---------|-------------|---------|
| ๐ **Tokens** | Token consumption with burn rate | `14638846 tok (279900 tpm)` |
### ๐จ Example Outputs
**New 3-Line Modern Layout (v1.2.2+):**
```
๐ ~/Projects/cc-statusline ๐ฟ feature/context-usage-output-styles ๐ค Sonnet 4 ๐ v1.0.85 ๐จ default
๐ง Context Remaining: 83% [========--] โ 3h 7m until reset at 01:00 (37%) [===-------]
๐ฐ $49.00 ($16.55/h) ๐ 14638846 tok (279900 tpm)
```
**Compact Mode:**
```
๐ ~/my-app ๐ฟ main ๐ค Claude Sonnet ๐ v1.0.85
๐ง Context Remaining: 95% [=========-]
๐ฐ $2.48 ($12.50/h)
```
## ๐ ๏ธ Advanced Usage
### Preview Your Statusline
Test your statusline before restarting Claude Code:
```bash
cc-statusline preview .claude/statusline.sh
```
**What preview does:**
1. ๐ **Loads** your actual statusline script
2. ๐งช **Runs** it with realistic mock data
3. ๐ **Shows** exactly what the output will look like
4. โก **Reports** performance metrics and functionality
### Installation Safety Features (v1.2.4+)
- ๐ **Safe Updates** - Never overwrites existing statuslines without confirmation
- ๐ก๏ธ **Settings Protection** - Preserves your existing settings.json configurations
- โ ๏ธ **Conflict Detection** - Warns when other statuslines are configured
- โ
**Smart Defaults** - Project-level installation by default for safety
### Custom Installation
```bash
# Generate to custom location
cc-statusline init --output ./my-statusline.sh
# Skip auto-installation (manual setup)
cc-statusline init --no-install
# Global installation for convenience
npm install -g @chongdashu/cc-statusline
```
## ๐ง How It Works
### How It Works
1. **๐ฏ Configuration** - Two questions configure your preferences
2. **๐๏ธ Generation** - Creates optimized bash script tailored to your needs
3. **โ๏ธ Installation** - Integrates with Claude Code settings
4. **๐ Updates** - Connects to ccusage for live usage statistics
### Technical Architecture
- **โก Bash-First** - Native shell execution for maximum speed
- **๐จ Claude Code Optimized** - Forces colors for Claude Code terminals (respects NO_COLOR)
- **๐ Environment Respect** - Honors `NO_COLOR` and other terminal conventions
- **๐ฆ Zero Dependencies** - Self-contained script with graceful fallbacks
- **๐ Secure** - No network requests except ccusage integration
## ๐ File Structure
After installation, you'll have a clean setup:
```
.claude/
โโโ statusline.sh # ๐ฏ Your generated statusline script
โโโ settings.json # โ๏ธ Auto-updated Claude Code configuration
```
### Manual Configuration (Backup Plan)
If auto-configuration fails, simply add this to `.claude/settings.json`:
```json
{
"statusLine": {
"type": "command",
"command": ".claude/statusline.sh",
"padding": 0
}
}
```
## ๐ง Troubleshooting
### ๐ซ Statusline Not Showing
1. **Restart Claude Code** after installation
2. **Verify settings** - Check `.claude/settings.json` contains the configuration above
3. **Check permissions** - Ensure script is executable: `chmod +x .claude/statusline.sh`
### ๐ Performance Issues
- **Test performance**: `cc-statusline preview .claude/statusline.sh`
- **Optimize features**: Disable heavy features if execution > 500ms
- **Disable ccusage**: Remove usage tracking if not needed
### ๐งฉ Missing Features
- **Install jq**: See the jq installation guide below
- **ccusage setup**: Works automatically via `npx ccusage@latest`
- **Git not found**: Install git for branch display
- **Context not showing**: Ensure you're in an active Claude Code session with context usage
- **Colors not working**: Check that NO_COLOR environment variable is not set
## ๐ Performance
| Metric | Target | Typical |
|--------|--------|---------|
| **Execution Time** | <100ms | 45-80ms |
| **Memory Usage** | <5MB | ~2MB |
| **CPU Impact** | Negligible | <1% |
| **Dependencies** | Minimal | jq only |
*Benchmarked on macOS with all features enabled*
## ๐ค Contributing
Contributions are welcome!
**Quick Start:**
```bash
git clone https://github.com/chongdashu/cc-statusline
cd cc-statusline
npm install && npm run build
```
**Contribution Areas:**
- ๐ **Bug Fixes** - Help make it more robust
- โจ **New Features** - Add support for more runtimes/features
- ๐ **Documentation** - Improve guides and examples
- ๐งช **Testing** - Add test coverage and edge cases
See our [Contributing Guide](CONTRIBUTING.md) for detailed information.
## ๐งช Testing
### Locking Mechanism Tests
The ccusage integration includes a robust file-based locking mechanism to prevent concurrent process spawning. Test this functionality:
**Single Test:**
```bash
echo '{}' | ./test/test-statusline-with-lock.sh
```
**Concurrent Test:**
```bash
./test/test-concurrent-locking.sh
```
**Manual Concurrent Test:**
```bash
# Spawn 10 concurrent processes
for i in {1..10}; do
echo '{}' | ./test/test-statusline-with-lock.sh &
done
```
**Expected Behavior:**
- โ
Only 1 process runs ccusage at a time
- โ
Other processes skip gracefully (no pile-up)
- โ
Lock files are properly cleaned up
- โ
No hanging processes remain
**Verification Commands:**
```bash
# Check for stale locks
ls /tmp/ccusage_statusline.* 2>/dev/null || echo "โ
No locks remain"
# Monitor running processes
ps aux | grep ccusage | grep -v grep
```
## ๐ Stats