• Stars
    star
    289
  • Rank 143,419 (Top 3 %)
  • Language
    Shell
  • License
    GNU General Publi...
  • Created almost 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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`

rmtrash 1.15

Put files (and directories) in trash using the trash-put command from trash-cli, in a way that (unlike trash-put itself) is compatible with GNU's rm and rmdir.

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. On macOS, you must install the gnu-getopt and coreutils packages using Homebrew.

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.

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 GNU's rm does, that means it accepts the following options (see --help):

  • Help options:

    • --help: display help and exit
    • --version: output version information and exit
  • Application options:

    • -f, --force: ignore nonexistent files, never prompt
    • -i: prompt before every removal
    • -I: prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving protection against most mistakes
    • --interactive[=WHEN]: prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompt always
    • --one-file-system: when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument
    • --no-preserve-root: do not treat / specially
    • --preserve-root: do not remove / (default)
    • -d, --dir: remove empty directories
    • -r, -R, --recursive: remove directories and their contents recursively
    • -v, --verbose: explain what is being done

Usage of rmdirtrash

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

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

  • Help options:

    • --help: display help and exit
    • --version: output version information and exit
  • Application options:

    • --ignore-fail-on-non-empty: ignore each failure that is solely because a directory is non-empty
    • -p, --parents: remove DIRECTORY and its ancestors; e.g., rmdirtrash -p a/b/c is similar to rmdirtrash a/b/c a/b a
    • -v, --verbose: output a diagnostic for every directory processed

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.

  • --forbid-root[=HOW]: forbid user root to trash files. When standard input is a terminal, ask-forbid and ask-pass will question the user to pass the command to /bin/rm. When standard input is no terminal, ask-forbid will abort the command, whereas ask-pass will pass the command to /bin/rm. Use pass to pass all commands of user root to /bin/rm without a query. If user root should never trash files, use always. In contrast, never treats root in no special way. Without HOW, ask-forbid is assumed

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, 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...

License & Copyright

Copyright (C) 2011-2023 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.

More Repositories

1

pico-file-prefixes

This is Pico's official file prefixes plugin to drop file prefixes from page URLs.
PHP
10
star
2

phpunit-array-asserts

Provides various array-related PHPUnit assertions, primarily used for API testing.
PHP
7
star
3

pico-admin

Pico's official admin plugin. http://picocms.org/ -- WORK IN PROGRESS - NOT YET USABLE
JavaScript
7
star
4

pico-robots

This is Pico's official robots plugin to add a robots.txt and sitemap.xml to your website. Pico is a stupidly simple, blazing fast, flat file CMS.
PHP
7
star
5

jQuery-Prettify

Use google-code-prettify to highlight sourecode with jQuery
JavaScript
5
star
6

cron-notify

FreeDesktop.org-compatible notification service to periodically ask for acknowledgement before executing a cronjob.
Python
5
star
7

pico-http-params

This is Pico's official HTTP parameters plugin to access GET and POST parameters in Twig templates.
PHP
4
star
8

cssmin

A (simple) css minifier with benefits.
PHP
2
star
9

awstats-update

Update AWStats database and/or generate static HTML pages
Shell
2
star
10

iblocksync

iblocksync incrementally syncs raw disk images.
Python
2
star
11

pico-excerpt

This is Pico's official plugin to create page excerpts. Pico is a stupidly simple, blazing fast, flat file CMS.
PHP
2
star
12

acme

Issue and renew Let's Encrypt TLS certificates using acme-tiny.
Shell
1
star
13

gh-workflow-immortality

Keeps cronjob based triggers of GitHub workflows alive.
Shell
1
star
14

mbutane

mbutane is a wrapper for Butane that merges multiple human-readable Butane Configs and translates them into machine-readable Ignition Configs.
Python
1
star
15

jQuery-XPath

Determine the XPath of an element with jQuery
JavaScript
1
star
16

phpunit-throwable-asserts

Provides various Throwable-related PHPUnit assertions.
PHP
1
star
17

pico-session

Pico's official utility plugin for session management. Pico is a stupidly simple, blazing fast, flat file CMS. -- WORK IN PROGRESS - NOT YET USABLE
PHP
1
star
18

pico-parse-pages-content

This is Pico's official plugin to parse the contents of all pages. Pico is a stupidly simple, blazing fast, flat file CMS.
PHP
1
star