From fb19c047981ae86b93bdb64787507e8dc4b0b13f Mon Sep 17 00:00:00 2001 From: BlackAngelTV Date: Wed, 11 Nov 2026 21:03:29 +0100 Subject: [PATCH] docs(session): document restoring the last session Explain where the state is kept, that restoring is explicit and what happens to a stale or corrupt state file, so that users know the feature exists and how to get rid of the saved state. --- docs/changelog.rst | 7 +++++++ docs/sessions.rst | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5c1ba8c..0f54c83 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -222,6 +222,13 @@ Detailed list of changes 0.50.1 [unreleased] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- kitty now remembers the state of the session that was in use when it exited, + in :file:`$XDG_STATE_HOME/kitty/last-session.json`, so that + :code:`kitty --session=last` brings back the tabs, layouts, working + directories and titles of the previous run. Restoring is explicit, never + automatic, and a corrupt or oversized saved state is discarded instead of + blocking startup. See :ref:`sessions` for details. + - :kbd:`Ctrl+Shift+E` now opens the :doc:`file manager kitten ` in a left dock by default, instead of requiring a manual mapping. This takes the key over from :ac:`open_url`; remap diff --git a/docs/sessions.rst b/docs/sessions.rst index 07f1d64..5c997f4 100644 --- a/docs/sessions.rst +++ b/docs/sessions.rst @@ -34,6 +34,26 @@ you want to work on the project, simply run: You can also set the session in :file:`kitty.conf` via :opt:`startup_session`. +Restoring the last session +---------------------------- + +kitty saves the state of its tabs, windows, layouts, working directories and +titles when it exits, in :file:`$XDG_STATE_HOME/kitty/last-session.json` +(usually :file:`~/.local/state/kitty/last-session.json`). The saved state is +limited to 1 MiB and is overwritten at every exit, so it never accumulates. + +To restore it, start kitty with: + +.. code-block:: sh + + kitty --session=last + +Restoring is never automatic: without this option the saved state is ignored, +so an unexpected state is never imposed on you. A state file that is corrupt, +unreadable or too large is discarded and kitty starts normally. :code:`cd` +directives whose directory no longer exists are dropped when restoring. Use +:ac:`save_as_session` for sessions that must survive beyond the next exit. + Thus, it is very easy to create sessions and work on projects. To learn how to create more complex sessions, see :ref:`complex_sessions`.