Skip to content

Instantly share code, notes, and snippets.

@lubosz
Created April 14, 2015 19:11
Show Gist options
  • Save lubosz/abfe18a4a2f0d6fd40ba to your computer and use it in GitHub Desktop.
Save lubosz/abfe18a4a2f0d6fd40ba to your computer and use it in GitHub Desktop.
display a weather gif in terminal
#!/bin/sh
DOWNLOAD_DIR=~/Downloads/weather
REGION=txgulf
# make download dir if not available
if [ ! -d "$DOWNLOAD_DIR" ]; then
mkdir -p $DOWNLOAD_DIR
fi
# set loop counter
COUNTER=0
# remove old files
rm -rf $DOWNLOAD_DIR/*.gif
rm -rf $DOWNLOAD_DIR/*.txt
rm -rf $DOWNLOAD_DIR/*.png
# replace URL with your region
wget -P $DOWNLOAD_DIR "http://archive.wfaa.com/weather/images/core/animated-loops/comp/880x495/${REGION}_anim.gif"
#rename file to map.gif
mv $DOWNLOAD_DIR/*.gif $DOWNLOAD_DIR/map.gif
# expand gif and convert to png
convert -coalesce $DOWNLOAD_DIR/map.gif $DOWNLOAD_DIR/map.png
# display extracted images as ASCII
for i in `ls $DOWNLOAD_DIR/map-*`; do
img2txt -W 75 -H 30 $i > $i.txt
done
while [ $COUNTER -lt 5 ] ; do
for i in `ls $DOWNLOAD_DIR/map-*.txt`; do
clear
cat $i
sleep 0.5
done
let COUNTER=COUNTER+1
done
@admalledd
Copy link

Add terminal size autoscaling/detection:

WIDTH=`tput cols`
HEIGHT=`tput lines`
img2txt -W $WIDTH -H HEIGHT $i > $i.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment