rmtrash

Put files (and directories) in trash using the `trash-put` command in a way that is, otherwise as `trash-put` itself, compatible to GNUs `rm` and `rmdir`

View on GitHub

rmtrash 1.13

Put files (and directories) in trash using the trash-put command in a way that is, otherwise as trash-put itself, compatible to GNUs rm and rmdir.

Click here for more information about trash-cli.

Installation

Just download both scriptfiles (rmtrash and rmdirtrash) and put them in /usr/local/bin. If you’re using Arch Linux, you can also use the AUR package.

If you don’t want to readjust the usage of rm and rmdir, a bash alias is probably a great solution for you. Just add the lines

alias rm='rmtrash'
alias rmdir='rmdirtrash'
alias sudo='sudo '

to your ~/.bashrc (or ~/.bash_aliases). Consider adding the --forbid-root option (see replacement option below)! The last line is optional, without you’ll notice that rmtrash and rmdirtrash won’t be called when using sudo.

Installation on Fedora, CentOS or RHEL

Download and install RPM package from here or from here

Otherwise you can install thru dnf by following these steps:

Requirements

Obviously trash-cli (to provide the trash-put or trash command) is required. rmtrash and rmdirtrash should work great with any distribution. If rmtrash or rmdirtrash doesn’t work with your favourite distribution, please file a bug report. It was written to work with bash.

You wanna make rmtrash and rmdirtrash work with your favorite distribution or improve them in general? Go on, I appreciate it!

Usage of rmtrash

rmtrash [OPTION]... [FILE...]

rmtrash supports everything that GNUs rm does, that means it accepts the following options (see --help):

Usage of rmdirtrash

rmdirtrash [OPTION]... [DIRECTORY...]

rmdirtrash supports everything that GNUs rmdir does, that means it accepts the following options (see --help):

Replacement option

This option is not supposed to be used when calling rmtrash resp. rmdirtrash. It helps you to control how and in which cases rm resp. rmdir are replaced. Without --forbid-root, root isn’t treated specially.

Additional Notes

For additional information see the trash-list (or list-trash), trash-empty (or empty-trash), trash-restore (or restore-trash) and trash-rm commands provided by trash-cli (Homepage) as well as the FreeDesktop.org Trash Specification. Note trash-put --help (or trash --help) and rm --help, too.

A important note about execution time: rmtrash is pretty slow! Because we’re indexing all containing files before actually building the trash command (and because it’s just a shell script), it is pretty slow when trashing many files. If you want to remove a very large directory (in terms of many files), consider using trash-put or rm directly. Never name rmtrashs scriptfile rm - this will replace rm and is definitly not what you actually want! Use a bash alias as described above. The same applies to rmdirtrash.

Typically you won’t notice a time delay when using rmtrash and rmdirtrash, but now you know that there is a time delay…

Copyright (C) 2011-2019 Daniel Rudolf https://www.daniel-rudolf.de/

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License only.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.