1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby -wKU

SUPPORT = ENV['TM_SUPPORT_PATH']
DIALOG = SUPPORT + '/bin/tm_dialog'

require SUPPORT + '/lib/escape'
require SUPPORT + '/lib/plist'

words = `grep -i "^$TM_CURRENT_WORD" /usr/share/dict/web2`.split("\n")
abort if words.empty?

words = words.collect { |e| { 'title' => e } }
plist = { 'menuItems' => words }.to_plist

res = PropertyList::load(`#{e_sh DIALOG} -up #{e_sh plist}`)
abort unless res.has_key? 'selectedMenuItem'

print res['selectedMenuItem']['title'][ENV['TM_CURRENT_WORD'].length..-1]