top

Package ansi is a small, fast library to create ANSI colored strings and codes.

Installation

# this installs the color viewer and the package
go get -u github.com/mgutz/ansi/cmd/ansi-mgutz

Example

// colorize a string, SLOW
msg := ansi.Color("foo", "red+b:white")

// create a closure to avoid recalculating ANSI code compilation
phosphorize := ansi.ColorFunc("green+h:black")
msg = phosphorize("Bring back the 80s!")
msg2 := phospohorize("Look, I'm a CRT!")

// cache escape codes and build strings manually
lime := ansi.ColorCode("green+h:black")
reset := ansi.ColorCode("reset")

fmt.Println(lime, "Bring back the 80s!", reset)

Other examples

Color(s, "red")            // red
Color(s, "red+b")          // red bold
Color(s, "red+B")          // red blinking
Color(s, "red+u")          // red underline
Color(s, "red+bh")         // red bold bright
Color(s, "red:white")      // red on white
Color(s, "red+b:white+h")  // red bold on white bright
Color(s, "red+B:white+h")  // red blink on white bright

To view color combinations, from terminal

ansi-mgutz

Style format

"foregroundColor+attributes:backgroundColor+attributes"

Colors

black
red
green
yellow
blue
magenta
cyan
white

Attributes

b = bold foreground
B = Blink foreground
u = underline foreground
h = high intensity (bright) foreground, background
i = inverse

Wikipedia ANSI escape codes [Colors](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors)

