mirror of
https://github.com/foo-dogsquared/dotfiles.git
synced 2025-01-30 22:57:54 +00:00
wezterm: modularize events in apply config step
This commit is contained in:
parent
04e1a9d0b2
commit
0ee4d7df89
@ -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
|
||||
|
@ -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 = {}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user