Update wezterm config
This commit is contained in:
parent
238f3ea099
commit
12e47a8613
44 changed files with 10874 additions and 171 deletions
|
@ -1,4 +1,5 @@
|
|||
local wezterm = require("wezterm")
|
||||
local wezterm = require("wezterm") --[[@as Wezterm]]
|
||||
local act = wezterm.action
|
||||
|
||||
local M = {}
|
||||
|
||||
|
@ -11,8 +12,8 @@ M.merge_tables = function(a, b)
|
|||
end
|
||||
end
|
||||
|
||||
-- Only load color schemes once; store them for later use
|
||||
M.get_schemes = function()
|
||||
-- Only load color schemes once; store them for later use
|
||||
local schemes = wezterm.GLOBAL.color_schemes
|
||||
if schemes then
|
||||
return schemes
|
||||
|
@ -21,4 +22,34 @@ M.get_schemes = function()
|
|||
return wezterm.GLOBAL.color_schemes
|
||||
end
|
||||
|
||||
-- Mimicks the show_last_command_output command in Kitty
|
||||
-- Spawns the pager in a new tab since Wezterm (for now) lacks overlays
|
||||
-- This function is meant to be used as a keybinding callback
|
||||
M.open_last_output_in_less = function(window, pane)
|
||||
-- Grab the last nonempty "output" semantic zone
|
||||
local zones = pane:get_semantic_zones("Output")
|
||||
local last_output = ""
|
||||
local idx = #zones
|
||||
while true do
|
||||
if idx == 0 then
|
||||
break
|
||||
end
|
||||
last_output = pane:get_text_from_semantic_zone(zones[idx])
|
||||
if last_output ~= "" then
|
||||
break
|
||||
end
|
||||
idx = idx - 1
|
||||
end
|
||||
|
||||
-- Ensure any quotes in output are properly escaped
|
||||
-- This is because we need to use sh/echo as a hackaround for wezterm not supporting passing stdin to
|
||||
-- commands spawned in a new tab/window
|
||||
-- See this StackOverflow question/answer for why this particular substitution works: https://stackoverflow.com/a/1315213
|
||||
last_output = last_output:gsub("'", "'\\''")
|
||||
|
||||
-- Spawn less in a new tab
|
||||
local action = act.SpawnCommandInNewTab({ args = { "sh", "-c", "echo '" .. last_output .. "' | less -R" } })
|
||||
window:perform_action(action, pane)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue