rip is a command-line deletion tool focused on safety, ergonomics, and performance

Related tags

Command-line trash
Overview

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

macOS users can install it with Homebrew:

$ brew install 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     Directory where deleted files go to rest
    -u, --unbury        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:
    ...    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.
Comments
  • Use

    Use "$XDG_DATA_HOME/graveyard" if possible

    Use XDG_DATA_HOME environment variable if the variable is set and no other options like GRAVEYARD or '--graveyard=' were specified. In such case use "$XDG_DATA_HOME/graveyard" as graveyard. Since XDG_* variables are user-specific, there is no reason to append username to the name of graveyard folder.

    opened by Siborgium 3
  • Issues when removing a symbolic link pointing to a directory

    Issues when removing a symbolic link pointing to a directory

    When removing a symbolic link pointing to a directory, I expect rip to behave like rm which remove the symbolic link itself. However, rip removes the physical directory instead.

    opened by dclong 2
  • rip seems not to respect XDG_DATA_HOME

    rip seems not to respect XDG_DATA_HOME

    Fantastic tool! Works great overall, just one minor quibble: XDG_DATA_HOME seems to not work.

    Linux 4.15.0-50-generic #54-Ubuntu x86_64 GNU/Linux
    Distributor ID:	Ubuntu
    Description:	Ubuntu 18.04.1 LTS
    Release:	18.04
    Codename:	bionic
    
    rip 0.12.0
    
    

    I have XDG_DATA_HOME set to /home/mike/.local/share. Rip is still sending files to /tmp/graveyard-mike.

    Thanks!

    opened by xkortex 2
  • Can't compile with new nightly

    Can't compile with new nightly

    $ rustc +nightly --version
    rustc 1.32.0-nightly (14997d56a 2018-12-05)
    $ cargo +nightly install rm-improved
        Updating crates.io index
      Installing rm-improved v0.11.4
       Compiling libc v0.2.45
       ...more "Compiling" lines
       Compiling error-chain v0.8.1
       Compiling rm-improved v0.11.4
    error[E0463]: can't find crate for `alloc_system`
     --> /home/paul/.cargo/registry/src/github.com-1ecc6299db9ec823/rm-improved-0.11.4/src/main.rs:5:1
      |
    5 | extern crate alloc_system;
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: failed to compile `rm-improved v0.11.4`, intermediate artifacts can be found at `/tmp/cargo-installVQRbyH`
    
    Caused by:
      Could not compile `rm-improved`.
    
    To learn more, run the command again with --verbose.
    
    opened by pwoolcoc 2
  • Security

    Security

    In rip's current state, a normal user could (depending on kernel settings) trick arbitrary users into overwriting arbitrary files (either on delete or restore).

    You need to make separate graveyards per-user and rip needs to make sure that each user graveyard is owned and writable by the user and only by the user. Alternatively, you could use setuid and run rip as root (and do some very careful permission checks) but that's very hard to do correctly. You could also run a rip daemon as root but that would complicate things.

    opened by Stebalien 2
  • Note macOS Homebrew install in README

    Note macOS Homebrew install in README

    Resolves #14. ~~This is conditional based on https://github.com/Homebrew/homebrew-core/pull/64107/ merging, so I am leaving it as a draft until then.~~ rm-improved is now available via Homebrew.

    opened by knowler 1
  • Fix travis build

    Fix travis build

    Build was broken because the uninstall path was wrong. Simpler option is just not to have Rust installed at all by using the generic image :) I've also upgraded the travis config to more modern options.

    opened by palfrey 1
  • Archlinux AUR installation

    Archlinux AUR installation

    Hi, I've added this package to AUR as rm-improved (due to name conflict with rip). Feel free to include installation instruction in your README.

    Something like this:

    ArchLinux installation:

    Package can be installed from AUR. $ yay -S rm-improved

    opened by EvansJahja 1
  • /tmp might be a partition with small free space

    /tmp might be a partition with small free space

    What if /tmp is a partition with size x and you delete an file with size y and y > x? What if /tmp would be big enough for y, but only free space of size m is left and m < y?

    ~/.trash seems to be more appropriate.

    opened by StefanoD 1
  • Pipes and other non-regular files

    Pipes and other non-regular files

    The current behavior is to loudly fail when =rip= encounters a non-regular file, like those produced by =mkfifo= or =mknod=. Is there a safe and consistent way to deal with these?

    opened by nivekuil 1
  • Multiple users

    Multiple users

    Since the graveyard is stored in a globally accessible directory by default, all users get their files sent to the same directory. If rip -r as a normal user tries to restore something deleted from /root, it will throw an error.

    The proposed solution is to include the username in the histfile and limit rip -r to files owned by $USER. The current histfile structure is not flexible enough to support this, so it's probably best to make it an append-only log and implement a parsing algorithm (with stacks and such) for the resurrect option. The downsides are worse performance and disk usage, but these should be totally negligible.

    opened by nivekuil 0
  • Rip does not check if parent folders have the same name as deleted files

    Rip does not check if parent folders have the same name as deleted files

    If a file was deleted, and an item with a parent that has the same path of that file was also deleted, rip fail to delete the file.

    E.g., assuming graveyard is /trash and current folder is /:

    $ touch item
    $ rip item
    $ mkdir item
    $ touch item/file
    $ rip item/file
    error: Failed to bury file
    caused by: Failed to move /item/file to /trash/item/file
    caused by: Not a directory (os error 20)
    

    rip will try to move file to /trash/item/file, but does not check if /trash/item exists and is a file.

    opened by jeiang 0
  • Permissions error

    Permissions error

    error: Failed to write record at /Users/leontepe/.Trash/.record
    caused by: Operation not permitted (os error 1)
    

    System: macOS $GRAVEYARD: ~/.Trash

    It still deletes the file though—as in it's not present in the original location anymore after running the command.

    opened by ghost 0
  • Using as a stash

    Using as a stash

    It is not really an issue, so should be ok to close it. Just wanted to share my excitement in discovering this tool, as it looks perfect for my need to stash files.

    While working for eg. in a git repository or elsewhere, I end up creating some temporary files which doesn't really belong in the repository. At the same time, I don't feel like deleting them permanently as there is a chance I might need them sometime in distant future. But if I don't remove them the list of Untracked Files in git keeps increasing.

    So, I have added alias stash="rip --graveyard <my homedir>/stash". Rip will take care of keeping the backup, keeping multiple backups in case of conflicts and retaining the whole path. As a bonus, stash -s lets me see files stashed in current directory. So, thank you for this tool :)

    opened by amardeep 0
  • What happens if rip is interrupted?

    What happens if rip is interrupted?

    Suppose I use rip to move a large directory of files which takes a long time to finish. What happens if rip is interrupt before it finishes. Will any file be moved or will it leave nothing changed?

    opened by dclong 0
