add functions

This commit is contained in:
Gerrit Pannek 2024-05-24 19:15:47 +02:00
parent c1bafe01a2
commit 402aa8d449

35
dotfiles/functions Normal file
View file

@ -0,0 +1,35 @@
# Venv Switcher
VENV_BASE="${HOME}/.venv"
type python &>/dev/null && PY=python
type python3 &>/dev/null && PY=python3
mkdir -p "${VENV_BASE}"
function create_venv {
if [ -d "${VENV_BASE}/$1" ] ; then
return
fi
$PY -m venv "${VENV_BASE}/$1"
}
function venv {
case "$1" in
l) ls -1 "${VENV_BASE}" | sed 's/^/\ \-\ /g' ;;
c) create_venv $2 ; shift ;;
s) create_venv $2 ; shift ; source "${VENV_BASE}/$1/bin/activate" ;;
*) source "${VENV_BASE}/$1/bin/activate" ;;
esac
if [ -n "$1" ] ; then
export PATH=$PATH:${VENV_BASE}/$1/bin
fi
}
function kubeprune {
for ns in $(kubectl get ns | awk '{ print $1 }'); do
for pod in $(kubectl get $1 -n $ns 2>/dev/null | grep $2 | awk '{ print $1}'); do
kubectl delete $1 -n $ns $pod
done
done
}