chiark / gitweb /
dot/shell-rc: Notice `$MDW_BUILDENV' and add it to the prompt.
[profile] / dot / shell-rc
index 11b9fc7f8e04296eeae7ba8acf116c0db337eb3f..975410649ed39b758c32fa1e94f23dcb8524dbf6 100644 (file)
@@ -14,10 +14,6 @@ __mdw_source_if_exists () {
   done
 }
 
-## Set the temporary directory again.  (A setuid or setgid program may have
-## unhelpfully forgotten this for us.)
-case ${TMPDIR+t} in t) ;; *) eval $(tmpdir -b); esac
-
 ###--------------------------------------------------------------------------
 ### Prompt machinery.
 
@@ -29,15 +25,15 @@ __mdw_set_prompt_pieces () {
 
   ## Fancy highlighting in some terminals.
   local bold unbold nl gitcolour rccolour uncolour
-  local host dir
-  bold="" unbold="" nl="" gitcolour="" rccolour="" uncolour=""
+  local host dir more
+  bold="" unbold="" nl="" gitcolour="" rccolour="" uncolour="" more=""
   __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 user u tty
-  user=${USER-$LOGNAME}
+  user=${USER-${LOGNAME-$(id -un)}}
   case $(id -u) in
     0)
       left=$(echo « | iconv -f UTF-8 -t //translit)
@@ -65,8 +61,10 @@ __mdw_set_prompt_pieces () {
     *) sec_l="" sec_r=""
   esac
 
-  ## If this is an schroot environment then point this out.
+  ## If this is an schroot environment or some other interesting augmented
+  ## environment then point this out.
   hqual="$hqual${SCHROOT_CHROOT_NAME+/$SCHROOT_CHROOT_NAME}"
+  hqual="$hqual${MDW_BUILDENV+/$BUILDENV}"
 
   ## Put together the main pieces.
   __mdw_prompt_left="$nl$bold$left$sec_l$u$host$hqual$sec_r$dir"
@@ -75,23 +73,32 @@ __mdw_set_prompt_pieces () {
   __mdw_prompt_rc_left="$unbold$rccolour"
   __mdw_prompt_rc_right="$uncolour$bold"
   __mdw_prompt_right="$right$unbold"
+  __mdw_prompt_more=" $more$bold>$unbold "
 }
 
 __mdw_set_prompt () {
-  __mdw_last_rc=$?
-  local git rc
-  if type __git_ps1 >/dev/null 2>&1; then
-    git="$__mdw_prompt_git_left$(__git_ps1)$__mdw_prompt_git_right"
-  else
-    git=""
-  fi
-  case $__mdw_last_rc in
-    0) rc="" ;;
-    *) rc="$__mdw_prompt_rc_left rc=$__mdw_last_rc$__mdw_prompt_rc_right" ;;
+  case "${TERM-dumb}:${INSIDE_EMACS+$INSIDE_EMACS}" in
+    dumb:)
+      case $(id -u) in 0) PS1='# ' ;; *) PS1='$ ' ;; esac
+      PS2='> '
+      ;;
+    *)
+      __mdw_last_rc=$?
+      local git rc
+      if type __git_ps1 >/dev/null 2>&1; then
+       git="$__mdw_prompt_git_left$(__git_ps1)$__mdw_prompt_git_right"
+      else
+       git=""
+      fi
+      case $__mdw_last_rc in
+       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"
+      PS2="$PS1$__mdw_prompt_more"
+      unset __mdw_last_rc
+      ;;
   esac
-  PS1="$__mdw_prompt_left$git$rc$__mdw_prompt_right"
-  PS2="$PS1 $bold>$unbold "
-  unset __mdw_last_rc
 }
 
 __mdw_precmd () {
@@ -125,6 +132,7 @@ alias pushtmp='pushd ${TMPDIR-/tmp}'
 alias e="$EDITOR"
 alias svn="svnwrap svn"
 alias @="ssh"
+alias make="nice make"
 
 ###--------------------------------------------------------------------------
 ### Colour output.
@@ -328,6 +336,16 @@ pathhack () {
 ###--------------------------------------------------------------------------
 ### Finishing touches.
 
+## Make sure `$HOME/bin' is on the path.
+path_add "$HOME/bin"
+
+## Set the temporary directory again.  (A setuid or setgid program may have
+## unhelpfully forgotten this for us.)
+case ${TMPDIR+t} in
+  t) ;;
+  *) if __mdw_programp tmpdir; then eval $(tmpdir -b); fi ;;
+esac
+
 ## For `root' use -- some simple molly-guards.
 case $(id -u) in
   0)