chiark / gitweb /
dot/shell-rc: Cache whether we're running as root.
[profile] / dot / shell-rc
index ee9161daaa65205b82715cbfa0e03c1af98d12dd..9857a82366888f826d44faa1072b4c0eb9cbbd3f 100644 (file)
@@ -70,6 +70,11 @@ __mdw_set_prompt_hacks () { host=$__mdw_host; dir=""; }
 : ${USER-${LOGNAME-$(id -un)}}
 __mdw_user=$USER
 
+case $(id -u) in
+  0) __mdw_rootp=t ;;
+  *) __mdw_rootp=nil ;;
+esac
+
 __mdw_set_prompt_pieces () {
 
   ## Fancy highlighting in some terminals.
@@ -82,12 +87,12 @@ __mdw_set_prompt_pieces () {
   ## highlight when I'm running as some other user.  Highlight when this
   ## isn't the outermost shell on the terminal.
   local left right u tty
-  case $(id -u) in
-    0)
+  case $__mdw_rootp in
+    t)
       left=$(echo « | iconv -f UTF-8 -t //translit)
       right=$(echo » | iconv -f UTF-8 -t //translit)
       ;;
-    *)
+    nil)
       case $USER in
        mdw | mwooding | nemo) u="" left="[" right="]" ;;
        *) u="$__mdw_user@" left="{" right="}" ;;