Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to display color when piped to custom pager #216

Open
Karmenzind opened this issue Dec 6, 2023 · 2 comments
Open

failed to display color when piped to custom pager #216

Karmenzind opened this issue Dec 6, 2023 · 2 comments

Comments

@Karmenzind
Copy link

Karmenzind commented Dec 6, 2023

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.

@sentientmachin3
Copy link

sentientmachin3 commented May 11, 2024

Did you solve this? I'm having this same issue, on ArchLinux.

@Karmenzind
Copy link
Author

@sentientmachin3 Unfortunately no. But it doesn't happen on my Archlinux. I'm using i3wm with xorg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants