Skip to content

zsh completion emits ANSI color codes when FORCE_COLOR=1 is set #2560

Description

@troykirin

When FORCE_COLOR=1 is set in the environment (common for users who want colored output from CLI tools), the zsh completion for task emits raw ANSI escape codes instead of clean task names.

Steps to reproduce

export FORCE_COLOR=1
task <Tab>

Expected behavior

Clean completion list of task names

Actual behavior

Completion shows literal escape codes like $'\033'\[

Environment

  • task version: 3.45.4
  • Shell: zsh 5.9
  • OS: macOS 14.x (Darwin)

Root cause

The __task_list() function in task --completion zsh runs task --list-all which respects FORCE_COLOR and emits colored output. The ANSI codes then leak into zsh's completion system.

Suggested fix

The completion script should either:

  1. Pass --color=false when calling task for completion, or
  2. Wrap the call with NO_COLOR=1 / FORCE_COLOR=

Current workaround

Override __task_list() after compinit to use:

cmd=(env FORCE_COLOR= CLICOLOR_FORCE= NO_COLOR=1 task --color=false)

Activity

  1. trulede commented on Dec 8, 2025

    @trulede
    Contributor

    @troykirin could you set envar GO_TASK_COMPLETION_LIST_OPTION to GO_TASK_COMPLETION_LIST_OPTION=--color=false --list-all and see if that also works. That could be a better way to solve it.

  2. added
    state: working as intendedThe issue described is working as originally intended.
    and removed
    state: needs triageWaiting to be triaged by a maintainer.
    on Dec 8, 2025
  3. added
    area: uiChanges related to the UI of Task.
    and removed on Dec 16, 2025
  4. added theissue type on Dec 16, 2025
  5. trulede commented on Dec 16, 2025

    @trulede
    Contributor

    @troykirin you will probably need to set the envar as suggested. However, there is also a small odd behaviour which PR #2584 would address.

    GO_TASK_COMPLETION_LIST_OPTION=--color=false --list-all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: completionsChanges related to shell completions and scripts.area: uiChanges related to the UI of Task.state: working as intendedThe issue described is working as originally intended.

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions