RSnip: Fast & Flexible Text Snippets 🚀
RSnip is a command-line text snippet manager built in Rust that helps you save and reuse frequently used text snippets with powerful templating capabilities.
🌟 Features
- Multiple Snippet Types: Organize snippets into different categories (shell commands, code snippets, etc.)
- Fuzzy Search: Fast fuzzy finding with interactive selection using fzf-style interface
- Shell Integration: Tab completion for your snippets in bash
- Dynamic Templates: Support for dynamic content using Jinja2-style templates
- Shell-friendly: Direct shell integration with aliases and completions
- Configurable: TOML-based configuration with multiple config file locations
- Fast: Written in Rust for optimal performance
- Debug Support: Configurable debug levels for troubleshooting
- Smart Completion: Both exact and fuzzy matching for snippet names
🚀 Quick Start
Installation
Basic Usage
- Create a snippet:
- Add some snippets in the format:
: This is a comment about the greeting snippet
Hello {{ env_USER }}!
: Creates a dated backup archive
tar -czf backup-{{ current_date|strftime('%Y%m%d') }}.tar.gz ./
- Use your snippets:
# List all snippet types
# List available snippets for a type
# Copy a snippet to clipboard
# Interactive fuzzy search
Command Line Options
)
)
Shell Integration
Add to your .bashrc
:
# Optional: Add convenient alias
# Enable tab completion
Now you can use:
⚙️ Configuration
RSnip looks for configuration in the following locations (in order):
~/.config/rsnip/config.toml
~/.config/rsnip/config.toml
/etc/rsnip/config.toml
Example configuration:
[]
= "~/.config/rsnip/shell_snippets.txt"
= "Shell command snippets"
[]
= "~/.config/rsnip/git_snippets.txt"
= "Git commands and workflows"
🛠️ Template Features
RSnip supports Jinja2-style templates with several built-in filters:
strftime
: Format dates -{{ current_date|strftime('%Y-%m-%d') }}
add_days
: Add days to date -{{ current_date|add_days(7) }}
subtract_days
: Subtract days -{{ current_date|subtract_days(7) }}
shell
: Execute shell commands (safely) -{{ 'date +%Y' | shell }}
Built-in variables:
current_date
: Current date in ISO format- Environment variables are available as
env_VARNAME
:
Current path is: {{ env_PATH }}
Snippet File Format
Snippets are stored in text files with a simple format:
: File-level comments (optional)
: Comment about this snippet
: Another comment
Content goes here
Can be multiple lines
🔍 Debug and Troubleshooting
RSnip supports multiple debug levels:
View configuration and version info:
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development
# Clone the repository
# Run tests
# Build in release mode
License
This project is licensed under the BSD 3 License - see the LICENSE file for details.
🙏 Acknowledgments
- Inspired by various snippet managers and completion tools
- Built with Rust and several awesome crates including clap, minijinja, skim, and more