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 && command2orcommand1; 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?