4 Because everybody likes "paste & jello" sandwiches, right? I know I did when I
7 Jello is a simple library to watch the OS X pasteboard and do something on
12 Jello::Mould.new do |paste|
13 system "say 'You pasted #{paste}'"
18 For example, to watch for URLs copied, and then shorten the URL and replace
19 the long URL with the shortened one, write a short mould like the following:
24 Jello::Mould.new do |paste|
26 if paste =~ %r{^http://.*}
29 unless uri =~ %r{^http://bit.ly}
30 shortener = 'http://bit.ly/api?url=' + uri
31 open(shortener).gets.chomp
39 Jello.start! :verbose => true
41 Moulds can even be stacked:
45 Jello::Mould.new do |paste|
49 Jello::Mould.new do |paste|
53 Jello.start! :verbose => true
55 Jello also provides a binary - if you have some moulds you use often, you can
56 throw them in your `~/.jello/` folder (as .rb files), and then run jello with
59 # Assuming ~/.jello/ contains foo.rb, bar.rb, and gaz/{one,two}.rb
61 # Now foo.rb, bar.rb, one.rb, and two.rb would be executed on incoming
64 Finally, you can use pasteboards other than the general one (see `man pbcopy`
65 for more information about this):
69 Jello::Mould.new do Jello::Pasteboard::Find |paste|
70 paste.gsub! /abc/, 'def'