dot/shell-rc, etc.: Introduce an easily user-definable prompt section.
[profile] / dot / shell-rc
index ee9161d..b65f63e 100644 (file)
@@ -67,27 +67,47 @@ __mdw_hqual=$__mdw_hqual${SCHROOT_CHROOT_NAME+/$SCHROOT_CHROOT_NAME}
 __mdw_hqual=$__mdw_hqual${CROSS_BUILDENV+/$CROSS_BUILDENV}
 __mdw_set_prompt_hacks () { host=$__mdw_host; dir=""; }
 
+__mdw_system=$(uname -s)
 : ${USER-${LOGNAME-$(id -un)}}
 __mdw_user=$USER
 
+case $(id -u) in
+  0)
+    __mdw_rootp=t
+    ;;
+  *)
+    case $__mdw_system in
+      CYGWIN_*)
+       case " $(id -G) " in
+         *" 544 "*) __mdw_rootp=t __mdw_user="$__mdw_user%admin" ;;
+         *) __mdw_rootp=nil ;;
+       esac
+       ;;
+      *)
+       __mdw_rootp=nil
+       ;;
+    esac
+esac
+
 __mdw_set_prompt_pieces () {
 
   ## Fancy highlighting in some terminals.
-  local bold unbold nl gitcolour rccolour uncolour
-  local host dir more
-  bold="" unbold="" nl="" gitcolour="" rccolour="" uncolour="" more=""
+  local bold unbold nl more host dir
+  local gitcolour extracolour rccolour uncolour
+  bold="" unbold="" nl="" more=""
+  gitcolour="" extracolour="" rccolour="" uncolour=""
   __mdw_set_prompt_hacks
 
   ## Choose the right delimiters.  Highlight root prompts specially;
   ## 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="}" ;;
@@ -118,6 +138,8 @@ __mdw_set_prompt_pieces () {
   __mdw_prompt_git_right="$uncolour$bold"
   __mdw_prompt_rc_left="$unbold$rccolour"
   __mdw_prompt_rc_right="$uncolour$bold"
+  __mdw_prompt_extra_left="$unbold$extracolour"
+  __mdw_prompt_extra_right="$uncolour$bold"
   __mdw_prompt_right="$right$unbold"
   __mdw_prompt_more=" $more$bold>$unbold "
 }
@@ -130,7 +152,7 @@ __mdw_set_prompt () {
       ;;
     *)
       __mdw_last_rc=$?
-      local git rc
+      local git extra rc
       if type __git_ps1 >/dev/null 2>&1; then
        git="$__mdw_prompt_git_left$(__git_ps1)$__mdw_prompt_git_right"
       else
@@ -140,7 +162,11 @@ __mdw_set_prompt () {
        0) rc="" ;;
        *) rc="$__mdw_prompt_rc_left rc=$__mdw_last_rc$__mdw_prompt_rc_right" ;;
       esac
-      PS1="$__mdw_prompt_left$git$rc$__mdw_prompt_right"
+      case $__mdw_prompt_extra in
+       ?*) extra="$__mdw_prompt_extra_left [$__mdw_prompt_extra]$__mdw_prompt_extra_right" ;;
+       *) extra="" ;;
+      esac
+      PS1="$__mdw_prompt_left$git$extra$rc$__mdw_prompt_right"
       PS2="$PS1$__mdw_prompt_more"
       unset __mdw_last_rc
       ;;
@@ -202,6 +228,16 @@ alias make="nice make"
 alias cross-run="nice cross-run"
 alias gdb="gdb -q"
 
+## Shut up Lisp interpreters.
+alias clisp="clisp -q -q"
+alias cmucl="rlwrap cmucl -quiet"
+alias ecl="rlwrap ecl"
+alias sbcl="rlwrap sbcl --noinform"
+alias ccl="rlwrap ccl"
+alias ccl32="rlwrap ccl32"
+alias ccl64="rlwrap ccl64"
+alias abcl="rlwrap abcl --noinform"
+
 ###--------------------------------------------------------------------------
 ### Colour output.