Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save red-001/5c279faa2f4dfd6fef4fdb4a9a36ba7a to your computer and use it in GitHub Desktop.
Save red-001/5c279faa2f4dfd6fef4fdb4a9a36ba7a to your computer and use it in GitHub Desktop.
local ESCAPE_CHAR = string.char(0x1b)
core = {}
function core.get_color_escape_sequence(color)
return ESCAPE_CHAR .. "(c@" .. color .. ")"
end
function core.get_background_escape_sequence(color)
return ESCAPE_CHAR .. "(b@" .. color .. ")"
end
function core.colorize(color, message)
return core.get_color_escape_sequence(color) .. message
end
print(core.colorize("red", "colour test"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment