From: Shawn O. Pearce Date: Sat, 02 Aug 2008 21:05:25 GMT Subject: Re: [PATCH] bash completion: Add completion for 'git grep' Message-ID: <20080802210525.GD24723@spearce.org> In-Reply-To: <1217638593-57321-1-git-send-email-lee.marlow@gmail.com> Lee Marlow wrote: > +_git_grep () > +{ > + __git_has_doubledash && return > + > + local cur="${COMP_WORDS[COMP_CWORD]}" > + case "$cur" in > + --*) > + __gitcomp " > + --cached > + --text --ignore-case --word-regexp --invert-match > + --full-name > + --extended-regexp --basic-regexp --fixed-strings > + --files-with-matches --name-only > + --files-without-match > + --count > + --and --or --not --all-match > + " > + return > + ;; > + esac > + COMPREPLY=() > +} Hmm. The has_doubledash test seems redundant since we don't do anything with args that aren't --foo. Even though git-grep will accept a tree-ish and thus completion of __git_refs here may make sense. I wonder if we shouldn't just add to the end something like: __gitcomp "$(__git_refs)" like the _git_reset function does. Then we can complete a tree-ish for searching, as well as honor -- to stop tree-ish completion and go back to file/directory completion. But that is very much a user question. Do users mostly search a file in the current working directory, or do they mostly search a tree-ish? -- Shawn.