41 lines
942 B
Text
41 lines
942 B
Text
# 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 {
|
|
if [ -z "$1" ] ; then
|
|
ls -1 "${VENV_BASE}" | sed 's/^/\ \-\ /g'
|
|
return
|
|
fi
|
|
|
|
case "$1" in
|
|
l) ls -1 "${VENV_BASE}" | sed 's/^/\ \-\ /g' ;;
|
|
c) create_venv $2 ; shift ;;
|
|
d) rm -rf "${VENV_BASE}/$2" ;;
|
|
s) create_venv "$1" ; shift ; source "${VENV_BASE}/$1/bin/activate" ;;
|
|
*) create_venv "$1" ; 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
|
|
}
|