Apple - Assign monospaced font family to selected text with keyboard shortcut in mac os x

I've been looking for doing this for a very long time.

I finally managed to end up with something that really works great for me, with the help of Alfred and Highlight CLI tool.

Here is the Alfred script portion :

query="{query}"
if echo $query|grep -e "^__SHORTCUT__"
then
    echo "$query"|sed -E "s/^__SHORTCUT__//"|pbcopy
    syntax=txt
else
    osascript -e 'tell application "System Events" to keystroke "c" using {command down}'
    syntax=$query
fi

pbpaste|/usr/local/bin/highlight --syntax $syntax --font Menlo --font-size 12 --out-format=rtf|pbcopy
osascript -e 'tell application "System Events" to keystroke "v" using {command down}'

Make sure the shortcut trigger adds __SHORTCUT__ to be recognized and argument is "Selection in OSX" :

enter image description here

Short demo https://youtu.be/y8NJT52APRQ