lamy@ai.utoronto.ca (Jean-Francois Lamy) (06/21/89)
\w should turn the leading part of the prompt into ~ if it matches the user's home directory; I think I know that it /homes/neat/car/lamy by now. also, I would like a tcsh-like option to display only the base name of the current directory (I hate starting to type at column 40 :-) Finally, I think ksh allows for commands to be executed within the prompt, something like PS1='`basename \w`' would be cute :-)
thomas@helios.prosys.se (Thomas Thyberg) (06/22/89)
In article <89Jun20.215016edt.11717@neat.ai.toronto.edu> lamy@ai.utoronto.ca (Jean-Francois Lamy) writes: >also, I would like a tcsh-like option to display only the base name of the >current directory (I hate starting to type at column 40 :-) > Here is my addition to the decode_prompt_string(). I have added \W which inserts the trailing component of cwd. It's like %c or %. in tcsh. I.E. PWD=/usr/foo/bar \W -> "bar" You need to apply Anders Ellefsrud's patch for \~ before you can apply mine. *** parse.y.orig Wed Jun 14 10:28:01 1989 --- parse.y Wed Jun 14 10:31:43 1989 *************** *** 1367,1372 **** --- 1367,1373 ---- \n CRLF \s the name of the shell \w the current working directory + \W the tail of current working directory \~ the current working directory with ~ substituted for $HOME \u your username \h the hostname *************** *** 1453,1458 **** --- 1454,1460 ---- goto add_string; } + case 'W': case 'w': case '~': { *************** *** 1477,1483 **** getwd (temp); #endif /* EFFICIENT */ ! if (c == '~') { int idx; if (t_string = get_string_value ("HOME")) { idx = strlen(t_string); --- 1479,1485 ---- getwd (temp); #endif /* EFFICIENT */ ! if (c == '~' || c == 'W') { int idx; if (t_string = get_string_value ("HOME")) { idx = strlen(t_string); *************** *** 1486,1491 **** --- 1488,1499 ---- strcpy( temp + 1, temp + idx); } } + if (c == 'W') { + char *p; + + if (p = (char *)strrchr(temp, '/')) + strcpy(temp, p + 1); + } } goto add_string; } -- Thomas Thyberg INET : thomas@prosys.se Programsystem AB UUCP : ...!{uunet,mcvax}!sunic!prosys!thomas Teknikringen 2A PHONE: +46 (0)13 21 40 40 S-583 30 Linkoping, Sweden FAX : +46 (0)13 21 36 35