drastically simplify the conditional logic

This commit is contained in:
Dustin Kirkland 2024-01-09 07:23:00 -06:00
commit 26528f1998
2 changed files with 37 additions and 46 deletions

3
debian/changelog vendored
View file

@ -2,8 +2,9 @@ byobu (6.5) unreleased; urgency=medium
* usr/share/byobu/profiles/bashrc: * usr/share/byobu/profiles/bashrc:
- drop debian chroot from wolfi ps1 - drop debian chroot from wolfi ps1
- drastically simplify the conditional logic
-- Dustin Kirkland <kirkland@ubuntu.com> Mon, 08 Jan 2024 21:31:05 -0600 -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 09 Jan 2024 07:22:34 -0600
byobu (6.4) released; urgency=medium byobu (6.4) released; urgency=medium

View file

@ -1,6 +1,6 @@
# byobu's bashrc -- colorize the prompt # byobu's bashrc -- colorize the prompt
# Copyright (C) 2014 Dustin Kirkland # Copyright (C) 2014 Dustin Kirkland
# Copyright (C) 2023 Dustin Kirkland # Copyright (C) 2023, 2024 Dustin Kirkland
# #
# Authors: Dustin Kirkland <kirkland@byobu.org> # Authors: Dustin Kirkland <kirkland@byobu.org>
# #
@ -23,18 +23,10 @@ case "$TERM" in
export TERM="xterm-256color" export TERM="xterm-256color"
;; ;;
esac esac
if [ -n "$TMUX" ] || [ "${TERMCAP#*screen}" != "${TERMCAP}" ]; then
# Ensure that we're in bash or ash, in a byobu environment
if [ -n "$BYOBU_BACKEND" ] && [ -n "$BASH" ] || [ "$SHELL" = "/bin/ash" ]; then
byobu_prompt_status() { local e=$?; [ $e != 0 ] && echo -e " $e "; }
[ -n "$BYOBU_CHARMAP" ] || BYOBU_CHARMAP=$(locale charmap 2>/dev/null || echo) [ -n "$BYOBU_CHARMAP" ] || BYOBU_CHARMAP=$(locale charmap 2>/dev/null || echo)
byobu_prompt_symbol() { [ -z "$USER" ] && export USER=$(whoami)
if [ "$USER" = "root" ]; then byobu_prompt_status() { local e=$?; [ $e != 0 ] && echo -e " $e "; }
printf "%s" "#"; byobu_prompt_symbol() { [ "$USER" = "root" ] && printf "%s" "#" || printf "%s" "\$"; }
else
printf "%s" "\$"
fi
}
case "$BYOBU_DISTRO" in case "$BYOBU_DISTRO" in
"Ubuntu") "Ubuntu")
# Use Ubuntu colors (grey / orange / aubergine) # Use Ubuntu colors (grey / orange / aubergine)
@ -65,5 +57,3 @@ if [ -n "$TMUX" ] || [ "${TERMCAP#*screen}" != "${TERMCAP}" ]; then
PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\[\e[00m\] " PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$(byobu_prompt_status)\[\e[38;5;69m\]\u\[\e[38;5;214m\]@\[\e[38;5;167m\]\h\[\e[38;5;214m\]:\[\e[38;5;71m\]\w\[\e[38;5;214m\]\$(byobu_prompt_symbol)\[\e[00m\] "
;; ;;
esac esac
fi
fi