🖥️ Cross-Platform: Supports different hotkeys for Windows, Linux, and macOS.
⚙️ Configurable: Customize the API endpoint, model, and other settings.
How to Use
Method 1: Hotkey + Selected Text (Recommended)
Type a comment in the terminal or any file:
# Compress the /root/test directory into a tar file
Select this line of text.
Press the hotkey:
Windows/Linux: Ctrl + Shift + X
macOS: Cmd + Shift + X
The AI will generate the corresponding command in the terminal:
tar -cvf /root/test.tar /root/test
Method 2: Hotkey + Manual Input
Press the hotkey without any selected text or clipboard content.
Enter a description of the command in the input box that appears.
The AI will generate the corresponding command.
Method 3: Command Palette
Press Cmd + Shift + P (macOS) or Ctrl + Shift + P (Windows/Linux).
Type "TerminalCommandAI: Generate Terminal Command".
Describe the command you want to generate in the input box.
Configuration
Configure the following options in your VSCode settings:
terminalCommandAI.apiEndpoint: The API endpoint for the LLM service (Default: OpenAI).
terminalCommandAI.modelName: The name of the model to use (Default: gpt-4o-mini).
terminalCommandAI.apiKey: Your API key.
terminalCommandAI.quickGenerateKeybinding: Customize the quick generation hotkey (Default: ctrl+x).
Available options: ctrl+shift+x, ctrl+x, ctrl+shift+g, ctrl+alt+x.
terminalCommandAI.terminalPreference: Choose your preferred terminal language/shell.
Pro Tips
Comment Format: Text starting with # is recognized as a command description.
Multi-language Support: Works well with descriptions in any language, e.g., "# 压缩文件夹".
Complex Commands: Describe complex operations, and the AI will generate the corresponding command pipelines.
Terminal Focus: Ensure the terminal window is active when using the hotkey.
Examples
# Find all .js files in the current directory
# Result: find . -name "*.js" -type f
# Create a new git branch and switch to it
# Result: git checkout -b new-branch-name
# Compress the entire project directory, excluding node_modules
# Result: tar --exclude='node_modules' -czf project.tar.gz .
# Check which process is using port 8080
# Result: lsof -i :8080
Troubleshooting
Hotkey Not Working: Make sure the terminal window is in focus.
API Error: Check your API key and endpoint configuration in the settings.
No Command Generated: Ensure your description is clear and specific.
Permission Issues: Some commands may require sudo privileges to run.
Disclaimer
The generated commands are for reference only. Please review them carefully before execution.
Use commands that modify system-critical files with extreme caution.
API calls may incur costs from your provider. Please monitor your usage.