rtrash

One native FreeDesktop trash tool — rm-compatible put, full trash-cli suite, optional Python bindings. Recoverable by design.

FreeDesktop rm-compatible Linux Rust + Python

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

rtrash path or multi-call rm → trash

Scripts / tests

pin with --trash-dir ; isolate XDG_DATA_HOME

Python instead of permanent unlink

rtrash.unlink(path) after import rtrash

See reclaim before empty

rtrash empty --dry-run

Install (shortest path)

CLI

cargo install --git https://github.com/HaoZeke/rtrash
rtrash setup   # multi-call links + completions + man under ~/.local

Python

pip install maturin
maturin develop --features python   # from a checkout
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 .trashinfo reservation

  • rm-compatible put (-rf, -i / -I last-wins, preserve-root, exit 0/1/2)

  • Suite: put / list / restore / empty / selective trash-rm

  • Fast empty: parallel top-level wipe, d_type unlinks, optional btrfs subvol destroy

  • Dry-run reclaim: empty -n reports approximate space that would be freed

  • Python: in-process unlink / rmtree over 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

Getting started

Install the CLI and Python module; shortest put / restore / empty flows.

When to use what
Architecture & safety

FreeDesktop layout, fail-safes, and when permanent delete still wins.

What rtrash is
Benchmarks

Measured safer / better / faster vs trash-cli and large empty timings.

Verdict
Python bindings

Replace os.remove / Path.unlink / shutil.rmtree with trash put.

Goal

Source & license