zsh-users
 help / color / mirror / code / Atom feed
From: "Adam R. Paul" <adamp@sco.com>
To: zsh <zsh-users@math.gatech.edu>
Subject: Re: multiple background jobs of the same program
Date: Sun, 14 Sep 1997 20:02:02 -0700	[thread overview]
Message-ID: <19970914200202.04363@sco.com> (raw)
In-Reply-To: <970914160910.ZM23900@candle.brasslantern.com>; from Bart Schaefer on Sun, Sep 14, 1997 at 04:09:10PM -0700

It would appear that on Sun, Sep 14, 1997 at 04:09:10PM -0700, Bart Schaefer wrote:
> On Sep 14,  3:05pm, Adam R. Paul wrote:
> } Subject: Re: multiple background jobs of the same program
> }
> } > Replace the `#' with `;:'.  This works best if you have menu completion
> } > so that the `;' isn't interpreted as a command separator until after you
> } > have a chance to cycle through all the possibilities.
> } 
> } Hmm, it doesn't appear to work at all unless menu_complete is set :(  
> 
> I use automenu, not menucomplete, and it's OK there ....

Hmm, I think I'm using automenu too (its not set explicitly, but it does
show up in my 'unsetopt' completion (which completes on set options), and 
not in my 'setopt' completion (which completes on unset options:) )

> However, it works for me with autolist and listambiguous, at least as far
> as getting the listing:
> 
> zagzig[37] fg <TAB>
> %1 ;: vim fo       %2 ;: info -f zsh  %3 ;: vim bar
> zagzig[37] fg %
> 
> At this point if I hit TAB again I get a beep, and if I supply (say) the
> digit 1 and then hit TAB I encounter what must be a completion bug:
> 
> zagzig[37] fg %1<TAB>
> zagzig[37] fg %^@1
> %1 ;: vim fo       %2 ;: info -f zsh  %3 ;: vim bar
> zagzig[37] fg %
> 
> That ^@ in there is a nul byte that zsh is incorrectly inserting.  It then
> gets erased by compctl -U, but it shouldn't be there to begin with.
> 
> Anyway, the ;: has nothing to do with this particular problem -- get rid of
> the -U if you don't use automenu or menucomplete, and things should be much
> better.
> 
> I just played around with this a bit and discovered that you don't need -U
> at all as long as reply is an empty array (rather than an array containing
> the empty string) when there are no jobs -- which you can do by testing
> whether "jobs" produced any output before running the "sed".  See below.
> 
> } > Either remove the temp file or use >| so `setopt clobber' isn't needed.
> } 
> } I'd love to not use a temp file, but it appears that piping 'jobs' output
> 
> No, I didn't mean don't use the temp file; I meant end the function with
> "rm /tmp/._zshjobcomp.$$".
> 
> Anyway, to summarize:
> 
> listjobs() {
>   jobs >| /tmp/._zshjobcomp.$$ 2>&1
>   if [[ -s /tmp/._zshjobcomp.$$ ]]
>   then
>    reply=( "${(@f)$(sed -e '{
>     s/.\(....\).............\(.*\)/%\1 ;: \2/g
>     s/\]//g
>     s/  */ /g
>     }' /tmp/._zshjobcomp.$$)}" )
>   else
>    reply=()
>   fi
> }
> 
> compctl -Q -K listjobs fg bg kill

Thanks much again!  That's _almost_ perfect :)  The only remaining thing is
that if a job is suspended due to tty output/input, the sed script doesn't
quite do the right thing (the completion looks like:

fg %1 ;: tty output) vi foo

which then gives a parse error if you hit <return> due to the unmatched ')'.
Oh well, no biggie:)


Thanks again, Bart,
	_Adam

-----
Adam R. Paul    - adamp@sco.com 
SCO Engineering - #include <stddisclaimer.h>

Nshiaththao.  Thcolkathsh iont eth n'aathtaghaa kgandu ouaiaaphu thbakggaghn.  


  reply	other threads:[~1997-09-15  3:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-14  3:26 Jose Unpingco
1997-09-14 17:28 ` Adam R. Paul
1997-09-14 19:10   ` Bart Schaefer
1997-09-14 22:05     ` Adam R. Paul
1997-09-14 23:09       ` Bart Schaefer
1997-09-15  3:02         ` Adam R. Paul [this message]
     [not found]           ` <5len6q9692.fsf@tequila.systemsz.cs.yale.edu>
     [not found]             ` <5ld8ma95sf.fsf@tequila.systemsz.cs.yale.edu>
1997-09-15 14:56               ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19970914200202.04363@sco.com \
    --to=adamp@sco.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).