Skip to main content

Today I Learned: zsh job control option

· 2 min read

I'm a fairly heavy user of job control in the shell. By which I mean one thing I do constantly is press control-z to suspend what I'm doing - reading a man page, editing a file, etc. - in order to run another command, and then use fg to resume.

Today I tried to do that and discovered that control-z didn't work. It did nothing. Or, rather, it just sent a literal control-z. Things sometimes get into a weird state, so I opened a new shell and tried again. Nope, nothing. Then I tried it in bash and it worked fine. I went back to zsh and discovered that running fg would also return the error:

fg: no job control in this shell.

After poking around the manual for a while, I found the option to tell zsh not to read any of the startup files: zsh -f. When I used that, I had job control again. So it was pretty obviously something to do with all of the fancy stuff I recently set up.

A little searching led me to a bug report from 2016 that had the answer. zplug disables job control while it's doing some tasks (apparently to avoid printing messages about them). It's supposed to reenable it afterward, but sometimes a lock file gets left behind that permanently prevents this from happening. The solution is quite simple: rm $_zplug_lock[job]. If you can find it.

I'm also now aware that job control can be turned on and off with the monitor option, so I guess this was a valuable learning experience.