From 19c6d2beeae782989be2b640b7f271f0f8498284 Mon Sep 17 00:00:00 2001 From: Santiago Bartesaghi Date: Mon, 3 Jul 2023 14:35:20 -0300 Subject: [PATCH 1/4] Add env to the rails console --- .irbrc | 16 ++++++++++++++++ .pryrc | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .irbrc diff --git a/.irbrc b/.irbrc new file mode 100644 index 00000000..f48fec60 --- /dev/null +++ b/.irbrc @@ -0,0 +1,16 @@ +# Add color coding based on Rails environment for safety +if defined?(Rails) + banner = if Rails.env.production? + "\e[41;97;1m #{Rails.env} \e[0m " + else + "\e[42;97;1m #{Rails.env} \e[0m " + end + + # Build a custom prompt + IRB.conf[:PROMPT][:CUSTOM] = IRB.conf[:PROMPT][:DEFAULT].merge( + PROMPT_I: banner + IRB.conf[:PROMPT][:DEFAULT][:PROMPT_I] + ) + + # Use custom prompt by default + IRB.conf[:PROMPT_MODE] = :CUSTOM +end diff --git a/.pryrc b/.pryrc index 705f61f6..f882b27b 100644 --- a/.pryrc +++ b/.pryrc @@ -1,6 +1,18 @@ +# Add command aliases if defined?(PryByebug) Pry.commands.alias_command 'c', 'continue' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'f', 'finish' end + +# Add color coding based on Rails environment for safety +if defined?(Rails) && defined?(Pry) + banner = if Rails.env.production? + "\e[41;97;1m #{Rails.env} \e[0m " + else + "\e[42;97;1m #{Rails.env} \e[0m " + end + + Pry.config.prompt_name = banner +end From b8fd925f475c37e5b4810963eb6c38d9bb040930 Mon Sep 17 00:00:00 2001 From: Santiago Bartesaghi Date: Mon, 3 Jul 2023 15:08:18 -0300 Subject: [PATCH 2/4] Update .irbrc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Diego Suárez --- .irbrc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.irbrc b/.irbrc index f48fec60..321e7694 100644 --- a/.irbrc +++ b/.irbrc @@ -1,10 +1,7 @@ # Add color coding based on Rails environment for safety if defined?(Rails) - banner = if Rails.env.production? - "\e[41;97;1m #{Rails.env} \e[0m " - else - "\e[42;97;1m #{Rails.env} \e[0m " - end + banner_color = Rails.env.production? ? 41 : 42 + banner = "\e[#{banner_color};97;1m #{Rails.env} \e[0m " # Build a custom prompt IRB.conf[:PROMPT][:CUSTOM] = IRB.conf[:PROMPT][:DEFAULT].merge( From 009acfb9b80eef8c1368df47fd740d36a21d5b4d Mon Sep 17 00:00:00 2001 From: Santiago Bartesaghi Date: Mon, 3 Jul 2023 15:09:42 -0300 Subject: [PATCH 3/4] Also update .pryrc --- .pryrc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.pryrc b/.pryrc index f882b27b..fb11cc7d 100644 --- a/.pryrc +++ b/.pryrc @@ -8,11 +8,8 @@ end # Add color coding based on Rails environment for safety if defined?(Rails) && defined?(Pry) - banner = if Rails.env.production? - "\e[41;97;1m #{Rails.env} \e[0m " - else - "\e[42;97;1m #{Rails.env} \e[0m " - end + banner_color = Rails.env.production? ? 41 : 42 + banner = "\e[#{banner_color};97;1m #{Rails.env} \e[0m " Pry.config.prompt_name = banner end From 1aa9b97697f750e8bb6a8d66dbdd0109eeb982ab Mon Sep 17 00:00:00 2001 From: Santiago Bartesaghi Date: Mon, 3 Jul 2023 15:13:33 -0300 Subject: [PATCH 4/4] Ignore .irb_history --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5342a7b6..05ee99a0 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,9 @@ config/master.key # Ignore byebug history .byebug_history +# Ignore irb history +.irb_history + /node_modules /yarn-error.log yarn-debug.log*