Skip to content

Commit

Permalink
Display dev/test env in console prompt in blue instead of green
Browse files Browse the repository at this point in the history
The combination of red and blue is more color-blind friendly than red
and green.

Discussion: rails#50796 (comment)
  • Loading branch information
st0012 committed Jan 23, 2024
1 parent ee88f41 commit 6fc1bd5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion railties/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
For example, `MyApp` will displayed as `my-app` in the prompt.

Additionally, the environment name will be colorized when the environment is
`development` (green), `test` (green), or `production` (red), if your
`development` (blue), `test` (blue), or `production` (red), if your
terminal supports it.

*Stan Lo*
Expand Down
4 changes: 2 additions & 2 deletions railties/lib/rails/commands/console/console_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def start
def colorized_env
case Rails.env
when "development"
IRB::Color.colorize("dev", [:GREEN])
IRB::Color.colorize("dev", [:BLUE])
when "test"
IRB::Color.colorize("test", [:GREEN])
IRB::Color.colorize("test", [:BLUE])
when "production"
IRB::Color.colorize("prod", [:RED])
else
Expand Down
6 changes: 3 additions & 3 deletions railties/test/commands/console_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def test_console_defaults_to_IRB
def test_prompt_env_colorization
irb_console = Rails::Console::IRBConsole.new(app)
red = "\e[31m"
green = "\e[32m"
blue = "\e[34m"
clear = "\e[0m"

Rails.env = "development"
assert_equal("#{green}dev#{clear}", irb_console.colorized_env)
assert_equal("#{blue}dev#{clear}", irb_console.colorized_env)

Rails.env = "test"
assert_equal("#{green}test#{clear}", irb_console.colorized_env)
assert_equal("#{blue}test#{clear}", irb_console.colorized_env)

Rails.env = "production"
assert_equal("#{red}prod#{clear}", irb_console.colorized_env)
Expand Down

0 comments on commit 6fc1bd5

Please sign in to comment.