ask is a smart Bash wrapper for Ollama that brings the power of multiple LLMs directly to your terminal. It automatically selects the best model for your specific query, manages system context, and keeps your shell workflow efficient.
- Smart Model Routing: Automatically detects the intent of your query and routes it to the right model:
- Coding/Scripting/Debugging/Reasoning ->
qwen3.5:latest(mid-size, runs with--think=falsefor fast, non-rambling answers) - General/Quick Questions ->
gemma3:1b(tiny, near-instant) - Falls back through
gemma3:1b->gemma:2b->qwen3.5:latest->gemma4:e4bif the target model isn't installed.
- Coding/Scripting/Debugging/Reasoning ->
- Fast Mode (
-f/--fast): Force the smallest/fastest model (gemma3:1b) for an instant answer. - Dynamic Context: Automatically detects your OS and Shell to provide accurate commands (works on Arch, Debian, Fedora, macOS, etc.).
- Context Awareness (
-c): securely injects the current directory structure (usingeza/exaif available) into the AI's context. - Error Analysis (
-e): Special mode to debug failed commands or analyze error logs via pipe. - Tight, No-Fluff Answers: The system prompt caps replies at ~5 lines, forbids disclaimers/closing questions, and disables model "thinking" output so you get a command, not an essay.
- Beautiful Output: Automatically formats output with Markdown syntax highlighting using
glow(if installed). - Safety Guardrails: Warns you before suggesting genuinely destructive commands (
rm -rf,dd,mkfs,DROP TABLE, etc.) — without inventing risk on harmless read-only commands.
-
Required:
-
bash(4.0+) -
ollama(0.20+ recommended, for--thinkflag support; must be installed and running) -
Models: You need to pull the models used by the script (or edit the script to use yours):
ollama pull qwen3.5 ollama pull gemma3:1b
-
-
Optional (Recommended):
glow: For beautiful markdown rendering.ezaorexa: For better file listing in context mode.
-
Clone the repository:
git clone https://github.com/myfoxx/ask-cli.git cd ask-cli -
Make it executable:
chmod +x ask
-
Install to PATH (optional but recommended):
sudo cp ask /usr/local/bin/ # OR link it locally mkdir -p ~/.local/bin ln -s "$(pwd)/ask" ~/.local/bin/ask
ask "how do I unzip a tar.gz file?"Includes the current directory file list in the prompt. Useful for "how do I run this project?" questions.
cd my-project
ask -c "explain the structure of this project"Analyze errors in two ways:
-
Wrapper Mode:
ask -e make build
Runs
make build. If it fails,askcaptures the error and explains it. -
Pipe Mode:
cat /var/log/syslog | ask -e "what is causing the crash?"
ask -m qwen3.5:latest "write a poem about linux"Skip routing and force the smallest, fastest model for an instant answer:
ask -f "how do I list files sorted by size?"-
Input Limiting (
-l): Truncate large logs to prevent token overflowask -e -l 50 make build # Max 50 lines of error -
Timeout (
-t): Prevent hanging on slow modelsask -t 30 "explain kubernetes" # 30-second timeout
-
Save Output (
-s): Save responses to fileask -s notes.md "explain Docker" ask -a -s history.log "explain Ansible" # Append with -a
-
Caching (
--cache): Cache responses for repeated queriesask --cache "how to install rust?" # Instant second time ask --clear-cache # Clear cache
-
List Models (
--list-models): Show available Ollama modelsask --list-models
-
Raw Output (
-R): Disable glow formattingask -R "question" | grep "specific"
-
Verbose (
-v): Show debug informationask -v "question"
Create ~/.askrc to customize defaults. See .askrc-example for available options:
# ~/.askrc
VERBOSE=true
MAX_LINES=100
TIMEOUT=120
CACHE_ENABLED=true
export OLLAMA_KEEP_ALIVE=30m # keep the model loaded in VRAM between callsAvoid setting
DEFAULT_MODELin~/.askrcunless you really want to pin every query to one model — it bypasses the smart routing entirely (except in-eerror mode).
Recommended aliases for .bashrc or .zshrc (also in alias.txt):
alias askcode='ask -m qwen3.5:latest' # Code/debug specialist
alias askhere='ask -c' # Context aware
alias askerr='ask -e' # Error analysis
alias askv='ask -v' # Verbose mode
alias askfast='ask -f' # Instant answer (gemma3:1b)
alias askarchive='ask -a -s ~/.ask-history' # Save to history- Basic Guide: See README.md (this file)
- Advanced Usage: See ADVANCED.md for edge cases, performance tips, and complex examples