about summary refs log tree commit diff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-11-02 12:35:32 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-11-02 12:35:32 +0000
commit19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4 (patch)
tree3b66e84c8560e38fe7d13c2fb22b73decc43ded5 /Src/prompt.c
parentf3f81f0837e9c10ec9fd0808e8640ab8a23b7ba8 (diff)
downloadzsh-19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4.tar.gz
zsh-19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4.tar.xz
zsh-19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4.zip
16198: add %j prompt expansion and j test character for no. of jobs in prompt
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index d5df9d1ce..9b6edfcc6 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -202,7 +202,7 @@ static int
 putpromptchar(int doprint, int endchar)
 {
     char *ss, *tmbuf = NULL, *hostnam;
-    int t0, arg, test, sep;
+    int t0, arg, test, sep, j, numjobs;
     struct tm *tm;
     time_t timet;
     Nameddir nd;
@@ -286,6 +286,13 @@ putpromptchar(int doprint, int endchar)
 		    if (getegid() == arg)
 			test = 1;
 		    break;
+		case 'j':
+		    for (numjobs = 0, j = 1; j < MAXJOB; j++)
+			if (jobtab[j].stat && jobtab[j].procs &&
+		    	    !(jobtab[j].stat & STAT_NOPRINT)) numjobs++;
+		    if (numjobs >= arg)
+		    	test = 1;
+		    break;
 		case 'l':
 		    *bp = '\0';
 		    countprompt(bufline, &t0, 0, 0);
@@ -371,6 +378,14 @@ putpromptchar(int doprint, int endchar)
 		sprintf(bp, "%d", curhist);
 		bp += strlen(bp);
 		break;
+	    case 'j':
+		for (numjobs = 0, j = 1; j < MAXJOB; j++)
+		    if (jobtab[j].stat && jobtab[j].procs &&
+		    	!(jobtab[j].stat & STAT_NOPRINT)) numjobs++;
+		addbufspc(DIGBUFSIZE);
+		sprintf(bp, "%d", numjobs);
+		bp += strlen(bp);
+		break;
 	    case 'M':
 		queue_signals();
 		if ((hostnam = getsparam("HOST")))