Distrobox Zsh Prompt

· josephmr's blog


This is a simple prompt addition so that it is obvious what distrobox container (if any) you are operating inside of:

 1function get_distrobox_name() {
 2  if [ -f /run/.toolboxenv ]; then
 3    echo $CONTAINER_ID
 4  else
 5    echo ""
 6  fi
 7}
 8
 9# Add distrobox name to prompt
10if [ -n "$(get_distrobox_name)" ]; then
11  PROMPT='%{$fg[yellow]%}[$(get_distrobox_name)]%{$reset_color%} '$PROMPT
12fi

Here is it in action on a baseline oh-my-zsh theme inside a distrobox named "dev":

distrobox zsh prompt

last updated: