Browse Source

Detect Ubuntu chroots and add info in zsh prompt.

Emmanuel Bouthenot 14 years ago
parent
commit
e0c5908cc5
1 changed files with 18 additions and 3 deletions
  1. 18 3
      .zsh.d/config.d/prompt.zsh

+ 18 - 3
.zsh.d/config.d/prompt.zsh

@@ -19,14 +19,29 @@ export PR_OS_NAME=$(uname -s)
 export PR_OS_ARCH=$(uname -m)
 export PR_OS_ARCH=$(uname -m)
 
 
 if [ -f /etc/debian_version ]; then
 if [ -f /etc/debian_version ]; then
+
+    # ugly way to detect Ubuntu chroots
+    LSB_NAME=$(egrep 'DISTRIB_(ID|CODENAME)' /etc/lsb-release 2>/dev/null \
+                | tr '\n' '=' | cut -d'=' -f2,4 | tr '=' ' ')
+
     if [ "$PR_OS_NAME" = "Linux" ]; then
     if [ "$PR_OS_NAME" = "Linux" ]; then
-        PR_OS_NAME="debian $(</etc/debian_version)"
+        PR_OS_NAME="Debian $(</etc/debian_version)"
     else
     else
-        PR_OS_NAME="debian/${PR_OS_NAME} $(</etc/debian_version)"
+        PR_OS_NAME="Debian/${PR_OS_NAME} $(</etc/debian_version)"
     fi
     fi
     if [ -f /etc/debian_chroot ]; then
     if [ -f /etc/debian_chroot ]; then
-        PR_OS_NAME="${PR_OS_NAME} ${PR_LIGHT_RED}chroot:${PR_WHITE}$(</etc/debian_version)"
+        if [ -n "$LSB_NAME" ]; then
+            PR_OS_NAME="${PR_OS_NAME} ${PR_LIGHT_RED}chroot:${PR_WHITE}$LSB_NAME"
+        else
+            PR_OS_NAME="${PR_OS_NAME} ${PR_LIGHT_RED}chroot:${PR_WHITE}Debian $(</etc/debian_version)"
+        fi
+    else
+        if [ -n "$LSB_NAME" ]; then
+            PR_OS_NAME="$LSB_NAME"
+        fi
     fi
     fi
+
+    unset LSB_NAME
 fi
 fi
 PR_OS_NAME="${PR_OS_NAME} ${PR_OS_ARCH}"
 PR_OS_NAME="${PR_OS_NAME} ${PR_OS_ARCH}"