Add prod command trap to save myself from utter destruction.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user