Update 05.04.2026
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
function fzf_setup_using_fzf() {
|
||||
(( ${+commands[fzf]} )) || return 1
|
||||
|
||||
# we remove "fzf " prefix, this fixes really old fzf versions behaviour
|
||||
# see https://github.com/ohmyzsh/ohmyzsh/issues/12387
|
||||
local fzf_ver=${"$(fzf --version)"#fzf }
|
||||
|
||||
autoload -Uz is-at-least
|
||||
is-at-least 0.48.0 ${${(s: :)fzf_ver}[1]} || return 1
|
||||
|
||||
eval "$(fzf --zsh)"
|
||||
}
|
||||
|
||||
function fzf_setup_using_base_dir() {
|
||||
local fzf_base fzf_shell fzfdirs dir
|
||||
|
||||
@@ -8,7 +21,9 @@ function fzf_setup_using_base_dir() {
|
||||
"${HOME}/.fzf"
|
||||
"${HOME}/.nix-profile/share/fzf"
|
||||
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
|
||||
"${MSYSTEM_PREFIX}/share/fzf"
|
||||
"/usr/local/opt/fzf"
|
||||
"/opt/homebrew/opt/fzf"
|
||||
"/usr/share/fzf"
|
||||
"/usr/local/share/examples/fzf"
|
||||
)
|
||||
@@ -59,8 +74,8 @@ function fzf_setup_using_base_dir() {
|
||||
|
||||
|
||||
function fzf_setup_using_debian() {
|
||||
if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
|
||||
# Either not a debian based distro, or no fzf installed
|
||||
if (( ! $+commands[apt] && ! $+commands[apt-get] )); then
|
||||
# Not a debian based distro
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -71,11 +86,19 @@ function fzf_setup_using_debian() {
|
||||
|
||||
case $PREFIX in
|
||||
*com.termux*)
|
||||
if [[ ! -f "${PREFIX}/bin/fzf" ]]; then
|
||||
# fzf not installed
|
||||
return 1
|
||||
fi
|
||||
# Support Termux package
|
||||
completions="${PREFIX}/share/fzf/completion.zsh"
|
||||
key_bindings="${PREFIX}/share/fzf/key-bindings.zsh"
|
||||
;;
|
||||
*)
|
||||
if [[ ! -d /usr/share/doc/fzf/examples ]]; then
|
||||
# fzf not installed
|
||||
return 1
|
||||
fi
|
||||
# Determine completion file path: first bullseye/sid, then buster/stretch
|
||||
completions="/usr/share/doc/fzf/examples/completion.zsh"
|
||||
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
|
||||
@@ -125,6 +148,27 @@ function fzf_setup_using_opensuse() {
|
||||
return 0
|
||||
}
|
||||
|
||||
function fzf_setup_using_fedora() {
|
||||
(( $+commands[fzf] )) || return 1
|
||||
|
||||
local completions="/usr/share/zsh/site-functions/fzf"
|
||||
local key_bindings="/usr/share/fzf/shell/key-bindings.zsh"
|
||||
|
||||
if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
source "$completions" 2>/dev/null
|
||||
fi
|
||||
|
||||
if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
|
||||
source "$key_bindings" 2>/dev/null
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function fzf_setup_using_openbsd() {
|
||||
# openBSD installs fzf in /usr/local/bin/fzf
|
||||
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
||||
@@ -178,7 +222,7 @@ function fzf_setup_using_macports() {
|
||||
(( $+commands[fzf] )) || return 1
|
||||
|
||||
# The fzf-zsh-completion package installs the auto-completion in
|
||||
local completions="/opt/local/share/zsh/site-functions/fzf"
|
||||
local completions="/opt/local/share/fzf/shell/completion.zsh"
|
||||
# The fzf-zsh-completion package installs the key-bindings file in
|
||||
local key_bindings="/opt/local/share/fzf/shell/key-bindings.zsh"
|
||||
|
||||
@@ -207,9 +251,11 @@ Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
|
||||
EOF
|
||||
}
|
||||
|
||||
fzf_setup_using_openbsd \
|
||||
fzf_setup_using_fzf \
|
||||
|| fzf_setup_using_openbsd \
|
||||
|| fzf_setup_using_debian \
|
||||
|| fzf_setup_using_opensuse \
|
||||
|| fzf_setup_using_fedora \
|
||||
|| fzf_setup_using_cygwin \
|
||||
|| fzf_setup_using_macports \
|
||||
|| fzf_setup_using_base_dir \
|
||||
|
||||
Reference in New Issue
Block a user