Improving Shell Workflows with Fzf
I use fzf in this very way and could have written this article if I weren’t lazy lol. However, I can add two other use cases:<p>1. I use i3wm at home (haven’t yet made the jump into Sway/Wayland), and don’t want to change my screen resolution by opening an app, clicking with my mouse, and then waiting. So I use fzf for quick resolution changes using xrandr:<p><pre><code>  cr() {
    xrandr | sed -En “s/^[ ]+([0-9]{3,4}x[0-9]{3,4}0.\*/\1/p” | fzf | xargs -I{} xrandr —output HDMI-0 —mode {}
  }
</code></pre>
2. At work I switch between multiple Kubernetes contexts during the day. To make the switch fast without typing a sentence, I will use this helper function:<p><pre><code>  kc () {
     kubectl config get-contexts | tail -n +2 | fzf | cut -c 2- | awk ‘{print $1}’ | xargs kubectl config use-context
  }
</code></pre>
I found this to be better than tab-completion because with tab completion I only get the name of the context, and not the cluster/user/namespace fields that make it easier to select the right one.<p>Use the above at your own risk, as they are fast hack-ups and could be far more clear (my sed skills are prone to error and overly verbose).<p>—Edited for HN formatting