Skip to content

Instantly share code, notes, and snippets.

@sorah
Forked from thinca/vim.cgi
Created December 2, 2009 00:17
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 sorah/246770 to your computer and use it in GitHub Desktop.
Save sorah/246770 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
"
execute 'help' getline(1)
.,/\*\S\+\*$/?\S?print
qa!
"
require 'rubygems'
require 'json'
require 'cgi'
TEMP = './temp'
cgi = CGI.new
json = JSON.parse(cgi["json"])
print cgi.header('text/plain')
text = json['events'][0]['message']['text']
if text =~ /^:h(e(lp?)?)?\s+(.+)/
open(TEMP, 'w'){|f| f.write($2)}
print `vim -Z -u NONE -N -e -s #{TEMP} < #{__FILE__}`
File.delete(TEMP)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment