When a program running in kitty reports progress of a task display it as a percentage in the tab title

This commit is contained in:
Kovid Goyal
2025-01-05 08:48:46 +05:30
parent 1080b148d3
commit 9b9b313e77
7 changed files with 147 additions and 9 deletions

View File

@@ -1400,7 +1400,7 @@ A value of zero means that no limit is applied.
'''
)
opt('tab_title_template', '"{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{title}"',
opt('tab_title_template', '"{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
option_type='tab_title_template',
long_text='''
A template to render the tab title. The default just renders the title with
@@ -1431,6 +1431,12 @@ use :code:`{sup.index}`. All data available is:
The maximum title length available.
:code:`keyboard_mode`
The name of the current :ref:`keyboard mode <modal_mappings>` or the empty string if no keyboard mode is active.
:code:`tab.last_focused_progress_percent`
If a command running in a window reports the progress for a task, show this progress as a percentage
from the most recently focused window in the tab. Empty string if no progress is reported.
:code:`tab.progress_percent`
If a command running in a window reports the progress for a task, show this progress as a percentage
from all windows in the tab, averaged. Empty string is no progress is reported.
Note that formatting is done by Python's string formatting machinery, so you can
use, for instance, :code:`{layout_name[:2].upper()}` to show only the first two

View File

@@ -607,7 +607,7 @@ class Options:
tab_separator: str = ''
tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
tab_title_max_length: int = 0
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{title}'
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}'
term: str = 'xterm-kitty'
terminfo_type: choices_for_terminfo_type = 'path'
text_composition_strategy: str = 'platform'
@@ -1039,6 +1039,7 @@ defaults.mouse_map = [
MouseMapping(button=1, mods=5, definition='mouse_show_command_output'),
]
nullable_colors = frozenset({
'cursor'
'cursor_text_color'