snip-manager
v0.2.0
Published
Fast, terminal-native CLI snippet manager with TUI and SQLite/Gist sync.
Downloads
400
Maintainers
Readme
snip — CLI Snippet Manager
🌐 Website · 🚀 Product Demo · 📦 npm · 📖 Docs
A lightweight, cross-platform CLI for saving, searching, sharing, and running reusable code and shell snippets. Built for developers who live in the terminal.
Why snip?
Stop hunting through your shell history for that one command. snip is your terminal's memory — save, search, and execute code snippets in milliseconds.
- ⚡ Lightning Fast — Add, search, and run snippets in milliseconds
- 🔍 Fuzzy Search — Find anything instantly across names, tags, and content
- 🛡️ Safety First — Preview commands before execution, auto-detect dangerous operations
- 🎨 Interactive TUI — Keyboard-first terminal UI with split-pane interface
- 💾 Flexible Storage — JSON for simplicity, SQLite for scale
- 🔄 Gist Sync — Backup and share via GitHub Gists
- 🔗 fzf Integration — Pipe snippets through fzf with live preview
Why snip over X?
| Feature | snip | pet | navi | tldr | dotfiles / aliases | |---------|------|-----|------|------|-----| | Run snippets directly | ✅ Any language | ✅ Shell only | ✅ Shell only | ❌ Reference only | ✅ Shell only | | Multi-language (JS, Python, Ruby…) | ✅ | ❌ | ❌ | ❌ | ❌ | | Interactive TUI | ✅ Split-pane | ❌ | ✅ Basic | ❌ | ❌ | | Dangerous command detection | ✅ Auto-detect | ❌ | ❌ | ❌ | ❌ | | fzf integration | ✅ Native | ✅ | ✅ Core | ❌ | Manual | | SQLite backend | ✅ Optional | ❌ | ❌ | ❌ | ❌ | | Gist sync | ✅ Push/pull | ✅ | ❌ | ❌ | Manual | | Cross-platform | ✅ Node.js | Go binary | Rust binary | Multi | Varies | | Zero config | ✅ Works out of box | ✅ | Needs cheats | ✅ | Heavy setup |
TL;DR: Other tools are great for shell commands. snip is for developers who save code — deploy scripts, API calls, Docker commands, JS utilities — across any language, with safety rails and a real TUI.
Quick Start
# Install globally
npm install -g snip-manager
# Add a snippet from stdin
echo 'docker run --rm -it -v "$PWD":/work -w /work ubuntu:24.04 bash' | snip add docker-run --lang sh --tags docker,run
# Or add from your editor (opens $EDITOR)
snip add my-script --lang bash --tags deploy,production
# Search snippets
snip search docker
# Run a snippet
snip run docker-run
# Launch interactive TUI
snip uiInstallation
Prerequisites
- Node.js 18+
- npm or yarn
Install via npm
npm install -g snip-managerInstall via yarn
yarn global add snip-managerVerify Installation
snip --versionCommands
| Command | Description |
|---------|-------------|
| snip add <name> --lang <lang> --tags <tag1,tag2> | Save a new snippet from stdin or editor |
| snip ui | Launch interactive TUI with fuzzy search |
| snip list [--json] | List all saved snippets (JSON for scripting) |
| snip search <query> | Fuzzy search across all snippets |
| snip run <id\|name> | Execute a snippet safely (with template prompts) |
| snip edit <id\|name> | Edit snippet content inline |
| snip update <id\|name> --tags <t> --lang <l> | Update snippet tags or language |
| snip delete <id\|name> | Remove a snippet (alias: snip rm) |
| snip fzf | Search snippets via fzf with live preview |
| snip grab <url> | Import a snippet from a URL or github:user/repo/path |
| snip stats | Show snippet library statistics |
| snip widget [shell] | Output Ctrl+G shell widget for zsh/bash/fish |
| snip sync push [query] | Upload matching snippets to GitHub Gist |
| snip sync pull <gist-id> | Download snippets from GitHub Gist |
| snip config | View or modify configuration |
| snip --version | Show version information |
| snip --help | Display help information |
Configuration
Set Your Editor
snip config set editor "vim"Supported editors: vim, nvim, nano, code, subl
Enable SQLite Backend
For larger snippet libraries (100+ snippets):
snip config set useSqlite trueRequires better-sqlite3 for native performance, or falls back to sql.js (WebAssembly).
Configuration Options
| Option | Default | Description |
|--------|---------|-------------|
| editor | $EDITOR or vi | Default editor for snippet creation |
| useSqlite | false | Use SQLite instead of JSON storage |
| snippetDir | ~/.snip | Custom snippets directory |
Features
Interactive TUI
Launch snip ui for a rich, split-pane interface:
- Navigation:
j/kor arrow keys to move up/down - Search: Type to fuzzy filter in real-time
- Add: Press
ato create a new snippet - Edit: Press
eto edit selected snippet - Run: Press
rto execute (shows preview first) - Quit:
qorCtrl+C
Safety Features
snip automatically detects potentially dangerous commands:
rm -rfand similar recursive deletionssudocommands- Network-intensive operations
- Commands that could modify system state
Preview is shown before execution — you confirm before running.
Parameterized Snippets
Use {{variable}} and {{variable:default}} syntax for reusable templates:
# Save a parameterized snippet
echo 'docker run --rm -it -v "{{dir:$PWD}}":/work {{image:ubuntu:24.04}} {{cmd:bash}}' \
| snip add docker-dev --lang sh --tags docker
# Run it — snip prompts for each variable
snip run docker-dev
# dir [/Users/me/project]: _
# image [ubuntu:24.04]: node:20
# cmd [bash]: shVariables support environment variable defaults with {{name:$ENV_VAR}}.
Grab from URL
Import snippets directly from any URL:
# Grab from a raw URL
snip grab https://gist.githubusercontent.com/.../deploy.sh --tags deploy
# Shorthand for GitHub files
snip grab github:user/repo/scripts/backup.shLanguage is auto-detected from file extension and shebang.
Shell Widget (Ctrl+G)
Bind snip to a hotkey — search and paste snippets inline without leaving your prompt:
# Zsh — add to ~/.zshrc
eval "$(snip widget zsh)"
# Bash — add to ~/.bashrc
eval "$(snip widget bash)"
# Fish — add to ~/.config/fish/config.fish
snip widget fish | source
# Now press Ctrl+G anywhere to search and insert a snippetGitHub Gist Sync
Backup and share your snippet library:
# Push all snippets to a new Gist
snip sync push
# Push matching snippets
snip sync push docker
# Pull from existing Gist
snip sync pull <gist-id>Shell Completions
Tab completions ship with snip for bash, zsh, and fish:
# Bash — add to ~/.bashrc
eval "$(snip completion bash)"
# Zsh — add to ~/.zshrc
eval "$(snip completion zsh)"
# Fish — add to ~/.config/fish/config.fish
snip completion fish | sourcefzf Integration
If you have fzf installed, use snip fzf for a searchable list with a live preview pane:
# Search and preview snippets
snip fzf
# Pipe selected snippet to clipboard
snip fzf | pbcopy
# Bind to a shell shortcut (add to ~/.zshrc)
bindkey -s '^S' 'snip fzf\n'Troubleshooting
"command not found: snip"
Ensure npm global bin directory is in your PATH:
# Add to ~/.zshrc or ~/.bashrc
export PATH="$(npm global bin):$PATH"Editor Not Opening
Set your preferred editor:
snip config set editor "vim"Permission Errors
Fix npm permissions:
# Option 1: Use nvm
nvm install --lts
npm install -g snip-manager
# Option 2: Use sudo (not recommended)
sudo npm install -g snip-managerFrequently Asked Questions
What is snip?
snip is a CLI tool that helps developers manage and reuse code snippets directly from the terminal. Think of it as a personal library for your most-used commands and code blocks.
How is snip different from dotfiles?
dotfiles store configuration files, while snip focuses specifically on executable snippets — commands and code blocks you run repeatedly. snip provides instant search and one-command execution.
Does snip support custom languages?
Yes! Use --lang to specify the language:
snip add deploy --lang python --tags deployCan I import/export snippets?
Yes, via GitHub Gist sync:
# Export to Gist
snip sync push
# Import from Gist
snip sync pull <gist-id>Is my data secure?
Local snippets are stored in ~/.snip/ by default. Gist sync requires GitHub authentication. All data stays on your machine unless you explicitly choose to sync.
Contributing
Contributions are welcome! Please read our Contributing Guide first.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Security
See SECURITY.md for our security policy and reporting guidelines.
License
MIT License — see the LICENSE file for details.
