fzf.plugin.zsh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
  2. if [[ -z "${fzf_base}" ]]; then
  3. fzfdirs=(
  4. "${HOME}/.fzf"
  5. "/usr/local/opt/fzf"
  6. "/usr/share/fzf"
  7. )
  8. for dir in ${fzfdirs}; do
  9. if [[ -d "${dir}" ]]; then
  10. fzf_base="${dir}"
  11. break
  12. fi
  13. done
  14. if [[ -z "${fzf_base}" ]]; then
  15. if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
  16. if [[ -d "${dir}" ]]; then
  17. fzf_base="${dir}"
  18. fi
  19. fi
  20. fi
  21. fi
  22. if [[ -n "${fzf_base}" ]]; then
  23. # Setup fzf
  24. # ---------
  25. if [[ ! "$PATH" == *$fzf_base/bin* ]]; then
  26. export PATH="$PATH:$fzf_base/bin"
  27. fi
  28. # Auto-completion
  29. # ---------------
  30. if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
  31. [[ $- == *i* ]] && source "$fzf_base/shell/completion.zsh" 2> /dev/null
  32. fi
  33. # Key bindings
  34. # ------------
  35. if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
  36. source "$fzf_base/shell/key-bindings.zsh"
  37. fi
  38. else
  39. print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
  40. "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
  41. fi
  42. unset fzf_base