🎨 Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows.

CLI Color

GitHub go.mod Go version Actions Status Codacy Badge GoDoc GitHub tag (latest SemVer) Build Status Coverage Status Go Report Card

A command-line color library with true color support, universal API methods and Windows support.

中文说明

Basic color preview:

basic-color

Now, 256 colors and RGB colors have also been supported to work in Windows CMD and PowerShell:

color-on-cmd-pwsh

Features

  • Simple to use, zero dependencies
  • Supports rich color output: 16-color (4-bit), 256-color (8-bit), true color (24-bit, RGB)
    • 16-color output is the most commonly used and most widely supported, working on any Windows version
    • Since v1.2.4 the 256-color (8-bit), true color (24-bit) support windows CMD and PowerShell
    • See this gist for information on true color support
  • Generic API methods: Print, Printf, Println, Sprint, Sprintf
  • Supports HTML tag-style color rendering, such as message.
    • In addition to using built-in tags, it also supports custom color attributes
    • Custom color attributes support the use of 16 color names, 256 color values, rgb color values and hex color values
    • Support working on Windows cmd and powerShell terminal
  • Basic colors: Bold, Black, White, Gray, Red, Green, Yellow, Blue, Magenta, Cyan
  • Additional styles: Info, Note, Light, Error, Danger, Notice, Success, Comment, Primary, Warning, Question, Secondary
  • Support by set NO_COLOR for disable color or use FORCE_COLOR for force open color render.
  • Support Rgb, 256, 16 color conversion

GoDoc

Install

go get github.com/gookit/color

Quick start

package main

import (
	"fmt"

	"github.com/gookit/color"
)

func main() {
	// quick use package func
	color.Redp("Simple to use color")
	color.Redln("Simple to use color")
	color.Greenp("Simple to use color\n")
	color.Cyanln("Simple to use color")
	color.Yellowln("Simple to use color")

	// quick use like fmt.Print*
	color.Red.Println("Simple to use color")
	color.Green.Print("Simple to use color\n")
	color.Cyan.Printf("Simple to use %s\n", "color")
	color.Yellow.Printf("Simple to use %s\n", "color")

	// use like func
	red := color.FgRed.Render
	green := color.FgGreen.Render
	fmt.Printf("%s line %s library\n", red("Command"), green("color"))

	// custom color
	color.New(color.FgWhite, color.BgBlack).Println("custom color style")

	// can also:
	color.Style{color.FgCyan, color.OpBold}.Println("custom color style")

	// internal theme/style:
	color.Info.Tips("message")
	color.Info.Prompt("message")
	color.Info.Println("message")
	color.Warn.Println("message")
	color.Error.Println("message")

	// use style tag
	color.Print("hello, welcome\n")
	// Custom label attr: Supports the use of 16 color names, 256 color values, rgb color values and hex color values
	color.Println("hello, welcome")

	// apply a style tag
	color.Tag("info").Println("info style text")

	// prompt message
	color.Info.Prompt("prompt style message")
	color.Warn.Prompt("prompt style message")

	// tips message
	color.Info.Tips("tips style message")
	color.Warn.Tips("tips style message")
}

Run demo: go run ./_examples/demo.go

colored-out

Basic/16 color

Supported on any Windows version. Provide generic API methods: Print, Printf, Println, Sprint, Sprintf

color.Bold.Println("bold message")
color.Black.Println("bold message")
color.White.Println("bold message")
color.Gray.Println("bold message")
color.Red.Println("yellow message")
color.Blue.Println("yellow message")
color.Cyan.Println("yellow message")
color.Yellow.Println("yellow message")
color.Magenta.Println("yellow message")

// Only use foreground color
color.FgCyan.Printf("Simple to use %s\n", "color")
// Only use background color
color.BgRed.Printf("Simple to use %s\n", "color")

Run demo: go run ./_examples/color_16.go

basic-color

Custom build color

// Full custom: foreground, background, option
myStyle := color.New(color.FgWhite, color.BgBlack, color.OpBold)
myStyle.Println("custom color style")

// can also:
color.Style{color.FgCyan, color.OpBold}.Println("custom color style")

custom set console settings:

// set console color
color.Set(color.FgCyan)

// print message
fmt.Print("message")

// reset console settings
color.Reset()

Additional styles

provide generic API methods: Print, Printf, Println, Sprint, Sprintf

print message use defined style:

color.Info.Println("Info message")
color.Note.Println("Note message")
color.Notice.Println("Notice message")
color.Error.Println("Error message")
color.Danger.Println("Danger message")
color.Warn.Println("Warn message")
color.Debug.Println("Debug message")
color.Primary.Println("Primary message")
color.Question.Println("Question message")
color.Secondary.Println("Secondary message")

Run demo: go run ./_examples/theme_basic.go

theme-basic

Tips style

color.Info.Tips("Info tips message")
color.Note.Tips("Note tips message")
color.Notice.Tips("Notice tips message")
color.Error.Tips("Error tips message")
color.Danger.Tips("Danger tips message")
color.Warn.Tips("Warn tips message")
color.Debug.Tips("Debug tips message")
color.Primary.Tips("Primary tips message")
color.Question.Tips("Question tips message")
color.Secondary.Tips("Secondary tips message")

Run demo: go run ./_examples/theme_tips.go

theme-tips

Prompt Style

color.Info.Prompt("Info prompt message")
color.Note.Prompt("Note prompt message")
color.Notice.Prompt("Notice prompt message")
color.Error.Prompt("Error prompt message")
color.Danger.Prompt("Danger prompt message")
color.Warn.Prompt("Warn prompt message")
color.Debug.Prompt("Debug prompt message")
color.Primary.Prompt("Primary prompt message")
color.Question.Prompt("Question prompt message")
color.Secondary.Prompt("Secondary prompt message")

Run demo: go run ./_examples/theme_prompt.go

theme-prompt

Block Style

color.Info.Block("Info block message")
color.Note.Block("Note block message")
color.Notice.Block("Notice block message")
color.Error.Block("Error block message")
color.Danger.Block("Danger block message")
color.Warn.Block("Warn block message")
color.Debug.Block("Debug block message")
color.Primary.Block("Primary block message")
color.Question.Block("Question block message")
color.Secondary.Block("Secondary block message")

Run demo: go run ./_examples/theme_block.go

theme-block

256-color usage

256 colors support Windows CMD, PowerShell environment after v1.2.4

Set the foreground or background color

  • color.C256(val uint8, isBg ...bool) Color256
c := color.C256(132) // fg color
c.Println("message")
c.Printf("format %s", "message")

c := color.C256(132, true) // bg color
c.Println("message")
c.Printf("format %s", "message")

256-color style

Can be used to set foreground and background colors at the same time.

  • S256(fgAndBg ...uint8) *Style256
s := color.S256(32, 203)
s.Println("message")
s.Printf("format %s", "message")

with options:

s := color.S256(32, 203)
s.SetOpts(color.Opts{color.OpBold})

s.Println("style with options")
s.Printf("style with %s\n", "options")

Run demo: go run ./_examples/color_256.go

color-tags

RGB/True color

RGB colors support Windows CMD, PowerShell environment after v1.2.4

Preview:

Run demo: Run demo: go run ./_examples/color_rgb.go

color-rgb

example:

color.RGB(30, 144, 255).Println("message. use RGB number")

color.HEX("#1976D2").Println("blue-darken")
color.HEX("#D50000", true).Println("red-accent. use HEX style")

color.RGBStyleFromString("213,0,0").Println("red-accent. use RGB number")
color.HEXStyle("eee", "D50000").Println("deep-purple color")

Set the foreground or background color

  • color.RGB(r, g, b uint8, isBg ...bool) RGBColor
c := color.RGB(30,144,255) // fg color
c.Println("message")
c.Printf("format %s", "message")

c := color.RGB(30,144,255, true) // bg color
c.Println("message")
c.Printf("format %s", "message")

Create a style from an hexadecimal color string:

  • color.HEX(hex string, isBg ...bool) RGBColor
c := color.HEX("ccc") // can also: "cccccc" "#cccccc"
c.Println("message")
c.Printf("format %s", "message")

