Skip to content

Commit 851ec96

Browse files
committed
save_as_session: when the filename input by the user has no extension, automatically add the .kitty-session extension
Fixes #9919
1 parent a5940b4 commit 851ec96

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ Detailed list of changes
258258

259259
- macOS: Fix args passed via ``open --args`` being ignored when :file:`macos-launch-services-cmdline` is present (:iss:`9910`)
260260

261+
- :ac:`save_as_session`: when the filename input by the user has no extension, automatically add the ``.kitty-session`` extension (:pull:`9919`)
262+
261263

262264
0.46.2 [2026-03-21]
263265
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

kitty/session.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,16 @@ def save_as_session_options() -> str:
691691
'''
692692

693693

694-
def save_as_session_part2(boss: BossType, opts: SaveAsSessionOptions, path: str) -> None:
694+
def save_as_session_part2(boss: BossType, opts: SaveAsSessionOptions, path: str, path_input_by_user: bool = False) -> None:
695695
if not path:
696696
return
697697
from .config import atomic_save
698698
if opts.base_dir and not os.path.isabs(path):
699699
base_dir = os.path.abspath(os.path.expanduser(opts.base_dir))
700700
path = os.path.join(base_dir, path)
701701
path = os.path.abspath(os.path.expanduser(path))
702+
if path_input_by_user and '.' not in os.path.basename(path):
703+
path += '.kitty-session'
702704
session = '\n'.join(boss.serialize_state_as_session(path, opts))
703705
os.makedirs(os.path.dirname(path), exist_ok=True)
704706
atomic_save(session.encode(), path)
@@ -732,4 +734,4 @@ def save_as_session(boss: BossType, cmdline: Sequence[str]) -> None:
732734
else:
733735
boss.get_save_filepath(_(
734736
'Enter the path at which to save the session, usually session files are given the .kitty-session file extension'),
735-
partial(save_as_session_part2, boss, opts))
737+
partial(save_as_session_part2, boss, opts, path_input_by_user=True))

0 commit comments

Comments
 (0)