mirror of https://github.com/Hilbis/Hilbish
feat(libs): add ansi lib for easier color codes, change config to use it
parent
e529796139
commit
333141ab60
|
@ -1,3 +1,6 @@
|
||||||
-- Default Hilbish config
|
-- Default Hilbish config
|
||||||
|
package.path = package.path .. ';./libs/?/init.lua'
|
||||||
|
|
||||||
prompt(string.char(0x001b).."[36m"..os.getenv("USER").." λ "..string.char(0x001b).."[0m")
|
local ansikit = require 'ansikit'
|
||||||
|
|
||||||
|
prompt(ansikit.text('λ {bold}{cyan}'..os.getenv('USER')..' >{magenta}>{cyan}>{reset} '))
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
local ansikit = {}
|
||||||
|
|
||||||
|
ansikit.getCSI = function (code, endc)
|
||||||
|
endc = (endc and endc or 'm')
|
||||||
|
return string.char(0x001b) .. '[' .. code .. endc
|
||||||
|
end
|
||||||
|
|
||||||
|
ansikit.text = function (text)
|
||||||
|
local colors = {
|
||||||
|
reset = {'{reset}', ansikit.getCSI(0)},
|
||||||
|
bold = {'{bold}', ansikit.getCSI(1)},
|
||||||
|
dim = {'{dim}', ansikit.getCSI(2)},
|
||||||
|
italic = {'{italic}', ansikit.getCSI(3)},
|
||||||
|
underline = {'{underline}', ansikit.getCSI(4)},
|
||||||
|
invert = {'{invert}', ansikit.getCSI(7)},
|
||||||
|
bold_off = {'{bold-off}', ansikit.getCSI(22)},
|
||||||
|
underline_off = {'{underline-off}', ansikit.getCSI(24)},
|
||||||
|
black = {'{black}', ansikit.getCSI(30)},
|
||||||
|
red = {'{red}', ansikit.getCSI(31)},
|
||||||
|
magenta = {'{magenta}', ansikit.getCSI(35)},
|
||||||
|
cyan = {'{cyan}', ansikit.getCSI(36)}
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v in pairs(colors) do
|
||||||
|
text = text:gsub(v[1], v[2])
|
||||||
|
end
|
||||||
|
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
return ansikit
|
||||||
|
|
Loading…
Reference in New Issue