Skip to content

Instantly share code, notes, and snippets.

@karmatr0n
Last active November 7, 2023 06:41
Show Gist options
  • Save karmatr0n/7266751236e4af267ed4feb78ae549e3 to your computer and use it in GitHub Desktop.
Save karmatr0n/7266751236e4af267ed4feb78ae549e3 to your computer and use it in GitHub Desktop.
dotirbrc
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
require 'irb/easter-egg' if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.7.0')
%w[awesome_print rainbow interative_editor virb].each do |gem|
next if Gem.loaded_specs.key?(gem)
if defined?(::Bundler)
system("rvm @global do gem install #{gem}")
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
$LOAD_PATH.concat(Dir.glob("#{global_gemset}/gems/*/lib"))
else
begin
Gem::Specification.find_by_name(gem)
rescue Gem::MissingSpecError
system("gem install #{gem} ")
end
end
Bundler.require gem.to_sym
require gem
end
def app_prompt
Rainbow("⚡").yellow
end
def env_prompt
"#{Rainbow("%N").yellow}.#{Rainbow("%m").bright}"
end
prompt = "#{app_prompt}#{env_prompt}"
IRB.conf[:PROMPT][:BANG] = {
PROMPT_I: "#{prompt} ⟩ ", # normal prompt
PROMPT_S: "#{prompt} ❯❯ ", # prompt for continuing strings
PROMPT_C: "#{Rainbow("%02n").bold} … ", # Prompt for continuing statement
PROMPT_N: "#{Rainbow("%02n").bold} … ", # unknown continuation
RETURN: "✨ %s\n" # Format to return value 📣
}
IRB.conf[:PROMPT_MODE] = :BANG
IRB.conf[:SAVE_HISTORY] = 10_000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
IRB.conf[:AUTO_INDENT] = true
AwesomePrint.irb!
IRB.send :easter_egg if IRB.respond_to?(:easter_egg, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment