Skip to content
This repository was archived by the owner on Aug 26, 2019. It is now read-only.

Handbook: Environment

Sergey Smagin edited this page Nov 22, 2015 · 3 revisions

You can customize your rush shell environment by putting Ruby commands into ~/.rush/env.rb. For example, you might assign some variable to common directories or hosts that you use:

myproj  = home['projects/myproj/']
another = home['projects/another/'] 
gems    = root['/usr/lib/ruby/gems/1.8/gems/']

You can also mix commands in to the dir and file array classes by putting methods into ~/.rush/commands.rb, like so:

def most_recent_modification 
  entries.map { |e| e.last_modified }.max
end

In env.rb you can also change prompt:

Rush::Shell.prompt = ' λ → '

And you can monkeypatch anything you want, the env file is just ruby script that will be executed:

class Rush::File < Rush::Entry
  # send given image to flickr
  # usage: pics['my_cat.png'].flickr
  def flickr
    # here we call ruby script from the middle of FS and send the file path as argument.
    Rush::Dir.new(ENV['HOME'])['opensource/8398506/2flickr.rb'].open_with :ruby, self.full_path
  end
end

Previous: Library - Next: Remote

source: https://web.archive.org/web/http://rush.heroku.com/handbook/environment

Clone this wiki locally