diff --git a/load-fzf b/load-fzf new file mode 100755 index 0000000..f7c74e3 --- /dev/null +++ b/load-fzf @@ -0,0 +1,61 @@ +#! /usr/bin/env bash + +BASE_0="$(basename ${0#-})" +BASE_SHELL="$(basename "$SHELL")" + +if [[ "$1" == "--force" ]]; then + [[ -e ~/.local/bin/fzf ]] && rm ~/.local/bin/fzf + [[ -e ~/.local/share/lib/fzf ]] && rm -fR ~/.local/share/lib/fzf + unset fzf +fi + +if [[ -z "$(type -t fzf)" || ! -e "$(type -p fzf)" ]]; then + curl -sS https://webi.sh/fzf | bash + + printf '%s\n' \ + 'Run the following and then try again:' \ + ' exec $SHELL -l' \ + '' +elif [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then + + FZF_CTRL_T_COMMAND="command find -L . -xdev -mindepth 1 \\( \ + -path '*/\\.*' \ + -xdev \ + -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \ + \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | cut -b3- \ + " + + FZF_ALT_C_COMMAND="command find -L . -xdev -mindepth 1 \\( \ + -path '*/\\.*' \ + -xdev \ + -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \ + \\) -prune \ + -o -type d + -print 2> /dev/null | cut -b3- \ + " + + SRCPATH="$HOME/.local/share/lib/fzf" + mkdir -p "$SRCPATH" + source_code_from() { + local SRCCODE="$SRCPATH/${1}" + [[ -r "$SRCCODE" ]] \ + || curl -sSLo "$SRCCODE" \ + "https://raw.githubusercontent.com/junegunn/fzf/master/shell/${1}" \ + && cat "$SRCCODE" + } + . <( source_code_from key-bindings.bash ) + . <( source_code_from completion.bash ) + unset SRCPATH +elif [[ "$1" == '-' ]]; then + cat "${BASH_SOURCE[0]}" +else + SCRIPT_NAME="$BASE_0" + printf '%s\n' \ + "It seems $SCRIPT_NAME was invoked as a script. It should be sourced instead." \ + 'The easiest way is to call it like this:' \ + " $ . <( $SCRIPT_NAME - ) # Note the '-' after the script's name" \ + '' +fi diff --git a/zfs_prune_all_snapshots b/zfs_prune_all_snapshots new file mode 100755 index 0000000..d354c90 --- /dev/null +++ b/zfs_prune_all_snapshots @@ -0,0 +1,5 @@ +#! /usr/bin/env bash + +DO="${DO:-echo}" +printf "%s\n" "${@}" | xargs -rn1 zfs list -r -t snapshot -Ho name -s creation -s name | xargs -rn1 ${DO} zfs destroy -v +