m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

[completion] Allow users to customize fzf options via _fzf_comprun

Related #1809 #1850
This commit is contained in:
Junegunn Choi
2020-02-20 00:28:16 +09:00
parent 54891d11e0
commit 5215415315
3 changed files with 63 additions and 26 deletions

View File

@@ -403,6 +403,21 @@ _fzf_compgen_path() {
_fzf_compgen_dir() {
fd --type d --hidden --follow --exclude ".git" . "$1"
}
# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf "$@" --preview 'tree -C {} | head -200' ;;
export|unset) fzf "$@" --preview "eval 'echo \$'{}" "$@" ;;
ssh) fzf "$@" --preview 'dig {}' ;;
*) fzf "$@" ;;
esac
}
```
#### Supported commands