Configuration

findfmt supports flexible, structured configuration loading through standard TOML files. This enables setting persistent personal defaults or project-level standards for output formatting, visual styling, traversal boundaries, and tag filtering.


1. Configuration Resolution Hierarchy

When findfmt executes, it determines effective settings according to a strict six-tier hierarchy where higher-priority sources override lower-priority sources:

  1. Explicit CLI arguments and flags (Highest Priority): Direct options passed on the command line (e.g. --format table, --no-hidden, -t python) always override environment variables and file settings.

  2. Environment Variables: FINDFMT_<KEY> schema environment variables (e.g. FINDFMT_FORMAT, FINDFMT_MAX_DEPTH, FINDFMT_HIDDEN, FINDFMT_TAGS) and system environment settings (NO_COLOR, CLICOLOR, CLICOLOR_FORCE, LANGUAGE, LC_*) override configuration file defaults while yielding to explicit command-line flags.

  3. Explicit Configuration File: A custom configuration path specified via --config <path> or the FINDFMT_CONFIG environment variable.

  4. Project Local Configuration: A .findfmt.toml file or a pyproject.toml file containing a [tool.findfmt] table, discovered by walking up from the current working directory to the repository VCS root (.git, .hg, or .svn), or checked in the current working directory when outside a repository.

  5. Standard User Configuration Path: User-level configuration located at $XDG_CONFIG_HOME/findfmt/config.toml (or ~/.config/findfmt/config.toml on POSIX systems; %APPDATA%\findfmt\config.toml on Windows). When both user and project configurations exist, they are merged with project settings overriding user settings (user < project < env < CLI).

  6. Built-in Defaults (Lowest Priority): Factory default options (format = "text", color = "auto", pager = "auto", etc.).

Note

Passing --no-config on the command line or setting FINDFMT_CONFIG="" completely suppresses discovery and loading of TOML configuration files, while FINDFMT_<KEY> environment variables and explicit command-line flags continue to apply.


2. Configuration Inspection

To inspect the currently active configuration file and resolved settings:

findfmt --show-config

When custom options are active, findfmt outputs the active path and the effective configuration table, annotating each setting with an inline comment indicating its value provenance (default, config, user config, project config, env, or cli):

Active configuration: /home/user/.config/findfmt/config.toml

[tool.findfmt]
color = "always"  # config
format = "table"  # env
hidden = true  # cli
table_style = "rounded"  # config

To view configuration status as part of general system diagnostics:

findfmt --diagnostics

To generate a self-documenting, annotated reference configuration file directly from the CLI:

mkdir -p ~/.config/findfmt
findfmt --generate-config > ~/.config/findfmt/config.toml

The repository and source distribution also include a practical sample configuration at examples/config.toml and the full annotated reference template at examples/config.reference.toml.


3. Configuration File Formats

findfmt natively parses configuration using standard TOML. Configuration can be defined either in a standalone config.toml file or embedded inside a repository’s pyproject.toml.

3.1. Standalone config.toml

A standalone file can place options at top level or under a [tool.findfmt] table:

# ~/.config/findfmt/config.toml

# Default output serialization format (text, table, tree, json, etc.)
format = "table"

# Border style for table and tree formatters (rounded, grid, ascii, etc.)
table_style = "rounded"

# ANSI color policy: "auto", "always", or "never"
color = "auto"

# Terminal pager policy: "auto", "always", or "never"
pager = "auto"

# Include hidden files (dotfiles) by default
hidden = false

# Honor .gitignore and global gitignore files (true) or ignore them (false)
ignore = true

# Default tags to include
tags = ["python", "shell"]

# Maximum directory descent depth
max_depth = 5

# Group directories first
dirs_first = true

3.2. Project Configuration (.findfmt.toml and pyproject.toml)

In repositories managed by modern Python tooling (uv, hatch, flit, poetry), findfmt searches upward from the current working directory to the repository VCS root (.git, .hg, or .svn) for a standalone .findfmt.toml file or a pyproject.toml file containing a [tool.findfmt] table:

# pyproject.toml

