From 2aefdfadd30cae281f5ea7ab6da32b3cc081855f Mon Sep 17 00:00:00 2001 From: Sergei Bulavintsev Date: Thu, 8 Feb 2024 14:23:12 +0300 Subject: [PATCH] feat(wezterm): move events to separate file --- .../nixos/desktop/addons/wezterm/default.nix | 1 + .../nixos/desktop/addons/wezterm/events.lua | 35 +++++++++++++++++++ .../nixos/desktop/addons/wezterm/wezterm.lua | 35 ------------------- 3 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 nix/modules/nixos/desktop/addons/wezterm/events.lua diff --git a/nix/modules/nixos/desktop/addons/wezterm/default.nix b/nix/modules/nixos/desktop/addons/wezterm/default.nix index d5fd69b..d3c841e 100644 --- a/nix/modules/nixos/desktop/addons/wezterm/default.nix +++ b/nix/modules/nixos/desktop/addons/wezterm/default.nix @@ -22,6 +22,7 @@ in { + (builtins.readFile ./mappings.lua) + (builtins.readFile ./colors.lua) + (builtins.readFile ./tabs.lua) + + (builtins.readFile ./events.lua) + '' return config ''; diff --git a/nix/modules/nixos/desktop/addons/wezterm/events.lua b/nix/modules/nixos/desktop/addons/wezterm/events.lua new file mode 100644 index 0000000..ff4e368 --- /dev/null +++ b/nix/modules/nixos/desktop/addons/wezterm/events.lua @@ -0,0 +1,35 @@ +-- Update window title +-- {{{ +wezterm.on("format-window-title", function(tab, _, tabs) + local index = "" + if #tabs > 1 then + index = "[" .. tab.tab_index + 1 .. "/" .. #tabs .. "]" + end + + return index .. tab.window_title +end) +-- }}} +-- Update status on the right side +-- {{{ +-- Icons: https://wezfurlong.org/wezterm/config/lua/wezterm/nerdfonts.html +-- https://wezfurlong.org/wezterm/config/lua/window-events/update-right-status.html +wezterm.on("update-right-status", function(window) + local _, kube_context, _ = wezterm.run_child_process { "bash", "-lc", "kubectx -c" } + local _, kube_ns, _ = wezterm.run_child_process { "bash", "-lc", "kubens -c" } + kube_context = kube_context:gsub("[\n\r]", "") + kube_ns = kube_ns:gsub("[\n\r]", "") + + local date = wezterm.strftime "[%H:%M]" + + window:set_right_status(wezterm.format { + { Foreground = { Color = base16_colors.blue } }, + { Text = wezterm.nerdfonts.md_kubernetes }, + { Foreground = { Color = base16_colors.magenta } }, + { Text = " " .. kube_context }, + { Foreground = { Color = base16_colors.cyan } }, + { Text = ":" .. kube_ns }, + { Foreground = { Color = base16_colors.red } }, + { Text = " " .. date }, + }) +end) +-- }}} diff --git a/nix/modules/nixos/desktop/addons/wezterm/wezterm.lua b/nix/modules/nixos/desktop/addons/wezterm/wezterm.lua index ac4bf34..8e006df 100644 --- a/nix/modules/nixos/desktop/addons/wezterm/wezterm.lua +++ b/nix/modules/nixos/desktop/addons/wezterm/wezterm.lua @@ -47,38 +47,3 @@ config.inactive_pane_hsb = { brightness = 0.2, } -- }}} --- Update window title --- {{{ -wezterm.on("format-window-title", function(tab, _, tabs) - local index = "" - if #tabs > 1 then - index = "[" .. tab.tab_index + 1 .. "/" .. #tabs .. "]" - end - - return index .. tab.window_title -end) --- }}} --- Update status on the right side --- {{{ --- Icons: https://wezfurlong.org/wezterm/config/lua/wezterm/nerdfonts.html --- https://wezfurlong.org/wezterm/config/lua/window-events/update-right-status.html -wezterm.on("update-right-status", function(window) - local _, kube_context, _ = wezterm.run_child_process { "bash", "-lc", "kubectx -c" } - local _, kube_ns, _ = wezterm.run_child_process { "bash", "-lc", "kubens -c" } - kube_context = kube_context:gsub("[\n\r]", "") - kube_ns = kube_ns:gsub("[\n\r]", "") - - local date = wezterm.strftime "[%H:%M]" - - window:set_right_status(wezterm.format { - { Foreground = { Color = base16_colors.blue } }, - { Text = wezterm.nerdfonts.md_kubernetes }, - { Foreground = { Color = base16_colors.magenta } }, - { Text = " " .. kube_context }, - { Foreground = { Color = base16_colors.cyan } }, - { Text = ":" .. kube_ns }, - { Foreground = { Color = base16_colors.red } }, - { Text = " " .. date }, - }) -end) --- }}}