The man does not define 'hidden' and 'ignored'. This probably means the 'hidden' is a file starting with a dot and 'ignored' is an entry in related ignore lists (.gitignore and .ignore).
However it is not clear if 'hidden' also includes hidden dirs. For example, .config
dir is ignored even with --hidden
option, but is included with -u
option.
What is the rule for hidden dirs, if any? Are all hidden dirs ignored without -u
option?
Yes, hidden files mean dotfiles. ag
by default ignores hidden files (i.e. dotfiles). This includes any hidden file or directory, we use the --hidden
argument to bypass that.
From the man page,
--hidden Search hidden files. This option obeys ignored files.
Thus, it means any hidden file or directory (files within hidden directories in our case).
Using the unrestricted -u
argument makes it search everything: binary files, hidden files and even ignoring .ignores, .gitignore etc.
-u --unrestricted Search all files. This ignores .ignore, .gitignore, etc. It searches binary and hidden files as well.
This is the difference between them. I couldn't reproduce what you said:
For example, .config dir is ignored even with --hidden option, but is included with -u option.
Placing a file in the folder .config/README.md
and searching
using --hidden
yielded the result for me. One scenario where it could happen for you is if your .config
dir is added to your .gitignore
file (a common setting) or any other ignore file. Thus -u
will always work.
Further reading: