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:
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:
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 {}
}
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: kc () {
kubectl config get-contexts | tail -n +2 | fzf | cut -c 2- | awk ‘{print $1}’ | xargs kubectl config use-context
}
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.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).
—Edited for HN formatting