gomi (meaning "trash" in Japanese) is a simple CLI tool written in Go that adds trash can functionality to the command line.
In a typical CLI, there’s no "trash" folder like in graphical file managers. This means if you accidentally delete important files using the rm command, restoring them can be very difficult. That's where gomi comes in. Unlike rm, which permanently deletes files, gomi moves them to the trash, allowing you to easily restore files whenever necessary. If you’re used to rm in the shell, gomi works as a more convenient, safer alternative.
- Functions like the
rmcommand but moves files to the trash instead of permanently deleting them. - Follows the XDG Trash specification for modern Linux desktop environments:
- Supports
$XDG_DATA_HOME/Trashor~/.local/share/Trash - Compatible with other applications using the XDG trash
- Supports
- Simple and intuitive restoration process with a user-friendly interface.
- Compatible with most of the flags available for the
rmcommand. - Allows easy searching of deleted files using fuzzy search.
- Customizable via a YAML configuration file:
- Filter what files to show (using regexp patterns, file globs, file size, etc.).
- Customize file content colorization.
- Define the command to list directory contents.
- Customize visual styles (e.g., color of selected files).
For detailed information about gomi's architecture and design decisions, see architecture.md.
gomi is compatible with rm flags (like -i, -f, and -r), so you can easily replace rm by setting up an alias:
alias rm=gomiI developed gomi as a safer replacement for rm, so setting up the alias is recommended. However, feel free to adjust to your preferences. The instructions below assume the alias is set.
Move files to the trash:
rm filesRestore a file to its original location. The --restore flag is a bit long, so you can use the shorthand -b:
rm -bGet started with gomi in just one command:
curl -fsSL https://gomi.dev/install | bashTo install it in a specific directory (e.g., ~/.local/bin):
curl -fsSL https://gomi.dev/install | PREFIX=~/.local/bin bash| Environment Variable | Description | Default |
|---|---|---|
VERSION |
Version to install (available versions are listed on Releases) | latest |
PREFIX |
Installation path | ~/bin |
Download the latest precompiled binary from GitHub Releases and place it in a directory included in your $PATH.
Using afx
"Write a YAML manifest, then run the install command.
github:
- name: babarot/gomi
description: Trash can in CLI
owner: babarot
repo: gomi
release:
name: gomi
tag: v1.4.3
command:
link:
- from: gomi
alias:
rm: gomiafx installUsing Homebrew
brew install gomiUsing Scoop
scoop bucket add babarot https://github.com/babarot/scoop-bucket
scoop install gomiUsing AUR
You can install gomi using an AUR helper:
yay -S gomiparu -S gomiFind it on AUR.
You can customize gomi's behavior and appearance with a YAML configuration file. The first time you run gomi, a default config will be automatically generated at ~/.config/gomi/config.yaml.
Here is an example of the default config:
core:
trash:
strategy: "auto" # or "xdg" or "legacy"
# Strategy determines which trash specification to use.
gomi_dir: ~/.gomi # Path to store trashed files. Can be changed to another location.
# Supports environment variable expansion like $HOME or ~.
# If empty, defaults to ~/.gomi.
# This config is only available on "legacy", "auto" trash strategy
restore:
confirm: false # If true, prompts for confirmation before restoring (yes/no)
verbose: true # If true, displays detailed restoration information
delete:
disable: false # Disable permanent deletion feature
ui:
density: spacious # or compact
preview:
syntax_highlight: true
colorscheme: nord # Available themes: https://xyproto.github.io/splash/docs/index.html
directory_command: ls -F -A --color=always
style:
list_view:
cursor: "#AD58B4" # purple
selected: "#5FB458" # green
indent_on_select: false
detail_view:
border: "#FFFFFF"
info_pane:
deleted_from:
fg: "#EEEEEE"
bg: "#1C1C1C"
deleted_at:
fg: "#EEEEEE"
bg: "#1C1C1C"
preview_pane:
border: "#3C3C3C"
size:
fg: "#EEEEDD"
bg: "#3C3C3C"
scroll:
fg: "#EEEEDD"
bg: "#3C3C3C"
deletion_dialog: "#FF007F" # pink
exit_message: bye! # Customizable exit message
paginator_type: dots # or arabic
history:
include:
within_days: 100 # Only show files deleted in the last 100 days
exclude:
files:
- .DS_Store # Exclude .DS_Store files
patterns:
- "^go\\..*" # Exclude files starting with "go."
globs:
- "*.jpg" # Exclude JPEG files
size:
min: 0KB # Exclude empty files
max: 10GB # Exclude files larger than 10GB
Gain deeper insights into gomi's operations by using the --debug flag:
gomi --debugThis command streams log output in real-time, similar to tail -f. While running gomi --debug, you can open another terminal and execute gomi commands to monitor live log updates. This feature is invaluable for troubleshooting and tracking gomi's actions in real-time.
The --debug flag supports two modes:
--debug=full: Displays the entire log file from the beginning, outputting its contents tostdout. After showing the complete log history, it continues to follow and display new log entries in real-time.--debug=live: Skips the initial log file content and immediately begins displaying new log entries as they are written, providing a live stream of ongoing activity.
