gencmd

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 3 Imported by: 0

README

gencmd

Build Go Report Card

gencmd is an interactive command line utility to generate bash commands from a natural language description, directly from the console.

asciicast

Ever went to ChatGPT after struggling some time with man awk, or with questions like "was it curl or wget with -O"? Well, save some time and ask directly from the terminal. Think of this as the fzf for natural language to bash commands.

Why?

There are many alternative tools for this task, but none did all I wanted:

  • Simple to install and configure (i.e. single binary, no dependencies).
  • Work interactively in the terminal, but require minimal typing.
  • Fast.
  • Do not run commands for me, but suggest alternatives.
  • Paste the result directly in the terminal (without me having to do it).
  • Have built-in history for both commands and prompts.
  • Open source, no sign-up required, no strings attached.

This project is minimal but provides all of the above.

Installation

Head over to the latest release, and download a binary appropriate for your system.

Make it executable and put it somewhere in $PATH:

chmod a+x gencmd
sudo mv gencmd /usr/local/bin

If you want to set up key bindings (default is Ctrl + G), add this to your .bashrc:

source ~/.config/gencmd/key-bindings.bash

or use key-bindings.zsh for .zshrc.

API Keys

Initialize with:

gencmd init

The instructions will guide you through setting up an AI model provider. The currently supported providers are OpenAI, Gemini, Anthropic, and Ollama.

The easiest to get started is to get a free API key from Google AI Studio. Follow the instructions there and once you have the key, paste it into the interactive prompt.

For local models, you can use Ollama. First install Ollama and pull a model (e.g., ollama pull gemma-3), then configure gencmd to use it.

Credentials are stored locally, and NEVER sent anywhere else.

[!NOTE] By default, gencmd uses "gemini-2.0-flash-lite", which has a generous free tier of 200 requests per day. More than enough for typical usage. If you want to make sure to block requests over the free tier, use a dedicated GCP project without billing enabled.

[!TIP] If you just want to test how gencmd looks without configuring it, you can try the demo (returning fake history and commands) with gencmd demo.

Usage

Think of this as fzf for natural language to bash commands. Open a new terminal and press Ctrl + G. As you type your query, gencmd will filter your recent history, so you can either select something from there, or submit a new prompt.

In case the prompt is new, your configured LLM will be invoked to generate a few alternative commands to solve your intended usage.

You can navigate history and completions with keyboard arrows ↑ ↓, or Ctrl + J and Ctrl + K.

The result is not executed, but pasted into your command line, so that you can edit it.

Examples for inspiration:

  • Find all subdirectories
  • Count the lines of a file that don't start with #
  • Delete a remote git tag

Building from source

This project is written in Go:

git clone https://github.com/mbrt/gencmd
cd gencmd
go build .

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
hack
jsonschema command