Add prompt generation commands for git/kubernetes
This commit is contained in:
parent
b1f6fc2f52
commit
e24e8a1c49
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user