Skip to content

Commit

Permalink
Add env to the rails console
Browse files Browse the repository at this point in the history
  • Loading branch information
santib committed Jul 3, 2023
1 parent d278a89 commit 19c6d2b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .irbrc
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .pryrc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 19c6d2b

Please sign in to comment.