{"thread":{"id":"30731","subject":"[PATCH v4] completion: add new zsh completion","startedAt":"2012-06-07T01:29:44Z","lastAt":"2012-06-07T01:29:44Z","messageCount":1,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":4,"patchTotal":null},"messages":[{"id":"193021","messageId":"1339032584-2877-1-git-send-email-felipe.contreras@gmail.com","threadId":"30731","inReplyTo":null,"subject":"[PATCH v4] completion: add new zsh completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-06-07T01:29:44Z","receivedAt":"2012-06-07T01:29:44Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It seems there's always issues with zsh's bash completion emulation.\nI've tried to fix as many as I could and most of the fixes are already\nin the latest version of zsh, but still, there are issues.\n\nThere is no point going through all that pain; the emulation is easy to\nachieve, and this patch works better than zsh's emulation.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\nv4:\n\n * Simplification updates for the latest bash completion\n\nv3:\n\n * Simplification\n * Avoid COMPREPLY; call compadd directly\n * Fix _get_comp_words_by_ref\n\n contrib/completion/git-completion.zsh |   68 +++++++++++++++++++++++++++++++++\n 1 file changed, 68 insertions(+)\n create mode 100644 contrib/completion/git-completion.zsh\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nnew file mode 100644\nindex 0000000..07fa5a4\n--- /dev/null\n+++ b/contrib/completion/git-completion.zsh\n@@ -0,0 +1,68 @@\n+#compdef git gitk\n+\n+# zsh completion wrapper for git\n+#\n+# You need git's bash completion script installed somewhere, by default on the\n+# same directory as this script.\n+#\n+# If your script is on ~/.git-completion.sh instead, you can configure it on\n+# your ~/.zshrc:\n+#\n+#  zstyle ':completion:*:*:git:*' script ~/.git-completion.sh\n+#\n+# The recommended way to install this script is to copy to\n+# '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file:\n+#\n+#  fpath=(~/.zsh/completion $fpath)\n+\n+complete ()\n+{\n+\t# do nothing\n+\treturn 0\n+}\n+\n+zstyle -s \":completion:*:*:git:*\" script script\n+test -z \"$script\" && script=\"$(dirname ${funcsourcetrace[1]%:*})\"/git-completion.bash\n+ZSH_VERSION='' . \"$script\"\n+\n+__gitcompadd ()\n+{\n+\tcompadd -Q -S \"$3\" -P \"$2\" -p \"${(M)cur#*[=:]}\" -- ${=1} && _ret=0\n+}\n+\n+__gitcomp ()\n+{\n+\tlocal cur_=\"${3-$cur}\"\n+\n+\tcase \"$cur_\" in\n+\t--*=)\n+\t\t;;\n+\t*)\n+\t\tlocal IFS=$'\\n'\n+\t\t__gitcompadd \"$(__gitcomp_1 \"${1-}\")\" \"${2-}\" \"\"\n+\t\t;;\n+\tesac\n+}\n+\n+__gitcomp_nl ()\n+{\n+\tlocal IFS=$'\\n'\n+\t__gitcompadd \"$1\" \"${2-}\" \"${4- }\"\n+}\n+\n+_git ()\n+{\n+\tlocal _ret=1\n+\t() {\n+\t\temulate -L ksh\n+\t\tlocal cur cword prev\n+\t\tcur=${words[CURRENT-1]}\n+\t\tprev=${words[CURRENT-2]}\n+\t\tlet cword=CURRENT-1\n+\t\t_main_${service}\n+\t}\n+\tlet _ret && _default -S '' && _ret=0\n+\treturn _ret\n+}\n+\n+_git\n-- \n1.7.10.3\n"}]}