MacOS – Suspended (tty output) when launching editors like vim, vi, emacs, or nano

command lineitermmacosterminal

I've been using Oh-My-ZSH for a few weeks now and it's been a great experience. Just today, though, terminal started acting strangely. When I try to run an interactive terminal editor like vim, vi, emacs, or nano, the process is suspended:

$ vim
[1] + 3515 suspended (tty output) vim

Of course, I can open it back up with fg, but this is incredibly annoying.

I wasn't experiencing this issue yesterday. Since then I haven't restarted my computer, iTerm, or even closed terminal tabs (from which I successfully ran vim yesterday without it being suspended).

Additionally, I temporarily reverted my shell back to bash. It now exhibits this same suspending behavior as ZSH. This problem occurs both in iTerm2 and the native osx Terminal.app for both bash and zsh, so presumably this isn't an issue with my shell.

I've been through every solution on the first 10 pages of Google for this issue, but haven't found one that resolves it. I'm approaching the point where I no longer understand why this is happening and therefore can't debug it.

Is there any way that I can get interactive processes like vim to stop suspending themselves when I try to run them from terminal?

Edit: Since this post I've tried new iTerm & Terminal tabs, relaunched iTerm & Terminal, and restarted my computer. All of these have failed to resolve this issue.

Best Answer

Terminal is suspending the editor because some other process is writing to the terminal.

Running stty -tostop should fix it.

If that does not fix the problem, take a look at this GitHub issue from the oh-my-zsh repository.

the issue results from a setting :set shellcmdflag=-ic. After I comment[ed] that out from .vimrc all relevant problems were solved.

Other users have evidently run into this problem. This seems to be the correct solution.