1

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .