git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] completion: zsh: improve main function selection

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 14, 2019, 06:50 UTC
Message-ID
<20190614065051.17774-5-felipe.contreras@gmail.com>
In-Reply-To
<20190614065051.17774-1-felipe.contreras@gmail.com>

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
Previous: Felipe ContrerasNext: Felipe Contreras
Message 5 of 6 in “contrib: completion: general zsh updates”
  1. 0/5 contrib: completion: general zsh updatesFelipe Contreras, Jun 14, 2019
  2. 1/5 completion: zsh: update installation instructionsFelipe Contreras, Jun 14, 2019
  3. 2/5 completion: zsh: fix for directories with spacesFelipe Contreras, Jun 14, 2019
  4. 3/5 completion: remove zsh hackFelipe Contreras, Jun 14, 2019
  5. 4/5 completion: zsh: improve main function selectionFelipe Contreras, Jun 14, 2019
  6. 5/5 completion: prompt: fix color for ZshFelipe Contreras, Jun 14, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.