Skip to content

Instantly share code, notes, and snippets.

@waynerobinson
Created April 29, 2011 05:17
Show Gist options
  • Save waynerobinson/947881 to your computer and use it in GitHub Desktop.
Save waynerobinson/947881 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'irb/completion'
require 'irb/ext/save-history'
# inspired by https://gist.github.com/794915
# I've changed it a bit, it works fine for me now
# but i'm still searching for a better solution
def require_without_bundler(*gems)
unless defined?(::Bundler)
gems.each { |g| require g }
return
end
gem_path = "/opt/local/lib/ruby/gems/1.8"
Dir.glob("#{gem_path}/gems/*").map { |gem_path|
gem_name=File.basename(gem_path).gsub(/-(\d\.?)+$/,'')
if gems.include?(gem_name)
$LOAD_PATH << "#{gem_path}/lib"
require gem_name
end
}
end
require_without_bundler "sketches"
Sketches.config :editor => 'vim'
require_without_bundler "wirble"
# wirble configuration, using only colours
Wirble.init(:skip_prompt => true, :skip_history => true,:init_colors=>true)
# where history is saved
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
# how many lines to save
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:AUTO_INDENT] = true
# detects a rails console, cares about version
def rails?(*args)
version=args.first
v2 = ($0 == 'irb' && ENV['RAILS_ENV'])
v3 = ($0 == 'script/rails' && Rails.env)
version == 2 ? v2 : version == 3 ? v3 : v2 || v3
end
# loading rails configuration if it is running as a rails console
load File.dirname(__FILE__) + '/.railsrc' if rails?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment