Rem is a CLI trash which makes it ridiculously easy to recover files.

Rem

Get some rapid-eye-movement sleep knowing your files are safe.

What is Rem?

Rem is a CLI trash which makes it ridiculously easy to recover files. We've all had that moment when we've deleted something we realised we shouldn't have. It sucks. Let's fix that!

Demo

asciicast

Let's say we have the following file structure

.
├── someDir
│   └── someFile
└── someFile

Next, we want to delete someDir. Simple!

rem someDir

Now it looks like this:

.
└── someFile

Oh no! We actually needed that directory!

rem --undo someDir

Back to:

.
├── someDir
│   └── someFile
└── someFile

It's really that easy.

You can also delete files of the same name with no problem:

rem someDir/someFile someFile

Installing

Build from source or use:

brew install quackduck/tap/rem

Uninstalling

Simply remove the executable or use:

brew uninstall rem

Rem stores its trash by default at ~/.remTrash.

Usage

Usage: rem [-t/--set-trash ] [--permanent | -u/--undo] file
       rem [-d/--directory | --empty | -h/--help | -v/--version | -l/--list]
Options:
   -u/--undo              restore a file
   -l/--list              list files in trash
   --empty                empty the trash permanently
   --permanent            delete a file permanently
   -d/--directory         show path to trash
   -t/--set-trash    set trash to dir and continue
   -h/--help              print this help message
   -v/--version           print Rem version

Thanks

Thanks to u/skeeto for helping me with race conditions and design here

Owner
Ishan Goel
Part of @hackclub. Commits way too rarely.
Ishan Goel
Comments
  • Improved `permanentlyDeleteFile`.

    Improved `permanentlyDeleteFile`.

    When some file in the trash did not have the write permission, they could not be removed and an error was raised. Performing a chmod 700 on files about to be removed fixes that issue.

  • Feature: Greater GNU rm compatibility

    Feature: Greater GNU rm compatibility

    If we want to use rem as a drop-in replacement for rm in scripts, a greater compatibility with GNU rm might be desirable. PR #8 already takes care of the -f flag.

    A fist step would be to remove the -v flag as a shorthand for --version as this flag is more usually used as a shorthand for --verbose which result in a wildly different behavior.

    Before using rem, I used trash-cli which does the rm compatibility in a pretty smart way. It simply ignores a lot of flag, they are not parsed as a file to trash but they don't have any effect. Should we aim to do the same thing ?

  • Fix bug when deleting file with absolute path

    Fix bug when deleting file with absolute path

    When trying to delete more than once a file with an absolute path, the following error was raised:

    o[^.^]o ~/dev/perso/rem >touch /home/mbouillot/test
    o[^.^]o ~/dev/perso/rem >./rem /home/mbouillot/test
    Trashed /home/mbouillot/test
    Undo using rem --undo /home/mbouillot/test
    o[^.^]o ~/dev/perso/rem >touch /home/mbouillot/test
    o[^.^]o ~/dev/perso/rem >./rem /home/mbouillot/test
    To avoid conflicts, /home/mbouillot/.local/share/rem/trash/trash/test will now be called /home/mbouillot/.local/share/rem/trash/trash/test Dec 21 11:51:58
    To avoid conflicts, /home/mbouillot/test will now be called /home/mbouillot/test Dec 21 11:51:58
    error: lstat /home/mbouillot/test Dec 21 11:51:58: no such file or directory
    o[^.^]o ~/dev/perso/rem >
    

    This was caused by the line path = getTimestampedPath(path, existsInLog) from the function trashFile which changed the name of the source file in the function when it had the same format as in the log (absolute path).

    Removing that line fixes that issue and keeps the current behavior.

  • Added -f flag.

    Added -f flag.

    This flag prevents error message to be printed if non existing files try to be deleted. This is meant for compatibility with GNU rm if rem is used as a drop-in replacement for rm.

  • Unable to trash a broken symbolic link

    Unable to trash a broken symbolic link

    When trying to remove a symbolic link that points to nothing, rem fails. image This is due to the facts that the Go function os.IsNotExists returns false for that kind of file. I don't know if the bug should be fixed here or if we should notify the developers of Go.

  • Tried to comply to the XDG specifications.

    Tried to comply to the XDG specifications.

    The trash directory by default is $XDG_DATA_HOME/remTrash. If XDG_DATA_HOME is not set, the choice of the trash directory is made in a smart-ish way. I know that I will definitively not use this software if it is going to add clutter to my home directory and I might not be the only one in that case. Following the XDG specification could let REM be used by more people.

  • Fixed check of argument usability.

    Fixed check of argument usability.

    The ignoreArgs map counts arguments indexed as they are given by the OS but the normal case loop starts to count as the index 1 which caused an offset of the ignored arguments.

  • Let multiples single letter arguments be chained.

    Let multiples single letter arguments be chained.

    This enable, for example, to do rem --rm-mode -vf to enable both verbose and force mode in a single argument. This is important for GNU rm compatibility as rm -fr is a very common call.