Imported by 435 package(s) ΒΆ

  1. bitbucket.org/ambrevar/demlo
  2. bitbucket.org/ulfurinn/sentinel
  3. github.com/3ofcoins/bheekeeper/cli
  4. github.com/3ofcoins/jetpack/lib/ui
  5. github.com/Ambrevar/Demlo
  6. github.com/AppliedTrust/sweet
  7. github.com/BrianIp/prodeng/inspect
  8. github.com/BrianIp/prodeng/inspect/osmain
  9. github.com/CanOpener/serverlog
  10. github.com/DavidGamba/grepp
  11. github.com/FGrosse/go-track
  12. github.com/FGrosse/go-track/internal
  13. github.com/FGrosse/gomega-matchers
  14. github.com/Fiery/godo
  15. github.com/Fiery/godo/util
  16. github.com/GeorgeErickson/dat/Gododir
  17. github.com/JustinTulloss/dat/Gododir
  18. github.com/KSubedi/go-web-seed/middlewares
  19. github.com/KSubedi/gomove
  20. github.com/LC2010/75.weekly.go
  21. github.com/MerlinDMC/advanced-ssh-config/pkg/commands
  22. github.com/Minio-io/mc
  23. github.com/Netflix-Skunkworks/go-jira
  24. github.com/ONSdigital/go-ns/log
  25. github.com/Pixelgaffer/dicod
  26. github.com/PlanitarInc/dat/Gododir
  27. github.com/QuentinPerez/serror
  28. github.com/RC1140/go-jira
  29. github.com/Rentlio/jit
  30. github.com/RobinUS2/cloudpelican-lsd/cli
  31. github.com/SchumacherFM/mediamock/common
  32. github.com/Stephen304/cmdfolder
  33. github.com/Term1nal/kittens
  34. github.com/TheRealBill/inspect
  35. github.com/TheRealBill/inspect/osmain
  36. github.com/Tobscher/kiss/logging
  37. github.com/TrueFurby/checkepisode
  38. github.com/TykTechnologies/logrus-prefixed-formatter
  39. github.com/Xe/flitter/proxy
  40. github.com/Xe/tools/splattus
  41. github.com/aarondl/colortest
  42. github.com/abhinavdahiya/henchman/henchman
  43. github.com/acoll/go-http-server
  44. github.com/adrienkohlbecker/goteam/logging
  45. github.com/adwd/mutt
  46. github.com/aktau/gofinance/app
  47. github.com/alaska/kraken
  48. github.com/alectic/archey-go/lib
  49. github.com/alexdreptu/archey-go/lib
  50. github.com/aliafshar/bu
  51. github.com/ansel1/godo
  52. github.com/ansel1/godo/util
  53. github.com/ansel1/logxi/Gododir
  54. github.com/ansel1/logxi/v1
  55. github.com/antha-lang/antha/antha/AnthaStandardLibrary/Packages/sequences/blast
  56. github.com/antha-lang/antha/antha/AnthaStandardLibrary/Packages/text
  57. github.com/antha-lang/antha/cmd/antharun/spawn
  58. github.com/aphistic/gomol
  59. github.com/aphistic/gomol-console
  60. github.com/aphistic/sweet
  61. github.com/apigee/henchman/henchman
  62. github.com/appliedtrust/sweet
  63. github.com/appneta/logxi/Gododir
  64. github.com/appneta/logxi/v1
  65. github.com/assemblyline/spanner/logger
  66. github.com/attic-labs/noms/cmd/noms
  67. github.com/avenue-contrib/avenue/logging
  68. github.com/b4b4r07/brionac
  69. github.com/beanieboi/codeship-go/cmd
  70. github.com/bensinober/go-tcp-proxy
  71. github.com/bgentry/hk
  72. github.com/bhenderson/goj
  73. github.com/blablacar/ggn/work
  74. github.com/blablacar/green-garden/work
  75. github.com/bom-d-van/csfw/codegen/csMake
  76. github.com/brandur/sab
  77. github.com/brianstarke/go-beget/generator/creator
  78. github.com/brianstarke/go-beget/generator/searcher
  79. github.com/brianstarke/go-beget/generator/updater
  80. github.com/brianstarke/go-beget/searcher
  81. github.com/brianstarke/go-beget/updater
  82. github.com/byrnedo/capitan/logger
  83. github.com/c0nrad/boggle
  84. github.com/cajun/shoehorn/command
  85. github.com/canopener/serverlog
  86. github.com/cardigann/cardigann/indexer
  87. github.com/ccampbell/clapp
  88. github.com/cedmundo/ulog
  89. github.com/chendrix/fly/commands/internal/hijacker
  90. github.com/chendrix/fly/commands/internal/setpipelinehelpers
  91. github.com/chunhei2008/watchf
  92. github.com/cigam/gogrep
  93. github.com/classmarkets/logxi/Gododir
  94. github.com/classmarkets/logxi/v1
  95. github.com/claudetech/loggo
  96. github.com/cloud66/cx
  97. github.com/codequest-eu/teleport
  98. github.com/codeship/go-ledge
  99. github.com/concourse/fly/commands/internal/hijacker
  100. github.com/concourse/fly/commands/internal/setpipelinehelpers
  101. github.com/concourse/testflight/gitserver
  102. github.com/concourse/testflight/guidserver
  103. github.com/concourse/testflight/helpers
  104. github.com/coryb/cliby/util
  105. github.com/cousine/go-krang-iris-test
  106. github.com/cubicdaiya/lltsv
  107. github.com/d4l3k/go-pry/pry
  108. github.com/daneharrigan/hk
  109. github.com/davelondon/go-jira
  110. github.com/davidgamba/grepp
  111. github.com/dbrower/go-jira
  112. github.com/dcu/1p
  113. github.com/dcu/1p/cli
  114. github.com/dcu/gin-scaffold/template
  115. github.com/dfeyer/flow-debugproxy/logger
  116. github.com/digibib/go-tcp-proxy
  117. github.com/divan/inspect/inspect
  118. github.com/divan/inspect/inspect/osmain
  119. github.com/dockersecuritytools/batten
  120. github.com/dockersecuritytools/batten/cli
  121. github.com/dos65/log_notify
  122. github.com/dos65/lognotify
  123. github.com/dreamersdw/redis-view
  124. github.com/dreamersdw/zk-view
  125. github.com/dvwallin/godisc
  126. github.com/ekanna/dat/Gododir
  127. github.com/eldarion-gondor/cli/lib
  128. github.com/elgris/jsondiff
  129. github.com/enjoylife/gofinance/app
  130. github.com/ernesto-jimenez/go-tcp-proxy
  131. github.com/facette/logger
  132. github.com/fanatic/hk
  133. github.com/fdr/hk
  134. github.com/fgrosse/go-track
  135. github.com/fgrosse/go-track/internal
  136. github.com/fgrosse/gomega-matchers
  137. github.com/firstrow/go-outdated
  138. github.com/fumiyas/qrc/lib
  139. github.com/gagliardetto/skyhash-pub-sub/replicator
  140. github.com/geigi/loopjongen
  141. github.com/gemnasium/toolbelt/utils
  142. github.com/getmillipede/millipede-go
  143. github.com/ghg/gofinance/app
  144. github.com/giantswarm/builder/task
  145. github.com/giantswarm/builder/util
  146. github.com/glassesfactory/godo
  147. github.com/glassesfactory/godo/util
  148. github.com/gloob/irc_bot/lib
  149. github.com/gnidan/foodtastechess/directory
  150. github.com/gnidan/foodtastechess/server
  151. github.com/go-godo/godo
  152. github.com/go-godo/godo/util
  153. github.com/gophergala/go_ne/core
  154. github.com/gophergala/go_ne/kiss
  155. github.com/gophergala/go_ne/plugins/core
  156. github.com/gotterdemarung/go-log/log
  157. github.com/grafov/factorlog
  158. github.com/gtfierro/PunDat
  159. github.com/gtfierro/bw2
  160. github.com/gtfierro/durandal
  161. github.com/gtfierro/hod
  162. github.com/guillaumewuip/console.go
  163. github.com/haisum/gameoflife
  164. github.com/heavenlyhash/gosu/util
  165. github.com/heridev/gophergala_repositories/bron
  166. github.com/heydabop/cyan-gerrit
  167. github.com/hirakiuc/ec2s/internal/common
  168. github.com/hirakiuc/gonta/logger
  169. github.com/hiremaga/fly
  170. github.com/hlubek/flow-debugproxy/logger
  171. github.com/hnakamur/execcommandexample
  172. github.com/holgerk/search-and-replace
  173. github.com/humboldtux/bron
  174. github.com/ian-kent/console-json-demo/wrapper
  175. github.com/ian-kent/service.go/log
  176. github.com/ibmjstart/cf-download
  177. github.com/ibmjstart/cf-download/dir_parser
  178. github.com/ibmjstart/cf-download/downloader
  179. github.com/ikkeps/replay
  180. github.com/immesys/bw2
  181. github.com/immesys/bw2bind
  182. github.com/immesys/spawnpoint/spawnctl
  183. github.com/immesys/spawnpoint/spawnd
  184. github.com/immesys/wd/wd
  185. github.com/include/gofinance/app
  186. github.com/ivolo/go-image-to-ascii
  187. github.com/jaisingh/colorize
  188. github.com/jaisingh/gofinance/app
  189. github.com/jandre/batten-1/cli
  190. github.com/jandre/ovpnreport/ovpnreport
  191. github.com/jandre/secrets/cli
  192. github.com/jeeyoungk/inspect/inspect
  193. github.com/jefferai/logxi/Gododir
  194. github.com/jefferai/logxi/v1
  195. github.com/jipperinbham/go-tcp-proxy
  196. github.com/jnwhiteh/wallops
  197. github.com/johnmcconnell/chenv
  198. github.com/johnnadratowski/go-tcp-proxy
  199. github.com/jpillora/go-tcp-proxy
  200. github.com/jraede/brewservice
  201. github.com/jrwren/kittens
  202. github.com/jshirley/go-jira
  203. github.com/junzzz/opstool/video_link_editor
  204. github.com/kalashnikov/gofinance/gofinance
  205. github.com/kbknapp/gok/log
  206. github.com/kdar/factorlog
  207. github.com/kefu1024/logxi/tasks
  208. github.com/kefu1024/logxi/v1
  209. github.com/kelproject/kel/cmd
  210. github.com/kiyor/go-tcp-proxy
  211. github.com/kolide/kolide/shared/formatter
  212. github.com/komand/plugin-sdk-go/plugin
  213. github.com/kotakanbe/logrus-prefixed-formatter
  214. github.com/koyue/godo
  215. github.com/ksred/gofinance/app
  216. github.com/ksubedi/go-web-seed/middlewares
  217. github.com/ksubedi/gomove
  218. github.com/kurafuto/kurafuto
  219. github.com/latencia/mtr-stream
  220. github.com/lestopher/fancylogger
  221. github.com/lestopher/gobot
  222. github.com/libgo/watchf
  223. github.com/lighthouse/beacon
  224. github.com/llgcode/nextone
  225. github.com/lordnynex/go-jira
  226. github.com/lucsky/gosu
  227. github.com/lukevers/golem
  228. github.com/lumanetworks/go-tcp-proxy
  229. github.com/lunixbochs/usercorn/go/models
  230. github.com/mabetle/mcore/demo/linux_color_console_demo
  231. github.com/macedo/godo
  232. github.com/macedo/godo/util
  233. github.com/malnick/logasaurus/loga
  234. github.com/markchadwick/spec
  235. github.com/marksalpeter/sugar
  236. github.com/maruel/panicparse/internal
  237. github.com/marvell/dps
  238. github.com/masahide/goansible
  239. github.com/matishsiao/go-tcp-proxy
  240. github.com/mefellows/godspeed/log
  241. github.com/mefellows/muxy/log
  242. github.com/mephux/dnas
  243. github.com/mephux/kolide/shared/formatter
  244. github.com/mewbak/anna/log
  245. github.com/mewpull/anna/log
  246. github.com/mgutz/ansi/cmd/ansi-mgutz
  247. github.com/mgutz/dat/Gododir
  248. github.com/mgutz/gosu
  249. github.com/mgutz/gosu/util
  250. github.com/mgutz/logxi/Gododir
  251. github.com/mgutz/logxi/v1
  252. github.com/milanaleksic/flowdock_stats/cmdcolors
  253. github.com/milanaleksic/jenkins_ping/view
  254. github.com/milanaleksic/mongodiff
  255. github.com/mischief/tqr
  256. github.com/mitchty/sys
  257. github.com/mmb/boosh
  258. github.com/mmirolim/HsNlaEWBgkaYrFKu2BQHSQ
  259. github.com/moul/advanced-ssh-config/pkg/commands
  260. github.com/moul/sapin
  261. github.com/moznion/persec
  262. github.com/mrmanc/spectro/spectro
  263. github.com/msoap/go-carpet
  264. github.com/msoap/yandex-weather-cli
  265. github.com/murz/dat/Gododir
  266. github.com/mwmahlberg/logxi/Gododir
  267. github.com/mwmahlberg/logxi/v1
  268. github.com/mythfish/simple-sip-test
  269. github.com/n0rad/go-erlog
  270. github.com/nathanleclaire/dat/Gododir
  271. github.com/ncbray/crank/task
  272. github.com/nhanphan/go-beget/generator/creator
  273. github.com/nhanphan/go-beget/generator/searcher
  274. github.com/nhanphan/go-beget/generator/updater
  275. github.com/nhanphan/go-beget/searcher
  276. github.com/nhanphan/go-beget/updater
  277. github.com/nickbruun/gocommons/unittest
  278. github.com/nickschuch/aliases/src
  279. github.com/nicolas314/mping
  280. github.com/oarmstrong/nsipam/cmd
  281. github.com/olomix/dynproxy/log
  282. github.com/olomix/log4go
  283. github.com/osuripple/ppwatch
  284. github.com/parkghost/spamdefender/tools/databuilder
  285. github.com/parkghost/spamdefender/tools/mailclassifier
  286. github.com/parkghost/watchf
  287. github.com/paulhamby/rundeck-client/cmd
  288. github.com/pemcconnell/amald/reports
  289. github.com/peter-edge/go-ledge
  290. github.com/peter-edge/ledge-go
  291. github.com/phonkee/go-logger
  292. github.com/phonkee/patrol
  293. github.com/phonkee/patrol/commands
  294. github.com/phonkee/patrol/core
  295. github.com/phonkee/patrol/models
  296. github.com/phonkee/patrol/settings
  297. github.com/prinsmike/archstatus
  298. github.com/prinsmike/go-module-check
  299. github.com/pschlump/MiscLib
  300. github.com/pschlump/jsondiff
  301. github.com/pschlump/lexie
  302. github.com/pschlump/lexie/com
  303. github.com/pulcy/pulsar/get
  304. github.com/pulcy/pulsar/golang
  305. github.com/rafax/dat/Gododir
  306. github.com/raff/go-fish
  307. github.com/raff/golorizer
  308. github.com/reiki4040/go-memo/ansi_color
  309. github.com/relistan/proctree-stats
  310. github.com/riking/homeapi/marvin/util
  311. github.com/robdimsdale/fly/commands
  312. github.com/robdimsdale/fly/eventstream
  313. github.com/robinjmurphy/later
  314. github.com/robinjmurphy/rd
  315. github.com/rocky/go-fish
  316. github.com/rzh/gofinance/app
  317. github.com/salfield/golly/log
  318. github.com/scjudd/gowatch
  319. github.com/seadowg/fly/commands
  320. github.com/seadowg/fly/eventstream
  321. github.com/sergle/gerrit-status-cli
  322. github.com/serussell/logxi/Gododir
  323. github.com/serussell/logxi/v1
  324. github.com/sgswtky/gotask/io_helper
  325. github.com/siadat/eton
  326. github.com/siddarth/zoo
  327. github.com/sideb0ard/ALBERT
  328. github.com/sideb0ard/CMDSine
  329. github.com/sideb0ard/Craxx
  330. github.com/sideb0ard/SB6502
  331. github.com/sideb0ard/murkdown
  332. github.com/silviucm/utils/log
  333. github.com/simonleung8/cf-download
  334. github.com/simonleung8/cf-download/dir_parser
  335. github.com/simonleung8/cf-download/downloader
  336. github.com/sklise/golang-resize-tasks/tasks
  337. github.com/sonots/lltsv
  338. github.com/sonots/stats
  339. github.com/sosedoff/shuttle-go
  340. github.com/spkane/proctree-stats
  341. github.com/stayradiated/veehd
  342. github.com/stefanbeeman/antfarm/common
  343. github.com/stengaard/ec2
  344. github.com/stephen304/cmdfolder
  345. github.com/stevelacy/go-kompare
  346. github.com/stevepartridge/go/log
  347. github.com/subosito/assert
  348. github.com/sudix/qiita-json-to-md
  349. github.com/sujaynsg/gofinance/app
  350. github.com/superordinate/scope/tools/runner
  351. github.com/swhite24/go-debug
  352. github.com/syohex/gopanf
  353. github.com/syreclabs/dat/Gododir
  354. github.com/t0mk/dosk
  355. github.com/taka011239/hi
  356. github.com/takawang/sugar
  357. github.com/tav/golly/log
  358. github.com/term1nal/kittens
  359. github.com/the-obsidian/mc
  360. github.com/the-varlog/gomon/logger
  361. github.com/therealbill/inspect
  362. github.com/therealbill/inspect/osmain
  363. github.com/thinxer/wscat
  364. github.com/tnextday/dat/Gododir
  365. github.com/tobscher/kiss/logging
  366. github.com/tomerdmnt/ichijiku
  367. github.com/tracelytics/logxi/Gododir
  368. github.com/tracelytics/logxi/v1
  369. github.com/trayo/godo
  370. github.com/trevrosen/go-pry/pry
  371. github.com/trivago/tgo/tlog
  372. github.com/troyk/gosu
  373. github.com/troyk/gosu/util
  374. github.com/tubesandlube/bron
  375. github.com/unchartedsoftware/plog
  376. github.com/upamune/block
  377. github.com/upamune/submit
  378. github.com/upamune/tw
  379. github.com/ursiform/logger
  380. github.com/ustrajunior/minion/tst
  381. github.com/vektra/cypress
  382. github.com/vito/boosh
  383. github.com/vmogilev/go-jira
  384. github.com/weaveworks/build-tools/runner
  385. github.com/weaveworks/scope/tools/runner
  386. github.com/wingyplus/mylog
  387. github.com/woanware/gohttprequest
  388. github.com/woanware/goutil
  389. github.com/x-cray/logrus-prefixed-formatter
  390. github.com/xboston/logxi/Gododir
  391. github.com/xboston/logxi/v1
  392. github.com/xh3b4sd/anna/log
  393. github.com/xlucas/vmgstat/console
  394. github.com/yangchenxing/cangshan/logging
  395. github.com/yashprit/go-cli-colorize-logger
  396. github.com/yelinaung/play-info
  397. github.com/ypapax/godo
  398. github.com/ypapax/godo/util
  399. github.com/ysugimoto/gang
  400. github.com/yukirin/goyuki/command
  401. github.com/yuya-takeyama/hi
  402. github.com/yuya-takeyama/qrcat
  403. github.com/zackkitzmiller/kittens
  404. github.com/zaninime/planet-updater
  405. github.com/zankich/fly/commands
  406. github.com/zeushammer/go-tcp-proxy
  407. github.com/zhaoyao/sitekeeper
  408. github.com/zhaozhi406/factorlog
  409. github.com/zmarcantel/gin/examples/logging
  410. github.com/zstyblik/logxi/Gododir
  411. github.com/zstyblik/logxi/v1
  412. gitlab.com/brianstarke/go-beget
  413. gopkg.in/Netflix-Skunkworks/go-jira.v0
  414. gopkg.in/aphistic/gomol.v0
  415. gopkg.in/bhenderson/goj.v0
  416. gopkg.in/coryb/cliby.v0/util
  417. gopkg.in/coryb/cliby.v1/util
  418. gopkg.in/go-godo/godo.v1
  419. gopkg.in/go-godo/godo.v1/util
  420. gopkg.in/go-godo/godo.v2
  421. gopkg.in/go-godo/godo.v2/util
  422. gopkg.in/godo.v1
  423. gopkg.in/godo.v1/util
  424. gopkg.in/godo.v2
  425. gopkg.in/godo.v2/util
  426. gopkg.in/immesys/bw2bind.v3
  427. gopkg.in/immesys/bw2bind.v5
  428. gopkg.in/mgutz/dat.v1/Gododir
  429. gopkg.in/mgutz/dat.v2/Gododir
  430. gopkg.in/naganumat/godo.v1
  431. gopkg.in/naganumat/godo.v1/util
  432. gopkg.in/naganumat/godo.v2
  433. gopkg.in/naganumat/godo.v2/util
  434. gopkg.in/parkghost/watchf.v0
  435. gopkg.in/spektroskop/go-log.v0