GithubHelp home page GithubHelp logo

matbesancon / rip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nivekuil/rip

0.0 1.0 0.0 139 KB

A safe and ergonomic alternative to rm

License: GNU General Public License v3.0

Rust 78.58% Shell 21.42%

rip's Introduction

rip (Rm ImProved)

https://img.shields.io/crates/v/rm-improved.svg https://travis-ci.org/nivekuil/rip.svg?branch=master

rip is a command-line deletion tool focused on safety, ergonomics, and performance. It favors a simple interface, and does not implement the xdg-trash spec or attempt to achieve the same goals.

Deleted files get sent to the graveyard (/tmp/graveyard-$USER by default, see notes on changing this) under their absolute path, giving you a chance to recover them. No data is overwritten. If files that share the same path are deleted, they will be renamed as numbered backups.

rip is made for lazy people. If any part of the interface could be more intuitive, please open an issue or pull request.

⚰ Installation

Or get a binary release (Linux x86_64, ARMv7 and macOS), untar it, and move it somewhere on your $PATH:

$ tar xvzf rip-*.tar.gz
$ mv rip /usr/local/bin

or build it:

$ cargo install rm-improved

Arch Linux users can install it from the AUR (thanks @Charon77!)

$ yay -S rm-improved

⚰ Usage

USAGE:
    rip [FLAGS] [OPTIONS] [TARGET]...

FLAGS:
    -d, --decompose    Permanently deletes (unlink) the entire graveyard
    -h, --help         Prints help information
    -i, --inspect      Prints some info about TARGET before prompting for action
    -s, --seance       Prints files that were sent under the current directory
    -V, --version      Prints version information

OPTIONS:
        --graveyard <graveyard>    Directory where deleted files go to rest
    -u, --unbury <target>       Undo the last removal by the current user, or specify some file(s) in the graveyard.  Combine with -s to restore everything printed by -s.

ARGS:
    <TARGET>...    File or directory to remove

Basic usage – easier than rm

$ rip dir1/ file1

Undo the last deletion

$ rip -u
Returned /tmp/graveyard-jack/home/jack/file1 to /home/jack/file1

Print some info (size and first few lines in a file, total size and first few files in a directory) about the target and then prompt for deletion

$ rip -i file1
dir1: file, 1337 bytes including:
> Position: Shooting Guard and Small Forward ▪ Shoots: Right
> 6-6, 185lb (198cm, 83kg)
Send file1 to the graveyard? (y/n) y

Print files that were deleted from under the current directory

$ rip -s
/tmp/graveyard-jack/home/jack/file1
/tmp/graveyard-jack/home/jack/dir1

Name conflicts are resolved

$ touch file1
$ rip file1
$ rip -s
/tmp/graveyard-jack/home/jack/dir1
/tmp/graveyard-jack/home/jack/file1
/tmp/graveyard-jack/home/jack/file1~1

-u also takes the path of a file in the graveyard

$ rip -u /tmp/graveyard-jack/home/jack/file1
Returned /tmp/graveyard-jack/home/jack/file1 to /home/jack/file1

Combine -u and -s to restore everything printed by -s

$ rip -su
Returned /tmp/graveyard-jack/home/jack/dir1 to /home/jack/dir1
Returned /tmp/graveyard-jack/home/jack/file1~1 to /home/jack/file1~1

Emacs

(setq delete-by-moving-to-trash t)
(defun system-move-file-to-trash (filename)
  (shell-command (concat (executable-find "rip") " " filename)))

⚰ Notes

  • You probably shouldn’t alias rm to rip. Unlearning muscle memory is hard, but it’s harder to ensure that every rm you make (as different users, from different machines and application environments) is the aliased one.
  • If you have $XDG_DATA_HOME environment variable set, rip will use $XDG_DATA_HOME/graveyard instead of the /tmp/graveyard-$USER.
  • If you want to put the graveyard somewhere else (like ~/.local/share/Trash), you have two options, in order of precedence:
    1. Alias rip to rip --graveyard ~/.local/share/Trash
    2. Set the environment variable $GRAVEYARD to ~/.local/share/Trash.

    This can be a good idea because if the graveyard is mounted on an in-memory filesystem (as /tmp is in Arch Linux), deleting large files can quickly fill up your RAM. It’s also much slower to move files across filesystems, although the delay should be minimal with an SSD.

  • In general, a deletion followed by a --unbury should be idempotent.
  • The deletion log is kept in .record, found in the top level of the graveyard.

rip's People

Contributors

nivekuil avatar siborgium avatar palfrey avatar adelarsq avatar

Watchers

James Cloos avatar

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.