# pet: the snippet manager for commands you refuse to memorize

> pet is an MIT-licensed command-line snippet manager written in Go, inspired by memo, that saves, tags, searches and executes commands with parameter placeholders and default values. Snippets live in plain TOML, sync through Gist or GitLab, and integrate into bash and zsh as a C-r style selector. The last release was v1.0.1 in December 2024.

**knqyf263/pet** — Simple command-line snippet manager

- Repository: https://github.com/knqyf263/pet
- Stars: 5,357 · Forks: 251
- Language: Go
- License: MIT
- Published: 2026-09-22 · Updated: 2026-09-22 · Language: en
- Canonical page: https://hysenlabs.com/projects/knqyf263-pet

## Built for the commands you use twice a year

pet's motivation section is a confession every long-career developer recognizes: it is hard to remember complex or rarely used commands, and harder still to find them again in shell history. The stated philosophy is to let go of the expectation of remembering every command and focus on finding the right ones as fast as possible, trivial when you are two years in working with two tools, less so a decade in across backend, frontend and infrastructure. The answer is a simple tool, inspired by mattn's memo, that saves, tags, searches and executes command-line snippets, and the project describes itself as nearly eight years old and used by many developers around the world. It is written in Go, so installation is grabbing a binary release and dropping it into your PATH.

## pet new, and a TOML file you can always edit

Snippet creation is a two-question prompt:

```text
$ pet new
Command> echo Hello world!
Description> print Hello world
```

Multiline commands get their own flag, pet new --multiline, and --help lists the remaining arguments. The storage design is the quiet virtue: snippets live in a configuration that is just a TOML file, so editing is not a feature the tool must provide, it is opening the file, and versioning or reviewing your snippet collection is diffing text. Tags attach for faster search, and the main feature list rounds out with interactive search and direct execution. For a tool whose job is to hold your most-used text, plain-file storage is the decision that keeps it trustworthy across eight years of operating system and shell changes.

## Parameters with one default or several

Snippets are not static text. Variables written as <param> or <param=default_value> become fill-in fields at execution time, defined by the equal sign, so Hello <subject=world> runs immediately but still offers substitution. The parsing rules are documented down to the corners: default values may contain spaces and even equals signs, they just cannot end with spaces, and multiple defaults are expressed with a pipe-separated list, the README's example offering John, Sam and Jane Doe, the last demonstrating special characters inside a default. At execution the built-in dialog presents the choices, and there is an alternative for shell purists covered below. This parameter system is what elevates pet from a clipboard to a template runner, the difference between storing a command and storing a family of commands.

## The C-r style selector the README recommends

The integration the documentation marks RECOMMENDED binds snippet search to a key at the shell's current line, like reverse history search. For bash, a pet-select function feeds the line into pet search and binds Control-x Control-r:

```bash
function pet-select() {
  BUFFER=$(pet search --query "$READLINE_LINE")
  READLINE_LINE=$BUFFER
  READLINE_POINT=${#BUFFER}
}
bind -x '"\C-x\C-r": pet-select'
```

For zsh, the same shape through ZLE, bound to Control-s:

```zsh
function pet-select() {
  BUFFER=$(pet search --query "$LBUFFER")
  CURSOR=$#BUFFER
  zle redisplay
}
zle -N pet-select
stty -ixon
bindkey '^s' pet-select
```

Because the snippet lands on your command line rather than executing from inside pet, you execute it yourself, which adds it to shell history, the only mechanism that can, and allows chaining commands before running. Search can be pre-scoped with -t or --tags, pet search -t myjob limiting the selector to a tagged subset.

## prev() and the --raw escape from the TUI

Two more shell hooks complete the loop. A prev function, documented separately for bash and zsh, captures the previous command from history and pipes it into pet new, so saving the thing you just typed is one function call instead of retyping it into a prompt. Fish users are pointed to a community integration, fish-pet. For those who dislike the built-in parameter dialog, pet search --raw returns the snippet with placeholders intact onto the shell line, where native editing, tab completion and highlighting apply, with documented cursor-jumping helpers that move point to the next parameter's default value. Even the selector itself is configurable, with a selector option in the configuration pointing at your preferred fuzzy finder, and an fzf-based mode registers straight from history.

## Sync through Gist or GitLab, automatically

Snippets are only useful if they follow you between machines, and pet's answer is synchronization through GitHub Gist or GitLab Snippets, with an auto-sync option in the configuration so that saving a snippet propagates without a remembered manual step. The dependency list confirms the scope, go-github and go-gitlab with oauth2 as direct dependencies, so both hosting paths are first-class rather than one being a shim over the other. The configuration sections mirror the feature set, selector, tag, sync and auto sync each getting their own block in the TOML. For teams, a shared Gist becomes a lightweight communal snippet library, and for individuals the Gist is effectively an off-machine backup that happens to be readable in a browser.

## A Go binary that finished its feature list

The implementation is a small, legible Go codebase on cobra for the CLI, go-toml for storage, and gocui over tcell for the terminal dialog, with clipboard, spinner and readline support in the dependencies. Installation paths cover the realistic matrix, raw binaries, Homebrew on macOS, RedHat and CentOS repositories, Debian and Ubuntu packages, Archlinux, and building from source with a three-target Makefile. The release history tells a maturity story, v0.9.1 with bug fixes and more tests in October 2024, then v1.0.0 and v1.0.1 by December 2024, the classic shape of a project declaring itself done, and the last push arrived on 2026-03-13. Against memo, its inspiration, the difference is focus: memo holds general notes, while pet holds executable, parameterized snippets with sync, and for its specific job the tool has been stable for years.

## Conclusion

Use pet when your command memory has overflowed, rare kubectl incantations, shell one-liners with five flags, and you want them tagged, parameterized and one keystroke away inside bash or zsh. Use memo, the project's own inspiration, when you want general memo notes rather than executable, parameterized snippets. Verify first that your shell integration of choice is wired, since the C-r style selector is the feature that turns a snippet database into muscle memory, and note the project's last push was 2026-03-13 with releases frozen at v1.0.1.

## FAQ

### What is pet, the CLI tool?

pet is an MIT-licensed command-line snippet manager written in Go, inspired by memo. It saves, tags, searches and executes command snippets, supports parameterized snippets with single or multiple default values, and syncs through Gist or GitLab Snippets.

### How do you create a snippet in pet?

Run pet new, which prompts for a command and a description, with pet new --multiline available for multiline commands. Snippets live in a plain TOML file you can edit directly, and tags can be attached for faster searching.

### How do you sync pet snippets across machines?

pet syncs through GitHub Gist or GitLab Snippets, configured in its TOML file, with an auto-sync option so snippets propagate automatically rather than requiring a manual sync command.

## Sources

- [Issues](https://github.com/knqyf263/pet/issues)
- [knqyf263/pet on GitHub](https://github.com/knqyf263/pet)
- [License: MIT](https://github.com/knqyf263/pet/blob/main/LICENSE)
- [README](https://github.com/knqyf263/pet/blob/main/README.md)
- [Releases](https://github.com/knqyf263/pet/releases)

---

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