Skip to main content

Posts about shell

Snatching text from Herdr

A couple of years ago I wrote about Extrakto, a tmux plugin that lets me find text in my terminal and insert it into the command I'm typing. I've missed that little trick while working in Herdr. A build prints the path I need, and there I am selecting it with the mouse or typing it out again.

So I built herdr-snatch. It puts an fzf picker over Herdr's output. Search for a path, URL, commit hash, word, or whole line, then press Enter to insert it into the pane you came from.

For example, if a build prints src/foo/parser.rs, I can type vim, open Snatch with prefix+Tab, search for pars, and press Enter. The path appears after vim, ready for me to run the command. Snatch doesn't press Enter for me, which is probably for the best.

It searches the visible output in the current tab by default. If the text was in another pane, or has scrolled away, I can switch to the whole workspace or retained scrollback without losing my search. Ctrl-Y copies the selection to the clipboard, and Ctrl-O opens a URL or file instead of inserting it.

To install it, you'll need Herdr 0.8.2 or newer, Python 3.9 or newer, and fzf:

herdr plugin install catlee/herdr-snatch

The README has the key binding I use and the other picker shortcuts. Right now this is a small tool for the paths and bits of output I keep reusing. If it misses something useful in your terminal, let me know!

Extrakto!

One of my favourite tmux plugins is extrakto.

It's this amazing little plugin that lets you insert text by fuzzy finding within the current tmux session.

Why is this useful?

Think of how often you copy/paste some line of text from the terminal in order to pass it into another command. For example, the output of git status, or perhaps your build or test failed and you want to open that file in your editor (nvim of course!).

Instead of taking your fingers off your keyboard, extrakto lets you quickly find the text you want and add it at the current cursor position.

Using it is simple: just type your prefix (Ctrl-b for me), then tab, type your fuzzy search, and hit tab again to insert the text.