Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: git --pretty completion, and (new) completion for npm



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