Enhance your irb experience on Windows
You can extend the functionality of your irb on Windows by creating a file .irbrc in your %userprofile% directory. Put some Ruby code in there, and they will get loaded when you launch your irb, as well as your script/console. I have put in some code snippets in there to aid my irb experience.
(You may have issues trying to create a file with its name beginning with a period on Windows Explorer. Try to run the command "notepad .irbrc" in your cmd.exe)
Tab Completion
require 'irb/completion'Do you miss intellisense? If you do this, then in irb, type in like "text".s[tab][tab] will give you a list of methods in String that starts with s.
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
Ruby Interactive (ri) reference in irb
def ri(*names)Then you can type ri 'String.strip' to see the Ruby index. The argument has to be a string though.
system(%{echo | ri #{names.collect { |name| name.to_s }.join(" ")}})
end
Remember, on a Windows machine, you have to put "echo | " in front of your ri line or else your irb will just return 'false'. I know it's counterintuitive that it isn't at the end, but it works.
Clear screen
def clsI always wanted clear screen...
system('cls')
end
Console messed up with long irb lines
If you have a line of Ruby code that is way too long, and you want to go back and make changes, on Windows console it is not very friendly as it will almost guarentee to mess up your edits and disorient your typings. The only way I Googled on how to fix this is to take away the "--readline" switch from the Tab Completion tip above, and replace it with "--noreadline". But then you lose Tab Completion of course. I haven't found a workaround for it yet, but in the mean time I will happily just use Cygwin bash shell =)