diff --git a/src/options.c b/src/options.c index 2145b33bb..fe2de17ce 100644 --- a/src/options.c +++ b/src/options.c @@ -219,6 +219,7 @@ void parse_options(int argc, char **argv, char **base_paths[], char **paths[]) { int opt_index = 0; char *num_end; const char *home_dir = getenv("HOME"); + const char *config_dir = getenv("XDG_CONFIG_HOME"); char *ignore_file_path = NULL; int accepts_query = 1; int needs_query = 1; @@ -685,10 +686,15 @@ void parse_options(int argc, char **argv, char **base_paths[], char **paths[]) { exit(1); } - if (home_dir && !opts.search_all_files) { - log_debug("Found user's home dir: %s", home_dir); - ag_asprintf(&ignore_file_path, "%s/.agignore", home_dir); - load_ignore_patterns(root_ignores, ignore_file_path); + if (!opts.search_all_files) { + if (config_home) { + ag_asprintf(&ignore_file_path, "%s/%s", config_home, "ag/ignore"); + } else if (home_dir) { + ag_asprintf(&ignore_file_path, "%s/%s", home_dir, ".agignore"); + } + if (ignore_file_path) { + load_ignore_patterns(root_ignores, ignore_file_path); + } free(ignore_file_path); }