diff --git a/bash/.functions b/bash/.functions index 41c5043..5b3ebbe 100644 --- a/bash/.functions +++ b/bash/.functions @@ -18,6 +18,49 @@ maths() cat_with_newline() { - cat "$@" && echo + \cat "$@" && echo } alias cat="cat_with_newline" + +k_prompt() +{ + set -x + if [ -z ${KUBE_PROMPT+x} ]; then + export KUBE_PROMPT=1 + else + unset KUBE_PROMPT + fi + set +x +} + +kube_prompt() +{ + set -x + if ! [ -z ${KUBE_PROMPT+x} ]; then + context=$(\cat ${KUBECONFIG} \ + | grep "current-context: " \ + | sed "s/current-context: //") + echo {$context} + fi + set +x +} + +g_prompt() +{ + if ! [ -z ${GIT_PROMPT+x} ]; then + export GIT_PROMPT=1 + else + unset GIT_PROMPT + fi +} + +git_prompt() +{ + if ! [ -z ${GIT_PROMPT+x} ]; then + # Determine if we are in a git repository + if git rev-parse --is-inside-work-tree &> /dev/null; then + branch=$(git rev-parse --abbrev-ref HEAD) + echo [$branch] + fi + fi +}