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

POSTPROMPT patches



I've included patches to add a new variable, $POSTPROMPT, which, if set,
outputs a prompt after it parses the command line.  The patch also adds %H
to the prompt substitution characters, where %H means the last history
line.

The patch probably isn't perfect, and maybe someone can improve it for
inclusion in zsh-3.0, whenever that's set for release.

Recommended use of the patch is with XTERM, to set:

export POSTPROMPT='%{^[]0;%H^G%}'

which uses XTERM escape sequences to set the title bar to the currently
executing command; especially useful for longer-running commands.

I'm just now joining the zsh-workers list, so I apologize if I've missed
the boat in any way.

Greg J. Badros
gjb@xxxxxxxxxxx
*** 1.1	1996/07/29 01:39:01
--- globals.h	1996/07/29 01:39:09
***************
*** 329,334 ****
--- 329,335 ----
  EXTERN char *prompt2;		/* etc.        */
  EXTERN char *prompt3;
  EXTERN char *prompt4;
+ EXTERN char *postprompt;	/* $POSTPROMPT */
  EXTERN char *rprompt;		/* $RPROMPT    */
  EXTERN char *sprompt;
  
*** 1.1	1996/07/29 01:32:30
--- hashtable.h	1996/07/29 01:34:27
***************
*** 139,144 ****
--- 139,145 ----
  IPDEF7("PS2", &prompt2),
  IPDEF7("PS3", &prompt3),
  IPDEF7("PS4", &prompt4),
+ IPDEF7("POSTPROMPT", &postprompt),
  IPDEF7("RPS1", &rprompt),
  IPDEF7("SPROMPT", &sprompt),
  IPDEF7("0", &argzero),
*** 1.1	1996/07/29 01:31:43
--- init.c	1996/07/29 02:03:09
***************
*** 515,520 ****
--- 515,521 ----
  	prompt3 = ztrdup("");
  	prompt4 = ztrdup("");
      }
+     postprompt = ztrdup("");
      sprompt = ztrdup("zsh: correct '%R' to '%r' [nyae]? ");
  
      if (!(ttystrname = ztrdup(ttyname(SHTTY))))
*** 1.1	1996/07/29 01:34:51
--- parse.c	1996/07/29 02:26:47
***************
*** 119,124 ****
--- 119,132 ----
      } else {
  	l->right = par_event();
      }
+     /* gjb added */
+     if (interact && postprompt != 0 && *postprompt != NULL) {
+ 	int plen=0;
+         curhist++;
+ 	fwrite(putprompt(postprompt,&plen,NULL,0), sizeof(char), plen, stderr);
+ 	fflush(stderr);
+         curhist--;
+     }
      return l;
  }
  
*** 1.1	1996/07/29 01:35:27
--- zle_misc.c	1996/07/29 03:04:27
***************
*** 1030,1035 ****
--- 1030,1044 ----
  		    ss++;
  		stradd(ss);
  		break;
+ 	    case 'H':
+ 		if (curhist > 0) {
+ 		    int cch;
+ 		    char *sz = quietgetevent(curhist-1);
+ 		    cch = strlen(sz) - 1;
+ 		    strncpy(bp,sz,cch);
+ 		    bp += cch;
+ 		}
+ 		break;
  	    case 'h':
  	    case '!':
  		addbufspc(DIGBUFSIZE);


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