Techronomicon

Mastering Efficiency: Unleashing the Power of 'Pet' Snippet Manager in Your Development Workflow

2024-03-11T20:05:22+0000

I've been a devoted user of pet, a snippet manager crafted in Go, for the past few months. Its name, intriguingly simple, I'm pretty sure is meant to cleverly play off the word 'snippet'. I took quite a while trying to figure out what the acronym pet meant, until I came to the aforementioned realisation! Snippet managers, in their essence, are brilliantly simple and convenient. They serve as a repository for those often elusive single-line commands, the kind that seem to slip through the hands of our memory just when we need them most.


These snippets don't need to be complex; they could be as mundane as the command to enter a Docker container—a task I used to forget frequently before integrating it into my pet library.


Accessing a snippet in pet can be achieved through three commands: pet clip, pet search, and pet exec.


The pet clip command is particularly useful for copying snippets to the clipboard, ideal for when you're not looking to execute a command immediately or need to transfer it outside the terminal.


pet search prints the snippet directly to the terminal, a feature I find less useful than pet clip, though it serves its purpose for those wanting a quick glance at their snippet without immediate execution.


However, the real star of the show is pet exec. This command executes a snippet instantly upon selection, eliminating the need to paste it manually. This is particularly useful for those times when speed is of the essence, making it my go-to feature in pet.


Figure 1: The pet logo, kinda rad right?


Beyond these, pet of course offers the expected functionality to create and edit snippets (new and edit). Yet, the two following features stand out to me as particularly powerful.


The first is the parameter feature, which introduces a level of dynamism to snippets by allowing you to specify variable parts. For instance, the snippet sudo docker exec -it <CONTAINER_NAME=techronomicon> bash lets you alter the 'CONTAINER_NAME' on the fly when the snip is executed. The '=' sign sets a default value, guiding you towards a typical use case or commonly used value, as illustrated with 'techronomicon' which I most often find myself jumping in to.


The second feature I highly appreciate is the built-in sync functionality. One of my requirements for a snippet manager was the ability to back up and version control my snippets. pet seamlessly integrates with Gist and GitLab Snippets, enabling both manual and auto-sync options to ensure your snippets are always up to date and safely stored. The auto-sync is particularly handy - it executes on the save of a snip for me, sending my snips up to Gist.


While I've touched on my favourite aspects, pet boasts an array of features waiting to be explored on its GitHub repository at here, many of which I'm yet to explore. It's available for macOS and several Linux distros, with a prebuilt binary for those who prefer to jive that way, and the option to build from source thanks to the nature of its open-source project.


In conclusion, pet is an awesome tool that I wholeheartedly recommend to anyone, whether you're new to snippet managers or looking for an upgrade. Its blend of simplicity, flexibility, and power makes it an invaluable addition to any developer's toolkit.

>> Back to Home