Add emoji_reaction script to easily put custom emoji on issues, MRs and comments
Why?
While work is being done to improve custom emoji support in GitLab itself and in glab, it seems like it might still take a while before either can actually be used. I'm frequently frustrated by not having an easy way to put a custom emoji on GitLab items.
What?
With this script, it becomes a little easier: Simply copy the permalink to the item you want to put an emoji on, and execute gls_emoji_reaction -e emojishortcode -u permalink and the script will do the rest. You can either use a link to an issue or an MR, or to a specific comment (the URL will end with #note_1234567, it's available via the timestamp on a comment).
How?
Personally I have then added a little function to my own dotfiles:
function emo() {
gls_emoji_reaction -e "$1" -u "$2"
}
This allows me to use it with absolutely minimal typing, here's a super quick 20 second demo:
Screen_Recording_2023-05-31_at_19.26.05
When? What else?
But Manu, how did you know that :thankyou: exists?
Well… I added it. But to get a list of all available custom emoji within a certain top-level namespace, you can use this snippet (if you scroll several hundred meters, you'll see that gitlab-org is in there – just replace with your top-level namespace of choice:
curl "https://gitlab.com/api/graphql" -s --header "Authorization: Bearer $GITLAB_TOKEN" --header "Content-Type: application/json" --request POST --data '{"query": "query {group(fullPath:\"gitlab-org\"){customEmoji{nodes{name,url}}}}"}' | jq '.data.group.customEmoji.nodes[]'
If you wanna get really nerdy and are using iTerm2 and its imgcat feature, you can use this monstrosity to get emoji image previews right in your terminal:
curl "https://gitlab.com/api/graphql" -s --header "Authorization: Bearer $GITLAB_TOKEN" --header "Content-Type: application/json" --request POST --data '{"query": "query {group(fullPath:\"gitlab-org\"){customEmoji{nodes{name,url}}}}"}' | jq -c '.data.group.customEmoji.nodes[]' | while read d; do name=$(echo $d | sed 's/.*"name":"\([^"]*\)".*"url":"\([^"]*\)".*/\1/');url=$(echo $d | sed 's/.*"name":"\([^"]*\)".*"url":"\([^"]*\)".*/\2/');echo "$name";curl -s ''$url'' | imgcat -W 64px -r;echo ""; done
But Manu, how did you add :thankyou: to gitlab-org?!
We can all do that. See custom_emoji/custom_emoji#1 for details.