c = color.HEX("aabbcc", true) // as bg color
c.Println("message")
c.Printf("format %s", "message")

RGB color style

Can be used to set the foreground and background colors at the same time.

  • color.NewRGBStyle(fg RGBColor, bg ...RGBColor) *RGBStyle
s := color.NewRGBStyle(RGB(20, 144, 234), RGB(234, 78, 23))
s.Println("message")
s.Printf("format %s", "message")

Create a style from an hexadecimal color string:

  • color.HEXStyle(fg string, bg ...string) *RGBStyle
s := color.HEXStyle("11aa23", "eee")
s.Println("message")
s.Printf("format %s", "message")

with options:

s := color.HEXStyle("11aa23", "eee")
s.SetOpts(color.Opts{color.OpBold})

s.Println("style with options")
s.Printf("style with %s\n", "options")

HTML-like tag usage

Supported on Windows cmd.exe PowerShell .

// use style tag
color.Print("hello, welcome")
color.Println("hello")
color.Println("hello")
color.Println("hello")

// custom color attributes
color.Print("hello, welcome\n")

// Custom label attr: Supports the use of 16 color names, 256 color values, rgb color values and hex color values
color.Println("hello, welcome")
  • color.Tag
// set a style tag
color.Tag("info").Print("info style text")
color.Tag("info").Printf("%s style text", "info")
color.Tag("info").Println("info style text")

Run demo: go run ./_examples/color_tag.go

color-tags

Color convert

Supports conversion between Rgb, 256, 16 colors, Rgb <=> 256 <=> 16

basic := color.Red
basic.Println("basic color")

c256 := color.Red.C256()
c256.Println("256 color")
c256.C16().Println("basic color")

rgb := color.Red.RGB()
rgb.Println("rgb color")
rgb.C256().Println("256 color")

Func refer

There are some useful functions reference

  • Disable() disable color render
  • SetOutput(io.Writer) custom set the colored text output writer
  • ForceOpenColor() force open color render
  • Colors2code(colors ...Color) string Convert colors to code. return like "32;45;3"
  • ClearCode(str string) string Use for clear color codes
  • ClearTag(s string) string clear all color html-tag for a string
  • IsConsole(w io.Writer) Determine whether w is one of stderr, stdout, stdin
  • HexToRgb(hex string) (rgb []int) Convert hex color string to RGB numbers
  • RgbToHex(rgb []int) string Convert RGB to hex code
  • More useful func please see https://pkg.go.dev/github.com/gookit/color

Project use

Check out these projects, which use https://github.com/gookit/color :

Gookit packages

  • gookit/ini Go config management, use INI files
  • gookit/rux Simple and fast request router for golang HTTP
  • gookit/gcli build CLI application, tool library, running CLI commands
  • gookit/slog Concise and extensible go log library
  • gookit/event Lightweight event manager and dispatcher implements by Go
  • gookit/cache Generic cache use and cache manager for golang. support File, Memory, Redis, Memcached.
  • gookit/config Go config management. support JSON, YAML, TOML, INI, HCL, ENV and Flags
  • gookit/color A command-line color library with true color support, universal API methods and Windows support
  • gookit/filter Provide filtering, sanitizing, and conversion of golang data
  • gookit/validate Use for data validation and filtering. support Map, Struct, Form data
  • gookit/goutil Some utils for the Go: string, array/slice, map, format, cli, env, filesystem, test and more
  • More, please see https://github.com/gookit

See also

License

MIT