Releases(0.13.1)
Owner
Kevin Liu
Kevin Liu
CLI tool for mass tweet deletion

Damae Damae is a simple CLI tool for mass-deleting tweets. Its name comes from the Latin phrase "damnatio memoriae", which means "condemnation of memo

null 3 Jan 30, 2022
Unopinionated low level API bindings focused on soundness, safety, and stronger types over raw FFI.

?? firehazard ?? Create a fire hazard by locking down your (Microsoft) Windows so nobody can escape (your security sandbox.) Unopinionated low level A

null 5 Nov 17, 2022
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
XP rust rewrite "v8" with serenity, focused on maintainability, stability and performance.

XP v8 The official XP v8 rewrite built with Rust and serenity-rs. Contributions We're always looking for contributors! If you want to contribute, plea

XP Discord Bot 3 Aug 28, 2023
Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Andreas Nordal 4.3k Dec 28, 2022
An open source, programmed in rust, privacy focused tool for reading programming resources (like stackoverflow) fast, efficient and asynchronous from the terminal.

Falion An open source, programmed in rust, privacy focused tool for reading programming resources (like StackOverFlow) fast, efficient and asynchronou

Obscurely 17 Dec 20, 2022
Pink is a command-line tool inspired by the Unix man command.

Pink is a command-line tool inspired by the Unix man command. It displays custom-formatted text pages in the terminal using a subset of HTML-like tags.

null 3 Nov 2, 2023
A command line tool written in Rust and designed to be a modern build tool + package manager for C/C++ projects.

CCake CCake is a command line tool written in Rust and designed to be a modern build tool + package manager for C/C++ projects. Goals To be easily und

Boston Vanseghi 4 Oct 24, 2022
Explore from the safety of your shell

turtlescan Explore from the safety of your shell Installation: cargo install turtlescan tui Starts a little tui which connects to your JSON-RPC server

Brian Cloutier 4 Sep 13, 2022
Assignments of Stanford CS110L-2020spr: Safety in Systems Programming

CS110L Spring 2020: Safety in Systems Programming 课程简介 CS110L将带领我们学习 Rust ,这是一门注重 安全、性能、工程 的语言。 Why Rust? 我的浅显理解是:Rust 被设计出来旨在解决目前系统级编程的困难,其特征 “安全、性能、

Shaofeng 6 Dec 28, 2022
Nimbus - A virtual, networked filesystem with strong upfront safety guarantees

The Nimbus Filesystem Nimbus is a virtual, networked filesystem that provides upfront safety guarantees to a user, intended for personal use. In parti

Max Fan 3 Jan 10, 2023
Adds back-and-forth jumping between current and previous focused windows to Sway.

sway-focus-back-and-forth Implements back-and-forth movement between the current and the previous focused windows. It also can be seen as a fix to thi

Vinícius Müller 4 Aug 11, 2022
Command-line HTTP client for sending a POST request to specified URI on each stdin line.

line2httppost Simple tool to read lines from stdin and post each line as separate POST request to a specified URL (TCP connection is reused though). G

Vitaly Shukela 3 Jan 3, 2023
REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀

Information: REC2 is an old personal project (early 2023) that I didn't continue development on. It's part of a list of projects that helped me to lea

Quentin Texier (g0h4n) 104 Oct 7, 2023
H2O Open Source Kubernetes operator and a command-line tool to ease deployment (and undeployment) of H2O open-source machine learning platform H2O-3 to Kubernetes.

H2O Kubernetes Repository with official tools to aid the deployment of H2O Machine Learning platform to Kubernetes. There are two essential tools to b

H2O.ai 16 Nov 12, 2022
🍅 A command-line tool to get and set values in toml files while preserving comments and formatting

tomato Get, set, and delete values in TOML files while preserving comments and formatting. That's it. That's the feature set. I wrote tomato to satisf

C J Silverio 15 Dec 23, 2022
tmplt is a command-line interface tool that allows you to quickly and easily set up project templates for various programming languages and frameworks

tmplt A User Friendly CLI Tool For Creating New Projects With Templates About tmplt is a command-line tool that lets users quickly create new projects

Humble Penguin 35 Apr 8, 2023
YAML(ish) - Terminal UI framework based on templates focused on simplicity

A YAML(ish) based terminal GUI framework for- and by Rust, focussed on making it quick and easy to create a functional UI for an app or game. Based on Crossterm and inspired by Kivy.

null 27 Dec 18, 2022
Tight Model format is a lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.

What is Tight Model Format The main goal of the tmf project is to provide a way to save 3D game assets compressed in such a way, that there are no not

null 59 Mar 6, 2023