I spent some time looking for something really simple: I wanted to be able to do this:
$ echo 'Hello world :tada:' | someprogram
Hello world 🎉
I didn't find one quickly enough, and as I want to learn go, I thought that doing it myself could be a good task (and it was 😄 I learned a 💩-load of new stuff 🎉)
To get it working on your machine, just grab the latest .exe
from the tags, and add an alias
to it or add it in your PATH
.
# .bashrc
alias goemoji="path/to/goemoji.exe $*"
Note: the $*
at then end allows to give arguments
Now, you can do
$ echo 'I :heart: code' | goemoji
I ❤ code
You can also build it yourself, it's simple:
$ go build goemoji.go
🎉
I'm on Windows, and I'm using Hyper. At this time, Hyper has a bug, emoji take too much room, which
"eat" the following char. The solution to prevent this is to add a space just after (so that it
eats the space).
Note: this bug has been fixed in the version 1.3.1
of Hyper. But I'll leave this feature, it
might be useful for some people.
So, you can specify a suffix by passing it as an argument:
$ git log | goemoji " "
Or by setting it as an environment variable:
$ export GOEMOJI_SUFFIX=" "
$ git log | goemoji
Plenty of program add color to their output only if the destination is a terminal. So, when you
pipe it, it doesn't use colors (so you get emoji, but no color 😞). It's the case for
git log
.
Fortunatly, there's often an option to oblige colored output. For git log
, it's --color=always
$ git log --color="always" --oneline --graph --decorate -10 --all | goemoji
😉
That's it! Hope you enjoy it (don't forget to ⭐ this repo if it did 😄)