Jobs Prompt

Torben wrote to me to suggest this prompt. He says he sometimes forgets that he has suspended jobs, so he uses the prompt to remind him how many he has. Due to a known bug in Bash 2.02, this won't work if you're using that version: all other versions should be fine. This prompt doesn't distinguish between running and stopped jobs, a second version that does is included below. jobs is a Bash builtin, so to get information on it type help jobs at the Bash prompt.

Code:

#!/bin/bash

function jobcount {
   jobs | wc -l | tr -d " "
}

PS1='\u@\h \W[$(jobcount)]\$ '

Code:

#!/bin/bash

function jobcount {
   stopped="$(jobs -s | wc -l | tr -d " ")"
   running="$(jobs -r | wc -l | tr -d " ")"
   echo -n "${running}r/${stopped}s"
}

PS1='\u@\h \W[$(jobcount)]\$ '

https://gilesorr.org/bashprompt/prompts/jobs.html 
by giles