junegunn/fzf · error
only ANSI attributes are allowed for 'nth' (regular, bold, u
Error message
only ANSI attributes are allowed for 'nth' (regular, bold, underline, reverse, dim, italic, strikethrough)
What it means
The 'nth' color theme attribute in fzf is used for highlighting matched character positions within each field using ANSI text attributes only; it cannot carry colors. The check at options.go:3658 fires when opts.Theme.Nth.IsColorDefined() is true, i.e. the --color=nth:... specification included a foreground or background color.
Source
Thrown at src/options.go:3658
}
}
}
if opts.Height.auto && (opts.Tmux == nil || opts.Tmux.index < opts.Height.index) {
for _, s := range []sizeSpec{opts.Margin[0], opts.Margin[2]} {
if s.percent {
return errors.New("adaptive height is not compatible with top/bottom percent margin")
}
}
for _, s := range []sizeSpec{opts.Padding[0], opts.Padding[2]} {
if s.percent {
return errors.New("adaptive height is not compatible with top/bottom percent padding")
}
}
}
if opts.Theme.Nth.IsColorDefined() {
return errors.New("only ANSI attributes are allowed for 'nth' (regular, bold, underline, reverse, dim, italic, strikethrough)")
}
if opts.BorderShape == tui.BorderInline ||
opts.ListBorderShape == tui.BorderInline ||
opts.InputBorderShape == tui.BorderInline ||
opts.Preview.border == tui.BorderInline {
return errors.New("inline border is only supported for --header-border, --header-lines-border, and --footer-border")
}
if opts.HeaderBorderShape == tui.BorderInline &&
opts.HeaderLinesShape != tui.BorderInline &&
opts.HeaderLinesShape != tui.BorderUndefined &&
opts.HeaderLinesShape != tui.BorderNone {
return errors.New("--header-border=inline requires --header-lines-border to be inline or unset")
}
return nil
}
View on GitHub (pinned to bd4efa277b)
Solutions
- Use only ANSI attributes for nth, e.g. --color=nth:bold,underline
- Use a different theme slot (e.g. 'matched' via --color=fg+/bg+ for the current line) for colors
- Remove color components from the nth entry in your theme
Example fix
# before fzf --color=nth:green # after fzf --color=nth:bold,underline
Defensive patterns
Strategy: validation
Validate before calling
// Shell: allow only attribute words in nth attrs='regular bold underline reverse dim italic strikethrough' nth=$(echo "$nth" | tr ',' '\n' | while read -r t; do [[ $attrs == *"$t"* ]] && printf '%s,' "$t" done | sed 's/,$//') exec fzf --color="nth:$nth"
Type guard
func isAnsiAttr(s string) bool {
switch s {
case "regular", "bold", "underline", "reverse", "dim", "italic", "strikethrough":
return true
}
return false
} Prevention
- Treat 'nth' as attribute-only: never put fg/bg colors there
- Use --color=fg+/bg+ or 'matched' styling slots for colors
- Lint theme files for color components in nth
When it happens
Trigger: Passing a color in the nth theme slot, e.g. --color=nth:green or --color=nth:fg=red,bg=black. Any defined color on Nth triggers the error; only attributes like bold, underline, reverse, dim, italic, strikethrough, regular are accepted.
Common situations: Copy-pasting color schemes from themes/dotfiles written for other fzf versions or other tools; assuming every --color slot accepts fg/bg; trying to make matches more visible with a color instead of an attribute.
Related errors
- unknown action: ${spec}
- invalid layout (expected: default / reverse / reverse-list)
- invalid info style (expected: default|right|hidden|inline[-r
- history max must be a positive integer
- number of items to keep must be a positive integer
AI-assisted analysis of junegunn/fzf@bd4efa277b (2026-08-15).
Data as JSON: /api/errors/3a47bb6cd9af623b.
Report an issue: GitHub.