I set up two terminal commands I can talk to, , and q. I enter , in terminal, hit Enter, say what I want, it gives me back the shell command. With q command, I ask a question out loud, and an LLM answers it (and can read files on disk to do so).

This is what it looks like in practice:

I saw this post by Python Monty about wiring up these two terminal commands:

  • , <description> to get a shell command based on your description

  • q <question> to have an LLM answer your question

This setup uses the Pi coding agent under the hood. After configuring these commands, we can do things like the following:

, find the 5 largest files in the current directory

q read run-qwen36-q8.sh and summarize what it does in 3 bullet points

I immediately found this useful for quick shell commands and questions cause I didn't have to launch a full coding-agent session in Pi or Claude or open a web UI.

Now, I'm a big fan of speech-to-text and I use voice typing for all my interactions with LLMs and coding agents. I have built this hns CLI tool for speech-to-text in the terminal. hns writes the transcription to stdout so it integrates well with other CLI tools.

So, of course, I wanted to adapt the workflow suggested by Python Monty so that I don't have to type anything after entering , or q. Instead, I can just speak out loud my request or question.

The transcription part of this setup runs locally on your machine. You can use local LLMs with Pi to keep the end-to-end setup on-device, or you can use remote LLMs.

Setting It Up on macOS

1. Install hns

Install hns by running uv tool install hns. By default, hns uses the base whisper model, about 145 MB in size, which is good enough for this kind of use case. So you don't need to do any other setup for hns. During the first transcription, hns automatically downloads the base model from Hugging Face. After that, transcription happens locally on your machine.

2. Install and Configure Pi

Install Pi coding agent by following the quickstart guide, then configure a provider and model. You can use a local LLM with Pi to keep your entire setup on-device. Or you can set up cloud LLM through a ChatGPT or GitHub Copilot subscription, or an API key.

3. Configure Comma Command

The , command helps you get a shell command for your use case. After setting this up, you just need to type , in the terminal, hit Enter, and start saying what you want the command to do in plain English.

Hit Enter again after you're done speaking and you'll soon see your request and then the shell command in your terminal. The shell command is also copied to the clipboard automatically, so you just need to press Cmd+V and hit Enter to execute the command.

If you're using bash or zsh, add this to your ~/.bashrc or ~/.zshrc file:

,() {
    local prompt command
    prompt=$(hns)
    printf '%s\n' "$prompt"

    command=$(pi --print --no-tools --thinking off \
        --system-prompt "Output exactly one shell command,
        the best one, with no numbering, no explanation,
        no markdown, and no backticks. Output only the raw command
        on a single line." "$prompt" 2>/dev/null)

    printf '%s' "$command" | pbcopy
    printf '%s\n' "$command"
}

If you're using fish, add this to ~/.config/fish/config.fish file:

function ,
    set -l prompt (hns | string collect)
    printf '%s\n' $prompt

    set -l command (pi --print --no-tools --thinking off \
        --system-prompt "Output exactly one shell command,
        the best one, with no numbering, no explanation,
        no markdown, and no backticks. Output only the raw command
        on a single line." $prompt 2>/dev/null | string collect)

    printf '%s' $command | pbcopy
    printf '%s\n' $command
end

Restart your terminal or source the config file, and the , command should be available in your shell.

4. Configure Question Command

The q command helps you get quick answers. I give Pi access to the read, grep, find, and ls tools for this command, so the model can answer questions based on existing knowledge or by reading and searching files on disk. Pi doesn't have a built-in web_search tool but you can configure a web-search tool yourself and make this command more capable.

After setting up this command, you can type q in the terminal, hit Enter, and then say your question aloud in plain English. Hit Enter again after you're done speaking and you'll soon see your question followed by the answer in your terminal.

If you're using bash or zsh, add this to your ~/.bashrc or ~/.zshrc file:

q() {
    local prompt
    prompt=$(hns)
    printf '%s\n' "$prompt"

    pi --print \
        --system-prompt "You are a helpful, concise assistant
        running in a macOS terminal. Answer clearly and accurately.
        You can read files from disk.
        Use this ability for file-specific information." \
        --tools "read,grep,find,ls" \
        "$prompt"
}

If you're using fish, add this to ~/.config/fish/config.fish file:

function q
    set -l prompt (hns | string collect)
    printf '%s\n' $prompt

    pi --print \
        --system-prompt "You are a helpful, concise assistant
        running in a macOS terminal. Answer clearly and accurately.
        You can read files from disk.
        Use this ability for file-specific information." \
        --tools "read,grep,find,ls" \
        $prompt
end

Restart your terminal or source the config file, and the q command should be available in your shell.

If this was useful, and you want workflows like these in your inbox, subscribe below. Thanks!

Reply

Avatar

or to participate

Keep Reading