Thread View: gnu.bash.bug
2 messages
2 total messages
Started by Jean-Francois Lamy
Wed, 21 Jun 1989 01:50
PS1 wishes
Author: Jean-Francois Lamy
Date: Wed, 21 Jun 1989 01:50
Date: Wed, 21 Jun 1989 01:50
8 lines
678 bytes
678 bytes
\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 :-)
Re: PS1 wishes
Author: Thomas Thyberg
Date: Thu, 22 Jun 1989 12:21
Date: Thu, 22 Jun 1989 12:21
75 lines
2363 bytes
2363 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads