Documentation
Installation, shell setup, commands, and configuration.
Installation
One-liner (macOS and Linux):
From source (requires Go):
Shell setup
Add one of these to your shell config, then restart:
Run oops doctor to verify.
Usage
Commands
oops
Undo the last destructive action. Pass a number to go further back.
oops log
Show undo history. -n 50 for more.
oops size
Show backup disk usage.
oops clean
Remove old backups. --all for everything, --older-than 3 for entries older than 3 days.
oops config
View or set settings:
oops doctor
Health check — verifies directory, config, git, and hook.
oops init <shell>
Print the hook for zsh, bash, or fish.
oops tutorial
Interactive walkthrough — creates a test file, deletes it, and restores it to show you how oops works.
oops --upgrade
Upgrade to the latest version by re-running the installer.
oops --version
Print the installed version.
Configuration
Stored in ~/.oops/config.json:
- retention_days — days to keep backups (default: 7)
- max_trash_bytes — max trash size (default: 5 GB)
- risk_warning — warn on high-risk commands (default: true)
Storage
Auto-cleanup runs lazily, at most once per hour. Old entries get purged. If trash exceeds the max, oldest go first.
How it works
Shell hook — a preexec function pattern-matches your command. Safe commands (ls, cat, git log, etc.) pass through with zero overhead — no subprocess is spawned.
Protect — for destructive commands, oops parses the command string, identifies the target files, and backs them up to ~/.oops/trash/. Then the original command runs normally.
Undo — reads the journal, restores files to their original paths. For git ops, applies the stash or recreates the deleted branch.
How backups work
oops uses hard links instead of copying files. A hard link creates a second reference to the same data on disk — it's instant and uses no extra space. When the original file is deleted by rm, the data survives through the hard link in trash.
This means backing up a 10GB directory takes the same time as a 10KB file: essentially zero. The disk space is only consumed after the original is deleted, since the data now only has one reference (the trash link) instead of two.
Hard links only work on the same filesystem. If oops detects a cross-filesystem backup (e.g. an external drive), it falls back to a regular copy.
When you run oops to restore, the files are linked back to their original paths — also instant.
Uninstall
Walks you through removing the shell hook, backup directory, and binary with y/n prompts.