Skip to content

Extra vertical gap above the modeline when using tmux #663

Description

@mallet

Ghostel is amazing! But I found what seems to be an incorrect vertical alignment when running tmux.

In a raw Bash shell, there is no gap between the modeline and the prompt. See in the example below how the number 4 is truncated so that the prompt lands perfectly above the modeline. I think this is the proper behavior.
Image

But if I run a tmux instance, a gap appears between the tmux status bar and the modeline. See how the 6 is fully shown. The first line (6, here) is never truncated, because of the spurious gap between the tmux status bar and the modeline. I assume this is not expected, and that the proper behavior would be to remove the gap between the tmux status bar and the modeline, and show a truncated 5.
Image

The analysis of an AI is the following:

With these measurements:

(window-screen-lines) => 73.71428571428571

Ghostel normally rounds this down to 73 terminal rows. With a regular shell, ghostel--pixel-anchor can use the scrollback and applies a small vertical scroll, so the bottom is aligned correctly.

With tmux, Ghostel is on the alternate screen, which has no Ghostel scrollback above the visible terminal. ghostel--pixel-anchor then returns:

(1 . 0)

If Ghostel uses 74 rows (ceiling instead of floor), it returns:

(1 . 4)

and the display is aligned as expected: the first line is slightly truncated and the tmux status bar is flush with the modeline.

If that helps, here is a fix I applied in my Emacs configuration, where ceiling makes all the difference:

(defun my/ghostel-window-size (process windows)
  (let ((size (window-adjust-process-window-size-smallest process windows)))
    (if (and windows
             (buffer-live-p (process-buffer process))
             (with-current-buffer (process-buffer process)
               (derived-mode-p 'ghostel-mode)))
        (cons
         (car size)
         (max
          1
          (ceiling
           (apply
            #'min
            (mapcar
             (lambda (window)
               (with-selected-window window
                 (window-screen-lines)))
             windows)))))
      size)))

(setq-default window-adjust-process-window-size-function
              #'my/ghostel-window-size)

Thanks for the excellent work on this very useful extension!

Activity

  1. dakra commented on Aug 31, 2026

    @dakra
    Owner

    and the display is aligned as expected: the first line is slightly truncated and the tmux status bar is flush with the modeline.

    I don't think this is then "aligned as expected" if the first line is slightly truncated.
    That works in screen or tmux but anything with a menubar or a fixed top row (htop, emacs -nw, ...) would then
    look like a cut off first row, no?

  2. mallet commented on Aug 31, 2026

    @mallet
    Author

    Indeed, for top, emacs -nw, and similar terminal applications, the bug is the other way around! Ideally, I suppose there should be neither a gap at the bottom nor any truncation of the first line. The remaining space would then have to appear as a gap at the top.

  3. emil-e commented on Aug 31, 2026

    @emil-e
    Collaborator

    @mallet Just as a clarification - the behavior you describe is expected and by design. tmux uses alt screen which means that it's essentially a fullscreen app without any scrollback. Ghostel sizes its display so that it fits completely within the window that shows it, which means that unless you have your window perfectly sized Ghostel will not fill up the entire screen since that would give you half visible lines - something you typically don't want in alt-screen apps.

    A raw bash shell, as in your first example, is a primary screen application which consists of an active area and then scrollback. Everything from the 5 and downwards is part of the active area and the 4 is part of scrollback. When there is scrollback available, Ghostel will align the bottom row to the bottom of the window and allow partial scrollback rows to be shown. This is because in a terminal with scrollback, the content is naturally bottom aligned and doing it this way prevents jittering when resizing. You could say that content gets added at the bottom and flows upward.

    If there is no scrollback, the the contents will be top aligned since that's where a content naturally aligns in a terminal with a shell - content starts at the top and flow downward, until you start getting scrollback.

    So when you use ceiling instead of floor, you're incorrectly sizing the terminal window so that it doesn't fit in the window anymore.

    @dakra made a PR that lets you set the balance of where the padding ends up. You can try that and see if any setting is more to your liking. But just know that the gap at the bottom is normal and expected behavior, it's the difference between primary screen and alt screen, the different between scrollback and no scrollback. And it is also the default of Ghostty proper.

  4. mallet commented on Aug 31, 2026

    @mallet
    Author

    @emil-e Thanks for the explanations. Very clear and helpful. Thanks for the PR, @dakra . I have commented there.

  5. added 5 commits that reference this issue on Aug 31, 2026
    bc73aad
    2f3d682
    dcb58fc
    17d7b76
    b46413d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions