[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Default IRB Directory

Rpg Action

6/13/2007 5:04:00 AM

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 via http://www.ruby-....

5 Answers

vasudevram

6/13/2007 7:23:00 PM

0

On Jun 13, 10:04 am, Rpg Action <rpgact...@gmail.com> 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-....

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.dancin...

vasudevram

6/13/2007 7:31:00 PM

0

On Jun 14, 12:22 am, vasudevram <vasudev...@gmail.com> wrote:
> On Jun 13, 10:04 am, Rpg Action <rpgact...@gmail.com> 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-....
>
> 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.dancin...

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.dancin...


Dejan Dimic

6/13/2007 8:28:00 PM

0

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 13, 7:04 am, Rpg Action <rpgact...@gmail.com> 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-....


Nobuyoshi Nakada

6/14/2007 3:11:00 AM

0

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

--
Nobu Nakada

vasudevram

6/26/2007 12:07:00 PM

0

On Jun 14, 8:10 am, Nobuyoshi Nakada <n...@ruby-lang.org> wrote:
> 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
>
> --
> 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