0

I run Vim in zsh. And I often need to check something else in the terminal. So I just quickly suspend the editor by pressing Ctrl+Z and then type fg to get back.

Today, by chance, I noticed that the suspended job can be resumed by typing just r. I guess it stands for resume. However, this command works only immediately after suspending the job. If I run any shell command I have to use fg.

Is this feature documented somewhere? Or is it a hidden gem? I couldn't find.

(ZSH 5.1.1 on Fedora Linux.)

1

If you look at the help for it (run-help r), you’ll see it listed at the bottom of the help for fc. It is quoted as:

Same as fc -e -

But you won’t find the -e option directly described there. One can expect that it refers to the editor. A later reference to ename states:

If ename is `-', no editor is invoked. When editing is complete, the edited command is executed.

Since no editor is invoked, it simply repeats the last command. So I will take r to mean “Repeat”.

I don’t think your backgrounded job is actually resuming. When I tried your use case, an identical job was created.

I was flummoxed at one point as to why I couldn’t invoke an r command I knew had installed via the littler package. It was masked by the unintuitive Zsh command that I was unaware of. I find any single-character command (e.g., r) to be prime real estate, and I don’t use Zsh’s version of it. So I kill it off in my ~/.zshrc with:

disable r
  • Thank you. Obviously 'r' repeated my previous 'fg' invocation. Mystery resolved. – Jan Včelák Jan 15 '16 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.