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,19 +23,11 @@ case "$TERM" in
export TERM="xterm-256color" export TERM="xterm-256color"
;; ;;
esac esac
if [ -n "$TMUX" ] || [ "${TERMCAP#*screen}" != "${TERMCAP}" ]; then [ -n "$BYOBU_CHARMAP" ] || BYOBU_CHARMAP=$(locale charmap 2>/dev/null || echo)
# Ensure that we're in bash or ash, in a byobu environment [ -z "$USER" ] && export USER=$(whoami)
if [ -n "$BYOBU_BACKEND" ] && [ -n "$BASH" ] || [ "$SHELL" = "/bin/ash" ]; then byobu_prompt_status() { local e=$?; [ $e != 0 ] && echo -e " $e "; }
byobu_prompt_status() { local e=$?; [ $e != 0 ] && echo -e " $e "; } byobu_prompt_symbol() { [ "$USER" = "root" ] && printf "%s" "#" || printf "%s" "\$"; }
[ -n "$BYOBU_CHARMAP" ] || BYOBU_CHARMAP=$(locale charmap 2>/dev/null || echo) case "$BYOBU_DISTRO" in
byobu_prompt_symbol() {
if [ "$USER" = "root" ]; then
printf "%s" "#";
else
printf "%s" "\$"
fi
}
case "$BYOBU_DISTRO" in
"Ubuntu") "Ubuntu")
# Use Ubuntu colors (grey / orange / aubergine) # Use Ubuntu colors (grey / orange / aubergine)
PS1="${debian_chroot:+($debian_chroot)}\[\e[38;5;202m\]\$(byobu_prompt_status)\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\w\[\e[00m\]\$(byobu_prompt_symbol) " PS1="${debian_chroot:+($debian_chroot)}\[\e[38;5;202m\]\$(byobu_prompt_status)\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\w\[\e[00m\]\$(byobu_prompt_symbol) "
@ -64,6 +56,4 @@ if [ -n "$TMUX" ] || [ "${TERMCAP#*screen}" != "${TERMCAP}" ]; then
# Use Googley colors (blue / red / yellow / blue / green / red ) # Use Googley colors (blue / red / yellow / blue / green / red )
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