# If not running interactively, don't do anything
[[ $- != *i* ]] && return

if command -v dircolors >/dev/null 2>&1; then
    eval "$(dircolors)"
fi
alias ls='ls --color=auto'
alias ll='ls --color=auto -l'
alias l='ls --color=auto -lA'

DISTRO='unknown'

# Generic distro check.
if [[ -r /etc/os-release ]]; then
    . /etc/os-release
    DISTRO=${ID:-unknown}
fi

# Proxmox uses Debian's /etc/os-release, try checking if it has a folder in the ESP.
if [[ -d /boot/efi/EFI/proxmox ]]; then
    DISTRO='proxmox'
fi

case "$DISTRO" in
    proxmox|ubuntu)
        DISTRO_COLOR='\[\e[38;5;208;3;4m\]'
        ;;
    debian)
        DISTRO_COLOR='\[\e[38;5;160;3;4m\]'
        ;;
    void)
        DISTRO_COLOR='\[\e[38;5;28;3;4m\]'
        ;;
    *)
        DISTRO_COLOR='\[\e[3;4m\]'
        ;;
esac

HOST_COLOR='\[\e[38;5;99m\]'

if [[ $EUID -eq 0 ]]; then
    USER_COLOR='\[\e[38;5;160m\]'
    PROMPT_COLOR='\[\e[1;38;5;160m\]'
else
    USER_COLOR='\[\e[38;5;33m\]'
    PROMPT_COLOR='\[\e[0;1m\]'
fi

PS1="${USER_COLOR}"'\u\[\e[0m\]@'"${HOST_COLOR}"'\h\[\e[0m\]:\[\e[38;5;219;3m\]\w\[\e[0m\] '"${DISTRO_COLOR}${DISTRO:-unknown}"'\[\e[0m\]'"${PROMPT_COLOR}"'\$\[\e[0m\] '
