1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-12 00:40:07 +00:00

Add fzf plugin (#6910)

This commit is contained in:
Maxime Brunet 2018-09-04 16:25:45 -04:00 committed by Marc Cornellà
parent 69e637c355
commit 86542dcd86
2 changed files with 69 additions and 0 deletions

19
plugins/fzf/README.md Normal file
View file

@ -0,0 +1,19 @@
# fzf
This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings
```zsh
# Set fzf installation directory path
export FZF_BASE=/path/to/fzf/install/dir
# Uncomment the following line to disable fuzzy completion
# export DISABLE_FZF_AUTO_COMPLETION="true"
# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
# export DISABLE_FZF_KEY_BINDINGS="true"
plugins=(
...
fzf
)
```

View file

@ -0,0 +1,50 @@
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
if [[ -z "${fzf_base}" ]]; then
fzfdirs=(
"${HOME}/.fzf"
"/usr/local/opt/fzf"
"/usr/share/fzf"
)
for dir in ${fzfdirs}; do
if [[ -d "${dir}" ]]; then
fzf_base="${dir}"
break
fi
done
if [[ -z "${fzf_base}" ]]; then
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
if [[ -d "${dir}" ]]; then
fzf_base="${dir}"
fi
fi
fi
fi
if [[ -n "${fzf_base}" ]]; then
# Setup fzf
# ---------
if [[ ! "$PATH" == *$fzf_base/bin* ]]; then
export PATH="$PATH:$fzf_base/bin"
fi
# Auto-completion
# ---------------
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
[[ $- == *i* ]] && source "$fzf_base/shell/completion.zsh" 2> /dev/null
fi
# Key bindings
# ------------
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
source "$fzf_base/shell/key-bindings.zsh"
fi
else
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
fi
unset fzf_base