Compare commits
No commits in common. "86cc420d574498c84b4f1e4692d601f14dd3a7c1" and "01cb3798ed16e01f2f27001baa1a510aa1c19e86" have entirely different histories.
86cc420d57
...
01cb3798ed
59
fix-kubectl
59
fix-kubectl
|
@ -1,26 +1,11 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
# shellcheck disable=SC2034,SC1090
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
# SC2034 variables appear unsued. export if used externally
|
USER_HOME=$HOME
|
||||||
# - uneeded, as this checked whether script is sourced
|
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
||||||
# SC1090 Can't follow non-constant source
|
|
||||||
|
|
||||||
# Helper function
|
BASE_0="$(basename ${0#-})"
|
||||||
is_sourced() {
|
BASE_SHELL="$(basename "$SHELL")"
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; 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
|
|
||||||
DBG_="Is Sourced"
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASE_0}" )" &> /dev/null && pwd )
|
|
||||||
USER_HOME=$HOME
|
|
||||||
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
|
||||||
|
|
||||||
[[ -n "$KUBECONFIG" && -r "$KUBECONFIG" ]] || unset KUBECONFIG
|
[[ -n "$KUBECONFIG" && -r "$KUBECONFIG" ]] || unset KUBECONFIG
|
||||||
|
|
||||||
|
@ -28,16 +13,14 @@ if is_sourced; then
|
||||||
|| export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"
|
|| export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"
|
||||||
|
|
||||||
if [[ -z "$KUBECONFIG" && -z "$FIX_KUBECTL_RECALL" ]]; then
|
if [[ -z "$KUBECONFIG" && -z "$FIX_KUBECTL_RECALL" ]]; then
|
||||||
(unset kubectl 2>/dev/null) || (unalias kubectl 2>/dev/null) || true
|
unset kubectl 2>/dev/null || unalias kubectl 2>/dev/null || true
|
||||||
|
|
||||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(unset kubectl-fix 2> /dev/null) || true
|
[[ 'function' == $(type -t kubectl-fix) ]] && unset kubectl-fix
|
||||||
|
|
||||||
DBG_="Check if k3s exists, but kubectl isn't available"
|
if [[ -n "$(type -t 'k3s')" && -z "$(type -t 'kubectl')" ]]; then
|
||||||
if (type 'k3s' >/dev/null 2>&1) && ! (type 'kubectl' >/dev/null 2>&1); then
|
|
||||||
DBG_="Define kubectl"
|
|
||||||
if [[ -r "${KUBECONFIG}" ]]; then
|
if [[ -r "${KUBECONFIG}" ]]; then
|
||||||
kubectl() { k3s kubectl "${@}"; }
|
kubectl() { k3s kubectl "${@}"; }
|
||||||
elif [[ -n "${KUBECONFIG}" && -e "${KUBECONFIG}" ]]; then
|
elif [[ -n "${KUBECONFIG}" && -e "${KUBECONFIG}" ]]; then
|
||||||
|
@ -48,19 +31,19 @@ if is_sourced; then
|
||||||
sudo install --mod 600 --owner \"$USER\" \"\${KUBECONFIG}\" \"$HOME/.kube/config\"
|
sudo install --mod 600 --owner \"$USER\" \"\${KUBECONFIG}\" \"$HOME/.kube/config\"
|
||||||
unset KUBECONFIG
|
unset KUBECONFIG
|
||||||
fi
|
fi
|
||||||
FIX_KUBECTL_RECALL=1 . \"${SCRIPT_DIR}/${BASE_0}\"
|
FIX_KUBECTL_RECALL=1 . \"$SCRIPT_FULL_PATH\"
|
||||||
}"
|
}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (type 'kubectl' >/dev/null 2>&1); then
|
if [[ -n "$(type -t 'kubectl')" ]]; then
|
||||||
|
|
||||||
. <( kubectl completion "${BASE_SHELL}" )
|
. <( kubectl completion ${SHELL##*/} )
|
||||||
|
|
||||||
if (type 'kubectl-cnpg' >/dev/null 2>&1 ); then
|
if [[ -n "$(type -t 'kubectl-cnpg')" ]]; then
|
||||||
. <( kubectl cnpg completion "${BASE_SHELL}" )
|
. <( kubectl cnpg completion ${SHELL##*/} )
|
||||||
fi
|
fi
|
||||||
if ! (type 'kubectl-cnpg' >/dev/null 2>&1) || [[ -n "$UPGRADE" ]]; then
|
if [[ -z "$(type -t 'kubectl-cnpg')" || -n "$UPGRADE" ]]; then
|
||||||
DL_VER=1.22.0
|
DL_VER=1.22.0
|
||||||
GH_URL=https://github.com/cloudnative-pg/cloudnative-pg
|
GH_URL=https://github.com/cloudnative-pg/cloudnative-pg
|
||||||
DL_FILE="kubectl-cnpg_${DL_VER}_linux_x86_64.deb"
|
DL_FILE="kubectl-cnpg_${DL_VER}_linux_x86_64.deb"
|
||||||
|
@ -71,7 +54,7 @@ if is_sourced; then
|
||||||
" sudo dpkg -i $DL_FILE"
|
" sudo dpkg -i $DL_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! (type 'kubetui' >/dev/null 2>&1) || [[ -n "$UPGRADE" ]]; then
|
if [[ -z "$(type -t 'kubetui')" || -n "$UPGRADE" ]]; then
|
||||||
DL_VER=1.5.0
|
DL_VER=1.5.0
|
||||||
GH_URL=https://github.com/sarub0b0/kubetui
|
GH_URL=https://github.com/sarub0b0/kubetui
|
||||||
DL_FILE=kubetui-x86_64-unknown-linux-musl-rustls
|
DL_FILE=kubetui-x86_64-unknown-linux-musl-rustls
|
||||||
|
@ -82,26 +65,26 @@ if is_sourced; then
|
||||||
" chmod +x ~/bin/kubetui"
|
" chmod +x ~/bin/kubetui"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! (type 'k9s' >/dev/null 2>&1) || [[ -n "$UPGRADE" ]]; then
|
if [[ -z "$(type -t 'k9s')" || -n "$UPGRADE" ]]; then
|
||||||
printf '%s\n' \
|
printf '%s\n' \
|
||||||
'To download and install k9s, run:' \
|
'To download and install k9s, run:' \
|
||||||
" curl -sS https://webinstall.dev/k9s | bash"
|
" curl -sS https://webinstall.dev/k9s | bash"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (type 'k3s' >/dev/null 2>&1 ); then
|
if [[ -n "$(type -t 'k3s')" ]]; then
|
||||||
. <( k3s completion "${SHELL##*/}" )
|
. <( k3s completion "${SHELL##*/}" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (type 'helm' >/dev/null 2>&1); then
|
if [[ -n "$(type -t 'helm')" ]]; then
|
||||||
. <( helm completion "${SHELL##*/}" 2>/dev/null )
|
. <( helm completion "${SHELL##*/}" 2>/dev/null )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kg() {
|
kg() {
|
||||||
kubectl get "${NS:+--namespace=}${NS:---all-namespaces}" "${@}" | { sed -u 1q; sort; }
|
kubectl get ${NS:+--namespace=}${NS:---all-namespaces} "${@}" | { sed -u 1q; sort; }
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
elif [[ "$1" == '-' ]]; then
|
elif [[ "$1" == '-' ]]; then
|
||||||
printf 'BASE_0="%s"\n' "${BASE_0}"
|
printf '%s\n' "SCRIPT_FULL_PATH='$SCRIPT_DIR/$BASE_0'"
|
||||||
cat "${BASH_SOURCE[0]}"
|
cat "${BASH_SOURCE[0]}"
|
||||||
else
|
else
|
||||||
SCRIPT_NAME="$BASE_0"
|
SCRIPT_NAME="$BASE_0"
|
||||||
|
|
|
@ -19,12 +19,11 @@ if [[ $USER == "$(sudo bash -c "echo \$SUDO_USER")" ]]; then
|
||||||
sudo update-alternatives --remove vim.tiny /usr/bin/vim.tiny || true
|
sudo update-alternatives --remove vim.tiny /usr/bin/vim.tiny || true
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt remove vim-tiny
|
sudo apt remove vim-tiny
|
||||||
sudo apt install neovim
|
sudo apt install fzf neovim fd-find ripgrep
|
||||||
# sudo apt install fzf fd-find ripgrep
|
sudo apt install atool caca-utils figlet zip
|
||||||
# sudo apt install atool caca-utils figlet zip
|
sudo apt install --yes mediainfo exiftool mupdf-tools cmigemo dict dict-wn dictd libsixel-bin xsel
|
||||||
# sudo apt install --yes mediainfo exiftool mupdf-tools cmigemo dict dict-wn dictd libsixel-bin xsel
|
# sudo apt install w3m-el xdg-utils unoconv
|
||||||
# # sudo apt install w3m-el xdg-utils unoconv
|
sudo apt install --yes ranger
|
||||||
# sudo apt install --yes ranger
|
|
||||||
echo "sudo section done."
|
echo "sudo section done."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
24
load-fzf
24
load-fzf
|
@ -1,21 +1,7 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
# shellcheck disable=SC2034,SC1090
|
|
||||||
# SC2034 variables appear unsued. export if used externally
|
|
||||||
# - uneeded, as this checked whether script is sourced
|
|
||||||
# SC1090 Can't follow non-constant source
|
|
||||||
|
|
||||||
# Helper function
|
BASE_0="$(basename ${0#-})"
|
||||||
is_sourced() {
|
BASE_SHELL="$(basename "$SHELL")"
|
||||||
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 [[ "$1" == "--force" ]]; then
|
if [[ "$1" == "--force" ]]; then
|
||||||
[[ -e ~/.local/bin/fzf ]] && rm ~/.local/bin/fzf
|
[[ -e ~/.local/bin/fzf ]] && rm ~/.local/bin/fzf
|
||||||
|
@ -26,12 +12,11 @@ fi
|
||||||
if [[ -z "$(type -t fzf)" || ! -e "$(type -p fzf)" ]]; then
|
if [[ -z "$(type -t fzf)" || ! -e "$(type -p fzf)" ]]; then
|
||||||
curl -sS https://webi.sh/fzf | bash >&2
|
curl -sS https://webi.sh/fzf | bash >&2
|
||||||
|
|
||||||
# shellcheck disable=SC2016 # $ inside single quotes is intentional
|
|
||||||
printf '%s\n' \
|
printf '%s\n' \
|
||||||
'Run the following and then try again:' \
|
'Run the following and then try again:' \
|
||||||
' exec $SHELL -l' \
|
' exec $SHELL -l' \
|
||||||
'' >&2
|
'' >&2
|
||||||
elif is_sourced; then
|
elif [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then
|
||||||
|
|
||||||
FZF_CTRL_T_COMMAND="command find -L . -xdev -mindepth 1 \\( \
|
FZF_CTRL_T_COMMAND="command find -L . -xdev -mindepth 1 \\( \
|
||||||
-path '*/\\.*' \
|
-path '*/\\.*' \
|
||||||
|
@ -43,9 +28,6 @@ elif is_sourced; then
|
||||||
-o -type l -print 2> /dev/null | cut -b3- \
|
-o -type l -print 2> /dev/null | cut -b3- \
|
||||||
"
|
"
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
# variable appears unsued. export if used externally
|
|
||||||
# - uneeded, as script is sourced
|
|
||||||
FZF_ALT_C_COMMAND="command find -L . -xdev -mindepth 1 \\( \
|
FZF_ALT_C_COMMAND="command find -L . -xdev -mindepth 1 \\( \
|
||||||
-path '*/\\.*' \
|
-path '*/\\.*' \
|
||||||
-xdev \
|
-xdev \
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#! /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
|
|
||||||
starship() {
|
|
||||||
if [[ ! -x "$HOME/bin/starship" ]]; then
|
|
||||||
curl -sS https://starship.rs/install.sh | FORCE=1 BIN_DIR="$HOME/bin" sh > /dev/null
|
|
||||||
fi
|
|
||||||
"$HOME/bin/starship" "${@}"
|
|
||||||
}
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. <( starship init "$BASE_SHELL" ) 2> /dev/null
|
|
||||||
|
|
||||||
elif [[ "$1" == '-' ]]; then
|
|
||||||
echo "BASE_0=${BASE_0}"
|
|
||||||
cat "${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
|
|
||||||
|
|
31
load-zellij
31
load-zellij
|
@ -1,19 +1,9 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
# Helper function
|
BASE_0="$(basename ${0#-})"
|
||||||
is_sourced() {
|
BASE_SHELL="$(basename "$SHELL")"
|
||||||
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}
|
if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then
|
||||||
BASE_SHELL=$(basename "$SHELL")
|
|
||||||
|
|
||||||
if is_sourced; then
|
|
||||||
zellij() {
|
zellij() {
|
||||||
if [[ -x /tmp/zellij/bootstrap/zellij ]]; then
|
if [[ -x /tmp/zellij/bootstrap/zellij ]]; then
|
||||||
/tmp/zellij/bootstrap/zellij "${@}"
|
/tmp/zellij/bootstrap/zellij "${@}"
|
||||||
|
@ -21,22 +11,13 @@ if is_sourced; then
|
||||||
bash <(curl -sL zellij.dev/launch) "${@}"
|
bash <(curl -sL zellij.dev/launch) "${@}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
. <( zellij setup --generate-completion "$BASE_SHELL" )
|
||||||
if [[ -z "$ZELLIJ_SESSION_NAME" ]]; then
|
if [[ -z "$ZELLIJ_SESSION_NAME" ]]; then
|
||||||
# shellcheck disable=SC2210
|
(zellij list-sessions 2&>1) > /dev/null || zellij attach -c $USER@$(hostname)
|
||||||
#(zellij list-sessions 2&>1) > /dev/null || zellij attach -c "$USER@$(hostname)"
|
|
||||||
zellij attach -c "$USER@$(hostname)" || EXITCODE=$?
|
|
||||||
|
|
||||||
# shellcheck disable=SC2086 # EXITCODE might be empty
|
|
||||||
return $EXITCODE
|
|
||||||
fi
|
|
||||||
if [[ -z "$ZSH_VERSION" ]] || (type compdef > /dev/null 2>&1); then
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. <( zellij setup --generate-completion "$BASE_SHELL" ) 2> /dev/null
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ "$1" == '-' ]]; then
|
elif [[ "$1" == '-' ]]; then
|
||||||
echo "BASE_0=${BASE_0}"
|
cat "${BASH_SOURCE[0]}"
|
||||||
cat "${0}"
|
|
||||||
else
|
else
|
||||||
SCRIPT_NAME="$BASE_0"
|
SCRIPT_NAME="$BASE_0"
|
||||||
printf '%s\n' \
|
printf '%s\n' \
|
||||||
|
|
Loading…
Reference in New Issue