[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Shell commands in irb

Andre Nathan

10/16/2006 2:10:00 PM

Hi

I was quite bored this morning and the coffee machine went into its 30
minute clean cycle, so I came up with this...

$ cat .irbrc
Dir["{,/usr,/usr/local}/bin/*"].each do |bin|
Object.instance_eval do
define_method(File.basename(bin)) do |*args|
args.map! { |arg| arg.to_s }
system bin, *args
end
end
end

$ irb --simple-prompt
irb: warn: can't alias kill from irb_kill.
>> touch :foo
=> true
>> mv :foo, :bar
=> true
>> ls "-l", :bar
-rw-r--r-- 1 andre andre 0 Oct 16 11:56 bar
=> true
>>


Probably useless, I know... but running "vim :foo.rb" or "top" from
inside irb is cool :P

Andre


6 Answers

Ara.T.Howard

10/16/2006 3:02:00 PM

0

Andre Nathan

10/16/2006 5:18:00 PM

0

On Tue, 2006-10-17 at 00:01 +0900, ara.t.howard@noaa.gov wrote:
> cool idea. i tweaked it to do lazy method definition:

Heh, sweet. If only we didn't need the commas and the quotes around
command flags...


Andre


Joel VanderWerf

10/16/2006 5:22:00 PM

0

Andre Nathan wrote:
> On Tue, 2006-10-17 at 00:01 +0900, ara.t.howard@noaa.gov wrote:
>> cool idea. i tweaked it to do lazy method definition:
>
> Heh, sweet. If only we didn't need the commas and the quotes around
> command flags...

Yes, but it's better than having to use $var to evaluate a variable ;)

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Andre Nathan

10/16/2006 5:32:00 PM

0

On Tue, 2006-10-17 at 02:22 +0900, Joel VanderWerf wrote:
> Yes, but it's better than having to use $var to evaluate a variable ;)
>

Ew, no kidding! :)


Andre


Eero Saynatkari

10/17/2006 2:47:00 AM

0

On 2006.10.16 23:10, Andre Nathan wrote:
> Hi
>
> I was quite bored this morning and the coffee machine went into its 30
> minute clean cycle, so I came up with this...
>
> $ cat .irbrc
> Dir["{,/usr,/usr/local}/bin/*"].each do |bin|
> Object.instance_eval do
> define_method(File.basename(bin)) do |*args|
> args.map! { |arg| arg.to_s }
> system bin, *args
> end
> end
> end
>
> $ irb --simple-prompt
> irb: warn: can't alias kill from irb_kill.
> >> touch :foo
> => true
> >> mv :foo, :bar
> => true
> >> ls "-l", :bar
> -rw-r--r-- 1 andre andre 0 Oct 16 11:56 bar
> => true
> >>
>
>
> Probably useless, I know... but running "vim :foo.rb" or "top" from
> inside irb is cool :P

You might find rs (the Ruby shell project) of interest! One of the
core tenets is to provide full access to Ruby at the command-line.

http://projects.kittensoft.org/rs/rdoc/...

Wayne Vucenic

10/17/2006 7:02:00 AM

0

Hi Eero,

On 10/16/06, Eero Saynatkari <ruby-ml@kittensoft.org> wrote:
> You might find rs (the Ruby shell project) of interest! One of the
> core tenets is to provide full access to Ruby at the command-line.
>
> http://projects.kittensoft.org/rs/rdoc/...

Your project looks very interesting, but the above URL gave me a "Page
Not Found" error. However,

http://projects.kittensoft.org/rs/rdoc/...

works fine.

Wayne

---
Wayne Vucenic
No Bugs Software
Ruby, C#, and Erlang Agile Contract Programming in Silicon Valley