Skip to content

Instantly share code, notes, and snippets.

@roryokane
Created July 11, 2012 01:32
Show Gist options
  • Save roryokane/3087362 to your computer and use it in GitHub Desktop.
Save roryokane/3087362 to your computer and use it in GitHub Desktop.
.irbrc – my Ruby IRB config
# encoding: utf-8
require 'rubygems' unless defined? Gem
# enables variable-name tab-completion
# I don’t care about the other features in here; I think irbtools already
# provides them, but there’s little harm in leaving them in
# from http://www.genlinux.org/2008/12/autocomplete-in-irb.html
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
IRB.conf[:LOAD_MODULES] << 'irb/completion'
end
def enable_irbtools
require 'irbtools'
# not using `require 'irbtools/more'` because Bond self-admittedly has errors since
# “EditLine” is also installed, and EditLine is confusing to remove or replace
rescue LoadError => e
# puts e.message # to help debug this rescue clause
raise unless e.message.match(/irbtools/)
puts "‘irbtools’ not installed - see install notes on https://github.com/janlelis/irbtools"
end
enable_irbtools
# prefabricated values of various types
# to make it easier to start experimenting with values of those types
# `include SampleValues` to import them; `SampleValues::HASH` to reference them
module SampleValues
HASH = {:a => 1, :b => 2}
SYM = :wherever
BIG_SYM = "Benjamin Franklin".to_sym
MIXED_ARRAY = [1, 2, nil, 4, true, 6, false, "eight", 9, /ten/, :eleven, 12]
REGEX = /a regex [w]ith character class(es)? and (?:more ?)+/
end
@roryokane
Copy link
Author

Gist doesn’t highlight this file correctly. It should be highlighted as Ruby code. I can’t just rename the file to .irbrc.rb because IRB doesn’t find the file in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment