From b33e57d67a9cad7f5901bc2224582d9b4b8961d1 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Mon, 6 Dec 2021 12:41:54 +0100 Subject: [PATCH] shell/fzf: add multiple methods for loading --- shell/fzf.sh | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/shell/fzf.sh b/shell/fzf.sh index d718308..3826182 100755 --- a/shell/fzf.sh +++ b/shell/fzf.sh @@ -1,9 +1,35 @@ #!/usr/bin/env bash -[ -r /usr/share/fzf/key-bindings.bash ] && . /usr/share/fzf/key-bindings.bash -[ -r /usr/share/fzf/completion.bash ] && . /usr/share/fzf/completion.bash - -if command -v fzf-share >/dev/null; then - source "$(fzf-share)/key-bindings.bash" - source "$(fzf-share)/completion.bash" +# Arch +if [ "${BASH_VERSION}" ] && [ -r /usr/share/fzf/key-bindings.bash ]; then + # shellcheck source=/dev/null + . /usr/share/fzf/key-bindings.bash +fi +if [ "${BASH_VERSION}" ] && [ -r /usr/share/fzf/completion.bash ]; then + # shellcheck source=/dev/null + . /usr/share/fzf/completion.bash +fi + +if [ "${ZSH_VERSION}" ] && [ -r /usr/share/fzf/key-bindings.zsh ]; then + # shellcheck source=/dev/null + . /usr/share/fzf/key-bindings.zsh +fi +if [ "${ZSH_VERSION}" ] && [ -r /usr/share/fzf/completion.zsh ]; then + # shellcheck source=/dev/null + . /usr/share/fzf/completion.zsh +fi + +# NixOS +if [ "${BASH_VERSION}" ] && command -v fzf-share >/dev/null; then + # shellcheck source=/dev/null + . "$(fzf-share)/key-bindings.bash" + # shellcheck source=/dev/null + . "$(fzf-share)/completion.bash" +fi + +if [ "${ZSH_VERSION}" ] && command -v fzf-share >/dev/null; then + # shellcheck source=/dev/null + . "$(fzf-share)/key-bindings.zsh" + # shellcheck source=/dev/null + . "$(fzf-share)/completion.zsh" fi