{"thread":{"id":"51310","subject":"[PATCH 0/5] contrib: completion: general zsh updates","startedAt":"2019-06-14T06:50:55Z","lastAt":"2019-06-14T06:51:02Z","messageCount":6,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"377215","messageId":"20190614065051.17774-1-felipe.contreras@gmail.com","threadId":"51310","inReplyTo":null,"subject":"[PATCH 0/5] contrib: completion: general zsh updates","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2019-06-14T06:50:46Z","receivedAt":"2019-06-14T06:50:55Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Helo,\n\nThese patches are definitely needed, and some of these have been cooking\nfor years in oh-my-zsh.\n\nFelipe Contreras (5):\n  completion: zsh: update installation instructions\n  completion: zsh: fix for directories with spaces\n  completion: remove zsh hack\n  completion: zsh: improve main function selection\n  completion: prompt: fix color for Zsh\n\n contrib/completion/git-completion.bash |  1 +\n contrib/completion/git-completion.zsh  | 33 ++++++++++++--------------\n contrib/completion/git-prompt.sh       | 10 ++++----\n 3 files changed, 22 insertions(+), 22 deletions(-)\n\n-- \n2.22.0.rc2.dirty\n\n"},{"id":"377216","messageId":"20190614065051.17774-2-felipe.contreras@gmail.com","threadId":"51310","inReplyTo":"20190614065051.17774-1-felipe.contreras@gmail.com","subject":"[PATCH 1/5] completion: zsh: update installation instructions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2019-06-14T06:50:47Z","receivedAt":"2019-06-14T06:50:57Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Commit 0e5ed7cca3 wrongly changed the extension of the bash script\nto .zsh. The extension doesn't really matter, but it confuses people.\n\nI've changed the text to make it clear that your zsh script goes to\n~/.zsh/_git, and the bash script to ~/.git-completion.bash (or wherever\nyou want).\n\nAlso, update the default locations of the system bash-completion.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.zsh | 21 +++++++++++----------\n 1 file changed, 11 insertions(+), 10 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex 886bf95d1f..b3c4588515 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -4,17 +4,19 @@\n #\n # Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>\n #\n-# You need git's bash completion script installed somewhere, by default it\n-# would be the location bash-completion uses.\n-#\n-# If your script is somewhere else, you can configure it on your ~/.zshrc:\n-#\n-#  zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh\n-#\n # The recommended way to install this script is to copy to '~/.zsh/_git', and\n # then add the following to your ~/.zshrc file:\n #\n #  fpath=(~/.zsh $fpath)\n+#\n+# You need git's bash completion script installed. By default bash-completion\n+# uses /usr/share/bash-completion.\n+#\n+# If your bash completion script is somewhere else, you can configure it on\n+# your ~/.zshrc:\n+#\n+#  zstyle ':completion:*:*:git:*' script ~/.git-completion.bash\n+#\n \n complete ()\n {\n@@ -31,9 +33,8 @@ if [ -z \"$script\" ]; then\n \tlocal e\n \tlocations=(\n \t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n-\t\t'/etc/bash_completion.d/git' # fedora, old debian\n-\t\t'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian\n-\t\t'/usr/share/bash-completion/git' # gentoo\n+\t\t'/usr/share/bash-completion/completions/git'\n+\t\t'/etc/bash_completion.d/git' # old debian\n \t\t)\n \tfor e in $locations; do\n \t\ttest -f $e && script=\"$e\" && break\n-- \n2.22.0.rc2.dirty\n\n"},{"id":"377217","messageId":"20190614065051.17774-3-felipe.contreras@gmail.com","threadId":"51310","inReplyTo":"20190614065051.17774-1-felipe.contreras@gmail.com","subject":"[PATCH 2/5] completion: zsh: fix for directories with spaces","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2019-06-14T06:50:48Z","receivedAt":"2019-06-14T06:50:58Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.zsh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex b3c4588515..067738d93f 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -32,7 +32,7 @@ if [ -z \"$script\" ]; then\n \tlocal -a locations\n \tlocal e\n \tlocations=(\n-\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n+\t\t\"$(dirname ${funcsourcetrace[1]%:*})\"/git-completion.bash\n \t\t'/usr/share/bash-completion/completions/git'\n \t\t'/etc/bash_completion.d/git' # old debian\n \t\t)\n-- \n2.22.0.rc2.dirty\n\n"},{"id":"377218","messageId":"20190614065051.17774-4-felipe.contreras@gmail.com","threadId":"51310","inReplyTo":"20190614065051.17774-1-felipe.contreras@gmail.com","subject":"[PATCH 3/5] completion: remove zsh hack","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2019-06-14T06:50:49Z","receivedAt":"2019-06-14T06:51:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We don't want to override the 'complete()' function in zsh, which can be\nused by bashcomp.\n\nReported-by: Mark Lodato <lodato@google.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 1 +\n contrib/completion/git-completion.zsh  | 6 ------\n 2 files changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9f71bcde96..57cced3f51 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3066,6 +3066,7 @@ __git_func_wrap ()\n # This is NOT a public function; use at your own risk.\n __git_complete ()\n {\n+\ttest -n \"$ZSH_VERSION\" && return\n \tlocal wrapper=\"__git_wrap${2}\"\n \teval \"$wrapper () { __git_func_wrap $2 ; }\"\n \tcomplete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \\\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex 067738d93f..58b3b5c27d 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -18,12 +18,6 @@\n #  zstyle ':completion:*:*:git:*' script ~/.git-completion.bash\n #\n \n-complete ()\n-{\n-\t# do nothing\n-\treturn 0\n-}\n-\n zstyle -T ':completion:*:*:git:*' tag-order && \\\n \tzstyle ':completion:*:*:git:*' tag-order 'common-commands'\n \n-- \n2.22.0.rc2.dirty\n\n"},{"id":"377219","messageId":"20190614065051.17774-5-felipe.contreras@gmail.com","threadId":"51310","inReplyTo":"20190614065051.17774-1-felipe.contreras@gmail.com","subject":"[PATCH 4/5] completion: zsh: improve main function selection","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2019-06-14T06:50:50Z","receivedAt":"2019-06-14T06:51:01Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Sometimes we want to use the function directly (e.g. _git_checkout), for\nexample when zsh has the option 'complete_aliases', this way, we can do\nsomething like:\n\n  compdef _git gco=git_checkout\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.zsh | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex 58b3b5c27d..92b956d5de 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -227,8 +227,10 @@ _git ()\n \n \tif (( $+functions[__${service}_zsh_main] )); then\n \t\t__${service}_zsh_main\n-\telse\n+\telif (( $+functions[__${service}_main] )); then\n \t\temulate ksh -c __${service}_main\n+\telif (( $+functions[_${service}] )); then\n+\t\temulate ksh -c _${service}\n \tfi\n \n \tlet _ret && _default && _ret=0\n-- \n2.22.0.rc2.dirty\n\n"},{"id":"377220","messageId":"20190614065051.17774-6-felipe.contreras@gmail.com","threadId":"51310","inReplyTo":"20190614065051.17774-1-felipe.contreras@gmail.com","subject":"[PATCH 5/5] completion: prompt: fix color for Zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2019-06-14T06:50:51Z","receivedAt":"2019-06-14T06:51:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We don't need PROMPT_COMMAND in Zsh; we are already using %F{color} %f,\nwhich in turn use %{ and %}, which are the equivalent of Bash's\n\\[ and \\].\n\nWe can use as many colors as we want and output directly into PS1\n(or RPS1) without the risk of buffer wrapping issues.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-prompt.sh | 10 ++++++----\n 1 file changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 983e419d2b..b57a9c96cb 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -88,7 +88,7 @@\n # If you would like a colored hint about the current dirty state, set\n # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on\n # the colored output of \"git status -sb\" and are available only when\n-# using __git_ps1 for PROMPT_COMMAND or precmd.\n+# using __git_ps1 for PROMPT_COMMAND in Bash, but always available in Zsh.\n #\n # If you would like __git_ps1 to do nothing in the case when the current\n # directory is set up to be ignored by git, then set\n@@ -506,9 +506,11 @@ __git_ps1 ()\n \n \tlocal z=\"${GIT_PS1_STATESEPARATOR-\" \"}\"\n \n-\t# NO color option unless in PROMPT_COMMAND mode\n-\tif [ $pcmode = yes ] && [ -n \"${GIT_PS1_SHOWCOLORHINTS-}\" ]; then\n-\t\t__git_ps1_colorize_gitstring\n+\t# NO color option unless in PROMPT_COMMAND mode or it's Zsh\n+\tif [ -n \"${GIT_PS1_SHOWCOLORHINTS-}\" ]; then\n+\t\tif [ $pcmode = yes ] || [ -n \"${ZSH_VERSION-}\" ]; then\n+\t\t\t__git_ps1_colorize_gitstring\n+\t\tfi\n \tfi\n \n \tb=${b##refs/heads/}\n-- \n2.22.0.rc2.dirty\n\n"}]}