#rm #trash #removing #file #directories #command #path

bin+lib rmsafe

safely removing files and directories; moving them to trash

19 stable releases

new 2.4.6 May 20, 2024
2.4.5 Nov 6, 2023
2.4.4 Oct 16, 2023
2.3.0 Jan 18, 2023
1.6.5 Nov 27, 2022

#346 in Filesystem

Download history 1/week @ 2024-02-21 268/week @ 2024-02-28 37/week @ 2024-03-06 3/week @ 2024-03-13 1/week @ 2024-03-27 3/week @ 2024-04-03

1,284 downloads per month

MIT license

21KB
503 lines

rmsafe (remove_safely)

Introduction

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.

Basics

Instead of just rm(ing) files and folders, they instead are moved to the local trash or custom path location.

Installation

cargo install rmsafe

Usage

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

Contribution

Open up an issue on GitHub and I'll be in touch!

Dependencies

~2.9–4MB
~72K SLoC