My .irbrc
I haven’t seen very many .irbrc files lying around on the internet. Examples, sure, I’ve seen examples, but nothing anyone would actually use. Maybe no one has taught me that things like .irbrc files are not interesting. I think they would be. I want to see more.
Here’s mine:
IRB_START_TIME = Time.now ARGV.concat [ "--readline" ] require 'pp' require 'rubygems' require 'duration' require 'wirble' require 'irb/completion' require 'irb/ext/save-history' IRB.conf[:PROMPT][:SHORT] = { :PROMPT_C=>"%03n:%i* ", :RETURN=>"%sn", :PROMPT_I=>"%03n:%i> ", :PROMPT_N=>"%03n:%i> ", :PROMPT_S=>"%03n:%i%l " } IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" IRB.conf[:PROMPT_MODE] = :SHORT Wirble.init(:skip_prompt => true, :skip_history => true) Wirble.colorize at_exit { puts Duration.new(Time.now - IRB_START_TIME) } def clear print "e[He[2J" end
A couple of notes:
- Wirble colorizes return values in irb, and does a pretty good job at it. It also changes the prompt and the behavior of irb’s history in ways I don’t like; the
Wirble.initline takes care of those problems. - I was always trying to clear the screen with
clear. I had to make it happen on my own. If I could suppress the nil that gets displayed afterwards, I would. - The short prompt I make there is sort of a halfway between the standard prompt
irb(main)001:0>and the simple prompt>>. I want line numbers and indent levels! I want to know where I am. - I also want to know when I am. So I set
IRB_START_TIMEand use the Duration gem andat_exitto tell me how long my irb sessions are. It is totally worthless, but I love it. It makes me feel productive. Have a look:
mvb:~ cms$ irb 001:0> "wait a minute" "wait a minute" 002:0> exit 20 seconds mvb:~ cms$
I couldn’t wait a full minute.
bryanl said,
July 14, 2007 @ 4:29 am
I use the one I posted, now I’ll take the good parts out of yours and merge them into mine :)
http://smartic.us/2007/3/7/i-present-my-irbrc
M'enfin ?!? said,
November 30, 2007 @ 5:46 pm
IRB, un outil à (re)découvrir…
IRB est un outil génial pour tester rapidement un truc en Ruby. C’est une sorte d’interpréteur Ruby qui fonctionne comme un shell : vous tapez une ligne de Ruby, irb l’interprête et vous donne le résultat, vous tapez une autre ligne, irb…