Owner
Gookit
🧰 Useful libs for the Go(router, console, log, config, cache, event, validate, filter, i18n, respond-data, view-render, DI)
Gookit
Comments
  • colors don't work on windows with git for windows while using vscode

    colors don't work on windows with git for windows while using vscode

    System (please complete the following information):

    • OS: Windows 10
    • GO Version: 1.1.5
    • Pkg Version: Latest

    Describe the bug

    A clear and concise description of what the bug is.

    To Reproduce

    Use my module and run go test -v .

    Expected behavior

    A clear and concise description of what you expected to happen.

    Same output as Windows Terminal

    image

    Screenshots

    What I get:

    image

    Additional context

    The screenshot is from VsCode but the same problem doesn't happen in Git Bash.

  • Color not working on Manjaro

    Color not working on Manjaro

    Here the output from the demo, I was expecting your nice colors: unfortunately it's all white.

    image

    What do you think the problem is ? Did you encounter such problem ?

    • NeoFetch output if needed:
    OS: Manjaro Linux x86_64 
    Kernel: 4.19.81-1-MANJARO
    Shell: bash 5.0.11 
    Resolution: 1920x1080 
    WM: i3 
    Theme: Adwaita [GTK3] 
    Icons: Adwaita [GTK3] 
    Terminal: urxvt 
    Terminal Font: DejaVu Sans Mono
    

    Thank you for your time,

  • No color after v1.4.0 upgrade

    No color after v1.4.0 upgrade

    System:

    • OS: linux
    • GO Version: 1.16
    • Pkg Version: 1.4.0
    TERM=xterm
    

    Describe the bug

    After upgrading to 1.4.0, no more color in output, without error.

    To Reproduce

    Upgrade to v1.4.0.

    green := color.FgGreen.Render
    fmt.Println(">>> Blah :", green("blahblah"))
    

    Expected behavior

    The color must be printed as expected.

  • Use terminfo instead of hardcoding a list of terminals

    Use terminfo instead of hardcoding a list of terminals

    Hey!

    You should use terminfo instead of relying on the terminal name in TERM. This can provide you the number of colors supported. Otherwise, you are missing a lot of terminals supporting colors, like rxvt or screen. In Go, it seems https://github.com/xo/terminfo can do that. It also seems to handle some edge cases for terminals not using the correct TERM. It also handles the special case of true color which was not available through terminfo until recently and is able to fallback to COLORTERM (but it should be using Tc if available).

  • Color on Windows in cygwin, powershell, cmd

    Color on Windows in cygwin, powershell, cmd

    This tool looks really promising! So thanks in advance.

    I'm running into some issues with your isSupportColor method on Windows, which affects RenderCode.

    1. Pure git-bash:
      • $MSYSTEM = MINGW64
      • $TERM = xterm
      • 256 coloration seems to work
    2. ConsoleZ git-bash (started via C:\Program Files\Git\bin\sh.exe --login -i)
      • $MSYSTEM = MINGW64
      • $TERM = cygwin
      • coloration is disabled
      • 16-color coloration is possible via github.com/fatih/color - Output
    3. CMD:
      • %CMDEXTVERSION% = 2
      • coloration is disabled
      • 16-color coloration is possible via github.com/fatih/color - Output
    4. Powershell:
      • Version: 5.1.16299.1146
      • coloration is disabled
      • 16-color coloration is possible via github.com/fatih/color - Output

    My method for testing includes creating a color.C256 object and using it's Sprint method to output the string to write to a github.com/fatih/color - Output Writer.

    Thanks!

  • feature: add hsl to and from methods

    feature: add hsl to and from methods

    Hi! I think it will be good to also add methods to take hsl as input and convert it by different variants.

    For reference, you can refer to this code.

    I need this feature as I will be adding HSL format as input option for my box-cli-maker.

  • panic when running on windows with multiple go routines

    panic when running on windows with multiple go routines

    Running this with multiple go routines causes this crash (on windows):

    runtime: bad pointer in frame github.com/gookit/color.EnableVirtualTerminalProcessing at 0xc000581838: 0x58
    fatal error: invalid pointer found on stack
    
    runtime stack:
    runtime.throw(0xc6d2fe, 0x1e)
            C:/Program Files/go/src/runtime/panic.go:1116 +0x79 fp=0xb2f1bff4d0 sp=0xb2f1bff4a0 pc=0x659799
    runtime.adjustpointers(0xc000581838, 0xb2f1bff5c0, 0xb2f1bff948, 0xfbcc00, 0x100e2a0)
            C:/Program Files/go/src/runtime/stack.go:605 +0x1e8 fp=0xb2f1bff520 sp=0xb2f1bff4d0 pc=0x66e888
    runtime.adjustframe(0xb2f1bff858, 0xb2f1bff948, 0x100e2a0)
            C:/Program Files/go/src/runtime/stack.go:647 +0x36b fp=0xb2f1bff5f0 sp=0xb2f1bff520 pc=0x66ec0b
    runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc000084d80, 0x0, 0x0, 0x7fffffff, 0xc89118, 0xb2f1bff948, 0x0, ...)
            C:/Program Files/go/src/runtime/traceback.go:334 +0x11b5 fp=0xb2f1bff8c0 sp=0xb2f1bff5f0 pc=0x67acd5
    runtime.copystack(0xc000084d80, 0x2000)
            C:/Program Files/go/src/runtime/stack.go:910 +0x2a7 fp=0xb2f1bffa78 sp=0xb2f1bff8c0 pc=0x66f387
    runtime.shrinkstack(0xc000084d80)
            C:/Program Files/go/src/runtime/stack.go:1178 +0x149 fp=0xb2f1bffaa0 sp=0xb2f1bffa78 pc=0x670429
    runtime.scanstack(0xc000084d80, 0xc00002de98)
            C:/Program Files/go/src/runtime/mgcmark.go:815 +0x56e fp=0xb2f1bffca8 sp=0xb2f1bffaa0 pc=0x640e4e
    runtime.markroot.func1()
            C:/Program Files/go/src/runtime/mgcmark.go:245 +0xce fp=0xb2f1bffcf8 sp=0xb2f1bffca8 pc=0x681cee
    runtime.markroot(0xc00002de98, 0x14)
            C:/Program Files/go/src/runtime/mgcmark.go:218 +0x310 fp=0xb2f1bffd80 sp=0xb2f1bffcf8 pc=0x63f910
    runtime.gcDrain(0xc00002de98, 0x7)
            C:/Program Files/go/src/runtime/mgcmark.go:1109 +0x138 fp=0xb2f1bffdd8 sp=0xb2f1bffd80 pc=0x641578
    runtime.gcBgMarkWorker.func2()
            C:/Program Files/go/src/runtime/mgc.go:1981 +0x176 fp=0xb2f1bffe18 sp=0xb2f1bffdd8 pc=0x681bd6
    runtime.systemstack(0x0)
            C:/Program Files/go/src/runtime/asm_amd64.s:370 +0x6b fp=0xb2f1bffe20 sp=0xb2f1bffe18 pc=0x68a6ab
    runtime.mstart()
            C:/Program Files/go/src/runtime/proc.go:1116 fp=0xb2f1bffe28 sp=0xb2f1bffe20 pc=0x65e920
    
  • Question: How to escape color tags

    Question: How to escape color tags

    I'm using the HTML like tags feature to pretty print some JSON, but I'm concerned that occasionally the JSON data might have tags like that would start getting rendered as a color. I did a search and replace and didn't see anything, so was wondering if there was a way to escape or encode tags to make it so that color tags aren't injected?

  • Truecolor being detected but no colour output

    Truecolor being detected but no colour output

    IsSupportTrueColor
    (bool) true
    IsSupport256Color
    (bool) false
    IsSupportColor
    (bool) false
    
    env | grep TERM
    COLORTERM=truecolor
    TERM=alacritty
    

    github.com/gookit/color v1.2.7

  • Bump github.com/stretchr/testify from 1.3.0 to 1.6.1

    Bump github.com/stretchr/testify from 1.3.0 to 1.6.1

    Bumps github.com/stretchr/testify from 1.3.0 to 1.6.1.

    Release notes

    Sourced from github.com/stretchr/testify's releases.

    Fixes breaking change with HTTPBodyContains

    A breaking change was accidentally released in v1.6.0 which breaks the API for the HTTPBodyContains and HTTPBodyNotContains, this release reverts that change.

    v1.6.0

    Latest release of testify. This includes many fixes and enhancements. Please view the v1.6.0 milestone for a list of changes.

    HOTFIX: Revert suite interface type

    This is a hotfix which reverts the suite package's interface type to use testing.T

    v1.5.0

    Latest, non-breaking changes merged into master. Please peruse the git log for a detailed changelist

    v1.4.0

    The 1.4.0 release includes new matchers and bug fixes. See the v.1.4.0 milestone for a complete list of closed issues associated with this release.

    Commits
    • f654a91 Update Go versions in Travis
    • 3184a9e This reverts commit 0a813b5898c0ee8d00b4f13fae21ea5df8b35e74.
    • e2b269e This reverts commit 2adb7b54b75da2c74e9342ed115957fe0b07e0b4.
    • 6353e56 This reverts commit 9d083cac4a26c76f8d92dff41d459f3f2fc0b911.
    • 6561324 This reverts commit 484fff1ace1f0acb84676a548b53477685c16414.
    • 46420cf This reverts commit 1a43b8334acb9df58064b765cd16675cc7c2c8b3.
    • 303198d Revert "allow body for HTTPBodyContains and HTTPBodyNotContains for
    • e7cc868 Update TravisCI config
    • 004e3cb commit generated files
    • ac1463f Implement NotEqualValues
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
  • Add support for tmux-256color

    Add support for tmux-256color

    The recommended way of enabling color support in tmux is to set the terminal to screen-256color or tmux-256color: https://github.com/tmux/tmux/wiki/FAQ

  • build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1

    build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1

    Bumps github.com/stretchr/testify from 1.8.0 to 1.8.1.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • tag-style color rendering fails if lines contain tag like content

    tag-style color rendering fails if lines contain tag like content

    System (please complete the following information):

    • OS: linux
    • GO Version: 1.18.1
    • Pkg Version: 1.5.2

    ENV info on the terminal (by command env | grep -i TERM):

    COLORTERM=truecolor
    TERM_PROGRAM_VERSION=3.2a
    TERM=tmux-256color
    TERM_PROGRAM=tmux
    

    Describe the bug

    I am using tag-style color rendeing to colorize tabular data. If multiple lines contain something like this: <none> then only the first colorziation works, subsequent ones are not replaced but printed as is.

    To Reproduce

    package main
    
    import (
    	"github.com/gookit/color"
    )
    
    func main() {
    	test1 := `FAILS:
    one <bg=lightGreen;fg=black>two</> <three>
    foo <bg=lightGreen;fg=black>two</> <four>
    
    `
    
    	test2 := `WORKS:
    one <bg=lightGreen;fg=black>two <three></>
    foo <bg=lightGreen;fg=black>two <four></>
    
    `
    
    	test3 := `WORKS:
    one <bg=lightGreen;fg=black>two</> three
    foo <bg=lightGreen;fg=black>two</> four
    `
    
    	color.Print(test1)
    	color.Print(test2)
    	color.Print(test3)
    }
    

    Expected behavior

    The colorziation should work independently from other non color-tag content.

    Screenshots

    See screenshot attached.

    colorfails

    ** Edited to add **

    The problem occurs ONLY if the "tagged" content appears outside the colorization. If it's inside, it works. Sample code and screenshot updated.

  • `ClearCode` doesn't work as intended on Mac OS

    `ClearCode` doesn't work as intended on Mac OS

    I am using your library in box-cli-maker and use color.ClearCode to clear colors from the string but it doesn't work on Mac OS's iterm terminal though works on other OSes Terminal.

    Read this issue for the detailed information https://github.com/Delta456/box-cli-maker/issues/29

