Created
February 12, 2022 16:49
-
-
Save igb/15b51ce17cdc4a0a2b74a3bf1fc7b97c to your computer and use it in GitHub Desktop.
Shell script for trimming accessible Wordle descriptions down to 140 characters or less when possible.
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
IFS="" | |
if [ "$#" -ne 1 ]; then | |
wordle=`pbpaste`; | |
else | |
wordle=`cat $1` | |
fi | |
filters=( | |
"s/Line //;" | |
"s/and/\&/g;" | |
"s/in the wrong/in wrong/g;" | |
"s/\.//;" | |
"s/correct/right/g;" | |
"s/!//;" | |
"s/://;" | |
"s/th / /g;" | |
"s/th,/,/g;" | |
"s/st / /g;" | |
"s/st,/,/g;" | |
"s/,//g;") | |
for t in ${filters[@]}; do | |
if [ `echo $wordle | wc -c` -gt 140 ]; then | |
wordle=`echo "$wordle" | sed $t` | |
fi | |
done | |
if [ `echo $wordle | wc -c` -gt 140 ]; then | |
echo "Could not express your Wordle text in 140 characters or less. :-(" | |
else | |
score=`echo $wordle | wc -c | xargs` | |
echo "$wordle" | pbcopy | |
echo "Rewrote your Wordle text in $score characters and copied it to the clipboard." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment