claude-statusline-powerline
Version:
Beautiful powerline-style statusline for Claude Code with git integration, session tracking, and cost monitoring
121 lines • 4.85 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("node:fs"));
const os = __importStar(require("node:os"));
const path = __importStar(require("node:path"));
const CLAUDE_SETTINGS_DIR = path.join(os.homedir(), '.claude');
const CLAUDE_SETTINGS_FILE = path.join(CLAUDE_SETTINGS_DIR, 'settings.json');
const STATUSLINE_CONFIG_FILE = path.join(CLAUDE_SETTINGS_DIR, 'claude-statusline-powerline.json');
function ensure_claude_dir() {
if (!fs.existsSync(CLAUDE_SETTINGS_DIR)) {
fs.mkdirSync(CLAUDE_SETTINGS_DIR, { recursive: true });
console.log(`✅ Created .claude directory at ${CLAUDE_SETTINGS_DIR}`);
}
}
function get_statusline_command() {
// Use the direct binary name - works regardless of package manager
return 'claude-statusline-powerline';
}
function create_default_config() {
// Create default statusline config if it doesn't exist
if (!fs.existsSync(STATUSLINE_CONFIG_FILE)) {
const default_config = {
$schema: 'https://raw.githubusercontent.com/spences10/claude-statusline-powerline/main/statusline.schema.json',
color_theme: 'dark',
segment_config: {
segments: [
{
type: 'model',
},
{
type: 'directory',
},
{
type: 'git',
},
],
},
};
fs.writeFileSync(STATUSLINE_CONFIG_FILE, JSON.stringify(default_config, null, 2));
console.log(`✅ Created default config at ${STATUSLINE_CONFIG_FILE}`);
}
}
function update_settings() {
const statusline_command = get_statusline_command();
let settings = {};
// Read existing settings if they exist
if (fs.existsSync(CLAUDE_SETTINGS_FILE)) {
try {
const settings_content = fs.readFileSync(CLAUDE_SETTINGS_FILE, 'utf8');
settings = JSON.parse(settings_content);
}
catch (error) {
console.warn('⚠️ Could not parse existing settings.json, creating new one');
}
}
// Update statusLine configuration
settings.statusLine = {
type: 'command',
command: statusline_command,
};
// Write updated settings
fs.writeFileSync(CLAUDE_SETTINGS_FILE, JSON.stringify(settings, null, 2));
console.log(`✅ Updated Claude settings at ${CLAUDE_SETTINGS_FILE}`);
console.log(`📊 Statusline configured to use: ${statusline_command}`);
}
function main() {
console.log('🚀 Installing claude-statusline-powerline...\n');
try {
ensure_claude_dir();
create_default_config();
update_settings();
console.log('\n🎉 Installation complete!');
console.log('💡 Your Claude Code statusline should now show:');
console.log(' 📱 Model name 📁 Directory 🌿 Git branch & status');
console.log('💰 Add "session" and "usage" segments to your config to track token usage and costs');
console.log('\n🔄 Restart Claude Code to see the changes.');
console.log(`🎨 Edit ${STATUSLINE_CONFIG_FILE} to customize your statusline`);
}
catch (error) {
console.error('❌ Installation failed:', error);
process.exit(1);
}
}
if (require.main === module) {
main();
}
//# sourceMappingURL=install.js.map