Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env to the rails console #384

Merged
merged 4 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
santib marked this conversation as resolved.
Show resolved Hide resolved

# 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