Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
How to solve completion of "git command" and "git-command"
- X-seq: zsh-users 10030
- From: "Nikolai Weibull" <now@xxxxxxxx>
- To: "Zsh Users" <zsh-users@xxxxxxxxxx>
- Subject: How to solve completion of "git command" and "git-command"
- Date: Wed, 15 Mar 2006 23:06:03 +0100
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=LfrOMwSlQYrUnJ6Z19NM1dSH3e2oFItkIb4fcFu8ogDUpK0qiMGRYiWx7Yk4hwgWzij7Wmss5Daj5NOzW7qH+KOjQ0rPQvjG1QAiYZvwEKN7YxnjFvk4fnCWoidcX1BjXQX1yY7gWbcmgDl90Ssw5hxpRWeRKb50NICmpkIhfeo=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Sender: nikolai.weibull@xxxxxxxxx
Currently, _git completes both ways of invoking git and it's subcommands:
if [[ $words[1] == git ]]; then
if (( CURRENT == 2 )); then
_git_commands
else
shift words
(( CURRENT-- ))
curcontext="${curcontext%:*:*}:git-$words[1]:"
_call_function ret _git-$words[1]
fi
else
_call_function ret _$words[1]
fi
However, the "git" command now also takes options, not just
subcommands as its argument. How do I best solve this, so that I can
still get the functionality implied in the example above (just calling
the correct function, e.g., _git-commit for both "git commit ..." and
"git-commit ...")?
The "git" command currently takes three options: "--version",
"--help", and "--exec-path[=PATH]".
The _git_commands function currently invokes _describe:
_describe -t commands 'git command' commands && ret=0
on an array of commands-descriptions.
I was thinking that something like
if [[ $words[1] == git ]]; then
local context state line
typeset -A opt_args
_arguments \
'(- :)--version[display version information]' \
'(- :)--help[display help]' \
'--exec-path=-[execution path for git]:directory:_directories' \
':command:->command' \
'*::options:->options' && ret=0
case $state in
(command)
_git_commands
;;
(options)
curcontext="${curcontext%:*:*}:git-$words[1]:"
_call_function ret _git-$words[1]
;;
esac
else
_call_function ret _$words[1]
fi
might work, but I want to make seru that I'm not missing something here?
Any help towards reaching a satisfactory solution will be greatly appreciated.
Thanks.
nikolai
Messages sorted by:
Reverse Date,
Date,
Thread,
Author