wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.68k stars 745 forks source link

Centered tab bar #2167

Open Pablo1107 opened 2 years ago

Pablo1107 commented 2 years ago

Is your feature request related to a problem? Please describe. Trying to imitate my custom bar that I use in tmux. image

I get something like this: image

Describe the solution you'd like I would like to be able to have those tabs title in the center of the window.

phgz commented 1 year ago

A solution could be to add some padding on the left in update-status depending on status-left, statusright`, and panes titles, but we do not have access to these last objets.

Congee commented 3 months ago

Here is an example to merge vim statusline into wezterm's status bar, with tab titles centered.

image

https://github.com/Congee/nix/blob/8394e6b13bfd870925a5d750afb8475a5502db6a/config/.wezterm.lua#L245-L269 https://github.com/Congee/nix/blob/8394e6b13bfd870925a5d750afb8475a5502db6a/config/nvim/lua/wezterm_bar.lua#L25

aasril commented 3 weeks ago

@Congee Thank you.

Since, I don't want to merge the tab bar with vim status line, it boils down to:

-- Center tab bar
wezterm.on("update-status", function(gui_window, pane)
    local tabs = gui_window:mux_window():tabs();
    local mid_width = 0;
    for idx, tab in ipairs(tabs) do
        local title = tab:get_title();
        mid_width = mid_width + math.floor(math.log(idx, 10)) + 1
        mid_width = mid_width + 2 + #title + 1
    end
    local tab_width = gui_window:active_tab():get_size().cols;
    local max_left = tab_width / 2 - mid_width / 2;

    gui_window:set_left_status(wezterm.pad_left(' ', max_left))
    gui_window:set_right_status('')
end)

The caveat with this is the workspace name is pushed out of the screen.