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

profile.d: prepend purple hexagon to PS1 rather than overwriting it #1517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juhp
Copy link
Contributor

@juhp juhp commented Jul 7, 2024

Importantly this means the traditional Red Hat style prompt is not forced onto all other OS toolboxes as well.

juhp added a commit to juhp/toolbox that referenced this pull request Jul 7, 2024
This also avoids the need to have separate definitions for bash and zsh

More importantly it means the traditional Red Hat style bash prompt is
not forced onto all other OS toolboxes too.

containers#1517

Signed-off-by: Jens Petersen <[email protected]>
juhp added a commit to juhp/toolbox that referenced this pull request Jul 7, 2024
More importantly it means the traditional Red Hat style prompt is
not forced onto all other OS toolboxes too.

A space is added after the hexagon since vte tends to render it too  big
at least with google-noto-color-emoji-fonts.

containers#1517

Signed-off-by: Jens Petersen <[email protected]>
Importantly this means the traditional Red Hat style prompt is
not forced onto all other OS toolboxes too.

A space is added after the hexagon since vte tends to render it too big
at least with google-noto-color-emoji-fonts.

containers#1517

Signed-off-by: Jens Petersen <[email protected]>
@juhp
Copy link
Contributor Author

juhp commented Jul 7, 2024

I tested this locally in a VM and it works for me both with bash and zsh in fedora-toolbox:41
and ubuntu-toolbox:24.04

Copy link

Build succeeded.
https://softwarefactory-project.io/zuul/t/local/buildset/6426b391ccd6403abb615593eb988e79

✔️ unit-test SUCCESS in 6m 34s
✔️ unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 29s
✔️ unit-test-restricted SUCCESS in 5m 34s
✔️ system-test-fedora-rawhide SUCCESS in 37m 44s
✔️ system-test-fedora-40 SUCCESS in 37m 05s
✔️ system-test-fedora-39 SUCCESS in 38m 06s
✔️ system-test-fedora-38 SUCCESS in 37m 11s

@glemco
Copy link

glemco commented Sep 11, 2024

This doesn't work if one overrides the PS1 in a user file (e.g. bashrc), as those are sourced after the ones in /etc/profile.d and would wipe the PS1 change introduced here.
A more robust way could be to override the PROMPT_COMMAND (#1357 (comment)), although I'm not fully sure about the implications on shells not supporting it as an array

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @juhp !

I didn't mean to ignore this. I have been trying to get a new dot-zero release out, and keep hitting various obstacles, and I am always paranoid about anything that touches the shell start-up scripts because every operating system does things so differently.

It will be good to try it out on host and container combinations of the operating systems that we claim to support. ie., Arch, Fedora, RHEL and Ubuntu. I know, the matrix isn't small. :)

What do you think of the PROMPT_COMMAND idea, and perhaps falling back to the current approach if PROMPT_COMMAND is not an array?

The current approach with the hexagon doesn't work on some host/container combinations. eg., Arch and Ubuntu, but I forgot the details. I wonder if this improves that situation or something can be done to improve it.

@juhp
Copy link
Contributor Author

juhp commented Oct 1, 2024

This doesn't work if one overrides the PS1 in a user file (e.g. bashrc), as those are sourced after the ones in /etc/profile.d and would wipe the PS1 change introduced here.

@glemco that is already the case today and I might even call it a feature: users should be able to override toolbox PS1 if they want, and it is particularly necessary currently since the current toolbox prompt is rather restrictive and insufficient (the biggest problem being that it is does not distinguish different toolboxes clearly).

@juhp
Copy link
Contributor Author

juhp commented Oct 1, 2024

I have been trying to get a new dot-zero release out, and keep hitting various obstacles, and I am always paranoid about anything that touches the shell start-up scripts because every operating system does things so differently.

I would love to see a 0.1 release finally :-)

It will be good to try it out on host and container combinations of the operating systems that we claim to support. ie., Arch, Fedora, RHEL and Ubuntu. I know, the matrix isn't small. :)

I feel a better approach might be to put out snapshots and test them in Rawhide, etc (early in the development cycle) for broader testing: it is not really practical for an individual to test all possible host × container matrices realistically.
Or ideally it should be done in CI or automated of course. But I will try to do some testing later.

What do you think of the PROMPT_COMMAND idea, and perhaps falling back to the current approach if PROMPT_COMMAND is not an array?

I reopened #1514 which was actually the original motivation or wart I wanted to fix, since currently the binary PS1 makes it harder than necessary to override PS1 for users or bash-color-prompt in Fedora, etc. That PR may be a simpler first step since it doesn't change the current PS1 much (it just changes from a binary to ascii string).

I need to think more about PROMPT_COMMAND in this context.

The current approach with the hexagon doesn't work on some host/container combinations. eg., Arch and Ubuntu, but I forgot the details. I wonder if this improves that situation or something can be done to improve it.

I see, maybe there should be an issue to track that?

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.

3 participants