mirror of
https://github.com/foo-dogsquared/dotfiles.git
synced 2025-01-31 04:57:57 +00:00
wezterm: add binding for viewing last output in pager
This commit is contained in:
parent
94286cf334
commit
e7efc8b643
@ -1,5 +1,7 @@
|
|||||||
local module = {}
|
local module = {}
|
||||||
local wezterm = require("wezterm")
|
local wezterm = require("wezterm")
|
||||||
|
local io = require("io")
|
||||||
|
local os = require("os")
|
||||||
|
|
||||||
wezterm.on("update-right-status", function(window, pane)
|
wezterm.on("update-right-status", function(window, pane)
|
||||||
local key = window:active_key_table()
|
local key = window:active_key_table()
|
||||||
@ -9,4 +11,35 @@ wezterm.on("update-right-status", function(window, pane)
|
|||||||
window:set_right_status(key or "")
|
window:set_right_status(key or "")
|
||||||
end)
|
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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
-- While it isn't required, it is nice to clean it up.
|
||||||
|
os.remove(tmpname)
|
||||||
|
end)
|
||||||
|
|
||||||
return module
|
return module
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
local wezterm = require("wezterm")
|
local wezterm = require("wezterm")
|
||||||
local base = require("config/base")
|
local base = require("config/base")
|
||||||
local events = require("config/events")
|
|
||||||
local act = wezterm.action
|
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 keymod = base.keymod
|
||||||
local alt_keymod = base.alt_keymod
|
local alt_keymod = base.alt_keymod
|
||||||
local module = {}
|
local module = {}
|
||||||
@ -115,6 +117,7 @@ function module.apply_to_config(config)
|
|||||||
{ key = "r", mods = keymod, action = act.ReloadConfiguration },
|
{ key = "r", mods = keymod, action = act.ReloadConfiguration },
|
||||||
{ key = "t", mods = keymod, action = act.ShowDebugOverlay },
|
{ key = "t", mods = keymod, action = act.ShowDebugOverlay },
|
||||||
{ key = "p", mods = keymod, action = act.ActivateCommandPalette },
|
{ key = "p", mods = keymod, action = act.ActivateCommandPalette },
|
||||||
|
{ key = "e", mods = keymod, action = act.EmitEvent "view-last-output-in-new-pane" },
|
||||||
|
|
||||||
-- Selection
|
-- Selection
|
||||||
{ key = "Space", mods = "LEADER", action = act.QuickSelect },
|
{ key = "Space", mods = "LEADER", action = act.QuickSelect },
|
||||||
|
Loading…
Reference in New Issue
Block a user