Need confirmation before uninstalling helm chart?

3 years since Helm graduated as a CNCF project and there is still no safeguard on typing 'helm uninstall'.

The GitHub issue did not receive attention and was closed to stale.

One can easily make mistakes when working with the same chart between multiple clusters, like test and production clusters.

To avoid Oops moments, I borrowed the idea from the author of the above GitHub issue and made minor adjustments.

Put this in your ~/.bashrc or ~/.zshrc to stay away from the fear of accidents.

function helm {
  if [[ "${@:1:1}" == "uninstall" ]]; then
          helm_uninstall "${@:2}"
          command helm "$@"
function helm_uninstall {
  echo "[>] Current kubectl context: $(kubectl config current-context)"
  read "? Are you sure to uninstall '$@'?"
  if [[ $REPLY =~ ^[Yy]$ ]]
      command helm uninstall "$@"