Created
September 29, 2011 15:45
-
-
Save czj/1251040 to your computer and use it in GitHub Desktop.
Custom .pryrc for OSX + Rails + polite
This file contains 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
# 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