Hello,
When using bash 5.3 as the shell for a user (/etc/passwd, chsh),
/etc/profile.d/vte-*.sh does not recognize interactive terminals. In my
case I'm simply installing 5.3 to /bin/bash.
Symptoms:
- '$-' is NULL (Sanity for vte.sh)
- $PROMPT_COMMAND does not include '__vte_prompt_command'
- Terminals behave as though PS1 contains non-visible chars that aren't
properly escape, even where PS1=''.
I had wanted to move away from using '${a[\#]' (I can't remember how I came
to this... I used to be smarter.) to make my exit-code indicators in the
PROMPT work by leveraging the new '${|foo;)' feature. No tangible gains
other than readability/maintainability for myself/others.
Prompt setup with handling for both <5.3 and 5.3.
Notes:
- That the issue with the term behaving as though PS1 contains improperly
escaped non-visible chars occurs for both versions of the PS1 prompt here.
- The <5.3 version of this PS1 cmd works on 5.2.37(1)-release and earlier.
```
# Bash Version < 5.3
__exit_symbol_52() {
[[ $? == 0 ]] && echo -n "⛳⟫"
[[ $? != 0 ]] && echo -n "💀⟫"
}
# Bash Version >= 5.3
function __exit_symbol_53() {
local EXIT_CODE="$?"
local WHITE='\[\e[0m\]'
local B_GREEN='\[\e[01;32m\]'
local B_GRAY='\[\e[1;30m\]'
local PROMPT="X"
[[ $EXIT_CODE -eq 0 ]] && local PROMPT="🟩"
[[ $EXIT_CODE -ne 0 ]] && local PROMPT="🟥"
[[ $HISTCMD -eq $PS1_HISTCMD ]] && local PROMPT="🎱"
printf "%s" "$PROMPT"
}
# shellcheck disable=2154
if [ "$color_prompt" = yes ]; then
# Bash Version < 5.3
PS1='${debian_chroot:+($debian_chroot)}${a[\#]-$(_exit_symbol_52)}${a[\#]+🎱⟫}${a[\#]=}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
'
# Bash Version >= 5.3
# TODO: Escape issues appears to be a bug where $- doesn't contain 'i' as
required by /etc/profile.d/vte*.sh
#
PS1='$(__exit_symbol_53)${|PS1_HISTCMD=$HISTCMD;}⟫${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$
'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
case "$TERM" in
tmux*|xterm*|rxvt*|screen)
# Bash Version < 5.3
PS1='${debian_chroot:+($debian_chroot)}${a[\#]-$(_exit_symbol)}${a[\#]+🎱⟫}${a[\#]=}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
'
# Bash Version >= 5.3 # TODO: Verify escapes
#PS1='$(__exit_symbol_53)${|PS1_HISTCMD=$HISTCMD;}⟫${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$
'
# Default
#PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
PROMPT_DIRTRIM=2
```