drop-in replacement for rm with undo/restore built-in.
Project description
resrm
resrm is a safe, drop-in replacement for the Linux rm command with undo/restore support.
It moves files to a per-user trash instead of permanently deleting them, while still allowing full sudo support for root-owned files.
Features
-
Move files and directories to a Trash folder instead of permanent deletion
-
Restore deleted files by short ID or exact basename
-
Empty trash safely
-
Supports
-r,-f,-i,--skip-trashoptions -
Works with
sudofor root-owned files -
Automatically prunes Trash entries older than
$RESRM_TRASH_LIFEdays (default 7, minimum 1)Note: if you need immediate deletion, use the
--skip-trashflag.
Configuration
To control how long trashed files are kept, add this line to your shell configuration (e.g. ~/.bashrc):
export RESRM_TRASH_LIFE=10
Installation
From package manager
This is the preferred method of installation.
Ubuntu 22.04 and 24.04
sudo add-apt-repository ppa:mdaleo/resrm
sudo apt update
sudo apt install resrm
Fedora 41, 42, 43
sudo dnf copr enable mdaleo/resrm
sudo dnf install resrm
From PyPI
NOTE: To use resrm with sudo, the path to resrm must be in the $PATH seen by root.
Either:
- install
resrmasroot, or - add the path to
resrmto thesecure_pathparameter in/etc/sudoers. For example, where/home/user/.local/binis whereresrmis:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/.local/bin"
Install with:
pip install resrm
From this repository
git clone https://github.com/guardutils/resrm.git
cd resrm/
poetry install
Usage
# Move files to trash
resrm file1 file2
# Recursive remove of a directory
resrm -r mydir
# Force remove (ignore nonexistent)
resrm -f file
# Interactive remove
resrm -i file
# Permanent delete (bypass trash)
resrm --skip-trash file
# List trash entries
resrm -l
# Restore a file by ID or basename
resrm --restore <id|name>
# Empty the trash permanently
resrm --empty
Trash Location
Normal users: ~/.local/share/resrm/files
Root user: /root/.local/share/resrm/files
TAB completion
Add this to your .bashrc
eval "$(register-python-argcomplete resrm)"
And then
source ~/.bashrc
pre-commit
This project uses pre-commit to run automatic formatting and security checks before each commit (Black, Bandit, and various safety checks).
To enable it:
poetry install
poetry run pre-commit install
This ensures consistent formatting, catches common issues early, and keeps the codebase clean.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file resrm-0.3.2.tar.gz.
File metadata
- Download URL: resrm-0.3.2.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.9 Linux/6.17.9-200.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c309e04c607d5566e3aa82625f6baf97f4dfdac4d7344daa4a9409a0b049784
|
|
| MD5 |
8a4012497a7eb9c4706c0ea62934e4b0
|
|
| BLAKE2b-256 |
a9106050eca1f663f5081d48db82171c2ccb5ed3787d5edee152bae953c7afbc
|
File details
Details for the file resrm-0.3.2-py3-none-any.whl.
File metadata
- Download URL: resrm-0.3.2-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.9 Linux/6.17.9-200.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8d91ed8eaf3ecc4b1764a5187bb9e4bcaa545bd8bc38e4414cd94cda47f2f62
|
|
| MD5 |
9b730c73b60d843abd4536af75376167
|
|
| BLAKE2b-256 |
03a7a6fb2ade5c77aa5a37b51f9b7b6518c76bb708b987a4f9061258dfa3e9fa
|