Added initial zsh completion support to git_index

zsh now completes all arguments and all directories inside $GIT_REPO_DIR. This is till buggy because not all directories in $GIT_REPO_DIR are actual git projects. Next update will include completing the list in the .git_index file.
This commit is contained in:
Aljaž "g5pw" Srebrnič
2012-10-23 09:13:20 +02:00
parent c20b91442a
commit a9aa363fdb
2 changed files with 59 additions and 31 deletions

View File

@@ -146,5 +146,7 @@ if [ $shell = "bash" ]; then
# If you know how to rewrite _git_index_tab_completion() for zsh, please send me a pull request!
complete -o nospace -F _git_index_tab_completion git_index
complete -o nospace -F _git_index_tab_completion $git_index_alias
else
compdef _git_index_tab_completion git_index $git_index_alias
fi

View File

@@ -281,6 +281,7 @@ function _git_index_batch_cmd() {
}
if [ $shell = 'bash' ]; then
# Bash tab completion function for git_index()
function _git_index_tab_completion() {
_check_git_index
@@ -317,4 +318,29 @@ function _git_index_tab_completion() {
IFS=$' \t\n'
return 0
}
else
function _git_index_tab_completion() {
typeset -A opt_args
_arguments \
"--rebuild[Rebuild repository index]" \
"--update-all[Update all indexed repositories]" \
"--update-all-with-notifications[Update all indexed repositories with notifications]" \
"--list[List all repositories currently present in the index]" \
"--count-by-host[Count all repositories per host]" \
"--batch-cmd+[Run a git command on all repositories]:git command:->git_command" \
":Project name:->projects" \
&& return 0
case "$state" in
projects)
_files -/ -W $GIT_REPO_DIR
;;
git_command)
;;
esac
return 1;
}
fi