All Projects → rcmdnk → trash

rcmdnk / trash

Licence: other
Remove Command using a trash box.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to trash

wastebasket
A crossplatform go library for moving files to the trashbin
Stars: ✭ 30 (+57.89%)
Mutual labels:  trash
Trash
Move files and directories to the trash
Stars: ✭ 2,293 (+11968.42%)
Mutual labels:  trash
ioBroker.trashschedule
Calculates trash pickup dates by using an ical calendar
Stars: ✭ 20 (+5.26%)
Mutual labels:  trash
SharpLoader
🔮 [C#] Source code randomizer and compiler
Stars: ✭ 36 (+89.47%)
Mutual labels:  trash
rmw
a safe-remove utility for the command line
Stars: ✭ 48 (+152.63%)
Mutual labels:  trash
nvidialinuxdriversaretrash.github.io
An aggregate void to yell into about Nvidia's terrible Linux drivers!
Stars: ✭ 20 (+5.26%)
Mutual labels:  trash
trash-d
A near drop-in replacement for rm that uses the trash bin. Written in D
Stars: ✭ 90 (+373.68%)
Mutual labels:  trash
VsCacheCleaner
🧹 Clear the Visual Studio solution cache, free up your disk space!
Stars: ✭ 69 (+263.16%)
Mutual labels:  trash
homeassistant-afvalwijzer
Provides sensors for some Dutch waste collectors
Stars: ✭ 119 (+526.32%)
Mutual labels:  trash
osx-trash
Make Emacs' delete-by-moving-to-trash do what you expect it to do on OS X.
Stars: ✭ 22 (+15.79%)
Mutual labels:  trash
del-webpack-plugin
A file plugin help you remove old files after webpack (v5) bundling
Stars: ✭ 43 (+126.32%)
Mutual labels:  trash
detect-waste
AI to Combat Environmental Pollution - detecting plastic waste in the environment to combat environmental pollution and promote circular economy (Deep Learning, PyTorch)
Stars: ✭ 113 (+494.74%)
Mutual labels:  trash

trash

Remove Command using a trash box.

rm command removes files/directories from the disk and they are not recoverable. It is stressful because we are used to benefit from the trash box on a GUI system, Windows, Mac, Linux, etc..

trash command brings you the removal command with recoverable files/directories.

current version requires sentaku.

If you use Homebrew or cURL to insatll, sentaku will be installed automatically, too.

If you install the script directly, please install sentaku or use standalone version (standalone version could be obsolete).

Installation

On Mac, you can install scripts by Homebrew:

$ brew tap rcmdnk/rcmdnkpac
$ brew install rcmdnk-trash

If you have brew-file, add following lines to Brewfile:

tap 'rcmdnk/rcmdnkpac'
brew 'rcmdnk-trash'

then, do:

$ brew file install

Or if you write like:

tapall 'rcmdnk/rcmdnkpac'

and do brew file install, you will have all useful scripts in rcmdnkpac.

You can also use an install script on the web like:

$ curl -fsSL https://raw.github.com/rcmdnk/trash/install/install.sh| sh

This will install scripts to /usr/bin and you may be asked root password.

If you want to install other directory, do like:

$ curl -fsSL https://raw.github.com/rcmdnk/trash/install/install.sh|  prefix=~/usr/local/ sh

Or, simply download the script and set where you like.

⚠️ Install sentaku, too if you download directly.

Usage

# Help
Usage: trash [-rficClbV] [-v <verbose level>] [-t <trash_box>] <file/directory>

Arguments:
   -r              Remove directory (default: 0)
   -f              Do not ask when file/directory is removed directly
                   Do not return error even if file/directory does not exist
                   -f ignores previous -i option
   -i              Remove w/ confirmation
                   -i ignores previous -f option
   -t <trash_box>  Use given trash box instead of $tbox
   -c              Clean up trash box (make it less than MAXTRASHBOXSIZE)
   -C              Clean up trash box (make it empty)
   -l              List up deleted files/directories in the trash box
   -b              Restore (turn Back) the file from the trash box
   -v <level>      Verbose level for list view
                   0 : Only original location (default).
                   1 : With Delete date-time (yyyymdd-hh:mm).
                   2 : With Current location (in the trash box).
   -V              Show version
   -h              Show help

To use trash, please specify following variables
in .bashrc or your setting file like (these rh values are default):

At restore mode, you can use following keys (based on vim move):
 <n>   : (any numb), set n for move
 j     : n-down (if n is not defined, 1 down)
 ^D    : Half page down
 ^F    : Page down
 k     : n-up   (if n is not defined, 1 up)
 ^U    : Half page up
 ^B    : Page up
 gg    : Go to top    (if n is defined, go to n)
 G     : Go to bottom (if n is defined, go to n)
 d     : Delete
 s     : Show details
 /     : Search mode
 Enter : Select to bring back to the original place, and quit
 h     : Select to copy it to current directory, and quit
 q     : Quit

export TRASHLIST=~/.trashlist # Where trash list is written
export TRASHBOX=~/.Trash # Where trash will be moved in
                         # (.Trash is Mac's trash box)
export MAXTRASHBOXSIZE=1024 # Max trash box size in MB
                            # Used for clean up
export MAXTRASHSIZE=\`echo \$MAXTRASHBOXSIZE \"*\" 0.1|bc -l|cut -d. -f1\`
    # Trashes larger than MAXTRASHBOXSIZE will be removed by 'rm' directly
"

Tips

Alias

Following alias is useful to use trash:

alias del="trash -i -r" # Do not confirm, remove directory, too

Clean up

You may be want to clean up trash box regularly to keep the box not too much.

To clean up regularly, first please set MAXTRASHBOXSIZE as described in above help.

Then, trash -c will clean up the trash box until it becomes less than MAXTRASHSIZE.

You can set it as a cron job like:

0 1 * * * /path/to/trash -c

to execute every night (1am, 00min).

In addition, you can empty your trash box for trash by

$ trash -C

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].