.
This commit is contained in:
28
.functions/kubernetes.sh
Normal file
28
.functions/kubernetes.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
function kc(){
|
||||
# print all kubernetes contexts
|
||||
kubectl config get-contexts
|
||||
}
|
||||
|
||||
function kuc(){
|
||||
# use kubernetes context <param>
|
||||
kubectl config use-context "$1"
|
||||
}
|
||||
|
||||
function kubernetes_configs(){
|
||||
# set KUBECONFIG to default kubeconfig and all *.yaml files in .kube
|
||||
local KUBE_CONFIG_DEFAULT="$HOME/.kube/config"
|
||||
local KUBE_CONFIG_DIR="$HOME/.kube"
|
||||
local KUBE_CONFIG_EXTENTION="*.yaml"
|
||||
if [[ -f "${KUBE_CONFIG_DEFAULT}" ]];then
|
||||
export KUBECONFIG="$KUBE_CONFIG_DEFAULT"
|
||||
fi
|
||||
[[ -d "${KUBE_CONFIG_DIR}" ]] || mkdir -p "${KUBE_CONFIG_DIR}"
|
||||
# shellcheck disable=SC2044
|
||||
for file in $(find "${KUBE_CONFIG_DIR}" -type f -name "$KUBE_CONFIG_EXTENTION"); do
|
||||
export KUBECONFIG="$file:$KUBECONFIG"
|
||||
done
|
||||
}
|
||||
|
||||
kubernetes_configs
|
38
.functions/ps1.sh
Normal file
38
.functions/ps1.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
function set_bash_prompt () {
|
||||
local LAST_EXIT_STATUS=$?
|
||||
local EXIT_STATUS=""
|
||||
local Color_Off='\033[0m' # Text Reset
|
||||
|
||||
local COLOR_DIVIDER="\033[0;32m"
|
||||
local COLOR_USERNAME="\[\e[34;1m\]"
|
||||
local COLOR_USERHOSTAT="\[\e[34;1m\]"
|
||||
local COLOR_HOSTNAME="\[\e[34;1m\]"
|
||||
local COLOR_GITBRANCH="\[\e[33;1m\]"
|
||||
local COLOR_VENV="\033[0;36m"
|
||||
local PATH_COLOR="\033[0;37m"
|
||||
|
||||
if [[ $LAST_EXIT_STATUS != 0 ]];then
|
||||
EXIT_STATUS="${COLOR_DIVIDER}[\033[1;37m\033[41m${LAST_EXIT_STATUS}${Color_Off}${COLOR_DIVIDER}]"
|
||||
fi
|
||||
|
||||
PS1="\n${COLOR_DIVIDER}┌──(${COLOR_USERNAME}\u${COLOR_USERHOSTAT}@${COLOR_HOSTNAME}\h${COLOR_DIVIDER})─[${PATH_COLOR}\w${COLOR_DIVIDER}]${EXIT_STATUS}"
|
||||
PS1="$PS1${COLOR_GITBRANCH}$(__git_ps1)${COLOR_DIVIDER}"
|
||||
# # Add git branch portion of the prompt"
|
||||
# if ! git_loc="$(type -p "$git_command_name")" || [ -z "$git_loc" ]; then
|
||||
# # Git is installed
|
||||
# if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
||||
# # Inside of a git repository
|
||||
# GIT_BRANCH=$(git symbolic-ref --short HEAD)
|
||||
# PS1="${PS1}:${COLOR_GITBRANCH}${GIT_BRANCH}${COLOR_DIVIDER}"
|
||||
# fi
|
||||
# fi
|
||||
# Add Python VirtualEnv portion of the prompt, this adds ":venvname"
|
||||
if ! test -z "$VIRTUAL_ENV" ; then
|
||||
PS1="${PS1}(${COLOR_VENV}${VIRTUAL_ENV##*/}${COLOR_DIVIDER})"
|
||||
fi
|
||||
PS1="${PS1}\n${COLOR_DIVIDER}└─\$${Color_Off} "
|
||||
}
|
||||
|
||||
# Tell Bash to run the above function for every prompt
|
||||
export PROMPT_COMMAND=set_bash_prompt
|
Reference in New Issue
Block a user