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 byrm-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 runningrmcommands that don't have any handlers set. Default isfalse.
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:
- https://github.com/Byron/trash-rs
- https://github.com/MilesCranmer/rip2
- https://github.com/alanzchen/rm-protection
- https://github.com/andreafrancia/trash-cli
- https://github.com/hitzhangjie/rm
- https://github.com/kaelzhang/shell-safe-rm (bash)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fb829744a356b490d83d874a10a756157b8b5af587c63940c2a1a714ded66ca
|
|
| MD5 |
9a7fceab5c9bdcfbb3db468c6d3ad87f
|
|
| BLAKE2b-256 |
a1cb9e9989526baa8c8d3d53c32fdfc6de398297746ea9a6c20c4773c0ace29b
|
Provenance
The following attestation bundles were made for rm_teng-1.0.3.tar.gz:
Publisher:
release.yml on geo7/rm-teng
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rm_teng-1.0.3.tar.gz -
Subject digest:
7fb829744a356b490d83d874a10a756157b8b5af587c63940c2a1a714ded66ca - Sigstore transparency entry: 785363421
- Sigstore integration time:
-
Permalink:
geo7/rm-teng@039164c1c7e4a957b670ea6922b4e9d88c882c5a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/geo7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@039164c1c7e4a957b670ea6922b4e9d88c882c5a -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6aca82b951f1a1f9ceb6056f853154f0b9604d326022ae99fb22c897783e6a3
|
|
| MD5 |
d98a66b52abbd81e1f14f2adcb541254
|
|
| BLAKE2b-256 |
ad7c20ea8162e80d69b95f201ec7d85bf8e5eb130bc14fe50d997ee899e4f33d
|
Provenance
The following attestation bundles were made for rm_teng-1.0.3-py3-none-any.whl:
Publisher:
release.yml on geo7/rm-teng
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rm_teng-1.0.3-py3-none-any.whl -
Subject digest:
d6aca82b951f1a1f9ceb6056f853154f0b9604d326022ae99fb22c897783e6a3 - Sigstore transparency entry: 785363426
- Sigstore integration time:
-
Permalink:
geo7/rm-teng@039164c1c7e4a957b670ea6922b4e9d88c882c5a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/geo7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@039164c1c7e4a957b670ea6922b4e9d88c882c5a -
Trigger Event:
push
-
Statement type: