1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-27 03:53:30 +00:00

docs(config): clarify special characters escaping (#3313)

This commit is contained in:
Kid 2021-12-13 04:51:13 +08:00 committed by GitHub
parent b4a14e3a80
commit faa9050f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,7 @@ You can use texts, variables and text groups in a format string.
#### Variable #### Variable
A variable contains a `$` symbol followed by the name of the variable. A variable contains a `$` symbol followed by the name of the variable.
The name of a variable only contains letters, numbers and `_`. The name of a variable can only contain letters, numbers and `_`.
For example: For example:
@ -112,21 +112,13 @@ For example:
- When `$all` is a shortcut for `\[$a$b\] `, `($all)` will show nothing only if `$a` and `$b` are both `None`. - When `$all` is a shortcut for `\[$a$b\] `, `($all)` will show nothing only if `$a` and `$b` are both `None`.
This works the same as `(\[$a$b\] )`. This works the same as `(\[$a$b\] )`.
#### Escapable characters #### Special characters
The following symbols have special usage in a format string. The following symbols have special usage in a format string and must be escaped: `$ \ [ ] ( )`.
If you want to print the following symbols, you have to escape them with a backslash (`\`).
- \$ Note that TOML has [both basic strings and literal strings](https://toml.io/en/v1.0.0#string).
- \\ It is recommended to use a literal string (surrounded by single quotes) in your config.
- [ If you want to use a basic string (surrounded by double quotes), you must escape the backslash itself (i.e. use `\\`).
- ]
- (
- )
Note that `toml` has [its own escape syntax](https://github.com/toml-lang/toml#user-content-string).
It is recommended to use a literal string (`''`) in your config.
If you want to use a basic string (`""`), pay attention to escape the backslash `\`.
For example, when you want to print a `$` symbol on a new line, the following configs for `format` are equivalent: For example, when you want to print a `$` symbol on a new line, the following configs for `format` are equivalent: