rtrash
One native FreeDesktop trash tool — rm-compatible put, full trash-cli suite, optional Python bindings. Recoverable by design.
put → list → restore → empty
Why rtrash#
Permanent os.remove / bare rm is instant and unforgiving.
Desktop environments already share a FreeDesktop trash layout —
rtrash is a single Rust binary (and library) that puts files there
with GNU rm–shaped flags, then lists, restores, empties, and
selectively purges like the trash-cli suite — without CPython startup on
every call.
Need |
Use |
|---|---|
Safer interactive delete |
|
Scripts / tests |
pin with |
Python instead of permanent unlink |
|
See reclaim before empty |
|
Install (shortest path)#
CLI#
cargo install rtrash
# or: cargo binstall rtrash # prebuilt musl on x86_64 / aarch64 Linux
rtrash setup # multi-call links + completions + man under ~/.local
Python#
pip install rtrash
python -c "import rtrash; rtrash.unlink('scratch.txt')"
Details, multi-call symlinks, and MSRV: Getting started.
What you get#
FreeDesktop-correct home and per-mount trash, atomic
.trashinforeservationrm-compatible put (
-rf,-i/-Ilast-wins, preserve-root, exit 0/1/2)Suite: put / list / restore / empty / selective
trash-rmFast empty: parallel top-level wipe,
d_typeunlinks, optional btrfs subvol destroyDry-run reclaim:
empty -nreports approximate space that would be freedPython: in-process
unlink/rmtreeover the same core as the CLI
Honest comparison to trash-cli (measured on the project build host): Benchmarks. Safety model vs permanent delete: Architecture.
Documentation map#
Install the CLI and Python module; shortest put / restore / empty flows.
FreeDesktop layout, fail-safes, and when permanent delete still wins.
Measured safer / better / faster vs trash-cli and large empty timings.
Replace os.remove / Path.unlink / shutil.rmtree with trash put.
Source & license#
Repository: https://github.com/HaoZeke/rtrash
License: MIT
Org sources for this site:
docs/orgmode/(export → Sphinx / Shibuya)