I follow this pattern of suspending the task and then letting it to continue too often with the Ctrl-Z bg sequence.
I was wondering is there any way to compress that to single keypress?
My shell is
The Ctrl+Z sequence is handled by the terminal, not by the shell. (Useful background: What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?)
Only a small, non-extensible set of functions can be bound to a key in a terminal. You can customize the keys bound to these functions but not add another function. These functions fall into three categories:
Some systems, including Linux, extend that list, but I've never seen one that included backgrounding. Note that it would take support both in the terminal driver in the kernel, and in the terminal emulator. So you have to make do with suspend, which sends the foreground job a SIGTSTP signal. This triggers a SIGCHLD in the parent process of the foreground job's leader, which is usually the shell. When the shell received SIGCHLD, it calls
You could program the shell to send a
What I do is to set the Ctrl+Z key sequence in zsh to background the current job (
So found the solution, not exactly what I want but darn close from here http://superuser.com/a/161922/35223
Are these commands that you wanted to run in the foreground initially, and then switch to the background? I don't know if there's a simpler way to do that. But if you'd like to run commands that will be in the background to begin with, you can just add an ampersand to the end of the line. e.g.,