Ctrl-z suspends the foreground process, but when there is nothing in the foreground it has no effect. I want to overload ctrl-z so when there is nothing in the foreground it brings the most recently suspended process back. This way, hitting ctrl-z toggles the foreground process. How would you do this?

BTW, I use zsh, but anything that works in bash should work too. I'm in terminal on OS X

1 Answer 1

ctrlz () {
  if [[ $#BUFFER -eq 0 ]]; then
    zle redisplay
    zle push-input
zle -N ctrlz
bindkey '^Z' ctrlz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.