Skip to content

Customize IRB prompt to include env name#9585

Merged
zachmargolis merged 2 commits intomainfrom
margolis-env-prompt-irb
Nov 14, 2023
Merged

Customize IRB prompt to include env name#9585
zachmargolis merged 2 commits intomainfrom
margolis-env-prompt-irb

Conversation

@zachmargolis
Copy link
Contributor

🎫 Ticket

Action item from incident review

🛠 Summary of changes

Updates IRB console (and Rails console) to include environment name, see screenshots below.
Note: local rails console uses Pry, which has its own prompt, see screenshots below that it does work in prod which uses plain IRB

Another option is coloring the text/background, but this seemed present and clear enough for the time being.

👀 Screenshots

env before after
local Screenshot 2023-11-13 at 2 22 45 PM Screenshot 2023-11-13 at 2 22 52 PM
deployed Screenshot 2023-11-13 at 2 23 57 PM Screenshot 2023-11-13 at 2 19 54 PM

changelog: Internal, Console, Update console prompt to include environment name

def on_deployed_box?
return @on_deployed_box if defined?(@on_deployed_box)
@on_deployed_box = File.directory?('/srv/idp/releases/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On some rollplans, I've seen cd /srv/idp/current. Is that a symbolic link to /srv/idp/releases? Is this a reliable way to tell that we're on a deployed box?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/current is a symlink to a folder inside releases and was reliable enough for our current check, so I opted to keep it:

on_deployed_box = File.directory?('/srv/idp/releases/')

previously: #8147

@zachmargolis zachmargolis merged commit adcb454 into main Nov 14, 2023
@zachmargolis zachmargolis deleted the margolis-env-prompt-irb branch November 14, 2023 00:54
Comment on lines +10 to +12
PROMPT_I: "%N(#{bold(env)}):%03n:%i> ",
PROMPT_S: "%N(\e[1m#{bold(env)}\e[22m):%03n:%i%l ",
PROMPT_C: "%N(\e[1m#{bold(env)}\e[22m):%03n:%i* ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to use Identity::Hostdata.env here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That requires bundler to be loaded, so this work with plain irb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants