Skip to content

Instantly share code, notes, and snippets.

@ierceg
Last active August 8, 2024 19:25
Show Gist options
  • Save ierceg/9e1b2761eab48fb5b03759c94697581b to your computer and use it in GitHub Desktop.
Save ierceg/9e1b2761eab48fb5b03759c94697581b to your computer and use it in GitHub Desktop.
macOS + zshell: say "The deployment has finished" after every command that has the string `deploy` in it
# Put this into your .zhrc
DEPLOY_FLAG=0
# Override the 'preexec' function to intercept commands before they are executed
function preexec() {
# Get the command as input
local command="$1"
# Set the flag if the command contains "deploy"
if [[ "$command" =~ .*deploy.* ]]; then
DEPLOY_FLAG=1
else
DEPLOY_FLAG=0
fi
}
# Override the 'precmd' function to run after each command
function precmd() {
# Check if the flag is set
if [[ $DEPLOY_FLAG -eq 1 ]]; then
say "The deployment has finished"
DEPLOY_FLAG=0
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment