Skip to content

Instantly share code, notes, and snippets.

@andrei512
Created January 16, 2014 15:48
Show Gist options
  • Save andrei512/8457174 to your computer and use it in GitHub Desktop.
Save andrei512/8457174 to your computer and use it in GitHub Desktop.
ubiquitous ruby clipboard processing script
#!/usr/bin/env ruby
clipboard = `pbpaste`
if clipboard.match /https?:\/\/w?w?w?\.((youtube)|(listenonrepeat))\.com\/.*/
# Youtube / Listen on repeat
if clipboard["youtube"] != nil
clipboard["youtube"] = "listenonrepeat"
elsif clipboard["listenonrepeat"] != nil
clipboard["listenonrepeat"] = "youtube"
end
end
output = clipboard
begin
output = eval(clipboard)
rescue Exception => e
# silence exception
end
`printf \"#{output}\" | pbcopy`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment