Any ideas for a shell based on Ruby?

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:

  1. ls returns a special array of Filename objects
  2. The array is sorted by the attribute :date
  3. the last element is chosen from the array
  4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

Martin

This is going into fantasyland, but perhaps you could use the way Ruby
handles object chains to replace pipes… e.g. instead of doing
$ ps -e | grep foo
you could do
$ ps( -e ).grep( foo )
Yeah I know, it’s a crappy example, but it gives you the idea. Of
course the problem would be on how to get the shell to treat binaries
as objects.
On the other hand, it might be interesting to integrate a class
browser into the shell, like the Smalltalk system browser (again, bad
analogy, but it gets the point through).

···

On Fri, 7 May 2004 21:53:59 +0900, Martinus elmartinos@eml.cc wrote:

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:

  1. ls returns a special array of Filename objects
  2. The array is sorted by the attribute :date
  3. the last element is chosen from the array
  4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

Martin

Martinus wrote:

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:

  1. ls returns a special array of Filename objects
  2. The array is sorted by the attribute :date
  3. the last element is chosen from the array
  4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

Don’t take this as a discouragement, but I’ve always had a mixed feeling
towards a Ruby shell (or Perl shell, or C# shell, etc). If we stick to
Ruby syntax strictly, it will be a more cumbersome/verbose shell than
bash/csh (e.g. we will need to quote all filenames, environment
variables will need to in a special container, etc). If we add many
magic or shortcuts (e.g. adding methods like #filesize to String or even
overriding #size), it will not be Ruby anymore. Some people have trouble
remembering Ruby and bash, and then they now have to remember yet
another
syntax (which is not exactly Ruby, and not quite bash either).
I think I’ll pass from using such a mixture shell on a daily basis,
except when I’m bored :wink:

···

–
dave

“Martinus” elmartinos@eml.cc schrieb im Newsbeitrag
news:7024f804.0405070450.3d461846@posting.google.com…

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:

  1. ls returns a special array of Filename objects
  2. The array is sorted by the attribute :date
  3. the last element is chosen from the array
  4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

This is coming up every once in a while.

There is in fact already a Ruby shell: irb. Together with fileutils you
get pretty much what you want to write…

Regards

robert

Hi,

At Fri, 7 May 2004 21:53:59 +0900,
Martinus wrote in [ruby-talk:99490]:

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:

  1. ls returns a special array of Filename objects
  2. The array is sorted by the attribute :date
  3. the last element is chosen from the array
  4. the file removes itself

$ irb -r pathname
irb(main):001:0> def ls(path)
irb(main):002:1> path=["
“] if path.empty?
irb(main):003:1> path.collect {|p|
irb(main):004:2* begin
irb(main):005:3* p = File.join(p,”*") if File.lstat(p).directory?
irb(main):006:3> rescue SystemCallError
irb(main):007:3> end
irb(main):008:2> Dir.glob(p)
irb(main):009:2> }.flatten.collect(&Pathname.method(:new))
irb(main):010:1> end
=> nil
irb(main):011:0> ls.sort_by{|p|p.mtime}.last
=> #Pathname:i686-linux
irb(main):012:0>

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

Give a glance at lib/shell.

And irbsh may clue.
http://raa.ruby-lang.org/list.rhtml?name=irbsh

···

–
Nobu Nakada

I was thinking about a ruby os shell last night, and wondering if anybody
had tried it. I was pondering the possibility of a ruby based vfs engine.
I was also thinking about using operator overload to simplify appending
content to files, etc. I also really want to be able to natively use xpath
style operations on xml files from the command line:

ls ~/files/file.xml//somenode/somenode2[@someattr]

Your sample syntax is very appealing, btw.

–SegPhault

···

On Fri, 07 May 2004 05:50:20 -0700, Martinus wrote:

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:

  1. ls returns a special array of Filename objects
  2. The array is sorted by the attribute :date
  3. the last element is chosen from the array
  4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

Martin

Sorry I caught this thread so late. I actually did a little work on this. You
can read about in the ROS project mailing list archives (on RubyForge).
Essentially, my thought was to traverse the file system as if it were a Ruby
Object --in fact it would be a proxy object for the filesystem. Then self
would be the current traversal object (like current directory). Files and
subdirectories would be accessor methods in that object, as would be commands
like #ls and #cd, etc. inherited from the Filesystem::Directory class.

···

On Friday 07 May 2004 08:53 am, Martinus wrote:

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort(:time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :slight_smile:

--
T.