Skip to content

feat: add a config file - #1917

Draft
o2sh wants to merge 4 commits into
mainfrom
feat/config-file
Draft

o2sh wants to merge 4 commits into
mainfrom
feat/config-file

Conversation

@o2sh

@o2sh o2sh commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

What

Onefetch can now read its settings from a config file.

  • File: ~/.config/onefetch/config.jsonc (or $XDG_CONFIG_HOME/onefetch/config.jsonc). It's JSONC, so comments and trailing commas are allowed. Unknown keys are an error.
  • Sections: $schema, logo, display, general, modules.
  • modules: lists the fields to show, in order. An entry is a name ("head") or an object with options ({"type": "authors", "number": 5, "email": true}), and a field left out is hidden. This also makes field order configurable for the first time.
  • logo: null hides it, "rust" is a shorthand, and type/source accept auto, builtin, data, file, kitty, sixel, iterm and none.
  • Precedence: an option given on the command line always overrides the file.
  • Key layout: display.separator sets the text between a key and its value (default ": "). display.key.width pads keys so values line up in a column, and display.key.paddingLeft indents the keys. Every module except title and colors also accepts key (a custom label), keyColor and outputColor, for example {"type": "head", "key": "Tip", "keyColor": 9}. These options exist only in the config file, with no command-line flags.

New flags:

Flag Behavior
--config <CONFIG> Path, a name looked up in the config dirs, - for stdin, or none
--gen-config [PATH] Minimal config (the modules list). Refuses to overwrite an existing file. - prints it.
--gen-config-full [PATH] Every setting with its current value
--gen-config-force [PATH] Overwrites an existing file
--list-config-paths Prints the search directories

Generated configs include the current command-line options.

Also adds a JSON schema (docs/json_schema.json) for editor completion, a wiki page (docs/wiki/configuration.md), and updates to the README and ARCHITECTURE.md.

Why

To keep settings without a shell alias full of flags.

Notes for reviewers

  • No -c short flag: --config is long-only, since -c already means --ascii-colors.
  • Implementation: the config only fills in Cli fields that the command line didn't set, checked with clap's value_source. Everything after that is unchanged.
  • Field order: InfoArgs has a new fields: Option<Vec<FieldKind>> (#[arg(skip)]), set only by modules. The builder sorts fields by it, and --disabled-fields still filters on top.
  • Partial colors: the config can set a single color, such as only the key color. A gap is stored as UNSET_COLOR (u8::MAX), and TextColors and get_ascii_colors give that slot its default color. The command line can't produce this value because it only accepts 0 to 15.
  • Key layout implementation: the key layout is a new RenderOptions::key_layout (KeyLayout), stored in TextFormattingArgs as an #[arg(skip)] field and set only by the config. field_lines builds each line's prefix from the left padding, key and separator, and pads it to width. With the default layout the output is unchanged. Per-line colors use two new styles, Style::KeyColor(n) and Style::ValueColor(n). outputColor only recolors plain value text, so language chips, bars and the activity graph keep their colors.
  • Title and palette: title and colors in modules turn the title and the palette on or off, but they always print first and last.
  • New dependency: json-strip-comments for comments and trailing commas. Its only dependency, memchr, was already in the tree.
  • Man page: docs/onefetch.1 was not regenerated, because help2man isn't available here.
  • Tests: cover parsing, unknown keys, command-line precedence, logo and color handling, minimal output, a round trip through a full config, and that the schema's names match the code.

🤖 Generated with Claude Code

Load settings from ~/.config/onefetch/config.jsonc (JSONC, with $schema,
logo, display, general and modules sections, like fastfetch). The modules
list sets which fields are shown and in which order. Options given on the
command line override the file.

New flags: --config, --gen-config, --gen-config-full, --gen-config-force
and --list-config-paths. Adds a JSON schema and a wiki page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@o2sh o2sh changed the title feat: add a fastfetch-style config file feat: add a config file Nov 7, 2026
Add display.separator, display.key.width and display.key.paddingLeft, and
per-module key, keyColor and outputColor options, so the label, colors and
alignment of each info line can be changed from the config file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Colors can be written as names (black to white, light_black to
light_white, any case) as well as numbers from 0 to 15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — ec0ff404 Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant