Ruby script to open the contents of the clipboard. Just assign it to a global hotkey, like Ctrl+O, using Sparkle, Quicksilver, Alfred Powerpack, or your favorite hotkey app. Copy something to the clipboard, hit the hotkey, and it's opened up.
This file contains 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 | |
# Opens the clipboard contents | |
# 1. Is it a file or folder? | |
# 2. Is it obviously a URL? | |
# 3. Google It | |
# clipboard contents | |
clip = IO.popen('pbpaste', 'r+').read | |
# open appropriately | |
if File.exist? clip | |
system("open", clip) | |
elsif /\w[^\s]*\.(?:com|co|uk|gov|edu|tv|net|org|tel|me|us|mobi|es|io)(?:[ \r\n]{0,2}\z|\/.*)[ \r\n]{0,2}\z/.match(clip) | |
clip = "http://#{clip}" unless (clip.index '://') | |
system("open -a 'Google Chrome' #{clip}") | |
else | |
google = "http://www.google.com/search?q=#{clip}" | |
system("open -a 'Google Chrome' '%s'" % [google]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment