feat(tab-bar): add command status and abbreviated cwd indicators

The tab bar only showed the window title, so it was impossible to tell at a
glance whether the last command failed or which directory a tab was in. Expose
the active window's last exit status and a compact working directory to
tab_title_template, and refresh the tab bar when a command finishes.
This commit is contained in:
BlackAngelTV committed 2026-11-09 11:14:07 +01:00
1 parent 90e6355841
commit bcf3fdff7b
5 files changed
+157 -11

No files matched your search

+17 -4
View File
@@ -2450,7 +2450,7 @@ lines is wrapped independently.
opt(
'tab_title_template',
'"{fmt.fg.red}{bell_symbol}{activity_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
'"{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_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
@@ -2473,12 +2473,25 @@ use :code:`{sup.index}`. All data available is:
The number of windows in the tab.
:code:`num_window_groups`
The number of window groups (a window group is a window and all of its overlay windows) in the tab.
:code:`last_exit_code`
The exit status of the last command that finished in the active window of
the tab, or the empty string if it succeeded or no command has finished.
Requires :ref:`shell integration <shell_integration>`.
:code:`exit_status_symbol`
A cross followed by :code:`last_exit_code` when the last command failed,
empty otherwise. Requires :ref:`shell integration <shell_integration>`.
:code:`secure_input_symbol`
A key symbol when secure input is enabled on macOS and the tab is the active tab, empty otherwise.
:code:`tab.active_wd`
The working directory of the currently active window in the tab
(expensive, requires syscall). Use :code:`tab.active_oldest_wd` to get
the directory of the oldest foreground process rather than the newest.
:code:`tab.active_wd_abbreviated`
A compact form of :code:`tab.active_wd` suited to a tab title: the home
directory is shown as ``~``, intermediate directories are reduced to
their first letter and, when the result is still too long, middle
directories are replaced by an ellipsis. For example
``~/p/fws-kitty``. Has the same cost as :code:`tab.active_wd`.
:code:`tab.active_exe`
The name of the executable running in the foreground of the currently
active window in the tab (expensive, requires syscall). Use
@@ -2518,9 +2531,9 @@ use styling directives, for example:
Similarly, for bold and italic:
``{fmt.bold}bold{fmt.nobold}normal{fmt.italic}italic{fmt.noitalic}``.
The 256 eight terminal colors can be used as ``fmt.fg.color0`` through ``fmt.fg.color255``.
Note that for backward compatibility, if :code:`{bell_symbol}` or
:code:`{activity_symbol}` are not present in the template, they are prepended to
it.
Note that for backward compatibility, if :code:`{bell_symbol}`,
:code:`{activity_symbol}` or :code:`{exit_status_symbol}` are not present in
the template, they are prepended to it.
""",
)
+1 -1
View File
@@ -704,7 +704,7 @@ class Options:
tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
tab_title_max_length: int = 0
tab_title_max_lines: int = 1
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}'
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}'
tab_title_wrap: int = 0
term: str = 'xterm-kitty'
terminfo_type: choices_for_terminfo_type = 'path'