7

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.

2 Answers 2

4

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.

4
  • 1
    Thanks for responding so quickly! Unfortunately, I've tried running stty -tostop, but subsequent attempts to run vim (or nano, vi, emacs, etc.) are still suspended. ps a reveals that the only things running are login -fp and -zsh (and as I understand it login launches -zsh). Is it possible that something else is running that I can't see which is writing to the terminal? Aug 10, 2015 at 4:34
  • In your question, you said that you haven't restarted your computer, nor closed any Terminal windows/tabs. If this is still the case, try both of those. @PhpMyCoder
    – Zach Gates
    Aug 10, 2015 at 4:37
  • From the time running vim last worked until today when it started suspending, I hadn't restarted my computer/iTerm or closed any terminal tabs. I have now done all 3 and yet vim still continues to be suspended. Sorry for the confusion, I'll reword the question. Aug 10, 2015 at 4:40
  • I've modified my answer. @PhpMyCoder
    – Zach Gates
    Aug 10, 2015 at 10:59
4

Turns out I misread the first result on Google. I incorrectly assumed that they were referring to the terminal shell (and when they said shell later on I assumed they meant $SHELL, although I should've been tipped off by the fact that shell wasn't capitalized). Instead they were referring to the vim shell setting, which incorrectly had the -i flag instead of the -l flag.

So in case anyone else has this issue, go into your .vimrc and change make sure the line that sets your shell looks like this:

set shell=/bin/zsh\ -l

(Replacing /bin/zsh with the value of which zsh if it's installed in a non-standard location, of course).

Reference commit: https://github.com/devx/vimified/commit/772e130c9c359ac87927a963e00a9cc6597cd170

You must log in to answer this question.

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