From: vasudevram Date: 2007-06-14T04:35:04+09:00 Subject: Re: Default IRB Directory On Jun 14, 12:22 am, vasudevram wrote: > On Jun 13, 10:04 am, Rpg Action 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 > http://www.dancingbison.com P.S. I wrote too soon. It looks to me like there's a much simpler way to do it. From your description it looks like you're not familiar with the DOS prompt. The default folder for IRB is not C:\ - it is whatever folder you run the irb command from. So you just have to do a "cd" to the folder you want to work in, then run the irb (no need for the irb0.bat) command there. E.g.: cd /d c:\my\folder\name\wherever\it\is irb (The /d changes the drive as well, to C:, in case you were at a different drive when you gave the command.) It would be a good idea to learn more about the DOS prompt and DOS commands - Google for "DOS tutorial", "DOS commands", and variations of the same. Also type "help" at a DOS prompt. Do it like this: C:\> help > dos_help.txt Then open the file dos_help.txt in a text editor and read it. For most DOS commands, you can use "help command", e.g. "help dir", or "dir /?" to get some help on them. If you want to work with irb, or the ruby command from the command- line (DOS prompt), its pretty much necessary to have some basic DOS knowledge. Not everything can be done from GUI's alone ... Vasudev Ram http://www.dancingbison.com