How can Homebrew print a beer mug in Terminal?
Solution 1
Homebrew is open source, so you can read its code to find out how it shows the icon. The line they're using is in the file formula_installer.rb
:
print "🍺 " if MacOS.version >= :lion
The first character in the print
command is a "🍺
", or unicode #1f37a 'BEER MUG'.
So it's not an icon but an funny unicode beer mug :)
Solution 2
BTW, try another variants in terminal:
echo $'\360\237\215\270'
echo $'\360\237\215\271'
echo $'\360\237\215\273'
echo $'\360\237\215\274'
Related videos on Youtube
stib
I specialise in bespoke After Effects scripts and expressions, but my day gig also involves cinematography, animation, 3D, editing and futzing around with various flavours of code. I'm also particularly interested in long-term preservation of digital audiovisual media.
Updated on September 18, 2022Comments
-
stib over 1 year
Homebrew has a neat trick of printing out little icons next to its output. Like this:
If I copy paste the icon it on its own and hit enter I get the result:
-bash: $'?\237\215?': command not found
And if I try it with
echo
orprintf
I justget ????
. Same if I escape all the quotes and$
s etc.editron:~ stib$ echo $'?\237\215?' ????
So how do they do that? What do the magic characters
$'?\237\215?'
mean? -
stib over 11 yearsAwesome. So in the shell I can just do echo -e "\xF0\x9f\x8d\xba"
-
ihatetoregister about 11 yearsAlso, try looking it up in the OS X dictionary (right click > look up) ;)
-
Chad Skeeters almost 11 yearsOr with octal:
echo $'\360\237\215\272'
-
pabouk - Ukraine stay strong over 10 yearsFor those who do not have a font containing these symbols: These are symbols/pictures of various drinks. See codepoints.net/miscellaneous_symbols_and_pictographs
-
dominicbri7 almost 8 yearsAlso from just about anywhere in OS X you can summon the Emoji keyboard using the shortcut
Ctrl + Cmd + Space
. Doesn't work everywhere but works in most places