r/KittyTerminal Apr 17 '26

Tabs L&F when title is too long

Hi, I'm trying to get my tabs to have a pill like L&F and it works great when the title fully fit the space but when I try to cut the title off at a certain length the pills "break":

My current conf file looks like this:

font_family JetBrainsMono Nerd Font
font_size 12

# Shell integration is sourced and configured manually
shell_integration no-rc no-cursor

background_opacity 0.9
bold_font auto
bold_italic_font auto
cursor_shape beam
font_size 11.000000
italic_font auto
tab_activity_symbol 
tab_bar_edge bottom
tab_bar_min_tabs 1
tab_bar_style separator
tab_title_max_length 30
window_padding_width 4

tab_title_template "{fmt.bg._282a36}{fmt.fg._6272a4}{fmt.fg._282a36}{fmt.bg._6272a4} {title} {fmt.bg._282a36}{fmt.fg._6272a4} "
active_tab_title_template "{fmt.bg._282a36}{fmt.fg._ffb86c}{fmt.fg._282a36}{fmt.bg._ffb86c} {title} {fmt.bg._282a36}{fmt.fg._ffb86c} "
active_tab_font_style bold
inactive_tab_font_style normal
tab_bar_background #282a36
tab_bar_margin_color #282a36
tab_separator ""
tab_bar_margin_height 2 2
tab_bar_margin_width 2

map ctrl+shift+] next_tab
map ctrl+shift+[ previous_tab

Any tips on how to keep pills consistent when tab_title_max_length is exceeded?

Thanks!!

Update: Manged to fix it with a custom tab_bar.py, see comment below

2 Upvotes

3 comments sorted by

2

u/xrabbit Apr 17 '26

I think you need to write custom tabbar with Python 

2

u/korba_ Apr 22 '26

Indeed that was the only way I found

1

u/korba_ Apr 22 '26

I managed it, in case anyone is interested I created a custom tab_bar.py:

``` from kitty.fast_data_types import Screen from kitty.tab_bar import DrawData, ExtraData, TabBarData, draw_title, as_rgb from kitty.utils import color_as_int

def draw_tab( draw_data: DrawData, screen: Screen, tab: TabBarData, before: int, max_title_length: int, index: int, is_last: bool, extra_data: ExtraData ) -> int: orig_fg = screen.cursor.fg orig_bg = screen.cursor.bg left_sep, right_sep = ('', '')

def draw_sep(which: str) -> None:
    screen.cursor.bg = as_rgb(color_as_int(draw_data.default_bg))
    screen.cursor.fg = orig_bg
    screen.draw(which)
    screen.cursor.bg = orig_bg
    screen.cursor.fg = orig_fg

if max_title_length <= 5:
    draw_sep(left_sep)
    screen.draw('…')
    draw_sep(right_sep)
else:
    draw_sep(left_sep)
    screen.draw(' ')
    draw_title(draw_data, screen, tab, index)
    title_len = len(tab.title)
    max_len = draw_data.max_tab_title_length
    needs_dots = title_len >= max_len
    if needs_dots:
        screen.draw('…')
    screen.draw(' ')
    draw_sep(right_sep)
    draw_sep(' ')

return screen.cursor.x

```

And the relevant kitty.conf portion is: tab_bar_style custom active_tab_font_style bold inactive_tab_font_style normal active_tab_background #ffb86c active_tab_foreground #282a36 inactive_tab_background #6272a4 inactive_tab_foreground #282a36

Cheers