Default IRB Directory

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.

On 6/13/07, Rpg A. [email protected] wrote:

Posted via http://www.ruby-forum.com/.
In commnad prompt type irb
and here you are on IRB directory and for coming out of this type exit.
Thanks.

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
http://www.dancingbison.com

Can you be more specific what you try to achieve?
Irb is an interpreter console.
If you start it from the command prompt then the current directory
will be the working directory. It you start if from the some kind
shortcut then you can define the “Start in” or working directory.
But the key question still remains: what do you want to achieve?

On Jun 14, 12:22 am, vasudevram [email protected] wrote:


But sorry, this won’t help you if you want to run IRB from the command

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

Hi,

At Thu, 14 Jun 2007 04:25:02 +0900,
vasudevram wrote in [ruby-talk:255512]:

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.

ruby -C “somewhere you want” -S irb

or

ruby -C “somewhere you want” -rirb -e IRB.start

On Jun 14, 8:10 am, Nobuyoshi N. [email protected] wrote:

or

ruby -C “somewhere you want” -rirb -e IRB.start


Nobu Nakada

Cool, didn’t know that, thanks. Good thing I came back to look at this
post … :). Guess that implies that you can pass any Ruby command-
line option to irb using this method of invoking it.

Vasudev

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs