1
Instead of waiting for slow commands to finish, I'd like to run them in the background. However, when they finish running and print to stdout, I get (where █
represents my cursor) this:
$ slowcmd &
$ cmd_output
█
- There is no prompt string before my cursor.
- and
slowcmd
can be any slow command (For the stuff I've tried, I just saidalias slowcmd='sleep 1 && echo cmd_output'
)
Whereas I'd like something like this:
$ slowcmd && redrawPromptString &
$ cmd_output
$ █
Where after the command's output, a new Prompt String is printed out for me.
What I can do to make redrawPromptString
do what I want? I've tried clear
, kill $$
to send a ^C
to the terminal, and finally printf "^C"
(of course that didn't work). I'm running bash. (GNU bash, version 3.2.57).
My PS1 is colored and uses backslash-escaped special characters - like
\@
for the time. (But yeah, that is a suitable workaround for any sane person who doesn't care about getting exactly what he wants...) Ahaha but for real, I hate not being able to do what I want out of ignorance! Out of lack of support in the program I'm using? Sure (for now). But out of ignorance? I don't like that. I will google and stack overflow and ask everyone who I think might now until the cows come home. – Ari Sweedler – 2018-09-04T03:02:12.5771Why not to use separate, dedicated for
slowcmd
terminal? Use terminal multiplexer such astmux
, create new window and run thereslowcmd
while you can switch back to working terminal and continue your work. – Alex – 2018-09-04T03:05:50.030@Alex I can also open up a new tab in iTerm. I'm not asking how to gain control of my terminal while doing commands that take some time, because I already know how to do that. And if I asked a question like that, I'd get rightfully downvoted. No, I'm not looking for a heuristic, I'm looking for a solution – Ari Sweedler – 2018-09-04T05:28:04.187