From d077a21a682faa27ab6f153650f38737894af7af Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 7 Jul 2026 22:47:09 -0700 Subject: wezterm: Dynamically load fennel for configuration --- GNUmakefile | 2 - wezterm/.config/wezterm/init.fnl | 75 +++++++++++++++++++++++++++++++++++++ wezterm/.config/wezterm/wezterm.fnl | 75 ------------------------------------- wezterm/.config/wezterm/wezterm.lua | 39 ++++++++++--------- 4 files changed, 97 insertions(+), 94 deletions(-) create mode 100644 wezterm/.config/wezterm/init.fnl delete mode 100644 wezterm/.config/wezterm/wezterm.fnl diff --git a/GNUmakefile b/GNUmakefile index da5f8a7..4370104 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -181,8 +181,6 @@ before-_mbsetupuser-install: \ _mbsetupuser/.emacs.d/init.elc \ _mbsetupuser/.emacs.d/scripts/find-php-class -before-wezterm-install: wezterm/.config/wezterm/wezterm.lua - _mbsetupuser/.config/zsh/conf.d/postgresql.sh: _mbsetupuser/Brewfile $(call tangle,shell) diff --git a/wezterm/.config/wezterm/init.fnl b/wezterm/.config/wezterm/init.fnl new file mode 100644 index 0000000..611624d --- /dev/null +++ b/wezterm/.config/wezterm/init.fnl @@ -0,0 +1,75 @@ +(local wezterm (require :wezterm)) + +(local colors { :foreground "#bfbfbf" + :background "#222424" }) + +(local open-url-key + { :key "E" + :mods "CTRL|SHIFT" + :action (wezterm.action.QuickSelectArgs + { :label "open url" + :patterns [ "https?://[[:alnum:]./-]+[[:alnum:]/]" ] + :action (wezterm.action_callback + (fn [window pane] + (let [url (window:get_selection_text_for_pane pane)] + (wezterm.log_info (.. "opening: " url)) + (wezterm.open_with url)))) }) }) + +(local copy-guix-hash-key + { :key "G" + :mods "LEADER" + :action (wezterm.action.QuickSelectArgs + { :label "copy hash" + :patterns [ "[a-z0-9]{52}" ] + :action (wezterm.action_callback + (fn [window pane] + (let [text (window:get_selection_text_for_pane pane)] + (wezterm.log_info (.. "copying: " text)) + (window:copy_to_clipboard text)))) }) }) +(local keys + [ open-url-key + copy-guix-hash-key + { :key "o" :mods "ALT" :action wezterm.action.PaneSelect } + { :key "p" :mods "ALT" :action (wezterm.action.ScrollToPrompt -1) } + { :key "n" :mods "ALT" :action (wezterm.action.ScrollToPrompt 1) } + { :key "c" :mods "LEADER" :action (wezterm.action.SendKey { :key "c" :mods "CTRL" }) } + { :key "c" :mods "LEADER|CTRL" :action (wezterm.action.SendKey { :key "c" :mods "CTRL" }) }]) + +(local inactive_pane_hsb + { :saturation 0.8 + :brightness 0.7 }) + +{ + ;; I use a tiling window manager, so the window size can't change when the font + ;; size changes. + :adjust_window_size_when_changing_font_size false + + :default_cursor_style "SteadyBar" + + :leader { :key "c" :mods "CTRL" :timeout_seconds 1000 } + + : colors + : keys + : inactive_pane_hsb + + ;; :command_palette_font (wezterm.font "Fantasque Sans Mono") + :command_palette_font_size 14 + :command_palette_bg_color "#111414" + :command_palette_fg_color "#bfbfbf" + :command_palette_rows 10 + + :font (wezterm.font "Fantasque Sans Mono") + :font_size 20 + + :hide_tab_bar_if_only_one_tab true + + :quick_select_alphabet "arstdhneio" + + ;; "INTEGRATED_BUTTONS|RESIZE" keeps the borders resizable and puts the + ;; Min/Max/Close buttons in the tab bar (modern look). + :window_decorations "INTEGRATED_BUTTONS|RESIZE" + + ;; Don't use the compose key in the terminal. + :send_composed_key_when_right_alt_is_pressed false + + } diff --git a/wezterm/.config/wezterm/wezterm.fnl b/wezterm/.config/wezterm/wezterm.fnl deleted file mode 100644 index 611624d..0000000 --- a/wezterm/.config/wezterm/wezterm.fnl +++ /dev/null @@ -1,75 +0,0 @@ -(local wezterm (require :wezterm)) - -(local colors { :foreground "#bfbfbf" - :background "#222424" }) - -(local open-url-key - { :key "E" - :mods "CTRL|SHIFT" - :action (wezterm.action.QuickSelectArgs - { :label "open url" - :patterns [ "https?://[[:alnum:]./-]+[[:alnum:]/]" ] - :action (wezterm.action_callback - (fn [window pane] - (let [url (window:get_selection_text_for_pane pane)] - (wezterm.log_info (.. "opening: " url)) - (wezterm.open_with url)))) }) }) - -(local copy-guix-hash-key - { :key "G" - :mods "LEADER" - :action (wezterm.action.QuickSelectArgs - { :label "copy hash" - :patterns [ "[a-z0-9]{52}" ] - :action (wezterm.action_callback - (fn [window pane] - (let [text (window:get_selection_text_for_pane pane)] - (wezterm.log_info (.. "copying: " text)) - (window:copy_to_clipboard text)))) }) }) -(local keys - [ open-url-key - copy-guix-hash-key - { :key "o" :mods "ALT" :action wezterm.action.PaneSelect } - { :key "p" :mods "ALT" :action (wezterm.action.ScrollToPrompt -1) } - { :key "n" :mods "ALT" :action (wezterm.action.ScrollToPrompt 1) } - { :key "c" :mods "LEADER" :action (wezterm.action.SendKey { :key "c" :mods "CTRL" }) } - { :key "c" :mods "LEADER|CTRL" :action (wezterm.action.SendKey { :key "c" :mods "CTRL" }) }]) - -(local inactive_pane_hsb - { :saturation 0.8 - :brightness 0.7 }) - -{ - ;; I use a tiling window manager, so the window size can't change when the font - ;; size changes. - :adjust_window_size_when_changing_font_size false - - :default_cursor_style "SteadyBar" - - :leader { :key "c" :mods "CTRL" :timeout_seconds 1000 } - - : colors - : keys - : inactive_pane_hsb - - ;; :command_palette_font (wezterm.font "Fantasque Sans Mono") - :command_palette_font_size 14 - :command_palette_bg_color "#111414" - :command_palette_fg_color "#bfbfbf" - :command_palette_rows 10 - - :font (wezterm.font "Fantasque Sans Mono") - :font_size 20 - - :hide_tab_bar_if_only_one_tab true - - :quick_select_alphabet "arstdhneio" - - ;; "INTEGRATED_BUTTONS|RESIZE" keeps the borders resizable and puts the - ;; Min/Max/Close buttons in the tab bar (modern look). - :window_decorations "INTEGRATED_BUTTONS|RESIZE" - - ;; Don't use the compose key in the terminal. - :send_composed_key_when_right_alt_is_pressed false - - } diff --git a/wezterm/.config/wezterm/wezterm.lua b/wezterm/.config/wezterm/wezterm.lua index 3459deb..cfd432e 100644 --- a/wezterm/.config/wezterm/wezterm.lua +++ b/wezterm/.config/wezterm/wezterm.lua @@ -1,19 +1,24 @@ -local wezterm = require("wezterm") -local colors = {foreground = "#bfbfbf", background = "#222424"} -local open_url_key -local function _1_(window, pane) - local url = window:get_selection_text_for_pane(pane) - wezterm.log_info(("opening: " .. url)) - return wezterm.open_with(url) +local wezterm = require "wezterm" + +local function file_exists(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + end + return false end -open_url_key = {key = "E", mods = "CTRL|SHIFT", action = wezterm.action.QuickSelectArgs({label = "open url", patterns = {"https?://[[:alnum:]./-]+[[:alnum:]/]"}, action = wezterm.action_callback(_1_)})} -local copy_guix_hash_key -local function _2_(window, pane) - local text = window:get_selection_text_for_pane(pane) - wezterm.log_info(("copying: " .. text)) - return window:copy_to_clipboard(text) + +local file_name = wezterm.config_dir .. "/fennel.lua" + +if not file_exists(file_name) then + os.execute("curl -o \"" .. file_name .. "\" https://fennel-lang.org/downloads/fennel-1.6.1.lua") end -copy_guix_hash_key = {key = "G", mods = "CTRL|SHIFT", action = wezterm.action.QuickSelectArgs({label = "copy hash", patterns = {"[a-z0-9]{52}"}, action = wezterm.action_callback(_2_)})} -local keys = {open_url_key, copy_guix_hash_key, {key = "o", mods = "ALT", action = wezterm.action.PaneSelect}, {key = "p", mods = "ALT", action = wezterm.action.ScrollToPrompt(-1)}, {key = "n", mods = "ALT", action = wezterm.action.ScrollToPrompt(1)}} -local inactive_pane_hsb = {saturation = 0.8, brightness = 0.7} -return {default_cursor_style = "SteadyBar", colors = colors, keys = keys, inactive_pane_hsb = inactive_pane_hsb, command_palette_font_size = 14, command_palette_bg_color = "#111414", command_palette_fg_color = "#bfbfbf", command_palette_rows = 10, font = wezterm.font("Fantasque Sans Mono"), font_size = 20, hide_tab_bar_if_only_one_tab = true, quick_select_alphabet = "arstdhneio", window_decorations = "INTEGRATED_BUTTONS|RESIZE", adjust_window_size_when_changing_font_size = false} + +wezterm.log_info(package.path) + +local fennel_file_name = wezterm.config_dir .. "/init.fnl" + +wezterm.add_to_config_reload_watch_list(fennel_file_name) + +return require("fennel").install().dofile(fennel_file_name) -- cgit v1.3-2-g0d8e