Created
May 19, 2017 15:54
-
-
Save iamahuman/c09ad420ac13c3b5a06e7599fdd6e36d to your computer and use it in GitHub Desktop.
(2015) A spinner which you can put on your terminal and waste some time staring at it doing nothing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
spin=("|" "/" "-" "\\");((i=j=0,n=$(tput cols)-10)) | |
echo -ne "\r"; tput sc | |
trap "echo;exit 0" SIGTERM SIGINT SIGHUP | |
while true;do tput rc;s="\r${spin[$i]} ";k=0;while [[ $k -lt $((j < 0 ? -j - 1 : j)) ]]; do | |
if [[ $j -ge 0 ]] | |
then s=$s"=";else s=$s" ";fi;((++k));done;((i++)) | |
if [[ $j -lt 0 ]];then ((--j));else ((++j)); fi; if [ $i -ge ${#spin[@]} ]; then i=0;fi | |
if [ $j -ge $n ]; then j=-1;else if [ $((-j)) -gt $n ]; then j=0; fi; fi; | |
printf "$s";sleep 0.05;read -t 0.0001 -n 1 -s ans;if [ "$ans" == "q" ];then break;fi;done;echo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment