ask

simple bash script that helps you with terminal commands with the power of chatgpt


Project maintained by zmsp Hosted on GitHub Pages — Theme by mattgraham

ask — AI terminal assistant

Turn plain-English descriptions into shell commands. Powered by OpenAI or Google Gemini.

Demo


Features


Quick Install

macOS / Linux

curl -fsSL https://zmsp.github.io/ask/install.sh | bash

Or manually:

curl -fsSL https://raw.githubusercontent.com/zmsp/ask/main/ask.sh -o /usr/local/bin/ask
chmod +x /usr/local/bin/ask
ask --setup

Windows (PowerShell)

irm https://zmsp.github.io/ask/install.ps1 | iex

Or manually:

irm https://raw.githubusercontent.com/zmsp/ask/main/ask.ps1 -OutFile "$env:USERPROFILE\bin\ask.ps1"
# Add $env:USERPROFILE\bin to your PATH, then:
ask --setup
Platform Script Installer
macOS / Linux ask (bash) install.sh
Windows ask.ps1 (PowerShell 5.1+) install.ps1

Requirements

Tool Install
bash 4+ Pre-installed on macOS/Linux
curl brew install curl / apt install curl
jq brew install jq / apt install jq
AI API key OpenAI or Gemini

Usage

Generate & run a bash command

ask "list all .log files modified in the last 7 days"
ask "restart nginx if it's not running"
ask "find the 5 largest files in my home directory"
Suggested:
find ~ -type f -printf '%s %p\n' | sort -rn | head -5

Run this command? (y/n): y

Free-form AI question (no command wrapping)

ask -q "What does HEAD~3 mean in git?"
ask -e "Explain the difference between CMD and ENTRYPOINT in Docker"

Pipe content as context

cat error.log  | ask "why is this failing?"
git diff       | ask "summarise these changes"
cat config.yml | ask "is anything misconfigured here?"

Explain the last command

ls -la /etc/hosts
ask !!
# → Explains ls, -l (long format), -a (hidden files), and the path

AI-powered git commit

ask commit
Git status:
 M src/index.js
 M README.md

Suggested commit message:
Update index.js routing and expand README usage section

Commit with this message? (y/n): y
[main 3f2a1b4] Update index.js routing and expand README usage section

Dangerous command guard

ask "recursively delete all files in /tmp/cache"

Suggested:
rm -rf /tmp/cache/*

⚠  This command looks dangerous. Type  yes  to run, anything else cancels.
Run ANYWAY? yes

Configuration

Configuration is stored in ~/.ask_config (user-readable only).

Run the interactive wizard:

ask --setup

Or edit the file directly:

# ~/.ask_config
provider=openai          # openai | gemini
model=gpt-4.1-nano       # leave blank for cheapest default
max_tokens=200
openai_api_key=sk-...
gemini_api_key=AIza...

Environment variables

Environment variables always take priority over the config file:

export OPENAI_API_KEY="sk-..."
export GEMINI_API_KEY="AIza..."
export VERBOSE=true           # print debug info

Provider & Model Reference

Provider Default model Price (input/output per 1M tokens)
openai gpt-4.1-nano $0.10 / $0.40
gemini gemini-2.5-flash-lite $0.10 / $0.40

OpenAI models: gpt-4.1-nano · gpt-4.1-mini · gpt-4.1 · gpt-4o-mini
Gemini models: gemini-2.5-flash-lite · gemini-2.5-flash · gemini-2.5-pro


License

MIT © Zobair