-
Notifications
You must be signed in to change notification settings - Fork 268
boxcli,devbox: move default prompt into devbox.json #145
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
Conversation
We currently set the devbox shell prompt in the shellrc template with: export PS1="(devbox) $PS1" This breaks the prompt for users that have a theme or use a shell that sets the prompt in some other way. To allow user's to opt out of the prompt, move it into devbox.json where they can modify or delete it. Running `devbox init` will now generate a config that looks like: { "packages": [], "shell": { "init_hook": [ "# Here you can remove or customize the prompt for your project's devbox shell.", "# By convention, individual users can set DEVBOX_NO_PROMPT=1 in their shell's", "# rc file to opt out of prompt customization.", "if [ -z \"$DEVBOX_NO_PROMPT\" ]; then", "\tPS1=\"(devbox:tmp.wGAYMHRO) $PS1\"", "fi" ] } } This also means that users with an existing devbox config will no longer get a prompt. If they want to get the default prompt back, they can run: devbox init -fix prompt This fix will automatically append the default devbox prompt to the shell init hook unless there's already a command that contains `PS1=`. A future change will print a hint when launching a shell to tell the user about this change. Note that the `-fix` flag accepts a comma-separated list of fixes in case we need to add more as the config evolves. For simplicity, the current implementation only allows "prompt", but can be redone later to support more.
Instead of checking that |
The hook runs in the devbox shell, so it'll always be set. Devbox itself doesn't do anything with the |
I'm going to hold off on merging this until the next release. I want to add the shell hint that also informs the user of |
I haven't reviewed the code, so this comment is purely based on the shell hook: I was thinking we would move to a world where the prompt with Point taken that |
Yeah, that check for We can simplify it down to just setting the prompt, but I thought it might be a good idea to include it by default. I'm imagining a scenario where a large project sets a prompt, but there are a few developers on the team where it messes up their shell. |
is this still for review? Or did y'all have a conversation out-of-band and plan more changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@gcurtis what's the status on this one? dropping myself to clear my review queue, but feel free to add me back. |
Summary
We currently set the devbox shell prompt in the shellrc template with:
This breaks the prompt for users that have a theme or use a shell that sets the prompt in some other way. To allow user's to opt out of the prompt, move it into devbox.json where they can modify or delete it. Running
devbox init
will now generate a config that looks like:This also means that users with an existing devbox config will no longer get a prompt. If they want to get the default prompt back, they can run:
This fix will automatically append the default devbox prompt to the shell init hook unless there's already a command that contains
PS1=
. A future change will print a hint when launching a shell to tell the user about this change.Note that the
-fix
flag accepts a comma-separated list of fixes in case we need to add more as the config evolves. For simplicity, the current implementation only allows "prompt", but can be redone later to support more.How was it tested?
Manually running
devbox shell
after:This one is trickier to add tests for because the prompt only applies for interactive shells, and the tests are obviously not interactive.