Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Configure File Support - Version 2 #709

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
@@ -1,7 +1,7 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}

bin_PROGRAMS = ag
ag_SOURCES = src/ignore.c src/ignore.h src/log.c src/log.h src/options.c src/options.h src/print.c src/print_w32.c src/print.h src/scandir.c src/scandir.h src/search.c src/search.h src/lang.c src/lang.h src/util.c src/util.h src/decompress.c src/decompress.h src/uthash.h src/main.c
ag_SOURCES = src/ignore.c src/ignore.h src/log.c src/log.h src/options.c src/options.h src/print.c src/print_w32.c src/print.h src/scandir.c src/scandir.h src/search.c src/search.h src/lang.c src/lang.h src/util.c src/util.h src/decompress.c src/decompress.h src/uthash.h src/main.c src/ag_rc.c src/ag_rc.h
ag_LDADD = ${PCRE_LIBS} ${LZMA_LIBS} ${ZLIB_LIBS} $(PTHREAD_LIBS)

dist_man_MANS = doc/ag.1
Expand Down
1 change: 1 addition & 0 deletions Makefile.w32
Expand Up @@ -13,6 +13,7 @@ SRCS = \
src/print.c \
src/scandir.c \
src/search.c \
src/ag_rc.c \
src/util.c \
src/print_w32.c
OBJS = $(subst .c,.o,$(SRCS))
Expand Down
76 changes: 75 additions & 1 deletion doc/ag.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "AG" "1" "February 2015" "" ""
.TH "AG" "1" "July 2015" "" ""
.
.SH "NAME"
\fBag\fR \- The Silver Searcher\. Like ack, but faster\.
Expand Down Expand Up @@ -243,5 +243,79 @@ Use the \fB\-t\fR option to search all text files; \fB\-a\fR to search all files
.P
\fBag foo /bar/\fR: Find matches for "foo" in path /bar/\.
.
.SH "CONFIGURATION FILES"
Ag reads \fBOPTIONS\fR from one of several configuration
files. Ag processes "config file" options \fBbefore\fR command-line
options. The config file format is very simple:
.P
.RS 4
# this is a comment => inline comments not supported
.br
# blank lines okay as well
.P
.br
\-\-long-option[=value]
.br
\-short-option[=value]
.br
\-\-long-option[ value]
.br
\-short-option[ value]
.P
.br
# And special keywords (of which there is only one)
.br
list
.RE
.P
Actual Example Config File
.br
==========================
.br
# set up nice colors for a white terminal bkgnd...
.P
.br
# bold blue
.br
\-\-color\-line\-number=1;34
.br
# black with grey bkgnd
.br
\-\-color\-match=30;47
.br
# green
.br
\-\-color\-path=32
.P
If the keyword "list" is included in a config file,
ag dumps the contents of argv[] on stdout. This is useful
for debugging config file errors that cause ag to output a usage
message and then silently exit.
.
.SH "CONFIGURATION FILE LOCATIONS"
Ag reads configuration information from a number of possible locations, in
the following order (first file found is used, all others ignored):
.RS
.P
.nf
1. \fIPath specified in $AGRC_PATH\fR
.br
2. \fI$XDG_CONFIG_HOME/agrc\fR
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly suggest this not be put directly into the XDG_CONFIG_HOME. Instead, I would suggest using a subdirectory of XDG_CONFIG_HOME the same way git and others do: $XDG_CONFIG_HOME/ag/agrc. It's been suggested in #1020 that the ignore lookup should also conform to XDG spec, and having these all in a single directory makes more sense than proliferating directly in the root of $XDG_CONFIG_HOME

.br
3. \fI~/.agrc\fR
.br
4. \fI/usr/local/etc/agrc\fR
.br
5. \fI/etc/agrc\fR
.fi
.RE
.
.SH "ENVIRONMENT VARIABLES"
.
.TP
.
\fBAGRC_PATH\fR
Specifies a complete path to an ag configuration file.
.
.SH "SEE ALSO"
grep(1)