1 minute read

foreground a stopped job in zsh:

I always hit ^z when I’m trying to hit ^x in vim. This stops the current process and sends you back to the shell, a startling but potentially useful–when done intentionally– thing to do. If you’re a recovering Microsoft user you’re used to nothing being saved ever, where as vim is always writing to a swap file so it’s quite difficult to accidentally nuke what you were working on in vim. You can close your terminal and the buffer will still be there in the swap file, you can shut off your computer and the same thing will happen. Now, how to get that process (your editor) back after you purposefully… or not … hit ^z.

jobs 

will tell you the name of the process. It’s also written to the terminal when you hit ^z, so if you did this by accident it’s right there. For example, say I’m editing my syllabus in nvim and I hit ^z now bam I’m back in the terminal and I see:

[1]  + 30607 suspended  nvim acctg3210Syl.md

I can get it back with fg (which brings jobs back to the foreground).

fg %1

1 is referring to [1] the job id. I know there are better ways to jump around projects inside of vim, but I am really starting to get used to this as a way to edit functions that I’ve defined outside of the file that I’m working in. This is particularly useful in python where the project path helpfully includes the folder of the file you are running so it makes sense to have everything sitting nearby.