Skip to content

Commit

Permalink
Should now work for both bash and zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
patmessina committed Dec 21, 2018
1 parent d7b679b commit 8c1da8c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions kube-aliases.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# #!/bin/bash

# Auto complete, for bash replace zsh with bash
# For some reason this is sourcing the oh-my-zsh plugin.
# source <(kubectl completion zsh)

KALIAS=$ZSH_CUSTOM/plugins/zsh-kubernetes
KRESOURCES=$ZSH_CUSTOM/plugins/zsh-kubernetes/docs/resources
SHELL_NAME=$(basename $SHELL)

# Contexts
alias kcc='kubectl config get-contexts'
Expand Down Expand Up @@ -191,7 +190,7 @@ kexec () {
kubectl exec -it $1 ${2:-bash}
}

# Set and use a new context
# Set and use a new context
knc () {
kc config set-context $1
kc config use-context $1
Expand Down Expand Up @@ -262,15 +261,27 @@ kgpns () {

# Delete all pods within a namespace.
kdap () {
read "kdelete?This will attempt to delete all pods within the namespace. Do you want to continue?(y/N) "

if [ $SHELL_NAME = zsh ]; then
read "kdelete?This will attempt to delete all pods within the namespace. Do you want to continue?(y/N) "
else
read -p "This will attempt to delete all pods within the namespace. Do you want to continue?(y/N) " kdelete
fi

if [[ "${kdelete}" =~ ^[yY]$ ]]; then
kubectl delete pods $(kgpns)
fi
}

# Drain node
# Drain node
kdrain () {
read "kdrainnode? This will drain the node ${1}, delete local data, and ignore daemonsets. Do you want to continue?(y/N) "

if [ $SHELL_NAME = zsh ]; then
read "kdrainnode? This will drain the node ${1}, delete local data, and ignore daemonsets. Do you want to continue?(y/N) "
else
read -p "This will drain the node ${1}, delete local data, and ignore daemonsets. Do you want to continue?(y/N) " kdrainnode
fi

if [[ "${kdrainnode}" =~ ^[yY]$ ]]; then
kubectl drain ${1} --delete-local-data --force --ignore-daemonsets
fi
Expand Down

0 comments on commit 8c1da8c

Please sign in to comment.