- Posted on
- • Artificial Intelligence
Artificial Intelligence Writing Tools on Linux
- Author
-
-
- User
- linuxbash
- Posts by this author
- Posts by this author
-
Artificial Intelligence Writing Tools on Linux (From Your Bash Prompt)
What if your next article outline, draft, and edit pass all started with a single command in your terminal? You don’t need a proprietary GUI to get world-class writing assistance. On Linux, you can use local models for privacy, cloud models for power, and glue it all together with simple Bash one-liners you can version-control and automate.
In this guide, you’ll learn practical, terminal-first ways to use AI for writing on Linux. You’ll get install commands (apt, dnf, zypper), concrete CLI examples, and a small workflow you can adapt to your projects.
Why AI writing on Linux is worth your time
Composable: Terminal tools chain together—pipe, redirect, schedule, script, and diff your writing as code.
Private and offline: Run capable local models for drafts and edits without sending text to the cloud.
Reproducible: Store prompts and commands in scripts and Makefiles so you (or your team) can repeat the same steps later.
Editor-agnostic: Work the same way from Vim, Emacs, VS Code, or a remote TTY.
1) Local-first AI with Ollama (fast, private, no cloud required)
Ollama makes it dead-simple to run high-quality open models locally (Llama 3, Mistral, and more). It’s ideal for outlines, brainstorming, rewrites, and summaries—without leaving the terminal.
Install Ollama:
curl -fsSL https://ollama.com/install.sh | sh
Pull a model and generate an outline:
ollama pull llama3
ollama run llama3 "Create a 7-point outline for a blog post on Linux dotfiles best practices."
Rewrite a draft in place:
prompt=$(printf 'Rewrite the following for clarity and concision. Keep Markdown formatting.\n\n%s\n' "$(cat draft.md)")
ollama run llama3 "$prompt" > draft.cleaned.md
Summarize a long transcript:
prompt=$(printf 'Summarize the following meeting transcript in 6 bullet points with action items:\n\n%s\n' "$(cat meeting.txt)")
ollama run mistral "$prompt" > meeting.summary.md
Tip: You can experiment with different local models (e.g., mistral, llama3:8b, neural-chat) depending on your hardware and tone preferences.
If you don’t have curl installed yet:
Debian/Ubuntu (apt):
sudo apt update && sudo apt install -y curlFedora/RHEL (dnf):
sudo dnf install -y curlopenSUSE (zypper):
sudo zypper install -y curl
2) Cloud models from the terminal with the “llm” CLI (vendor-agnostic feel)
The “llm” CLI by Simon Willison gives you a clean command-line interface to cloud LLMs (like OpenAI). It’s fantastic for quick drafts, structured prompts, and saving results to files. We’ll install it with pipx so it stays isolated and easy to update.
Install pipx:
Debian/Ubuntu (apt):
sudo apt update && sudo apt install -y pipx python3-venvFedora/RHEL (dnf):
sudo dnf install -y python3-pipxopenSUSE (zypper) — one of these will exist depending on your distro version:
sudo zypper install -y python311-pipx || sudo zypper install -y python3-pipx
Put pipx on your PATH (run once):
pipx ensurepath
exec $SHELL -l
Install the CLI:
pipx install llm
Set your API key (example: OpenAI):
export OPENAI_API_KEY="sk-..."
Draft a blog intro:
llm -m gpt-4o "Write a compelling 120-word introduction for a blog about automating Linux backups with Borg. Use an approachable tone."
Expand bullet points into a section (save to file):
llm -m gpt-4o "Expand these three bullets into a cohesive 200-word section with examples:
- encrypt backups
- prune old archives
- monitor with cron emails" > section-backups.md
Rewrite for a defined audience:
llm -m gpt-4o --system "You are a technical editor optimizing text for junior sysadmins." \
"Rewrite the following to be friendly for early-career readers and keep all commands accurate:
$(cat hardening-notes.md)"
Note: You can configure different providers with environment variables; check llm --help for details.
3) Zero-friction Bash with curl + jq (DIY, scriptable everywhere)
If you prefer “just curl it,” you can hit a provider’s HTTP API directly and format results with jq. This is perfect for ephemeral one-liners or embedding AI calls into shell scripts.
Install prerequisites:
Debian/Ubuntu (apt):
sudo apt update && sudo apt install -y curl jqFedora/RHEL (dnf):
sudo dnf install -y curl jqopenSUSE (zypper):
sudo zypper install -y curl jq
Example using OpenRouter (lets you choose from many models via one key):
export OPENROUTER_API_KEY="or-..."
A tiny helper function:
ai() {
local prompt="$1"
curl -s https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg p "$prompt" '{
model: "meta-llama/llama-3.1-70b-instruct",
messages: [{role: "user", content: $p}]
}')" \
| jq -r '.choices[0].message.content'
}
Rewrite a file with a style brief:
ai "$(printf 'Please rewrite the following in active voice, keep Markdown headers, and reduce fluff by 20%%:\n\n%s' "$(cat draft.md)")" > draft.active.md
Summarize a log:
ai "Summarize these logs in 6 bullets focused on user-facing impact:\n\n$(tail -n 500 app.log)" > app-impact.md
Swap out model names or endpoints as needed. Because this is pure Bash, you can slot it into cron jobs, Git hooks, or Makefile targets.
4) Turn prompts into a repeatable writing pipeline
Glue it all together with a tiny script or Makefile so your writing steps are predictable and versioned. This example prefers local Ollama if available, otherwise falls back to a cloud model via the llm CLI.
Simple script: ai-write.sh
#!/usr/bin/env bash
set -euo pipefail
ENGINE=${ENGINE:-auto} # auto|ollama|llm
MODEL_LOCAL=${MODEL_LOCAL:-llama3}
MODEL_CLOUD=${MODEL_CLOUD:-gpt-4o}
usage() {
echo "Usage: $0 <mode> [args...]"
echo "Modes:"
echo " outline <topic>"
echo " expand <prompt-file>"
echo " rewrite <input-file> <style-brief>"
}
run_local() {
ollama run "$MODEL_LOCAL" "$1"
}
run_cloud() {
llm -m "$MODEL_CLOUD" "$1"
}
run() {
local prompt="$1"
if [[ "$ENGINE" == "ollama" || ( "$ENGINE" == "auto" && command -v ollama >/dev/null 2>&1 ) ]]; then
run_local "$prompt"
else
run_cloud "$prompt"
fi
}
mode=${1:-}
case "$mode" in
outline)
topic="${2:-}"
[[ -z "$topic" ]] && usage && exit 1
run "Create a detailed blog post outline about: $topic"
;;
expand)
file="${2:-}"
[[ -z "$file" || ! -f "$file" ]] && usage && exit 1
run "Expand the following bullet points into a 300-word section with code examples where sensible:\n\n$(cat "$file")"
;;
rewrite)
infile="${2:-}"; brief="${3:-}"
[[ -z "$infile" || -z "$brief" || ! -f "$infile" ]] && usage && exit 1
run "Rewrite the following according to this brief: $brief\n\nText:\n$(cat "$infile")"
;;
*)
usage; exit 1;;
esac
Make it executable and try it:
chmod +x ai-write.sh
./ai-write.sh outline "Automating server patching on Fedora and Ubuntu"
./ai-write.sh expand bullets.txt > section.md
./ai-write.sh rewrite draft.md "Simplify jargon, keep code blocks unchanged." > draft.edited.md
Because this is just Bash, you can commit the script to your repo, review changes with git diff, and keep your writing flow consistent across machines.
Real-world usage tips
Keep context small: Feed only the relevant sections of a long doc to the model to improve focus and save tokens.
Set a “house style” system prompt: e.g., “Technical, friendly, use active voice, prefer short sentences.”
Protect code blocks: Tell the model “Do not alter code blocks; only edit prose.”
Track versions: Commit your drafts and AI outputs to Git; review diffs like you would source code.
Mix local + cloud: Use local models for brainstorming and redlines, cloud models for final polish if you need maximum quality.
Conclusion and next step
You now have multiple Linux-native options for AI-assisted writing, from private local models (Ollama) to clean cloud CLIs (llm), plus raw curl+jq for total control. Pick one path and try it today:
1) Local: Install Ollama, pull llama3, and generate an outline for your next post.
2) Cloud: Install pipx + llm, set your API key, and expand a bullet list into a draft.
3) DIY: Drop the ai() Bash function into your shell profile and rewrite a paragraph.
Once you’ve got a result you like, wire it into a repeatable script (like ai-write.sh) and keep shipping great content—directly from your terminal.