Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: pws-24: prompt escapes for script/function and lineno



Peter Stephenson wrote:

> OK, this makes sense --- %N:%i is certainly unambiguous, and `content over
> form' is the zsh motto.  (All right, that was a lie.)  It's already long
> enough when you have lines like
> 
> +/usr/local/lib/hepix/shells/site/aliases.sh:54> [ -r /u/theor/pubtheor/group_aliases.sh ]
> 
> being executed by zsh -f.

Why not share some code with `%c' and allow `%<number>N'? Hm, this
makes the default be only the last pathname-component, is that ok?
Does anyone want to see the whole path anyway?

Bye
 Sven

--- os/prompt.c	Fri Jul  2 09:04:05 1999
+++ Src/prompt.c	Fri Jul  2 14:57:46 1999
@@ -305,10 +305,13 @@
 		break;
 	    case 'c':
 	    case '.':
+	    case 'N':
 	        {
 		    char *t;
 
-		    if ((nd = finddir(pwd)))
+		    if (*fm == 'N')
+			t = ztrdup(scriptname ? scriptname : argzero);
+		    else if ((nd = finddir(pwd)))
 			t = tricat("~", nd->nam, pwd + strlen(nd->dir));
 		    else
 			t = ztrdup(pwd);
@@ -535,9 +538,6 @@
 		addbufspc(DIGBUFSIZE);
 		sprintf(bp, "%ld", (long)lineno);
 		bp += strlen(bp);
-		break;
-	    case 'N':
-		stradd(scriptname ? scriptname : argzero);
 		break;
 	    case '\0':
 		return 0;
diff -u od/Zsh/prompt.yo Doc/Zsh/prompt.yo
--- od/Zsh/prompt.yo	Tue Jun 29 12:51:33 1999
+++ Doc/Zsh/prompt.yo	Fri Jul  2 15:04:52 1999
@@ -98,7 +98,9 @@
 item(tt(%N))(
 The name of the script, sourced file, or shell function that zsh is
 currently executing, whichever was started most recently.  If there is
-none, this is equivalent to the parameter tt($0).
+none, this is equivalent to the parameter tt($0). As for `tt(%c)', an
+integer may follow the `tt(%)' to specify the number of trailing
+components that should be printed.
 )
 item(tt(%i))(
 The line number currently being executed in the script, sourced file, or

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author