Last active
January 31, 2019 09:11
-
-
Save esin/acf5205d77714b700c00f754e5edc06f to your computer and use it in GitHub Desktop.
safe-kubectl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl() { | |
if [[ $1 == "apply" ]] || [[ $1 == "create" ]] || [[ $1 == "delete" ]] || [[ $1 == "edit" ]] || [[ $1 == "patch" ]]; then | |
cc=$(/usr/bin/kubectl config current-context); | |
read -p $'Current context is \e[1m'$cc$'\e[0m. Show must go on? ' -n1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
/usr/bin/kubectl $@ | |
return 0 | |
fi | |
else | |
/usr/bin/kubectl $@ | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just add this code to ~/.bashrc