iterm2: Ctrl-C doesn't work sometimes
One of the possible causes for this is that you've used trap
to set the INT signal to something else.
If you reset the trap(ed function) on INT to default, this problem should go away1. You can do that by doing this:
trap - INT
trap
One other way to fix this, although "hacky", is to add something like the following to your .zshrc
or .bashrc
:
function reset_trap {
# Hacky hack because of <function/script-that-sets-trap-INT>
trap - INT
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec reset_trap
1 At least, that/this worked for me!
I'm posting a work around here as it might benefit some people. I will not accept it myself though.
When this happens, kill
the running process in the current tab, probably from a different tab/shell. Then in the original tab, execute reset
and things will get back to normal.
Still don't know why.