3 Because everybody likes "paste & jello" sandwiches, right? I know I did when I
6 Jello is a simple library to watch the OS X pasteboard and do something on
11 Jello::Mould.new do |paste|
12 system "say 'You pasted #{paste}'"
17 For example, to watch for URLs copied, and then shorten the URL and replace
18 the long URL with the shortened one, write a short mould like the following:
23 Jello::Mould.new do |paste|
25 if paste =~ %r{^http://.*}
28 unless uri =~ %r{^http://bit.ly}
29 shortener = 'http://bit.ly/api?url=' + uri
30 open(shortener).gets.chomp
38 Jello.start! :verbose => true
40 Moulds can even be stacked:
44 Jello::Mould.new do |paste|
48 Jello::Mould.new do |paste|
52 Jello.start! :verbose => true
54 Jello also provides a binary - if you have some moulds you use often, you can
55 throw them in your `~/.jello/` folder (as .rb files), and then run jello with
58 # Assuming ~/.jello/ contains foo.rb, bar.rb, and gaz/{one,two}.rb
60 # Now foo.rb, bar.rb, one.rb, and two.rb would be executed on incoming
63 You can also use pasteboards other than the general one (see `man pbcopy` for
64 more information about this):
68 Jello::Mould.new do |paste|
69 paste.gsub! /abc/, 'def'
74 Finally, you can create a Jello [property list][plist] for [launchd][] that
75 will keep jello running all the time, even after you restart. Just run
76 `rake launchd` from the Jello distribution directory. (This requires that you
77 install the [LaunchDoctor][] gem first!)
79 [launchd]: <http://en.wikipedia.org/wiki/Launchd> "launchd on Wikipedia"
80 [plist]: <http://en.wikipedia.org/wiki/Property_list> "Property list on Wikipedia"
81 [LaunchDoctor]: <http://github.com/elliottcable/launchdr> "elliottcable's launchdr on GitHub"