# pet

> Command-line snippet manager written in Go. Save, tag, search, and run shell command snippets with parameters, stored in TOML and synced via Gist or GitLab.

Stars: 5.4k · Language: Go · License: MIT · Categories: Shell

- Repository: https://github.com/knqyf263/pet
- Page: https://www.trmn.sh/tools/pet

## Install

- Homebrew: `brew install pet`

## Overview

pet is a command-line snippet manager written in Go, inspired by memo. It stores commands you rarely use or can't easily recall, along with descriptions and tags, so you can find them later instead of digging through shell history. Snippets are created with `pet new` (or `pet new --multiline` for multiline commands) and managed through subcommands such as `list`, `search`, `exec`, `clip`, `edit`, `configure`, and `sync`.

Snippets can include parameters written as `<param>` or `<param=default_value>`, including multiple default values per parameter. Snippets live in a TOML file that you can edit directly with `pet edit`, and a snippet can also store a command's output (displayed by `pet list` but not searchable). The config supports a custom editor, sort order, the shell command used to run snippets, an output format string, and multiple snippet directories or files. Interactive selection uses fzf or peco.

Shell integration is documented for bash, zsh, and fish. The README provides a `prev` function that registers the previous command with `pet new`, and a key binding (for example `Ctrl-s` in zsh) that runs `pet search` and puts the chosen snippet on the current command line, like `Ctrl-r`. Because the command lands in the shell buffer, running it adds it to shell history and lets you chain commands. A `--raw` mode lets you expand parameters with native shell editing instead of the built-in dialog. Snippets can be filtered by tag with `-t`, and an fzf `alt+s` binding can save a command from history.

pet can sync the snippet file through GitHub Gist, GitHub Enterprise, or GitLab Snippets, with an optional `auto_sync` setting that syncs on edits. The selected snippet can be copied to the clipboard with `pet clip` (the README mentions `pbcopy` on macOS). It is aimed at developers and operators who work across many tools and want a searchable, shareable set of commands.

### Installation

```bash
# via Homebrew
brew install pet
```

## Alternatives

- [Carapace](https://www.trmn.sh/tools/carapace-bin.md): A single binary providing argument completion for many CLI commands across Bash, Zsh, Fish, Nushell, Elvish, PowerShell, Xonsh and other shells. (Go, 2.0k stars)
- [up](https://www.trmn.sh/tools/up.md): Interactive terminal UI for building Linux pipelines with live preview of command results (Go, 8.9k stars)
- [shfmt](https://www.trmn.sh/tools/shfmt.md): Shell script formatter built on a Go parser for POSIX sh, Bash, Zsh and mksh. The same repo ships a syntax package, shell helpers and an interpreter. (Go, 9.2k stars)
- [direnv](https://www.trmn.sh/tools/direnv.md): Shell extension that automatically loads and unloads environment variables based on current directory (Go, 15.6k stars)
- [gum](https://www.trmn.sh/tools/gum.md): CLI tool providing interactive components for shell scripts with input prompts, menus, spinners, and styling (Go, 24.6k stars)

---

Canonical: https://www.trmn.sh/tools/pet
