Sean

Weekly Brain Dump #22

- 540 words

At a Glance

FZF

I have been sleeping on how amazing fzf is! I stumbled across a pretty recent feature that makes it work great as a pop up inside of tmux. I’ve configured this to let me easily switch projects from within any tmux session with this little script.

#!/usr/bin/env bash
set -euo pipefail

repository_path=~/Syncthing/code
expanded_path=$(realpath ${repository_path})
path_length=$((${#expanded_path} + 1))

unset paths
for git in $(ls -d ${repository_path}/**/{,*/}.git); do
  paths+=(${git:$path_length:-5})
done

printf "%s\n" "${paths[@]}" | fzf \
  --popup \
  --reverse \
  --border-label "Switch to:" \
  --bind "enter:execute(tmux detach -E 'cd ${repository_path}/{} && devinator'),esc:become:"

It’s pretty simple, bash just makes everything look complicated. All it does is find all the git repositories in the specified directory and formats their paths. Then it hands that list to fzf to work with.

The magic comes from --popup which fzf uses to hook into tmux’s display-popup feature and also --bind which I’ve used here to do a couple things.

When you press enter on a result it runs tmux detach but then gets that to cd to the correct directory and run devinator which is my tool for easily booting up or reconnecting to a programming project.

The other little trick is esc:become: tells it to just become the process : if you press esc. This stops you getting an exit code of 130.

A terminal with tmux running my blog. An fzf popup appears and is then filtered down to taylor-org/website. This then exits out of tmux and boots up a new tmux with the Taylor website code shown. Then a tmux display-popup appears and we switch back to my blogs code.

THE BORING INTERNET: A bit of hope during these dark days

The Digg Lesson: Why Moderation Infrastructure Matters: I love learning about how moderation works for projects like this.

Making your own programming language is easier than you think (but also harder): More temptation to build my own programming language.

Replacing a 3 GB SQLite database with a 10 MB FST (finite state transducer) binary: A fun look at how Finnish can be compressed using FST and compressed 3GB of data down to 10MB.

The Go Compiler: A Deep Dive Into How Your Code Becomes a Binary: Feeding the “build a programming language” beast inside of me.


Comments