mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 22:14:53 +02:00
Nicer fix for showing cwd in tab titles
This commit is contained in:
@@ -178,28 +178,14 @@ def template_has_field(template: str, field: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
class TabCWD:
|
||||
|
||||
def __init__(self, tab_ref: 'ReferenceType[Tab]'):
|
||||
self.tab_ref = tab_ref
|
||||
self.saved_val: Optional[str] = None
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self.saved_val is None:
|
||||
tab = self.tab_ref()
|
||||
self.saved_val = (tab.get_cwd_of_active_window() or '') if tab else ''
|
||||
return self.saved_val
|
||||
|
||||
|
||||
def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int) -> None:
|
||||
tcwd = TabCWD(tab.tab_ref)
|
||||
data = {
|
||||
'index': index,
|
||||
'layout_name': tab.layout_name,
|
||||
'num_windows': tab.num_windows,
|
||||
'num_window_groups': tab.num_window_groups,
|
||||
'title': tab.title,
|
||||
'cwd': tcwd,
|
||||
'tab': tab.tab_ref(),
|
||||
}
|
||||
ColorFormatter.draw_data = draw_data
|
||||
ColorFormatter.tab_data = tab
|
||||
@@ -209,7 +195,7 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int)
|
||||
'num_windows': tab.num_windows,
|
||||
'num_window_groups': tab.num_window_groups,
|
||||
'title': tab.title,
|
||||
'cwd': tcwd,
|
||||
'tab': tab.tab_ref(),
|
||||
'fmt': Formatter,
|
||||
'sup': SupSub(data),
|
||||
'sub': SupSub(data, True),
|
||||
|
||||
Reference in New Issue
Block a user