Directory Display
The directory feature shows your current working directory with intelligent home path abbreviation.How It Works
cc-statusline extracts the current directory from Claude Codeβs JSON input and automatically abbreviates your home directory to~:
Implementation Details
- With jq (Preferred)
- Bash Fallback
When jq is available, directory extraction is fast and reliable:This looks for:
workspace.current_dir(primary location)cwd(fallback)"unknown"(if both fail)
Display Code
Frombash-generator.ts:220:
- π folder emoji
- Sky blue color (ANSI 38;5;117)
- Color reset after text
Git Integration
The git feature displays your current branch name with automatic detection of git repositories.Features
Branch Detection
Automatically detects and displays current git branch
Fallback to SHA
Shows short commit SHA in detached HEAD state
Safe Execution
Gracefully handles non-git directories
Performance
Minimal overhead with fast git commands
Configuration
Fromcli/prompts.ts:26:
Implementation
Fromfeatures/git.ts:21-25:
How the git detection works
How the git detection works
- Check if in git repo:
git rev-parse --git-dir >/dev/null 2>&1- Silently checks for
.gitdirectory - Returns exit code 0 if in a git repository
- Silently checks for
- Get branch name:
git branch --show-current- Gets the current branch name (e.g.,
main,feature/new-feature) - Fails in detached HEAD state
- Gets the current branch name (e.g.,
- Fallback to commit SHA:
git rev-parse --short HEAD- If branch detection fails, show short commit hash
- Useful in detached HEAD state or CI/CD environments
Display Code
Fromfeatures/git.ts:28-39:
- πΏ branch emoji (or
git:prefix if emojis disabled) - Soft green color (ANSI 38;5;150)
- Only shown if branch was detected
Example Outputs
Color Customization
Fromfeatures/git.ts:11-18:
Colors respect the
NO_COLOR environment variable. Set NO_COLOR=1 to disable all colors.Requirements
| Feature | Requirement | Fallback Behavior |
|---|---|---|
| Directory | None (always works) | Shows βunknownβ if extraction fails |
| Git Branch | git installed | Branch not displayed if git unavailable |
| Colors | Terminal with ANSI support | Plain text if colors disabled |
Performance Notes
Both features are extremely lightweight:- Directory: Simple string extraction and replacement (~1ms)
- Git: Single git command with short-circuit logic (~5-15ms)
- Total overhead: Less than 20ms combined
Git commands are only executed if the repository check succeeds, minimizing overhead in non-git directories.
Troubleshooting
Directory shows 'unknown'
Directory shows 'unknown'
This can happen if:
- Claude Code JSON format has changed
- jq is not installed (install jq for more reliable parsing)
- Thereβs an issue with the workspace path
Git branch not showing
Git branch not showing
Check if:
- Youβre in a git repository:
git status - Git is installed:
git --version - The script has execute permissions:
chmod +x .claude/statusline.sh
git init or ensure git is in your PATH.Windows path issues
Windows path issues
Windows paths with backslashes are automatically converted to forward slashes:This is handled by the sed replacement in the bash fallback parser.
Next Steps
Context Tracking
Monitor your context window usage
Customization
Customize colors and themes