git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Custom git completion
@ 2010-01-29 12:57 David Rhodes Clymer
  2010-01-29 15:11 ` Shawn O. Pearce
  0 siblings, 1 reply; 25+ messages in thread
From: David Rhodes Clymer @ 2010-01-29 12:57 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 902 bytes --]

Unless I read it incorrectly, the completion script included with
git-core does not make it easy for users to write completion scripts
for custom git commands. I can extend git itself by creating a command
"git-foo", and placing it in my path. The command can then be used
like so: "git foo". However, if I want to add command completion for
that command without modifying (I may not have permission) or
duplicating the system git completion, I can't write a completion
script which matches works on "git foo", only "git-foo", which is not
how I would ever call the script.

Anyway, so I made a simple modification which looks for completion
code for custom commands, and calls that as appropriate. If the
attached patch (or something like it) were applied to the git
completion script, it would be awfully handy.

-davidc

ps. I'm not subscribed to the list, so please copy me on any replies, thanks!

[-- Attachment #2: git_completion.patch --]
[-- Type: text/x-patch, Size: 380 bytes --]

--- /etc/bash_completion.d/git.orig	2010-01-12 14:50:16.000000000 -0500
+++ /etc/bash_completion.d/git	2010-01-12 15:28:27.000000000 -0500
@@ -1403,7 +1403,10 @@
 	svn)         _git_svn ;;
 	tag)         _git_tag ;;
 	whatchanged) _git_log ;;
-	*)           COMPREPLY=() ;;
+	*)
+    COMPREPLY=()
+    $(complete -p |awk '/ '"git-${command}"'$/{print $(NF-1)}')
+  ;;
 	esac
 }
 

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-02-26 20:17 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-29 12:57 Custom git completion David Rhodes Clymer
2010-01-29 15:11 ` Shawn O. Pearce
2010-01-29 17:42   ` Junio C Hamano
2010-01-29 17:59     ` Shawn O. Pearce
2010-01-29 18:02       ` Junio C Hamano
2010-01-29 19:06         ` [PATCH] bash: support user-supplied completion scripts for user's git commands SZEDER Gábor
2010-01-29 19:13           ` Shawn O. Pearce
2010-01-29 20:00             ` SZEDER Gábor
2010-01-29 20:04               ` Shawn O. Pearce
2010-01-31 19:19                 ` SZEDER Gábor
2010-02-23 21:02                   ` [PATCH 0/4] bash: support user-supplied completion scripts for custom git commands and aliases SZEDER Gábor
2010-02-23 21:02                     ` [PATCH 1/4] bash: improve aliased command recognition SZEDER Gábor
2010-02-23 22:11                       ` Junio C Hamano
2010-02-24  1:04                         ` SZEDER Gábor
2010-02-24  2:56                           ` Junio C Hamano
2010-02-23 21:02                     ` [PATCH 2/4] bash: support user-supplied completion scripts for user's git commands SZEDER Gábor
2010-02-23 21:02                     ` [PATCH 3/4] bash: support user-supplied completion scripts for aliases SZEDER Gábor
2010-02-23 21:03                     ` [PATCH 4/4] bash: completion for gitk aliases SZEDER Gábor
2010-01-29 20:32           ` [PATCH] bash: support user-supplied completion scripts for user's git commands Junio C Hamano
2010-02-26 15:27             ` SZEDER Gábor
2010-02-26 20:04               ` Junio C Hamano
2010-02-26 20:17                 ` Shawn O. Pearce
2010-01-30 23:34           ` David Rhodes Clymer
2010-01-30 23:03       ` Custom git completion David Rhodes Clymer
2010-01-30 23:00   ` David Rhodes Clymer

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 NNTP newsgroup(s).