wezterm: Dynamically load colors from scheme file

This commit is contained in:
Marty Oehme 2023-03-03 18:41:06 +01:00
parent 25d37d17b3
commit 22341e7988
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -6,6 +6,26 @@ local maps = require 'maps'
require 'statusbar'.setup() require 'statusbar'.setup()
require 'events'.setup() require 'events'.setup()
local function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- automatically reload colors file
local colorsfile = (os.getenv('XDG_STATE_HOME') or
(os.getenv('HOME') .. '/.local/state')) ..
'/wezterm/colors.toml'
local colors = {}
if file_exists(colorsfile) == true then
wezterm.add_to_config_reload_watch_list(colorsfile)
colors = wezterm.color.load_scheme(colorsfile)
end
-- wezterm.on("set-up-dotfile-workspace", function(window, pane) -- wezterm.on("set-up-dotfile-workspace", function(window, pane)
-- -- Set a workspace for coding on a current project -- -- Set a workspace for coding on a current project
-- -- Top pane is for the editor, bottom pane is for the build tool -- -- Top pane is for the editor, bottom pane is for the build tool
@ -58,20 +78,16 @@ require 'events'.setup()
return { return {
enable_wayland = true, enable_wayland = true,
hide_tab_bar_if_only_one_tab = true, hide_tab_bar_if_only_one_tab = true,
use_fancy_tab_bar = false, use_fancy_tab_bar = false,
tab_bar_at_bottom = true, tab_bar_at_bottom = true,
window_padding = { left = 0, right = 0, top = 0, bottom = 0 }, window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
colors = colors,
color_scheme = "Railscasts (base16)", color_scheme = "Nord (base16)", -- will be overwritten by colors
-- default_prog = {"nu"}, -- default_prog = {"nu"},
scrollback_lines = 10000, scrollback_lines = 10000,
font = wezterm.font('Iosevka Nerd Font'), font = wezterm.font('Iosevka Nerd Font'),
line_height = 1.0, line_height = 1.0,
leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 }, leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 },
keys = maps.keys, keys = maps.keys,
key_tables = maps.key_tables key_tables = maps.key_tables