Seems to run stable for hours!
If you can't see your cursor after killing it, run
tput cnorm
Sometimes you may see a seq error if you run it multiple times with different resolutions in the same session. Easier to make a new session, or you can change it unset the variables used initially.
# Play a gif in the terminal indefinitely. Specify the file/url and the horizontal resolution
# Requires the amazing ImageMagick. `(brew|apt-get|yum) install imagemagick`
function playgif ()
{
f=$(convert $1 -resize $2 -coalesce txt:-|sed -E 's/ //g;s/#.+:([0-9]+).+/_\1/g;s/.+://;s/\(//;s/\)//;s/#.*//;s/255/254/g;s/([0-9]+,[0-9]+,[0-9]+),[0-9]+/\1/;s/_/ /'|tr '\n' 'z');
w=$(echo ${f::3}|sed -E 's/([0-9]+).*/\1/');
clear;
tput civis;
while true; do
for i in ${f[@]};
do
j=($(echo $i|tr 'z' '\n'|sed -E '/^[0-9]*$/d;s/(.+),(.+),(.+)/\1\/42.5*36+\2\/42.5*6+\3\/42.5+16/'|bc));
for r in $(seq 0 $w $((${#j[@]}-$w)));
do
p=($(for c in $(seq 0 $(($w-1)));do echo " ${j[$(($r+$c))]} ";done));
IFS='%';
k=$(echo ${p[@]}|sed -E 's/^/\\e[0m\\e[48;5;/;s/\ /m\ \ \\e[0m\\e[48;5;/g;s/$/m\ \ \\e[0m/');
echo -e $k;
unset IFS;
done;
tput cup 0 0;
done;
done
}
Are there any specific settings required for the terminal for this to work? I tried iTerm and Terminal on OSX but all I get are the raw character codes, instead of colored blocks.