🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Anders Ellefsrud Mon, 12 Jun 1989 18:14
Current directory in prompt
#1007
Author: Anders Ellefsrud
Date: Mon, 12 Jun 1989 18:14
49 lines
1667 bytes
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;
  	}
        
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