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