Created
October 14, 2008 16:28
-
-
Save tommorris/16735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ,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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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