Created
December 27, 2010 11:09
-
-
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.)
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
| 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