On Jun 13, 10:04 am, Rpg A. [email protected] wrote:
I’m new to Ruby, and I’ve never used a similar language that could be
executed from the command line, so I’m pretty clueless in these first
couple of steps, and I hope that you’ll help me here.
Is there a way under Windows that I can set the default IRB directory to
a specific folder? Right now the default is C:, and I’ve no idea how to
go about changing it.
–
Posted viahttp://www.ruby-forum.com/.
Create a shortcut on the Windows Desktop for IRB using Windows
Explorer.
Then right-click on the shortcut and in the dialog that pops up, look
for the field labeled “Start in” (not sure of the exact label for the
field, not at my PC now, but in the dialog the label/field should be
evident/self-explanatory). In that field, enter the name of the folder
that you want IRB to start in.
But sorry, this won’t help you if you want to run IRB from the command
line - from a DOS command prompy, that is. You’ll have to double-click
on the shortcut on the Desktop for this technique to work.
One way to make this work from the command line is to create a batch
file called, say, irb0.bat (or any suitable name), and in that file,
put these lines:
@echo off
cd your_folder_name here
irb
Then put that file irb0.bat in some folder which is in your PATH, and
run it from any folder when you are in a DOS window. It should do what
you want.
Or, if you want to come back to the directory from which you run the
irb0 file (after the batch file terminates - since the version shown
above will leave you in the your_folder_name folder), change the “cd”
in the 2nd line of the batch file to “pushd” and add a line “popd”
below the line “irb”.
Not tested as I’m not at my PC but looks correct to me.
P.S. If you want to pass arguments to irb, change the “irb” line to:
irb %1 %2 %3 (and so on upto %9)
Then you can pass upto 9 command-line arguments to irb0 when you call
it, and those will be passed on to irb.
Vasudev Ram