diff --git a/etc/bash.bashrc b/etc/bash.bashrc index b76f4ec..caa7c7f 100644 --- a/etc/bash.bashrc +++ b/etc/bash.bashrc @@ -6,29 +6,47 @@ ## Functions function __miaou_prompt_container { - if [[ -v CONTAINER_TYPE && -v CONTAINER_HOST ]]; then - [[ -v CONTAINER_PURPOSE ]] || CONTAINER_PURPOSE='development' - local bg_purpose fg_purpose - case "$CONTAINER_PURPOSE" in - prod | prd | production) - # red - bg_purpose=41 - fg_purpose=31 - ;; - beta | sta | stg | staging) - # yellow - bg_purpose=43 - fg_purpose=33 - ;; - *) - # green - bg_purpose=42 - fg_purpose=32 - ;; - esac - # ▶ alternative - PS1+="\[\e[100;37m\] ${CONTAINER_TYPE} \[\e[${bg_purpose};90m\]\[\e[30m\] ${CONTAINER_HOST} \[\e[49;${fg_purpose}m\]${R} " + if [[ -S /dev/incus/sock ]]; then + CONTAINER_TYPE=incus + elif [[ -S /dev/lxd/sock ]]; then + CONTAINER_TYPE=lxd + elif [[ $(hostnamectl chassis) == 'container' ]]; then + CONTAINER_TYPE=pve # FIXME: might also be docker! + else + return fi + + if [[ -f /etc/machine-info ]]; then + while IFS='=' read -r key value; do + case "$key" in + DEPLOYMENT) CONTAINER_DEPLOYMENT="$value" ;; + LOCATION) CONTAINER_LOCATION="$value" ;; + esac + done