Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created October 14, 2008 16:28
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 tommorris/16735 to your computer and use it in GitHub Desktop.
Save tommorris/16735 to your computer and use it in GitHub Desktop.
" ,g - create google a href for word under cursor
map ,g <Esc>Bm`:r!ghref <cword><CR>"gdd``i<C-R><C-R>g<esc>dwi<BackSpace><Esc>
vmap ,g yvgvdm`:r!ghref '<C-R>=substitute(@0, "['\n]", " ", "g")<cr>'<cr>"gdd``i<C-R><C-R>g<Esc>i<BackSpace><Esc>
#!/usr/bin/env ruby
require 'rubygems'
require 'curb'
require 'json'
str = ARGV.join(" ")
c = Curl::Easy.new("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=#{URI.encode(str)}") {|curl| curl.headers["Referer"] = "http://tommorris.org/" } # Your favourite URI here!
c.perform
puts "<a href=\"" + JSON.parse(c.body_str)['responseData']['results'][0]['url'] + "\">" + str + "</a>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment