# gomi: a safer rm that puts files in the trash

> gomi is a Go command line tool that takes over the rm command and moves what you delete into a trash directory instead of erasing it, so a mistyped path is recoverable. It follows the XDG Trash specification, restores from a terminal UI, and keeps the rm flags you already type.

**babarot/gomi** — 🗑️ Your UNIX rm command with a safety net!

- Repository: https://github.com/babarot/gomi
- Website: https://gomi.dev
- Stars: 577 · Forks: 17
- Language: Go
- License: MIT
- Published: 2026-10-22 · Updated: 2026-10-22 · Language: en
- Canonical page: https://hysenlabs.com/projects/babarot-gomi

## The reason rm is dangerous is that it leaves nothing behind

The README puts the problem plainly. In a typical command line there is no trash folder like in graphical file managers, which means that if you accidentally delete important files with rm, restoring them can be very difficult. That is where gomi comes from. It is a simple CLI tool written in Go that adds trash can functionality to the command line, and unlike rm, which permanently deletes files, gomi moves them to the trash so you can restore them whenever necessary.

The name is a small hint about the intent. gomi means trash in Japanese, and the repository description calls it your UNIX rm command with a safety net. The tool is deliberately a replacement for one specific command rather than a general file manager, and its whole design follows from that narrow target.

The audience is someone who lives in a shell and has internalized rm as muscle memory. The README frames gomi as a more convenient, safer alternative to rm for people used to using rm in the shell, and the way it delivers on that is by not asking you to learn anything new at all.

## Same flags, same habits, one extra letter for undo

gomi is compatible with the rm flags, and the README names -i, -f and -r as examples, so the switch is a shell alias rather than a change of workflow:

```bash
alias rm=gomi
```

With that alias in place the ordinary commands keep working, so `rm files` moves the named files to the trash rather than erasing them. The author says he developed gomi as a safer replacement for rm and that setting up the alias is recommended, while leaving the choice open.

Restoring is where the new verb appears. The flag is --restore, with a one letter shorthand -b, and invoking it launches an interactive file browser:

```bash
rm -b
```

Inside that browser the README lists the keys. Arrow keys move through the trashed files, / starts searching and filtering by name, Tab selects several files for restoration, Space previews the contents of a file, and Enter restores the selected files.

The -b shorthand is a small but telling design decision. Typing rm -b after a mistaken deletion is short enough to remember under stress, and it keeps the interaction inside the command you already know.

## Two trash strategies, and the desktop has to agree with yours

The compliance claim is specific: gomi follows the XDG Trash specification, which is what makes the trashed files visible to your desktop environment and to other applications that use the same trash. The specification supports $XDG_DATA_HOME/Trash or ~/.local/share/Trash, and the README notes that gomi is compatible with other applications using the XDG trash.

The configuration decides which behaviour you get, and the default is deliberately open-ended:

```yaml
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 is a legacy storage setting. If set with strategy "auto",
                        # gomi will automatically use legacy storage as the primary backend.

    home_fallback: true # If true, fallbacks to home trash when external trash fails

    forbidden_paths:    # List of paths that cannot be moved to trash for safety.
                        # Each path protects itself and everything inside it ("/" protects only itself).
```

Three things in that block matter. The strategy can be auto, xdg or legacy, and auto resolves based on what the system supports. The legacy store lives in ~/.gomi, and the comment says plainly that setting gomi_dir with strategy auto makes gomi use legacy storage as the primary backend. And home_fallback decides whether a failure to use an external trash sends the file to the home trash instead of failing.

That legacy path is the trade-off in the whole design. Files in ~/.gomi are not in the desktop trash, so they will not appear in your file manager's bin, and the restore browser is the only way back to them. The forbidden_paths list is the safety net for the other end of the problem, marking directories that must never be moved to the trash, with each entry protecting itself and everything inside it.

Multi-volume support is the other structural piece. Deleting a file that lives on a different mount point than your home directory cannot simply be moved into the home trash, so gomi has to know where the mount points are, and the dependency list includes moby/sys/mountinfo for reading the system mount table.

## One curl command, or whichever package manager you already use

The README leads the installation section with a single command:

```bash
curl -fsSL https://gomi.dev/install | bash
```

To install into a specific directory, the same installer takes a PREFIX variable, and the example given is a local bin directory:

```bash
curl -fsSL https://gomi.dev/install | PREFIX=~/.local/bin bash
```

The table under those commands lists the two variables the installer understands. VERSION selects which release to install, with the available versions listed on the Releases page, and it defaults to latest. PREFIX is the installation path, and it defaults to ~/bin.

If you would rather not pipe a script into a shell, the alternatives cover the usual ground. Homebrew is one line:

```bash
brew install gomi
```

Scoop on Windows needs the bucket added first:

```bash
scoop bucket add babarot https://github.com/babarot/scoop-bucket
scoop install gomi
```

Arch users have the AUR with either of the two common helpers, yay -S gomi or paru -S gomi. And there is a repology badge tracking the packaged versions, which is the usual sign that a small CLI has spread across the distributions.

The author's own tool, afx, manages it through a YAML manifest that pins the release tag and declares the alias:

```yaml
github:
- name: babarot/gomi
  description: Trash can in CLI
  owner: babarot
  repo: gomi
  release:
    name: gomi
    tag: v1.6.5
  command:
    link:
    - from: gomi
    alias:
      rm: gomi
```

and then `afx install` performs the installation and wires up the alias. For anyone who already uses afx, that manifest is the tidiest route, since the alias you would otherwise add by hand is part of it.

## Configuration is YAML, written on first run

The first time you run gomi, a default configuration file is generated at ~/.config/gomi/config.yaml. There is no setup step and no flag to point somewhere else.

