Skip to content

Add option to generate not-colorized output #81

@divaltor

Description

@divaltor

Hello, thanks for this CLI, very helpful

Could we add option to generate output without ANSI color sequences because it pollutes context with unnecessary symbols and doesn't give any benefits to an agent. I'm using it via custom Opencode plugin and process output directly (not in bash) and colored sequences are useless in that case.

I tested it with NO_COLOR=1 CLICOLOR=0 CLICOLOR_FORCE=0 TERM=dumb colgrep --yes --results 1 --lines 2 "search something"

const { spawnSync } = require('node:child_process')

const result = spawnSync(
  'colgrep',
  ['--yes', '--results', '1', '--lines', '2', '--', 'search something'],
  {
    encoding: 'utf8',
    env: {
      ...process.env,
      NO_COLOR: '1',
      CLICOLOR: '0',
      CLICOLOR_FORCE: '0',
      TERM: 'dumb',
    },
  }
)

const output = `${result.stderr || ''}${result.stdout || ''}`
console.log('has ANSI:', /\u001b\[[0-?]*[ -/]*[@-~]/.test(output))
console.log(JSON.stringify(output.slice(0, 220)))

Option like --color=auto|always|never would help a lot, thanks

Might add option to disable line numbers from output too

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions