7 Commits
0.8.2 ... 0.9.0

Author SHA1 Message Date
9cfc86b596 added .local/bin folder in PATH 2026-04-30 10:23:24 +02:00
2ba65cce12 added variables in deploy function usage message 2026-04-22 18:49:18 +02:00
5e4a8464c5 feat(kubernetes): Guard kubectl initialization and completions
Ensures kubectl-related aliases and functions are only sourced if the `kubectl` command is available.
2026-04-16 19:21:35 +02:00
2c0ac0f6ab feat(bash): Improve source directory calculation in bashrc overrides 2026-04-16 17:08:47 +02:00
77ab262c43 added kubernetes aliases and help functions 2026-04-14 15:26:58 +02:00
d689420388 added aliases and deploy function 2026-03-05 00:46:52 +01:00
1d8ec5e402 added aliases alias 2025-03-29 19:24:33 +01:00
5 changed files with 57 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
_source_basedir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
# Source all the overrides in this folder # Source all the overrides in this folder
for source in $(find "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" -type f | grep -Ev "_all|terminal_fancyfying"); do for source in $(find "${_source_basedir}" -type f | grep -Ev "_all|terminal_fancyfying"); do
. "${source}" . "${source}"
done done
. "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/terminal_fancyfying_${TERMINAL_FANCYFY}" . "${_source_basedir}/terminal_fancyfying_${TERMINAL_FANCYFY}"
# If the file ~/.bash_sources exist, source every line it contains # If the file ~/.bash_sources exist, source every line it contains
if [ -f ~/.bash_sources ]; then if [ -f ~/.bash_sources ]; then

View File

@@ -1,12 +1,16 @@
alias pubkey='for PUBKEY_FILE in $(ls ~/.ssh/id_*.pub); do echo "${PUBKEY_FILE} :" | sed -e "s/.*id_//;s/\.pub//"; cat "${PUBKEY_FILE}"; ssh-keygen -lf "${PUBKEY_FILE}" -E sha256; echo; done' alias pubkey='for PUBKEY_FILE in $(ls ~/.ssh/id_*.pub); do echo "${PUBKEY_FILE} :" | sed -e "s/.*id_//;s/\.pub//"; cat "${PUBKEY_FILE}"; ssh-keygen -lf "${PUBKEY_FILE}" -E sha256; echo; done'
alias taglist='git tag | tr - \~ | sort -V | tr \~ -' alias taglist='git tag | tr - \~ | sort -V | tr \~ -'
alias desudo="sudo -k"
alias hosts='sudo nano /etc/hosts' alias hosts='sudo nano /etc/hosts'
alias historygrep='history | grep' alias historygrep='history | grep'
alias sshconfig='nano ~/.ssh/config' alias sshconfig='nano ~/.ssh/config'
alias aliases='nano ~/.bash_aliases'
alias bashrc='. ~/.bashrc' alias bashrc='. ~/.bashrc'
alias bashrc-edit="nano ~/.bashrc"
alias sshagent='eval `ssh-agent` && ssh-add ~/.ssh/id_!(*.pub)' alias sshagent='eval `ssh-agent` && ssh-add ~/.ssh/id_!(*.pub)'
alias sshfingerprint='ssh-keygen -lf' alias sshfingerprint='ssh-keygen -lf'
alias nocomments='grep -vE "^$|^#|^;"' alias nocomments='grep -vE "^$|^#|^;"'
alias ipecho="curl -fsSL https://ipecho.net/plain; echo"
alias newrepo='bash <(curl -s https://get.bjphoster.com/new-git-repo.sh)' alias newrepo='bash <(curl -s https://get.bjphoster.com/new-git-repo.sh)'
alias newansibleworkspace='bash <(curl -s https://get.bjphoster.com/new-ansible-workspace.sh)' alias newansibleworkspace='bash <(curl -s https://get.bjphoster.com/new-ansible-workspace.sh)'
alias infinitenothing='while true; do sleep 1; done' alias infinitenothing='while true; do sleep 1; done'

17
bashrc_overrides/deploy Normal file
View File

@@ -0,0 +1,17 @@
deploy() {
REPO_HOST="git.bjphoster.com/"
REPO_ORG="deployments"
DEPLOY_DIRECTORY="${DEPLOY_DIRECTORY:-/srv}"
SERVICE="$1"
if [ "$#" -lt 1 ]; then
echo "Usage: deploy <service> [service-name]"
echo "Variable overrides: REPO_HOST - REPO_ORG - DEPLOY_DIRECTORY"
return
fi
if [ "$#" -gt 1 ]; then
SERVICE_NAME="$2"
else
SERVICE_NAME="$SERVICE"
fi
git clone https://$REPO_HOST$REPO_ORG/$SERVICE $DEPLOY_DIRECTORY/$SERVICE_NAME
}

View File

@@ -1,4 +1,8 @@
# set PATH so it includes user's private bin if it exists # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:$PATH"
fi
# also include .local/bin if it exists
if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH"
fi fi

View File

@@ -0,0 +1,27 @@
if command -v kubectl >/dev/null 2>&1; then
source <(kubectl completion bash)
alias k="kubectl"
alias kcontext="kubectl config use-context"
kns() {
if [[ $# -eq 0 ]]; then
printf '%s\n' "$(kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}')"
else
local ns="${1?Namespace required}"
kubectl config set-context --current --namespace "$ns"
printf 'Switched current context to namespace: %s\n' "$ns"
fi
}
_kns_completion() {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(kubectl get namespaces -o name | sed 's|namespace/||')" -- "$cur") )
}
_kcontext_completion() {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(kubectl config get-contexts -o name)" -- $cur) )
}
complete -F __start_kubectl k
complete -F _kns_completion kns
complete -F _kcontext_completion kcontext
fi