So the files are completed and coloured nicely. The code would be only a couple of lines if only _multi_parts or _path_files worked correctly, but alas, they don't. Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- contrib/completion/git-completion.zsh | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 4577502..8c6916a 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -60,6 +60,48 @@ __gitcomp_nl () compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } +# +# We need to remove the extra slash for directories, and we need to remove the +# spaces for files, otherwise zsh can't stat them and threat them as proper files. +# +__git_index_files () +{ + local dir="$(__gitdir)" root="${2-.}" file + + if [ -d "$dir" ]; then + local -a files + emulate ksh -c '__git_ls_files_helper "$root" "$1"' | + while read -r file; do + case "$file" in + ?*/*) + files+="${file%%/*}" + ;; + *) + files+="$file" + ;; + esac + done + compadd -Q -p "${2-}" -f -a files && _ret=0 + fi +} + +__git_complete_index_file () +{ + emulate -L zsh + + local pfx="" cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + ;; + esac + + __git_index_files "$1" "$pfx" +} + _git () { local _ret=1 -- 1.8.2.1.1031.g2ee5873 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html