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

Re: A job signaller



Paolo Pumilia wrote:
> 
> Hi z-shell users,
> Is there a way to put a mark within the prompt string to
> inform the user that jobs are still running from that shell?
> (e.g +/-: "+" for running or stopped jobs; "-" for no jobs)
> 
> thank you for your suggestions
> 
> Paolo Pumilia
> 
> ---- cstc -

I use the following in my .zshrc

function precmd
{
  if jobs % >& /dev/null; then
    psvar=("*")
  else
    psvar=("")
  fi
}

PS1="%~ %!%1v> "

The precmd function is executed before printing a prompt. It checks
whether there are background jobs or not.
The %1v pattern in PS1 means to print the first element of the array
psvar.  If there background jobs, an asterisk is printed. Otherwise, an
empty string is printed.

It works fine for me.

You would just have to modify the precmd to check whether the jobs are
running or suspended and set psvar accordingly.

Regards,

Alain Caron
alainc@xxxxxxxxxxxxx
514-288-4498 ext. 225



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