#StackBounty: #git #grep #consult How to exclude certain directories/files from `consult-git-grep` search?

Bounty: 50

I want to exlude certain files such as .gitignore in consult-git-grep search.

  • consult-git-grep works find with following defualt setup:

(setq consult-git-grep-args "git --no-pager grep -F -n --no-color -I -e '%s')

I have updated consult-git-grep-args definition where -- '(exclude).gitignore' is added at the end, but it crashes. How could I make it work?

init.el

(require 'consult)

Followed by:

(setq consult-git-grep-args "git --no-pager grep -F -n --no-color -I -e '%s' -- '(exclude).gitignore'")


Related: How to exclude certain directories/files from counsel-git-grep search?

consult-git-grep already ignores files you put in .gitignore. In
order to exclude additional files you can write on the
consult-git-grep prompt:

#foo -- :!*.org #foo -- :!.gitignore This will search for foo and
ignore *.org files or the file .gitignore. If you want to hard code
these settings adjust the variable consult-git-grep-args, which is
similar to counsel-git-grep-cmd-default.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.