🎨 Terminal color rendering tool library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows. GO CLI 控制台颜色渲染工具库,支持16色,256色,RGB色彩渲染输出,使用类似于 Print/Sprintf,兼容并支持 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 <green>message</>. Support working on windows cmd powerShell
  • 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

GoDoc

Install

go get github.com/gookit/color

NOTICE

If you want print custom colors message on windows, should use color.PrintX instead of fmt.PrintX

str := color.Red.Sprint("an colored message string")

// Color will not be output under Windows
fmt.Println(str)

// Color will be output under Windows
color.Println(str)

color.PrintX is universal, you can use it directly instead of fmt.PrintX

Quick start

package main

import (
	"fmt"

	"github.com/gookit/color"
)

func main() {
	// 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("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>\n")

	// 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

Custom Build Color

// 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")

// 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()

Basic Color

Supported on any Windows version.

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

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

basic-color

Additional styles

Supported on any Windows version.

  • color.Info
  • color.Note
  • color.Warn
  • color.Light
  • color.Error
  • color.Danger
  • color.Debug
  • color.Notice
  • color.Success
  • color.Comment
  • color.Primary
  • color.Question
  • color.Secondary

Basic Style

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

HTML-like tag usage

Supported on Windows cmd.exe PowerShell .

// use style tag
color.Print("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>")
color.Println("<suc>hello</>")
color.Println("<error>hello</>")
color.Println("<warning>hello</>")

// custom color attributes
color.Print("<fg=yellow;bg=black;op=underscore;>hello, welcome</>\n")
  • 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/colortag.go

color-tags

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")

Use a 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/color256.go

color-tags

Use RGB 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")

Use an 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")

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

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, DI, log, config, cache, event, validate, filter, CLI, i18n, respond-data, view-render)
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

Console Text Colors - The non-invasive cross-platform terminal color library does not need to modify the Print method

ctc - Console Text Colors The non-invasive cross-platform terminal color library does not need to modify the Print method Virtual unix-like environmen

Nov 9, 2022
✨ #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.
✨ #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.

?? PTerm | Pretty Terminal Printer A golang module to print pretty text Show Demo Code PTerm.sh | Installation | Documentation | Quick Start | Example

Dec 27, 2022
uilive is a go library for updating terminal output in realtime
uilive is a go library for updating terminal output in realtime

uilive uilive is a go library for updating terminal output in realtime. It provides a buffered io.Writer that is flushed at a timed interval. uilive p

Dec 28, 2022
Terminal string styling for go done right, with full and painless Windows 10 support.
Terminal string styling for go done right, with full and painless Windows 10 support.

GChalk GChalk is a library heavily inspired by chalk, the popular Node.js terminal color library, and using go ports of supports-color and ansi-styles

Dec 28, 2022
Intuitive package for prettifying terminal/console output. http://godoc.org/github.com/ttacon/chalk
Intuitive package for prettifying terminal/console output. http://godoc.org/github.com/ttacon/chalk

chalk Chalk is a go package for styling console/terminal output. Check out godoc for some example usage: http://godoc.org/github.com/ttacon/chalk The

Dec 23, 2022
Small library for simple and convenient formatted stylized output to the console.
Small library for simple and convenient formatted stylized output to the console.

cfmt cfmt is a small library for simple and convenient formatted stylized output to the console, providing an interface that is exactly the same as th

Jan 7, 2023
:art: Contextual fmt inspired by bootstrap color classes

Cfmt Contextual fmt It provides contextual formatting functions that have nearly identical usage of the fmt package. The ideas were borrowed from boot

Jan 7, 2023
Change the color of console text.

go-colortext package This is a package to change the color of the text and background in the console, working both under Windows and other systems. Un

Oct 26, 2022
Vale-compatible implementations of many popular "readability" metrics.

Readability This repository contains a Vale-compatible implementation of many popular "readability" metrics. Getting Started ❗ Readability requires Va

Aug 31, 2022
Yet Another CLi Spinner; providing over 70 easy to use and customizable terminal spinners for multiple OSes
Yet Another CLi Spinner; providing over 70 easy to use and customizable terminal spinners for multiple OSes

Yet Another CLi Spinner (for Go) Package yacspin provides yet another CLi spinner for Go, taking inspiration (and some utility code) from the https://

Dec 25, 2022
A go library to render progress bars in terminal applications
A go library to render progress bars in terminal applications

uiprogress A Go library to render progress bars in terminal applications. It provides a set of flexible features with a customizable API. Progress bar

Dec 29, 2022
A go library to improve readability in terminal apps using tabular data

uitable uitable is a go library for representing data as tables for terminal applications. It provides primitives for sizing and wrapping columns to i

Dec 30, 2022
go-colorable - Colorable writer for windows.
go-colorable - Colorable writer for windows.

go-colorable Colorable writer for windows. For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But

Dec 30, 2022
An ANSI colour terminal package for Go

colourize An ANSI colour terminal package for Go. Supports all ANSI colours and emphasis. Not compatible with Windows systems. Installation go get gi

Sep 26, 2022
Simple tables in terminal with Go

Simple tables in terminal with Go This package allows to generate and display ascii tables in the terminal, f.e.: +----+------------------+-----------

Dec 29, 2022
Terminal based dashboard.
Terminal based dashboard.

Termdash is a cross-platform customizable terminal based dashboard. The feature set is inspired by the gizak/termui project, which in turn was inspire

Dec 28, 2022
Golang terminal dashboard
Golang terminal dashboard

termui termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-c

Dec 27, 2022
multi progress bar for Go cli applications

Multi Progress Bar mpb is a Go lib for rendering progress bars in terminal applications. Features Multiple Bars: Multiple progress bars are supported

Dec 30, 2022
A CLI to adjust display brightness using xrandr. Made because Ubuntu desktop was baking my eyeballs in low light.

bright This is a simple program to set monitor brightness using xrandr. I made this because Ubuntu does not come with a built-in way to change monitor

Jan 15, 2022