Last active
February 17, 2018 18:19
-
-
Save valeth/087b1997ebdaed83212d4079a775a721 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# frozen_string_literal: true | |
# rubocop:disable all | |
require "ostruct" | |
PRY_DATA_HOME = | |
if ENV.include?("XDG_DATA_HOME") | |
File.join(ENV["XDG_DATA_HOME"], "pry") | |
else | |
File.join(Dir.home, ".local/share/pry") | |
end | |
FileUtils.mkdir_p(PRY_DATA_HOME) unless Dir.exist?(PRY_DATA_HOME) | |
Pry.config.history.file = File.join(PRY_DATA_HOME, "history") | |
Pry.config.editor = ENV["EDITOR"] | |
COLOR = OpenStruct.new( | |
red: [218, 68, 83].join(";"), | |
darkgrey: [35, 38, 41].join(";"), | |
none: "\e[m" | |
).freeze | |
BG = OpenStruct.new( | |
red: "\e[48;2;#{COLOR.red}m", | |
grey: "\e[48;2;#{COLOR.darkgrey}m" | |
).freeze | |
FG = OpenStruct.new( | |
red: "\e[38;2;#{COLOR.red}m", | |
grey: "\e[38;2;#{COLOR.darkgrey}m" | |
).freeze | |
PROMPTS = [] | |
PROMPTS << proc do |obj, nest_level, _pry| | |
"#{BG.red} #{FG.grey}#{obj} #{BG.grey}#{FG.red} "\ | |
"#{BG.grey} #{FG.red}#{nest_level} #{COLOR.none}#{FG.grey}#{COLOR.none} " | |
end | |
PROMPTS << proc do |obj, nest_level, _pry| | |
"#{BG.red}#{' ' * (obj.to_s.size - 3)}#{FG.grey} ... "\ | |
"#{BG.grey} #{' ' * (nest_level.to_s.size + 3)}#{COLOR.none} " | |
end | |
Pry.prompt = PROMPTS.freeze |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment