chiark / gitweb /
dot/shell-rc: If terminal is `dumb' then use vanilla prompts.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 16 Nov 2017 12:25:12 +0000 (12:25 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 16 Nov 2017 12:25:12 +0000 (12:25 +0000)
This avoids confusing Emacs's `TRAMP' facility.

dot/shell-rc

index 5c3c3367615b62e4308ec3da7f160bbe73d9d04c..4538bc393f8d3afa737bcd1679d41f70ee6dbb6f 100644 (file)
@@ -74,20 +74,28 @@ __mdw_set_prompt_pieces () {
 }
 
 __mdw_set_prompt () {
 }
 
 __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" 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 $bold>$unbold "
+      unset __mdw_last_rc
+      ;;
   esac
   esac
-  PS1="$__mdw_prompt_left$git$rc$__mdw_prompt_right"
-  PS2="$PS1 $bold>$unbold "
-  unset __mdw_last_rc
 }
 
 __mdw_precmd () {
 }
 
 __mdw_precmd () {