Skip to content

Instantly share code, notes, and snippets.

@likern
Created October 2, 2023 11:00
Show Gist options
  • Save likern/a077efcb1b6e5fa42e21652c317b7f5c to your computer and use it in GitHub Desktop.
Save likern/a077efcb1b6e5fa42e21652c317b7f5c to your computer and use it in GitHub Desktop.
Show or Hide Overlay Pane For WezTerm
wezterm.on('show-or-hide-overlay', function(window, pane)
wezterm.log_info 'Event: show-or-hide-terminal'
local overlay_pane_ids = wezterm.GLOBAL.overlay_pane_ids
local tab_old_pane_ids = {}
local found = false
if overlay_pane_ids then
local active_tab = window:active_tab()
for _, pane_with_info in pairs(active_tab:panes_with_info()) do
local pane_id = pane_with_info.pane:pane_id()
table.insert(tab_old_pane_ids, pane_id)
if overlay_pane_ids[tostring(pane_id)] then
found = true
-- local pixel_width = pane_with_info.pixel_width;
local pixel_height = pane_with_info.pixel_height;
wezterm.log_info('Found overlay pane ' .. tostring(pane_id) .. ', height = ' .. pixel_height .. '. Close it!')
pane_with_info.pane:activate()
local action = act.CloseCurrentPane { confirm = false }
window:perform_action(action, pane_with_info.pane)
end
end
end
if not found then
wezterm.log_info('NOT Found overlay pane, create a new one')
local active_pane = window:active_tab():active_pane()
local new_pane = active_pane:split {
direction = 'Bottom',
args = { 'bash' },
size = 0.5,
top_level = true
}
local new_pane_id = new_pane:pane_id()
wezterm.log_info('Created new pane with id ' .. tostring(new_pane_id))
if not overlay_pane_ids then
overlay_pane_ids = {}
end
overlay_pane_ids[tostring(new_pane_id)] = true
wezterm.GLOBAL.overlay_pane_ids = overlay_pane_ids
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment