#! /bin/bash trace () { # echo $* >&2 true } wgetfirst=false #wgetfirst=true case "$1" in -sh) postproc=cat shift;; *) postproc=bash;; esac case `basename "$PWD"` in mintty) echo "You seem to be in a mintty config directory:" >&2 echo " $PWD" >&2 echo "For direct emoji deployment, run this script from its subdirectory 'emojis'." >&2 exit;; esac emojisurl0=https://www.unicode.org/emoji/charts/full-emoji-list.html emojisurl1=https://www.unicode.org/emoji/charts/full-emoji-modifiers.html download () { if $wgetfirst then wget -N -t 1 "$1" elif type curl then # prefer curl because it works better behind proxies if [ -f `basename "$1"` ] then curl -RO -z `basename "$1"` "$1" else # avoid "Warning: Illegal date format for -z" curl -RO "$1" fi else wget -N -t 1 "$1" fi || (echo "[41;30mFILE: $1[m" >&2 echo "[41;30mERROR: download failed, file incomplete[m" >&2 if [ -f `basename "$1"` ] then # enforce fresh download next time touch -d 1970-01-01 `basename "$1"` fi return 9 ) } case "$1" in ""|-h|--help) echo "Usage: `basename $0` [-d | DIR | .../full-emoji-list.html] [EMOJI_STYLE]..." >&2 echo >&2 echo "This script extracts emojis graphics (.png format) from a downloaded copy of" >&2 echo " $emojisurl0" >&2 echo " $emojisurl1" >&2 echo "for the selected emoji style sets, or (if none selected) all of them:" >&2 echo " google" >&2 echo "and always extracts common emoji graphics." >&2 echo "Other styles are no longer provided at unicode.org:" >&2 echo " [apple facebook windows twitter emojione samsung]" >&2 echo >&2 echo "Options:" >&2 echo " -d Download the chart files" >&2 echo " DIR Expect the chart files in given directory" >&2 echo >&2 echo "Warning: with all styles selected, this may take a while." >&2 echo >&2 if [ `uname` = "Linux" ] && type wslpath 2> /dev/null 1>&2 then echo "Note: for direct deployment from WSL, first go into the common config directory:" >&2 echo ' cd `wslpath "$APPDATA/mintty/emojis"` || cd `wslpath "$APPDATA/wsltty/emojis"`' >&2 else echo "Note: for direct deployment, first go into subdirectory 'emojis' of one of the" >&2 echo "mintty config directories:" >&2 echo ' ~/.mintty' >&2 echo ' ~/.config/mintty' >&2 echo ' $APPDATA/mintty' >&2 echo ' /usr/share/mintty' >&2 fi exit;; -d|--download) if download $emojisurl0 && download $emojisurl1 then emojis0=full-emoji-list.html emojis1=full-emoji-modifiers.html else echo Download failed >&2 exit fi shift;; *.html) emojis1=`dirname "$1"`/full-emoji-modifiers.html if [ -r "$1" -a -r "$emojis1" ] then emojis0="$1" else echo Not readable: "$1" "$emojis1" >&2 exit fi shift;; *) if [ -d "$1" ] then emojis0="$1"/full-emoji-list.html emojis1="$1"/full-emoji-modifiers.html if [ -r "$emojis0" -a -r "$emojis1" ] then true else echo Not readable: "$emojis0" "$emojis1" >&2 exit fi shift else echo Missing file name of full emoji list >&2 exit fi;; esac echo -n "Using " >&2 cat "$emojis0" | sed -e "s,