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