8

With my current workflow, I frequently use CTRL-z to suspend Vim so I can enter a quick few commands before resuming editing my code with fg (actually, it's CTRL-z again, thanks to the handy ZSH tip on this blog post). The issue is, my terminal ends up being cluttered with job suspension messages which is distracting from the output I wish to see.

Unwanted output:

[1]  + continued  vim

zsh: suspended  vim

The following screenshot shows what this can end up looking like in a standard session: enter image description here

So my question; is there a way to stop CTRL-z and fg printing any output?

JamoBox
  • 183
  • 4
  • 2
    I don't think so. You probably should consider using `screen` or `tmux` to avoid the problem altogether. – Otheus Jan 02 '16 at 02:12
  • “I could not find a solution, so I developed one on my own” *[ahem](http://unix.stackexchange.com/questions/10825/remember-a-half-typed-command-while-i-check-something/10851#10851)* – Gilles 'SO- stop being evil' Jan 02 '16 at 03:14
  • 1
    Looking at the source, neither bash nor zsh seem to have a way to avoid these messages. – Gilles 'SO- stop being evil' Jan 02 '16 at 03:17
  • @Gilles That's unfortunate. Thanks anyway though, if you are sure then could you put this as an answer so I can mark it as solved? – JamoBox Jan 02 '16 at 09:47
  • 2
    why don't you run command from inside `vim` using `:! your_command`? – Jakuje Jan 02 '16 at 13:04
  • @Jakuje I do when it makes sense to, however if I need to run a couple a git or system commands consecutively then it's normally a lot easier to suspend the session. I guess I can always settle for a tmux split open in the same directory. – JamoBox Jan 02 '16 at 16:11
  • I usually have several terminals open... it lets me look at compilation errors and at the code at the same time. Other than that, what @otheus said. – Law29 Jan 02 '16 at 22:54

2 Answers2

2

I am not sure if messages for interactive sessions can be easily changed. But your problem can be solved as Jakuje suggests with a subshell from Vim. Instead of running your command, just :!zsh or :!bash and when you're done exit.

cxed
  • 31
  • 5
  • Of course you could map this in Vim to make it even easier than C-z and use C-d to exit the shell and return to Vim. – cxed Dec 04 '17 at 16:51
0

One way is to break the pipe. However, the progressing program cannot be called by fg anymore.

You can fist abandon the job to init by command disown -h JobID|PID after running bg JobID|PID. And then you can close the terminal.

The program won't stop. It will more like a daemon since then. However, it can't get anything from stdin and it's output to stdout and stderr will be neglect.

TJM
  • 534
  • 5
  • 12
  • Although this didn't quite achieve what I wanted it does technically answer the question, so I'll mark this as correct. – JamoBox Dec 09 '17 at 13:49