I have a command that I run every time a new terminal is opened or a new login is made.
This program produces output (colored) which should be positioned before the command prompt. It can take a few seconds to run which will prevent me from using the terminal until then (unless ran in background).
Given than zsh has some advanced ways of redrawing the terminal without clobbering existing text, I would like to know how can I run this command in a way that I don't have to wait for it to finish before I can use the terminal but that once it finishes it prints the output as if it was not backgrounded in the first place.
In practice I would like something that could do:
Command output:
... (running on background)
me@computer: somecommand
me@computer: someothercommand
and once the command finishes I would get:
Command output:
* Output foo
* Multiple lines bar
* and some yada
me@computer: somecommand
me@computer: someothercommand
I tried putting the process in background at start but then it does not display the output cleanly. I get something like:
Command output:
[2] 32207
me@computer: somecommand
me@computer: someother * Output foo
* Multiple lines bar
* and some yada
[2] + done command
me@computer: someothercommand
So, is this possible? If not with zsh is there any solution out there that could do it?
Any pointers or information is welcome.
zpty
: have the command run in a terminal created by zsh, with its output relayed to the real terminal under zsh's control.zpty
? I am aware that you can't have two programs writing to the same terminal without some kind of competition over the cursor. My question comes from the fact that zsh already rewrites the prompt in some configurations. Obviously this program would have to write to some temporary in-memory buffer that would then be "printed" to the specific location once the command finishes. All of the latter under control of zsh.screen
with a startup script that splits the screen and runs the long runner in the upper part and the normal command line in the lower part.