From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7771 invoked by alias); 28 Sep 2010 17:10:34 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15436 Received: (qmail 9942 invoked from network); 28 Sep 2010 17:10:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) Date: Tue, 28 Sep 2010 10:03:40 +0200 From: Frank Terbeck To: zsh-users@zsh.org Subject: Re: _git Completion and custom commands Message-ID: <20100928080340.GJ9720@fsst.voodoo.lan> Mail-Followup-To: zsh-users@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Df-Sender: 430444 Benjamin R. Haskell : [...] >> The one issue I've found is that the _git completion function (as of >> 4.3.10 shipped with Debian testing) does not include custom commands >> (though it does include aliases). [...] > zstyle ':completion:*:git:*' user-commands ${${(k)commands[(I)git-*]}#git-} Yes, this is explained at the top of the _git completion file. Here's a little more: The basic idea is that you can list your own git commands in the `user-commands' style. And generally you're allowed to provide a description for each command, too. So, say you've got a program `git-foo', you can do this: % zstyle ':completion:*:*:git:*' user-commands \ foo:'solves the question about the universe' Now completing `git fo' results in a menu such as this (depending on how compsys is configured, of course): % % git fo - git command - foo -- solves the question about the universe for-each-ref -- output information on each ref format-patch -- prepare patches for e-mail submission Now, if you want smartness, when you try `git foo ' you may write a function `_git-foo()' and _git will pick it up. So, if your `git-foo' program supports a few options (-f, -v and -q), a completion function may look like this: function _git-foo() { _arguments \ '-f[force stuff]' \ '-v[be verbose]' \ '-q[be quiet]' && ret=0; } With this, typing `git foo -' results in this menu: % git foo - - option - -f -- force stuff -q -- be quiet -v -- be verbose This can become as complicated as you like. :) The `style' line Benjamin gave sets the `user-commands' style to a list of all `git-*' commands zsh finds in $PATH. It's useful if you got a *lot* of own scripts. Since zsh cannot guess a description for the programs this way, commands added like that will be missing descriptions. Regards, Frank PS: If the OP didn't configure compsys yet, then may serve him as a quickstart. I'll certainly help to get menus such as the ones I mentioned above.