The commented-out section of the README shows what the configuration is meant to hold in full, and it is more than the core block shown above. You can filter what files to show using regexp patterns, file globs and file size. You can customize the file content colorization. You can define the command to list directory contents, which is the hook that lets a preview show you what a trashed directory actually contained. And you can customize the visual styles, for example the color of selected files.

That last group is what turns the tool from a file mover into a browser. The preview feature in the TUI, where Space shows the contents of a trashed file, depends on the colorization and directory listing settings, and the syntax highlighting of trashed files mentioned in the feature list is another thing the config controls.

The file filters deserve a note as well. Because a trash accumulates, the ability to say show me only the spreadsheets larger than a megabyte, or only the paths matching a pattern, is what keeps the restore browser usable after a few months of real use.

## The restore browser is a Bubble Tea program

The dependency list in go.mod describes the architecture more clearly than the README does, and the shape is recognisable. The interactive parts are built on the Charm toolkit, with bubbletea as the program model, bubbles for the widgets such as the file list and the search field, lipgloss for styling and log for output. Syntax highlighting of previewed files comes from alecthomas/chroma, and the table output from olekukonko/tablewriter.

The rest of the list shows the non-visual side. jessevdk/go-flags handles the rm-compatible command line parsing, gopkg.in/yaml.v2 reads the configuration, gobwas/glob and go-playground/validator handle the filtering rules and validation, gabriel-vasile/mimetype detects file types, dustin/go-humanize formats sizes, atotto/clipboard copies selections, rs/xid and google/uuid generate identifiers for trashed entries, al.essio.dev/pkg/shellescape handles quoting for the configured directory listing command, and samber/lo provides the generic helpers.

Two other entries explain features in the README. moby/sys/mountinfo is how the tool learns where the mount points are, which is what makes multi-volume deletion work, and nxadm/tail plus golang.org/x/sync point at the concurrent operations the feature list describes as blazing fast with concurrent operations, with the sync package providing the primitives for it.

The module targets Go 1.25.0, which is a recent language version and tells you the toolchain expectation of anyone building from source.

## Building it yourself, and what the release cadence looks like

The Makefile is a conventional Go build with a few extras. The version information is stamped into the binary at link time from git, with the tag, the short revision and the build date:

```makefile
LDFLAGS := "-X main.version=$(shell git describe --tags --abbrev=0 --always) -X main.revision=$(shell git rev-parse --verify --short HEAD) -X main.buildDate=$(shell date "+%Y-%m-%d")"
```

The targets cover the usual ground, with `test` running the suite with coverage, `lint` running golangci-lint, `deps` running go mod tidy, `build` producing the binary, `install` doing a go install, and `sys-install` copying the result into /usr/local/bin with sudo. The test target in full is:

```makefile
test: $(SRCS)
	go test ./... -coverprofile=coverage.out -covermode=count
```

The repository root shows a project with its release machinery in place: a .goreleaser.yaml for building the cross-platform binaries, a .golangci.yaml for the linter configuration, a .octocov.yaml for coverage reporting, a .tagpr file for tagging releases, a Makefile, a VERSION file, a CHANGELOG.md, a hack directory for development scripts, a docs directory that includes architecture.md, and an internal directory holding the implementation.

The licence is MIT, the default branch is main, and the recent releases are v1.6.5 from 2026-09-30, v1.6.4 from 2026-06-07 and v1.6.3 from 2026-03-20, which is a release every few months with patch-level version numbers. The last push was on 2026-10-09, so the project is current, and the homepage is gomi.dev.

## Conclusion

gomi fits a shell user who has once deleted the wrong directory and wants a recoverable mistake, and who is on Linux, macOS or Windows with a desktop trash that already follows the XDG specification. It is the wrong choice for a scripted pipeline that relies on rm returning a file to nowhere, since a trashed file still occupies disk and the trash is a directory any backup tool will now sweep up. Verify first whether the trash strategy of auto resolves to xdg or legacy on your machine, because a legacy ~/.gomi store is invisible to your desktop file manager, and check the forbidden_paths list before you rely on the safety net it provides.

## FAQ

### How do I install gomi?

The README's one-command install is curl -fsSL https://gomi.dev/install | bash, with PREFIX=~/.local/bin bash to choose a directory, and a VERSION variable to pin a release. It is also packaged for Homebrew with brew install gomi, for Scoop, for the AUR with yay or paru, and for afx.

### How do I restore a file I deleted with gomi?

Run gomi with the --restore flag, or its -b shorthand, which opens an interactive browser over the trashed files. Arrow keys move through them, / searches by name, Tab selects several, Space previews the contents and Enter restores the selection.

### Can I use gomi instead of rm without changing my habits?

Yes. gomi is compatible with the rm flags such as -i, -f and -r, and the README recommends setting the alias rm=gomi so that the commands you already type move files to the trash instead of deleting them permanently.

### What is the difference between the xdg and legacy trash strategies in gomi?

The xdg strategy uses the XDG Trash specification, so trashed files appear in your desktop environment and interoperate with other applications using the same trash. The legacy strategy stores files in ~/.gomi, which is a separate location your file manager will not show, and the default strategy of auto resolves between them.

### Where is gomi's configuration file and what can it set?

A default configuration is generated at ~/.config/gomi/config.yaml the first time you run gomi. It controls the trash strategy and directory, the home fallback, forbidden paths, and the appearance of the interface including file filters based on regexp patterns, globs and size, content colorization, the directory listing command and visual styles.

## Sources

- [babarot/gomi on GitHub](https://github.com/babarot/gomi)
- [License: MIT](https://github.com/babarot/gomi/blob/main/LICENSE)
- [Project website](https://gomi.dev)
- [README](https://github.com/babarot/gomi/blob/main/README.md)
- [Releases](https://github.com/babarot/gomi/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/babarot-gomi
