From 61efad34bc9adf37c07286dcb60ca01aecb43ffa Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 25 Nov 2021 18:08:31 +0100 Subject: [PATCH] profile.d: Fix the PS1 on Z shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, on Fedora, a nested instance of Z shell inside a Toolbox container renders the PS1 like this: \[\]⬢\[\][\u@\h \W]\$ Notice that Z shell doesn't like that the terminal escape sequences for the foreground colour are wrapped in '\[' and '\]' [1], and doesn't understand the special characters like '\u' and '\h'. This is fixed by making the PS1 specific to the shell. The prompt for Z shell is based on the default prompt used on Fedora, just like the one for Bash. Note that this only affects nested instances of Z shell because of the way the start-up scripts for Z shell are written on Fedora. Toolbox invokes top-level shell as a login shell, and for those the PS1 set by profile.d/toolbox.sh is overwritten by the operating system's default in /etc/zshrc. See: https://bugzilla.redhat.com/show_bug.cgi?id=2026749 [1] Commit bc1a816ea3b80fc7 https://github.com/debarshiray/toolbox/issues/190 https://github.com/containers/toolbox/pull/936 --- profile.d/toolbox.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/profile.d/toolbox.sh b/profile.d/toolbox.sh index ab8dc43..dce6e85 100644 --- a/profile.d/toolbox.sh +++ b/profile.d/toolbox.sh @@ -39,7 +39,8 @@ fi if [ -f /run/.containerenv ] \ && [ -f /run/.toolboxenv ]; then - PS1=$(printf "\[\033[35m\]⬢\[\033[0m\]%s" "[\u@\h \W]\\$ ") + [ "${BASH_VERSION:-}" != "" ] && PS1=$(printf "\[\033[35m\]⬢\[\033[0m\]%s" "[\u@\h \W]\\$ ") + [ "${ZSH_VERSION:-}" != "" ] && PS1=$(printf "\033[35m⬢\033[0m%s" "[%n@%m]%~%# ") if ! [ -f "$toolbox_welcome_stub" ]; then echo ""