@lenne.tech/cli
Version:
lenne.Tech CLI: lt
122 lines (121 loc) • 4.83 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const shell_config_1 = require("../../lib/shell-config");
/**
* Claude Code shortcuts (shell aliases)
* See: https://docs.lennetech.app/claude-code/installation
*/
const CLAUDE_SHORTCUTS = [
{
alias: 'c',
command: 'claude --dangerously-skip-permissions',
description: 'Start new Claude Code session',
},
{
alias: 'cc',
command: 'claude --dangerously-skip-permissions --continue',
description: 'Continue last session',
},
{
alias: 'cr',
command: 'claude --dangerously-skip-permissions --resume',
description: 'Select and resume previous session',
},
{
alias: 'cf',
command: 'LT_PLUGIN_HOOKS_SKIP=1 claude --dangerously-skip-permissions',
description: 'Start Claude Code in fast mode (skip lenne.tech plugin detect hooks)',
},
];
/**
* Install Claude Code shell shortcuts
*/
const ShortcutsCommand = {
alias: ['s'],
description: 'Install shell shortcuts',
name: 'shortcuts',
run: (toolbox) => __awaiter(void 0, void 0, void 0, function* () {
const { print: { error, info, success }, } = toolbox;
// Get preferred shell config
const shellConfig = (0, shell_config_1.getPreferredShellConfig)();
if (!shellConfig) {
error('Could not detect shell configuration file.');
info('Supported shells: zsh, bash');
if (!toolbox.parameters.options.fromGluegunMenu) {
process.exit(1);
}
return 'shortcuts: no shell config found';
}
info(`Shell: ${shellConfig.shell}`);
info(`Config: ${shellConfig.path}`);
info('');
// Check which shortcuts are already installed
const existingAliases = [];
const missingAliases = [];
for (const shortcut of CLAUDE_SHORTCUTS) {
if ((0, shell_config_1.checkAliasInFile)(shellConfig.path, shortcut.alias)) {
existingAliases.push(shortcut);
}
else {
missingAliases.push(shortcut);
}
}
// Show status
if (existingAliases.length > 0) {
info('Already installed:');
for (const { alias, description } of existingAliases) {
info(` ${alias} - ${description}`);
}
info('');
}
if (missingAliases.length === 0) {
success('All Claude Code shortcuts are already installed!');
info('');
info('Available shortcuts:');
for (const { alias, command, description } of CLAUDE_SHORTCUTS) {
info(` ${alias} - ${description}`);
info(` ${command}`);
}
if (!toolbox.parameters.options.fromGluegunMenu) {
process.exit(0);
}
return 'shortcuts: already installed';
}
// Add missing aliases
const added = (0, shell_config_1.addAliasBlockToShellConfig)(shellConfig.path, missingAliases);
if (added) {
info('');
success(`Added ${missingAliases.length} shortcut${missingAliases.length > 1 ? 's' : ''} to ${shellConfig.path}`);
info('');
info(`Run: source ${shellConfig.path}`);
info('Or restart your terminal to apply changes.');
}
else {
error(`Failed to write to ${shellConfig.path}`);
info('');
info('To add manually, add these lines to your shell config:');
info('');
for (const { alias, command } of missingAliases) {
info(`alias ${alias}='${command}'`);
}
if (!toolbox.parameters.options.fromGluegunMenu) {
process.exit(1);
}
return 'shortcuts: write failed';
}
if (!toolbox.parameters.options.fromGluegunMenu) {
process.exit(0);
}
return `shortcuts: ${missingAliases.length} added`;
}),
};
exports.default = ShortcutsCommand;