kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
22.13k stars 907 forks source link

Break values in kitty.conf into multiple lines #7375

Closed lyokha closed 3 weeks ago

lyokha commented 3 weeks ago

This is not a feature request but rather a question. I have very long lines for values of tab_title_template and active_tab_title_template, and they tend to grow. I didn't find how to break values in kitty.conf into multiple lines, so I accidentally checked this:

tab_title_template          {fmt.italic}{fmt.fg._404040}{index}{fmt.fg._d2eb52}{activity_symbol} {fmt.noitalic}
                           \{fmt.fg._cc4545 if title[:5] == 'root@' else fmt.fg._aa6666 if title[0] >= '\ue600' and title[1].isspace() else fmt.fg.tab}
                           \{title[0]}{fmt.fg.tab if title[0] >= '\ue600' and title[1].isspace() else ''}{title[1:]}
active_tab_title_template   {fmt.italic}{fmt.fg._404040}{index}{fmt.fg._eb7152}{activity_symbol} {fmt.nobold}
                           \{fmt.fg._ff0000 if title[:5] == 'root@' else fmt.fg._cc3333 if title[0] >= '\ue600' and title[1].isspace() else fmt.fg.tab}
                           \{title[0]}{fmt.fg.tab if title[0] >= '\ue600' and title[1].isspace() else ''}{title[1:]}

(notice backslashes at beginning of secondary lines) and, to my surprise, this worked as expected! So the question is: can I rely on this syntax? If so then does it make sense to document this in the Kitty documentation? Note also that vim-kitty does not highlight this well.

lyokha commented 3 weeks ago

I found that debug_config shows multi-lined values as a single concatenated line, so this really seems to work as expected. In my particular case, I put the settings in even more expressive way:

tab_title_template
    \ {fmt.italic}{fmt.fg._404040}{index}{fmt.fg._d2eb52}{activity_symbol}
    \ {fmt.noitalic}
    \{fmt.fg._cc4545 if title[:5] == 'root@'
        \ else fmt.fg._aa6666 if title[0] >= '\ue600' and title[1].isspace()
        \ else fmt.fg.tab}
    \{title[0]}
    \{fmt.fg.tab if title[0] >= '\ue600' and title[1].isspace()
        \ else ''}
    \{title[1:]}
active_tab_title_template
    \ {fmt.italic}{fmt.fg._404040}{index}{fmt.fg._eb7152}{activity_symbol}
    \ {fmt.nobold}
    \{fmt.fg._ff0000 if title[:5] == 'root@'
        \ else fmt.fg._cc3333 if title[0] >= '\ue600' and title[1].isspace()
        \ else fmt.fg.tab}
    \{title[0]}
    \{fmt.fg.tab if title[0] >= '\ue600' and title[1].isspace()
        \ else ''}
    \{title[1:]}
kovidgoyal commented 3 weeks ago

It is documented at https://sw.kovidgoyal.net/kitty/conf/ read the first few paragraphs.

lyokha commented 3 weeks ago

Ah, really. Somehow I missed that. Thanks!