reference Flags

--force-color

Accepted by
opengrep scan, opengrep ci, opengrep test, opengrep validate
Also spelled
--no-force-color
Environment
OPENGREP_FORCE_COLOR
See also
NO_COLOR, --skin

By default, Opengrep styles its output only when it writes to a terminal; output to a pipe or a file is plain text. --force-color keeps the styling. It also styles the text output written to files by --text-output and --output. --no-force-color turns it off.

The flag takes precedence over NO_COLOR and OPENGREP_FORCE_NO_COLOR. OPENGREP_FORCE_COLOR has the same effect.

Examples

Color through a pipe

rule.yaml
rules:  - id: find-eval    pattern: eval(...)    message: found eval    languages: [python]    severity: WARNING
app.py
eval(1)
Command and result
$ opengrep scan --config rule.yaml app.py | grep -q $'\e\[' && echo styled || echo plain
plain
$ opengrep scan --config rule.yaml --force-color app.py | grep -q $'\e\[' && echo styled || echo plain
styled