rip (rm-improved) sends deleted files to a graveyard instead of permanently removing them. You get 14 days to restore anything before it's automatically cleaned up.
cargo install rm-improvedNo cargo? Install Rust first: https://rustup.rs
Add this to your ~/.zshrc (or ~/.bashrc):
export RIP_GRAVEYARD="$HOME/.local/share/rip-graveyard"
rip() {
case "$1" in
--restore) shift; command rip --graveyard "$RIP_GRAVEYARD" --unbury "$@"; return ;;
--list) command rip --graveyard "$RIP_GRAVEYARD" --seance; return ;;
--nuke) command rip --graveyard "$RIP_GRAVEYARD" --decompose; return ;;
esac
command rip --graveyard "$RIP_GRAVEYARD" "$@"
local bytes
bytes=$(du -sb "$RIP_GRAVEYARD" 2>/dev/null | awk '{print $1}')
if [[ -n "$bytes" && "$bytes" -gt 1073741824 ]]; then
echo "⚠️ Graveyard is $(du -sh "$RIP_GRAVEYARD" 2>/dev/null | cut -f1) — run 'rm --nuke' to clear it"
fi
}
alias rm="rip"Then reload your shell:
source ~/.zshrcCreate two files to set up a daily systemd timer that permanently removes graveyard files older than 14 days.
~/.config/systemd/user/rip-cleanup.service
[Unit]
Description=Clean rip graveyard files older than 14 days
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'find ~/.local/share/rip-graveyard -mindepth 1 -mtime +14 -type f -delete 2>/dev/null; find ~/.local/share/rip-graveyard -mindepth 1 -empty -type d -delete 2>/dev/null'~/.config/systemd/user/rip-cleanup.timer
[Unit]
Description=Daily rip graveyard cleanup
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.targetEnable it:
systemctl --user daemon-reload
systemctl --user enable --now rip-cleanup.timerrm file.txt # sends to graveyard (recoverable)
rm --list # list deleted files in current directory
rm --restore # restore the last deleted file
rm --nuke # permanently delete everything in graveyardFiles stay recoverable for 14 days, then the timer cleans them up automatically. If the graveyard exceeds 1GB, you'll see a warning after any deletion.