zsh-users
 help / color / mirror / code / Atom feed
* A job signaller
@ 1998-10-29 13:36 Paolo Pumilia
  1998-10-29 13:58 ` Zefram
  1998-10-29 14:16 ` Alain Caron
  0 siblings, 2 replies; 4+ messages in thread
From: Paolo Pumilia @ 1998-10-29 13:36 UTC (permalink / raw)
  To: zsh-users

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 -


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A job signaller
  1998-10-29 13:36 A job signaller Paolo Pumilia
@ 1998-10-29 13:58 ` Zefram
  1998-10-29 18:19   ` Dan Nelson
  1998-10-29 14:16 ` Alain Caron
  1 sibling, 1 reply; 4+ messages in thread
From: Zefram @ 1998-10-29 13:58 UTC (permalink / raw)
  To: pumilia; +Cc: zsh-users

Paolo Pumilia wrote:
>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)

I use something like this:

precmd () {
  if jobs % >& /dev/null; then
    psvar=("")
  else
    psvar=()
  fi
}
PS1="%(1v:+:-)> "

-zefram


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A job signaller
  1998-10-29 13:36 A job signaller Paolo Pumilia
  1998-10-29 13:58 ` Zefram
@ 1998-10-29 14:16 ` Alain Caron
  1 sibling, 0 replies; 4+ messages in thread
From: Alain Caron @ 1998-10-29 14:16 UTC (permalink / raw)
  To: pumilia; +Cc: zsh-users

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@sangacorp.com
514-288-4498 ext. 225


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A job signaller
  1998-10-29 13:58 ` Zefram
@ 1998-10-29 18:19   ` Dan Nelson
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Nelson @ 1998-10-29 18:19 UTC (permalink / raw)
  To: Zefram, pumilia; +Cc: zsh-users

In the last episode (Oct 29), Zefram said:
> Paolo Pumilia wrote:
> >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)
> 
> I use something like this:
> 
> precmd () {
>   if jobs % >& /dev/null; then
>     psvar=("")
>   else
>     psvar=()
>   fi
> }
> PS1="%(1v:+:-)> "

Note that a side-effect of this is that an "exit" will not warn you
that you have jobs running.  The "jobs" comand in the precmd() function
clears the variable that would cause the warning to be printed.

	-Dan Nelson
	dnelson@emsphone.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-10-29 18:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-29 13:36 A job signaller Paolo Pumilia
1998-10-29 13:58 ` Zefram
1998-10-29 18:19   ` Dan Nelson
1998-10-29 14:16 ` Alain Caron

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).