From: "Bart Schaefer" <schaefer@brasslantern.com>
To: "Adam R. Paul" <adamp@sco.com>, zsh <zsh-users@math.gatech.edu>
Subject: Re: multiple background jobs of the same program
Date: Sun, 14 Sep 1997 12:10:42 -0700 [thread overview]
Message-ID: <970914121042.ZM22784@candle.brasslantern.com> (raw)
In-Reply-To: <19970914102839.45957@sco.com>
On Sep 14, 10:28am, Adam R. Paul wrote:
} Subject: Re: multiple background jobs of the same program
}
} setopt interactive_comments
}
} listjobs() {
} jobs > /tmp/._zshjobcomp.$$ 2>&1
} set -A reply
} OIFS="$IFS"
} IFS='
} '
} reply=( $(sed -e '{
} s/.\(....\).............\(.*\)/\1 # \2/g
} s/\]//g
} s/ */ /g
} }' /tmp/._zshjobcomp.$$) )
} IFS="$OIFS"
} }
}
} compctl -P % -K listjobs fg
}
} The only problem is that zsh is escaping the spaces & #'s that result
Change it to
compctl -Q -P % -K listjobs fg
} Also, I don't really want
} interactive_comments set all the time
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.
} Any improvements?
Either remove the temp file or use >| so `setopt clobber' isn't needed.
You don't need `set -A reply'.
Don't change IFS, use "${(@f)...}" to interpret each line as a word.
Have listjobs insert the leading % instead of using -P, and use -U to
cause the line so far to be replaced by the completion. Then when there
are no possible completions (no jobs), nothing gets inserted. (Your
original inserts "% " when there are no jobs.)
Do the completion for `bg' and `kill', too.
} I suspect that the sed bit could be replaced by some neato
} zsh internal parameter mangling stuff
Since you're doing several substitutions and already reading from a file,
I don't think that's worth it.
Finished product:
listjobs() {
jobs >| /tmp/._zshjobcomp.$$ 2>&1
reply=( "${(@f)$(sed -e '{
s/.\(....\).............\(.*\)/%\1 ;: \2/g
s/\]//g
s/ */ /g
}' /tmp/._zshjobcomp.$$)}" )
}
compctl -U -Q -K listjobs fg bg kill
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
next prev parent reply other threads:[~1997-09-14 20:16 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 [this message]
1997-09-14 22:05 ` Adam R. Paul
1997-09-14 23:09 ` Bart Schaefer
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=970914121042.ZM22784@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).