# nap

> Code snippet manager with CLI and TUI for creating, organizing, and accessing snippets in the terminal

Stars: 2.2k · Language: Go · Categories: Dev Tools

- Repository: https://github.com/maaslalani/nap
- Page: https://www.trmn.sh/tools/nap

## Install

- Go: `go install github.com/maaslalani/nap@main`

## Overview

Nap is a terminal-based code snippet manager that provides both command-line and text-user interfaces for managing code snippets. The tool allows developers to quickly save code snippets via stdin piping, organize them into folders with language tagging, and retrieve them through fuzzy search or direct access commands.

The CLI interface supports creating snippets by piping content from files, curl requests, or GitHub gists using commands like `nap < main.go` or `curl https://example.com/main.go | nap Notes/FizzBuzz.go`. Snippets can be output to files, piped to clipboard utilities, or searched with fuzzy matching. The TUI mode provides an interactive interface launched with `nap` for browsing, editing, and managing snippets with keyboard shortcuts.

Nap stores snippets locally and offers extensive customization through YAML configuration files or environment variables, including theme selection and color customization. The tool integrates well with external utilities like Gum for enhanced fuzzy finding and standard clipboard tools like pbcopy or xclip for workflow integration.

### Installation

```bash
# via Go
go install github.com/maaslalani/nap@main
```

![Nap overview demonstration](https://media.trmn.sh/cached/5d629da351d250081e52e7b395b6c107f7f289d1a94403cf8cc43767537f3749.gif)

![TUI interface](https://media.trmn.sh/cached/14dc2d9e2bf8bbc0bf563a26ad84b04547cdb9ce4b4b2c4182e6629162c3d988.gif)

![CLI snippet creation](https://media.trmn.sh/cached/cd52cd071fdf4286abfbb9a5df5fefabf5885efaae4eda7ad9c1cac029907db0.gif)

## Alternatives

- [flyctl](https://www.trmn.sh/tools/flyctl.md): Command-line interface for fly.io that authenticates accounts, lists apps, and checks app status; also invoked as fly. (Go, 1.7k stars)
- [octocov](https://www.trmn.sh/tools/octocov.md): Code metrics toolkit for collecting coverage, code-to-test ratio, test execution time, and custom metrics from multiple report formats (Go, 517 stars)
- [awsesh](https://www.trmn.sh/tools/awsesh.md): TUI and CLI tool for managing AWS SSO sessions with fuzzy search, account switching, and shell integration. (Go, 143 stars)
- [envdiff](https://www.trmn.sh/tools/envdiff.md): Snapshots a machine's system info, runtimes, env vars and network config to JSON, diffs snapshots, and validates environments against a YAML file. (Go, 25 stars)
- [freeze](https://www.trmn.sh/tools/freeze.md): Generate PNG, SVG, and WebP images of code and terminal output with syntax highlighting and customizable styling. (Go, 4.9k stars)

---

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