Skip to content

Instantly share code, notes, and snippets.

@millenomi
Created December 27, 2010 11:09
Show Gist options
  • Select an option

  • Save millenomi/756048 to your computer and use it in GitHub Desktop.

Select an option

Save millenomi/756048 to your computer and use it in GitHub Desktop.
Need to apply some manipulation to strings in arbitrary apps? Clipboard filtering to the rescue! (OS X 10.6+ only, but can be adapted to other versions and OSes.)
require 'osx/cocoa'
pboard = OSX::NSPasteboard.generalPasteboard
x = nil
loop do
new_x = `pbpaste`
if new_x != x
x = new_x
y = x.gsub(/Art\./, 'art').gsub(/[^a-zA-Z0-9]/, '').downcase
puts y
pboard.clearContents
pboard.writeObjects [y]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment