.. highlight:: sh
.. code-block:: sh

  save_as_session [options] [path-to-save-session-file-at]

Save the current state of kitty as a session file for easy re-use. If the path at which to save the session
file is not specified, kitty will prompt you for one. If the path is :code:`.` it will save the session
to the path of the currently active session, if there is one, otherwise prompt you for a path.


Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. option:: --save-only [=no]

    Only save the specified session file, dont open it in an editor to review after saving.

.. option:: --use-foreground-process [=no]

    When saving windows that were started with the default shell but are currently running some other process inside that shell, save that process so that when the session is used both the shell **and** the process running inside it are re-started. This is most useful when you have opened programs like editors or similar inside windows that started out running the shell and you want to preserve that. WARNING: Be careful when using this option, if you are running some dangerous command like :file:`rm` or :file:`mv` or similar in a shell, it will be re-run when the session is executed if you use this option. Note that this option requires :ref:`shell_integration` to work.

.. option:: --relocatable [=no]

    When saving the working directory for windows, do so as paths relative to the directory in which the session file will be saved. This allows the session file to work even when its containing directory is moved elsewhere.

.. option:: --match <MATCH>

    If specified, only save all windows (and their parent tabs/OS Windows) that match the specified search expression. See :ref:`search_syntax` for details on the search language. In particular if you want to only save windows that are present in the currently active session, use :code:`--match=session:.`.
