English | 中文
sure-rm is a command-line tool written in Rust. It works just like the system rm.
Instead of permanently deleting files from disk, it moves them into a recoverable trash store. Files are only permanently deleted when you explicitly ask for it.
brew tap ChunzhengLab/tap
brew install sure-rmSee homebrew-tap for details.
--mode and the SURE_RM_MODE environment variable support three modes:
auto: detect based on TTYinteractive: prompt once for riskier operationsbatch: no extra prompts, execute directly
The recommended setup is interactive mode with a shell alias:
alias rm='sure-rm --mode interactive'Or set the default mode via environment variable:
export SURE_RM_MODE=interactive
alias rm='sure-rm'This makes rm behave as sure-rm. When you need a real delete, use rm -s ... (or rm --sure ...) to fall back to the system command.
Note: Shell aliases only apply in interactive terminals. In scripts,
rmremains/bin/rmand existing automation is unaffected.
Safely delete files, symlinks, and directories — moved to trash by default instead of permanent deletion.
list— view all entries in the trashrestore— restore an entry by id or by original pathpurge— permanently clean the trash, by id, by path, or--allunlink— single-file delete entry point:sure-rm unlink [--] <path>
- Supports nearly all
rmoptions:-d,-f,-i,-I,-p,-r/-R,-v,-x -ppermanently delete, skip the trash-s/--surebypass sure-rm, exec system/bin/rmor/bin/unlink--mode auto|interactive|batchcontrol prompt behavior, also configurable viaSURE_RM_MODE
- Automatically blocks dangerous targets like
/,.,.., current directory, andHOME
# Set up alias
alias rm='sure-rm --mode interactive'
rm -rv build # move build/ to trash, verbose output
rm -sf build # bypass sure-rm, exec /bin/rm -f build
rm list # list all entries in the trash
rm restore 1774864212-68302-250054000 # restore a specific entry by id
rm restore ./notes.txt # restore by relative path
rm restore ../docs/notes.txt # cross-directory relative path works too
rm restore /home/user/notes.txt # restore by absolute path
rm -pv old.log # permanently delete, skip the trash
rm unlink -- -file # unlink a file named "-file"The trash is located at ~/.sure-rm by default.
rm list # view trash contents
rm restore ./notes.txt # restore a file
rm purge 1774864212-68302-250054000 # permanently delete one entry by id
rm purge ./notes.txt # permanently delete one entry by path
rm purge --all # empty the trashYou can override the trash path via environment variable for testing or sandboxed execution:
SURE_RM_ROOT=/tmp/sure-rm sure-rm -rv some-directorySet SURE_RM_TTL to automatically purge entries older than the specified duration. Expired entries are cleaned up when running list.
export SURE_RM_TTL=30d # 30 days (default unit is days)
export SURE_RM_TTL=12h # 12 hours
export SURE_RM_TTL=3600s # 3600 secondsSet to 0 or leave unset to disable auto-expiry.
Inspired by jwanLab, who spent months building an awesome project, then deleted it in less than a second.