Skip to content

Instantly share code, notes, and snippets.

@rynkis
Created October 12, 2019 05:20
Show Gist options
  • Save rynkis/572df8ceb31cdb77c37c2b9ac7013ade to your computer and use it in GitHub Desktop.
Save rynkis/572df8ceb31cdb77c37c2b9ac7013ade to your computer and use it in GitHub Desktop.
帮助健忘的我快速查询小鹤双拼键位
#!/usr/bin/env ruby
#encoding: utf-8
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
require "./bundle/bundler/setup"
require "alfred"
mapping = {
'iu' => 'Q',
'ei' => 'W',
'e' => 'E',
'uan' => 'R',
'ue' => 'T',
've' => 'T',
'u' => 'U',
'sh' => 'U',
'i' => 'I',
'ch' => 'I',
'o' => 'O',
'uo' => 'O',
'ie' => 'P',
'a' => 'A',
'iong' => 'S',
'ong' => 'S',
'ai' => 'D',
'en' => 'F',
'eng' => 'G',
'ang' => 'H',
'an' => 'J',
'ing' => 'K',
'uai' => 'K',
'iang' => 'L',
'uang' => 'L',
'ou' => 'Z',
'ia' => 'X',
'ua' => 'X',
'ao' => 'C',
'ui' => 'V',
'v' => 'V',
'zh' => 'V',
'in' => 'B',
'iao' => 'N',
'ian' => 'M'
}
Alfred.with_friendly_error do |alfred|
fb = alfred.feedback
icon = 'icon.png'
mapping.keys.find_all {|x| x.include? ARGV[0].downcase }.each do |yun|
fb.add_item(
title: "小鹤: #{yun} => #{mapping[yun]}",
icon: {type: 'default', name: icon}
)
end
puts fb.to_alfred
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment