[Pkg-zsh-devel] Bug#630906: git-annex completion gone missing

Frank Terbeck ft at bewatermyfriend.org
Wed Jun 29 22:12:23 UTC 2011


Joey Hess wrote:
> bash does not complete "git an<tab>", or "git annex ge<tab>"
> but it does complete "git annex get somefile<tab>" with filenames,
> which is all that's really needed.

Here is an update: Tonight I kicked the following series towards
zsh-workers:

  <http://www.zsh.org/mla/workers/2011/msg00954.html>


The first patch from that series pretty much gives you bash-like
behaviour out of the box, which should be enough to close this bug, once
it's included (I didn't commit any of the patches yet, but I will unless
someone complains loudly).


However, the second patch allows for a *lot* more: You can just drop a
`_git-annex' function file somewhere into `$fpath'. Then

  zsh% git a<tab>

would suggest `annex' as one of the possibilities (if `git-annex' is
found in `$path'). The `_git-annex' function could then handle
completion for `annex' in depth.

  zsh% git annex --<tab>
  zsh% git annex <tab>
  zsh% git annex add <tab>

...could all be handled appropriately.

Such a file could be maintained with annex (in which case you'd have to
drop it into `$fpath' - since 4.3.12-1 that could be
`/usr/share/zsh/vendor-completions/'). Or it could be maintained
upstream like `_git-buildpackage' is.


In any case, here is a start for _git-annex:

[snip]
#compdef git-annex
#desc:managing files while ignoring their content

local state line context
local -A opt_args

local -a arguments
arguments=(
    '--force[force something]'
    '--fast[don'\''t be slow]'
    '--verbose[tell me more]'
    ': :->command'
    '*:: :->subcmd'
)

_arguments -C $arguments

case $state in
(command)
    local -a cmds
    cmds=(
        add:'add files to the annex'
        drop:'useful description after the colon'
        get
        map
        move
        status
    )
    _describe -t commands command cmds
    ;;
(subcmd)
    case ${line[1]} in
    (map|status)
        _message 'No more arguments'
        ;;
    (*)
        _path_files
        ;;
    esac
    ;;
esac
[snap]

I've got no idea of what git-annex does, so the above is just based on
skimming through <http://git-annex.branchable.com/git-annex/>. But I
think it already handles the vast majority of required cases. They just
need to be added by someone.

If you (or one of your contributors) wants to do that and run(s) into
problems, feel free to ask pkg-zsh-devel at lists.alioth.debian.org for
assistance. ;)

Regards, Frank





More information about the Pkg-zsh-devel mailing list