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