chiark / gitweb /
dot/shrc: Put working directory into plain-sh prompts.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 8 Aug 2017 16:50:36 +0000 (17:50 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 8 Aug 2017 16:50:36 +0000 (17:50 +0100)
Apparently dash does process substitution on PS1.  Yay.

dot/shrc

index 90710dfb4cf22596d5da2ea01b5f2b4bfcb2c6e6..114cc23ac750ea42ab8d3e1fe2114e012ab8beee 100644 (file)
--- a/dot/shrc
+++ b/dot/shrc
@@ -16,7 +16,7 @@ __mdw_set_prompt_hacks () {
       ;;
   esac
   host=$(hostname)
-  dir=""
+  dir=' $(d=$(pwd); case "$d" in ("$HOME") d="~" ;; ("$HOME"/*) d="~${d#$HOME}" ;; esac; echo $d)'
 }
 
 __mdw_set_prompt_pieces