revamped load-fzf and load-zellij

This commit is contained in:
Lockszmith 2024-04-29 23:23:19 -04:00
parent a18b8506a4
commit 367e634527
2 changed files with 46 additions and 9 deletions

View file

@ -1,7 +1,21 @@
#! /usr/bin/env bash
# shellcheck disable=SC2034,SC1090
# SC2034 variables appear unsued. export if used externally
# - uneeded, as this checked whether script is sourced
# SC1090 Can't follow non-constant source
BASE_0="$(basename ${0#-})"
BASE_SHELL="$(basename "$SHELL")"
# Helper function
is_sourced() {
if [ -n "$ZSH_VERSION" ]; then
case $ZSH_EVAL_CONTEXT in *:file:*) return 0;; esac
else # Add additional POSIX-compatible shell names here, if needed.
case ${0##*/} in dash|-dash|bash|-bash|ksh|-ksh|sh|-sh) return 0;; esac
fi
return 1; # NOT sourced.
}
BASE_0=${BASE_0:-$0}
BASE_SHELL=$(basename "$SHELL")
if [[ "$1" == "--force" ]]; then
[[ -e ~/.local/bin/fzf ]] && rm ~/.local/bin/fzf
@ -12,11 +26,12 @@ fi
if [[ -z "$(type -t fzf)" || ! -e "$(type -p fzf)" ]]; then
curl -sS https://webi.sh/fzf | bash >&2
# shellcheck disable=SC2016 # $ inside single quotes is intentional
printf '%s\n' \
'Run the following and then try again:' \
' exec $SHELL -l' \
'' >&2
elif [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then
elif is_sourced; then
FZF_CTRL_T_COMMAND="command find -L . -xdev -mindepth 1 \\( \
-path '*/\\.*' \
@ -28,6 +43,9 @@ elif [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then
-o -type l -print 2> /dev/null | cut -b3- \
"
# shellcheck disable=SC2034
# variable appears unsued. export if used externally
# - uneeded, as script is sourced
FZF_ALT_C_COMMAND="command find -L . -xdev -mindepth 1 \\( \
-path '*/\\.*' \
-xdev \