Skip to content

Zai/statusline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Claude Code Statusline

A customizable and modular statusline for Claude Code based on a configurable plugin system. Display the information you care about: directory, Git branch, Node version, Claude Code tokens, and more!

Features

  • πŸ”Œ Dynamic plugin system: Plugins loaded on-demand from config
  • βš™οΈ JSON configuration: Easy customization via config.json
  • πŸš€ Zero-config required: Works out-of-the-box with sensible defaults
  • πŸ“ Directory Plugin: Displays current directory
  • πŸ”€ Git Plugin: Shows branch and modification status
  • β¬’ Node Version Plugin: Displays Node.js version
  • πŸ”΅ Claude Tokens Plugin: Shows token usage (count + percentage)
  • πŸ€– Claude Version Plugin: Displays Claude Code version
  • 🎨 ANSI colors for elegant display
  • ⚑ Written in TypeScript with fast execution
  • πŸ”„ Automatic updates in Claude Code
  • ❌ Visible error handling: Failed plugins show as ❌ plugin-name

Prerequisites

  • Node.js (version 18+)
  • pnpm
  • Git
  • Claude Code

Installation

  1. Clone or copy this project to your working directory

  2. Install dependencies:

pnpm install
  1. Compile the TypeScript project:
pnpm build

This will generate JavaScript files in the dist/ folder.

  1. Configure Claude Code to use this statusline by creating or modifying .claude/settings.json:
{
  "statusLine": {
    "type": "command",
    "command": "node dist/index.js",
    "padding": 0
  }
}

Or with absolute path:

{
  "statusLine": {
    "type": "command",
    "command": "node /path/to/statusline/dist/index.js",
    "padding": 0
  }
}

Plugin Configuration

The statusline uses a dynamic plugin system where plugins are loaded on-demand:

  1. Default configuration: Each plugin loads its own default.json with default values
  2. User configuration: Optional config.json file at project root to enable/customize plugins
  3. Dynamic loading: Only plugins listed in config.json are loaded into memory
  4. Automatic merging: Plugins merge their defaults with user overrides

You don't need to create config.json to use the statusline - it works out-of-the-box!

Quick Start

Create a config.json at the project root:

{
  "separator": " | ",
  "plugins": [
    { "name": "directory" },
    { "name": "git" },
    { "name": "node-version" },
    { "name": "claude-tokens" },
    { "name": "claude-version" }
  ]
}

How it works:

  • Plugin order = array position (first in array = first displayed)
  • Enabled plugins = plugins present in the array
  • Disabled plugins = simply omit them from the array

Customizing Plugins

Override any plugin setting by adding fields:

{
  "plugins": [
    {
      "name": "directory",
      "prefix": "πŸ“‚",
      "options": { "showFullPath": true }
    },
    {
      "name": "git",
      "color": "cyan",
      "options": { "dirtyColor": "red" }
    }
  ]
}

Global options:

  • separator (string): Text displayed between plugins (default: " ")

Per-plugin options:

  • name (required): Plugin name
  • prefix: Custom prefix
  • color: Text color ("blue", "green", "cyan", "yellow", "magenta", "red", "gray")
  • options: Plugin-specific options (see plugin docs)

How Dynamic Loading Works

The plugin system is fully dynamic:

  1. Load config: System reads config.json to see which plugins are needed
  2. Dynamic import: Only listed plugins are loaded via import()
  3. Merge config: Plugin loads its default.json and merges with user config
  4. Execute: Plugin runs its logic and returns results
  5. Error handling: If a plugin fails to load, ❌ plugin-name appears in statusline

Example:

Plugin's default (from src/plugins/directory/default.json):

{
  "name": "directory",
  "prefix": "πŸ“",
  "color": "blue",
  "options": { "showFullPath": false }
}

Your override (in root config.json):

{
  "name": "directory",
  "prefix": "πŸ“‚",
  "options": { "showFullPath": true }
}

Result after merge:

{
  "name": "directory",
  "prefix": "πŸ“‚",           ← overridden
  "color": "blue",        ← kept from default
  "options": { "showFullPath": true }  ← overridden
}

Available Plugins

πŸ“ Directory

Displays the current directory name or full path.

πŸ”€ Git

Shows Git branch and modification statistics (file count + line changes).

β¬’ Node Version

Displays the current Node.js version.

πŸ”΅ Claude Tokens

Shows Claude Code token usage with count and percentage.

πŸ€– Claude Version

Displays the current Claude Code version.

Creating Custom Plugins

Want to create your own plugin? See the Plugin Development Guide for detailed instructions.

