Hi,
The following substitutes '~' for $HOME in the \W prompt case, taken
from \w. This matches bash's behavior for \W.
OK?
Cheers,
Okan
Index: ksh.1
===================================================================
RCS file: /home/open/anoncvs/cvs/src/bin/ksh/ksh.1,v
retrieving revision 1.138
diff -u -p -r1.138 ksh.1
--- ksh.1 20 Sep 2010 07:41:17 -0000 1.138
+++ ksh.1 8 Mar 2011 08:42:53 -0000
@@ -1622,6 +1622,9 @@ is abbreviated as
.It Li \eW
The basename of
the current working directory.
+.Dv $HOME
+is abbreviated as
+.Sq ~ .
.It Li \e!
The current history number.
An unescaped
Index: lex.c
===================================================================
RCS file: /home/open/anoncvs/cvs/src/bin/ksh/lex.c,v
retrieving revision 1.44
diff -u -p -r1.44 lex.c
--- lex.c 3 Jul 2008 17:52:08 -0000 1.44
+++ lex.c 8 Mar 2011 08:38:52 -0000
@@ -1324,7 +1324,16 @@ dopprompt(const char *sp, int ntruncate,
break;
case 'W': /* '\' 'W' basename(cwd) */
p = str_val(global("PWD"));
- strlcpy(strbuf, basename(p), sizeof strbuf);
+ n = strlen(str_val(global("HOME")));
+ if (strcmp(p, str_val(global("HOME"))) == 0) {
+ strbuf[0] = '~';
+ strbuf[1] = '\0';
+ } else if (strncmp(p, str_val(global("HOME")),
n)
+ == 0 && p[n] == '/') {
+ snprintf(strbuf, sizeof strbuf, "~/%s",
+ str_val(global("PWD")) + n + 1);
+ } else
+ strlcpy(strbuf, basename(p), sizeof
strbuf);
break;
case '!': /* '\' '!' history line number */
snprintf(strbuf, sizeof strbuf, "%d",