Skip to content

Instantly share code, notes, and snippets.

@austintraver
Created June 29, 2023 19:03
Show Gist options
  • Save austintraver/951abc03c4f3dd5934e78e0068886c85 to your computer and use it in GitHub Desktop.
Save austintraver/951abc03c4f3dd5934e78e0068886c85 to your computer and use it in GitHub Desktop.
An illustrative example on how to use ZSH traps.
#!/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