From ab3e8132ccc8ee3f3f09dcb5d2e4a8be4d5cc767 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Wed, 3 Aug 2022 22:43:35 -0400 Subject: [PATCH] chore: mostly cleanup and formatting --- _home/dot_sz.shrc.d/bash.post/99_chezmoi.complete | 2 +- _home/dot_sz.shrc.d/bash.pre/10_check_completion | 5 ++++- _home/dot_sz.shrc.d/bash.pre/21_aliases | 4 +++- _home/private_dot_local/bin/executable_sz-add-my-apt-repos | 5 ++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete index da06e6e..4bd013e 100644 --- a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete +++ b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete @@ -1 +1 @@ -[[ -n "$BASH_COMPLETION_EXIST" && -n $(type -fP chezmoi) ]] && source <(chezmoi completion bash | add-alias-to-bash-completion-code cz ) +[[ -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.pre/10_check_completion b/_home/dot_sz.shrc.d/bash.pre/10_check_completion index 3e46793..8ad89ce 100644 --- a/_home/dot_sz.shrc.d/bash.pre/10_check_completion +++ b/_home/dot_sz.shrc.d/bash.pre/10_check_completion @@ -1 +1,4 @@ -[[ -r /usr/share/bash-completion/bash_completion ]] && BASH_COMPLETION_EXIST=1 +if [[ -r /usr/share/bash-completion/bash_completion ]]; then + BASH_COMPLETION_EXIST=1 +fi + diff --git a/_home/dot_sz.shrc.d/bash.pre/21_aliases b/_home/dot_sz.shrc.d/bash.pre/21_aliases index c41f21e..f4bb23a 100644 --- a/_home/dot_sz.shrc.d/bash.pre/21_aliases +++ b/_home/dot_sz.shrc.d/bash.pre/21_aliases @@ -1,6 +1,8 @@ alias which-command="type -fP " function add-alias-to-bash-completion-code() { - local CMD=$(printf "%s" "sed '" 's/\(complete\W.*-F\W.*chezmoi\)/\1 ' "$1/g'") + local CMD=$(printf "%s" "sed '" 's/\(complete\W.*-F\W.*' "$1" '.*$\)/\1 ' "$2/g'") + [[ -r "$3" ]] && CMD="$CMD -i $3" + [[ -n "$4" ]] && CMD="$4 $CMD" eval "$CMD" } 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 index 7f830cf..96a8adf 100644 --- a/_home/private_dot_local/bin/executable_sz-add-my-apt-repos +++ b/_home/private_dot_local/bin/executable_sz-add-my-apt-repos @@ -1,6 +1,5 @@ #! /usr/bin/env bash - # Make sure the /usr/share/keyrings dir exists sudo mkdir -p /usr/share/keyrings 2>&1 > /dev/null @@ -28,7 +27,7 @@ function add_repo() { 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" | \ @@ -42,7 +41,7 @@ function add_repo() { # ---------------------------- ------------------------------------------------------- ---------- ------------------------------------------------ ----------- --------- # for: docker-ce docker-ce-cli containerd.io docker-compose-plugin # Also don't forget: -# remove: docker docker-engine docker.io containerd runc +# 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