Skip to content

Commit

Permalink
irb configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jooray committed May 8, 2017
1 parent ce66a32 commit 10f426b
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .irbrc
@@ -0,0 +1,48 @@
#!/usr/bin/ruby
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'

IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"

IRB.conf[:PROMPT_MODE] = :SIMPLE

IRB.conf[:AUTO_INDENT] = true

class Object
# list methods which aren't in superclass
def local_methods(obj = self)
(obj.methods - obj.class.superclass.instance_methods).sort
end

# print documentation
#
# ri 'Array#pop'
# Array.ri
# Array.ri :pop
# arr.ri :pop
def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
method = [klass, method].compact.join('#')
end
puts `ri '#{method}'`
end
end

# Copies the result of the last operation you ran in IRB to the system
# clipboard (if you're on macOS).
def cop
last_value = IRB.CurrentContext.last_value
%x[echo '#{last_value}' | pbcopy]
"copied \`#{last_value}' to your clipboard"
end

def me
User.find_by_login(ENV['USER'].strip)
end

def r
reload!
end

0 comments on commit 10f426b

Please sign in to comment.