Skip to content

Center wezterm when opening additional new window(s) (CMD+N) #5578

Answered by Hacksore
Hacksore asked this question in Q&A
Discussion options

You must be logged in to vote

Was able to find a working solution for this with what @wez suggestion above.

local function center_window_once(window)
  wezterm.GLOBAL.windows_centered = wezterm.GLOBAL.windows_centered or {}

  local window_id = window:window_id() .. ""
  if wezterm.GLOBAL.windows_centered[window_id] then
    return
  end

  local screen = wezterm.gui.screens().active

  local width = screen.width * 0.85
  local height = screen.height * 0.85

  window:set_inner_size(width, height)

  local dimensions = window:get_dimensions()
  local x = (screen.width - dimensions.pixel_width) * 0.5
  local y = (screen.height - dimensions.pixel_height) * 0.5

  wezterm.GLOBAL.windows_centered[window_id] = true

  window:

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@wez
Comment options

wez Jun 20, 2024
Maintainer

@Hacksore
Comment options

@wez
Comment options

wez Jun 20, 2024
Maintainer

@Hacksore
Comment options

Answer selected by Hacksore

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants