#2831·yay

Add config option for syntax-highlighted yay -Gp output

Author: shbernalCreated May 29, 2026Updated Aug 12, 2026
Labelshelp wanted

Is your feature request related to a problem? Please describe.

When using yay -Gp <package>, yay prints the fetched PKGBUILD to stdout as plain text. This is useful for quickly inspecting a package without cloning it, but repeated PKGBUILD inspection is harder than it needs to be because the output is not syntax-highlighted.

A one-off flag is not very useful here because users can already write:

bash
yay -Gp <package> | bat --language bash --style=plain --paging=never

The missing piece is a persistent yay configuration option so users can configure their preferred PKGBUILD viewer once and then simply run:

bash
yay -Gp yay

and get highlighted output automatically.

Describe the solution you would like

Add a config option for the command used to display PKGBUILD output from yay -Gp, for example:

ini
PkgbuildPager = bat --language bash --style=plain --paging=never

or an equivalent JSON/config key if that better matches the current configuration format.

When the option is unset, yay -Gp should keep the current plain stdout behavior. When set, yay should pipe the generated PKGBUILD output into the configured command, allowing users to use tools such as bat, less, or a wrapper script.

This keeps syntax highlighting opt-in, avoids adding bat as a hard dependency, and preserves the current script-friendly behavior by default.

Describe alternatives you have considered

  • Adding a command-line flag such as --highlight: less useful because it is not much better than manually piping to bat each time.
  • Automatically using bat when installed: less predictable and changes behavior depending on the machine.
  • Changing --color: confusing because yay already uses --color=always|auto|never for yay/pacman UI coloring, not syntax highlighting file contents.

Additional context

Related but not exactly the same as #2542, which discusses syntax-highlighted PKGBUILD review inside the normal review/diff flow. This request is specifically about the yay -Gp stdout path and making the viewer/highlighter configurable so it works seamlessly for repeated use.