Created
September 30, 2020 13:10
-
-
Save ephraimduncan/e5da46341483802ada7a99736edc5947 to your computer and use it in GitHub Desktop.
Onliner Functions to Add Colors to console logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://stackoverflow.com/a/46705010 | |
const { r, g, b, w, c, m, y, k } = [ | |
['r', 1], | |
['g', 2], | |
['b', 4], | |
['w', 7], | |
['c', 6], | |
['m', 5], | |
['y', 3], | |
['k', 0], | |
].reduce( | |
(cols, col) => ({ | |
...cols, | |
[col[0]]: (f) => `\x1b[3${col[1]}m${f}\x1b[0m`, | |
}), | |
{} | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment