index rss mastodon twitter github linkedin email
Álvaro Ramírez

Álvaro Ramírez

10 November 2019 Enhanced Emacs searching with counsel switches

The counsel family of Emacs search commands are great for searching the filesystem. More specifically, counsel-rg, counsel-ag, and counsel-pt, which use the popular ripgrep, silver searcher, and platinum searcher utilities.

counsel-rg is my default searcher. It returns results quickly, with live updates as I tweak the search query.

Up until recently, my queries typically matched text in files only. This works great, but every so often I wished I could amend the query to include (or exclude) results matching specific file names. Turns out, you can prepend the search query with additional switches using the "–" separator.

The switches are usually utility-specific, but if we wanted to keep results from file names matching a glob, we can prepend the ripgrep query with something like "–glob Make* –" or the shorter version "-g Make* –".

rg: -g Make* – install