Skip to content

Instantly share code, notes, and snippets.

@shammellee
Last active July 20, 2017 14:54
Show Gist options
  • Save shammellee/4a79fbe882a56d047e59fdd36986438d to your computer and use it in GitHub Desktop.
Save shammellee/4a79fbe882a56d047e59fdd36986438d to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
function times()
{
_in_string="$1"
_out_string=""
_count=$2
for (( i=0; i < $_count; i++ ))
do
_out_string+="$_in_string"
done
echo "$_out_string"
}
_hundred_spaces="$(times " " 100)"
for i in {0..100}
do
if [[ $i -lt 100 ]]
then
color=33
eol="\r"
else
color=32
eol="\n"
fi
printf "\e[${color}m%s%.*s\e[m [%3d%%]${eol}" "$(times "█" $i)" $((100 - i)) "$_hundred_spaces" $i
sleep .05
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment