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

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 ....

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

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1997-09-14 23:14 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 [this message]
1997-09-15  3:02         ` Adam R. Paul
     [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=970914160910.ZM23900@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=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).