Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bell/attention in tab_title_template #4581

Closed
ChristianTacke opened this issue Jan 27, 2022 · 8 comments
Closed

Allow bell/attention in tab_title_template #4581

ChristianTacke opened this issue Jan 27, 2022 · 8 comments

Comments

@ChristianTacke
Copy link

Is your feature request related to a problem? Please describe.
I start my tab templates with some opening characters like [ or U+1fb7d. Having the bell / attention symbol before that looks like it belongs to the previous tab or the separator.

Describe the solution you'd like
It would be cool to have some {bell} and {attention} variables for the template string, so that one can place them where one likes (and maybe even use the formatter to format them?). If the template (after formatting) doesn't have the bell / attention symbol in it and the symbol is wanted, one can still display them the old way?

Describe alternatives you've considered
Currently tricking around a bit by putting some things in the separators. Which means the first tab does not have the "start" chars.

@kovidgoyal
Copy link
Owner

I suggest you simply draw the tab bar using your own python function. I
dont feel like adding conditionals to the template language. See the
"custom" tab_bar_style https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.tab_bar_style

@ChristianTacke
Copy link
Author

Well, the template language wouldn't really get conditionals. If done the full way, the code in kitty would even get simpler?

bell = ''
if tab.needs_attention and draw_data.bell_on_tab:
    bell = '🔔'eval_locals = {
    'bell': bell,
}
…
title = template.format(**eval_locals)

@ChristianTacke
Copy link
Author

That said… Many thanks for linking me to the custom style and the examples. I guess, I can get something done this way that pleases me!

@kovidgoyal
Copy link
Owner

What you propose would break backward compatibility and prevent the bell symbol from showing up for any existing users that have defined their own templates in kitty.conf.

@ChristianTacke
Copy link
Author

If you want backward compatibility (well, a bit of breaking is IMHO okay for a 0.x release, but anyway), append this:

if bell not in title:
    title = bell + title

This should also work nicely for bell == ""

@kovidgoyal
Copy link
Owner

That assumes bell is a unique character not otherwise present in the
template. That's a reasonably safe assumption but not quite 100%. I can
guarantee someone somewhere is using a common character for bell. See
for example #4507

@ChristianTacke
Copy link
Author

Well, in the case of bell, it's quite reasonable. For the attention symbol, you're probably right!

Also having color codes in it a la {fmt.bg.red} would make this again more unique.

The backward compatibility code is just that: A try to be as backward compatible as reasonable. I would even drop it after a year or so.

Your decision!

@kovidgoyal kovidgoyal reopened this Feb 1, 2022
@ChristianTacke
Copy link
Author

Wow! Cool! Many thanks! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants