- Ability to list files under current directory with
$GRAVEYARD
removed. For example:
/Users/$USER/.local/share/graveyard/Users/$USER/test/colored
# Transforms to
/Users/$USER/test/colored
- Ability to list all files that are removed (both with and without
$GRAVEYARD
) not just files under current directory.
- Integrate
fzf
in a better way
- Display timestamps
- Maybe remove individual files from the
$GRAVEYARD
with glob
- Better completion output (current do not work properly)
- Use globs to return files, and prevent having to use full path
- Ability to restore file in local directory by just mentioning file name
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.
Get a binary release
- Linux
x86_64
ARMv7
macOS
untar
it, and move it somewhere on your $PATH
:
$ tar xvzf rip-*.tar.gz
$ mv rip /usr/local/bin
$ cargo install rm-improved
$ git clone https://github.com/lmburns/rip
$ 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
$ brew install rm-improved
USAGE:
rip [FLAGS] [OPTIONS] [TARGET]...
ARGS:
<TARGET>... File or directory to remove
FLAGS:
-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
OPTIONS:
-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)
$ rip dir1/ file1
$ rip -u
Returned /Users/jack/.local/share/graveyard/Users/jack/file1 to /Users/jack/file1
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
These two options can be used with -p
to prevent displaying index and time, and/or -N
to not display colored output.
$ rip -s
0 - [2021-07-31 16:40:45] /Users/jack/file1
1 - [2021-07-31 18:21:23] /Users/jack/dir1
$ 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
$ 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
$ 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
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
$ rip -u /Users/jack/file1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/file1 to /Users/jack/file1
$ rip -s
0 - [2021-07-31 16:40:45] /Users/jack/folder/folder2/file1
$ pwd
/Users/jack/folder
$ rip -lu folder2/file1
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/folder/folder2/file1 to /Users/jack/folder/folder2/file1
$ rip -s
0 - [2021-07-31 16:40:45] /Users/jack/folder/folder2/file1
$ pwd
/Users/jack/folder
$ rip -lu
Returned /Users/jack/.local/share/graveyard-jack/Users/jack/folder/folder2/file1 to /Users/jack/folder/folder2/file1
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
$ 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)))
- You probably shouldn't alias
rm
torip
.- 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're using
zsh
, it is possible to create azsh
function like the following and add it to yourfpath
. This allows the user to userm
asrip
, but if you typesudo
, then it will use the actualrm
command.
- Unlearning muscle memory is hard, but it's harder to ensure that every
[[ $EUID -ne 0 ]] && rip "${@}" || command rm -I -v "${@}"
- 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) 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.
- 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.