aboutsummaryrefslogtreecommitdiffstats
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/init/helpers23
1 files changed, 14 insertions, 9 deletions
diff --git a/.config/init/helpers b/.config/init/helpers
index 1f2ed89..81859ec 100644
--- a/.config/init/helpers
+++ b/.config/init/helpers
@@ -55,21 +55,22 @@ progress-bar() {
local i=0
local starttime=$EPOCHREALTIME
local lasttime=$starttime
- local thistime=$starttime
+ local thistime=$starttime
local elapsed=0
while true; do
+ local now=$EPOCHREALTIME
[[ $i -eq $count ]] && break
local width=$COLUMNS
- local statwidth=$(( ($#count * 2) + 20))
+ local statwidth=$(( ($#count * 2) + 35))
local progwidth=$(($width - $statwidth - 3))
[[ $progwidth -gt 30 || $progwidth -le 1 ]] && progwidth=30
- if [[ $i -eq 0 || $elapsed -eq 0 ]]; then
+ if [[ $i -eq 0 ]]; then
eta='??:??:??'
else
- local left=$(( ($count - $i) * ($elapsed / $i) - ($EPOCHREALTIME - $lasttime) ))
+ local left=$(( ($count - $i) * ($elapsed / $i) - ($now - $lasttime) ))
if [[ $left -ge 86400 ]]; then
eta=' days...'
elif [[ $left -le 0 ]]; then
@@ -79,21 +80,25 @@ progress-bar() {
fi
fi
+ local rt=$(($now - $starttime))
+ [[ $rt -ge 86400 ]] && rt=' days...' \
+ || rt=$(strftime '%H:%M:%S' ${$(( floor($rt + 802800) )):s/\./})
+
local fpart=""
local epart=""
local progress=$(($i * $progwidth / $count))
repeat $progress fpart="$fpart#"
- repeat $(($progwidth-$progress)) epart="$epart-"
+ repeat $(($progwidth - $progress)) epart="$epart-"
printf \
- "\e[G\e[K$colour%s...\e[0m\n[%${#count}s/$count] [eta: $eta] [$fpart$epart]\e[J" \
+ "\e[G\e[K$colour%s...\e[0m\n[%${#count}s/$count] [rt: $rt] [eta: $eta] [$fpart$epart]\e[J" \
$message \
$i \
read -t 0.2 \
- && thistime=$EPOCHREALTIME \
- && elapsed=$(($elapsed + $thistime - $lasttime)) \
- && lasttime=$EPOCHREALTIME \
+ && thistime=$EPOCHREALTIME \
+ && elapsed=$(($elapsed - $lasttime + $thistime)) \
+ && lasttime=$thistime \
&& i=$(($i + 1))
printf "\e[F"