
trashy: Safe file deletion with Rust-based trash tool
Introduction
trashy is a Rust-based alternative to rm and trash-cli, designed to safely move files to a trash can instead of deleting them outright. This post covers the basics and common workflows with practical examples.
Quick start
- Install (examples; your package manager or cargo can vary):
- Using cargo:
cargo install trashy
- Or via your distro’s package manager if available.
- Verify installation:
trashy --version
Basic usage: move files to trash
- Move a single file to the trash:
trash path/to/file
- Move multiple files to the trash:
trash path/to/file1 path/to/file2 /another/path/file3
List and inspect trash contents
- List items currently in the trash:
trash list
Restore files from the trash
- Restore a specific file:
trash restore path/to/file
- Restore all files from the trash:
trash restore --all
Remove files from the trash (per-file or all)
- Remove a specific file from the trash:
trash empty path/to/file
- Remove all files from the trash:
trash empty --all
Tips and pitfalls
- When in doubt, list the trash first to confirm what you’re about to restore or permanently remove:
trash list
- If you accidentally trash the wrong file, use restore quickly:
trash restore path/to/wrong-file
- Replace multiple files only if you’re sure they are no longer needed; the empty —all option is irreversible for the trash on most systems.
- Ensure your PATH includes the trashy binary directory (e.g., ~/.cargo/bin) after installation:
export PATH="$PATH:$HOME/.cargo/bin"
Common workflows
- Quick delete-and-restore cycle:
trash important/document.pdf
trash list
trash restore important/document.pdf
- Clean slate:
trash empty --all
Troubleshooting
- If trashy isn’t found after install, verify where cargo bins are installed and update PATH:
which trashy
- If the trash shows up empty but files are missing, check if your system has a separate trash directory or permissions issues.
Conclusion
trashy provides a straightforward, safer alternative to rm by moving files to a trash bin first. Start with a small set of files, verify the trash contents, and gradually adopt the workflow for day-to-day file management.