🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #41

Re: PS1 wishes

#41
From: Thomas Thyberg
Date: Thu, 22 Jun 1989 12:21
75 lines
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
Technical Details
Message-ID: <427@helios.prosys.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!liuida!prosys!thomas
References: <89Jun20.215016edt.11717@neat.ai.toronto.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!liuida!prosys!thomas
From: thomas@helios.prosys.se (Thomas Thyberg)
Newsgroups: gnu.bash.bug
Subject: Re: PS1 wishes
Message-ID: <427@helios.prosys.se>
Date: 22 Jun 89 12:21:03 GMT
References: <89Jun20.215016edt.11717@neat.ai.toronto.edu>
Organization: Programsystem AB, Linkoping, SWEDEN
Lines: 75