. /etc/profile.d/bash_colors
[ -f /etc/ps1.conf ] && . /etc/ps1.conf
[ $(id -u) -eq 0 ] && { _c=$red; _cz=red; } || { _c=$blue; _cz=blue; }
if [ -n "$ZSH_VERSION" ]; then _shell=zsh
elif [ -n "$BASH_VERSION" ]; then _shell=bash
else
	_shell=${0##*/}; _shell=${_shell#-}
	case "$_shell" in
		*sh) ;;
		*) _shell=; [ -r /proc/$$/comm ] && read _shell < /proc/$$/comm ;;
	esac
	: "${_shell:=sh}"
fi
_inct=$container
[ -z "$_inct" ] && [ -n "$PS1_SYSTEM" ] && _inct=$PS1_SYSTEM
_chroot=
_cmp=
[ -r /proc/1/root ] && {
	_r1=$(stat -Lc '%d:%i' /proc/1/root 2>/dev/null)
	_r0=$(stat -c '%d:%i' / 2>/dev/null)
	[ -n "$_r0" ] && [ -n "$_r1" ] && {
		_cmp=done
		[ "$_r0" != "$_r1" ] && _chroot=chroot
	}
}
[ -z "$_cmp" ] && [ -z "$_inct" ] && [ -r /proc/self/mountinfo ] && {
	_mi=$(awk '$5=="/" {print $4; exit}' /proc/self/mountinfo 2>/dev/null)
	[ -n "$_mi" ] && [ "$_mi" != "/" ] && _chroot=chroot
}
[ -r /etc/debian_chroot ] && {
	_dc=$(tr -cd 'A-Za-z0-9._-' < /etc/debian_chroot 2>/dev/null | cut -c1-32)
	[ -n "$_dc" ] && _chroot=$_dc
}
_priv=
[ -n "$_inct" ] && {
	_sys=${PS1_SYSTEM:-$_inct}
	[ "$_inct" = "lxc" ] && [ -z "$PS1_SYSTEM" ] && _sys=incus
	_uidmap=$(awk '{print $2; exit}' /proc/self/uid_map 2>/dev/null)
	[ "${_uidmap:-1}" -eq 0 ] && { _priv=priv; _pc_b=$purple; _pc_z=magenta; } || { _priv=unpriv; _pc_b=$cyan; _pc_z=cyan; }
}
PS1_BASH=""; PS1_ZSH=""
_add() { PS1_BASH="$PS1_BASH$1"; PS1_ZSH="$PS1_ZSH$2"; }
[ -n "$PS1_HOST" ] && _add "$red$PS1_HOST$white::" "%F{red}$PS1_HOST%f::"
[ -n "$_priv" ] && _add "$green$_sys$white<${_pc_b}$_priv$white>:" "%F{green}$_sys%f<%F{${_pc_z}}$_priv%f>:"
[ -n "$_chroot" ] && _add "${yellow}($_chroot)$white " "%F{yellow}($_chroot)%f "
_add "" "%B%F{${_cz}}%(?..%? )%f%b"
_add "${_c}\u${white}" "%B%F{${_cz}}%n%f%b"
_add "@\h " "@%m "
_add "${blue}\w " "%B%F{blue}%40<..<%~%<< %f"
_add "${white}|${yellow}${_shell}${white}| " "|%F{yellow}${_shell}%f| "
[ -n "$_priv" ] && _add "# " "%f%b%# " || _add "\\$ " "# "
export PS1_BASH PS1_ZSH
unset _c _cz _shell _inct _chroot _cmp _r0 _r1 _mi _dc _priv _sys _uidmap _pc_b _pc_z
unset -f _add
