mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
37 lines
2.5 KiB
Plaintext
37 lines
2.5 KiB
Plaintext
A format string is a string that contains placeholders for values.
|
|
These placeholders begin with a '{', containing the index of the value, and end with a '}'.
|
|
For example the format string "Values: {1} ({2})", with the values "First" and "My second val", will produce
|
|
The format string can contain placeholders in any order and have multiple occurences.
|
|
To include spaces when setting from the command line, surround the whole string with double quotes (").
|
|
|
|
If the value index is missing, meaning the placeholder is "{}", an internal counter sets the value index.
|
|
This means that the format string "Values: {1} ({2})" is equivalent to "Values: {} ({})".
|
|
Note that this counter only counts empty placeholders, so the format string "{2} {} {}" will contain the second v
|
|
|
|
To make formatting easier, a double open curly brace ("{{") will be printed as a single open curly brace and not
|
|
If a value index is misformatted or wants a non-existing value, it will be printed as is, with the curly braces aro
|
|
If the last placeholder isn't closed, it will be treated like it was at the end of the format string.
|
|
|
|
To only print something if a variable is set, use "{?<index>} ... {?}".
|
|
For example, to only print a second value if it is set, use "{?2} Second value: {2}{?}".
|
|
If a "{?}" is found without an opener, it is printed as is.
|
|
|
|
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.
|
|
For example to print a fallback for a second value if it is not set, use "{?2}{2}{?}{/2}Second value fallback{/}"
|
|
|
|
To stop formatting at any point in the format string, use "{-}".
|
|
|
|
To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.
|
|
"\\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
|
|
A "{#}" is equivalent to a "{#0}" and resets everything to normal.
|
|
For example to print something pink and underline, use "{#4;35}...{#}".
|
|
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Sele
|
|
Which escape codes are supported and how they look is defined by your terminal.
|
|
|
|
If a format string evaluates to an empty value, the whole line in the output will be discarded.
|
|
You can therefore use --host-format " " to disable host output.
|
|
Note that --host-format "" would evaluate as not set, and therefore use the built-in host format
|
|
|
|
Format string is also the way to go to set a fixed value - just use one without placeholders.
|
|
For example when running in headless mode, you could use "--resolution-format "Preferred".
|