Skip to content

Instantly share code, notes, and snippets.

@czj
Created September 29, 2011 15:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czj/1251040 to your computer and use it in GitHub Desktop.
Save czj/1251040 to your computer and use it in GitHub Desktop.
Custom .pryrc for OSX + Rails + polite
# This script is greatly inspired by Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# Use TextMate as default editor
Pry.config.editor = "mate -w"
# My pry is polite
Pry.hooks = {
:after_session => proc {
puts "\nGoodbye." if Pry.active_sessions == 1
}
}
# Prompt with ruby version
Pry.prompt = [
proc { |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} > " },
proc { |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " }
]
require 'map_by_method'
require 'hirb'
# Toys methods
# Stealed from https://gist.github.com/807492
class Array
def self.toy(n=10, &block)
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
end
end
class Hash
def self.toy(n=10)
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
end
end
# loading rails configuration if it is running as a rails console
load File.dirname(__FILE__) + '/.railsrc' if defined?(Rails) && Rails.env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment