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?


(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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.