bash - How does git-completion call the function related to the command you're typing? -
i'm trying @ code of git-completion.bash.  if run file, can auto complete git command arguments.  want write similar tool, command (ie: not git).  i'm trying figure out how works can copy / modify it.  have decent understanding:
there functions _git_rebase called when type git rebase <something><tab>.  thing can't figure out how _git_rebase called?  can't find function being used anywhere in code.  think may have with function, i'm not sure.
can more familiar bash explain me what's going on here , how, example, _git_rebase gets called?  convenience, here's source code: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
these functions automatically called bash depending on command current inputted in command line.
you may have @ bash's documentation:
simple example:
$ cat compspec.foo function _foo {     local cmd=$1 cur=$2 pre=$3      if [[ $pre == "$cmd" ]];         compreply=( $(compgen -w 'hello world' -- "$cur") )     fi }  complete -f _foo foo $ source compspec.foo $ foo <tab><tab> hello  world $ foo h<tab> $ foo hello 
Comments
Post a Comment