Skip to content

Instantly share code, notes, and snippets.

@melborne
Forked from jugyo/emoji.rb
Last active August 29, 2015 14:01
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 melborne/ac7a3613ad5c77387b8c to your computer and use it in GitHub Desktop.
Save melborne/ac7a3613ad5c77387b8c to your computer and use it in GitHub Desktop.
# coding: UTF-8
# emoji plugin(Emot gem version)
# ====
#
# You can post Emoji easily!
#
# Usage
# ----
#
# heading to Shibuya :train:
# :zzz:
#
# See also:
# ----
#
# * https://github.com/jugyo/named_emoji
# * http://www.emoji-cheat-sheet.com/
# * https://github.com/melborne/emot
require 'emot'
Earthquake.init do
input_filter do |text|
next text unless text =~ %r|^(:\w+)|
text.gsub(/:([^\s:]+):/) do |emoji_name|
Emot.icon($1.to_sym) || emoji_name
end
end
completion do |text|
next [] if Readline.line_buffer.strip == text
regexp = /^#{Regexp.quote(text)}/
Emot::MAP.keys.map {|i| ":#{i}:"}.grep(regexp)
end
command :emojis do
puts Emot.list.map {|k, (v,_)| "#{v} #{k}"}.join(" ")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment