add functions
This commit is contained in:
parent
c1bafe01a2
commit
402aa8d449
1 changed files with 35 additions and 0 deletions
35
dotfiles/functions
Normal file
35
dotfiles/functions
Normal 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
|
||||
}
|
Loading…
Reference in a new issue