diff --git a/_home/private_dot_config/sz.env/PATH_truestuff.env b/_home/private_dot_config/sz.env/PATH_truestuff.env index bced20c..88e9bea 100644 --- a/_home/private_dot_config/sz.env/PATH_truestuff.env +++ b/_home/private_dot_config/sz.env/PATH_truestuff.env @@ -1,14 +1,9 @@ #!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' -if is_cmd midclt; then +if is_truenas && is_cmd midclt && [ -z "$SCALE_POOL" ]; then export SCALE_POOL="$(midclt call "kubernetes.config" 2>/dev/null | jq -r '.pool')" - [ -n "$SCALE_POOL" ] && [ "$SCALE_POOL" != "null" ] || export SCALE_POOL="$(midclt call "pool.query" 2>/dev/null | jq -r '.[0].name')" [ -d "/mnt/$SCALE_POOL" ] || unset SCALE_POOL fi -[ -n "$SCALE_POOL" ] \ -&& export SCALE_POOL_ROOT=/mnt/$SCALE_POOL \ -&& PATH="$SCALE_POOL_ROOT/_apps.data/_scripts/truestuff:$PATH" \ -&& PATH="$SCALE_POOL_ROOT/data/scripts/truestuff:$PATH" \ -&& export PATH +[ -n "$SCALE_POOL" ] && export SCALE_POOL_ROOT=/mnt/$SCALE_POOL && export PATH="$SCALE_POOL_ROOT/_apps.data/_scripts/truestuff:$PATH" diff --git a/_home/private_dot_local/bin/executable_load-zellij b/_home/private_dot_local/bin/executable_load-zellij index 4399ad7..0a6deb2 100644 --- a/_home/private_dot_local/bin/executable_load-zellij +++ b/_home/private_dot_local/bin/executable_load-zellij @@ -15,49 +15,37 @@ BASE_SHELL=$(basename "$SHELL") if is_sourced; then zellij-cleanup() { - which zellij > /dev/null && which zellij | grep -E "^$HOME" | ${SUDO:-} xargs -tr rm - [[ -d "$HOME/.cache/zellij" ]] && echo "$HOME/.cache/zellij" | ${SUDO:-} xargs -tr rm -fR - find /tmp -maxdepth 1 -mindepth 1 -type d -name 'zellij*' -print0 | ${SUDO:-} xargs -r0t rm -fR - if [[ -d "$HOME/.cache/zellij" ]]; then - printf 'Zellij cleanup failed to remove the cache directory, you might still have a zellij session active.\n' - else - printf 'Zellij has been cleaned up, you can now reinstall it.\n' - unset zellij-cleanup - fi - } - refresh-zellij() { - if [ -z "$(which zellij)" ] && ! [ -x ~/.local/bin/zellij ]; then - if [[ ! -r /tmp/zellij/bootstrap/zellij ]]; then - printf "Grabbing zellij from the web!\n" - bash <(curl -sL zellij.dev/launch) "--help" > /dev/null 2>&1 || true - fi - if [[ -r /tmp/zellij/bootstrap/zellij ]]; then - mv /tmp/zellij/bootstrap/zellij ~/.local/bin/zellij - rm -fR /tmp/zellij - fi - fi - refresh-zellij() { :; } + type -pa zellij > /dev/null && type -pa zellij | sed -Ee 's/^.* is //' | awk '{ print $1 }' | grep -E "^$HOME" | xargs -tr rm + [[ -d "$HOME/.cache/zellij" ]] && echo "$HOME/.cache/zellij" | xargs -rt rm -fR + find /tmp -maxdepth 1 -mindepth 1 -type d -name 'zellij*' -print0 | xargs -r0t rm -fR + printf 'Zellij has been cleaned up, you can now reinstall it.\n' } zellij() { - refresh-zellij - if [[ $# -eq 0 ]]; then - env zellij attach -c $USER@$(hostname) - else - env zellij "${@}" + if [[ ! -x ~/bin/zellij ]]; then + if [[ -x $HOME/.cache/chezmoi/tmp/zellij/zellij ]]; then + ln --symbolic --relative $HOME/.cache/chezmoi/tmp/zellij/zellij ~/bin + elif [[ ! -x /tmp/zellij/bootstrap/zellij ]]; then + printf "Grabbing zellij from the web!\n" + bash <(curl -sL zellij.dev/launch) "${@}" && return + fi fi + if [[ -e /tmp/zellij/bootstrap/zellij ]]; then + mv /tmp/zellij/bootstrap/zellij ~/bin/zellij + rm -fR /tmp/zellij + fi + if [[ -x ~/bin/zellij ]]; then + ~/bin/zellij "${@}" + fi + } zellij-completion() { - if [[ "${BASE_SHELL}" == "zsh" ]]; then - . <( env zellij setup --generate-completion zsh | sed -Ee 's/^(_(zellij) ).*/compdef \1\2/' ) - else - . <( env zellij setup --generate-completion "$BASE_SHELL" ) - fi - } -${SET:-:} -x - if [[ -n "$(which zellij)" ]]; then - zellij-completion + if [[ "${BASE_SHELL}" == "zsh" ]]; then + . <( zellij setup --generate-completion zsh | sed -Ee 's/^(_(zellij) ).*/compdef \1\2/' ) + else + . <( zellij setup --generate-completion "$BASE_SHELL" ) fi -${SET:-:} -x + } + zellij-completion # Was needed when zsh would load # . <( zellij setup --generate-completion "$BASE_SHELL" | sed -ne '/^function/,$p' ) if [[ -z "$ZELLIJ_SESSION_NAME" ]]; then diff --git a/_home/private_dot_local/bin/executable_szetup-kubectl4k3s b/_home/private_dot_local/bin/executable_szetup-kubectl4k3s index 1ec4e51..d82f8b0 100644 --- a/_home/private_dot_local/bin/executable_szetup-kubectl4k3s +++ b/_home/private_dot_local/bin/executable_szetup-kubectl4k3s @@ -5,7 +5,7 @@ # SC1090 Can't follow non-constant source # User basename instead of ${0:##*/} to be POSIX compliant -BASE_0=${BASE_0:-$(basename ${0#-})} +BASE_0=${BASE_0:-$(basename $0)} SCRIPT_DIR=${SCRIPT_DIR:-"$( cd -- "$( dirname -- "$0" )" &> /dev/null && pwd )"} BASE_SHELL=$(basename "$SHELL") @@ -15,7 +15,7 @@ is_sourced() { case $ZSH_EVAL_CONTEXT in *:file:*) return 0;; esac else # case ${0##*/} in dash|-dash|bash|-bash|ksh|-ksh|sh|-sh) return 0;; esac - case "${BASE_0}" in $BASE_SHELL|-$BASE_SHELL) return 0;; esac + case "$(basename $0)" in $BASE_SHELL|-$BASE_SHELL) return 0;; esac fi return 1; # NOT sourced. }