Last active
August 8, 2024 19:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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