Skip to main content

Add your description here

Project description

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.

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

rm_teng-1.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

rm_teng-1.0.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file rm_teng-1.0.3.tar.gz.

File metadata

  • Download URL: rm_teng-1.0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rm_teng-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7fb829744a356b490d83d874a10a756157b8b5af587c63940c2a1a714ded66ca
MD5 9a7fceab5c9bdcfbb3db468c6d3ad87f
BLAKE2b-256 a1cb9e9989526baa8c8d3d53c32fdfc6de398297746ea9a6c20c4773c0ace29b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rm_teng-1.0.3.tar.gz:

Publisher: release.yml on geo7/rm-teng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rm_teng-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: rm_teng-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rm_teng-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d6aca82b951f1a1f9ceb6056f853154f0b9604d326022ae99fb22c897783e6a3
MD5 d98a66b52abbd81e1f14f2adcb541254
BLAKE2b-256 ad7c20ea8162e80d69b95f201ec7d85bf8e5eb130bc14fe50d997ee899e4f33d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rm_teng-1.0.3-py3-none-any.whl:

Publisher: release.yml on geo7/rm-teng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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