* [PATCH 0/5] contrib: completion: general zsh updates
@ 2019-06-14 6:50 Felipe Contreras
2019-06-14 6:50 ` [PATCH 1/5] completion: zsh: update installation instructions Felipe Contreras
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Felipe Contreras @ 2019-06-14 6:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Richard Hansen, Felipe Contreras
Helo,
These patches are definitely needed, and some of these have been cooking
for years in oh-my-zsh.
Felipe Contreras (5):
completion: zsh: update installation instructions
completion: zsh: fix for directories with spaces
completion: remove zsh hack
completion: zsh: improve main function selection
completion: prompt: fix color for Zsh
contrib/completion/git-completion.bash | 1 +
contrib/completion/git-completion.zsh | 33 ++++++++++++--------------
contrib/completion/git-prompt.sh | 10 ++++----
3 files changed, 22 insertions(+), 22 deletions(-)
--
2.22.0.rc2.dirty
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] completion: zsh: update installation instructions
2019-06-14 6:50 [PATCH 0/5] contrib: completion: general zsh updates Felipe Contreras
@ 2019-06-14 6:50 ` Felipe Contreras
2019-06-14 6:50 ` [PATCH 2/5] completion: zsh: fix for directories with spaces Felipe Contreras
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Felipe Contreras @ 2019-06-14 6:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Richard Hansen, Felipe Contreras
Commit 0e5ed7cca3 wrongly changed the extension of the bash script
to .zsh. The extension doesn't really matter, but it confuses people.
I've changed the text to make it clear that your zsh script goes to
~/.zsh/_git, and the bash script to ~/.git-completion.bash (or wherever
you want).
Also, update the default locations of the system bash-completion.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 886bf95d1f..b3c4588515 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -4,17 +4,19 @@
#
# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
#
-# You need git's bash completion script installed somewhere, by default it
-# would be the location bash-completion uses.
-#
-# If your script is somewhere else, you can configure it on your ~/.zshrc:
-#
-# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
-#
# The recommended way to install this script is to copy to '~/.zsh/_git', and
# then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
+#
+# You need git's bash completion script installed. By default bash-completion
+# uses /usr/share/bash-completion.
+#
+# If your bash completion script is somewhere else, you can configure it on
+# your ~/.zshrc:
+#
+# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
+#
complete ()
{
@@ -31,9 +33,8 @@ if [ -z "$script" ]; then
local e
locations=(
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
- '/etc/bash_completion.d/git' # fedora, old debian
- '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
- '/usr/share/bash-completion/git' # gentoo
+ '/usr/share/bash-completion/completions/git'
+ '/etc/bash_completion.d/git' # old debian
)
for e in $locations; do
test -f $e && script="$e" && break
--
2.22.0.rc2.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] completion: zsh: fix for directories with spaces
2019-06-14 6:50 [PATCH 0/5] contrib: completion: general zsh updates Felipe Contreras
2019-06-14 6:50 ` [PATCH 1/5] completion: zsh: update installation instructions Felipe Contreras
@ 2019-06-14 6:50 ` Felipe Contreras
2019-06-14 6:50 ` [PATCH 3/5] completion: remove zsh hack Felipe Contreras
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Felipe Contreras @ 2019-06-14 6:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Richard Hansen, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index b3c4588515..067738d93f 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -32,7 +32,7 @@ if [ -z "$script" ]; then
local -a locations
local e
locations=(
- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
+ "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
'/usr/share/bash-completion/completions/git'
'/etc/bash_completion.d/git' # old debian
)
--
2.22.0.rc2.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] completion: remove zsh hack
2019-06-14 6:50 [PATCH 0/5] contrib: completion: general zsh updates Felipe Contreras
2019-06-14 6:50 ` [PATCH 1/5] completion: zsh: update installation instructions Felipe Contreras
2019-06-14 6:50 ` [PATCH 2/5] completion: zsh: fix for directories with spaces Felipe Contreras
@ 2019-06-14 6:50 ` Felipe Contreras
2019-06-14 6:50 ` [PATCH 4/5] completion: zsh: improve main function selection Felipe Contreras
2019-06-14 6:50 ` [PATCH 5/5] completion: prompt: fix color for Zsh Felipe Contreras
4 siblings, 0 replies; 6+ messages in thread
From: Felipe Contreras @ 2019-06-14 6:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Richard Hansen, Felipe Contreras, Mark Lodato
We don't want to override the 'complete()' function in zsh, which can be
used by bashcomp.
Reported-by: Mark Lodato <lodato@google.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 1 +
contrib/completion/git-completion.zsh | 6 ------
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9f71bcde96..57cced3f51 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3066,6 +3066,7 @@ __git_func_wrap ()
# This is NOT a public function; use at your own risk.
__git_complete ()
{
+ test -n "$ZSH_VERSION" && return
local wrapper="__git_wrap${2}"
eval "$wrapper () { __git_func_wrap $2 ; }"
complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 067738d93f..58b3b5c27d 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -18,12 +18,6 @@
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
#
-complete ()
-{
- # do nothing
- return 0
-}
-
zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
--
2.22.0.rc2.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] completion: zsh: improve main function selection
2019-06-14 6:50 [PATCH 0/5] contrib: completion: general zsh updates Felipe Contreras
` (2 preceding siblings ...)
2019-06-14 6:50 ` [PATCH 3/5] completion: remove zsh hack Felipe Contreras
@ 2019-06-14 6:50 ` Felipe Contreras
2019-06-14 6:50 ` [PATCH 5/5] completion: prompt: fix color for Zsh Felipe Contreras
4 siblings, 0 replies; 6+ messages in thread
From: Felipe Contreras @ 2019-06-14 6:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Richard Hansen, Felipe Contreras
Sometimes we want to use the function directly (e.g. _git_checkout), for
example when zsh has the option 'complete_aliases', this way, we can do
something like:
compdef _git gco=git_checkout
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 58b3b5c27d..92b956d5de 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -227,8 +227,10 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main
- else
+ elif (( $+functions[__${service}_main] )); then
emulate ksh -c __${service}_main
+ elif (( $+functions[_${service}] )); then
+ emulate ksh -c _${service}
fi
let _ret && _default && _ret=0
--
2.22.0.rc2.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] completion: prompt: fix color for Zsh
2019-06-14 6:50 [PATCH 0/5] contrib: completion: general zsh updates Felipe Contreras
` (3 preceding siblings ...)
2019-06-14 6:50 ` [PATCH 4/5] completion: zsh: improve main function selection Felipe Contreras
@ 2019-06-14 6:50 ` Felipe Contreras
4 siblings, 0 replies; 6+ messages in thread
From: Felipe Contreras @ 2019-06-14 6:50 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Richard Hansen, Felipe Contreras
We don't need PROMPT_COMMAND in Zsh; we are already using %F{color} %f,
which in turn use %{ and %}, which are the equivalent of Bash's
\[ and \].
We can use as many colors as we want and output directly into PS1
(or RPS1) without the risk of buffer wrapping issues.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-prompt.sh | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 983e419d2b..b57a9c96cb 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -88,7 +88,7 @@
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
-# using __git_ps1 for PROMPT_COMMAND or precmd.
+# using __git_ps1 for PROMPT_COMMAND in Bash, but always available in Zsh.
#
# If you would like __git_ps1 to do nothing in the case when the current
# directory is set up to be ignored by git, then set
@@ -506,9 +506,11 @@ __git_ps1 ()
local z="${GIT_PS1_STATESEPARATOR-" "}"
- # NO color option unless in PROMPT_COMMAND mode
- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
- __git_ps1_colorize_gitstring
+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+ __git_ps1_colorize_gitstring
+ fi
fi
b=${b##refs/heads/}
--
2.22.0.rc2.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-06-14 6:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 6:50 [PATCH 0/5] contrib: completion: general zsh updates Felipe Contreras
2019-06-14 6:50 ` [PATCH 1/5] completion: zsh: update installation instructions Felipe Contreras
2019-06-14 6:50 ` [PATCH 2/5] completion: zsh: fix for directories with spaces Felipe Contreras
2019-06-14 6:50 ` [PATCH 3/5] completion: remove zsh hack Felipe Contreras
2019-06-14 6:50 ` [PATCH 4/5] completion: zsh: improve main function selection Felipe Contreras
2019-06-14 6:50 ` [PATCH 5/5] completion: prompt: fix color for Zsh Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).