Skip to content

Commit c8335e1

Browse files
authored
Merge pull request rails#53027 from Uaitt/colorize-prompt-for-non-standard-environments
Colorize console prompt on non standard environments
2 parents 8cd9230 + b097cfb commit c8335e1

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Colorize the Rails console prompt even on non standard environments.
2+
3+
*Lorenzo Zabot*
4+
15
* Don't enable YJIT in development and test environments
26

37
Development and test environment tend to reload code and redefine methods (e.g. mocking),

railties/lib/rails/commands/console/irb_console.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def colorized_env
120120
when "production"
121121
IRB::Color.colorize("prod", [:RED])
122122
else
123-
Rails.env
123+
IRB::Color.colorize(Rails.env, [:MAGENTA])
124124
end
125125
end
126126
end

railties/test/commands/console_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_prompt_env_colorization
7171
irb_console = Rails::Console.new(app).console
7272
red = "\e[31m"
7373
blue = "\e[34m"
74+
magenta = "\e[35m"
7475
clear = "\e[0m"
7576

7677
Rails.env = "development"
@@ -83,7 +84,7 @@ def test_prompt_env_colorization
8384
assert_equal("#{red}prod#{clear}", irb_console.colorized_env)
8485

8586
Rails.env = "custom_env"
86-
assert_equal("custom_env", irb_console.colorized_env)
87+
assert_equal("#{magenta}custom_env#{clear}", irb_console.colorized_env)
8788
end
8889

8990
def test_default_environment_with_no_rails_env

0 commit comments

Comments
 (0)