process bar
reference:
with dot .
reference:
while true; do
(( i++ == 0 )) && printf $(c sY)%-6s$(c) 'waiting ...' || printf $(c sY)%s$(c) '.'
sleep 1
done
with ▉ ▎ ▌ ▊
another:
# main function designed for quickly copying to another program
progressBar() {
Bar="" # Progress Bar / Volume level
Len=25 # Length of Progress Bar / Volume level
Div=4 # Divisor into Volume for # of blocks
Fill="▒" # Fill up to $Len
Arr=( "▉" "▎" "▌" "▊" ) # UTF-8 left blocks: 7/8, 1/4, 1/2, 3/4
FullBlock=$((${1} / Div)) # Number of full blocks
PartBlock=$((${1} % Div)) # Size of partial block (array index)
while [[ $FullBlock -gt 0 ]]; do
Bar="$Bar${Arr[0]}" # Add 1 full block into Progress Bar
(( FullBlock-- )) # Decrement full blocks counter
done
# if remainder zero no partial block, else append character from array
if [[ $PartBlock -gt 0 ]]; then Bar="$Bar${Arr[$PartBlock]}"; fi
# Pad Progress Bar with fill character
while [[ "${#Bar}" -lt "$Len" ]]; do Bar="$Bar$Fill"; done
echo progress : "$1 $Bar"
exit 0 # Remove this line when copying into program
} # progressBar
Main () {
tput civis # Turn off cursor
for ((i=0; i<=100; i++)); do
CurrLevel=$(progressBar "$i") # Generate progress bar 0 to 100
echo -ne "$CurrLevel"\\r # Reprint overtop same line
sleep .04
done
echo -e \\n # Advance line to keep last progress
echo "$0 Done"
tput cnorm # Turn cursor back on
} # main
Main "$@"
with [###----]
another solution:
BAR='##############################'
FILL='------------------------------'
totalLines=100
barLen=30
count=0
while [ ${count} -lt ${totalLines} ]; do
# update progress bar
count=$(( ${count}+ 1 ))
percent=$(( (${count} * 100 / ${totalLines} * 100)/ 100 ))
i=$(( ${percent} * ${barLen} / 100 ))
echo -ne "\r[${BAR:0:$i}${FILL:$i:barLen}] ${count}/${totalLines} (${percent}%)"
sleep .1
done
with |\|/
while :; do
for s in / - \\ \|
do printf "\r$s"
sleep .1
done
done
Integralist/python progress bar.py
save & restore screen
reference
tput
- clear
$ tput smcup
- restore
$ tput rmcup
echo
- save
$ echo -e '\033[?47h'
- restore
$ echo -e '\033[?47l'
terminfo escape sequences
$ infocmp
...
colors#256, cols#80, it#8, lines#24, pairs#32767,
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M,
...
tput
reset terminal
[!NOTE]
$ reset
# or
$ stty sane
clear screen
$ tput home
# or
$ tput cup %py %px
# or
$ tput cup %py %px >/dev/null
show term
$ tput color
show terminal width
$ tput cols
customized colorful output
references:
$ export GREP_COLORS="sl=0;33;49:ms=1;34;49"
$ find /etc/ -type f | head | grep --color=always '^\|[^/]*$'
Operation not permitted
[!NOTE|label:references:]
$ sudo lsattr /etc/resolv.conf
----i-------------- /etc/resolv.conf
$ sudo rm -rf /etc/resolv.conf
rm: cannot remove '/etc/resolv.conf': Operation not permitted
# solution
$ sudo chattr -i /etc/resolv.conf
$ sudo lsattr /etc/resolv.conf
------------------- /etc/resolv.conf
$ sudo mv /etc/resolv.conf{,.bak}
# revert back
$ sudo chattr +i /etc/resolv.conf
$ sudo lsattr /etc/resolv.conf
----i-------------- /etc/resolv.conf