Skip to content

Instantly share code, notes, and snippets.

@BorisAnthony
Last active May 24, 2026 12:06
Show Gist options
  • Select an option

  • Save BorisAnthony/160a441c5e34897527d58c0964b97b74 to your computer and use it in GitHub Desktop.

Select an option

Save BorisAnthony/160a441c5e34897527d58c0964b97b74 to your computer and use it in GitHub Desktop.
Fuzzy Command Search
# Fuzzy Command Search
# ---
# Add to your .zshrc or whatever
# NB: Requires `fzf` be installed
# ---
# Usage: `cc` or `cc <search string>` to pre-populate the search query.
# ---
# https://gist.github.com/BorisAnthony/160a441c5e34897527d58c0964b97b74
# ---
command_search_fzf() {
command -v fzf >/dev/null || return 1
local selected
selected=$(
print -rl -- \
${(k)aliases} \
${(k)functions} \
${(k)builtins} \
${(k)commands} \
| grep -vE '^[.+:_\[\-]' \
| sort -u \
| fzf --query="$*" --reverse
)
[[ -n $selected ]] && print -z "$selected"
return 0
}
alias cc="command_search_fzf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment