From f3bd0e804de06d48f6e7bc2eb99d5ab9ed1b41ae Mon Sep 17 00:00:00 2001 From: "Lockszmith (kateryna)" Date: Sat, 21 Sep 2024 12:55:51 -0400 Subject: [PATCH] Add load-webi --- .../bin/executable_load-webi | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 _home/private_dot_local/bin/executable_load-webi diff --git a/_home/private_dot_local/bin/executable_load-webi b/_home/private_dot_local/bin/executable_load-webi new file mode 100644 index 0000000..32e58fd --- /dev/null +++ b/_home/private_dot_local/bin/executable_load-webi @@ -0,0 +1,40 @@ +#! /usr/bin/env bash + +# 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 is_sourced; then + webi() { + if [[ ! -x "${HOME}/.local/bin/webi" ]]; then + printf '%s\n' \ + "webi isn't installed, install by running:" \ + " curl -sS https://webi.sh/webi | sh" + return + fi + ${HOME}/.local/bin/webi "${@}" + } + if is_cmd webi; then + webi + fi + +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 +