Searching From the Command Line
Outcome: you can pull answers out of the
database without opening the search
window — in scripts, in pipes, and in
the "what exactly did I run?" moments.
Check: each command below, run against
the lab's database, prints what the
transcript says it prints
(atuin-lab/transcripts/t04-search.txt).
The interactive search (next chapter) is
for you, typing. atuin search is the
same engine with the conversation taken
out: give it a query, it prints the
matches, newest first, and leaves.
The plain search
atuin search rsync
2026-10-07 22:09:00 rsync -av ~/Documents/ ~/backups/documents/ 0s
Three tab-separated fields by default: when it ran, the command, how long it took. Two refinements you will use daily:
--cmd-onlyprints just the command text — the form you want in a pipe.--formatbuilds the line yourself from placeholders:{command},{directory},{duration},{time},{exit},{host},{user},{relativetime}. Chapter 4's tables came from--format "{time} | exit {exit} | {duration} | {directory} | {command}".
And atuin history last answers the
smallest question of all — what did I
just run? — with the previous command
and its duration:
$ atuin history last
2026-10-28 11:37:12 atuin history list --format "{time} | exit {exit} | {duration} | {directory} | {command}" | tail -13 97ms
What "matches" means
A bare query does not mean "starts
with". Atuin's default search mode is
fuzzy: the letters of your query
must appear in the command, in order,
anywhere. Watch what that does to a
search for tar in the lab's database
(transcript t04-search.txt):
$ atuin search --cmd-only tar
atuin history list --format "{time} | …" | tail -13
echo "water the tomatoes on Friday" > todo.txt
mkdir -p ~/projects/garden-notes
cd ~/projects/garden-notes
tar czf photos-2026.tgz ~/Pictures
tar czf garden-notes-backup.tgz projects/garden-notes
Only the last two lines start a tar.
The others merely contain a t, an
a and an r in order somewhere —
"water", "tomatoes", "Friday"
will do it. Fuzziness is a feature in
the interactive window, where your eyes
filter the list; in a pipe it is noise.
Chapter 7's filters narrow by fact
(directory, exit code, date); the
search modes narrow by match kind.
Preview, from transcript
t08-search-modes.txt:
$ atuin search --search-mode prefix --cmd-only tar
tar czf photos-2026.tgz ~/Pictures
tar czf garden-notes-backup.tgz projects/garden-notes
$ atuin search --search-mode prefix --cmd-only aptinst
$ atuin search --search-mode fuzzy --cmd-only aptinst
sudo apt install -y tmux htop
- prefix — the command must start with your query. The librarian's mode: exact, unsurprising, pipe-safe.
- fulltext — the query appears
anywhere as one piece:
sshfinds bothssh storage.example.comandsystemctl status ssh. - fuzzy — the default; letters in
order, anywhere.
aptinstfinds the install command because its letters are in there, scattered.
Modes can be set per search with
--search-mode, or as your default in
the configuration (chapter 10, where
the lab changes it and the same two
searches change their answers).
Shaping the output
Four more flags earn their keep:
--limit N— at most N results.--reverse— oldest first, for reading a story in order.--before/--after— bound the search by date; both take real dates (2026-10-10) and relative phrases (yesterday 3pm). The lab counted its imported past withatuin search --before 2026-10-10 --cmd-only | wc -land got 12 — the fixture commands from 6–9 October.--delete— removes whatever the query matches and prints nothing. It is the only flag in this chapter that changes the database; chapter 14 talks about what deletion does and does not promise.
One boundary to keep in mind: plain
atuin search deduplicates — a
command you ran five times appears
once, at its most recent running.
--include-duplicates shows every
running when you truly want them all.