Skip to content

Instantly share code, notes, and snippets.

@elundmark
Last active May 16, 2020 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elundmark/94a4a58c4a5b208d69317134e3787467 to your computer and use it in GitHub Desktop.
Save elundmark/94a4a58c4a5b208d69317134e3787467 to your computer and use it in GitHub Desktop.
Copy Emoji from Rofi List (plus how-to generate a full list)
#!/usr/bin/env bash
# curl 'https://unicode.org/Public/emoji/13.0/emoji-test.txt' > Public_emoji_13.0_emoji-test.txt
declare title_re='^# (sub)?group[: ]+(.+)'
declare e_line_re='^([0-9A-Z]+ )+[ ]+;[ ]*(fully-qualified|unqualified|minimally-qualified|qualified|component)[ ]+#[ ]*(.+)[ ]+(E[0-9.]+)[ ]+(.+)$'
declare work_dir
work_dir="$(dirname "$(realpath "$0")")"
while read -r; do
[[ "$REPLY" =~ $title_re ]] && DESC="${BASH_REMATCH[2]}"
[[ "$REPLY" =~ $e_line_re ]] && echo "${BASH_REMATCH[3]} ${BASH_REMATCH[4]} U${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${DESC}: ${BASH_REMATCH[5]}"
done < "$work_dir/Public_emoji_13.0_emoji-test.txt" > "$work_dir/cli-list.txt"
exit $?
#!/usr/bin/env bash
rofi_cmd(){
rofi -disable-history -dmenu -i -matching regex -location 8 -width 40% -lines 50 \
-p "Select an emoji to copy it: "
return $?
}
declare work_dir
work_dir="$(dirname "$(realpath "$0")")"
declare copy_me
copy_me="$(rofi_cmd < "$work_dir/cli-list.txt")" || exit 1
copy_me="$(grep -ioP '^[^ ]+' <<< "$copy_me")"
test -n "$copy_me" || exit 1
printf '%s' "$copy_me" | xsel -b -f -i
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment