This document describes the output formatting and display configuration system in fastfetch. It covers the structure, configuration, and runtime behavior of the output pipeline, focusing on the FFOptionsDisplay system and its related code. This includes color schemes, key/value formatting, percentage bars, temperature/size/frequency formatting, and output modes (text, JSON, pipe).
Scope:
FFOptionsDisplay.Not covered here:
The output formatting and display options system is responsible for controlling the visual and structural aspects of fastfetch's output. It acts as the bridge between the configuration state (FFconfig), the format engine, and the final output system. It enables users to customize how information is presented, including:
This system is implemented primarily through the FFOptionsDisplay struct and its associated parsing and application logic.
Sources:
src/options/display.h src/options/display.c doc/json_schema.json src/common/percent.h src/common/percent.c src/common/temps.h src/common/temps.c
Below is a diagram mapping the main display and formatting configuration system to its code entities.
Sources:
src/options/display.h src/options/display.c doc/json_schema.json src/common/percent.c src/common/temps.c src/common/format.c
Display and formatting options can be set via:
The main code entry points for parsing these options are:
| Source | Function/Handler | File |
|---|---|---|
| JSON config | ffOptionsParseDisplayJsonConfig | src/options/display.c |
| Command-line options | ffOptionsParseDisplayCommandLine | src/options/display.c |
| JSON schema | doc/json_schema.json | doc/json_schema.json |
Sources:
src/options/display.c10-521 src/options/display.c533-9999 doc/json_schema.json
The FFOptionsDisplay struct holds all display and formatting options. It is a field of the global FFconfig struct and is referenced throughout the output pipeline.
FFOptionsDisplay| Field Name | Purpose | Example Option(s) |
|---|---|---|
colorKeys | Color for module keys | --color-keys, display.color |
colorTitle | Color for the title line | --color-title |
colorOutput | Color for module output values | --color-output |
colorSeparator | Color for key-value separator | --color-separator |
brightColor | Use bright colors for keys/title/logo | --bright-color |
keyValueSeparator | String between key and value | --separator |
keyType | Key display type (string, icon, both, none) | --key-type |
keyWidth | Width for key alignment | --key-width |
keyPaddingLeft | Left padding for keys | --key-padding-left |
pipe | Disable all escape sequences (plain output) | --pipe |
showErrors | Show errors in output | --show-errors |
disableLinewrap | Disable terminal line wrapping | --disable-linewrap |
hideCursor | Hide cursor during output | --hide-cursor |
percentType | Percentage output type (number, bar, both, etc.) | --percent-type |
percentNdigits | Digits after decimal for percentages | --percent-ndigits |
percentColorGreen | Color for "green" state in percentages | --percent-color-green |
percentColorYellow | Color for "yellow" state in percentages | --percent-color-yellow |
percentColorRed | Color for "red" state in percentages | --percent-color-red |
barCharElapsed | Character for filled part of bar | --bar-char-elapsed |
barCharTotal | Character for unfilled part of bar | --bar-char-total |
barBorderLeft | Left border string for bar | --bar-border-left |
barBorderRight | Right border string for bar | --bar-border-right |
barColorElapsed | Color for filled part of bar | --bar-color-elapsed |
barColorTotal | Color for unfilled part of bar | --bar-color-total |
barColorBorder | Color for bar borders | --bar-color-border |
barWidth | Width of percentage bars | --bar-width |
sizeBinaryPrefix | Binary prefix type for sizes (IEC, SI, JEDEC) | --size-binary-prefix |
sizeNdigits | Digits after decimal for sizes | --size-ndigits |
sizeMaxPrefix | Maximum size prefix (e.g., GiB, TiB) | --size-max-prefix |
sizeSpaceBeforeUnit | Space before size unit | --size-space-before-unit |
tempUnit | Temperature unit (C, F, K) | --temp-unit |
tempNdigits | Digits after decimal for temperature | --temp-ndigits |
tempColorGreen/Yellow/Red | Colors for temperature ranges | --temp-color-green etc. |
tempSpaceBeforeUnit | Space before temperature unit | --temp-space-before-unit |
freqNdigits | Digits after decimal for frequency | --freq-ndigits |
freqSpaceBeforeUnit | Space before frequency unit | --freq-space-before-unit |
fractionNdigits | Digits after decimal for fractions | --fraction-ndigits |
fractionTrailingZeros | Keep trailing zeros in fractions | --fraction-trailing-zeros |
noBuffer | Disable stdout buffering | --no-buffer |
constants | List of user-defined constants for format strings | display.constants |
Sources:
src/options/display.h35-94 doc/json_schema.json
Display options are defined in the JSON schema (doc/json_schema.json) and mapped to both config file fields and command-line arguments.
Sources:
doc/json_schema.json src/options/display.c10-521 src/options/display.c533-9999
fastfetch supports extensive color customization for keys, values, separators, bars, and more. Colors can be set globally or per-module.
colorKeys, colorTitle, colorOutput, colorSeparator, percentColorGreen, percentColorYellow, percentColorRed, barColorElapsed, barColorTotal, barColorBorder, tempColorGreen, tempColorYellow, tempColorRed"red", "light_blue"), ANSI codes, or hex codes (see Color Format Specification)pipe is enabled, all color codes are suppressed for plain output.Example:
Sources:
doc/json_schema.json src/options/display.c50-74 src/options/display.h38-41
keyType).keyWidth, keyPaddingLeft).keyValueSeparator).brightColor).Example:
Sources:
doc/json_schema.json src/options/display.c437-471 src/options/display.h85-87
fastfetch provides flexible options for displaying percentages and visual bars (e.g., for memory, disk, battery).
percentType)percentNdigits)percentWidth, barWidth)barCharElapsed, barCharTotal)barBorderLeft, barBorderRight, etc.)| Value | Meaning | Description |
|---|---|---|
| 1 | num | Show percentage number |
| 2 | bar | Show bar |
| 3 | num + bar | Show both |
| 6 | bar only | Bar only |
| 9 | num-color | Colored number |
| 10 | bar-monochrome | Monochrome bar |
Example:
Sources:
doc/json_schema.json src/common/percent.h src/common/percent.c src/options/display.h77-83 src/options/display.c228-393
fastfetch allows fine-grained control over how numeric values are formatted.
Size formatting:
sizeBinaryPrefix)sizeMaxPrefix)sizeNdigits)sizeSpaceBeforeUnit)Temperature formatting:
tempUnit)tempNdigits)tempColorGreen, etc.)tempSpaceBeforeUnit)Frequency formatting:
freqNdigits)freqSpaceBeforeUnit)Fraction formatting:
fractionNdigits)fractionTrailingZeros)Example:
Sources:
doc/json_schema.json src/options/display.c99-162 src/options/display.c163-227 src/options/display.c481-515 src/options/display.h57-91
pipe).--format json or --json).The output mode is auto-detected (e.g., disables colors if not writing to a TTY) or can be forced via options.
Sources:
src/data/help.json src/options/display.c41-42 src/options/display.h48
showErrors)stat)disableLinewrap)hideCursor)Sources:
src/options/display.c20-47 src/options/display.h47-56
Sources:
doc/json_schema.json
At runtime, the display options are referenced by the output and formatting functions. For example:
ffPercentAppendBar and ffPercentAppendNum use the percentage and bar options to render visual bars and numbers.ffTempsAppendNum uses temperature formatting and color thresholds.ffParseFormatString applies color, key, and value formatting as specified in FFOptionsDisplay.Sources:
src/common/percent.c src/common/temps.c src/common/format.c src/options/display.h
The output formatting and display options system in fastfetch provides a comprehensive and flexible mechanism for customizing the appearance and structure of output. It is implemented via the FFOptionsDisplay struct, which is populated from config files and command-line arguments, and is referenced throughout the output pipeline to control colors, formatting, and output modes.
For further details on the template/format string engine, see Format String System. For logo rendering, see Logo Rendering System.
Sources for this page:
src/options/display.h src/options/display.c doc/json_schema.json src/common/percent.h src/common/percent.c src/common/temps.h src/common/temps.c src/common/format.c src/data/help.json
Refresh this wiki
This wiki was recently refreshed. Please wait 1 day to refresh again.