rsnip
Smart Snippet Management with Template Support
A powerful command-line snippet manager that helps organize, find, and reuse text snippets with advanced templating capabilities. It features fuzzy search, intelligent shell integration, and dynamic template rendering.
Fast, Reliable, Yours: Why Snippets Outshine LLMs for boring Tasks
🌟 Key Features
- Multiple Snippet Formats:
- Native format with rich template support
- VSCode snippets compatibility
- SCLS (Simple Completion Language Server) format (ZED, Helix, etc.)
- Smart Organization: Categorize snippets into types (shell commands, code, notes, etc.)
- Fuzzy Search: Lightning-fast fuzzy finding with interactive fzf-style interface
- Deep Shell Integration (Inspired by zoxide):
- Tab completion for snippets in bash
- Customizable aliases per snippet type
- Interactive fuzzy completion
- Dynamic Templates:
- Jinja2-style template syntax
- Date manipulation filters
- Environment variable access
- Safe shell command execution
- Flexible Configuration:
- TOML-based configuration
- Per-snippet-type settings
- Developer-Friendly: Comprehensive debugging support
🚀 Quick Start
Installation
Basic Setup
- Initialize configuration:
# Generate default config
- Add shell integration to your
.bashrc
:
# Enable tab completion and aliases
- Create your first snippet file:
Configuration
RSnip uses TOML configuration with rich customization options:
[]
= "~/.config/rsnip/shell_snippets.txt"
= "Shell commands and scripts"
= "," # Quick access alias
[]
= "~/.config/rsnip/rust_snippets.json"
= "Rust snippets in VSCode format"
= "vcode"
[]
= "~/.config/rsnip/python_snippets.toml"
= "Python snippets in SCLS format"
= "scls"
Configuration is searched in:
~/.config/rsnip/config.toml
Snippet Formats
RSnip supports multiple snippet formats to make it easy to integrate with existing snippet collections:
- Default Format - RSnip's native format with comments and template support:
: Optional file-level comments
: Comment describing the snippet (optional)
: Additional comment lines
Content goes here
Multiple lines supported
: Example using templates
Hello {{ env_USER }}!
Created on: {{ current_date|strftime('%Y-%m-%d') }}
- VSCode Format - Compatible with Visual Studio Code snippets:
- SCLS Format - Simple Completion Language Server format (TOML-based):
[[]]
= "log"
= ["python"]
= "print($1)"
= "Simple print statement"
[[]]
= "func"
= ["python", "javascript"]
= "def ${1:name}(${2:args}):\n ${3:pass}"
🛠️ Advanced Features
Shell Integration & Aliases
RSnip provides powerful shell integration:
- Type-Specific Aliases: Configure quick access aliases per snippet type:
[]
= "," # Use as: , mysnippet
For every alias an associated "edit" alias will be generated automatically (prefix e): e,
.
- Smart Tab Completion:
- Works with both full command and aliases
- Supports fuzzy matching
- Shows preview window with snippet content
Example usage:
# Using alias
# Using full command
- Interactive Selection:
- FZF-style interface
- Live preview
- Fuzzy search
- Vim-style navigation
- Shell Support: Currently supports bash. PRs welcome for other shells!
Template System
RSnip implements a template engine with:
- Built-in Filters:
# Date formatting
{{ current_date|strftime('%Y-%m-%d') }}
# Date arithmetic
{{ current_date|add_days(7) }}
{{ current_date|subtract_days(7) }}
# Safe shell execution
{{ 'git rev-parse --short HEAD'|shell }}
- Environment Variables:
{{ env_HOME }} # Access $HOME
{{ env_USER }} # Access $USER
{{ env_PATH }} # Access $PATH
- Dynamic Content:
: Create a dated commit
git commit -m "Update: {{ current_date|strftime('%Y-%m-%d') }} - {{ 'git status -s|wc -l'|shell }} files"
- Snippets to be handled as Literal Text:
If you have snippets which happen to contain Jinja2-style template syntax, you can escape them like:
{% raw %}
gh run list --workflow "$workflow" \
--status success --json name,startedAt,headBranch,databaseId,status \
--template '{{range .}}{{tablerow (autocolor "white+h" .name) (autocolor "blue+h" .startedAt) .headBranch (autocolor "cyan" .databaseId) (autocolor "grey+h" .status)}}{{end}}' \
--limit 20
{% endraw %}
Command Reference
)
Debug Support
Multiple verbosity levels for troubleshooting:
View system information:
🔍 Usage Examples
Managing Shell Commands
- Create shell snippets:
: Switch AWS profile
export AWS_PROFILE={{ env_AWS_PROFILE|default('default') }}
: Remove unused Docker resources
docker system prune -af
- Use with aliases:
Git Workflows
- Create git snippets:
: Create WIP commit with date
git commit -m "WIP: {{ current_date|strftime('%Y-%m-%d %H:%M') }}"
- Use with dedicated alias:
🤝 Contributing
Contributions welcome! Please check our Contributing Guide.
Development Setup
# Clone repository
# Run tests
# Build release
📄 License
BSD 3-Clause License - see LICENSE for details.
🙏 Acknowledgments
Built with excellent Rust crates:
- clap: Command line parsing
- minijinja: Template engine
- skim: Fuzzy finder
- anyhow/thiserror: Error handling
- crossterm: Terminal UI
Similar Work
GitHub - knqyf263/pet: Simple command-line snippet manager
Shell integration inspired by: GitHub - ajeetdsouza/zoxide: A smarter cd command. Supports all major shells.