8 releases
new 0.3.3 | Jan 9, 2025 |
---|---|
0.3.2 | Jan 9, 2025 |
0.2.0 | Jan 8, 2025 |
0.1.2 | Jan 7, 2025 |
#1075 in Command line utilities
412 downloads per month
49KB
1K
SLoC
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
🚀 Quick Start
Installation
cargo install rsnip
Basic Usage
- Create a snippet:
rsnip edit --ctype shell # Opens your default editor
- Add some snippets in the format:
--- greeting
Hello {{ env_USER }}!
---
--- backup
tar -czf backup-{{ current_date|strftime('%Y%m%d') }}.tar.gz ./
---
- Use your snippets:
# List available snippets
rsnip list --ctype shell
# Copy a snippet to clipboard
rsnip copy --ctype shell --input greeting
# Interactive fuzzy search
rsnip complete --ctype shell --interactive
Shell Integration
Add to your .bashrc
:
# Optional: Add convenient alias
alias ,="rsnip copy --ctype shell --input"
# Enable tab completion
source <(rsnip --generate bash)
Now you can use:
, back<tab> # Will fuzzy-find and complete 'backup'
⚙️ Configuration
RSnip looks for configuration in the following locations:
~/.config/rsnip/config.toml
~/.rsnip/config.toml
/etc/rsnip/config.toml
Example configuration:
[snippet_types.shell]
source_file = "~/.config/rsnip/shell_snippets.txt"
description = "Shell command snippets"
[snippet_types.git]
source_file = "~/.config/rsnip/git_snippets.txt"
description = "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) }}
Environment variables are available as env_VARNAME
:
--- path
Current path is: {{ env_PATH }}
---
🤝 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
git clone https://github.com/yourusername/rsnip
cd rsnip
# Run tests
cargo test
# Build in release mode
cargo build --release
License
This project is licensed under the BSD 3 License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
License
🙏 Acknowledgments
- Inspired by various snippet managers and completion tools
- Built with Rust and several awesome crates including clap, minijinja, and skim
Dependencies
~19–34MB
~556K SLoC