GithubHelp home page GithubHelp logo

evysgarden / trashy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oberblastmeister/trashy

0.0 0.0 0.0 613 KB

a cli system trash manager, alternative to rm and trash-cli

License: Apache License 2.0

Rust 97.66% Nix 2.34%

trashy's Introduction

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 trash 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

$ trash first second third

This is just sugar for

$ trash put first second third

List items in the trash

$ trash list

Restore or empty some files

$ trash restore first second
$ trash 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

$ trash restore --all
$ trash empty --all

Integrations

fzf

Restore with fzf

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

Empty with fzf

trash list | fzf --multi | awk '{$1=$1;print}' | rev | cut -d ' ' -f1 | rev | xargs trash 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

niv-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 trash 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 'trash 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='trash 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 trash 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.