[tool.findfmt]
format = "tree"
table_style = "rounded"
tags = ["python"]
exclude_tags = ["text"]
ignore = true
hidden = false
dirs_first = true

3.3. Environment Variables (FINDFMT_<KEY>)

Every schema key in the reference table below can also be configured via an uppercase FINDFMT_<KEY> environment variable. Environment variables override TOML configuration files and are overridden by explicit CLI flags:

export FINDFMT_FORMAT="table"
export FINDFMT_MAX_DEPTH="2"
export FINDFMT_HIDDEN="true"
export FINDFMT_TAGS="python,shell"

Environment variable values are coerced and validated against the configuration schema:

  • Boolean Values: Case-insensitive 1, true, yes, or on (true), and 0, false, no, or off (false).

  • Integers: Non-negative base-10 integers (e.g. 0, 1, 100).

  • String Lists: Comma-separated items (e.g. python,shell) or TOML/JSON array syntax (e.g. ["python", "shell"]).

  • Empty Values: Setting FINDFMT_<KEY>="" is treated as unset and ignored.

  • Validation: Unrecognized FINDFMT_* keys (other than FINDFMT_CONFIG and FINDFMT_CONTAINER_TESTS) or invalid values exit with code 2 and a descriptive error message.


4. Configuration Schema Reference

Setting

Type

CLI Equivalent

Description

Default

format

string

-f, --format

Output serialization format (text, table, tree, json, yaml, csv, tsv, xml, html, markdown, rst, jsonl, csv-table).

"text"

html

string

-H, --html

Render output as an HTML5 document with hyperlinks prefixed by BASEHREF.

None

title

string

-T, --title

Document <title> and <h1> heading for HTML output.

None

no_links

bool

--nolinks / --no-nolinks

Suppress hyperlink anchors in HTML output, rendering plain text paths.

false

csv_safe

bool

--csv-safe / --no-csv-safe

Prefix formula triggers in CSV/TSV cells with single quote to prevent spreadsheet formula injection.

false

allow_outside_root

bool

--allow-outside-root / --no-allow-outside-root

Allow --from-file paths that resolve outside the traversal root directory.

false

table_style

string

--table-style

Table border style (rounded, grid, ascii, minimal, etc.).

None

no_indent

bool

-i, --no-indent / --indent

Omit branch indentation lines in tree format and strip extraneous whitespace in structured formats.

false

ansi_lines

bool

-A, --ansi-lines / --no-ansi-lines

Use ANSI/VT100 line drawing escapes for tree indentation lines.

false

cp437

bool

-S, --cp437 / --no-cp437

Use CP437 console graphics characters for tree indentation lines.

false

color

string / bool

-C / -n

Color policy: "auto", "always", "never", or boolean.

"auto"

pager

string / bool

--pager / --no-pager

Terminal paging policy: "auto", "always", "never", or boolean.

"auto"

hidden

bool

-a, --all / --no-all

Include dotfiles and hidden directories in traversal.

false

ignore

bool

--no-ignore / --ignore

Respect .gitignore and global gitignore rules (true to honor, false to disable).

true

gitignore_file

string

--gitignore-file

External .gitignore file path applied across the traversal scope.

None

tags

list[str] / str

-t, --tag

Default tag inclusions.

[]

exclude_tags

list[str] / str

-e, --exclude-tag

Default tag exclusions.

[]

all_tags

bool

--all-tags

Require all specified tags to match rather than any tag.

false

sort

string

--sort

Sort key criterion (name, size, mtime, ctime, version, none).

"name"

unsorted

bool

-U, --unsorted

Yield entries in raw filesystem order without sorting (equivalent to --sort=none).

false

reverse

bool

-r, --reverse

Reverse sort ordering.

false

dirs_first

bool

--dirsfirst

Group directories before files.

false

files_first

bool

--filesfirst

Group files before directories.

false

follow_symlinks

bool

-l, --follow-links / --follow-symlinks

Follow symbolic links during traversal and classify target contents (by default, symlinks are listed as link entries without following).

false

dirs_only

bool

-d, --dirs-only

Emit directories only and suppress files.

false

one_file_system

bool

-x, --one-file-system

Confine traversal to the starting directory’s filesystem device.

false

max_depth

int

-L, --max-depth

Maximum directory descent depth limit.

None

file_limit

int

--filelimit

Directory entry count threshold.

None

prune

bool

--prune

Omit directories containing zero matching items.

false

pattern

list[str] / str

-P, --pattern

Wildcard filename include patterns.

[]

exclude_pattern

list[str] / str

-I, --exclude-pattern

Wildcard filename exclude patterns.

[]

ignore_case

bool

--ignore-case

Case-insensitive pattern matching.

false

match_dirs

bool

--match-dirs

Inherit pattern matches to subdirectories.

false

shebang

string

--shebang

Interpreter shebang pattern filter.

None

absolute

bool

--absolute

Output absolute paths instead of relative paths.

false

relative

bool

--relative

Prepend search prefix to relative paths.

false

print0

bool

-0, --print0

Delimit paths with NUL (\0) character for xargs -0.

false

list_tags

bool

--list-tags

Display detected format and content tags.

false

summary

bool

-s, --summary

Print match count statistics to stderr.

false

exit_status

bool

--exit-status

Exit with code 1 if no matching files are found.

false

permissions

bool

-p, --permissions

Format file permissions in ls -l style.

false

user

bool

-u, --user

Display file owner username or UID.

false

group

bool

-g, --group

Display file group name or GID.

false

inodes

bool

--inodes / --no-inodes

Print filesystem inode number (st_ino).

false

device

bool

--device / --no-device

Print filesystem device number (st_dev).

false

size

bool

--size

Print file size in bytes.

false

human_readable

bool

-h, --human-readable

Format file sizes using binary units (KiB, MiB).

false

si

bool

--si

Format file sizes using SI metric units (kB, MB).

false

du

bool

--du

Accumulate recursive directory disk usage.

false

mtime

bool

-D, --mtime

Display file last modification date and time.

false

ctime

bool

--ctime

Display last file status change date and time.

false

time_format

string

--time-format

Custom strftime syntax format string.

None

classify

bool

-F, --classify

Append file type indicators (/, *, @, etc.).

false

hide_control_chars

bool

-q, --hide-control-chars

Replace non-printable control characters in filenames with ?.

false

literal

bool

-N, --literal

Print non-printable control characters literally without masking.

false

quote_name

bool

-Q, --quote-name

Enclose filenames in double quotes.

false

hyperlink

bool

--hyperlink

Render paths as OSC 8 terminal hyperlinks.

false

hyperlink_schema

string

--hyperlink-schema

URI schema prefix for terminal hyperlinks.

"file://"

hyperlink_authority

string

--hyperlink-authority

Authority or hostname component for terminal hyperlinks.

None

locale

string

--locale

Default display and translation locale.

None

Note

The legacy tree, json, and xml boolean configuration keys (and their FINDFMT_TREE, FINDFMT_JSON, and FINDFMT_XML environment counterparts) emit a deprecation warning in 1.x and will be removed in v2.0.0. Use format = "tree", format = "json", or format = "xml" (or FINDFMT_FORMAT) instead.


5. Troubleshooting & Diagnostics

  • Syntax Errors: If a configuration file contains invalid TOML syntax, findfmt displays an informative syntax error and exits with code 2:

    Error: Invalid TOML in configuration file '/home/user/.config/findfmt/config.toml': Expected '=' after a key in a key/value pair (at line 4, column 1)
    
  • Unknown Keys: If an unsupported or misspelled key is provided, findfmt rejects the configuration:

    Error: Unknown configuration key 'frmat' in '/home/user/.config/findfmt/config.toml'.
    
  • Type Mismatches: Supplying an unexpected type (e.g., a string where a boolean is required) triggers a clear validation error:

    Error: Invalid value for 'hidden' in '/home/user/.config/findfmt/config.toml': expected boolean (true/false), got str
    
  • Bypassing Configuration: In scripts or CI environments where deterministic, clean-room behavior is required regardless of existing user configurations, supply --no-config:

    findfmt --no-config -t python