Skip to content

Instantly share code, notes, and snippets.

@likern
Created October 1, 2023 23:20
Show Gist options
  • Save likern/06e295f38e296e8efdc3b3daa105fac0 to your computer and use it in GitHub Desktop.
Save likern/06e295f38e296e8efdc3b3daa105fac0 to your computer and use it in GitHub Desktop.
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)
local action = act.AdjustPaneSize { 'Down', 1 }
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
-- pane:split { direction = 'Bottom', top_level = true }
-- window:perform_action(wezterm.action.SplitPane {
-- direction = 'Bottom',
-- command = { args = { 'bash' } },
-- size = { Percent = 40 },
-- top_level = true
-- })
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment