If you’re anything like me, you write little helper scripts to save typing and to automate tasks
Fzf is a CLI tool that you can send a list and fuzzy search/select one or more items.
Github:
Installation
# Mac
brew install fzf
# Arch
pacman -S fzf
# Ubuntu
apt install fzf
# Fedora
dnf install fzf
# mise
mise use fzf
Simple examples, echoing a list and selecting a single value
echo -e '1\n2\n3\n4' | fzf
echo -e "1,2,3,4" | tr ',' '\n' | fzf
Customize the text prompt
fzf --prompt "Select AWS account: "
Preview file contents as you search
With cat
# using cat as preview command
fzf --preview 'cat {}'
With bat
# using bat as preview command
fzf --preview 'bat --style=numbers --color=always {}'
Change git branch
git switch $(git branch | sed 's/*//g' | xargs | tr ' ' '\n' | fzf)
Switch kubernetes context
kubectl config use-context $(yq -r '.contexts[].name' ~/.kube/config | fzf)
Tip
Checkout the Github repo or read the man page to learn more!