mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
refactor(fzf): adopt code style and simplify function naming (#10514)
This commit is contained in:
parent
41c15a2159
commit
010c36d4ab
1 changed files with 137 additions and 137 deletions
|
@ -1,4 +1,4 @@
|
||||||
function setup_using_base_dir() {
|
function fzf_setup_using_base_dir() {
|
||||||
local fzf_base fzf_shell fzfdirs dir
|
local fzf_base fzf_shell fzfdirs dir
|
||||||
|
|
||||||
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
||||||
|
@ -58,7 +58,7 @@ function setup_using_base_dir() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setup_using_debian_package() {
|
function fzf_setup_using_debian() {
|
||||||
if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
|
if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
|
||||||
# Either not a debian based distro, or no fzf installed
|
# Either not a debian based distro, or no fzf installed
|
||||||
return 1
|
return 1
|
||||||
|
@ -96,7 +96,7 @@ function setup_using_debian_package() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_using_opensuse_package() {
|
function fzf_setup_using_opensuse() {
|
||||||
# OpenSUSE installs fzf in /usr/bin/fzf
|
# OpenSUSE installs fzf in /usr/bin/fzf
|
||||||
# If the command is not found, the package isn't installed
|
# If the command is not found, the package isn't installed
|
||||||
(( $+commands[fzf] )) || return 1
|
(( $+commands[fzf] )) || return 1
|
||||||
|
@ -125,7 +125,7 @@ function setup_using_opensuse_package() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_using_openbsd_package() {
|
function fzf_setup_using_openbsd() {
|
||||||
# openBSD installs fzf in /usr/local/bin/fzf
|
# openBSD installs fzf in /usr/local/bin/fzf
|
||||||
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
||||||
return 1
|
return 1
|
||||||
|
@ -149,21 +149,21 @@ function setup_using_openbsd_package() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function indicate_error() {
|
# Indicate to user that fzf installation not found if nothing worked
|
||||||
cat >&2 <<EOF
|
function fzf_setup_error() {
|
||||||
|
cat >&2 <<'EOF'
|
||||||
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
|
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
|
||||||
Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc
|
Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Indicate to user that fzf installation not found if nothing worked
|
fzf_setup_using_openbsd \
|
||||||
setup_using_openbsd_package \
|
|| fzf_setup_using_debian \
|
||||||
|| setup_using_debian_package \
|
|| fzf_setup_using_opensuse \
|
||||||
|| setup_using_opensuse_package \
|
|| fzf_setup_using_base_dir \
|
||||||
|| setup_using_base_dir \
|
|| fzf_setup_error
|
||||||
|| indicate_error
|
|
||||||
|
|
||||||
unset -f setup_using_opensuse_package setup_using_debian_package setup_using_base_dir indicate_error
|
unset -f -m 'fzf_setup_*'
|
||||||
|
|
||||||
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||||
if (( $+commands[rg] )); then
|
if (( $+commands[rg] )); then
|
||||||
|
|
Loading…
Reference in a new issue