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

Blake Taylor
  • 113
  • 3

1 Answers1

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