Suppose you run a command which takes some time to return and want to execute a different command after it has been executed but you didn't plan this in advance.
I know that there is the option to press Ctrl + Z and then submit fg && otherCommand
. However, this has two major flaws:
- It doesn't work if the first command is a composition of different commands (
command1 && command2
orcommand1; command2
) because then the subsequent commands of the first submitted line aren't executed. - Execution of the first command is stopped while you enter the next command. With those nasty 30 second commands, the time you spend entering the next command makes up a good portion of the remaining execution time, if not all of it.
I also know that you can just type in the next command while one command is being executed and then hit Enter to sumbit it. However, this also has two major flaws:
- It doesn't work if the command you execute first reads from
stdin
. - If the command you execute first produces output, you can't see what you entered.
Is there a quick way to queue up more commands while one command is being executed, possibly involving using a special terminal emulator or several terminals?
stdin
. These two requirements seem to contradict each other: you do both "typing the second commands" and "feeding the first command" with yourstdin
simultaneously? – Franklin Yu Apr 30 '17 at 16:51stdin
), or non-interactive (so it doesn't get in the way when you instruct the shell about the second command). – Franklin Yu Apr 30 '17 at 17:03screen
) which introduces a ctrl. seq. that does that. Maybe there is a command which misuses job control to do this (launches a new process to do the actual work and then pipes that process's output through put the new process isn't affected byctrl + Z
). My point is: There are lots of options. Probably a lot more than I can think about while writing a comment. – UTF-8 Apr 30 '17 at 17:39stdin
" you are actually fine if the first command can't read certain byte like^Z
(which is not the case if, for example, the first command is a shell). – Franklin Yu May 01 '17 at 04:48