Chalk is a Go Package which can be used for making terminal output more vibrant with text colors, text styles and background colors.
Chalk is a Go Package which can be used for making terminal output more vibrant with text colors, text styles and background colors.

Chalk Chalk is a Go Package which can be used for making terminal output more vibrant with text colors, text styles and background colors. Documentati

Oct 29, 2022
Command-line utility for Postgres-compatible SCRAM-SHA-256 passwords

scram-password -- Command-line utility for Postgres-compatible SCRAM-SHA-256 passwords SCRAM-SHA-256 (see RFC-7677, Salted Challenge Response Authenti

Jan 21, 2022
A tiny markup language for terminal output. Makes formatting output in CLI apps easier!
A tiny markup language for terminal output. Makes formatting output in CLI apps easier!

tml - Terminal Markup Language A Go module (and standalone binary) to make the output of coloured/formatted text in the terminal easier and more reada

Dec 14, 2022
Advanced ANSI style & color support for your terminal applications
Advanced ANSI style & color support for your terminal applications

termenv lets you safely use advanced styling options on the terminal. It gathers information about the terminal environment in terms of its ANSI & col

Dec 31, 2022
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

✨ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more ?? It's completely configurable and 100% cross-platform compatible.

Jan 1, 2023
Print day progress in your terminal

Day progress Print day progress in your terminal Install go install github.com/tsivinsky/day-progress@latest Usage day-progress By default, day-progre

Jan 10, 2022
archy is an static binary to determine current kernel and machine architecture, with backwards compatible flags to uname, and offers alternative output format of Go runtime (i.e. GOOS, GOARCH).

archy archy is an simple binary to determine current kernel and machine architecture, which wraps uname and alternatively can read from Go runtime std

Mar 18, 2022
A Go library for terminal background color detection

go-termbg A Go library for terminal background color detection. The detected color is provided by RGB or theme ( dark or light ). Based on https://git

Jan 4, 2022
Detects whether a terminal supports colors
Detects whether a terminal supports colors

Termcolor Detects what level of color support your terminal has. This package is heavily inspired by chalk's support-color module. Install go get gith

Nov 27, 2022
Golang package with functionality to add colors to your logs to the terminal.
Golang package with functionality to add colors to your logs to the terminal.

colrz It's a set of funcs and constants to provide basic colors to your terminal app. How to use Get it go get github.com/unnamedxaer/colrz Use it pac

Sep 15, 2022
Light weight Terminal User Interface (TUI) to pick material colors written by Go.
Light weight Terminal User Interface (TUI) to pick material colors written by Go.

mcpick Light weight Terminal User Interface (TUI) to pick material colors. You do NOT need to take your hands off the keyboard to pick colors. Getting

Dec 27, 2022
Draw images in your ANSI terminal with true color
Draw images in your ANSI terminal with true color

___ _____ ____ / _ \/ _/ |/_/ /____ ______ _ Made with love by Eliuk Blau / ___// /_> </ __/ -_) __/ ' \ https://github.com/eliukblau/pix

Dec 14, 2022
🍫 A customisable, universally compatible terminal status bar
🍫 A customisable, universally compatible terminal status bar

Shox: Terminal Status Bar A customisable terminal status bar with universal shell/terminal compatibility. Currently works on Mac/Linux. Installation N

Dec 27, 2022
A golang library for building interactive prompts with full support for windows and posix terminals.
A golang library for building interactive prompts with full support for windows and posix terminals.

Survey A library for building interactive prompts on terminals supporting ANSI escape sequences. package main import ( "fmt" "github.com/Alec

Jan 6, 2023
Go-colorful: A library for playing with colors in golang
Go-colorful: A library for playing with colors in golang

go-colorful A library for playing with colors in Go. Supports Go 1.13 onwards. Why? I love games. I make games. I love detail and I get lost in detail

Dec 30, 2022
contaiNERD CTL - Docker-compatible CLI for containerd, with support for Compose, Rootless, eStargz, OCIcrypt, IPFS, ...

contaiNERD CTL - Docker-compatible CLI for containerd, with support for Compose, Rootless, eStargz, OCIcrypt, IPFS, ...

Jan 4, 2023
Use go to count file's lines and print them.

用法 go run staticCodeLine.go -p [root path] -s [suffix name] -e [exclude dirs] 如果 -e 有多个参数,多次输入 -e [suffix name]。 ╰─± go run statisticCodeLine.go -p /U

Dec 12, 2022
This CLI tool sends HTTP GET requests and print MD5 hash values of the response's body

HTTP Body Hash Generator This CLI (Command Line Interface) tool sends HTTP GET requests and print MD5 hash values of the response's body. Usage You ne

Feb 10, 2022
CLI hex dumper with colors
CLI hex dumper with colors

heksa Hex dumper with colors Features ANSI colors for different byte groups such as Printable: A-Z, a-z, 0-9 Spaces: space, tab, new line Special: 0x0

Sep 27, 2022