Last active
March 3, 2021 21:16
-
-
Save pndurette/67e204c0ee4ea2e1f28e839b059d36b2 to your computer and use it in GitHub Desktop.
Cursed script to convert text to Slack's :alphabet-*: emoji
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 | |
# $0 <text to convert> | |
# COLOUR=yellow $0 <text to convert> | |
TEXT="$@" | |
COLOUR="${COLOUR:-white}" # can be 'yellow' | |
REGEX='^[a-zA-Z\!\?\#\@\ ]+$' | |
[[ $TEXT =~ $REGEX ]] || \ | |
{ echo "Text must match $REGEX"; exit 1; } | |
echo "${TEXT}" | \ | |
sed -r "s/([a-zA-Z])/:alphabet-${COLOUR}-\1:/g" | \ | |
sed -r "s/(\!)/:alphabet-${COLOUR}-exclamation:/g" | \ | |
sed -r "s/(\?)/:alphabet-${COLOUR}-question:/g" | \ | |
sed -r "s/(\#)/:alphabet-${COLOUR}-hash:/g" | \ | |
sed -r "s/(\@)/:alphabet-${COLOUR}-at:/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment