Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Replace that boring variable names with funny emojis in your Swift code
#!/usr/bin/env bash
# Replace that boring variable names with funny emojis in your Swift code
#
# @param 1 - file to emojize
emojize() {
local FILE=$1
local EMOJI=(๐Ÿ˜€ ๐Ÿ˜ฌ ๐Ÿ˜ ๐Ÿ˜‚ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜… ๐Ÿ˜† ๐Ÿ˜‡ ๐Ÿ˜‰ ๐Ÿ˜Š ๐Ÿ™‚ ๐Ÿ™ƒ ๐Ÿ˜‹ ๐Ÿ˜Œ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ˜œ ๐Ÿ˜ ๐Ÿ˜› ๐Ÿค‘ ๐Ÿค“ ๐Ÿ˜Ž ๐Ÿค— ๐Ÿ˜ ๐Ÿ˜ถ ๐Ÿ˜ ๐Ÿ˜‘ ๐Ÿ˜’ ๐Ÿ™„ ๐Ÿค” ๐Ÿ˜ณ ๐Ÿ˜ž ๐Ÿ˜Ÿ ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜” ๐Ÿ˜• ๐Ÿ™ ๐Ÿ˜ฃ ๐Ÿ˜– ๐Ÿ˜ซ ๐Ÿ˜ฉ ๐Ÿ˜ค ๐Ÿ˜ฎ ๐Ÿ˜ฑ ๐Ÿ˜จ ๐Ÿ˜ฐ ๐Ÿ˜ฏ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜ข ๐Ÿ˜ฅ ๐Ÿ˜ช ๐Ÿ˜“ ๐Ÿ˜ญ ๐Ÿ˜ต ๐Ÿ˜ฒ ๐Ÿค ๐Ÿ˜ท ๐Ÿค’ ๐Ÿค• ๐Ÿ˜ด ๐Ÿ’ค ๐Ÿ’ฉ ๐Ÿ˜ˆ ๐Ÿ‘ฟ ๐Ÿ‘น ๐Ÿ‘บ ๐Ÿ’€ ๐Ÿ‘ป ๐Ÿ‘ฝ ๐Ÿค– ๐Ÿ˜บ ๐Ÿ˜ธ ๐Ÿ˜น ๐Ÿ˜ป ๐Ÿ˜ผ ๐Ÿ˜ฝ ๐Ÿ™€ ๐Ÿ˜ฟ ๐Ÿ˜พ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿ‘‹ ๐Ÿ‘ ๐Ÿ‘Š ๐Ÿ‘Œ ๐Ÿ’ช ๐Ÿ™ ๐Ÿ‘† ๐Ÿ‘‡ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ–• ๐Ÿค˜ ๐Ÿ–– ๐Ÿ’… ๐Ÿ‘„ ๐Ÿ‘… ๐Ÿ‘‚ ๐Ÿ‘ƒ ๐Ÿ‘ ๐Ÿ‘€ ๐Ÿ‘ค ๐Ÿ—ฃ ๐Ÿ‘ถ ๐Ÿ‘ฆ ๐Ÿ‘ง ๐Ÿ‘จ ๐Ÿ‘ฉ ๐Ÿ‘ฑ ๐Ÿ‘ด ๐Ÿ‘ต ๐Ÿ‘ฒ ๐Ÿ‘ณ ๐Ÿ‘ฎ ๐Ÿ‘ท ๐Ÿ’‚ ๐Ÿ•ต ๐ŸŽ… ๐Ÿ‘ผ ๐Ÿ‘ธ ๐Ÿ‘ฐ ๐Ÿšถ ๐Ÿƒ ๐Ÿ’ƒ ๐Ÿ‘ฏ ๐Ÿ‘ซ ๐Ÿ‘ฌ ๐Ÿ‘ญ ๐Ÿ™‡ ๐Ÿ’ ๐Ÿ™… ๐Ÿ™† ๐Ÿ™‹ ๐Ÿ™Ž ๐Ÿ™ ๐Ÿ’‡ ๐Ÿ’† ๐Ÿ’‘ ๐Ÿ’ ๐Ÿ‘ช)
local EMOJI_LEN=${#EMOJI[@]}
local I=0
[ -r "$FILE" ] && grep -o -E '\<(let|var)\>[ \t]+([a-zA-Z0-9_-]+)' \
"$FILE" | while read -r _ NAME
do
(( I >= EMOJI_LEN )) && break
sed -i '' -e "s/[[:<:]]${NAME}[[:>:]]/${EMOJI[$(( I++ ))]}/g" "$FILE"
done
}
if [ "${BASH_SOURCE[0]}" == "$0" ]
then
for ARG
do
emojize "$ARG"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You canโ€™t perform that action at this time.