Last active
May 24, 2026 12:06
-
-
Save BorisAnthony/160a441c5e34897527d58c0964b97b74 to your computer and use it in GitHub Desktop.
Fuzzy Command Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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