Note
This project is a part of SnapCore!
A tiny AI assistant for your terminal, written in plain POSIX sh.
Ask a question or describe a task; it answers or suggests a shell command and runs it only after you approve.
- Works with Anthropic, OpenAI and Ollama (local, no API key)
- One-shot mode and an interactive chat/agent mode that can run several commands in a row
- Saved conversations (or
--temp-sessionto save nothing) - No dependencies besides
curlandjq
$ ai.sh "list files larger than 100MB"
$ ai.sh --chat
$ ai.sh -y "show disk usage per directory" # auto-approve commandsNote
Quick terminal tasks shouldn't require bloated apps or shell-specific setups. ai.sh gives you a minimal, lightweight alternative that works anywhere without getting in your way. If you already love your current ecosystem helpers, by all means, stick with them! But if you just want something simple that gets straight to the point, you're in the right place.
Pick one way.
curl -fsSL https://raw.githubusercontent.com/snapsettle/ai.sh/main/install.sh | shNo curl? Use wget:
wget -qO- https://raw.githubusercontent.com/snapsettle/ai.sh/main/install.sh | shThis puts ai.sh (and a short alias ai) in ~/.local/bin and checks the download against a checksum.
If ~/.local/bin is not in your PATH, the installer prints the exact line to add for your shell.
You also need jq (sudo apt install jq, brew install jq, sudo pacman -S jq, ...).
Windows: use WSL.
Options (put them before sh):
| What | How |
|---|---|
| Install a specific version | curl -fsSL .../install.sh | AI_SH_VERSION=2026.10.25 sh |
| Install somewhere else | curl -fsSL .../install.sh | AI_SH_INSTALL_DIR=/usr/local/bin sh |
| Uninstall | curl -fsSL .../install.sh | sh -s -- --uninstall |
Nix users never run --update. Nix replaces the whole package when you rebuild.
With flakes (recommended): in your flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
ai-sh = {
url = "github:snapsettle/ai.sh";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, ai-sh, ... }: {
nixosConfigurations.YOUR-HOSTNAME = nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
{ nixpkgs.overlays = [ ai-sh.overlays.default ]; }
];
};
};
}then in configuration.nix:
{ pkgs, ... }: {
environment.systemPackages = [ pkgs.ai-sh ];
}Rebuild with sudo nixos-rebuild switch --flake . and the commands ai.sh and ai are available.
Home Manager works the same way: home.packages = [ pkgs.ai-sh ];.
Without flakes: in configuration.nix:
{ pkgs, ... }:
let
src = builtins.fetchTarball "https://github.com/snapsettle/ai.sh/archive/refs/heads/main.tar.gz";
ai-sh = pkgs.callPackage "${src}/package.nix" { inherit src; };
in
{
environment.systemPackages = [ ai-sh ];
}Just try it (nothing installed): nix run github:snapsettle/ai.sh -- "your request"
Install for your user: nix profile install github:snapsettle/ai.sh
| How you installed | How to update |
|---|---|
| One-liner / manual | ai.sh --update |
| Nix flake | nix flake update ai-sh then sudo nixos-rebuild switch --flake . |
| Nix without flakes | sudo nixos-rebuild switch (Nix re-downloads about once an hour) |
ai.sh --update downloads the newest release, verifies its checksum and syntax, then replaces itself.
At most once a day ai.sh quietly checks for a newer version and tells you if there is one.
Turn that off with export SH_AI_NO_UPDATE_CHECK=1.
Running ai.sh --update on a Nix install does nothing except explain the Nix way.
Run ai.sh once in a terminal. A short setup asks which provider(s) you use and for an API key
(or reads ANTHROPIC_API_KEY / OPENAI_API_KEY from your environment). Change it later with ai.sh --reconfig.
ai.sh [options] "request" One-shot mode
ai.sh --chat [options] ["message"] Conversation mode
| Option | What it does |
|---|---|
-y, --yolo |
Flip auto-approval of commands (off by default). Deleting chats always asks. |
--chat, --convo |
Interactive conversation mode |
--temp-session |
Chat without saving anything to disk |
--update |
Update to the newest release (not for Nix) |
--reconfig |
Change settings |
--reset, --reset-config, --reset-convos |
Delete everything / settings / saved chats |
--version, -h, --help |
Version / help |
Inside a chat: /exit leaves (chat is kept), /delete leaves and deletes it, /help lists commands.
Environment variables: SH_AI_PROVIDER, SH_AI_MODEL, ANTHROPIC_API_KEY, OPENAI_API_KEY,
OLLAMA_HOST, SH_AI_DIR, SH_AI_NO_UPDATE_CHECK, SH_AI_NO_PROBE, SH_AI_NO_EXPLAIN,
SH_AI_NO_PATHS, NO_COLOR.
Settings and chats live in ~/.cache/ai.sh (or $SH_AI_DIR). The config file is readable only by you.
- Commands are shown and need your approval unless you use
-y. - Even with
-y, anything that does not look like a real command, a corrected command offered after a failure (one-shot mode), and every chat deletion still asks first. - You are running commands an AI wrote. Read them, especially with
-y.
To get commands right the first time, ai.sh sends your provider some context along with your request:
- your OS, distro, whether you are root, and which common tools are installed
- the names (only the names) of the folders in your home folder and of the entries in the current folder
- for requests about services, containers or processes: the few matching names found by quick read-only lookups on your machine
- command output, only when needed: the last lines after a failed command, the output of a command when you asked a question (so it can answer), and the output of every command in chat mode
- after a command fails on a path that does not exist: the names inside the nearest folder that does exist
With Ollama all of this stays on your machine. Turn parts off with SH_AI_NO_PATHS=1 (folder names), SH_AI_NO_PROBE=1 (service and process lookups) and SH_AI_NO_EXPLAIN=1 (sending output back to answer questions).
Versions are dates: 2026.10.25, or 2026.10.25.1 for a second release on the same day.
Every release is on the Releases page.
ai.sh --version shows what you have. The version is written in one place: the VERSION= line near the top of ai.sh.
- Edit
ai.shand raise theVERSION=line near the top (today's date, or add.1for a second release on the same day). - Commit and push to
main. That is all. - GitHub Actions (
.github/workflows/release.yml) checks the script, reads the version you wrote, checks that it is new and higher than every earlier release, and publishes a Release for exactly the commit you pushed. It never writes to the repository, so your local copy never falls behind because of a release. - One-liner users get it via
ai.sh --update. Nix users get it when they update their input / rebuild.
If you push a change to ai.sh without raising the version, the release job fails with a message saying so.
Raise the version, commit and push again.
Always remember to bump the version when proposing changes. Optional but recommended: turn on the repo's commit hook. It warns you when GitHub has new commits you do not have yet, so you can update before conflicts pile up. It never blocks a commit and never touches your files. Git does not enable hooks from a clone by itself, so run this once per clone:
git config core.hooksPath .githooksTo update your copy before you start working: git pull --rebase --autostash.