Skip to content

Nissyaniss/BetterReMove

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brm (Better ReMove)

brm is a command line deletion tool to replace the default and unsafe rm (if I delete a file I will never recover it). The idea was stolen from rip (so this README is heavily inspired from them).

Deleted files are send by default to $HOME/.local/share/BetterReMove/trash, you can change it via commands (see Usage)

brm is only available for Linux (not extendly tested for the latter) at the moment. No MacOS nor Windows version is planned at the moment (if you want to add it create a PR i will be happy to merge)

THIS IS MY FIRST RUST PROJECT BE INDULGENT I'M NOT SMART

Installation

Linux

Get the binary from release and move it to your /usr/local/bin (or any folder in your PATH)

$ mv brm /usr/local/bin

I hope i get to upload this onto the arch AUR repo but it is not the case at the moment

Usage

Usage: brm [OPTIONS] [PATHS]...

Arguments:
  [PATHS]...  Files to remove

Options:
  -t, --trash-path                    Reveal the trash path
  -d, --delete-trash-contents         Deletes the trash's contents
      --set-trash-path <path>        Files to remove
      --generate-completions <SHELL>  Generate shell completions [possible values: bash, elvish, fish, powershell, zsh]
  -f, --force                         Force remove file(s) without moving to trash
  -h, --help                          Print help

-f is to remove files like rm.

brm doesn't care if what you are removing is a directory but will ask if this is wanted (even when -f is used), if this is not what you want it to behave like you can create an issue or a PR.

$ brm test_directory
The file you are trying to trash or remove is a directory. Are you sure ? [y/N]
$ brm -f test_directory
The file you are trying to trash or remove is a directory. Are you sure ? [y/N]

If the file name is already in the trash folder brm will add a number to it

$ ls /home/user/.local/BetterReMove/trash/
test
$ brm test
$ ls /home/user/.local/BetterReMove/trash/
test
test1

If you want to change the default trash folder you can either change it in the config at $HOME/.config/BetterReMove/config.toml or use the --set-trash-path like this :

$ brm --set-trash-path /home/user/new_trash/
$ brm -t
This is the current trash directory.
/home/user/new_trash/

You can also generate completions for your favorite shell like this :

$ brm --generate-completions zsh
# For zsh, you can use bash, elvish, fish and powershell too

To empty your trash you can use the -d option like this :

$ brm -d
Are you sure you want to erase the trash ? [y/N]

THERE IS CURRENTLY NO WAY TO RESTORE FILE TO THERE ORIGINAL PATH

I will love to do so but like said above this is my first Rust project and the code is bad as it is, and i cannot see a solution not involving a lot of rework. But it is planned.

Planned things to do

  • Make the code great again (i think its done)
  • fzf integration
  • Restore files to their original place

Credit

  • clap for all options, completions ect
  • dialoguer for the [Y/N] questions
  • toml for all things toml related
  • skim for the fzf integration