-
Notifications
You must be signed in to change notification settings - Fork 0
/
color-config.lua
55 lines (48 loc) · 1.76 KB
/
color-config.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
local wezterm = require "wezterm"
local util = require "util.util"
color_config = {}
function select_random_scheme(all_color_schemes)
local keys = {}
local n = 0
for k, _ in pairs(all_color_schemes) do
n = n + 1
keys[n] = k
end
local index = math.random(0, #(keys))
return keys[index]
end
function get_color_scheme(scheme_name, randomize_color_scheme)
local color_scheme_map = {}
local default_color_scheme = {
background = "#dfdbc3",
cursor_bg = "#73635a",
cursor_fg = "#000000",
foreground = "#3b2322",
selection_bg = "#000000",
selection_fg = "#a4a390"
}
local color_schemes_filename = util.path_join({wezterm.config_dir, "color-schemes.json"})
local all_color_schemes = util.json_parse(color_schemes_filename)
if all_color_schemes ~= nil then
if randomize_color_scheme then
scheme_name = select_random_scheme(all_color_schemes)
end
if all_color_schemes[scheme_name] ~= nil then
color_scheme_map = {
background = all_color_schemes[scheme_name]["background"],
cursor_bg = all_color_schemes[scheme_name]["cursor_bg"],
cursor_fg = all_color_schemes[scheme_name]["cursor_fg"],
foreground = all_color_schemes[scheme_name]["foreground"],
selection_fg = all_color_schemes[scheme_name]["selection_bg"],
selection_bg = all_color_schemes[scheme_name]["selection_fg"],
}
else
color_scheme_map = default_color_scheme
end
else
color_scheme_map = default_color_scheme
end
return color_scheme_map
end
color_config.get_color_scheme = get_color_scheme
return color_config