mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-15 04:54:14 +02:00
remove --focus-tab and add docs
This commit is contained in:
@@ -631,12 +631,10 @@ use :code:`--match=session:.`.
|
||||
|
||||
--base-dir
|
||||
When specified, relative session filenames will be saved to this directory instead of the current
|
||||
working directory. Absolute paths are not affected by this option.
|
||||
|
||||
|
||||
--focus-tab
|
||||
type=bool-set
|
||||
When enabled, add a focus_tab command to the saved session file to preserve the currently active tab.
|
||||
working directory. This is useful when kitty is launched from locations where the working directory
|
||||
is not your home directory, such as from system-wide shortcuts. Note that :code:`--relocatable` is
|
||||
typically not used with :code:`--base-dir`, since relocatable is meant for session files that are
|
||||
co-located with their project directories.
|
||||
'''
|
||||
|
||||
|
||||
@@ -649,7 +647,10 @@ def save_as_session_part2(boss: BossType, opts: SaveAsSessionOptions, path: str)
|
||||
base_dir = os.path.abspath(os.path.expanduser(opts.base_dir))
|
||||
path = os.path.join(base_dir, path)
|
||||
path = os.path.abspath(os.path.expanduser(path))
|
||||
session = '\n'.join(boss.serialize_state_as_session(path, opts))
|
||||
# When --base-dir is specified, use it as the session_path for relocatable calculation
|
||||
# This makes relative paths relative to base_dir instead of the session file location
|
||||
session_path_for_serialize = os.path.join(opts.base_dir, 'dummy') if opts.base_dir else path
|
||||
session = '\n'.join(boss.serialize_state_as_session(session_path_for_serialize, opts))
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
atomic_save(session.encode(), path)
|
||||
if not opts.save_only:
|
||||
|
||||
@@ -1317,10 +1317,7 @@ class TabManager: # {{{
|
||||
hmap[at.id] = len(self.active_tab_history) + 1
|
||||
def skey(tab: Tab) -> int:
|
||||
return hmap.get(tab.id, -1)
|
||||
active_tab_index = -1
|
||||
for i, tab in enumerate(sorted(self, key=skey)):
|
||||
if tab is self.active_tab:
|
||||
active_tab_index = i
|
||||
for tab in sorted(self, key=skey):
|
||||
ans.extend(tab.serialize_state_as_session(session_path, matched_windows, ser_opts))
|
||||
if ans:
|
||||
prefix = [] if is_first else ['', '', 'new_os_window']
|
||||
@@ -1329,10 +1326,6 @@ class TabManager: # {{{
|
||||
if self.wm_name and self.wm_name != appname:
|
||||
prefix.append(f'os_window_name {self.wm_name}')
|
||||
ans = prefix + ans
|
||||
# Add focus_tab command if --focus-tab option is enabled
|
||||
if ser_opts.focus_tab and active_tab_index >= 0:
|
||||
ans.append('')
|
||||
ans.append(f'focus_tab {active_tab_index}')
|
||||
return ans
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user