AI-powered shell shortcuts for local Ollama workflows
Llamalias is a modular shell library that supercharges your terminal with local LLM capabilities. By wrapping Ollama's HTTP API into modular shell functions prefixed with ai-, it provides instant development shortcuts for code auditing, commit message generation, unit testing, log diagnosis, and interactive terminal chat—with zero cloud dependencies and zero API fees.
To automatically load these commands whenever you open a terminal, source the file in your ~/.bashrc:
echo "source ${LLAMALIAS_DIR}/llamalias" >> ~/.bashrc
source ~/.bashrcClick here to see the command reference cheat sheet
Temporary Switch (Current Shell Session Only):
ai-model llama3.2:3bOne-Off Command Override:
AI_MODEL="qwen2.5-coder:3b-instruct-q4_K_M" ai-commitPermanent Default: Edit export AI_MODEL="..." at the top of ${LLAMALIAS_DIR}/config/settings.sh.
Ensure jq is installed:
sudo apt install -y jqEnable token performance metrics:
ai-perf off # Mutes performance bar
ai-perf on # Re-enables performance barWhat the Metrics Measure
When AI_SHOW_PERF is enabled, every ai-* command appends a performance summary line at the bottom of its output:
[Perf] 2.14s total | Gen: 85 tok (39.72 tok/s) | Prompt: 312 tok (145.80 tok/s)
| Metric | Description |
|---|---|
| total | End-to-end wall clock time in seconds. |
| Gen tok | Total output tokens generated by the LLM. |
| tok/s (Gen) | Tokens generated per second (measures model inference speed). |
| Prompt tok | Input prompt + context token volume passed to Ollama. |
| tok/s (Prompt) | Prompt prefill rate per second (measures context evaluation speed). |
The compaction filter strips blank lines, indentation fluff, and standalone comments from incoming piped code/text before it gets formatted into the JSON payload.
With Compaction OFF:
ai-compact off
cat main.py | ai-review
# Output: [Perf] 3.10s total | Gen: 92 tok | Prompt: 680 tokWith Compaction ON:
ai-compact on
cat main.py | ai-review
# Output: [Perf] 1.85s total | Gen: 90 tok | Prompt: 340 tok (50% context reduction)When you pipe commands:
ai-skeletonparses the Python AST and strips method bodies.- The skeletonized interface streams into the next
ai-*command asstdin. - The downstream command passes that slimmed-down context directly to Ollama.
Review code structure, class design, or potential anti-patterns without flooding the context window with implementation details:
cat main.py | ai-skeleton | ai-reviewConcatenate multiple Python files into a single skeleton before asking for an architectural breakdown:
cat models.py services.py controllers.py | ai-skeleton | ai-explainAsk Ollama to write test suites based purely on function signatures, type hints, and docstrings:
cat api/routes.py | ai-skeleton | ai-testPass a skeletonized structure along with an explicit targeted question:
cat database.py | ai-skeleton | ai-ask "Suggest how to refactor this class hierarchy to use the Repository pattern."Ensure public APIs have thorough docstrings without distracting the LLM with method internals:
ai-skeleton legacy_service.py | ai-docExplicitly chaining ai-skeleton | ai-... gives you granular control. Even if you turn auto-compaction off globally (ai-compact off), manually piping ai-skeleton lets you selectively skeletonize large files only when you need to:
ai-compact off
# Full code sent (detailed review)
cat small_utils.py | ai-review
# Explicitly skeletonized (lightweight review)
cat huge_monolith.py | ai-skeleton | ai-reviewLlamalias is licensed under the terms of the MIT License.