LinuxCommandLibrary

gomi

Move files to the trash/recycle bin

TLDR

Safely delete specific files or folders

$ gomi [path/to/file1 path/to/file2 path/to/folder1 path/to/folder2 ...]
copy

Open an interactive menu to restore one or more files
$ gomi [[-b|--restore]]
copy

Remove files that have been in the trashcan longer than the specified time ([d]ay, [w]eek, [m]onth, [y]ear)
$ gomi --prune [1d|1w|1m|1y|...]
copy

Remove orphaned .trashinfo files
$ gomi --prune [orphans]
copy

SYNOPSIS

gomi [OPTION]... [FILE]...

PARAMETERS

-e, --empty
    Empty the trashcan completely

-l, --list
    List files in the trashcan

-r, --restore <name>
    Restore a file from trashcan by original path

-i, --info
    Show trashcan information and stats

-c, --clear-config
    Clear gomi configuration

-v, --version
    Display gomi version

-h, --help
    Show help message

DESCRIPTION

gomi is a lightweight, cross-platform command-line utility for moving files and directories to the trash (recycle bin) instead of permanently deleting them with rm. Written in Go, it adheres to the Freedesktop.org Trash specification on Linux, ensuring compatibility with desktop environments like GNOME, KDE, and others. This allows easy restoration via file managers.

Use gomi to avoid accidental data loss during routine cleanups. It supports trashing multiple files, emptying the trash, listing contents, and restoring items. On Linux, trashed files go to ~/.local/share/Trash/; home or system trash depending on permissions. Unlike rm, gomi preserves original paths and deletion times for reliable recovery.

Ideal for scripts, aliases (e.g., alias rm='gomi'), or interactive use, gomi is fast, has no dependencies beyond Go runtime, and works on macOS/Windows too.

CAVEATS

Requires write access to trash directory; may fail on read-only filesystems. Restores to original paths only if available. Not a drop-in rm replacement for symlinks or special files.

INSTALLATION

Install via go install github.com/dwakuta/gomi/cmd/gomi@latest or package managers like AUR (gomi-bin).

EXAMPLES

gomi file.txt dir/ - Trash files.
gomi -l - List trash.
gomi -r './file.txt' - Restore.

HISTORY

Developed by Daisuke Wakuta in 2020 as a simple Go-based trash tool. Inspired by trash-cli, it gained popularity for speed and portability. Actively maintained on GitHub with releases supporting major platforms.

SEE ALSO

rm(1), trash-put(1), gio(1), shred(1)

Copied to clipboard