Generate and run bash commands from natural language descriptions using a local LLM via Ollama.
Describe what you want to do in plain English, and gcmd will generate the appropriate bash command, show you what it does, and let you run it or refine it. Other tools exist like this, but this one is fully designed for local Ollama models.
gcmd find all pdf files larger than 10MB in my home directory- Install dependencies:
pip install ollama questionary rich- Install Ollama and pull your preferred model (default:
llama3.2:3b):
ollama pull llama3.2:3b- Install globally (optional but recommended):
chmod +x gcmd.py
sudo ln -s "$(pwd)/gcmd.py" /usr/local/bin/gcmdOn first run, a config file is created at ~/.config/gcmd/config.json:
{
"model": "llama3.2:3b"
}Edit this file to use a different Ollama model.
gcmd <describe your task>After the command is generated, you can:
- Run - execute the command in your shell
- Refine - add more context to get a better command
- Cancel - exit without running
