From 24ac0aaaedd77dd99077701499e9152045b3efe8 Mon Sep 17 00:00:00 2001 From: vados-dev Date: Fri, 13 Mar 2026 07:40:03 +0300 Subject: [PATCH] Autocommit in repo: , generated by owner: mikro_bak, in 07:40:02 13.03.2026. --- bin/bash-progress-indicator/.st.txt | 0 bin/bash-progress-indicator/bash-cli-spinners | 1 + bin/bash-progress-indicator/moreexamples.sh | 330 ++++++++++++++++++ bin/bash-progress-indicator/progress_bar.sh | 1 + bin/ros-diff.sh | 17 +- 5 files changed, 345 insertions(+), 4 deletions(-) create mode 100644 bin/bash-progress-indicator/.st.txt create mode 160000 bin/bash-progress-indicator/bash-cli-spinners create mode 100755 bin/bash-progress-indicator/moreexamples.sh create mode 160000 bin/bash-progress-indicator/progress_bar.sh diff --git a/bin/bash-progress-indicator/.st.txt b/bin/bash-progress-indicator/.st.txt new file mode 100644 index 0000000..e69de29 diff --git a/bin/bash-progress-indicator/bash-cli-spinners b/bin/bash-progress-indicator/bash-cli-spinners new file mode 160000 index 0000000..79434c5 --- /dev/null +++ b/bin/bash-progress-indicator/bash-cli-spinners @@ -0,0 +1 @@ +Subproject commit 79434c5bc1f726a1b2d3816bb11b9e9ffb21163d diff --git a/bin/bash-progress-indicator/moreexamples.sh b/bin/bash-progress-indicator/moreexamples.sh new file mode 100755 index 0000000..65de180 --- /dev/null +++ b/bin/bash-progress-indicator/moreexamples.sh @@ -0,0 +1,330 @@ +#!/bin/bash -e +# shellcheck disable=SC1091 + +printf '\n\tInternet speed test: ' + + +spin[0]="⣔" +spin[1]="⣤" +spin[2]="⣥" +spin[3]="⣦" +spin[4]="⣮" +spin[5]="⣶" + +sleep 5 & ## & : continue running script +pid=$! ## PID of last command + +# If this script is killed, kill 'speedtest': +trap "kill $pid 2> /dev/null" EXIT + +# While 'speedtest' is running: +while kill -0 $pid 2> /dev/null; do +for i in "${spin[@]}" +do +# echo -ne "$i" + printf "%c" "${i}" + sleep 0.1 + printf "\b\b\\n" +done +#echo -ne "✅" +done + +# Disable the trap on a normal exit: +trap - EXIT + +printf "\n\t " +grep Download: .st.txt +printf "\t " +grep Upload: .st.txt +echo '' +rm -f st.txt +exit 0 + +progreSh() { + LR='\033[1;31m' + LG='\033[1;32m' + LY='\033[1;33m' + LC='\033[1;36m' + LW='\033[1;37m' + NC='\033[0m' + if [ "${1}" = "0" ]; then TME=$(date +"%s"); fi + SEC=`printf "%04d\n" $(($(date +"%s")-${TME}))`; SEC="$SEC sec" + PRC=`printf "%.0f" ${1}` + SHW=`printf "%3d\n" ${PRC}` + LNE=`printf "%.0f" $((${PRC}/2))` + LRR=`printf "%.0f" $((${PRC}/2-12))`; if [ ${LRR} -le 0 ]; then LRR=0; fi; + LYY=`printf "%.0f" $((${PRC}/2-24))`; if [ ${LYY} -le 0 ]; then LYY=0; fi; + LCC=`printf "%.0f" $((${PRC}/2-36))`; if [ ${LCC} -le 0 ]; then LCC=0; fi; + LGG=`printf "%.0f" $((${PRC}/2-48))`; if [ ${LGG} -le 0 ]; then LGG=0; fi; + LRR_="" + LYY_="" + LCC_="" + LGG_="" + for ((i=1;i<=13;i++)) + do + DOTS=""; for ((ii=${i};ii<13;ii++)); do DOTS="${DOTS}."; done + if [ ${i} -le ${LNE} ]; then LRR_="${LRR_}#"; else LRR_="${LRR_}."; fi + echo -ne " ${LW}${SEC} ${LR}${LRR_}${DOTS}${LY}............${LC}............${LG}............ ${SHW}%${NC}\r" + if [ ${LNE} -ge 1 ]; then sleep .05; fi + done + for ((i=14;i<=25;i++)) + do + DOTS=""; for ((ii=${i};ii<25;ii++)); do DOTS="${DOTS}."; done + if [ ${i} -le ${LNE} ]; then LYY_="${LYY_}#"; else LYY_="${LYY_}."; fi + echo -ne " ${LW}${SEC} ${LR}${LRR_}${LY}${LYY_}${DOTS}${LC}............${LG}............ ${SHW}%${NC}\r" + if [ ${LNE} -ge 14 ]; then sleep .05; fi + done + for ((i=26;i<=37;i++)) + do + DOTS=""; for ((ii=${i};ii<37;ii++)); do DOTS="${DOTS}."; done + if [ ${i} -le ${LNE} ]; then LCC_="${LCC_}#"; else LCC_="${LCC_}."; fi + echo -ne " ${LW}${SEC} ${LR}${LRR_}${LY}${LYY_}${LC}${LCC_}${DOTS}${LG}............ ${SHW}%${NC}\r" + if [ ${LNE} -ge 26 ]; then sleep .05; fi + done + for ((i=38;i<=49;i++)) + do + DOTS=""; for ((ii=${i};ii<49;ii++)); do DOTS="${DOTS}."; done + if [ ${i} -le ${LNE} ]; then LGG_="${LGG_}#"; else LGG_="${LGG_}."; fi + echo -ne " ${LW}${SEC} ${LR}${LRR_}${LY}${LYY_}${LC}${LCC_}${LG}${LGG_}${DOTS} ${SHW}%${NC}\r" + if [ ${LNE} -ge 38 ]; then sleep .05; fi + done +} + +printf "\n\n\n\n\n\n\n\n\n\n" +progreSh 0 +progreSh 10 +progreSh 20 +progreSh 30 +progreSh 40 +progreSh 50 +progreSh 60 +progreSh 70 +progreSh 80 +progreSh 90 +progreSh 100 +printf "\n\n\n\n\n\n\n\n\n\n" + +exit 0 + +phasess=( + 'Ready to perform operations...' + 'Performing some operations...' + 'Please wait ...' + 'almost there...' +) + +for i in $(seq 1 100); do + sleep 0.04 + + if [ $i -eq 100 ]; then + echo -e "XXX\n100\nDone!\nXXX" + elif [ $(($i % 25)) -eq 0 ]; then + let "phase = $i / 25" + echo -e "XXX\n$i\n${phasess[phase]}\nXXX" + else + echo $i + fi +done | whiptail --title 'This is a GUI progress bar' --gauge "${phasess[0]}" 6 60 0 + +exit 0 + +function pro { + bar='' + for (( x=50; x <= 100; x++ )); do + sleep 0.05 + bar="${bar}=" + echo -ne "$bar ${x}%\r" + done + echo -e "\n" +} + +function proo { + barr='' + for (( y=50; y <= 100; y++ )); do + sleep 0.05 + barr="${barr} " + + echo -ne "\r" + echo -ne "\e[43m$barr\e[0m" + + local left="$(( 100 - $y ))" + printf " %${left}s" + echo -n "${y}%" + done + echo -e "\n" +} + +pro + +echo "" +echo "This was a progress bar with percentage" +echo "" + +proo +echo "This was a progress bar with color" + +exit 0 + +bar='####################' +echo "" +for i in {1..20}; do + echo -ne "\rDownloading ${bar:0:$i}" + sleep .1 +done +echo "" +echo "" +echo "This is a simple progress bar" + +exit 0 + +# your real command here, instead of sleep +sleep 7 & +PID=$! +i=1 +sp="/-\|" +echo -n ' ' +while [ -d /proc/$PID ] +do + printf "\b${sp:i++%${#sp}:1}" +done +exit 0 + + + + +progress_bar() +{ + local DURATION=$1 + local INT=0.25 # refresh interval + + local TIME=0 + local CURLEN=0 + local SECS=0 + local FRACTION=0 + + local FB=2588 # full block + + trap "echo -e $(tput cnorm); trap - SIGINT; return" SIGINT + + echo -ne "$(tput civis)\r$(tput el)│" # clean line + + local START=$( date +%s%N ) + + while [ $SECS -lt $DURATION ]; do + local COLS=$( tput cols ) + + # main bar + local L=$( bc -l <<< "( ( $COLS - 5 ) * $TIME ) / ($DURATION-$INT)" | awk '{ printf "%f", $0 }' ) + local N=$( bc -l <<< $L | awk '{ printf "%d", $0 }' ) + + [ $FRACTION -ne 0 ] && echo -ne "$( tput cub 1 )" # erase partial block + + if [ $N -gt $CURLEN ]; then + for i in $( seq 1 $(( N - CURLEN )) ); do + echo -ne \\u$FB + done + CURLEN=$N + fi + + # partial block adjustment + FRACTION=$( bc -l <<< "( $L - $N ) * 8" | awk '{ printf "%.0f", $0 }' ) + + if [ $FRACTION -ne 0 ]; then + local PB=$( printf %x $(( 0x258F - FRACTION + 1 )) ) + echo -ne \\u$PB + fi + + # percentage progress + local PROGRESS=$( bc -l <<< "( 100 * $TIME ) / ($DURATION-$INT)" | awk '{ printf "%.0f", $0 }' ) + echo -ne "$( tput sc )" # save pos + echo -ne "\r$( tput cuf $(( COLS - 6 )) )" # move cur + echo -ne "│ $PROGRESS%" + echo -ne "$( tput rc )" # restore pos + + TIME=$( bc -l <<< "$TIME + $INT" | awk '{ printf "%f", $0 }' ) + SECS=$( bc -l <<< $TIME | awk '{ printf "%d", $0 }' ) + + # take into account loop execution time + local END=$( date +%s%N ) + local DELTA=$( bc -l <<< "$INT - ( $END - $START )/1000000000" \ + | awk '{ if ( $0 > 0 ) printf "%f", $0; else print "0" }' ) + sleep $DELTA + START=$( date +%s%N ) + done + + echo $(tput cnorm) + trap - SIGINT +} +exit 0 + +progressBarWidth=20 + +# Function to draw progress bar +progressBar () { + + # Calculate number of fill/empty slots in the bar + progress=$(echo "$progressBarWidth/$taskCount*$tasksDone" | bc -l) + fill=$(printf "%.0f\n" $progress) + if [ $fill -gt $progressBarWidth ]; then + fill=$progressBarWidth + fi + empty=$(($fill-$progressBarWidth)) + + # Percentage Calculation + percent=$(echo "100/$taskCount*$tasksDone" | bc -l) + percent=$(printf "%0.2f\n" $percent) + if [ $(echo "$percent>100" | bc) -gt 0 ]; then + percent="100.00" + fi + + # Output to screen + printf "\r[" + printf "%${fill}s" '' | tr ' ' ▉ + printf "%${empty}s" '' | tr ' ' ░ + printf "] $percent%% - $text " +} + + + +## Collect task count +taskCount=33 +tasksDone=0 +tput civis -- +while [ $tasksDone -le $taskCount ]; do + + # Do your task + (( tasksDone += 1 )) + + # Add some friendly output + text=$(echo "somefile-$tasksDone.dat") + + # Draw the progress bar + progressBar $taskCount $taskDone $text + + sleep 0.5 + tput cnorm -- +done + +echo +exit 0 + + + +sleep 20 & PID=$! #simulate a long process + +echo "THIS MAY TAKE A WHILE, PLEASE BE PATIENT WHILE ______ IS RUNNING..." +printf "[" +# While process is running... +while kill -0 $PID 2> /dev/null; do + printf "▓" + sleep 1 +done +printf "] done!\\n" + + +while true; do +for X in '-' '/' '|' '\'; do +echo -en "\b$X"; +sleep 0.1; +done; +done diff --git a/bin/bash-progress-indicator/progress_bar.sh b/bin/bash-progress-indicator/progress_bar.sh new file mode 160000 index 0000000..eb0b680 --- /dev/null +++ b/bin/bash-progress-indicator/progress_bar.sh @@ -0,0 +1 @@ +Subproject commit eb0b680d10017e59097c2d11cb4b16a7fbe1e18e diff --git a/bin/ros-diff.sh b/bin/ros-diff.sh index 20950c8..5740008 100755 --- a/bin/ros-diff.sh +++ b/bin/ros-diff.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # shellcheck disable=SC1091 #set +e -u #o pipefail @@ -90,6 +90,7 @@ if [ -t 1 ] && $DEBUG_OUT; then bold=$(tput bold) red=$(tput setaf 1) green=$(tput setaf 2) + bg_green=$(tput setab 2) yellow=$(tput setaf 3) blue=$(tput setaf 4) magenta=$(tput setaf 5) @@ -120,7 +121,7 @@ spinstr() { local -r pid="${1}" local delay=0.1 - local spinsym='\|/-' + local spinsym='\\||//-' local temp tput civis -- while ps a | awk '{print $1}' | grep -q "${pid}"; do @@ -128,12 +129,20 @@ spinstr() printf "[ %c ]" "${spinsym}" spinsym=${temp}${spinsym%"${temp}"} sleep "${delay}" - printf "\b\b\b\b\b\b" + printf "\b\b\b\b\b" done - echo -ne "\\r[ ✔ ]\\n" + printf "\b\b\b\b[ ✔ ]\\n" +# echo -ne "\\r[✅]\\n" tput cnorm -- } +# Source - https://stackoverflow.com/a/34392382 +# Posted by fipsbox, modified by community. See post 'Timeline' for change history +# Retrieved 2026-03-12, License - CC BY-SA 4.0 + +sleep 10 & +spinstr $! +exit 0 save_log() { local log="${DEFAULT_LOG}" if [ -n "${LogFile}" ]; then -- 2.52.0