Ask HN: How do you use rm safely or which trash utility are you using?

I accidentally rmed files which I had not committed to a repo. I tested several other utilities which should send the files.

a) trash-cli python - didn't work, I got some error

b) nodejs one - worked but the files sent to trash have uuid as its name and it's not recognizable.

Which trash utility do you use?

  • You haven’t specified your OS, but on macOS I use `trash`[1] (`brew install trash`). Files are deleted by default using the Finder API, which means you still hear the trashing sound and can use the ā€œPut Backā€ feature, as well as ⌘Z to get them back.

    [1]: http://hasseg.org/trash/

  • Another alternative is to not use 'rm' day-to-day to delete files. Alias "del" to "rm -i" and force the habit of using "del" to delete. You will then be prompted per file (allowing you to avoid deleting those you don't want to delete). Then reserve use of raw 'rm' for only those times when you really mean to delete a file without prompting (and therefore, have hopefully thought about if you really want to delete these files for good).

  • Delete things using `git rm <file>`. If it's not been committed then you won't be able to delete it. If you want to actually remove the file before you commit it use the -f option.