mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-10-26 15:13:22 +03:00
Session file: Allow setting the title for windows
This commit is contained in:
parent
c551384369
commit
85a3da057f
@ -291,6 +291,8 @@ cd ~
|
||||
# Create a window and run the specified command in it
|
||||
launch zsh
|
||||
launch vim
|
||||
# Set the title for the next window
|
||||
title Chat with x
|
||||
launch irssi --profile x
|
||||
|
||||
# Create a new tab (the part after new_tab is the optional tab name which will
|
||||
|
@ -18,6 +18,7 @@ def __init__(self, opts, name):
|
||||
self.enabled_layouts = opts.enabled_layouts
|
||||
self.layout = (self.enabled_layouts or ['tall'])[0]
|
||||
self.cwd = None
|
||||
self.next_title = None
|
||||
|
||||
|
||||
class Session:
|
||||
@ -31,6 +32,9 @@ def add_tab(self, opts, name=''):
|
||||
del self.tabs[-1]
|
||||
self.tabs.append(Tab(opts, name))
|
||||
|
||||
def set_next_title(self, title):
|
||||
self.tabs[-1].next_title = title.strip()
|
||||
|
||||
def set_layout(self, val):
|
||||
if val not in all_layouts:
|
||||
raise ValueError('{} is not a valid layout'.format(val))
|
||||
@ -42,7 +46,9 @@ def add_window(self, cmd):
|
||||
else:
|
||||
cmd = None
|
||||
from .tabs import SpecialWindow
|
||||
self.tabs[-1].windows.append(SpecialWindow(cmd, cwd=self.tabs[-1].cwd))
|
||||
t = self.tabs[-1]
|
||||
t.windows.append(SpecialWindow(cmd, cwd=t.cwd, override_title=t.next_title))
|
||||
t.next_title = None
|
||||
|
||||
def add_special_window(self, sw):
|
||||
self.tabs[-1].windows.append(sw)
|
||||
@ -78,6 +84,8 @@ def parse_session(raw, opts):
|
||||
ans.set_enabled_layouts(rest)
|
||||
elif cmd == 'cd':
|
||||
ans.set_cwd(rest)
|
||||
elif cmd == 'title':
|
||||
ans.set_next_title(rest)
|
||||
else:
|
||||
raise ValueError('Unknown command in session file: {}'.format(cmd))
|
||||
for t in ans.tabs:
|
||||
|
Loading…
Reference in New Issue
Block a user