2

I do this often after shelling out to bash

$ git grep 'banner-image' | grep mb3

Can I do it without leaving emacs?

Drew
  • 75,699
  • 9
  • 109
  • 225
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
  • 1
    `M-x grep` followed by the input `grep -nH -e banner-image | grep mb3 RET`. (The `grep -nH -e` is provided by default.) As usual for `M-x grep`, this gives you a `grep` output buffer with the search hits. See (emacs) [Grep Searching](https://www.gnu.org/software/emacs/manual/html_node/emacs/Grep-Searching.html). – Drew Sep 03 '17 at 05:40
  • Is your solution "recursive", because git grep is recursive by default – american-ninja-warrior Sep 03 '17 at 05:41
  • Use `rgrep` if you want recursive`. – Drew Sep 03 '17 at 05:42
  • the .git folder contains two thousand files not for human consumption. git grep by default ignores that folder. does your solution take that in to account. – american-ninja-warrior Sep 03 '17 at 05:44
  • Try `grep-find-template`. – Drew Sep 03 '17 at 14:36
  • @joshsverns: Did you try `rgrep`? By default it ignores any/all of `grep-find-ignored-directories` and `grep-find-ignored-files` (see which variables). – phils Sep 04 '17 at 03:18
  • https://stackoverflow.com/questions/25633490/how-can-i-use-m-x-rgrep-with-the-git-grep-command-in-emacs – MarcH Apr 25 '18 at 20:22

1 Answers1

1

I have counsel (and ivy and swiper and ivy-hydra) loaded, and have "ctrl-c j" bound to counsel-git-grep, which works well for the LHS of your pipeline. It is not clear if the RHS of your pipeline is trying to match more of the line or the filename. If the former then I would tend to add a space and mb3, if the latter then I would use "ctrl-c ctrl-o" ivy-occur to save the git grep output in a buffer, and then use "ctrl-s" to search this new buffer for mb3, pressing enter to visit the place.

All of these packages are available from melpa.org.

icarus
  • 1,904
  • 1
  • 10
  • 15