@tuncayk/nlc v1.0.0
NLC (Natural Language Commands)
Convert plain English into CLI commands! NLC is your command-line companion that translates natural language into actual shell commands. Perfect for when you know what you want to do but don't remember the exact command syntax.
✨ Features
- 🗣️ Natural language to CLI command translation
- 🤖 Optional command auto-detection
- 📁 File path auto-completion support
- 🎨 Colorful command explanations
- 🤖 Multiple AI providers support (OpenAI, Groq, Deepseek)
- ⚡ Interactive command preview and execution
- 🔍 Detailed parameter explanations
🎯 Example Usage
You can use NLC in two ways:
1. Auto-detect the command:
nlc "remove audio from video.mp4"
nlc "show me python files modified today"
nlc "show size of current directory"
nlc "show me what changed last week in git"
2. Specify the command (for more precise control):
nlc ffmpeg "remove audio from video.mp4"
nlc find "show me python files modified today"
nlc du "show size of current directory"
nlc git "show me what changed last week"
Both approaches will work! Use auto-detection when you're unsure which command to use, or specify the command when you want more control.
🚀 Installation
Requirements
- Node.js >= 16
- Currently tested only on macOS. Windows and Linux support is experimental.
- For Windows users: Consider using Git Bash or WSL for better compatibility
Option 1: Install from npm (Recommended)
# Install globally
npm install -g @tkaplan/nlc
# Or use with npx (no installation needed)
npx @tkaplan/nlc ffmpeg "remove audio from video.mp4"
Option 2: Clone and Install
# Clone the repository
git clone https://github.com/yourusername/nlc-tool
cd nlc-tool
# Install dependencies
npm install
# Make the CLI executable
chmod +x ./index.js
# Create a global symlink (optional)
npm link
Option 3: Share the Script Directly
If you want to share the script with friends who might not want to install from npm:
Send them these files:
index.js
package.json
They should then:
# Create a new directory
mkdir nlc && cd nlc
# Copy the files into the directory
# Then install and make executable
npm install
chmod +x ./index.js
# Optional: Add to PATH
echo "export PATH=\$PATH:$(pwd)" >> ~/.zshrc # for zsh
# or
echo "export PATH=\$PATH:$(pwd)" >> ~/.bashrc # for bash
source ~/.zshrc # or ~/.bashrc
⚠️ Platform-Specific Notes
macOS
- Fully tested and supported
- All core features work out of the box
Linux (Experimental)
- Basic functionality should work
- Some commands might need adjustments for different distributions
- Command paths might vary between distributions
Windows (Experimental)
- Best used with Git Bash or WSL
- Native Windows CMD/PowerShell might have limited compatibility
- Some Unix-style commands might not be available by default
⚙️ Configuration
Set up your preferred AI provider by setting one of these environment variables in your shell profile (~/.zshrc or ~/.bashrc):
# Choose ONE of these providers:
# Option 1: OpenAI (Recommended)
export OPENAI_API_KEY=your_openai_key
# Option 2: Groq
export GROQ_API_KEY=your_groq_key
# Option 3: Deepseek
export DEEPSEEK_API_KEY=your_deepseek_key
After adding the environment variable:
source ~/.zshrc # or ~/.bashrc
💡 How It Works
You type your command in plain English:
nlc ffmpeg "convert video.mp4 to 720p resolution and reduce file size"
NLC processes your request using this structured prompt:
{ "command": "the complete command string", "parts": [ { "value": "part of the command", "type": "command|flag|path|parameter", "explanation": "detailed explanation of what this part does" } ] }
NLC shows a detailed, colored preview:
Command Preview: ffmpeg -i video.mp4 -vf scale=-1:720 -crf 23 output.mp4 Explanation: ffmpeg - Video/audio processing tool -i - Input file flag video.mp4 - Source video file -vf - Video filter flag scale=-1:720 - Set height to 720p, auto width -crf - Quality control (0-51) 23 - Balanced quality/size value output.mp4 - Output file Press Enter to execute...
Press Enter to run the command!
🛠️ Supported Commands
NLC can help with any CLI command, but has special understanding of:
- ffmpeg/avconv (video processing)
- find/ls/grep (file operations)
- git (version control)
- docker (container operations)
- tar/zip (compression)
- curl/wget (downloads)
- and many more!
📦 Dependencies
- chalk: For beautiful terminal styling
- commander: CLI framework
- figlet: ASCII art headers
- inquirer: Interactive prompts
- openai: AI provider client
🤝 Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
📝 License
MIT
🐛 Troubleshooting
- Command not found: Make sure the tool is properly installed and in your PATH
- Permission denied: Run
chmod +x ./index.js
- API key error: Make sure you've set up one of the API keys in your shell profile
- Node version error: Make sure you have Node.js >= 18.0.0 installed
🌟 Share with Friends
The easiest way to share with friends is to tell them to install via npm:
npm install -g @tkaplan/nlc
Then they just need to: 1. Get an API key from OpenAI, Groq, or Deepseek 2. Add it to their shell profile 3. Start using natural language commands!
For more installation options, see the Installation section above.
6 months ago