Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: git --pretty completion, and (new) completion for npm
- X-seq: zsh-workers 28931
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: Johan Sundström <oyasumi@xxxxxxxxx>
- Subject: Re: PATCH: git --pretty completion, and (new) completion for npm
- Date: Sun, 20 Mar 2011 11:35:25 +0100
- Cc: zsh-workers@xxxxxxx
- In-reply-to: <AANLkTi=Evf1nLVkKF9pr0t_hdzuTXJNi0nA6bcD9KBdT@mail.gmail.com> ("Johan Sundström"'s message of "Sun, 13 Mar 2011 23:38:34 -0700")
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <AANLkTi=Evf1nLVkKF9pr0t_hdzuTXJNi0nA6bcD9KBdT@mail.gmail.com>
Johan Sundström wrote:
[...]
> I took to adding documented completion for to the git completer for syntax that
> is impossible to remember and hard to find in the man page; git log --pretty
> (and whichever other commands support --pretty / --format) now covers the whole
> lot except %w, which seemed like it would need a whole little state machine in
> itself.
Hm. This only works for stuff directly after the `=', doesn't it? As in:
% git log -1 --pretty=%<tab>
But not in:
% git log -1 --pretty="%H %<tab>
That would be pretty useful, don't you think?
Also, you can cancel out the use of sed(1) from the code:
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index d65362e..ef4f263 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5550,8 +5550,7 @@ __git_setup_pretty_aliases () {
aliases=()
for spec in $(git config --get-regexp '^pretty\.' 2>/dev/null); do
name="${${spec#pretty.}/ */}"
- pfmt="${spec#pretty.$name }"
- pfmt="$(sed 's_\([]:["]\)_\\\1_g' <<<"$pfmt")" # escapes ], :, [, and "
+ pfmt="${${spec#pretty.$name }//(#b)([]:[\"])/\\\\${match[1]}}"
aliases+=(${name}'\:"git config alias for\: '${pfmt}'"')
done
pretty_aliases="${(pj:\n:)aliases}"
...which would save a fork().
Regards, Frank
PS: I've just committed the _npm completion from the message I'm
replying to.
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by:
Reverse Date,
Date,
Thread,
Author