mirror of
https://github.com/rwxrob/dot
synced 2024-11-14 18:12:56 +00:00
43 lines
708 B
Bash
Executable File
43 lines
708 B
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
declare -A emoji
|
|
emoji[smile]=😃
|
|
emoji[bear]=🐻
|
|
emoji[hamburger]=🍔
|
|
emoji[lightbulb]=💡
|
|
emoji[idea]=💡
|
|
emoji[comment]=💬
|
|
emoji[chat]=💬
|
|
emoji[pomo]=🍅
|
|
emoji[stop]=🛑
|
|
emoji[warning]=⚠️
|
|
emoji[rant]=🤬
|
|
emoji[tv]=📺
|
|
emoji[update]=📰
|
|
emoji[tux]=🐧
|
|
emoji[tux]=🐧
|
|
emoji[facepalm]=🤦
|
|
|
|
toemoji() {
|
|
local in=/dev/stdin
|
|
local out=/dev/stdout
|
|
local file="$1"
|
|
if [[ -n $file ]];then
|
|
in="$file"
|
|
out="$(mktemp)"
|
|
fi
|
|
IFS=$'\n'
|
|
while read -r line; do
|
|
for k in ${!emoji[@]}; do
|
|
line=${line//:$k:/${emoji[$k]}}
|
|
done
|
|
echo "$line" >> $out
|
|
done < "$in"
|
|
if [[ -n $file ]]; then
|
|
cp "$out" "$file"
|
|
rm "$out"
|
|
fi
|
|
}
|
|
|
|
toemoji "$@"
|