Ordinary file deletion should moves files and directories to the trash instead of permanently unlinking them.
That matters a lot when using coding agents, especially in YOLO mode. Agents can
run broad shell commands quickly, expand globs, execute cleanup scripts, or apply
generated commands with more confidence than the situation deserves. A trash-backed
rm does not make destructive work impossible, but it turns many accidental
deletions from irreversible data loss into a recoverable operation.
Interactive shell deletion is redirected to trash:
alias rm='trash-put'
alias rmdir='trash-put'There is also a user-level wrapper at:
~/.local/bin/rmBecause ~/.local/bin is ahead of /bin and /usr/bin in PATH, normal command
lookup resolves rm to the wrapper. The wrapper calls trash-put by default.
Permanent deletion is still available, but it is explicit:
real-rm path
rm --permanent pathThis is intentional. Some operations genuinely need permanent deletion, but they should stand out in shell history and during review.
Useful trash-cli commands:
trash-list
trash-restore
trash-empty 60trash-list shows deleted files. trash-restore lets you recover them.
trash-empty 60 permanently removes trash entries older than 60 days.
A user-level systemd timer runs daily:
systemctl --user status trash-empty-old.timerThe service executes:
/bin/trash-empty 60That keeps recent accidents recoverable while preventing trash from growing forever.
This setup protects normal user-level shell deletion. It does not fully protect against:
sudo rm .../bin/rm ...- programs that unlink files directly
- scripts that set their own
PATH - filesystem damage or overwrites
For stronger protection, add filesystem snapshots such as Btrfs, ZFS, LVM, or Timeshift. Trash-backed deletion is the first line of defense; snapshots are the next layer.