Key benefits of the dynamic system:

  • πŸš€ No registration needed: Just drop your plugin in src/plugins/ folder
  • πŸ“ Add to config: Enable it by adding to config.json
  • πŸ”„ Hot-swappable: Change plugin list without touching source code
  • ❌ Error-safe: Invalid plugins show ❌ without crashing

Enabling/Disabling Plugins

To enable a plugin: Add it to the plugins array in your config.json

To disable a plugin: Simply remove it from the array (or don't include it)

Example - only directory and git:

{
  "plugins": [{ "name": "directory" }, { "name": "git" }]
}

Changing Plugin Order

The order in the plugins array determines display order:

{
  "plugins": [
    { "name": "git" }, // First
    { "name": "directory" } // Second
  ]
}

Result: main πŸ“ statusline

Rendering Examples

Default configuration (all plugins enabled)

πŸ“ statusline main β¬’ 18.0.0 πŸ”΅ 59.1k/200k (29.6%)

Directory without Git

πŸ“ my-project β¬’ 18.0.0 πŸ”΅ 45.2k/200k (22.6%)

Directory with Git (no modifications)

πŸ“ my-project main β¬’ 18.0.0 πŸ”΅ 59.1k/200k (29.6%)

Directory with Git (uncommitted modifications)

πŸ“ my-project main !3 +45/-12 β¬’ 18.0.0 πŸ”΅ 59.1k/200k (29.6%)

(3 modified files, 45 lines added, 12 lines deleted)

Minimal configuration (directory + git only)

πŸ“ statusline main !3 +45/-12

Custom configuration with separator

With this configuration:

{
  "separator": " | ",
  "plugins": [
    { "name": "directory" },
    { "name": "git" },
    { "name": "claude-tokens", "options": { "showCount": false } }
  ]
}

Result:

πŸ“ statusline | main !3 +45/-12 | πŸ”΅ 29.6%

Color Preview

In your terminal, the statusline will appear with the following colors:

  • Directory: Bright blue with πŸ“ prefix
  • Git branch: Green (configurable with color)
  • Git modifications: Yellow !N +X/-Y format (configurable with dirtyColor)
  • Node version: Green with β¬’ prefix
  • Claude tokens: Cyan with πŸ”΅ prefix

All colors are customizable per-plugin in your config.json.

Project Structure

statusline/
β”œβ”€β”€ .claude/
β”‚   └── settings.json              # Claude Code configuration
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── plugin.ts              # Plugin interfaces and types
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ constant.ts            # ANSI color constants
β”‚   β”‚   β”œβ”€β”€ merge.ts               # Deep merge utility
β”‚   β”‚   └── plugin-manager.ts      # Plugin manager
β”‚   β”œβ”€β”€ plugins/
β”‚   β”‚   β”œβ”€β”€ README.md              # πŸ“– Plugin Development Guide
β”‚   β”‚   β”œβ”€β”€ directory/
β”‚   β”‚   β”‚   β”œβ”€β”€ README.md          # πŸ“– Directory plugin documentation
β”‚   β”‚   β”‚   β”œβ”€β”€ default.json       # ⭐ Default configuration
β”‚   β”‚   β”‚   └── index.ts           # Directory plugin
β”‚   β”‚   β”œβ”€β”€ git/
β”‚   β”‚   β”‚   β”œβ”€β”€ README.md          # πŸ“– Git plugin documentation
β”‚   β”‚   β”‚   β”œβ”€β”€ default.json       # ⭐ Default configuration
β”‚   β”‚   β”‚   └── index.ts           # Git plugin
β”‚   β”‚   β”œβ”€β”€ node-version/
β”‚   β”‚   β”‚   β”œβ”€β”€ README.md          # πŸ“– Node version plugin documentation
β”‚   β”‚   β”‚   β”œβ”€β”€ default.json       # ⭐ Default configuration
β”‚   β”‚   β”‚   └── index.ts           # Node version plugin
β”‚   β”‚   β”œβ”€β”€ claude-tokens/
β”‚   β”‚   β”‚   β”œβ”€β”€ README.md          # πŸ“– Claude tokens plugin documentation
β”‚   β”‚   β”‚   β”œβ”€β”€ default.json       # ⭐ Default configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts           # Claude tokens plugin
β”‚   β”‚   β”‚   └── transcript-parser.ts  # Transcript parsing utility
β”‚   β”‚   └── claude-version/
β”‚   β”‚       β”œβ”€β”€ README.md          # πŸ“– Claude version plugin documentation
β”‚   β”‚       β”œβ”€β”€ default.json       # ⭐ Default configuration
β”‚   β”‚       └── index.ts           # Claude version plugin
β”‚   └── index.ts                   # Main entry point
β”œβ”€β”€ dist/                          # Compiled JavaScript files (generated by pnpm build)
β”‚   β”œβ”€β”€ types/
β”‚   β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ plugins/
β”‚   β”‚   β”œβ”€β”€ directory/
β”‚   β”‚   β”‚   └── default.json       # ⭐ Default config (copied)
β”‚   β”‚   β”œβ”€β”€ git/
β”‚   β”‚   β”‚   └── default.json       # ⭐ Default config (copied)
β”‚   β”‚   β”œβ”€β”€ node-version/
β”‚   β”‚   β”‚   └── default.json       # ⭐ Default config (copied)
β”‚   β”‚   β”œβ”€β”€ claude-tokens/
β”‚   β”‚   β”‚   └── default.json       # ⭐ Default config (copied)
β”‚   β”‚   └── claude-version/
β”‚   β”‚       └── default.json       # ⭐ Default config (copied)
β”‚   └── index.js
β”œβ”€β”€ config.json                    # User configuration (optional - for overrides)
β”œβ”€β”€ config.json.example            # Customization examples
β”œβ”€β”€ LICENSE                        # MIT License
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

Development

Available Scripts

  • pnpm dev: Run statusline in development mode (via tsx)
  • pnpm build: Compile TypeScript to JavaScript
  • pnpm watch: Compile in watch mode

Testing the Statusline Locally

In production (with compiled files):

After compiling with pnpm build, test with:

echo '{"workspace":{"current_dir":"'$(pwd)'"}}' | node dist/index.js

Or with a specific directory:

echo '{"workspace":{"current_dir":"/path/to/project"}}' | node dist/index.js

In development (without compilation):

To test quickly without compiling:

echo '{"workspace":{"current_dir":"'$(pwd)'"}}' | pnpm dev

Development Mode

To develop and test quickly, you have two options:

Option 1: Watch mode (recommended)

  1. Start watch mode for automatic TypeScript compilation:
pnpm watch
  1. In another terminal, test with the compiled version:
echo '{"workspace":{"current_dir":"'$(pwd)'"}}' | node dist/index.js

Option 2: Use tsx directly

Test directly without compilation:

echo '{"workspace":{"current_dir":"'$(pwd)'"}}' | pnpm dev

Note: Don't forget to rebuild (pnpm build) before committing or using the statusline in production with Claude Code.

Customization

Modifying Colors

Edit the src/lib/constant.ts file to customize ANSI colors:

export const colors = {
  reset: "\x1b[0m",
  bright: "\x1b[1m",
  cyan: "\x1b[36m",
  blue: "\x1b[34m",
  green: "\x1b[32m",
  yellow: "\x1b[33m",
  // Add your own colors
} as const;

Creating a Custom Plugin

Creating your own plugin is straightforward with the dynamic loading system!

For detailed step-by-step instructions, see the Plugin Development Guide.

Quick overview:

  1. Create src/plugins/my-plugin/default.json with defaults
  2. Create src/plugins/my-plugin/index.ts with your plugin logic using export default
  3. Add { "name": "my-plugin" } to your config.json
  4. Done! The plugin is automatically loaded ✨

No manual registration needed - the system dynamically loads plugins from the config!

See the guide for complete examples and best practices!

Available Prefixes

Some prefix ideas to use:

  • πŸ“ Folder
  • πŸ”€ Git branch
  • ✨ Clean
  • ⚠️ Warning
  • πŸš€ Rocket
  • πŸ’» Code
  • 🎯 Target

Input Format

The statusline receives a JSON object via stdin from Claude Code:

interface ClaudeCodeInput {
  yolo;
  workspace?: {
    current_dir?: string;
  };
  model?: {
    display_name?: string;
  };
}

You can extend the interface to use other information provided by Claude Code.

Troubleshooting

Statusline doesn't appear

  • Check that .claude/settings.json file exists and is properly configured
  • Make sure you've compiled the project: pnpm build
  • Verify that dist/ folder exists and contains index.js
  • Test the statusline manually to see errors: echo '{}' | node dist/index.js

Colors don't display

  • Check that your terminal supports ANSI codes
  • Some terminals require specific configurations for colors

"Cannot find module" error

  • Make sure you've compiled the project: pnpm build
  • Check that all files are present in dist/
  • Reinstall dependencies: pnpm install

Changes are not applied

  • Don't forget to recompile after each modification: pnpm build
  • Or use watch mode during development: pnpm watch

Technologies Used

  • TypeScript: Main language
  • Node.js: Runtime for production execution
  • tsx: Development tool for testing without compilation
  • pnpm: Package manager
  • Git: Git integration to display branch

License

MIT

Author

Created for Claude Code

About

A customizable and modular statusline for Claude Code based on a configurable plugin system.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors