Crates.io | rmsafe |
lib.rs | rmsafe |
version | 2.5.0 |
source | src |
created_at | 2022-11-25 04:04:54.520541 |
updated_at | 2024-05-26 04:09:42.466609 |
description | safely removing files and directories; moving them to trash |
homepage | |
repository | https://github.com/frroossst/rmsafe |
max_upload_size | |
id | 722561 |
size | 41,229 |
After (almost) accidentally removing a file with about week's worth of changes for my C lang assignment, I took it as an excuse to lear a bit more of Rust and re-write the rm command.
Instead of just rm(ing) files and folders, they instead are moved to the local trash or custom path location.
cargo install rmsafe
NOTE: I have only tested this on Linux Mint 20.3.
// view trashcan path
rmsafe
// removing a single file
rmsafe test.txt
// removing a single folder; it will recursively move the folder to trash
rmsafe test_dir
// removing files with wildcard matching; removing all files ending with .o
rmsafe -r "*.o"
// change trashcan path
rmsafe -t "/home/jane/Desktop/.rmsafe"
Change your .bashrc
to include the following
alias rm='printf "Avoid using rm!"'
alias rms="rmsafe"
This disallows the use of rm, you can still use sudo rm
and not setting rmsafe to rm
ensures that you don't accidentally rm while on someone else's computer
NOTE: The shell might interpret wildcards before they are passed down as function arguments which might cause problems, best to disable wildcard expansion on the shell
Open up an issue on GitHub and I'll be in touch!