We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

cczona on 03/28/08


Tagged

class textmate google method ruby osx clipboard irb history Gem wirble utilitybelt


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

lakedenman


Irb power tricks with Wirble & Utility-Belt


Published in: Ruby 


URL: http://utilitybelt.rubyforge.org/usage.html

Note: most of these will be available to the shell and Rails' console too.

  1. ## Required
  2.  
  3. # install
  4. sudo gem install utility-belt
  5.  
  6. # settings for ~/.irbrc
  7. require 'rubygems'
  8. require 'utility_belt'
  9. UtilityBelt::Themes.background(:light) #optional
  10.  
  11. ## Now you can play in irb
  12.  
  13. # Interactively edit IRB code in TextMate
  14. mate
  15.  
  16. # read from clipboard
  17. MacClipboard.read
  18.  
  19. # write to clipboard
  20. MacClipboard.write 'some text to be pasted elsewhere'
  21.  
  22. # review history
  23. h # 'history' also works, but who wants to type?
  24.  
  25. # re-play last command
  26. h!
  27.  
  28. # re-play arbitrary command from history
  29. h! 123
  30.  
  31. # save history to some file
  32. history_write('/path/to/file')
  33.  
  34. # find class name
  35. grep_classes("num")
  36. #=> ["Bignum", "Fixnum", "Numeric", "REXML::SyncEnumerator"]
  37.  
  38. # find method name
  39. "foo".grep_methods("pretty")
  40. #=> ["pretty_inspect", "pretty_print_instance_variables", ... ]
  41.  
  42. # google for whatever's in clipboard
  43. google
  44.  
  45. # arbitrary google search
  46. google singleWord
  47. google 'multiple words'

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: lakedenman on April 24, 2008

You should use: sudo gem install utility_belt instead of: sudo gem install utility-belt

;)

You need to login to post a comment.