0
Fork 0
mirror of https://github.com/oberblastmeister/trashy.git synced 2024-07-14 12:02:26 +02:00
[Mirror] A CLI system trash manager, alternative to rm and trash-cli
Go to file
2024-01-18 21:18:44 -05:00
.github Rename executable to trashy (#104) (#106) 2023-10-24 20:50:07 -04:00
doc add demo 2022-08-08 11:22:30 -04:00
src Rename executable to trashy (#104) (#106) 2023-10-24 20:50:07 -04:00
.gitignore rewrite using new trash library (#7) 2022-07-17 17:36:10 -04:00
Cargo.lock version bump trash to 3.0.6 (#101) 2023-10-03 07:58:17 -04:00
Cargo.toml Rename executable to trashy (#104) (#106) 2023-10-24 20:50:07 -04:00
CHANGELOG.md Rename executable to trashy (#104) (#106) 2023-10-24 20:50:07 -04:00
flake.lock add nix flake files (#102) 2023-10-03 07:58:43 -04:00
flake.nix add nix flake files (#102) 2023-10-03 07:58:43 -04:00
LICENSE-APACHE rename license 2022-08-07 17:51:27 -04:00
LICENSE-MIT Add LICENSE-MIT 2022-07-17 17:44:40 -04:00
README.md Fix typo in README command. (#112) 2024-01-18 21:18:44 -05:00
rustfmt.toml remove uneeded code 2022-08-08 10:59:24 -04:00

trashy

Build Status

trashy is a simple, fast, and featureful alternative to rm and trash-cli written in rust.

Quick links:

Demo

demo

Features

  • easy to use, just run trashy put PATH
  • recursive by default, without having the issues
  • beautiful output
    • colorized paths (similar to fd)
    • cool tables
  • very fast, and faster than trash-cli (see benchmarks)
  • much safer than rm -rf
  • intuitive syntax and fine grained control
  • uses the system trash on both linux and windows

Usage

Trash a path

$ trashy first second third

This is just sugar for

$ trashy put first second third

List items in the trash

$ trashy list

Restore or empty some files

$ trashy restore first second
$ trashy empty first second third

The restore and empty subcommands both take very similar arguments and flags.

By default the arguments for restore and empty are interpreted as regular expressions. Use the -m option to interpret them differently.

Restore or empty all files

$ trashy restore --all
$ trashy empty --all

Integrations

fzf

Restore with fzf

trashy list | fzf --multi | awk '{$1=$1;print}' | rev | cut -d ' ' -f1 | rev | xargs trashy restore --match=exact --force

Empty with fzf

trashy list | fzf --multi | awk '{$1=$1;print}' | rev | cut -d ' ' -f1 | rev | xargs trashy empty --match=exact --force

Installation

Using cargo

cargo install trashy

From Github Releases

Download the binary from Github Releases and put it in your $PATH.

From the AUR

Use your favorite AUR helper.

paru -S trashy

Using Nix

nix-env -i trashy

Or if you have flakes enabled:

nix profile install nixpkgs#trashy

Benchmarks

These benchmarks are run on the rust compiler source in the compiler/ directory. The directory has about 2000 files. The benchmarks are run using hyperfine.

Running put on each file in the compiler/ directory recursively.

hyperfine -M 1 'fd -t f --threads 1 -x trash-put'
Time (abs ≡):        65.849 s               [User: 54.383 s, System: 11.370 s]

Now with trashy

hyperfine -M 1 'fd -t f --threads 1 -x trashy put'
Time (abs ≡):         4.822 s               [User: 2.014 s, System: 2.918 s]

trashy has practically zero startup time, while trash-cli has a large startup time because it is written in python. This difference in startup time causes massive speed differences when used in scripts. The benchmark shows that trashy is about 13 times faster!

Listing the previously trashed items

hyperfine 'trash-list'
Time (mean ± σ):     383.7 ms ±  10.5 ms    [User: 321.8 ms, System: 59.4 ms]
Range (min … max):   375.9 ms … 412.0 ms    10 runs
hyperfine 'trashy list'
Time (mean ± σ):     178.3 ms ±   1.9 ms    [User: 135.7 ms, System: 40.4 ms]
Range (min … max):   175.6 ms … 181.0 ms    16 runs

trashy is faster by more than 2 times.

FAQ

Is this supported on MacOS?

No, see this issue

Should I alias rm='trashy put'?

You should not. The alias will not be present on other systems and habits are really hard to break. An alternative is to alias trashy put to rt or tp.

License

Copyright (c) 2020 Brian Shu

trashy is distributed under the terms of both the MIT license and the Apache License 2.0.

See the LICENSE-APACHE and LICENSE-MIT