Discover more from hrbrmstr's Daily Drop
Drop #314 (2023-08-10): Textual Revolution
Micro; Peco; Grip
A side project I've referenced a few times (but not provided much context on) involves alot of text files, so I've been at the CLI quite a bit and have had “text processing” at the forefront of daily noggin' thoughts.
So, today's Drop features three text-focused tools that should be fun and useful for all.
This is an AI-generated summary of today’s Drop.
Today I used Perplexity Labs’s Llama-2-13b beta with my go-to “please provide a concise three-bullet summary of this with a link to the main resource in each section” prompt.
It failed miserably at the “links” (so I deleted them) and was also way less impressive when it came to extracting the salient portions of each section. It seems there is quite a bit of pre-prompt-engineering going on behind the scenes at Poe, Perplexity-proper, Anthropic, and ChatGPT.
Micro: A modern, intuitive terminal editor with features such as proper mouse support, syntax highlighting, and multiple cursors. It is written in Go and has a simple JSON config format.
Peco: An interactive filtering tool that simplifies the process of sifting through data. It allows for real-time filtering and customizable key bindings, and supports multiple selection and flexible configuration.
Grip: A tool that generates instant HTML previews of Markdown files, making it easy to preview and confirm the rendering of your README files before committing changes. It is written in Python and can be used with any Markdown editor.
Bram Moolenaar, the creator of Vim, passed away this week at a far too young of an age. Vim is my go-to terminal editor, but it is far from the only terminal-based editor out there. I'm not sure which of the (checks current count) 491 new, alternative social media platforms out there I saw this on, but in one of b0rk's threads, someone mentioned the Micro editor. I had not heard of it before this or used it, so I took some time to poke at it, and it is 100% cool enough to dedicate a Drop section to.
Now, I will wholeheartedly admit that Vim is not intuitive to the vast majority of folks who are forced (or like) to use a terminal to get things done. There would not be a gazillion “quit vim” jokes/memes out there if that assertion were not true. As an alternative, I — and others — often suggest folks use nano. It is easier to use out-of-the-box, but it's always felt clunky and more limited than necessary to me. Having tried Micro this week, I can honestly say it offers a fresh and — dare I say — modern take on editing at the command line.
First off, Micro is written in Go, so it's a single binary you can install locally without a package manager or elevated permissions. Since nearly every Drop reader uses a terminal-based editor, I'll respect your time and knowledge and hit the core bits bullet-style. We’ll focus on how it compares to nano (since that's what it aims to replace) and vim (b/c there's no hope for emacs folks; y'all are lost forever):
Micro's keybindings are similar to those of GUI-based editors, making it more familiar to folks who are not accustomed to the unique keybindings of vim or nano.
Unlike nano, Micro has proper mouse support, allowing folks to scroll the window, click anywhere to move the cursor, and drag to select text. This works incredibly well.
Micro supports syntax highlighting for over 75 languages and has 7 default color schemes to choose from. This is one aspect of Golang-based tools I really 💙, as it's so stupid easy to bake a bunch of components right into the binary.
Micro supports Sublime Text-style multiple cursors, giving us more editing power directly in the terminal. Multiple-cursors are, IMO, table stakes for any modern editor.
Micro has a full-blown plugin system, with plugins written in Lua and a plugin manager to automatically download and install plugins.
Micro supports undo and redo functionality, making it easier to recover from mistakes.
Micro lets us configure options and rebind keys using a simple JSON format, and further customization can be done using Lua.
Micro supports 16, 256, and true color themes, making it visually appealing and customizable.
Micro is designed to work efficiently right out of the box. While it's highly configurable, most folks shouldn't find much to tweak initially.
Micro's help system is
Zachary Yedidia, and others who have contributed to his work, have done a fantastic job with this editor and encourage readers to give it a go. It's on all my systems and is now part of the default install components of any new container, VM, or VPS.
Oh, and I wrote the Markdown for this edition in Micro (which you already knew from the section header image).
If you've ever found yourself lost in a sea of data, trying to pinpoint that one nugget of information you desperately need, then Peco might just be the tool you've been searching for. Peco is an interactive filtering tool that simplifies the process of sifting through data, making it easier and faster to find what you're looking for. Think of it as a more dynamic and interactive version of the traditional 'grep' command.
Peco's primary strength lies in its ability to filter data interactively. As you type, the results are narrowed down in real-time, allowing you to quickly hone in on the information you need. The section header image is me seeing how many folks were hitting my CISA KEV RSS feed this morning via pec-ing at my Nginx access logs.
Peco also allows you to customize key bindings, ensuring that the tool can be tailored to individual preferences and workflows. This is a great feature for users who want to be able to work as efficiently as possible.
In addition to its interactive filtering capabilities, Peco also supports multiple selection and flexible configuration. This means that you can select multiple items from the filtered results and that you can adjust Peco's behavior and appearance to suit your needs.
And, Peco is extensible with plugins. This ensures that the tool remains versatile and can adapt to a wide range of use cases. Whether you need to filter data from a specific source or you need to perform a specific set of operations on the data, Peco has a plugin for you.
The single Golang binary drops in anywhere (just like Micro) and has sane, succinct options (which I know I'll regret putting into a Substack code block):
Usage: peco [options] [FILE] Options: -h, --help show this help message and exit --query initial value for query --rcfile path to the settings file --version print the version and exit -b, --buffer-size number of lines to keep in search buffer --null expect NUL (\0) as separator for target/output --initial-index position of the initial index of the selection (0 base) --initial-matcher specify the default matcher (deprecated) --initial-filter specify the default filter --prompt specify the prompt string --layout layout to be used. 'top-down' or 'bottom-up'. default is 'top-down' --select-1 select first item and immediately exit if the input contains only 1 item --on-cancel specify action on user cancel. 'success' or 'error'. default is 'success'. This may change in future versions --selection-prefix use a prefix instead of changing line color to indicate currently selected lines. default is to use colors. This option is experimental --exec execute command instead of finishing/terminating peco. Please note that this command will receive selected line(s) from stdin, and will be executed via '/bin/sh -c' or 'cmd /c' --print-query print out the current query as first line of output
I only recently discovered Peco, but it's now also on all existing systems and part of the default install routines of new ones.
I'm slowly migrating all non-R project plain markdown README's to Quarto, since Quarto’s GitHub-flavored Markdown renders makes it dirt simple to ensure things look right before committing changes.
Not everyone uses Quarto, and it would be great if there was an editor-agnostic way to have the same commit-confidence for any project. Well, we can strike the “wishes” part of that first sentence by introducing Grip, which stands for “GitHub Readme Instant Preview”.
Grip is a small Python tool that you point at a Markdown file and either generate an HTML preview file directory, or have it fire up a mini webserver to give you a (live) preview of the rendering.
It uses the GitHub Markdown REST API to perform these magicks, and drops in fairly well on most systems I've tried it on via:
$ python3 -m pip install grip
(Some of my systems are permanently in Python dependency Hades, meaning I had to waste time and space making virtual environments for this on some of them.)
$ grip index.md * Serving Flask app 'grip.app' * Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://localhost:6419 Press CTRL+C to quit
let me view today’s Drop with Grip (which you can see in the section header).
There's plenty more config and usage bits at the repo itself.
I'd be curious to know about your fav Peco alternatives (since I think there has to be quite a bit of activity in this particular space). ☮
hrbrmstr's Daily Drop is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.