excluding a directory from being searched
asmallteapot opened this issue · 2 comments
asmallteapot commented
Hi there! Is there a way to exclude a subdirectory from being searched, like ack
's --ignore-dir=
option?
swolchok commented
You can do this with the --glob
option. It plumbs into the ignore
crate's glob support, which is documented to "have precisely the same semantics as a single line in a gitignore file, where the meaning of ! is inverted: namely, ! at the beginning of a glob will ignore a file". gitignore documentation says that putting a slash at the end of a pattern makes it match only directory names, so:
$ cd /tmp
$ mkdir fmtest
$ cd fmtest
$ ls
$ mkdir yes
$ mkdir no
$ yes/a.txt
$ no/a.txt
$ fastmod hello goodbye -g '!no/'
./yes/a.txt:1
- hello
+ goodbye
Accept change (y = yes [default], n = no, e = edit, A = yes to all, E = yes+edit, q = quit)?
n
$ mkdir subdir
$ mv no yes subdir
$ fastmod hello goodbye -g '!no/'
./subdir/yes/a.txt:1
- hello
+ goodbye
Accept change (y = yes [default], n = no, e = edit, A = yes to all, E = yes+edit, q = quit)?
n
Hope this helps!
asmallteapot commented
This is perfect, thanks! I had no idea glob syntax supported negation, this is life-changing tbh