15 releases (8 breaking)
0.9.0 | Oct 22, 2024 |
---|---|
0.8.2 | Aug 12, 2024 |
0.8.1 | Jul 1, 2024 |
#564 in Command line utilities
78 downloads per month
45KB
877 lines
rip
is a rust-based rm
with a focus 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 🪦 (typically /tmp/graveyard-$USER
, 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.
This version, "rip2", is a fork-of-a-fork:
- nivekuil/rip, the original, which has been unmaintained since 2020.
- StandingPadAnimation/rip who added a few features.
- Finally, that repo was forked @here with ongoing maintenance:
- Expanded support: Windows, NixOS
- Cleanup: refactoring to modern rust, merging PRs from original repo
- Testing: add full test suite and coverage monitoring
- Style: colorful output, datetime info in seance
- Bug fixes: Fixed FIFO files, and an issue with seance
- Shell completions: bash, elvish, fish, powershell, zsh, and nushell (via clap)
- Safety: implemented flock to prevent races from concurrent processes
⚰️ Installation
This package is supported on Linux, macOS, and Windows.
Cargo
- First install Rust.
- Then, install this package with cargo:
$ cargo install --locked rip2
Binaries
Binary releases for different architectures and operating systems are made available on the GitHub releases page: https://github.com/MilesCranmer/rip2/releases/
To install, simply open the archive and move the binary somewhere you can run it.
Nix
This repository is flake-compatible, and backwards-compatible with non-flake systems. Just run the following to test it out:
nix develop "github:MilesCranmer/rip2"
Other
A few other package managers have contributed support:
Additional Nix options
The repo uses flake-compat
for compatibility, and naersk
to build the Rust package from source.
Details:
Add To Path Temporarily (With Flakes):
nix shell "github:MilesCranmer/rip2"
Flake minimal setup:
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rip2 = {
url = "github:MilesCranmer/rip2";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, rip2, ... }:
{
nixosConfigurations.your-host = let
system = "x86_64-linux"; # or your system
lib = nixpkgs.lib;
in lib.nixosSystem {
inherit system;
modules = [
./configuration.nix # or other configuration options
# ...
{
environment.systemPackages = [
rip2.packages.${system}.default
];
}
];
};
};
}
openSUSE
zypper ar -f obs://utilities
zypper in rip2
Usage
Usage: rip [OPTIONS] [FILES]...
rip [SUBCOMMAND]
Arguments:
[FILES]... Files and directories to remove
Options:
--graveyard <GRAVEYARD> Directory where deleted files rest
-d, --decompose Permanently deletes the graveyard
-s, --seance Prints files that were deleted in the current directory
-u, --unbury Restore the specified files or the last file if none are specified
-i, --inspect Print some info about TARGET before burying
-h, --help Print help
-V, --version Print version
Sub-commands:
completions Generate shell completions file
graveyard Print the graveyard path
help Print this message or the help of the given subcommand(s)
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
Notes
Aliases.
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.
What I instead recommend is aliasing rm
to an echo statement that simply reminds you to use rip
:
alias rm="echo Use 'rip' instead of rm."
Graveyard location.
You can see the current graveyard location by running rip graveyard
.
If you have $XDG_DATA_HOME
environment variable set, rip
will use $XDG_DATA_HOME/graveyard
instead of the $TMPDIR/graveyard-$USER
.
If you want to put the graveyard somewhere else (like ~/.local/share/Trash
), you have two options, in order of precedence:
- Alias
rip
torip --graveyard ~/.local/share/Trash
- Set the environment variable
$RIP_GRAVEYARD
to~/.local/share/Trash
.
This can be a good idea because if the graveyard is mounted on an in-memory file system (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.
Miscellaneous.
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.
Dependencies
~4–13MB
~170K SLoC