anders@IFI.UIO.NO (Anders Ellefsrud) (06/13/89)
Following is a small hack to substitute ~ for $HOME in the prompt string. I use \~ (instead of \w) for this effect. anders@ifi.uio.no *** parse.y.orig Mon Jun 12 19:00:48 1989 --- parse.y Mon Jun 12 19:40:04 1989 *************** *** 1370,1375 **** --- 1370,1376 ---- \n CRLF \s the name of the shell \w the current working directory + \~ the current working directory with ~ substituted for $HOME \u your username \h the hostname \# the command number of this command *************** *** 1456,1461 **** --- 1457,1463 ---- } case 'w': + case '~': { /* We would like to use the value of $PWD, but it turns out that this could be a bad idea because the user could set PWD to *************** *** 1477,1482 **** --- 1479,1495 ---- temp = (char *)xmalloc (MAXPATHLEN); getwd (temp); #endif /* EFFICIENT */ + + if (c == '~') { + int idx; + if (t_string = get_string_value ("HOME")) { + idx = strlen(t_string); + if (idx > 1 && strncmp(temp, t_string, idx) == 0) { + temp[0] = '~'; + strcpy( temp + 1, temp + idx); + } + } + } goto add_string; }