Linux – tcsh shell prompt to show unfinished jobs count

linuxprompttcsh

How do I make my tcsh shell prompt to show unfinished background jobs? I understand %j will tell me unfinished job number count but prompt goes stale if I keep it idle. Ideally, I would like prompt to get updated automatically. Basically, I want to avoid keep typing bjobs commands to check if all the jobs I submitted are completed.

Best Answer

set prompt = "%j %# "

This would set the prompt to the current number of background jobs, followed by > or # for root (unless promptchars has been changed from the default).

Testing it:

> set prompt = "%j %# "
0 > 

Then start a couple of background jobs:

0 > ls &
[1] 82556
1 > ls &
[2] 99869
[1]    Done                          ls
2 >
[2]    Done                          ls
2 >
2 >
2 >
2 >
2 >
2 >
2 >

As you see, the job count in the prompt is not updated when you just press Enter. It will be updated once you enter a new command though:

2 > ls
0 >
0 >

You mentioned bjobs. This is an LFS command and not related to tcsh at all. Please update the question with further information if this was intentional or not.

Related Question