diff --git a/_home/private_dot_local/private_share/emoji/svg/android.svg b/_externals/private_dot_local/private_share/private_emoji/svg/android.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/android.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/android.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/discord.svg b/_externals/private_dot_local/private_share/private_emoji/svg/discord.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/discord.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/discord.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/docs.svg b/_externals/private_dot_local/private_share/private_emoji/svg/docs.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/docs.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/docs.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/drive.svg b/_externals/private_dot_local/private_share/private_emoji/svg/drive.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/drive.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/drive.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/emacs.svg b/_externals/private_dot_local/private_share/private_emoji/svg/emacs.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/emacs.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/emacs.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/executable__0_mkpng.sh b/_externals/private_dot_local/private_share/private_emoji/svg/executable__0_mkpng.sh similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/executable__0_mkpng.sh rename to _externals/private_dot_local/private_share/private_emoji/svg/executable__0_mkpng.sh diff --git a/_home/private_dot_local/private_share/emoji/svg/facebook-blue.svg b/_externals/private_dot_local/private_share/private_emoji/svg/facebook-blue.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/facebook-blue.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/facebook-blue.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/facebook-full.svg b/_externals/private_dot_local/private_share/private_emoji/svg/facebook-full.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/facebook-full.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/facebook-full.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/facebook-outline.svg b/_externals/private_dot_local/private_share/private_emoji/svg/facebook-outline.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/facebook-outline.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/facebook-outline.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/gcal.svg b/_externals/private_dot_local/private_share/private_emoji/svg/gcal.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/gcal.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/gcal.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/gcloud-gcp.svg b/_externals/private_dot_local/private_share/private_emoji/svg/gcloud-gcp.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/gcloud-gcp.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/gcloud-gcp.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/gcp-gcloud.svg b/_externals/private_dot_local/private_share/private_emoji/svg/gcp-gcloud.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/gcp-gcloud.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/gcp-gcloud.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/linkedin.svg b/_externals/private_dot_local/private_share/private_emoji/svg/linkedin.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/linkedin.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/linkedin.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/linux.svg b/_externals/private_dot_local/private_share/private_emoji/svg/linux.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/linux.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/linux.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/meet.svg b/_externals/private_dot_local/private_share/private_emoji/svg/meet.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/meet.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/meet.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/messenger-white.svg b/_externals/private_dot_local/private_share/private_emoji/svg/messenger-white.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/messenger-white.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/messenger-white.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/messenger.svg b/_externals/private_dot_local/private_share/private_emoji/svg/messenger.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/messenger.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/messenger.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/org-mode.svg b/_externals/private_dot_local/private_share/private_emoji/svg/org-mode.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/org-mode.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/org-mode.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/reddit.svg b/_externals/private_dot_local/private_share/private_emoji/svg/reddit.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/reddit.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/reddit.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/signal.svg b/_externals/private_dot_local/private_share/private_emoji/svg/signal.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/signal.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/signal.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/smartphone-android-icon.svg b/_externals/private_dot_local/private_share/private_emoji/svg/smartphone-android-icon.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/smartphone-android-icon.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/smartphone-android-icon.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/smartphone-apple-iphone-bw.svg b/_externals/private_dot_local/private_share/private_emoji/svg/smartphone-apple-iphone-bw.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/smartphone-apple-iphone-bw.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/smartphone-apple-iphone-bw.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/snapchat.svg b/_externals/private_dot_local/private_share/private_emoji/svg/snapchat.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/snapchat.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/snapchat.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/spacemacs.svg b/_externals/private_dot_local/private_share/private_emoji/svg/spacemacs.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/spacemacs.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/spacemacs.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/spotify.svg b/_externals/private_dot_local/private_share/private_emoji/svg/spotify.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/spotify.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/spotify.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/telegram.svg b/_externals/private_dot_local/private_share/private_emoji/svg/telegram.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/telegram.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/telegram.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/terraform-black.svg b/_externals/private_dot_local/private_share/private_emoji/svg/terraform-black.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/terraform-black.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/terraform-black.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/terraform.svg b/_externals/private_dot_local/private_share/private_emoji/svg/terraform.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/terraform.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/terraform.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/twitter.svg b/_externals/private_dot_local/private_share/private_emoji/svg/twitter.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/twitter.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/twitter.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/vi-neovim.svg b/_externals/private_dot_local/private_share/private_emoji/svg/vi-neovim.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/vi-neovim.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/vi-neovim.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/vi-vim-minimalist.svg b/_externals/private_dot_local/private_share/private_emoji/svg/vi-vim-minimalist.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/vi-vim-minimalist.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/vi-vim-minimalist.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/vi-vim.svg b/_externals/private_dot_local/private_share/private_emoji/svg/vi-vim.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/vi-vim.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/vi-vim.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/vscode.svg b/_externals/private_dot_local/private_share/private_emoji/svg/vscode.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/vscode.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/vscode.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/whatsapp-icon.svg b/_externals/private_dot_local/private_share/private_emoji/svg/whatsapp-icon.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/whatsapp-icon.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/whatsapp-icon.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/whatsapp-no-outline.svg b/_externals/private_dot_local/private_share/private_emoji/svg/whatsapp-no-outline.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/whatsapp-no-outline.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/whatsapp-no-outline.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/whatsapp-outline.svg b/_externals/private_dot_local/private_share/private_emoji/svg/whatsapp-outline.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/whatsapp-outline.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/whatsapp-outline.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/whatsapp.svg b/_externals/private_dot_local/private_share/private_emoji/svg/whatsapp.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/whatsapp.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/whatsapp.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/youtube-music.svg b/_externals/private_dot_local/private_share/private_emoji/svg/youtube-music.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/youtube-music.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/youtube-music.svg diff --git a/_home/private_dot_local/private_share/emoji/svg/youtube.svg b/_externals/private_dot_local/private_share/private_emoji/svg/youtube.svg similarity index 100% rename from _home/private_dot_local/private_share/emoji/svg/youtube.svg rename to _externals/private_dot_local/private_share/private_emoji/svg/youtube.svg diff --git a/_home/dot_bashrc b/_home/dot_bashrc index afe2ed4..3bb4b11 100644 --- a/_home/dot_bashrc +++ b/_home/dot_bashrc @@ -1,8 +1,8 @@ # ~/.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_SZSHRC} ] || echo "Entered .bashrc" +[ -z ${DBG_SHRC} ] || echo "Entered .bashrc" [[ -r ~/.sz.shrc ]] && source ~/.sz.shrc -[ -z ${DBG_SZSHRC} ] || echo "Exiting .bashrc" +[ -z ${DBG_SHRC} ] || echo "Exiting .bashrc" diff --git a/_home/private_dot_poshtheme.omp.json b/_home/dot_poshtheme.omp.json similarity index 97% rename from _home/private_dot_poshtheme.omp.json rename to _home/dot_poshtheme.omp.json index fe8bca3..6e20364 100644 --- a/_home/private_dot_poshtheme.omp.json +++ b/_home/dot_poshtheme.omp.json @@ -74,14 +74,14 @@ ], "background": "red", "background_templates": [ - "{{ if contains \"true\" .Output }}#DD7700{{ end }}" + "{{ if contains \"true\" .Output }}#4063D8{{ end }}" ], "powerline_symbol": "", "invert_powerline": true, "style": "powerline", "properties": { "shell": "bash", - "command": "type -t direnv 2>/dev/null && { direnv status 2>&1 || true; } | grep \"Found RC allowed\"; true" + "command": "type -t direnv 2>&1 > /dev/null && direnv status 2>&1 | grep 'Found RC allowed'" }, "template": "{{ if .Output }}.{{ end }}" }, @@ -93,14 +93,14 @@ ], "background": "red", "background_templates": [ - "{{ if contains \"true\" .Output }}#DD7700{{ end }}" + "{{ if contains \"true\" .Output }}#4063D8{{ end }}" ], "invert_powerline": true, "style": "diamond", "trailing_diamond": "▓", "properties": { "shell": "bash", - "command": "type -t direnv 2>/dev/null && { direnv status 2>&1 || true; } | grep \"Found RC allowed\"; true" + "command": "type -t direnv 2>&1 > /dev/null && direnv status 2>&1 | grep 'Found RC allowed'" }, "template": "{{ if .Output }}envrc{{ end }}" } diff --git a/_home/dot_sz.shrc b/_home/dot_sz.shrc index 633b4d5..1b6b1e5 100644 --- a/_home/dot_sz.shrc +++ b/_home/dot_sz.shrc @@ -1,24 +1,25 @@ # If not running interactively, don't do anything -[ -z ${DBG_SZSHRC} ] || echo "Entered .sz.shrc" +SFP='.sz' # Script Family Prefix +[ -z ${DBG_SHRC} ] || echo "Entered ${SFP}.shrc" case $- in *i*) echo "Welcome $USER to $(hostname)";; - *) [ -z "${INCLUDE_SZSHRC}" ] && return;; + *) return;; esac -if [ -d ~/.sz.shrc.d ]; then - [ -z ${DBG_SZSHRC} ] || ps -p$$ -ho comm - script_source=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")") - script_source+=("$(find ~/.sz.shrc.d -maxdepth 0 -type d)") - script_source+=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")") - [ -z ${DBG_SZSHRC} ] || echo "Working with (${script_source[@]})..." +export SHRC_D=~/${SFP}.shrc.d +if [ -d ${SHRC_D} ]; then + script_source=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")") + script_source+=("$(find ${SHRC_D} -maxdepth 0 -type d)") + script_source+=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")") + [ -z ${DBG_SHRC} ] || echo "Working with (${script_source[@]})..." for script_src in ${script_source[@]}; do scripts=($(find $script_src -maxdepth 1 -type f -not -name "*~" -not -name "*.off" -not -name "*.swp" | sort)) - #[ -z ${DBG_SZSHRC} ] || echo "Within $script_src, will review (${scripts[@]})..." + #[ -z ${DBG_SHRC} ] || echo "Within $script_src, will review (${scripts[@]})..." for script_name in ${scripts[@]}; do - [ -z ${DBG_SZSHRC} ] || echo "Checking $script_name..." + [ -z ${DBG_SHRC} ] || echo "Checking $script_name..." if [ -r $script_name ]; then - [ -z ${DBG_SZSHRC} ] || echo "Sourcing $script_name..." + [ -z ${DBG_SHRC} ] || echo "Sourcing $script_name..." . $script_name fi done @@ -28,4 +29,5 @@ if [ -d ~/.sz.shrc.d ]; then unset script_source fi -[ -z ${DBG_SZSHRC} ] || echo "Exiting .sz.shrc" +[ -z ${DBG_SHRC} ] || echo "Exiting ${SFP}.shrc" + diff --git a/_home/dot_sz.shrc.d/01_util.functions b/_home/dot_sz.shrc.d/01_util.functions index b88d28e..f811c94 100644 --- a/_home/dot_sz.shrc.d/01_util.functions +++ b/_home/dot_sz.shrc.d/01_util.functions @@ -1,3 +1,7 @@ +warn() { + (>&2 printf '\E[34mWARNING:\E[0m %s\n' "$@" ) +} + error() { (>&2 printf '\E[31mERROR:\E[0m %s\n' "$@" ) } @@ -9,6 +13,13 @@ require_root() { fi } +recommend_root() { + if [[ $EUID -ne 0 ]]; then + warn "This script works better using sudo or as the root user" + return 3 + fi +} + function setacl() { if [[ $# -lt 4 ]]; then error "setacl missing arguments, called with '$1' ${@:2}" diff --git a/_home/dot_sz.shrc.d/21_aliases b/_home/dot_sz.shrc.d/21_aliases index 8869ad7..9579c86 100644 --- a/_home/dot_sz.shrc.d/21_aliases +++ b/_home/dot_sz.shrc.d/21_aliases @@ -1,5 +1,3 @@ -alias sudo="/usr/bin/sudo " - # some more ls aliases alias ll='ls -alF' alias la='ls -A' @@ -7,12 +5,10 @@ alias l='ls -CF' alias lessr="less --raw-control-chars " -alias sz-edshrc="ed ~/.sz.shrc.d ; exec $SHELL" +alias edshrc="ed ~/${SFP}.shrc.d && exec $SHELL" [[ -z "$(env inkscape 2> /dev/null)" && -n "$(flatpak info org.inkscape.Inkscape 2> /dev/null)" ]] && alias inkscape="flatpak run org.inkscape.Inkscape " -alias cdgit='cd $(git rev-parse --show-toplevel) ' - function clip() { xclip -i -sel clipboard } diff --git a/_home/dot_sz.shrc.d/22_editor.aliases b/_home/dot_sz.shrc.d/22_editor.aliases index 4860ab7..0e356dd 100644 --- a/_home/dot_sz.shrc.d/22_editor.aliases +++ b/_home/dot_sz.shrc.d/22_editor.aliases @@ -1,17 +1,6 @@ -PREFERED_VI=$(which-command nvim vim | head -1) -if [[ -z "$PREFERED_VI" ]]; then - PREFERED_VI=$(which-command vi | head -1) +MY_VI="$(type -fP my_vi)" - if [[ -z "$PREFERED_VI" ]]; then - alias my_vi='eval $EDITOR ' - else - alias my_vi="$PREFERED_VI" - fi -else - alias my_vi="$PREFERED_VI -p" -fi - -export DOOMROOT="$HOME/.config/_my.emacs/doom" +port DOOMROOT="$HOME/.config/_my.emacs/doom" [[ -x $DOOMROOT/emacs.d/bin/doom ]] && function doom() { export EMACSDIR="$DOOMROOT/emacs.d" export DOOMDIR="$DOOMROOT/config" @@ -23,17 +12,18 @@ export DOOMROOT="$HOME/.config/_my.emacs/doom" } || unset DOOMROOT if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \ - && -n "$(which-command emacsclient)" \ - && -n "$(which-command emacs)" \ - && -n "$(which-command edit-with-spacemacs)" \ - ]]; then - alias my_editor='edit-with-spacemacs' + && -n "$(which-command emacsclient)" \ + && -n "$(which-command emacs)" \ + && -n "$(which-command edit-with-spacemacs)" \ + ]]; then + alias my_editor='edit-with-spacemacs' else - alias my_editor='my_vi' + alias my_editor="${MY_VI} " fi -alias nvim="my_vi" -alias vim="my_vi" -alias vi="my_vi" + +alias nvim="${MY_VI} " +alias vim="${MY_VI} " +alias vi="${MY_VI} " alias ed="my_editor" alias edit="my_editor" diff --git a/_home/dot_sz.shrc.d/23_sudo b/_home/dot_sz.shrc.d/23_sudo new file mode 100644 index 0000000..c48ebe9 --- /dev/null +++ b/_home/dot_sz.shrc.d/23_sudo @@ -0,0 +1,8 @@ +#alias sudo="/usr/bin/sudo " +function sudo() { + local cli="$(command -v "${1}")" + [[ -x "$cli" ]] || cli="${1}" + /usr/bin/sudo --preserve-env=PATH -- "$cli" "${@:2}" +} + + diff --git a/_home/dot_sz.shrc.d/24_git b/_home/dot_sz.shrc.d/24_git new file mode 100644 index 0000000..73f4f50 --- /dev/null +++ b/_home/dot_sz.shrc.d/24_git @@ -0,0 +1,7 @@ +if [[ -n "$(which-command git)" ]]; then + alias gitcd='cd $(git rev-parse --show-toplevel) ' + + if [[ -n $(git credential-manager-core --version 2>/dev/null) ]]; then + export GCM_CREDENTIAL_STORE=plaintext + fi +fi diff --git a/_home/dot_sz.shrc.d/31_zfs b/_home/dot_sz.shrc.d/41_zfs similarity index 100% rename from _home/dot_sz.shrc.d/31_zfs rename to _home/dot_sz.shrc.d/41_zfs diff --git a/_home/dot_sz.shrc.d/23_truecharts b/_home/dot_sz.shrc.d/42_truecharts similarity index 100% rename from _home/dot_sz.shrc.d/23_truecharts rename to _home/dot_sz.shrc.d/42_truecharts diff --git a/_home/dot_sz.shrc.d/97_chezmoi_aliases b/_home/dot_sz.shrc.d/97_chezmoi_aliases index a5b4650..67c9e9a 100644 --- a/_home/dot_sz.shrc.d/97_chezmoi_aliases +++ b/_home/dot_sz.shrc.d/97_chezmoi_aliases @@ -1,48 +1,61 @@ if [[ -n "$(which-command chezmoi)" ]]; then - export CHEZMOIROOT="$(chezmoi source-path)" - export CZ="$CHEZMOIROOT" - export CZ_X="$(readlink -f $CHEZMOIROOT/../_externals)" + export CHEZMOIROOT="$(chezmoi source-path)" + export CZ="$CHEZMOIROOT" + export CZ_X="$(readlink -f $CHEZMOIROOT/../_externals)" - alias czcd="cd $CZ" - alias czxcd="cd $CZ_X" - - alias cz="chezmoi " - alias czx="chezmoi --source $CZ_X --config $HOME/.config/chezmoi/chezmoi.externals.toml " + alias czcd="cd $CZ" + alias czxcd="cd $CZ_X" + + function cz() { chezmoi "${@}"; } + function czx() { + chezmoi --source $CZ_X --config $HOME/.config/chezmoi.externals/config.toml "${@}" + } - alias czs="cz status " - - alias cz-refresh="czs | cut -d\ -f2 | grep '^\.sz\.shrc\.d' | xargs cz forget --force; cz add ~/.sz.shrc.d --recursive; cz status; cz git status" - alias cz-commit="cz git -- commit -a " + alias czs="cz status " + function czg() { + cz git -- "${@}" + } + #alias czg="cz git -- " + alias czgs="cz git -- status " + alias cza="cz apply && exec $SHELL" + alias czu="cz upgrade && cz update && exec $SHELL " + alias czxu="cz upgrade && cz update && czx apply && exec $SHELL " + + alias cz-refresh="czs | cut -d\ -f2 | grep '^\.sz\.shrc\.d' | xargs cz forget --force; cz add ~/.sz.shrc.d --recursive; cz status; cz git status" + alias cz-commit="cz git -- commit -a " - function cz() { - chezmoi "${@}" - } - function cz-remove-missing() { - pushd ~ > /dev/null - changes=$(cz status | sed -n 's/^DA[ \t]\+//p') - for c in $changes; do - cz rm $c - done - popd > /dev/null - } + function cz-remove-missing() { + pushd ~ > /dev/null + changes=$(cz status | sed -n 's/^DA[ \t]\+//p') + for c in $changes; do + cz rm $c + done + popd > /dev/null + } - function cz-add-changes() { - pushd ~ > /dev/null - changes=$(cz status | sed -n 's/^MM[ \t]\+//p') - for c in $changes; do - echo Adding $c - cz add $c - done - popd > /dev/null - } + function cz-add-changes() { + pushd ~ > /dev/null + changes=$(cz status | sed -n 's/^MM[ \t]\+//p') + for c in $changes; do + echo Adding $c + cz add $c + done + popd > /dev/null + } - function cz-set-ssh-github() { - cz git -- remote set-url origin "$(cz git -- remote get-url origin | sed 's|https://github.com/|git@github.com:|')" - cz git -- remote get-url origin - } + function cz-set-ssh-github() { + cz git -- remote set-url origin "$( \ + cz git -- remote get-url origin \ + | sed 's|https://github.com/|git@github.com:|' \ + )" + cz git -- remote get-url origin + } - function cz-set-https-github() { - cz git -- remote set-url origin "$(cz git -- remote get-url origin | sed 's|git@github.com:|https://github.com/|')" - cz git -- remote get-url origin - } + function cz-set-https-github() { + cz git -- remote set-url origin "$( \ + cz git -- remote get-url origin \ + | sed 's|git@github.com:|https://github.com/|' \ + )" + cz git -- remote get-url origin + } fi diff --git a/_home/dot_sz.shrc.d/98_chezmoi_status.off b/_home/dot_sz.shrc.d/98_chezmoi_status.off deleted file mode 100644 index 17106ec..0000000 --- a/_home/dot_sz.shrc.d/98_chezmoi_status.off +++ /dev/null @@ -1,5 +0,0 @@ -if [[ -n "$(type -fP chezmoi)" ]]; then - CHEZMOI_OUT="$(chezmoi status || true)x" - [[ "x" != "$CHEZMOI_OUT" ]] && printf "\nChezmoi changes:\n" && echo "${CHEZMOI_OUT%?}" - unset CHEZMOI_OUT -fi diff --git a/_home/dot_sz.shrc.d/bash.post/10_oh-my-posh b/_home/dot_sz.shrc.d/bash.post/10_oh-my-posh.hook similarity index 100% rename from _home/dot_sz.shrc.d/bash.post/10_oh-my-posh rename to _home/dot_sz.shrc.d/bash.post/10_oh-my-posh.hook diff --git a/_home/dot_sz.shrc.d/bash.post/11_persistent.history b/_home/dot_sz.shrc.d/bash.post/11_persistent-history.hook similarity index 61% rename from _home/dot_sz.shrc.d/bash.post/11_persistent.history rename to _home/dot_sz.shrc.d/bash.post/11_persistent-history.hook index 0a5fcde..d31a742 100644 --- a/_home/dot_sz.shrc.d/bash.post/11_persistent.history +++ b/_home/dot_sz.shrc.d/bash.post/11_persistent-history.hook @@ -4,4 +4,11 @@ export HISTFILESIZE=100000 # big big history shopt -s histappend # append to history, don't overwrite it # Save and reload the history after each command finishes -export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" +function _history_hook() { + history -a; history -c; history -r +} +export PROMPT_COMMAND="$( \ + echo "$PROMPT_COMMAND" \ + | sed 's/;\ *$//; s/; _history_hook//g' \ + ); _history_hook" + diff --git a/_home/dot_sz.shrc.d/bash.post/12_direnv.hook b/_home/dot_sz.shrc.d/bash.post/12_direnv.hook index 5d4faab..130cccc 100644 --- a/_home/dot_sz.shrc.d/bash.post/12_direnv.hook +++ b/_home/dot_sz.shrc.d/bash.post/12_direnv.hook @@ -1,4 +1,4 @@ if [[ -n "$(type -fP direnv)" ]]; then - source <( direnv hook bash ) - source <( direnv stdlib ) + source <( direnv hook bash ) + source <( direnv stdlib ) fi diff --git a/_home/dot_sz.shrc.d/bash.post/91_prep-bash.completion b/_home/dot_sz.shrc.d/bash.post/91_prep-bash.completion new file mode 100644 index 0000000..064f4f7 --- /dev/null +++ b/_home/dot_sz.shrc.d/bash.post/91_prep-bash.completion @@ -0,0 +1,2 @@ +# BC_PATH=$(which-command bash-complete-alias) +# [[ -n "$BC_PATH" && -r "$BC_PATH" ]] && source "$BC_PATH" diff --git a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete deleted file mode 100644 index 4bd013e..0000000 --- a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete +++ /dev/null @@ -1 +0,0 @@ -[[ -n "$BASH_COMPLETION_EXIST" && -n $(which-command chezmoi) ]] && source <(chezmoi completion bash | add-alias-to-bash-completion-code chezmoi cz ) diff --git a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.completion b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.completion new file mode 100644 index 0000000..1d5b966 --- /dev/null +++ b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.completion @@ -0,0 +1,13 @@ +[[ -n "$BASH_COMPLETION_EXIST" && -n $(which-command chezmoi) ]] \ + && source <( \ + chezmoi completion bash \ + | add-alias-to-bash-completion-code chezmoi cz czx \ + | add-alias-to-bash-completion-code chezmoi czx \ + ) \ + echo done. +# && if [[ $(type -t compopt) = "builtin" ]]; then +# complete -o default -F __git_complete czg +# else +# complete -o default -o nospace -F __git_complete czg +# fi + diff --git a/_home/dot_sz.shrc.d/bash.post/99_docker_compose.complete b/_home/dot_sz.shrc.d/bash.post/99_docker_compose.completion similarity index 100% rename from _home/dot_sz.shrc.d/bash.post/99_docker_compose.complete rename to _home/dot_sz.shrc.d/bash.post/99_docker_compose.completion diff --git a/_home/dot_sz.shrc.d/bash.post/99_gcloud.complete b/_home/dot_sz.shrc.d/bash.post/99_gcloud.completion similarity index 100% rename from _home/dot_sz.shrc.d/bash.post/99_gcloud.complete rename to _home/dot_sz.shrc.d/bash.post/99_gcloud.completion diff --git a/_home/dot_sz.shrc.d/bash.post/99_kubectl.complete b/_home/dot_sz.shrc.d/bash.post/99_kubectl.completion similarity index 100% rename from _home/dot_sz.shrc.d/bash.post/99_kubectl.complete rename to _home/dot_sz.shrc.d/bash.post/99_kubectl.completion diff --git a/_home/dot_sz.shrc.d/bash.post/99_oh-my-posh.complete b/_home/dot_sz.shrc.d/bash.post/99_oh-my-posh.complete deleted file mode 100644 index 4308f9c..0000000 --- a/_home/dot_sz.shrc.d/bash.post/99_oh-my-posh.complete +++ /dev/null @@ -1 +0,0 @@ -[[ -n "$(which-command oh-my-posh)" ]] && source <(oh-my-posh completion bash) diff --git a/_home/dot_sz.shrc.d/bash.post/99_oh-my-posh.completion b/_home/dot_sz.shrc.d/bash.post/99_oh-my-posh.completion new file mode 100644 index 0000000..59dc619 --- /dev/null +++ b/_home/dot_sz.shrc.d/bash.post/99_oh-my-posh.completion @@ -0,0 +1,2 @@ +[[ -n "$(which-command oh-my-posh)" ]] \ + && source <( oh-my-posh completion bash ) diff --git a/_home/dot_sz.shrc.d/bash.post/99_terraform.complete b/_home/dot_sz.shrc.d/bash.post/99_terraform.completion similarity index 100% rename from _home/dot_sz.shrc.d/bash.post/99_terraform.complete rename to _home/dot_sz.shrc.d/bash.post/99_terraform.completion diff --git a/_home/dot_sz.shrc.d/bash.post/99_truenas.complete b/_home/dot_sz.shrc.d/bash.post/99_truenas.complete deleted file mode 100644 index ae90515..0000000 --- a/_home/dot_sz.shrc.d/bash.post/99_truenas.complete +++ /dev/null @@ -1,21 +0,0 @@ -if ( uname --kernel-release | grep -q truenas ); then - # Completion code is only avialable with `sudo`, the aliases below - # are desined for 'lazy-loading' the completion code, when it's time - # to enter the sudo password. - - if [[ -n "$(which-command 'k3s')" ]]; then - alias kubectl=' \ - ### Lazy load `kubectl` bash-completion \ - alias kubectl="sudo k3s kubectl "; \ - source <( kubectl completion bash ); \ - sudo k3s kubectl ' - fi - - if [[ -n "$(which-command 'helm')" ]]; then - alias helm=' \ - ### Lazy load `helm` bash-completion \ - alias helm="sudo KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm "; \ - source <( helm completion bash ); \ - sudo KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm ' - fi -fi diff --git a/_home/dot_zshrc b/_home/dot_zshrc index 871f1f1..acb23ae 100644 --- a/_home/dot_zshrc +++ b/_home/dot_zshrc @@ -1,5 +1,5 @@ -[ -z ${DBG_SZSHRC} ] || echo "Entered .zshrc" +[ -z ${DBG_SHRC} ] || echo "Entered .zshrc" [[ -r ~/.sz.shrc ]] && source ~/.sz.shrc -[ -z ${DBG_SZSHRC} ] || echo "Exiting .zshrc" +[ -z ${DBG_SHRC} ] || echo "Exiting .zshrc" diff --git a/_home/private_dot_local/bin/executable_sz-add-apt-repo b/_home/private_dot_local/bin/executable_sz-add-apt-repo new file mode 100644 index 0000000..0827e26 --- /dev/null +++ b/_home/private_dot_local/bin/executable_sz-add-apt-repo @@ -0,0 +1,228 @@ +#! /usr/bin/env bash + +######### Repo list + +# this is a reference template +# function _repo_template_function() { +# REPO_FQDN='' # host FQDN, this will also be the name of the apt list/source file +# GPG_KEY_URL='' # [optional] URL to the GPG Key, if not supplied it will be https://$REPO_FQDN/gpg +# GPG_KEY_PATH='' # [optional] Location on disk for the public GPG key +# REPO_ARCH='' # [optional] System architecture specific package, '-' is shorthand for current architecture +# REPO_URL='' # [optional] REPO Url if not https://$REPO_FQDN, which is the default. +# REPO_SUITE='' # [optional] Suite / Release codename +# REPO_CMP='' # [optional] Package Channel - default is 'main', this is vendor specific. +# } + +function _repo_docker() { +# for: docker-ce docker-ce-cli containerd.io docker-compose-plugin +# Also don't forget: +# remove: docker docker-engine docker.io containerd runc +# possibly remove docker-compose and install: https://github.com/docker/compose-switch + + REPO_FQDN='download.docker.com' + REPO_URL="https://download.docker.com/linux/$_OS" + GPG_KEY_URL="$REPO_URL/gpg" + REPO_CMP='stable' +} +function _repo_anydesk() { +# for: anydesk + REPO_FQDN='deb.anydesk.com' + REPO_URL="http://$REPO_FQDN/" # NOTE, this is http, not https + GPG_KEY_URL='https://keys.anydesk.com/repos/DEB-GPG-KEY' + REPO_ARCH='-' + REPO_CMP='main' + REPO_SUITE='all' +} +function _repo_gcloud() { +# for: google-cloud-cli + REPO_FQDN='packages.cloud.google.com' + REPO_URL="https://$REPO_FQDN/apt" + GPG_KEY_URL="$REPO_URL/doc/apt-key.gpg" + REPO_ARCH='-' + REPO_SUITE='cloud-sdk' +} +function _repo_mspackages() { +# for: code (optionally: powershell dotnet-*) + REPO_FQDN='packages.microsoft.com' + GPG_KEY_URL="https://$REPO_FQDN/keys/microsoft.asc" + REPO_URL="https://$REPO_FQDN/$_OS/$_REL/prod" +} +function _repo_msedge() { +# for: microsoft-edge-stable + REPO_FQDN='edge.microsoft.com' + GPG_KEY_URL="https://packages.microsoft.com/keys/microsoft.asc" + REPO_URL="http://packages.microsoft.com/repos/edge" + REPO_SUITE='stable' +} +function _repo_hashicorp() { +# for: terraform + REPO_FQDN='apt.releases.hashicorp.com' + # GPG_KEY_URL='' # default value is enough here + # REPO_URL='' # default value is enough here +} +function _repo_custom_xscreensavers() { + # I really LOVE xscreensavers, but it's been stuck in limbo on the + # `stable` repos, so I install it from the `unstable`, aka `sid`, suite. + # To do that safely, I make sure the repo is pinned to a lower priority. + # I do this BEFORE I add the repo. + + # # Debian sid (unstable) as low-priority option + (echo 'Package: *'; echo 'Pin: release a=unstable'; echo 'Pin-Priority: 200') | sudo tee /etc/apt/preferences.d/unstable > /dev/null + # # pin xscreensaver to unstable + (echo 'Package: xscreenaver*'; echo 'Pin: release a=unstable'; echo 'Pin-Priority: 2000') | sudo tee /etc/apt/preferences.d/xscreensaver > /dev/null + + # for: xscreensaver xscreensaver-data xscreensaver-data-extra + # xscreensaver-screensaver-bsod xscreensaver-screensaver-webcollage + # Add the unstable/sid repo - THIS IS DANGEROUS without the pinning via + # /etc/apt/preferences.d files created by the code above. + sudo apt-add-repository $_YES --no-update "deb [arch=amd64] http://deb.debian.org/debian sid main non-free contrib" +} + +############ Script Logic starts here +set -e + +ANSI_Print() { printf "\E[${ANSI_Code}m%s\E[0m" "$@"; } +ANSI_Red() { ANSI_Code=31 ANSI_Print "$@"; } +ANSI_Green() { ANSI_Code=32 ANSI_Print "$@"; } +ANSI_Yellow() { ANSI_Code=33 ANSI_Print "$@"; } +ANSI_Blue() { ANSI_Code=34 ANSI_Print "$@"; } +ANSI_Indiego() { ANSI_Code=35 ANSI_Print "$@"; } +ANSI_Cyan() { ANSI_Code=36 ANSI_Print "$@"; } + +error() { + (>&2 ANSI_Red 'ERROR: ' && printf '%s\n' "$@" ) +} + +require_root() { + if [[ $EUID -ne 0 ]]; then + error "This script should only be run using sudo or as the root user" + exit 1 + fi +} + +# The function that does the _Heavy Lifting_. +# see the code that follows for the parameter signature +function add_repo() { + unset REPO_FQDN GPG_KEY_URL GPG_KEY_PATH REPO_ARCH REPO_URL REPO_SUITE REPO_CMP + + # In case custom handling is required, call it and return. + if [[ "$(type -t _repo_custom_$1)" == 'function' ]]; then + eval "_repo_custom_$1" && return 0 + return $? + # If no repo defintion exist, exit with an error + elif [[ "$(type -t _repo_$1)" != 'function' ]]; then + error "Can't configure $1, could not find _repo_$1 definition!" + return 1 + fi + # Grab the repo's defintion + eval "_repo_$1" + + # Prepare all necessary vraiables + [[ -z "$REPO_FQDN" ]] && error "REPO_FQDN not defined for '$1'" && return 1 + GPG_KEY_URL=${GPG_KEY_URL:-https:\/\/$REPO_FQDN\/gpg} + GPG_KEY_PATH=${GPG_KEY_PATH:-/usr/share/keyrings/$REPO_FQDN.gpg} + REPO_ARCH=${REPO_ARCH:-${_ARC}} + [[ $REPO_ARCH == '-' ]] && REPO_ARCH='' || REPO_ARCH="arch=$REPO_ARCH" + REPO_URL=${REPO_URL:-https:\/\/$REPO_FQDN} + REPO_SUITE=${REPO_SUITE:-$_CNM} + REPO_CMP=${REPO_CMP:-main} + + # Grab the GPG key and save it. + curl -fsSL $GPG_KEY_URL | sudo gpg --dearmor -o $GPG_KEY_PATH $_YES + echo "Key created: $GPG_KEY_PATH" + # Define the package source + echo "deb [$(echo "$REPO_ARCH signed-by=$GPG_KEY_PATH" | xargs )] $REPO_URL $REPO_SUITE $REPO_CMP" | \ + sudo tee /etc/apt/sources.list.d/$REPO_FQDN.list > /dev/null + echo "APT source list added: /etc/apt/sources.list.d/$REPO_FQDN.list" +} + +function usage() { + printf " %s\n" \ + "Usage:" \ + " $0 [-v[v]] " \ + " [--no-init] [--no-overwrite] " \ + " all|[ ...] " \ + "" \ + "Repos: $( \ + printf "\n %s" $( \ + typeset -f \ + | grep '^_repo_' \ + | sed 's/_repo\(_custom\)\?_\(.*\) ()/\2/' \ + | sort \ + ))" \ + "" \ + "Options:" \ + " --no-init - skip package initialization." \ + " --no-overwrite - don't overwrite gpg keys automatially, ask." \ + " new keys will still be written without asking." \ + " -v[v] - script verbosity, equivalent to set -x and set -xv" \ + "" +} + +function main() { + [[ ${#REPO_LIST[@]} -eq 0 ]] && usage && return 1 + + require_root + + _OS=$(lsb_release -is | awk '{ print tolower($0) }') + [[ $_OS == 'pop' ]] && _OS='ubuntu' + _REL=$(lsb_release -rs) # Release + _CNM=$(lsb_release -cs) # CodeName + _ARC=$(dpkg --print-architecture) # Architecture + + ANSI_Cyan "Initializing: Installing basic packages..."; echo + if [[ -n "$SHOULD_INIT" ]]; then + # Make sure the /usr/share/keyrings dir exists + mkdir -p /usr/share/keyrings 2>&1 > /dev/null + + # Make sure all of the basic required tools are installed for the code + # below to work + apt-get install --yes --no-install-recommends \ + curl gnupg software-properties-common apt-transport-https + fi + ANSI_Green "Done."; echo + + while read r; do + ANSI_Cyan "Installing $r repository..."; echo + add_repo $r && UPDATE_REQUIRED=1 || return 2 + ANSI_Green "Installation of $r repository completed."; echo + done < <(printf "%s\n" "${REPO_LIST[@]}") + + # Finally, run `apt update` to check that everything completed successfully + if [[ $UPDATE_REQUIRED == 1 ]]; then + ANSI_Cyan "Finalizing: running 'apt update'..."; echo + + MISSING_SIGNATURES=($( \ + sudo apt update 2>&1 1>/dev/null \ + | sed -ne 's/.*NO_PUBKEY //p' \ + )) + $MISSING_SIGNATURES| while read key; do if ! [[ ${keys[*]} =~ "$key" ]]; then sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys "$key"; keys+=("$key"); fi; done + sudo apt update + ANSI_Green "'apt update' completed."; echo + fi +} + +# Iterate through stdin or parameters +if [[ $# == 0 ]]; then + usage +else + REPO_LIST=() + _YES='--yes' + _SHOULD_INIT=1 + UPDATE_REQUIRED=0 + + READCMD='printf "%s\n" "${@}"' + [[ $# == 1 && $1 == '-' ]] && READCMD='cat - ' + while read a; do + # Switch on _YES + [[ "$a" == "-v" ]] && set -x && continue + [[ "$a" == "-vv" ]] && set -xv && continue + [[ "$a" == "--no-overwrite" ]] && unset _YES && continue + [[ "$a" == "--no-init" ]] && unset _SHOULD_INIT && continue + + # Add repo + [[ -n "$a" ]] && REPO_LIST+=("$a") + done < <( eval $READCMD ) + + main +fi \ No newline at end of file diff --git a/_home/private_dot_local/bin/executable_sz-add-my-apt-repos b/_home/private_dot_local/bin/executable_sz-add-my-apt-repos deleted file mode 100644 index 96a8adf..0000000 --- a/_home/private_dot_local/bin/executable_sz-add-my-apt-repos +++ /dev/null @@ -1,75 +0,0 @@ -#! /usr/bin/env bash - -# Make sure the /usr/share/keyrings dir exists -sudo mkdir -p /usr/share/keyrings 2>&1 > /dev/null - -# Make sure all of the basic required tools are installed for the code -# below to work -sudo apt-get install --yes --no-install-recommends \ - curl gnupg software-properties-common apt-transport-https - -# some utility variables, _YES is optionally '--yes' -[[ ! -z "$1" && "$1" == '--yes' ]] && _YES='--yes' -_OS=$(lsb_release -is | awk '{ print tolower($0) }') -[[ $_OS == 'pop' ]] && _OS='ubuntu' -_REL=$(lsb_release -rs) # Release -_CNM=$(lsb_release -cs) # CodeName -_ARC=$(dpkg --print-architecture) # Architecture - -# The function that does the _Heavy Lifting_. -# see the code that follows for the parameter signature -function add_repo() { - REPO_FQDN=$1 #'download.docker.com' - GPG_KEY_URL=${2:-https:\/\/$REPO_FQDN\/gpg} - GPG_KEY_PATH=/usr/share/keyrings/$REPO_FQDN.gpg - REPO_ARCH=${3:-${_ARC}} - [[ $REPO_ARCH == '-' ]] && REPO_ARCH='' || REPO_ARCH="arch=$REPO_ARCH" - REPO_URL=${4:-https:\/\/$REPO_FQDN} - REPO_SUITE=${5:-$_CNM} - REPO_CMP=${6:-main} - - curl -fsSL $GPG_KEY_URL | sudo gpg --dearmor -o $GPG_KEY_PATH $_YES - echo "Key created: $GPG_KEY_PATH" - echo "deb [$(echo "$REPO_ARCH signed-by=$GPG_KEY_PATH" | xargs )] $REPO_URL $REPO_SUITE $REPO_CMP" | \ - sudo tee /etc/apt/sources.list.d/$REPO_FQDN.list > /dev/null - echo "APT source list added: /etc/apt/sources.list.d/$REPO_FQDN.list" -} - -#Long line - 197 characters long -#add_repo REPO_FQDN/Name GPG_KEY_URL REPO_ARCH REPO_URL REPO_SUITE REPO_CMP # TBD: PIN_PRIORITY -#defaults: 'https://$REPO_FQDN/gpg' $_ARC 'https://$REPO_FQDN' $_CNM 'main' # -# ---------------------------- ------------------------------------------------------- ---------- ------------------------------------------------ ----------- --------- -# for: docker-ce docker-ce-cli containerd.io docker-compose-plugin -# Also don't forget: -# remove: docker docker-engine docker.io containerd runc -# possibly remove docker-compose and install: https://github.com/docker/compose-switch -add_repo 'download.docker.com' "https://download.docker.com/linux/$_OS/gpg" '' "https://download.docker.com/linux/$_OS" '' 'stable' -# for: anydesk -add_repo 'deb.anydesk.com' 'https://keys.anydesk.com/repos/DEB-GPG-KEY' '-' 'http://deb.anydesk.com/' 'all' '' -# for: google-cloud-cli -add_repo 'packages.cloud.google.com' 'https://packages.cloud.google.com/apt/doc/apt-key.gpg' '-' 'https://packages.cloud.google.com/apt' 'cloud-sdk' '' -# for: code (optionally: powershell dotnet-*) -add_repo 'packages.microsoft.com' 'https://packages.microsoft.com/keys/microsoft.asc' '' "https://packages.microsoft.com/$_OS/$_REL/prod" '' '' -# for: microsoft-edge-stable -add_repo 'packages.microsoft.com-edge' 'https://packages.microsoft.com/keys/microsoft.asc' '' 'http://packages.microsoft.com/repos/edge' 'stable' '' -# for: terraform -add_repo 'apt.releases.hashicorp.com' 'https://apt.releases.hashicorp.com/gpg' '' 'https://apt.releases.hashicorp.com' '' '' - -# I really LOVE xscreensavers, but it's been stuck in limbo on the -# `stable` repos, so I install it from the `unstable`, aka `sid`, suite. -# To do that safely, I make sure the repo is pinned to a lower priority. -# I do this BEFORE I add the repo. - -# # Debian sid (unstable) as low-priority option -(echo 'Package: *'; echo 'Pin: release a=unstable'; echo 'Pin-Priority: 200') | sudo tee /etc/apt/preferences.d/unstable > /dev/null -# # pin xscreensaver to unstable -(echo 'Package: xscreenaver*'; echo 'Pin: release a=unstable'; echo 'Pin-Priority: 2000') | sudo tee /etc/apt/preferences.d/xscreensaver > /dev/null - -# for: xscreensaver xscreensaver-data xscreensaver-data-extra -# xscreensaver-screensaver-bsod xscreensaver-screensaver-webcollage -# Add the unstable/sid repo - THIS IS DANGEROUS without the pinning via -# /etc/apt/preferences.d files created by the code above. -sudo apt-add-repository $_YES --no-update "deb [arch=amd64] http://http.us.debian.org/debian sid main non-free contrib" - -# Finally, run `apt update` to check that everything completed successfully -sudo apt update diff --git a/_home/private_dot_local/bin/executable_sz-doctor b/_home/private_dot_local/bin/executable_sz-doctor index 22d902b..26bb9fa 100644 --- a/_home/private_dot_local/bin/executable_sz-doctor +++ b/_home/private_dot_local/bin/executable_sz-doctor @@ -1,4 +1,7 @@ #! /usr/bin/env bash +USER_HOME=$HOME +[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")" +. ${SHRC_D:-$USER_HOME/.pqb.shrc.d}/01_util.functions unset MISSING_APT_PACKAGES export MISSING_APT_PACKAGES=() @@ -8,7 +11,7 @@ APT_OK=$([[ -e $(type -fP apt) ]] && [[ -x $(type -fP apt | head -1) ]] && echo # TODO: Implement a test for specific Package Sources per package check PACKAGE_SOURCES=$( \ - grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* \ + grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null \ | sed 's/\[.*\] //; s/^deb //' \ | sort -u\ ) @@ -70,22 +73,31 @@ function check-exist() { } #### Output starts here -PROD_NAME=$( sudo dmidecode --type 200 2> /dev/null | tail +5 | tail -2 | head -1 | awk '{print $1}') - -MACHINE_INFO_FORMAT='%-14s %-19s %-13s %-11s %s\n' -MACHINE_INFO_FIELDS=("Manufacturer" "Model family" "Model/MTM" "S/N" "BIOS Firmware") -printf "$MACHINE_INFO_FORMAT" "${MACHINE_INFO_FIELDS[@]}" -printf "$MACHINE_INFO_FORMAT" "$( - sudo dmidecode -s system-manufacturer - )" "$(sudo dmidecode -s system-family - )" "${PROD_NAME:-$( - sudo dmidecode -s system-product-name - )}" "$(sudo dmidecode -s system-serial-number - )" "$(sudo dmidecode -s bios-version)" -printf " CPU: %s\n" "$( - sudo dmidecode -s processor-version - )" -echo '' +#### These all run better with sudo +if ( check-exist 'dmidecode' > /dev/null ); then + if recommend_root; then + PROD_NAME=$( dmidecode --type 200 2> /dev/null | tail +5 | tail -2 | head -1 | awk '{print $1}') + + MACHINE_INFO_FORMAT='%-14s %-19s %-13s %-11s %s\n' + MACHINE_INFO_FIELDS=("Manufacturer" "Model family" "Model/MTM" "S/N" "BIOS Firmware") + printf "$MACHINE_INFO_FORMAT" "${MACHINE_INFO_FIELDS[@]}" + printf "$MACHINE_INFO_FORMAT" "$( + dmidecode -s system-manufacturer + )" "$(dmidecode -s system-family + )" "${PROD_NAME:-$( + dmidecode -s system-product-name + )}" "$(dmidecode -s system-serial-number + )" "$(dmidecode -s bios-version)" + printf " CPU: %s\n" "$( + dmidecode -s processor-version + )" + echo '' + else + echo "Running dmidecode requires root access, skipping machine info collection..." + fi +else + echo "dmidecode is required to collect System and BIOS information" +fi echo "Shell: $SHELL (availabe: $(echo $(cat /etc/shells | grep -v 'shells:' | sed "s/^\(.*\/\)*//" | sort -u)))" echo '' @@ -99,13 +111,17 @@ echo '' print-result 'Executable `apt`' $(test-print $APT_OK "Found" "Missing") "$(test-print $APT_OK '' "$(printf 'repair by running:\n%-41sfix-apt.sh')" )" echo '' check-exist 'Byobu' '/usr/bin/byobu-launch' || MISSING_APT_PACKAGES+=('byobu') +check-exist "setxkbmap" '' '' '(Optional)' \ + || MISSING_APT_PACKAGES+=('setxkbmap') check-exist 'oh-my-posh' -check-exist '~/.poshtheme.omp.json' "~/.poshtheme.omp.json" "-r" +check-exist '~/.poshtheme.omp.json' "${USER_HOME}/.poshtheme.omp.json" "-r" check-exist 'tmux' || MISSING_APT_PACKAGES+=('tmux') check-exist 'git' || MISSING_APT_PACKAGES+=('git') check-exist 'emacs' || MISSING_APT_PACKAGES+=('emacs') check-exist 'monit' || MISSING_APT_PACKAGES+=('monit') check-exist 'direnv' || MISSING_APT_PACKAGES+=('direnv') +check-exist "chezmoi" '' '' '' 'wget -O- chezmoi.io/get | bash # or' + # wget -O- lksz.me/dotfiles | bash' check-exist 'terraform' '' '' '' "$( \ [[ -r /usr/share/keyrings/apt.releases.hashicorp.com.gpg ]] \ && MISSING_APT_PACKAGES+=('terraform') \ @@ -114,10 +130,6 @@ check-exist 'terraform' '' '' '' "$( \ || SUGGESTED+=( 'sz-add-my-apt-repos' '# followed by:' 'sudo apt install terraform', '' ) -check-exist "setxkbmap" '' '' '(Optional)' \ - || MISSING_APT_PACKAGES+=('setxkbmap') -check-exist "chezmoi" '' '' '' 'wget -O- chezmoi.io/get | bash # or - # wget -O- lksz.me/dotfiles | bash' check-exist "gcloud" '' '' '' "$( \ [[ -r /usr/share/keyrings/apt.releases.hashicorp.com.gpg ]] \ && MISSING_APT_PACKAGES+=('terraform') \ @@ -125,11 +137,13 @@ check-exist "gcloud" '' '' '' "$( \ )" \ || SUGGESTED+=( 'sz-add-my-apt-repos' '# followed by:' 'sudo apt install gcloud', '' ) +check-exist 'dmidecode' + check-exist 'bash completion' '/usr/share/bash-completion/bash_completion' '-r' -check-exist 'CodeNewRoman Nerd Font' '~/.local/share/fonts/NF_CodeNewRoman' '-d' -check-exist 'FiraCode Nerd Font' '~/.local/share/fonts/NF_FiraCode' '-d' -check-exist '~/bin' "~/bin" '-d' '(Optional)' -check-exist '~/.local/bin' "~/.local/bin" '-d' '(Optional)' +check-exist 'CodeNewRoman Nerd Font' '${USER_HOME}/.local/share/fonts/NF_CodeNewRoman' '-d' +check-exist 'FiraCode Nerd Font' '${USER_HOME}/.local/share/fonts/NF_FiraCode' '-d' +check-exist '~/bin' "${USER_HOME}/bin" '-d' '(Optional)' +check-exist '~/.local/bin' "${USER_HOME}/.local/bin" '-d' '(Optional)' echo "" [[ -n $SUGGESTED ]] && echo 'You might want to run the following commands:' && printf " %s\n" "${SUGGESTED[@]}"