Skip to content

Commit d13a295

Browse files
rohiebgitster
authored andcommitted
completion: improve docs for using __git_complete
It took me more than a few tries and a good lecture of __git_main to understand that the two paragraphs really only refer to adding completion functions for executables that are not called through git's subcommand magic. Improve the docs and be more specific. Signed-off-by: Roland Hieber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb85fdf commit d13a295

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,22 @@
3131
# Note that "git" is optional --- '!f() { : commit; ...}; f' would complete
3232
# just like the 'git commit' command.
3333
#
34-
# If you have a command that is not part of git, but you would still
35-
# like completion, you can use __git_complete:
34+
# If you have a shell command that is not part of git (and is not called as a
35+
# git subcommand), but you would still like git-style completion for it, use
36+
# __git_complete. For example, to use the same completion as for 'git log' also
37+
# for the 'gl' command:
3638
#
3739
# __git_complete gl git_log
3840
#
39-
# Or if it's a main command (i.e. git or gitk):
41+
# Or if the 'gk' command should be completed the same as 'gitk':
4042
#
4143
# __git_complete gk gitk
4244
#
45+
# The second parameter of __git_complete gives the completion function; it is
46+
# resolved as a function named "$2", or "__$2_main", or "_$2" in that order.
47+
# In the examples above, the actual functions used for completion will be
48+
# _git_log and __gitk_main.
49+
#
4350
# Compatible with bash 3.2.57.
4451
#
4552
# You can set the following environment variables to influence the behavior of

0 commit comments

Comments
 (0)