Skip to main content

drop-in replacement for rm with undo/restore built-in.

Project description

License Language GitHub Release PyPI - Version PyPI downloads

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 --skip-trash flag.


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 resrm as root, 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 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


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.3.tar.gz (18.5 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.3-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: resrm-0.3.3.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

Hashes for resrm-0.3.3.tar.gz
Algorithm Hash digest
SHA256 76b47bf438af4344b86114dd66692ae73eed8fe8458e8c8a25a24613f97a429c
MD5 b7a469098e39cbfc46d422b3d79b05b7
BLAKE2b-256 b6614b89b772a101756784e0083ed63852247231ef49bd6e8f70e788406df21d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: resrm-0.3.3-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

Hashes for resrm-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e30d9a51a3268cf89e3ce1b1a28dcf1c80751af135f2f0705796a4c0f161e1f
MD5 15c80c6406b492537f4e881065934496
BLAKE2b-256 2b460eed0a1cee56b4b951796e55dcbd1acfb1a31c58ebd74694fd86bc1d5be0

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