From 7ce0f968e818ac080639e7e7d8a6d928d7bd4178 Mon Sep 17 00:00:00 2001 From: "Lockszmith (kateryna)" Date: Thu, 19 Sep 2024 00:31:48 -0400 Subject: [PATCH] =First commit --- _home/.chezmoiexternal.yaml | 5 ++ _home/.chezmoiscripts/.keep | 0 _home/dot_bashrc | 24 ++++++ _home/dot_profile | 31 +++++++ _home/dot_zshrc | 8 ++ .../000_stop_on_non_interactive_sessions.env | 6 ++ .../sz.env/PATH_home_bin.env | 4 + _home/private_dot_config/sz.env/PATH_node.env | 3 + .../sz.env/PATH_truestuff.env | 9 ++ .../sz.env/PATH_zz_cleanup.env | 12 +++ .../sz.env/aaa_zsh_0_perp.env | 60 ++++++++++++++ .../sz.env/aaa_zsh_2_zinit.env | 58 +++++++++++++ .../sz.env/aaa_zsh_3_completion_system.env | 10 +++ .../private_dot_config/sz.env/aab_zellij.env | 8 ++ _home/private_dot_config/sz.env/aliases.env | 9 ++ .../sz.env/bbb_bash_preexec.env | 28 +++++++ .../private_dot_config/sz.env/bbb_ble.sh.env | 26 ++++++ _home/private_dot_config/sz.env/broot.env | 6 ++ _home/private_dot_config/sz.env/chezmoi.env | 11 +++ .../sz.env/envman-and-webi.env | 8 ++ .../sz.env/executable__.load.sh | 83 +++++++++++++++++++ .../private_dot_config/sz.env/fix-kubectl.env | 5 ++ _home/private_dot_config/sz.env/fix-nvim.env | 22 +++++ .../sz.env/truenas-scale.env | 11 +++ _home/private_dot_config/sz.env/zza_atuin.env | 17 ++++ .../sz.env/zza_starship.env | 7 ++ .../private_dot_config/sz.env/zzz_fzf.env.off | 5 ++ 27 files changed, 476 insertions(+) create mode 100644 _home/.chezmoiexternal.yaml create mode 100644 _home/.chezmoiscripts/.keep create mode 100644 _home/dot_bashrc create mode 100644 _home/dot_profile create mode 100644 _home/dot_zshrc create mode 100644 _home/private_dot_config/sz.env/000_stop_on_non_interactive_sessions.env create mode 100644 _home/private_dot_config/sz.env/PATH_home_bin.env create mode 100644 _home/private_dot_config/sz.env/PATH_node.env create mode 100644 _home/private_dot_config/sz.env/PATH_truestuff.env create mode 100644 _home/private_dot_config/sz.env/PATH_zz_cleanup.env create mode 100644 _home/private_dot_config/sz.env/aaa_zsh_0_perp.env create mode 100644 _home/private_dot_config/sz.env/aaa_zsh_2_zinit.env create mode 100644 _home/private_dot_config/sz.env/aaa_zsh_3_completion_system.env create mode 100644 _home/private_dot_config/sz.env/aab_zellij.env create mode 100644 _home/private_dot_config/sz.env/aliases.env create mode 100644 _home/private_dot_config/sz.env/bbb_bash_preexec.env create mode 100644 _home/private_dot_config/sz.env/bbb_ble.sh.env create mode 100644 _home/private_dot_config/sz.env/broot.env create mode 100644 _home/private_dot_config/sz.env/chezmoi.env create mode 100644 _home/private_dot_config/sz.env/envman-and-webi.env create mode 100644 _home/private_dot_config/sz.env/executable__.load.sh create mode 100644 _home/private_dot_config/sz.env/fix-kubectl.env create mode 100644 _home/private_dot_config/sz.env/fix-nvim.env create mode 100644 _home/private_dot_config/sz.env/truenas-scale.env create mode 100644 _home/private_dot_config/sz.env/zza_atuin.env create mode 100644 _home/private_dot_config/sz.env/zza_starship.env create mode 100644 _home/private_dot_config/sz.env/zzz_fzf.env.off diff --git a/_home/.chezmoiexternal.yaml b/_home/.chezmoiexternal.yaml new file mode 100644 index 0000000..ab3f242 --- /dev/null +++ b/_home/.chezmoiexternal.yaml @@ -0,0 +1,5 @@ +".config/sz.env/lib/ble.sh.curl": + type: "archive" + url: "https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz" + refreshPeriod: "168h" + diff --git a/_home/.chezmoiscripts/.keep b/_home/.chezmoiscripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/_home/dot_bashrc b/_home/dot_bashrc new file mode 100644 index 0000000..52e331e --- /dev/null +++ b/_home/dot_bashrc @@ -0,0 +1,24 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples +[ -z "${DBG_SHRC}" ] || echo "Entered .bashrc" + +## Generated for envman. Do not edit. +#[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh" +# +## Generated by Webi. Do not edit. +#eval "$(webi --init zsh)" + +[ -s "$HOME/.config/sz.env/_.load.sh" ] && . <( "$HOME/.config/sz.env/_.load.sh" - ) + +[ -z "${DBG_SHRC}" ] || echo "Exiting .bashrc" +# This will prevent atuin's setup script from adding itself: atuin init bash + +eval "${SZ_ENV_BASH_LOAD_PREEXEC}" +if [[ -n "${BLE_VERSION-}" ]]; then + [[ -n "${DBG}" ]] && echo "attaching ble.sh" + ble-attach +fi + diff --git a/_home/dot_profile b/_home/dot_profile new file mode 100644 index 0000000..88fa551 --- /dev/null +++ b/_home/dot_profile @@ -0,0 +1,31 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# Generated for envman. Do not edit. +# [ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh" +[ -s "$HOME/.config/sz.env/_.load.sh" ] && . <( "$HOME/.config/sz.env/_.load.sh" - ) diff --git a/_home/dot_zshrc b/_home/dot_zshrc new file mode 100644 index 0000000..7742f46 --- /dev/null +++ b/_home/dot_zshrc @@ -0,0 +1,8 @@ +## Generated for envman. Do not edit. +#[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh" +# +## Generated by Webi. Do not edit. +#eval "$(webi --init zsh)" + +[ -s "$HOME/.config/sz.env/_.load.sh" ] && . <( "$HOME/.config/sz.env/_.load.sh" - ) + diff --git a/_home/private_dot_config/sz.env/000_stop_on_non_interactive_sessions.env b/_home/private_dot_config/sz.env/000_stop_on_non_interactive_sessions.env new file mode 100644 index 0000000..ccfc5ce --- /dev/null +++ b/_home/private_dot_config/sz.env/000_stop_on_non_interactive_sessions.env @@ -0,0 +1,6 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if [[ ! "$-" =~ i ]]; then + LOAD_EXIT=1 + echo "Non interactive session ($-) , stopping load of shell environment" 1>&2 +fi diff --git a/_home/private_dot_config/sz.env/PATH_home_bin.env b/_home/private_dot_config/sz.env/PATH_home_bin.env new file mode 100644 index 0000000..72f28fd --- /dev/null +++ b/_home/private_dot_config/sz.env/PATH_home_bin.env @@ -0,0 +1,4 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +PATH="$HOME/bin:$PATH" +PATH="$HOME/.local/bin:$PATH" diff --git a/_home/private_dot_config/sz.env/PATH_node.env b/_home/private_dot_config/sz.env/PATH_node.env new file mode 100644 index 0000000..2c440cb --- /dev/null +++ b/_home/private_dot_config/sz.env/PATH_node.env @@ -0,0 +1,3 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +export PATH="$HOME/.local/opt/node/bin:$PATH" diff --git a/_home/private_dot_config/sz.env/PATH_truestuff.env b/_home/private_dot_config/sz.env/PATH_truestuff.env new file mode 100644 index 0000000..2178998 --- /dev/null +++ b/_home/private_dot_config/sz.env/PATH_truestuff.env @@ -0,0 +1,9 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if is_cmd midclt; then + export SCALE_POOL="$(midclt call "kubernetes.config" 2>/dev/null | jq -r '.pool')" + [ -d "/mnt/$SCALE_POOL" ] || unset SCALE_POOL +fi + +[ -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_config/sz.env/PATH_zz_cleanup.env b/_home/private_dot_config/sz.env/PATH_zz_cleanup.env new file mode 100644 index 0000000..b910958 --- /dev/null +++ b/_home/private_dot_config/sz.env/PATH_zz_cleanup.env @@ -0,0 +1,12 @@ +#!/usr/bin/env -S sh -c 'echo "Not a user script. source(aka .) only"' + +# Remove duplicates from PATH +OLDPATH="$PATH"; NEWPATH=""; colon="" +while [ "${OLDPATH#*:}" != "$OLDPATH" ]; do + entry="${OLDPATH%%:*}"; search=":${OLDPATH#*:}:" + [ "${search#*:"$entry":}" = "$search" ] && [[ -d $entry ]] && NEWPATH="$NEWPATH$colon$entry" && colon=: + OLDPATH="${OLDPATH#*:}" +done +NEWPATH="$NEWPATH:$OLDPATH" +export PATH="$NEWPATH" +unset NEWPATH OLDPATH colon entry search diff --git a/_home/private_dot_config/sz.env/aaa_zsh_0_perp.env b/_home/private_dot_config/sz.env/aaa_zsh_0_perp.env new file mode 100644 index 0000000..772818f --- /dev/null +++ b/_home/private_dot_config/sz.env/aaa_zsh_0_perp.env @@ -0,0 +1,60 @@ +#!/usr/bin/env -S zsh -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if [[ "${BASE_SHELL}" == "zsh" ]]; then + + [ -z "$ZSH_CACHE_DIR" ] && export ZSH_CACHE_DIR=$HOME/.cache/zsh + mkdir -p $ZSH_CACHE_DIR/completions + mkdir -p "$HOME/.local/share/zsh/completions" + + [ -d "$HOME/.local/share/zsh/completions" ] && fpath=( + $HOME/.local/share/zsh/completions + $fpath + ) + + skip_global_compinit=1 + + # # Jump to the bottom of the screen + # SZ_TPUT_END=$(tput cup 9999 0) + # echo $SZ_TPUT_END + + PS1="$(zsh -c '. <(cat /etc/*-release | uniq -u); echo "$NAME $VERSION_ID "')| ZSH ${ZSH_VERSION} LOADING >" + + #"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + #""" Shell Settings """ + #"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + typeset -g HISTFILE="$HOME/.zsh_history" + typeset -g HISTSIZE=1000000 + typeset -g SAVEHIST=$HISTSIZE + typeset -g COMPLETION_WAITING_DOTS="true" + setopt hist_ignore_dups # ignore duplicated commands history list + export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES # fix "+[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called" issue + + ##################### + # SETOPT # + ##################### + setopt promptsubst + setopt extended_history # record timestamp of command in HISTFILE + setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE + setopt hist_ignore_all_dups # ignore duplicated commands history list + setopt hist_ignore_space # ignore commands that start with space + setopt hist_verify # show command with history expansion to user before running it + setopt inc_append_history # add commands to HISTFILE in order of execution + setopt share_history # share command history data + setopt always_to_end # cursor moved to the end in full completion + setopt hash_list_all # hash everything before completion + setopt nocompletealiases # no complete alisases - no need for specific compdef for aliases + setopt always_to_end # when completing from the middle of a word, move the cursor to the end of the word + setopt complete_in_word # allow completion from within a word/phrase + setopt nocorrect # spelling correction for commands + setopt list_ambiguous # complete as much of a completion until it gets ambiguous. + setopt auto_cd # changing directories without cd + setopt nolisttypes + setopt listpacked + setopt automenu + setopt vi + + [[ -n "${DBG}" ]] && echo "ZSH preped" +fi + diff --git a/_home/private_dot_config/sz.env/aaa_zsh_2_zinit.env b/_home/private_dot_config/sz.env/aaa_zsh_2_zinit.env new file mode 100644 index 0000000..6024fa0 --- /dev/null +++ b/_home/private_dot_config/sz.env/aaa_zsh_2_zinit.env @@ -0,0 +1,58 @@ +#!/usr/bin/env -S zsh -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if [[ "${BASE_SHELL}" == "zsh" ]]; then + # true = install zdharma-continuum/zinit + # false = install z-shell/zi + + if false; then + # Auto install zdharma-continuum/zinit + ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/bin" + if [[ ! -d "$ZINIT_HOME/.git" ]]; then + print -P "%F{33}▓▒░ %F{220}Installing DHARMA Initiative Plugin Manager (zdharma-continuum/zinit)…%f" + command mkdir -p "$(dirname "$ZINIT_HOME")" \ + && command chmod go-rwX "$(dirname "$ZINIT_HOME")" + command git clone -q --depth=1 --branch "main" \ + https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" \ + && print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" \ + || print -P "%F{160}▓▒░ The clone has failed.%f%b" + fi + source "${ZINIT_HOME}/zinit.zsh" + + autoload -Uz _zinit + (( ${+_comps} )) && _comps[zinit]=_zinit + ### End of Zinit installer's chunk + alias zi='zinit ' + + [[ -n "${DBG}" ]] && echo "zinit ready" + else + #"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + #""" z-shell/zi """ + #"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + # + # ### Added by z-shell/zi's installer + ZI_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zi/bin" + mkdir -p "$(dirname "$ZI_HOME")" + if [[ ! -d "$ZI_HOME/.git" ]]; then + print -P "%F{33}▓▒░ %F{160}Installing (%F{33}z-shell/zi%F{160})…%f" + command mkdir -p "$(dirname "$ZINIT_HOME")" \ + && command chmod go-rwX "$(dirname "$ZI_HOME")" + command git clone -q --depth=1 --branch "main" \ + https://github.com/z-shell/zi.git "$ZI_HOME" \ + && print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" \ + || print -P "%F{160}▓▒░ The clone has failed.%f%b" + fi + source "${ZI_HOME}/zi.zsh" + autoload -Uz _zi + (( ${+_comps} )) && _comps[zi]=_zi + # examples here -> https://wiki.zshell.dev/ecosystem/category/-annexes + zicompinit # <- https://wiki.zshell.dev/docs/guides/commands + ### End of z-shell/zi installer's chunk + alias zinit=zi + + [[ -n "${DBG}" ]] && echo "zi ready" + fi + +fi + diff --git a/_home/private_dot_config/sz.env/aaa_zsh_3_completion_system.env b/_home/private_dot_config/sz.env/aaa_zsh_3_completion_system.env new file mode 100644 index 0000000..714e502 --- /dev/null +++ b/_home/private_dot_config/sz.env/aaa_zsh_3_completion_system.env @@ -0,0 +1,10 @@ +#!/usr/bin/env -S zsh -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if [[ "${BASE_SHELL}" == "zsh" ]]; then + autoload -Uz +X compinit bashcompinit && compinit && bashcompinit + + zstyle ':completion:*' menu yes select +fi + diff --git a/_home/private_dot_config/sz.env/aab_zellij.env b/_home/private_dot_config/sz.env/aab_zellij.env new file mode 100644 index 0000000..32d2119 --- /dev/null +++ b/_home/private_dot_config/sz.env/aab_zellij.env @@ -0,0 +1,8 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if is_cmd load-zellij; then + # zellij will need to allow reload of the enviornment + [[ -z "$ZELLIJ_SESSION_NAME" ]] && unset SZ_ENV_LOADED + . <( load-zellij - ) + [[ -z "$ZELLIJ_SESSION_NAME" ]] && SZ_ENV_LOADED=1 +fi diff --git a/_home/private_dot_config/sz.env/aliases.env b/_home/private_dot_config/sz.env/aliases.env new file mode 100644 index 0000000..1f5219e --- /dev/null +++ b/_home/private_dot_config/sz.env/aliases.env @@ -0,0 +1,9 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +alias l='ls -lAhF --color=auto --group-directories-first ' +alias lu='l -U ' +alias lold='l --sort=time ' +alias lnew='l --sort=time --reverse ' +alias ll='l' + +alias sudo='sudo ' diff --git a/_home/private_dot_config/sz.env/bbb_bash_preexec.env b/_home/private_dot_config/sz.env/bbb_bash_preexec.env new file mode 100644 index 0000000..bde5808 --- /dev/null +++ b/_home/private_dot_config/sz.env/bbb_bash_preexec.env @@ -0,0 +1,28 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if [[ "${BASE_SHELL}" == "bash" ]]; then + update-bash-preexec() { + local workdir="$SZ_ENV_ROOT/lib/bash-preexec" + [ -d "$workdir" ] && rm -fR "$workdir" + mkdir -p "$workdir" + + cd "$workdir" + + # Pull down our file from GitHub and write it to your home directory as a hidden file. + curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ./bash-preexec.sh + # Source our file to bring it into our environment + source .bash-preexec.sh + + source "$workdir/ble-nightly/ble.sh" + } + + # shellcheck disable=SC1091 source=$HOME/.bash-preexec.sh + if [[ -f "$SZ_ENV_ROOT/lib/bash-preexec/.bash-preexec.sh" ]]; then + SZ_ENV_BASH_LOAD_PREEXEC='. "$SZ_ENV_ROOT/lib/bash-preexec/.bash-preexec.sh"' + + [[ -n "${DBG}" ]] && echo "Bash-preexec will be loaded." + fi +fi + diff --git a/_home/private_dot_config/sz.env/bbb_ble.sh.env b/_home/private_dot_config/sz.env/bbb_ble.sh.env new file mode 100644 index 0000000..7c2e99e --- /dev/null +++ b/_home/private_dot_config/sz.env/bbb_ble.sh.env @@ -0,0 +1,26 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if [[ "${BASE_SHELL}" == "bash" ]]; then + update-ble.sh() { + [[ -n "${DBG}" ]] && set -x + local workdir="$SZ_ENV_ROOT/lib/ble.sh.curl" + [ -d "$workdir" ] && rm -fR "$workdir" + mkdir -p "$workdir" + + cd "$workdir" + curl -L https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf - + + source "$workdir/ble-nightly/ble.sh" + [[ -n "${DBG}" ]] && set +x + } + if [ -f "$SZ_ENV_ROOT/lib/ble.sh.curl/ble-nightly/ble.sh" ]; then + source "$SZ_ENV_ROOT/lib/ble.sh.curl/ble-nightly/ble.sh" --noattach + fi + + if [[ -n "${DBG}" && -n "${BLE_VERSION-}" ]]; then + echo "ble.sh will be loaded." + fi +fi + diff --git a/_home/private_dot_config/sz.env/broot.env b/_home/private_dot_config/sz.env/broot.env new file mode 100644 index 0000000..8919977 --- /dev/null +++ b/_home/private_dot_config/sz.env/broot.env @@ -0,0 +1,6 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if is_cmd broot; then + source /mnt/szmedia/USERDATA/home/sz/.config/broot/launcher/bash/br +fi + diff --git a/_home/private_dot_config/sz.env/chezmoi.env b/_home/private_dot_config/sz.env/chezmoi.env new file mode 100644 index 0000000..1aa08ae --- /dev/null +++ b/_home/private_dot_config/sz.env/chezmoi.env @@ -0,0 +1,11 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' +# shellcheck disable=SC1090 + +if is_cmd 'chezmoi'; then + alias cz="chezmoi " + eval "$( chezmoi completion "${SHELL##*/}" | sed -Ee 's/(complete -o default .* chezmoi)/\1 cz/' )" + + czcd() { + cd "$(chezmoi source-path "${@}")" + } +fi diff --git a/_home/private_dot_config/sz.env/envman-and-webi.env b/_home/private_dot_config/sz.env/envman-and-webi.env new file mode 100644 index 0000000..9757b80 --- /dev/null +++ b/_home/private_dot_config/sz.env/envman-and-webi.env @@ -0,0 +1,8 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh" + +if is_cmd webi; then + . <(webi --init "${SHELL##*/}") +fi + diff --git a/_home/private_dot_config/sz.env/executable__.load.sh b/_home/private_dot_config/sz.env/executable__.load.sh new file mode 100644 index 0000000..5ad2e54 --- /dev/null +++ b/_home/private_dot_config/sz.env/executable__.load.sh @@ -0,0 +1,83 @@ +#! /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") + +is_cmd() { +type -- "${@}" 2> /dev/null 1> /dev/null +} + +if is_sourced; then + # shellcheck disable=SC2139 # This expands when defined, not when used. + alias _r="unset DBG; exec $SHELL -l " + # shellcheck disable=SC2139 # This expands when defined, not when used. + alias _rdbg="exec sh -c 'DBG=1 $SHELL -l '" + + SZ_ENV_ROOT=$( cd -- "$( dirname -- "${BASE_0}" )" &> /dev/null && pwd ) + USER_HOME=$HOME + [[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")" + + load_next() { + [ "$LOAD_EXIT" != "0" ] && return 1 + + if [[ -n "${DBG}" ]]; then + echo "Loading ${1}..." 1>&2 + #shellcheck disable=SC2086 + ${DBG/%1/:} 1>&2 + fi + #shellcheck source=/dev/null + . "${1}" + } + + load_all() { + local ALL_ENV_FILES + if [ -z "$SZ_ENV_LOADED" ]; then + SZ_ENV_LOADED=1 + LOAD_EXIT=0 + + # The following constructs a list of load_next ... commands + ALL_ENV_FILES="$( + find ~/.config/sz.env -xdev -type d -not -name '*.off' \ + -exec sh -c ' + find "$1" -xdev -maxdepth 1 -type f -name "PATH_*.env" | sort + ' shell '{}' ';' \ + -exec sh -c ' + find "$1" -xdev -maxdepth 1 -type f -name "*.env" -not -name "PATH_*" -print | sort + ' shell '{}' ';' \ + | sed -e 's/^/load_next "/; s/$/";/' + )" + if [ -n "$DBG_NO_SZ_LOAD" ]; then + ALL_ENV_FILES=$(<<<"$ALL_ENV_FILES" sed -Ee ' + /PATH_/!s/^(load_next )/# \1/ + ') + printf 'Loading limited environment...\n' + fi + # Run the constructed (see above) list + eval "$ALL_ENV_FILES" + fi + } + load_all +elif [[ "$1" == '-' ]]; then + echo "BASE_0=${BASE_0}" + cat "${0}" +else + is_cmd "${BASE_0##*/}" && SCRIPT_NAME="${BASE_0##*/}" || SCRIPT_NAME="${BASE_0/$HOME/\~}" + printf '%s\n' \ + "It seems '$SCRIPT_NAME' was invoked as a standalone script." \ + 'This script is designed to produce output that is sourced.' \ + '' \ + 'The recommended way is to use calling pattern below:' \ + " $ . <( $SCRIPT_NAME - ) # Note the '-' after the script's name" \ + '' +fi + diff --git a/_home/private_dot_config/sz.env/fix-kubectl.env b/_home/private_dot_config/sz.env/fix-kubectl.env new file mode 100644 index 0000000..a71ada8 --- /dev/null +++ b/_home/private_dot_config/sz.env/fix-kubectl.env @@ -0,0 +1,5 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if is_cmd fix-kubectl; then + . <( fix-kubectl - ) +fi diff --git a/_home/private_dot_config/sz.env/fix-nvim.env b/_home/private_dot_config/sz.env/fix-nvim.env new file mode 100644 index 0000000..4f2bb96 --- /dev/null +++ b/_home/private_dot_config/sz.env/fix-nvim.env @@ -0,0 +1,22 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if [[ -x "${CUSTOM_NVIM_PATH:-$HOME/.local/bin/nvim}" ]]; then + fix_nvim () { + CUSTOM_NVIM_PATH="${CUSTOM_NVIM_PATH:-$HOME/.local/bin/nvim}" + printf '%s\n' \ + "update-alternatives --install /usr/bin/editor editor '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --install /usr/bin/edit edit '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --install /usr/bin/ex ex '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --install /usr/bin/vi vi '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --install /usr/bin/view view '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --install /usr/bin/vim vim '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --install /usr/bin/vimdiff vimdiff '${CUSTOM_NVIM_PATH}' 110" \ + "update-alternatives --set editor '${CUSTOM_NVIM_PATH}'" \ + "update-alternatives --set edit '${CUSTOM_NVIM_PATH}'" \ + "update-alternatives --set ex '${CUSTOM_NVIM_PATH}'" \ + "update-alternatives --set vi '${CUSTOM_NVIM_PATH}'" \ + "update-alternatives --set view '${CUSTOM_NVIM_PATH}'" \ + "update-alternatives --set vim '${CUSTOM_NVIM_PATH}'" \ + "update-alternatives --set vimdiff '${CUSTOM_NVIM_PATH}'" + } +fi diff --git a/_home/private_dot_config/sz.env/truenas-scale.env b/_home/private_dot_config/sz.env/truenas-scale.env new file mode 100644 index 0000000..5fc83de --- /dev/null +++ b/_home/private_dot_config/sz.env/truenas-scale.env @@ -0,0 +1,11 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if is_cmd midclt; then + if [ -n "$SCALE_POOL_ROOT" ]; then + if [ -e "$SCALE_POOL_ROOT/jailmaker/jlmkr.py" ]; then + #alias jlmkr="bash -c '_jlmkr() { $SCALE_POOL_ROOT/jailmaker/jlmkr.py \${@:---help}; }; _jlmkr \$@' " + jlmkr() { sudo $SCALE_POOL_ROOT/jailmaker/jlmkr.py "${@:---help}"; } + fi + fi +fi + diff --git a/_home/private_dot_config/sz.env/zza_atuin.env b/_home/private_dot_config/sz.env/zza_atuin.env new file mode 100644 index 0000000..03c93ca --- /dev/null +++ b/_home/private_dot_config/sz.env/zza_atuin.env @@ -0,0 +1,17 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if is_cmd atuin; then + if [[ "${BASE_SHELL}" == "bash" ]] && ! [[ -n "$SZ_ENV_BASH_LOAD_PREEXEC$BLE_VERSION" ]]; then + printf '%s\n' \ + 'atuin was found, but bash-preexec or ble.sh are not loaded,' \ + 'to load atuin, first run update-ble.sh or update-bash-preexec ' \ + 'then relaod (_r) the shell.' + fi + + . <( atuin init "${BASE_SHELL}" ) + . <( atuin gen-completions --shell ${BASE_SHELL} ) + + [[ -n "${DBG}" ]] && echo "atuin loaded." +fi diff --git a/_home/private_dot_config/sz.env/zza_starship.env b/_home/private_dot_config/sz.env/zza_starship.env new file mode 100644 index 0000000..ecf459d --- /dev/null +++ b/_home/private_dot_config/sz.env/zza_starship.env @@ -0,0 +1,7 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if is_cmd load-starship; then + . <( load-starship - ) + [[ -n "${DBG}" ]] && echo "starship loaded." +fi + diff --git a/_home/private_dot_config/sz.env/zzz_fzf.env.off b/_home/private_dot_config/sz.env/zzz_fzf.env.off new file mode 100644 index 0000000..71b9b42 --- /dev/null +++ b/_home/private_dot_config/sz.env/zzz_fzf.env.off @@ -0,0 +1,5 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +if ! is_cmd atuin && is_cmd load-fzf; then + . <( load-fzf - ) +fi