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