I do this often after shelling out to bash
$ git grep 'banner-image' | grep mb3
Can I do it without leaving emacs?
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.
M-x grep
followed by the inputgrep -nH -e banner-image | grep mb3 RET
. (Thegrep -nH -e
is provided by default.) As usual forM-x grep
, this gives you agrep
output buffer with the search hits. See (emacs) Grep Searching.rgrep
if you want recursive`.grep-find-template
.