We love Ruby. And we love the command line. So… the shell needs to be rubyfied ;).

Fresh is a new gem, trying to achieve this.

Updated for fresh version 0.2.0.

Fresh tries to detect automatically, if your expression should be a Ruby or a shell command. Basically, this is done by a regexp similar to this one: /^\w+\s+.*/ (match a single word followed by at least one space)

~/a/ripl-fresh> 3.times{ puts "This is Ruby" } This is Ruby This is Ruby This is Ruby => 3 ~/a/ripl-fresh> cd lib/ripl ~/a/ripl-fresh/lib/ripl> ls fresh fresh.rb ~/a/ripl-fresh/lib/ripl> vim fresh.rb ~/a/ripl-fresh/lib/ripl> cd - ~/a/ripl-fresh> cal November 2010 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

The command used (as single word or first part of the regex) is looked for in Ripl.config[:fresh_system_commands] which contains the commands available in your path.

You can also force the line to be interpreted as Ruby by prefixing it with a space, or to force interpretation as system command by prefixing it with ^ :

~/a/ripl-fresh> cal NameError: undefined local variable or method `cal' for main:Object ~/a/ripl-fresh> mv [TAB] .README.rdoc.swp CHANGELOG.rdoc README.rdoc bin/ deps.rip pkg/ .gemspec LICENSE.txt Rakefile blog.textile lib/ ~/a/ripl-fresh> mv LICENSE.txt LICENSE

Fresh comes with a very basic auto-completion: currently, only path completion and (sometimes) command completion is supported.

You can also use the command output in Ruby by assigning it to a Ruby expression. This is done like this:

~/a/ripl-fresh> ls => a ~/a/ripl-fresh> a => ["bin", "CHANGELOG.rdoc", "deps.rip", "fresh.gemspec", "lib", "LICENSE", "pkg", "Rakefile", "README.rdoc"] ~/a/ripl-fresh> a.size => 9

Further information on github ;)