rsnip

Crates.iorsnip
lib.rsrsnip
version
sourcesrc
created_at2025-01-05 11:04:59.317675
updated_at2025-01-08 21:11:23.874481
descriptionA universal command-line snippet manager
homepage
repositoryhttps://github.com/sysid/rsnip
max_upload_size
id1504668
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
sysid (sysid)

documentation

https://docs.rs/rsnip

README

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.

CI Status Crates.io License

🌟 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

  1. Create a snippet:
rsnip edit --ctype shell  # Opens your default editor
  1. Add some snippets in the format:
--- greeting
Hello {{ env_USER }}!
---

--- backup
tar -czf backup-{{ current_date|strftime('%Y%m%d') }}.tar.gz ./
---
  1. 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 /path/to/rsnip.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
Commit count: 20

cargo fmt