xref: /curl/docs/cmdline-opts/config.md (revision e7219c2b)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: config
5Arg: <file>
6Help: Read config from a file
7Short: K
8Category: curl
9Added: 4.10
10Multi: append
11See-also:
12  - disable
13Example:
14  - --config file.txt $URL
15---
16
17# `--config`
18
19Specify a text file to read curl arguments from. The command line arguments
20found in the text file are used as if they were provided on the command
21line.
22
23Options and their parameters must be specified on the same line in the file,
24separated by whitespace, colon, or the equals sign. Long option names can
25optionally be given in the config file without the initial double dashes and
26if so, the colon or equals characters can be used as separators. If the option
27is specified with one or two dashes, there can be no colon or equals character
28between the option and its parameter.
29
30If the parameter contains whitespace or starts with a colon (:) or equals sign
31(=), it must be specified enclosed within double quotes ("like this"). Within
32double quotes the following escape sequences are available: \\, \", \t, \n, \r
33and \v. A backslash preceding any other letter is ignored.
34
35If the first non-blank column of a config line is a '#' character, that line
36is treated as a comment.
37
38Only write one option per physical line in the config file. A single line is
39required to be no more than 10 megabytes (since 8.2.0).
40
41Specify the filename to --config as minus "-" to make curl read the file from
42stdin.
43
44Note that to be able to specify a URL in the config file, you need to specify
45it using the --url option, and not by simply writing the URL on its own
46line. So, it could look similar to this:
47
48    url = "https://curl.se/docs/"
49
50    # --- Example file ---
51    # this is a comment
52    url = "example.com"
53    output = "curlhere.html"
54    user-agent = "superagent/1.0"
55
56    # and fetch another URL too
57    url = "example.com/docs/manpage.html"
58    -O
59    referer = "http://nowhereatall.example.com/"
60    # --- End of example file ---
61
62When curl is invoked, it (unless --disable is used) checks for a default
63config file and uses it if found, even when --config is used. The default
64config file is checked for in the following places in this order:
65
661) **"$CURL_HOME/.curlrc"**
67
682) **"$XDG_CONFIG_HOME/curlrc"** (Added in 7.73.0)
69
703) **"$HOME/.curlrc"**
71
724) Windows: **"%USERPROFILE%\.curlrc"**
73
745) Windows: **"%APPDATA%\.curlrc"**
75
766) Windows: **"%USERPROFILE%\Application Data\.curlrc"**
77
787) Non-Windows: use getpwuid to find the home directory
79
808) On Windows, if it finds no *.curlrc* file in the sequence described above, it
81checks for one in the same directory the curl executable is placed.
82
83On Windows two filenames are checked per location: *.curlrc* and *_curlrc*,
84preferring the former. Older versions on Windows checked for *_curlrc* only.
85