Skip to content

No option for forcing styled output (a.k.a. better fzf support) #4035

@slafs

Description

@slafs

Describe the feature or problem you’d like to solve

Hello. As mentioned in #364 (comment) by @mislav:

We aim to enable the fzf usage as you are describing in a future release ✨

and later encouraged by @vilmibm I'm opening this issue.

I'm trying to put together a simple terminal PR viewer with gh and fzf. E.g. trying something like:

gh pr list | fzf --preview 'gh pr view {1}'

but the output in the preview window isn't "prettified" e.g. with glamour markdown or anything like that, just plain text, because, as expected, the command in the preview option can't find interactive terminal.

I can get some colors when setting CLICOLOR_FORCE env var,
but setting GLAMOUR_STYLE (as suggested by gh help environment) doesn't seem to influence anything.

Proposed solution

A usual approach in CLI programs that can be successfully combined with fzf preview
is to have an option to force coloured/styled output even when no tty is found.
E.g. bat has --color=always
or glow (a markdown console renderer that also uses glamour) has --style=...,
so I can preview markdown files with fzf and glow e.g. with:

ls *md | fzf --preview 'glow --style=dark {}'

Additional context

Note that using GLAMOUR_STYLE doesn't work with glow either. I.e.

export GLAMOUR_STYLE=dark
ls .md | fzf --preview 'glow {}'

doesn't give me prettified output.
So it might be that the issue is in the library itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions