Skip to content

Repository files navigation

snip

snip is a local command-line tool for saving, searching, and reusing code snippets. Everything stays on your machine: snippets are stored in a SQLite database under your home directory, so you can build a personal library of patterns, commands, and boilerplate without a cloud service.

Typical workflow:

  • Add snippets with a title, optional language label, and tags; paste code from the terminal or pass it with -c.
  • List and search by keywords across titles, code, and tags.
  • Get a snippet by numeric ID to print it with syntax highlighting.
Command Purpose
snip add Save a snippet (-t title, optional -c code, --lang, --tags)
snip list / snip ls Show all snippets, newest first
snip search / snip s Search by keyword
snip get <id> Show a snippet; copy to clipboard unless --no-copy
snip health Quick sanity check that the CLI runs

The CLI is implemented in TypeScript and runs on Node.js when you develop from source; release binaries are standalone executables.

Documentation

Extended guides live under docs/:

Install from GitHub Releases

When a release tag is pushed (for example v0.1.0), Release Binaries builds standalone executables and uploads them to the GitHub Releases page. The tag must match the version in package.json: the workflow checks that v plus package.json’s version equals the pushed tag (e.g. version 0.1.0 with tag v0.1.0).

Download the file for your OS, make it executable on macOS and Linux, put it on your PATH, and run it. The published filenames are:

Platform Asset
macOS (Apple Silicon, arm64) snip-macos-arm64
Linux (x64) snip-linux-x64
Windows (x64) snip-windows-x64.exe

You do not need Node.js installed to use these builds.

macOS (arm64)

  1. Open the latest release and download snip-macos-arm64.
  2. In Terminal, allow execution and install on your PATH (example uses /usr/local/bin and the command name snip):
chmod +x snip-macos-arm64
xattr -d com.apple.quarantine ./snip-macos-arm64
sudo mv snip-macos-arm64 /usr/local/bin/snip
  1. Confirm:
snip --version
snip health

Linux (x64)

  1. Download snip-linux-x64 from the latest release.
  2. Install to a directory on your PATH:
chmod +x snip-linux-x64
mv snip-linux-x64 ~/.local/bin/snip

Ensure ~/.local/bin is on your PATH, then run snip --version and snip health.

Windows (x64)

  1. Download snip-windows-x64.exe from the latest release.
  2. Optionally rename it to snip.exe.
  3. Place the file in a folder that is on your user or system PATH, or run it by full path. Open a new terminal and run snip --version and snip health.

Prerequisites (from source)

  • Node.js 20 or newer
  • npm (comes with Node.js)

Local setup

git clone <your-repo-url>
cd snip
npm install
npm run build
npm link

Run locally

After npm link, the snip command is globally available in your shell.

snip --help
snip --version
snip health

Expected output for health:

snip is working

Database storage

On first run, any snip command creates a local SQLite database at ~/.snip/snippets.db and automatically creates the ~/.snip directory when it does not exist.

If startup reports that the database is corrupt, delete ~/.snip/snippets.db and run the command again to recreate it.

Development workflow

  • Make changes in src/
  • Rebuild with npm run build
  • Re-run commands (for example snip health)

Lint and format

Run ESLint:

npm run lint

Check formatting with Prettier:

npm run format:check

Rewrite files in place with Prettier:

npm run format

Releasing

Use release.sh to bump package.json, tag, and push so Release Binaries can build and publish the prebuilt binaries. The release workflow expects the Git tag to match v plus the version field in package.json; the script keeps those in sync.

Prerequisites

  • You are on main with the changes you want in the release already merged (the script refuses other branches).
  • Your branch is up to date with origin/main (pull before running if needed).
  • You have permission to push to main and to create tags on the remote.

Steps

  1. Choose a SemVer version (for example 1.2.3).

  2. From the repo root, run:

./release.sh 1.2.3

You can pass the version with or without a leading v (./release.sh v1.2.3 is the same).

If the script is not executable yet: chmod +x release.sh, or run bash release.sh 1.2.3.

What the script does

  1. Runs npm version <version> --no-git-tag-version so package.json matches the new version.
  2. Commits that change with message chore: bump version to vX.Y.Z.
  3. Creates a Git tag vX.Y.Z on that commit.
  4. Pushes main to origin, then pushes the tag.

After the tag push, GitHub Actions builds the platform binaries and attaches them to the GitHub Release. Watch progress under the repository’s Actions tab (the script prints a link derived from your origin remote).

Unlink when finished

npm unlink -g snip

License

Released under the MIT License.

About

A CLI snippet manager for developers — save, search and copy code snippets from your terminal

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages