From: Lee Marlow <lee.marlow@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org, Lee Marlow <lee.marlow@gmail.com>
Subject: [PATCH] bash completion: Add completion for 'git grep'
Date: Sun, 3 Aug 2008 23:26:48 -0600 [thread overview]
Message-ID: <1217827608-5143-1-git-send-email-lee.marlow@gmail.com> (raw)
In-Reply-To: <20080804040634.GC2963@spearce.org>
Added completions for all long options specified in the docs
--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
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
On Sun, Aug 3, 2008 at 10:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Though I think you have an excellent point about completing paths
> by ls-tree for HEAD rather than the working directory itself,
> as then you can avoid produced files. But in practice how often
> do you pass a single file or a couple of files to the grep utility
> and are having problems bypassing the build products?
I think you're right that it's not a good fit for grep, but maybe for
some other commands. mv and commit come to mind. I'll look into this
as I'm trying to add completions for the more common (i.e. ones that I
use) porcelain commands.
> After having thought about it your original patch makes the most
> sense, but without the has_doubledash test.
This updated patch removes the __git_has_doublehash line. However, I
just noticed that d773c631 added __git_has_doublehash to prevent
completions of long options after --. So, maybe it's not too
redundant and my first patch might be better.
-Lee
contrib/completion/git-completion.bash | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 678a155..96181dc 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -791,6 +791,27 @@ _git_gc ()
COMPREPLY=()
}
+_git_grep ()
+{
+ 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=()
+}
+
_git_help ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1482,6 +1503,7 @@ _git ()
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
gc) _git_gc ;;
+ grep) _git_grep ;;
help) _git_help ;;
log) _git_log ;;
ls-remote) _git_ls_remote ;;
--
1.6.0.rc1.48.g2b6032
next prev parent reply other threads:[~2008-08-04 5:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-02 0:56 [PATCH] bash completion: Add completion for 'git grep' Lee Marlow
2008-08-02 21:05 ` Shawn O. Pearce
2008-08-03 7:31 ` Lee Marlow
2008-08-04 4:06 ` Shawn O. Pearce
2008-08-04 5:26 ` Lee Marlow [this message]
2008-08-04 14:52 ` Shawn O. Pearce
2008-08-04 14:53 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1217827608-5143-1-git-send-email-lee.marlow@gmail.com \
--to=lee.marlow@gmail.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).