Open juhp opened 1 year ago
This is a good point!
I remember trying to prepend to PS1
when I first did this, and for some reason it didn't work. It might have been due to the order in which PS1
is set by the start-up scripts on Fedora for Bash as a login shell. I don't remember.
It is a little tricky since the setup order of PS1 is different for a fedora bash login shell, but I got it working now with bash-color-prompt after changing toolbox.sh
to:
[ "${BASH_VERSION:-}" != "" ] && PS1="\[\033[35m\]⬢\[\033[0m\] ${PS1@P}"
But without it, one gets ⬢bash-5.2$
which is perhaps what you ran into?
In a sense toolbox.sh is setting (modifying) PS1 too early (ie before /etc/bashrc
has set the fedora default prompt, and hence it then no longer detects it is a bash default prompt...). Arguably that is also a Fedora bug in my mind - not sure the reason.
You seem to have jogged my memory a bit. I think it had something to do with the order in which the snippets in /etc/profile.d
are invoked depending on whether Bash is invoked as a login shell or a non-login shell. The order isn't stable. My memory is still very vague. :)
Anyway, if you have already found a way to improve the situation, then feel free to file a pull request against Toolbx or Fedora's shell start-up scripts, whichever is appropriate. Or, I can dig into it later myself.
Just to add one more data point: for developing mutter we use a script to create a nested D-Bus session and it modifies PS1
to show the prompt is in this nested session. This is broken currently on toolbox and I often am not sure if a terminal is in this nested D-Bus context or not.
This may have side effects, but what about not touching PS1 at all and just overriding the PROMPT_COMMAND
, it may fight with vte.sh in case the command is not an array, this works on Fedora 40:
PROMPT_COMMAND+=('printf "\033[35m⬢\033[0m"')
This may have side effects, but what about not touching PS1 at all and just overriding the
PROMPT_COMMAND
, it may fight with vte.sh in case the command is not an array, this works on Fedora 40:PROMPT_COMMAND+=('printf "\033[35m⬢\033[0m"')
That's actually a really interesting idea.
We need to check if PROMPT_COMMAND
is an array on all the operating systems we claim to support. ie., Arch, Fedora, RHEL and Ubuntu. We could perhaps fall 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 one of these ideas improve that situation or something can be done to improve it.
Describe the bug Toolbox currently overrides the shell prompt (PS1). I feel it would be better if it just prepended ⬢ to the existing PS1 rather than overwriting the setting.
Steps how to reproduce the behaviour For example for Fedora 39 the default bash prompt (now green) is:
which on
toolbox enter
then changes to:Expected behaviour I think it would be good if the prompt just modified to:
Then the prompt would also be closer to (derived from) the default system prompt for the toolbox container OS I think.
Actual behaviour