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

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.0.tar.gz (17.8 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.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: resrm-0.3.0.tar.gz
  • Upload date:
  • Size: 17.8 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.0.tar.gz
Algorithm Hash digest
SHA256 d147c229061761b4c0b047e10793c5f9c81f59a01867917976abfa383aa68c3b
MD5 65073bd50a50da3fcef8944d96b27ab0
BLAKE2b-256 32e9fecb01ca53372d6f074a6c2dbd9324dcdfc2f278b8b25d31125667ae5c68

See more details on using hashes here.

File details

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

File metadata

  • Download URL: resrm-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68fae11f11d065d6d8103d132ba0e2555b417c18336c65478fa4c69260ada5f5
MD5 056615c062d19fed8632695d6a4522fc
BLAKE2b-256 da3d03078da4acc2de415f7b0e04273a4a8e806d0d660e4a2a5dce2dbbd41f81

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