Skip to content

Commit

Permalink
irb tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Oct 24, 2022
1 parent 84d000e commit 1d38960
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
17 changes: 11 additions & 6 deletions .irbrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
env = (ENV["IRB_PROMPT"] || ENV["APP_ENV"] || ENV["RACK_ENV"] || "unknown").upcase
env = (ENV["IRB_PROMPT"] || ENV["APP_ENV"] || ENV["RACK_ENV"] || "").upcase
if env == "PRODUCTION" || env == "DEPLOYMENT"
color = "31"
else
color = "33"
end
prompt = "%03n "
prompt += "\e[#{color}m#{env} " if env
prompt += "\e[33m"

IRB.conf[:PROMPT][:CUSTOM] = {
PROMPT_I: "%03n \e[#{color}m#{env} >>\e[0m ",
PROMPT_N: "%03n \e[#{color}m#{env} \e[1;33m>>\e[0m ",
PROMPT_S: nil,
PROMPT_C: "%03n \e[#{color}m#{env} \e[33m?>\e[0m ",
RETURN: "\e[#{color}m#{env} \e[32m=>\e[0m %s\n"
PROMPT_I: "#{prompt}>>\e[0m ",
PROMPT_N: "#{prompt}>>\e[0m ",
PROMPT_S: "#{prompt}%l>\e[0m ",
PROMPT_C: "#{prompt}?>\e[0m ",
RETURN: "\e[32m=>\e[0m %s\n",
}
IRB.conf[:PROMPT_MODE] = :CUSTOM

IRB.conf[:USE_AUTOCOMPLETE] = false
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ RUN bundle install --retry=3 --jobs=4
COPY . .
RUN find

# Disable irb history to prevent .irb_history permission error from showing
RUN echo "IRB.conf[:SAVE_HISTORY] = nil" >> .irbrc

# Run the container as an unprivileged user
RUN mkdir -p tmp
RUN chown nobody:nogroup tmp
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"
ruby ">= 2.7.0"

gem "rake", require: false
gem "irb", "=1.4.0" # https://github.com/ruby/irb/commit/99d3aa979dffece1fab06a7d5ebff4ae5da50aae
gem "irb"
gem "rack"
gem "sinatra"
gem "puma"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GEM
github-release-party (0.3.6)
rake (>= 12)
io-console (0.5.11)
irb (1.4.0)
irb (1.4.2)
reline (>= 0.3.0)
loofah (2.19.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -93,7 +93,7 @@ DEPENDENCIES
dotenv
feedjira
github-release-party
irb (= 1.4.0)
irb
newrelic_rpm
nokogiri
opengraph_parser
Expand Down

0 comments on commit 1d38960

Please sign in to comment.