Created
October 22, 2009 19:51
-
-
Save joshaven/216239 to your computer and use it in GitHub Desktop.
launch many ruby projects by typing 'irb' from the root dir of the project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Save this file as .irbrc in the root of your home directory... This will allow | |
# you to load multiple different enviroments by simply typing 'irb' from your console. | |
# | |
# This file includes tab compleation and irb history. | |
# | |
# For example, after saving this file you can: | |
# type: irb instead of ./script/console | |
# type: irb instead of irb (followed by "require 'lib/init.rb'") | |
require 'irb/completion' | |
require 'pp' | |
IRB.conf[:AUTO_INDENT] = true | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
current_path = Dir.pwd | |
working_dir = current_path.split(File::Separator).last | |
# Load Cilantro apps: http://github.com/dcparker/cilantro | |
if File.exists?('lib/cilantro.rb') | |
require 'lib/cilantro' | |
Cilantro.load_environment(:irb) | |
puts "Custom environment loaded." | |
# load Rails apps: http://www.rubyonrails.org | |
elsif File.exists?('script/console') && File.exists?('config/boot.rb') | |
unless Object.const_defined?("RAILS_ROOT") | |
require 'config/boot' unless Object.const_defined?("RAILS_ROOT") | |
require 'commands/console' if ENV['RAILS_ENV'].nil? | |
end | |
puts "Rails #{Rails.version} #{RAILS_ENV} environment loaded." | |
# load other apps | |
elsif File.exists?('config/init.rb') | |
require 'config/init.rb' | |
puts "Custom environment loaded." | |
# load under-development gems | |
elsif File.exists?("lib/#{working_dir}.rb") | |
require "lib/#{working_dir}" | |
puts "Custom environment loaded." | |
# Load else | |
else | |
puts "Standard IRB: No special environment loaded." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment