dotfiles/wezterm/config/events.lua

46 lines
1.0 KiB
Lua
Raw Normal View History

2023-03-22 11:20:01 +00:00
local module = {}
local wezterm = require("wezterm")
local io = require("io")
local os = require("os")
2023-03-22 11:20:01 +00:00
wezterm.on("update-right-status", function(window, pane)
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]
if not last_zone then
return nil
end
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
2023-09-05 22:55:12 +00:00
pane:split({
args = { os.getenv("PAGER") or "less", tmpname },
direction = "Bottom",
domain = { DomainName = "local" },
2023-09-05 22:55:12 +00:00
})
-- 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)
2023-03-22 11:20:01 +00:00
return module