Skip to content

Instantly share code, notes, and snippets.

@dipil-saud
Created February 10, 2012 04:13
Show Gist options
  • Save dipil-saud/1786539 to your computer and use it in GitHub Desktop.
Save dipil-saud/1786539 to your computer and use it in GitHub Desktop.
My pryrc file
CodeRay.scan("example", :ruby).term # just to load necessary files
CUSTOM_COLORS = {
:constant => '1;34', # Bold Midnight Blue #191970
:class_variable => '1;34',
:symbol => '1;31' # will make symbols bolded and light red on my terminal
}
Pry.config.prompt = [
proc { |target_self, nest_level, pry|
if nest_level == 0
"[#{pry.input_array.size}](#{Pry.view_clip(target_self)})> "
else
"[#{pry.input_array.size}](#{Pry.view_clip(target_self)}):#{nest_level}> "
end
},
proc { |target_self, nest_level, pry|
if nest_level == 0
"[#{pry.input_array.size}](#{Pry.view_clip(target_self)})* "
else
"[#{pry.input_array.size}](#{Pry.view_clip(target_self)}):#{nest_level}* "
end
}
]
colors = if (CodeRay::Encoders::Terminal::TOKEN_COLORS rescue nil)
# CodeRay 1.0.0
CodeRay::Encoders::Terminal::TOKEN_COLORS
else
# CodeRay 0.9
begin
require 'coderay/encoders/term'
CodeRay::Encoders::Term::TOKEN_COLORS
rescue
nil
end
end
if colors
CUSTOM_COLORS.each_pair do |key, value|
colors[key] = value
end
end
Pry.config.editor = "mate"
Pry.config.exception_handler = proc do |output, exception, _pry_|
output.puts "#{exception}"
exception.backtrace.each{|backtrace_line| output.puts backtrace_line }
_pry_.run_command 'cat --ex'
end
class Object
# Return only the methods not present on basic objects
def interesting_methods
(self.methods - Object.instance_methods).sort
end
end
def colputs(array)
def num_columns; 4; end
def col_width; 25; end
def force_length(x)
x = x.to_s
max_length = col_width+2
if x.length > max_length
x = x[0..max_length-4] + '...'
end
x += (' '*max_length)
x[0..max_length-1]
end
def get_element(array, i) # displays in column order instead of row order
num_rows = (array.length/num_columns)+1
col = i % num_columns
row = i / num_columns
array[col*num_rows+row]
end
for i in (0..array.length)
print force_length(get_element(array, i))
print " "
puts if (i % num_columns) == (num_columns-1)
end
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment