oops is in beta. Report any issues on GitHub.

How to undo rm in the terminal

May 2026

There is no built-in undo for rm. When you run rm file.txt, the file usually bypasses your desktop Trash and is unlinked from the filesystem immediately.

What to try right now

If the file was tracked by git, run git status and restore it from the last commit with git restore file.txt. If the file was committed but removed in a later commit, use git log -- file.txt to find the old version.

If it was not tracked by git, check Time Machine, snapshots, cloud backups, editor history, or your IDE's local history. Forensic tools can sometimes help, but on SSDs recovery after rm is often unreliable.

How to make rm reversible

oops installs a shell hook that sees destructive commands before they run. When it detects rm, it copies the affected files into local trash, lets the original command run, and records a restore plan.

$ rm notes.txt $ oops ✓ restored notes.txt

That means you keep the normal rm workflow, but you have a short undo window if you delete the wrong thing.

Install

curl -fsSL oops-cli.com/install.sh | bash

Then open a new terminal tab and run oops tutorial. For recursive deletes, read the rm -rf guide. For the full command list, see the docs.