New Tricks
2020-01-18

I’ve been working on incrementally incorporating new tricks, techniques and tools into my daily life to improve my workflow. These are some new things I’ve recently begun using that I enjoy.

  • peco Simplistic interactive filtering tool
  • yank Yank terminal output to clipboard
  • vim - neovim/vim read from stdin
  • "*yy vim register
  • hexyl A command-line hex viewer
  • bat A cat(1) clone with wings
  • bropages examples for command line programs

These CLI tools help further my OCD-driven quest to avoid using the mouse as much as possible. Developers that work with the CLI clients for docker, kubernetes, MySQL, etc often must take a value from the (often complex) output of one command and use it as an input argument to another command. For example, docker ps and docker inspect or docker rm -f. Or how about kubectl config get-contexts and kubectl config use-context "$context"

peco, yank, vim -, * vim register

By piping the output of a command to peco and yank you can filter results and then use the HJKL keys to navigate values and copy a value to your clipboard. This is much, much less frustrating than taking your hands off your keyboard and going for a mouse, dragging the cursor over the value you want, click+dragging to select it and then copying.

docker, kubectl, and other cli tools can often produce lengthy output in your terminal. I’ve found that piping the outputs of these commands into VIM where I’m comfortable searching and navigating is much better. Also useful is the “*” vim register which copies values to your system clipboard.

Two commands with long output. Piping the output into vim makes working with it easier
$ kubectl describe pod "$POD_ID" | vim -
$ docker inspect "$CID" | vim -
See it in action

tmux

For a long time I used iterm2 panes and tabs to organize my terminals. My primary editor is neovim, so I spend 95% of my time in my terminal. I prefer to use a mouse as infrequently as possible so I bound ⌥ +hjkl to switch split panes. The biggest limitation I encountered on a daily basis was I couldn’t easily resize split panes without using my mouse. In the interest of having a more cross-platform compatible development flow, I decided to just switch to primarily tmux. (I’ve also switched from iterm to kitty since kitty is much faster) .tmux.conf

hexyl / bat

The other day I was working on a project where I’m using the cedict Chinese-English dictionary. To make the file easier to work with I converted it to an Sqlite3 database file (cedict-sqlite3). When I was in the process of writing a shell script to iterate through the lines of the file I kept getting an error where there seemed to be a weird control character terminating each line. So I used a hex viewer to find out exactly what was going on with the file.

hexyl is a utility similar to xxd, except it nicely color codes bytes depending on their type (ascii, non-printable, etc). sharkdp has quite a few really great utilities, check him out. Shortly after I found hexyl I also started using bat - an improved version of cat.

bropages

Bropages is great. Often I just want a quick reminder example of the syntax or cli flags for common unix utilities. Say I want to know how to use curl to follow redirects? Or maybe I forgot the exact syntax of find. One quick call to bro curl or bro find and 910 times I’ve got the answer I’m looking for.

Back to Top


Back to Top