clitutor
Version:
Interactive CLI learning tool for beginners
177 lines (166 loc) • 6.28 kB
JavaScript
const chalk = require('chalk');
const boxen = require('boxen');
const green = chalk.hex('#00FF00');
const cyan = chalk.cyan;
const yellow = chalk.yellow;
const magenta = chalk.magenta;
const blue = chalk.blue;
const dim = chalk.dim;
const bold = chalk.bold;
function showMemo() {
console.clear();
console.log(
boxen(
green.bold('🎯 CLITUTOR COMMAND MEMO') + '\n' +
dim('Your quick reference for terminal commands'),
{
padding: 1,
margin: 1,
borderStyle: 'double',
borderColor: 'green'
}
)
);
// Terminal Navigation
console.log(
boxen(
cyan.bold('⌨️ TERMINAL NAVIGATION\n\n') +
bold('Cursor Movement:\n') +
' Ctrl+A ' + dim('→ Jump to line start\n') +
' Ctrl+E ' + dim('→ Jump to line end\n') +
' Ctrl+←/→ ' + dim('→ Jump word by word\n') +
' ↑/↓ ' + dim('→ Browse command history\n\n') +
bold('Text Editing:\n') +
' Ctrl+W ' + dim('→ Delete word backward\n') +
' Ctrl+U ' + dim('→ Delete to line start\n') +
' Ctrl+K ' + dim('→ Delete to line end\n') +
' Ctrl+Y ' + dim('→ Paste deleted text\n\n') +
bold('Screen Control:\n') +
' Ctrl+L ' + dim('→ Clear screen\n') +
' Ctrl+C ' + dim('→ Cancel current command\n') +
' Ctrl+D ' + dim('→ Exit terminal\n') +
' Tab ' + dim('→ Auto-complete'),
{
padding: 1,
margin: { top: 1 },
borderColor: 'cyan'
}
)
);
// File & Directory Navigation
console.log(
boxen(
yellow.bold('📁 FILE & DIRECTORY NAVIGATION\n\n') +
bold('Where Am I?\n') +
' pwd ' + dim('→ Print working directory\n\n') +
bold('List & Explore:\n') +
' ls ' + dim('→ List files\n') +
' ls -la ' + dim('→ List all files (detailed)\n') +
' ls -lh ' + dim('→ Human-readable sizes\n\n') +
bold('Move Around:\n') +
' cd [dir] ' + dim('→ Change directory\n') +
' cd .. ' + dim('→ Go up one level\n') +
' cd ~ ' + dim('→ Go to home directory\n') +
' cd - ' + dim('→ Go to previous directory\n\n') +
bold('Create & Delete:\n') +
' mkdir ' + dim('→ Create directory\n') +
' touch ' + dim('→ Create empty file\n') +
' rm ' + dim('→ Remove file\n') +
' rm -r ' + dim('→ Remove directory\n') +
' cp ' + dim('→ Copy file/directory\n') +
' mv ' + dim('→ Move/rename\n\n') +
bold('View Files:\n') +
' cat ' + dim('→ Display file content\n') +
' less ' + dim('→ View file (scrollable)\n') +
' head -n ' + dim('→ Show first n lines\n') +
' tail -n ' + dim('→ Show last n lines'),
{
padding: 1,
margin: { top: 1 },
borderColor: 'yellow'
}
)
);
// Git Reference
console.log(
boxen(
magenta.bold('🔄 GIT VERSION CONTROL\n\n') +
'For comprehensive Git commands, use:\n\n' +
bold(' clitutor git') + '\n\n' +
'This includes:\n' +
' • Basic workflow (init, add, commit)\n' +
' • Branching and merging\n' +
' • Remote operations\n' +
' • Stashing and recovery\n' +
' • Advanced techniques\n' +
' • Pro tips and aliases\n\n' +
dim('Git deserves its own reference! 🚀'),
{
padding: 1,
margin: { top: 1 },
borderColor: 'magenta'
}
)
);
// Useful Utilities
console.log(
boxen(
blue.bold('🛠️ USEFUL UTILITIES\n\n') +
bold('Search & Find:\n') +
' grep "text" file ' + dim('→ Search in file\n') +
' grep -r "text" . ' + dim('→ Search recursively\n') +
' find . -name "*.js" ' + dim('→ Find files by name\n\n') +
bold('Process Management:\n') +
' ps aux ' + dim('→ List all processes\n') +
' kill [PID] ' + dim('→ Terminate process\n') +
' Ctrl+Z ' + dim('→ Suspend process\n') +
' jobs ' + dim('→ List background jobs\n') +
' fg ' + dim('→ Resume foreground\n\n') +
bold('System Info:\n') +
' whoami ' + dim('→ Current username\n') +
' which [command] ' + dim('→ Command location\n') +
' history ' + dim('→ Command history\n') +
' df -h ' + dim('→ Disk usage\n') +
' du -sh ' + dim('→ Directory size\n\n') +
bold('File Permissions:\n') +
' chmod +x file ' + dim('→ Make executable\n') +
' chmod 755 file ' + dim('→ Set permissions\n') +
' chown user:group ' + dim('→ Change ownership'),
{
padding: 1,
margin: { top: 1 },
borderColor: 'blue'
}
)
);
// Pro Tips
console.log(
boxen(
green.bold('💡 PRO TIPS\n\n') +
'• Use ' + bold('Tab') + ' extensively for auto-completion\n' +
'• Press ' + bold('↑') + ' to recall previous commands\n' +
'• Use ' + bold('!!') + ' to repeat last command\n' +
'• Use ' + bold('!$') + ' for last command\'s last argument\n' +
'• Combine commands with ' + bold('&&') + ' (run if success)\n' +
'• Pipe output with ' + bold('|') + ' (e.g., ls | grep ".js")\n' +
'• Redirect output with ' + bold('>') + ' and ' + bold('>>') + '\n' +
'• Use ' + bold('man [command]') + ' for detailed help\n' +
'• Create aliases for common commands\n' +
'• Use ' + bold('Ctrl+R') + ' to search command history\n\n' +
dim('Remember: Practice makes perfect! 🚀'),
{
padding: 1,
margin: { top: 1 },
borderColor: 'green',
borderStyle: 'round'
}
)
);
console.log('\n' + dim('Exit memo with Ctrl+C or keep it open for reference!\n'));
// Handle graceful exit
process.on('SIGINT', () => {
console.log('\n' + green('Thanks for using clitutor memo! 📚\n'));
process.exit(0);
});
}
module.exports = { showMemo };