diff --git a/wezterm/config/events.lua b/wezterm/config/events.lua index 903dec0..c28bf74 100644 --- a/wezterm/config/events.lua +++ b/wezterm/config/events.lua @@ -3,43 +3,51 @@ local wezterm = require("wezterm") local io = require("io") local os = require("os") -wezterm.on("update-right-status", function(window, _) - local key = window:active_key_table() - if key then - key = "TABLE: " .. key - end - window:set_right_status(key or "") -end) +function module.apply_to_config(config) + wezterm.on("update-right-status", function(window, _) + local key = window:active_key_table() + if key then + key = "TABLE: " .. key + end + window:set_right_status(key or "") + end) -wezterm.on("view-last-output-in-new-pane", function(_, pane) - local zones = pane:get_semantic_zones("Output") - local last_zone = zones[#zones - 1] + wezterm.on("view-last-output-in-new-pane", function(_, pane) + local zones = pane:get_semantic_zones("Output") + local last_zone = zones[#zones - 1] - if not last_zone then - return nil - end + if not last_zone then + return nil + end - local output = pane:get_text_from_semantic_zone(last_zone) + local output = pane:get_text_from_semantic_zone(last_zone) - local tmpname = os.tmpname() - local f = io.open(tmpname, "w+") - if f ~= nil then - f:write(output) - f:flush() - f:close() - end + local tmpname = os.tmpname() + local f = io.open(tmpname, "w+") + if f ~= nil then + f:write(output) + f:flush() + f:close() + end - pane:split({ - args = { os.getenv("PAGER") or "less", tmpname }, - direction = "Bottom", - domain = { DomainName = "local" }, - }) + pane:split({ + args = { os.getenv("PAGER") or "less", tmpname }, + direction = "Bottom", + domain = { DomainName = "local" }, + }) - -- Without this, it would quickly close all of the process immediately. - wezterm.sleep_ms(1000) + -- Without this, it would quickly close all of the process immediately. + wezterm.sleep_ms(1000) - -- While it isn't required, it is nice to clean it up. - os.remove(tmpname) -end) + -- While it isn't required, it is nice to clean it up. + os.remove(tmpname) + end) + + -- Maximize the terminal on startup. + wezterm.on('gui-startup', function(cmd) + local tab, pane, window = wezterm.mux.spawn_window(cmd or {}) + window:gui_window():maximize() + end) +end return module diff --git a/wezterm/config/keys.lua b/wezterm/config/keys.lua index f854a60..8c650ee 100644 --- a/wezterm/config/keys.lua +++ b/wezterm/config/keys.lua @@ -2,9 +2,6 @@ local wezterm = require("wezterm") local base = require("config/base") local act = wezterm.action --- Take note this is required to import the events in this module. -local _ = require("config/events") - local keymod = base.keymod local alt_keymod = base.alt_keymod local module = {} diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index f328a14..19ac06e 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -1,6 +1,8 @@ local config = require("wezterm").config_builder() config:set_strict_mode(true) + +require("config/events").apply_to_config(config) require("config/base").apply_to_config(config) require("config/keys").apply_to_config(config) require("config/appearance").apply_to_config(config)