rip (Rm ImProved) travis-ci


Goals of Fork:

# Transforms to
  1. Integrate fzf in a better way
  1. Maybe remove individual files from the $GRAVEYARD with glob

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 ($XDG_DATA_HOME/graveyard if set, else /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

Get a binary release

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

Installing this fork

$ git clone
$ cd rip
$ cargo build --release && mv target/release/rip ~/bin

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

    rip [FLAGS] [OPTIONS] [TARGET]...

    <TARGET>...    File or directory to remove

    -a, --all          Prints all files in graveyard
    -d, --decompose    Permanently deletes (unlink) the entire graveyard
    -f, --fullpath     Prints full path of files under current directory (with -s)
    -h, --help         Prints help information
    -i, --inspect      Prints some info about TARGET before prompting for action
    -l, --local        Undo files in current directory (local to current directory)
    -N, --no-color     Do not use colored output (in progress)
    -p, --plain        Prints only file-path (to be used with scripts)
    -s, --seance       Prints files that were sent under the current directory
    -v, --verbose      Print what is going on
    -V, --version      Prints version information

    -G, --graveyard <graveyard>    Directory where deleted files go to rest
    -m, --max-depth <max-depth>    Set max depth for glob to search (default: 10)
    -u, --unbury <target>          Undo the last removal, or specify some file(s) in the graveyard.
                                   Can be glob, or combined with -s (see --help)

Basic usage -- easier than rm

$ rip dir1/ file1

Undo the last deletion

$ rip -u
Returned /Users/jack/.local/share/graveyard/Users/jack/file1 to /Users/jack/file1

Print some info

Print the size and first few lines in a file, total size and first few files in a directory, 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

These two options can be used with -p to prevent displaying index and time, and/or -N to not display colored output.

Shortened path to buried file (by default, under current directory)
$ rip -s
0  - [2021-07-31 16:40:45] /Users/jack/file1
1  - [2021-07-31 18:21:23] /Users/jack/dir1
Full path to buried file (under current directory)
$ rip -sf
0  - [2021-07-31 16:40:45] /Users/jack/.local/share/graveyard-jack/Users/jack/file1
1  - [2021-07-31 18:21:23] /Users/jack/.local/share/graveyard-jack/Users/jack/dir1
Shortened path to buried file (all)
$ rip -sa
0  - [2021-07-31 16:40:45] /Users/jack/file1
1  - [2021-07-31 18:21:23] /Users/jack/dir1
2  - [2021-07-31 18:48:49] /usr/local/share/dir1
3  - [2021-07-31 19:09:41] /usr/local/share/dir2

Name conflicts are resolved

$ touch file1
$ rip file1
$ rip -s
0  - [2021-07-31 16:40:45] /Users/jack/file1
1  - [2021-07-31 18:21:23] /Users/jack/dir1
2  - [2021-07-31 18:22:34] /Users/jack/file1~1

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

Full path (including $GRAVEYARD)

This option is mainly here for compatibility with scripts or anything else that uses older versions.

$ rip -u /Users/jack/.local/share/graveyard-jack/Users/jack/file1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/file1 to /Users/jack/file1
Full path (from $HOME)
$ rip -u /Users/jack/file1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/file1 to /Users/jack/file1
Specifying file local to current directory
$ rip -s
0  - [2021-07-31 16:40:45] /Users/jack/folder/folder2/file1
$ pwd
$ rip -lu folder2/file1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/folder/folder2/file1 to /Users/jack/folder/folder2/file1
Most recent file local to current directory
$ rip -s
0  - [2021-07-31 16:40:45] /Users/jack/folder/folder2/file1
$ pwd
$ rip -lu
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/folder/folder2/file1 to /Users/jack/folder/folder2/file1
A glob pattern

A glob is detected if an asterisk is used. A max-depth can be specified using -m or --max-depth

$ rip -s
0  - [2021-07-31 16:40:45] /Users/jack/folder/folder2/file1
1  - [2021-07-31 18:21:23] /Users/jack/dir1
2  - [2021-07-31 18:22:34] /Users/jack/file2

$ rip -u '*file*'
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/folder/folder2/file1 to /Users/jack/folder/folder2/file1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/file2 to /Users/jack/file2

NOTE: Glob patterns can consist of: * *glob, !*glob * **glob, !**glob - Traverse many directories (however, --max-depth should probably be used for this) * *.{png.jpg,jpeg}, !*.{png.jpg,jpeg} - Multiple patterns * The ! negates the pattern

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

$ rip -su
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/dir1 to /Users/jack/dir1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/file1~1 to /Users/jack/file1~1


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

⚰ Notes

[[ $EUID -ne 0 ]] && rip "${@}" || command rm -I -v "${@}"
# 1) Aliasing rip
alias rip="rip --graveyard $HOME/.local/share/Trash"

# 2) Set environment variable
export GRAVEYARD="$HOME/.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 file-systems, although the delay should be minimal with an SSD.