Skip to main content

rm-teng

An attempt to minimise the impact of rm in careless hands. Note, minimise, not prevent.

Motivation

A couple of times I've managed to rm -rf {{ some-dir }} accidentally and, each time, it's been verrry annoying. Having something which stored {{ some-dir }} in a different location would have enabled me to undo the error. Issue here is rm -i wouldn't have saved me, I've deleted things thinking they were safe to delete then found out they weren't.

Usage

Basic

Expected usage is as follows:

# in .zshrc / .bashrc / .whatever
alias rm="uvx rm-teng"

The only case that's currently handled is rm -rf {{ some-dir }}.

Configuration

Configuration is done via the following env vars:

  • RM_TENG_DELETION_DIR: Optional, controls where to store files that are relocated by rm-teng. If set it must be an absolute path. Default is ~/.rm_rf_files.
  • RM_TENG_DOUBLE_CHECK: Optional, controls whether to prompt for confirmation when running rm commands that don't have any handlers set. Default is false.

What it doesn't do

If used in the way outlined above rm-teng is only called when called interactively from the shell. It won't be called from scripts, and it won't be called from something like find . -type f | xargs rm (see https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Aliasing or similar if unfamiliar).

Cleaning up

When rm -rf {{ some-dir }} is run the directory is moved to ~/.rm_rf_files instead of being deleted. As a result a few entries can build up here.

rm-teng doesn't currently handle cleaning these up. It's pretty easy to do something along the lines of:

# Simple workflow to check what is in the {{ deleted-dir }} older than a certain
# time, and delete.

# check what's there
find . -mindepth 1 -type d -ctime +10 | less
# delete (if ok)
find . -mindepth 1 -maxdepth 1 -type d -ctime +10 -print0 | xargs -0 rm -rf

Hopefully a bit more mindfulness can be applied at this stage!

Restore deleted

Alternatively, you should be able to restore something by simply moving it back where it was.

E.g: if we have ~/one/two/three/four/five, then run rm -rf one it'll create:

{{ timestamp }}
└── Users
  └── user_name
    └── one
      └── two
        └── three
          └── four
            └── five

Then from ~/ you can run mv {{ rm-teng-dir }}/{{ timestamp }}/Users/user_name/one ./ to restore.

Alternative solutions

I've managed to find more of these after writing most of this, you might find one more suitable! rip2 and rm-protection (who I copied most of this list off) look nice, though I've not really used either:

Future development

I've had this running for a bit and have found it fine. Adding additional handlers should be pretty straightforward, it would also be easy to implement custom handlers for user specific settings.

Metadata

Release files for rm-teng 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rm-teng 1.0.3
File Size Uploaded Provenance
rm_teng-1.0.3.tar.gz 4.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rm-teng 1.0.3
File Interpreter ABI Platform
rm_teng-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / rm_teng-1.0.3.tar.gz

Download URL rm_teng-1.0.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7fb829744a356b490d83d874a10a756157b8b5af587c63940c2a1a714ded66ca
BLAKE2b-256 checksum
How to use checksums
a1cb9e9989526baa8c8d3d53c32fdfc6de398297746ea9a6c20c4773c0ace29b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 31, 2025.

Transparency log

Release files / rm_teng-1.0.3-py3-none-any.whl

Download URL rm_teng-1.0.3-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6aca82b951f1a1f9ceb6056f853154f0b9604d326022ae99fb22c897783e6a3
BLAKE2b-256 checksum
How to use checksums
ad7c20ea8162e80d69b95f201ec7d85bf8e5eb130bc14fe50d997ee899e4f33d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 31, 2025.

Transparency log

Security for rm-teng 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rm_teng-1.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 31, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page