Skip to content

Instantly share code, notes, and snippets.

@crevier
Created June 13, 2018 14:21
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crevier/f2529b8b474ecddeb606770d148e761f to your computer and use it in GitHub Desktop.
Save crevier/f2529b8b474ecddeb606770d148e761f to your computer and use it in GitHub Desktop.
How to print color in console in groovy
def fg = 30
def bg = 46
def style = "${(char)27}[$fg;$bg"+"m"
println(style+"HELLO")
/*
+~~~~~~+~~~~~~+~~~~~~~~~~~+
| fg | bg | color |
+~~~~~~+~~~~~~+~~~~~~~~~~~+
| 30 | 40 | black |
| 31 | 41 | red |
| 32 | 42 | green |
| 33 | 43 | yellow |
| 34 | 44 | blue |
| 35 | 45 | magenta |
| 36 | 46 | cyan |
| 37 | 47 | white |
| 39 | 49 | default |
+~~~~~~+~~~~~~+~~~~~~~~~~~+
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment