rsnip
Fast, Reliable, Yours: Why Snippets Outshine LLMs for boring Tasks
While large language models (LLMs) like ChatGPT are revolutionizing workflows with their smart completions and contextual insights, you don’t want to re-research a command or script every time you need it.
Why does a good snippet manager still matter?
Even in an age of intelligent assistants, there’s a compelling case for a specialized and fast snippet manager:
-
Speed: LLMs are slow when it comes to re-fetching familiar snippets. rsnip provides instant access via shell completion and fuzzy search (fzf).
-
Cost: Hitting a LLM every time can be costly in the long run.
-
Precision: rsnip delivers exactly what has been saved. No ambiguity, no approximations — just curated snippets.
-
Repeatability: LLMs are dynamic and the answers can change for the same question. You do not want to re-evaluate new answers every time.
A good snippet tool has been specifically designed for productivity and speed:
-
Fast: Don’t remember the exact snippet name? FZF-powered fuzzy search with live previews has you covered and lets explore all your snips on the fly. If you remember the name of your snippet good enough, tab-completion is even faster.
-
Smart: Jinja2-style templating makes for smart snippets.
Imagine you need a git
snippet to reset a branch while keeping untracked files. Look it up with an LLM and then save it:
--- git-reset-safe
: Reset branch but keep untracked files
git reset --soft HEAD~1
git stash save --keep-index
git stash apply
---
Now, anytime you need this snippet, rsnip has you covered — no need to consult the LLM again and check the correctness of the answer.
Use an LLM for the creative tasks like generating scripts and solving edge cases.
Use rsnip to save and reuse the solutions you’ll need repeatedly.
Features
1. Dynamic Templates
- Jinja2-based syntax allows to embed dynamic content:
- Environment variables:
{{ env_USER }}
- Date manipulations:
{{ current_date|strftime('%Y-%m-%d') }}
- Shell command outputs:
{{ 'git rev-parse HEAD'|shell }}
.
- Environment variables:
2. Interactive Fuzzy Search
- Leverage Skim-powered search for intuitive, real-time exploration of your snippets.
- Visual previews show snippet content, comments, and more.
3. Shell Integration
- Bash completion support: Type a partial snippet alias and press Tab.
- Quick aliases: Configure dedicated shortcuts (e.g.
,
for shell,,g
for git, etc.) for different snippet types.
4. Clipboard Integration
- Copy snippets directly to the clipboard for immediate use.
Example Use Cases
To configure rsnip use a configuration like the following:
[snippet_types.general]
alias = ",g"
source_file = "~/.config/rsnip/git_snippets.txt"
description = "Git snippets"
[snippet_types.shell]
alias = ","
source_file = "~/.config/rsnip/shell_snippets.txt"
description = "Shell command snippets"
Case 1: Boosting Shell Productivity
- Save your most-used AWS or Docker commands:
--- docker-clean : Clean unused Docker resources docker system prune -af ---
- Call it with:
, docker<tab>
Case 2: Dynamic Git Workflows
- Automate commit messages with dynamic content:
--- git-commit : Add files with auto-generated commit message git commit -m "Update on {{ current_date|strftime('%Y-%m-%d') }}" ---
- Use it interactively to select the appropriate command (fzf based selection):
,g git<tab>
Final Thoughts
In today’s world of on-the-fly LLM support many workflows change and mundane tasks are vanishing. However, as a developer I still need to come back to proven artefacts of my previous work because I understand them and know they work.
Often consulting a LLM in this case is not only expensive and slow, it is even counter-productive due to the fact that the correctness of the answer again has to be verified.
This is the sweet-spot for tools like rsnip.
So yes, I am using the old boring snippet tool all the time. Old school, still cool!
For documentation and examples, visit the rsnip GitHub page. 🚀