diff --git a/.bash_profile b/.bash_profile index a2a6b2c..d4ecb8a 100644 --- a/.bash_profile +++ b/.bash_profile @@ -66,3 +66,20 @@ export ANSIBLE_NOCOWS=1 # Ansible aliases. alias an='ansible' alias ap='ansible-playbook' + +# Ask for confirmation when 'prod' is in a command string. +prod_command_trap () { + if [[ $BASH_COMMAND == *prod* ]] + then + read -p "Are you sure you want to run this command on prod [Y/n]? " -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]] + then + echo -e "\nRunning command \"$BASH_COMMAND\" \n" + else + echo -e "\nCommand was not run.\n" + return 1 + fi + fi +} +shopt -s extdebug +trap prod_command_trap DEBUG