Irb power tricks with Wirble & Utility-Belt


/ Published in: Ruby
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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'

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.