Created
June 29, 2023 19:03
-
-
Save austintraver/951abc03c4f3dd5934e78e0068886c85 to your computer and use it in GitHub Desktop.
An illustrative example on how to use ZSH traps.
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
#!/bin/zsh | |
nap() { | |
print "Taking a nap..." | |
command sleep 3 | |
} | |
TRAPINT() { | |
# Remove the printed '^C' from the console. | |
print -n "\x1b[2D" | |
# Initiate anarchy." | |
print "You're not the boss of me, CTRL-C!" | |
command sleep 0.2 | |
# Restart our interrupted nap-nap... | |
nap | |
return 0 | |
} | |
nap | |
print "All done..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment