Skip to main content

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-trash options
  • Works with sudo for root-owned files
  • Automatically prunes Trash entries older than $RESRM_TRASH_LIFE days (default 7, minimum 1)

    Note: if you need immediate deletion, use the regular rm command instead.


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

NOTE: To use resrm with sudo, the path to resrm must be in the $PATH seen by root.
Either:

  • install resrm as root (preferred), or
  • add the path to resrm to the secure_path parameter in /etc/sudoers. For example, where /home/user/.local/bin is where resrm is:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/.local/bin"

Install via PyPI (preferred):

pip install resrm

Or clone the repo and install locally:

git clone https://github.com/mdaleo404/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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resrm-0.3.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resrm-0.3.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file resrm-0.3.1.tar.gz.

File metadata

  • Download URL: resrm-0.3.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.9 Linux/6.17.7-200.fc42.x86_64

File hashes

Hashes for resrm-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1ecf5477fba44244f0b10891523d8d03967c96e8bafe17a8e0c0270cc0eb3629
MD5 98326e390cb42275b4fc436de0b84ccb
BLAKE2b-256 57a2ecfbd90bb34c855d03346f7b9dd27b8811f6128595c6f2141c8d93d78211

See more details on using hashes here.

File details

Details for the file resrm-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: resrm-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.9 Linux/6.17.7-200.fc42.x86_64

File hashes

Hashes for resrm-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05dedecc53f3acd8b0a1691d394a4fb060fb25518f75cb2376b70d4275b182a9
MD5 fb15ce6eb82a5b71643a6c2c054926ec
BLAKE2b-256 845c367ff0b72d2a6e5721f1d2ee766b5952901e0b94c54f2c6d7496e04af5bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page