AEC(1)
NAME
aec — Go wrapper for ANSI escape code
SYNOPSIS
INFO
99 stars
3 forks
0 views
DESCRIPTION
Go wrapper for ANSI escape code
README
aec
Go wrapper for ANSI escape code.
Install
go get github.com/morikuni/aec
Features
ANSI escape codes depend on terminal environment.
Some of these features may not work.
Check supported Font-Style/Font-Color features with checkansi.
Wikipedia for more detail.
Cursor
Up(n)Down(n)Right(n)Left(n)NextLine(n)PreviousLine(n)Column(col)Position(row, col)SaveRestoreHideShowReport
Erase
EraseDisplay(mode)EraseLine(mode)
Scroll
ScrollUp(n)ScrollDown(n)
Font Style
BoldFaintItalicUnderlineBlinkSlowBlinkRapidInverseConcealCrossOutFrameEncircleOverline
Font Color
Foreground color.
DefaultFBlackFRedFGreenFYellowFBlueFMagentaFCyanFWhiteFLightBlackFLightRedFLightGreenFLightYellowFLightBlueFLightMagentaFLightCyanFLightWhiteFColor3BitF(color)Color8BitF(color)FullColorF(r, g, b)
Background color.
DefaultBBlackBRedBGreenBYellowBBlueBMagentaBCyanBWhiteBLightBlackBLightRedBLightGreenBLightYellowBLightBlueBLightMagentaBLightCyanBLightWhiteBColor3BitB(color)Color8BitB(color)FullColorB(r, g, b)
Color Converter
24bit RGB color to ANSI color.
NewRGB3Bit(r, g, b)NewRGB8Bit(r, g, b)
Builder
To mix these features.
custom := aec.EmptyBuilder.Right(2).RGB8BitF(128, 255, 64).RedB().ANSI
custom.Apply("Hello World")
Usage
- Create ANSI by
aec.XXX().With(aec.YYY())oraec.EmptyBuilder.XXX().YYY().ANSI - Print ANSI by
fmt.Print(ansi, "some string", aec.Reset)orfmt.Print(ansi.Apply("some string"))
aec.Reset should be added when using font style or font color features.
Example
Simple progressbar.

package mainimport ( "fmt" "strings" "time"
"github.com/morikuni/aec")
func main() { const n = 20 builder := aec.EmptyBuilder
up2 := aec.Up(2) col := aec.Column(n + 2) bar := aec.Color8BitF(aec.NewRGB8Bit(64, 255, 64)) label := builder.LightRedF().Underline().With(col).Right(1).ANSI // for up2 fmt.Println() fmt.Println() for i := 0; i <= n; i++ { fmt.Print(up2) fmt.Println(label.Apply(fmt.Sprint(i, "/", n))) fmt.Print("[") fmt.Print(bar.Apply(strings.Repeat("=", i))) fmt.Println(col.Apply("]")) time.Sleep(100 * time.Millisecond) }
}
License
SEE ALSO
neovim(1)— Hyperextensible Vim-based text editor — the future of Vimtmux(1)— Terminal multiplexer — split panes, detach sessions, pair programhyperfine(1)— A command-line benchmarking tool — measure execution timestokei(1)— Count lines of code quickly — supports 150+ languagescftunnel(1)— 全协议内网穿透 CLI — Cloud 模式免费 HTTP/WS 穿透 + Relay 模式自建中继 TCP/UDP 全协议 | Cloudflare Tunnel + frp 双引擎
clihub3/4/2026AEC(1)