After rewatching abo-abo’s refactoring video I decided check out his other videos. I’ve seen most of them, of course, but mostly forgotten the details. One video, counsel git grep demo, is really informative and worth your time.
If you have the Ivy/Counsel/Swiper suite installed, you already have
counsel-git-grep. It’s a really handy way of grepping through a git repository. That may sound a bit limited but it’s not. What it does is grep through all the files in the current git repository where “current git repository” means the repository that has a
.git directory in the current directory hierarchy. It works by calling
git grep so in a sense it’s nothing new but it’s really handy to be able to invoke from within Emacs without having to shell out. All the results are put in the minibuffer in the usual Ivy way so it’s easy to find the right match or to put the results in a separate buffer by calling
ivy-occur and deal with the matches one-by-one or even en masse as described in the refactoring video.
After watching the video, I added bindings for
counsel-git-grep to my configuration so that I can call it easily. The video is only 4 minutes so you can watch it twice while the coffee’s brewing.