From 22341e798837bee6bf9018737f15f51fbc2209e9 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 3 Mar 2023 18:41:06 +0100 Subject: [PATCH] wezterm: Dynamically load colors from scheme file --- terminal/.config/wezterm/wezterm.lua | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/terminal/.config/wezterm/wezterm.lua b/terminal/.config/wezterm/wezterm.lua index 525036c..cca48f1 100644 --- a/terminal/.config/wezterm/wezterm.lua +++ b/terminal/.config/wezterm/wezterm.lua @@ -6,6 +6,26 @@ local maps = require 'maps' require 'statusbar'.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) -- -- Set a workspace for coding on a current project -- -- Top pane is for the editor, bottom pane is for the build tool @@ -58,20 +78,16 @@ require 'events'.setup() return { enable_wayland = true, - hide_tab_bar_if_only_one_tab = true, use_fancy_tab_bar = false, tab_bar_at_bottom = true, window_padding = { left = 0, right = 0, top = 0, bottom = 0 }, - - color_scheme = "Railscasts (base16)", - + colors = colors, + color_scheme = "Nord (base16)", -- will be overwritten by colors -- default_prog = {"nu"}, scrollback_lines = 10000, - font = wezterm.font('Iosevka Nerd Font'), line_height = 1.0, - leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 }, keys = maps.keys, key_tables = maps.key_tables