Last active
December 16, 2017 16:41
-
-
Save markusfisch/b49c283626990e7475812ecd52deaca8 to your computer and use it in GitHub Desktop.
Replace that boring variable names with funny emojis in your Swift code
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
#!/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