A go cli makes it easy to get quotes from the Ted Lasso Quotes API

Ted Lasso Quotes CLI This cli makes it easy to get quotes from the Ted Lasso Quotes API Just clone the repo and build the binary for your distribution

Jun 15, 2022
ghcv-cli makes it easy to view the user-created issues, pull requests, and repositories in the terminal.
ghcv-cli makes it easy to view the user-created issues, pull requests, and repositories in the terminal.

ghcv-cli ghcv-cli makes it easy to view the user-created issues, pull requests, and repositories in the terminal. About Show a list of pull requests c

Mar 13, 2022
Plugin which makes tmux work and feel like i3wm

Tmux Tilish This is a plugin that makes tmux behave more like a typical dynamic window manager. It is heavily inspired by i3wm, and most keybindings a

Jan 7, 2023
A tiny markup language for terminal output. Makes formatting output in CLI apps easier!
A tiny markup language for terminal output. Makes formatting output in CLI apps easier!

tml - Terminal Markup Language A Go module (and standalone binary) to make the output of coloured/formatted text in the terminal easier and more reada

Dec 14, 2022
Simple cli that makes your thoughts captured in the moment.

note Simple cli that makes your thoughts captured in the moment. Install go install github.com/jnszkr/note Usage > note This is my first note that I

Jan 8, 2022
A CLI tool which loads data from yaml files into the Google Cloud Spanner tables

splanter A CLI tool which loads data from yaml files into the Google Cloud Spanner tables (mainly for the development).

Oct 27, 2022
Easy to use library and CLI utility to generate Go struct from CSV files.

csv2struct Easy to use library and CLI utility to generate Go struct from CSV files. As a benefit, it's fully compatible with csvutil. So, structs gen

Nov 7, 2022
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it

news-parser-cli Simple CLI which allows you to receive news depending on the par

Jan 4, 2022
Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Jan 12, 2022
tinygo-used-files is a CLI tool that lists only the files to be built as specified by buildtag.

tinygo-used-files is a CLI tool that lists only the files to be built as specified by buildtag.

Feb 6, 2022
Related is a simple cli utility tool to create files or a group of files.

Related - Create files based on individual definitions or groups Related helps with common file-creation-based tasks. You can predefine single types a

Apr 16, 2022
Simple and easy to use command line application written in Go for cleaning unnecessary XCode files.

xcclear Say hello to a few extra gigabytes of space on your Mac with xcclear, a simple and easy to use command line application written in Go for clea

Dec 16, 2022
PingMe is a CLI tool which provides the ability to send messages or alerts to multiple messaging platforms & email.
PingMe is a CLI tool which provides the ability to send messages or alerts to multiple messaging platforms & email.

PingMe is a personal project to satisfy my needs of having alerts, most major platforms have integration to send alerts but its not always useful, either you are stuck with one particular platform, or you have to do alot of integrations. I needed a small app which i can just call from my backup scripts, cron jobs, CI/CD pipelines or from anywhere to send a message with particular information. And i can ship it everywhere with ease. Hence, the birth of PingMe.

Dec 28, 2022
CLI for SendGrid, which helps in managing SSO users, can install and update users from yaml config

Sendgrid API This script is needed to add new users to SendGrid as SSO teammates. Previously, all users were manually added and manually migrating the

Jul 20, 2022
A CLI which automates semver versioning.

Semverbot A CLI which automates semver versioning based on git information. Why Semverbot? There are several reasons why you should consider using sbo

Dec 12, 2022
Go-ticket-booking-app - Simple CLI application which books tickets for a Go conference made to learn the fundamentals of Go programming language.

go-ticket-booking-app Simple CLI application which books ticket for a Go conference made to learn the fundamentals of Go programming language. Gorouti

Jan 2, 2022
Adventure is a CLI game, which is a project of the OOP course of ZJU

Adventure is a CLI game, which is a project of the OOP course of ZJU. This is the go version of ZJU-OOP-Adventure.

Jan 25, 2022
K-Mesh is an experimental Knative distribution which provides a fresh, CLI-focused, holistic user experience of running and managing Knative.

K-Mesh is an experimental Knative distribution which provides a fresh, CLI-focused, holistic user experience of running and managing Knative. N

Feb 14, 2022