Why shell history isn't enough
Shell history is good at the command you ran ten minutes ago. It's bad at the one you run twice a year: the exact flags for a database dump, the ffmpeg line that worked, the git command that undoes the last commit without losing your changes. Those end up in a browser tab, a notes app, or nowhere.
There are two good homes for commands you reuse, and they cover different cases.
Commands you run often: aliases
zsh is the default shell on current versions of macOS. For a command you run every day with the same arguments, give it a name in your ~/.zshrc:
alias gs="git status -sb"Open a new Terminal window and gs runs it. Aliases are ideal for a small set of fixed commands. They're a poor fit for commands with parts that change each time, and for the rare ones you won't remember the alias for anyway.
Commands you look up: a snippet library
For everything else, keep the command text somewhere you can search and paste from. In Refrain:
- Press Control-Option-Space in Terminal (or any editor). A search palette opens.
- Type words you remember, from the name or the command itself:
undo commit,ffmpeg,dump. Every word you type has to match, so two words usually find it. - Press Return to copy it, then Cmd-V into the prompt. Edit the parts that change, then run it yourself.
Refrain only copies text. It never runs a command, so nothing executes until you press Return in Terminal. Multi-line scripts keep their line breaks.
One starter snippet ships with the app as an example: git-undo-last-commit, which copies git reset --soft HEAD~1.
Store them as plain text
Refrain keeps snippets in one markdown file. Each snippet is a name plus the exact text that gets copied:
---
name: postgres-dump-one-table
---
pg_dump --data-only --table=TABLE_NAME DATABASE_NAME > table.sql
----- Save the bare command. The text is copied exactly as written, so leave out code fences and prompt characters like
$. - Mark the parts you change in capitals, like
TABLE_NAME, so they stand out after you paste. - Name by task, not by tool:
git-undo-last-commitis easier to find later thangit-reset-soft.
One place for commands and everything else
The same palette holds whatever else you paste during the day: AI prompts, review comments, email replies. If you work with coding agents, see how to organize Claude Code prompts.