8000 failed to display color when piped to custom pager · Issue #216 · fatih/color · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
failed to display color when piped to custom pager #216
Open
@Karmenzind

Description

@Karmenzind

Hi,
I need to invoke pager in my app to display long text. Here is the sample code:

package main

import (
	"fmt"
	"os"
	"os/exec"
	"strings"

	"github.com/fatih/color"
)

func main() {
    var Yellow = color.New(color.FgYellow).SprintfFunc()
    fmt.Println(Yellow("from fmt.Println"))

    var pager = exec.Command("less", "-F")
	pager.Stdin = strings.NewReader(Yellow("from pager"))
	pager.Stdout = os.Stdout

	err := pager.Run()
	if err != nil {
            fmt.Println(err)
	}
}

It worked on Archlinux:
image

but failed on Debian (bookworm, on rasberrypi) and latest MacOS:
image

I don't think this was caused by your package but I wonder if you have any idea how to fix it.
Thanks very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0