I once saw a console app that visualized a progress of multiple downloads with multiple progressbars, each on its own line. I was curious how to do that, but I found only partial solutions. Here they are:
One progressbar is easy
It is easy to clear one line with "carriage return" and thus visualize one progress bar, as it is discussed e.g. in this question. Easy to use, also a lot of helper libraries exist.
"use ncurses"
Everybody says "use ncurses". But as far as I know every ncurses program must start with initscr()
call, that really clears the whole screen. Your prompt is gone, your terminal history is gone. This is not what I want.
Use terminfo from ncurses
Use sc
, ed
and rc
capabilities from terminfo
, as ilustrates this Bash script (the script is taken from this question):
tput sc; while [ true ]; do tput ed; echo -e "$SECONDS\n$SECONDS\n$SECONDS"; sleep 1; tput rc; done
This works, but only in xterm
. My urxvt
term ignores it, same as e.g. terminator
.
So what are other options?