Skip to content

Instantly share code, notes, and snippets.

@esin
Last active January 31, 2019 09:11
Show Gist options
  • Save esin/acf5205d77714b700c00f754e5edc06f to your computer and use it in GitHub Desktop.
Save esin/acf5205d77714b700c00f754e5edc06f to your computer and use it in GitHub Desktop.
safe-kubectl
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
}
@esin
Copy link
Author

esin commented Jan 31, 2019

Just add this code to ~/.bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment