trash

command module
v0.0.0-...-14fecc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 1 Imported by: 0

README

Trash 🗑️

trash is a command-line interface (CLI) tool designed to prevent irreversible file deletions. It achieves this by moving files to a designated trash folder instead of permanently deleting them, allowing for future cleanup or recovery.

Warning

UNDER DEVELOPMENT

Installation

You can install trash using the following command:

go install github.com/ericklima-ca/trash@latest

Usage

To use trash, you can run the following command:

$ trash remove file.txt

file.txt will be moved to the ~/.trash directory inside of a timestamp folder instead of being deleted.

user@ in ~/.trash
$ tree
.
└── 20230927005243
    └── file.txt

2 directories, 1 file
Available Commands
  • clean: Cleans the trash directory.
  • completion: Generates autocompletion scripts for various shells.
  • help: Provides help and information about available commands.
  • init: Initializes the trash directory (default location: $HOME/.trash).
  • remove: Moves files to the trash directory.
  • stats: Displays statistics about the contents of the trash directory, similar to 'du -sh'.
Flags
  • -h, --help: Display help for the trash command.
  • -v, --version: Display the version information for trash.

Creating an Alias for Easy Usage (Optional)

To simplify the usage of trash and make it a seamless replacement for the rm command, you can create an alias in your shell configuration file (e.g., .zshrc for Zsh). This alias will allow you to use trash instead of rm, ensuring that deleted files go to the trash directory by default.

# ~/.zshrc
...
alias rm="trash remove"
...

Generate the autocompletion script for the zsh shell.

If shell completion is not already enabled in your environment you will need to enable it. You can execute the following once:

echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions in your current shell session:

source <(trash completion zsh)

To load completions for every new session, execute once:

Linux:
trash completion zsh > "${fpath[1]}/_trash"
macOS:
trash completion zsh > $(brew --prefix)/share/zsh/site-functions/_trash

You will need to start a new shell for this setup to take effect.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL