When I suspend python with ctrl+Z and try to get it back with fg, I cannot use the python interactive command prompt anymore. Pressing the Enter key produces ^M on the screen, Esc produces ^[ and even ctrl+C doesn't work (it just displays ^C). I have to use ctrl+Z again and kill %1.

Any guesses as to what's wrong?

I'm using zsh with iTerm2 on MacOS Catalina.

I've included a screenie below.

enter image description here

P.S. I know cross-posting is frowned upon, but I didn't get any responses on StackOverflow so I have copy-pasted my question here. Google has been unhelpful, as I cannot search special characters (such as ^M).

  • Does this behavior occur with Terminal.app? Commented Jun 1, 2022 at 14:35
  • @MarcWilson Yes it does. Commented Jun 1, 2022 at 14:40
  • It doesn't happen here. Who's python is that? Reaching for straws, if you launch the shell without the custom config, does it still occur? Commented Jun 1, 2022 at 14:48
  • @MarcWilson I removed my ~/.zshrc and the problem went away. Then I narrowed it down to the z plugin. I have commented it out in my .zshrc and it's fine now. I'm not well-versed in shell scripts and unix in general. So I had no idea where to start. Thank you so much for pointing me in the right direction. Commented Jun 2, 2022 at 0:05

2 Answers 2


You should use precedence percentage symbol % with along with the job number while switching between the foreground and background jobs. Example: fg %1

See the zsh manual

  • That didn't make a difference. The issue persisted. I've identified the "z" plugin as the culprit though. Commented Jun 2, 2022 at 11:38

The offender was the z plugin. I commented it out in my ~/.zshrc from plugins = ( ... ) and it got fixed. I wasn't really using that plugin anyway so it's fine. Thank you Marc Wilson for the troubleshooting pointer.

You must log in to answer this question.

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