for i in 10 20 30; do echo $i; sleep 1; done | dialog --title "My Gauge" --gauge "Hi, this is a gauge widget" 20 70
works fine, so @Shadur is right and there is buffering at play.
Adding the sed
stripper into the mix shows it is the culprit (only shows 0 and 30):
for i in 10 20 30; do echo $i; sleep 1; done | sed 's/\([0-9]*\).*/\1/' | dialog --title "My Gauge" --gauge "Hi, this is a gauge widget" 20 70
Now that the problem is known, you have multiple options. The cleanest would be to round/cut the percentage in awk
with either math or string manipulation, but since you have GNU sed
, just adding -u
or --unbuffered
should do the trick.
However for completeness' sake, a simple test case shows awk
also does buffering:
for i in 10 20 30; do echo $i; sleep 1; done | awk '{print $0}' | sed -u 's/\([0-9]*\).*/\1/' | dialog --title "My Gauge" --gauge "Hi, this is a gauge widget" 20 70
But you already handle that with fflush
, so I don't expect problems.
Best Answer
You may pre-populate the directory stack in your
~/.bashrc
file if you wish:or, if you want to put the directories in an array and use them from there instead:
With
-n
,pushd
won't actually change the working directory, but instead just add the given directory to the stack.If you wish, you can store the value of the
DIRSTACK
array (upper-case variable name here), which is the current directory stack, into a file from~/.bash_logout
, and then read that file in~/.bashrc
rather than using a predefined array.In
~/.bash_logout
:In
~/.bashrc
:I don't know how well this would work in a situation where you use multiple terminals. The
.dirstack
file would be overwritten every time a terminal exited, if it ran abash
as a login shell.