Skip to content

[RFC] Saving and jumping between kitty sessions #8911

Description

@kovidgoyal

Hi all,

I have just implemented support for saving sessions and switching between them with a shortcut in master. As this is not functionality I use myself, I would like some feedback on its design and testing if it works well.

To try it out install a nightly build or build kitty from source. Then, start kitty as:

kitty -o 'map f1 save_as_session --use-foreground-process --relocatable'

Now setup kitty as you like with splits, tabs, layouts, whatever programs you want running, etc. and when you are done, press the F1 key to save kitty's state into a session file. You will be prompted for a path to save the session file and after it is saved it will open in your editor for you to review.

Once you are happy with it, you can use it in kitty by simply running:

kitty --session /path/to/session/file

and kitty should open with all your splits/tabs etc. pre setup. If instead you want to switch between multiple sessions in a single kitty process, add the following lines to kitty.conf:

# Press F7 and then c to jump to the "cool" project
map f7>c goto_session ~/path/to/cool/cool.kitty-session
# Press F7 and then h to jump to the "hot" project
map f7>h goto_session ~/path/to/hot/hot.kitty-session
# Browse and select from the list of known projects defined via goto_session commands
map f7>/ goto_session

Change the keystrokes and the paths to the session files as appropriate.

Now in kitty you can press the key and focus will switch to the last active window/tab in the corresponding session. If the session is not yet loaded, kitty will automatically load it for you.

Adding windows to the current session can be done with:

map kitty_mod+enter launch --add-to-session=. 

and updating the current session's session file to match the current set of windows in the session can be done with:

map f5 save_as_session --relocatable --use-foreground-process --match=session:. .

Full documentation and a specification for all the keywords and syntax for session files is in session.rst in case you prefer to write session files by hand rather than saving them.
Enjoy and thanks for testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions