Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS: kitty doesn't restore #1197

Open
toonn opened this issue Dec 2, 2018 · 16 comments
Open

Mac OS: kitty doesn't restore #1197

toonn opened this issue Dec 2, 2018 · 16 comments

Comments

@toonn
Copy link
Contributor

toonn commented Dec 2, 2018

Mac OS offers the option to resume all your open apps after a shutdown, Apple's version of hibernate, I guess. Terminal.app actually restores the ouput/history in the windows that were open when you shut the system down.

While that's nice, just restoring windows to the positions and sizes they had when shutting down would be plenty for me. Previous versions of kitty restored the positions, not the size. The current version (0.12.3) doesn't for me.

Note that I don't like the remember_window_size setting, I want new terminals to open at 80x24, it's just some long running terminals I'd like to restore to whatever size I made them.

On a similar note, I've been unable to change kitty windows's sizes using applescript, this was a nice QoL improvement with Terminal.app because the Mac OS window manager is so impotent.

@kovidgoyal
Copy link
Owner

kitty has no code to restore window positions, so I am surprised it would ever have happened. As I recall, cocoa has some special APIs for saving/restoring application state. These are not wrapped by glfw (the toolkit kitty uses) so they would need to be implement in kitty/cocoa_window.m instead. This is too much effort for me personally, but patches are welcome.

@toonn
Copy link
Contributor Author

toonn commented Dec 3, 2018

I assume this holds for applescript control as well?
How about simply opening at startup if it was open at shutdown? Does that also require implementation?

How hard/easy would it be to build kitty? Maybe I can git bisect to find where the behavior was lost?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Dec 3, 2018

No idea about aplescript control. Isn't applescript going to be retired by apple? opening at startup is the same thing as far as i know. see https://sw.kovidgoyal.net/kitty/build.html for how to build from source

@pencilcheck
Copy link

It would be very nice to have this feature. :)

@zoidyzoidzoid
Copy link

After looking into this a little, I think this is the necessary related documentation.

setFrameAutosaveName might also work to solve it too, apparently.

Here is the related StackOverflow where I found them. It took a while to figure out the right thing to search for.

@JunfengJia
Copy link

This is the only missing feature blocked me using kitty in Mac, after reboot the workspace will be gone.

@anicolao
Copy link

@kovidgoyal my preferred way for you to implement something like this, if you ever did, would be to have the opposite of ls so that the output of kitty @ ls can be re-used. I'd be pretty happy with something like:

kitty @ ls > savestate
kitty @ fromjson < savestate

In an ideal world, kitty ls would support --match and so it would also be trivial to save a subset of the window state.

A less good implementation could be some sort of kitty @ save-session feature that would dump a session file that approximated the current setup. I think that'll be worse by definition as session files don't have all the information that is already in ls and it's surely less work to add the right info into the ls JSON structure and rehydrate from there.

@lloeki
Copy link

lloeki commented Nov 12, 2020

While I'm not usually intentionally restoring, the restore feature comes in very handy when the OS crashes (which does happen...). Even if the windows aren't resized/placed correctly, at least having them all pop up again with the previous scrollback content is really, really useful.

I also wish there were a CMD+SHIFT+T "restore closed tab" feature for when I fat finger CMD+W.

Restoring working directories probably requires something like #3091.

@toonn
Copy link
Contributor Author

toonn commented Nov 12, 2020

To be clear, my original issue report is just about restoring window size and location.
You should probably open a new issue to talk about restoring terminal state like Terminal.app does.

@dflock
Copy link

dflock commented Feb 24, 2021

If anyone is interested, I wrote a script which converts the output of kitty @ ls into a kitty session file, so that you can do:

# Dump the current kitty session:
$ kitty @ ls > kitty-dump.json
# Convert this JSON file into a kitty session file:
$ cat kitty-dump.json | python3 ./kitty-convert-dump.py > kitty-session.kitty
# Start kitty from that session file:
$ kitty --session kitty-session.kitty

It's here if anyone wants to use it: https://github.com/dflock/kitty-save-session

@sharpenedblade
Copy link

While I'm not usually intentionally restoring, the restore feature comes in very handy when the OS crashes (which does happen...). Even if the windows aren't resized/placed correctly, at least having them all pop up again with the previous scrollback content is really, really useful.

I also wish there were a CMD+SHIFT+T "restore closed tab" feature for when I fat finger CMD+W.

This is essentially the same as opening a new tab, because when you close the tab, the shell in there is killed, the terminal could show the scroll back buffer, and reopen trhe shell in the old directory, but it is not the same. After a restart, I think there is no way to get back shell state, though scroll back can be dumped then restored. It would have to handle the case of running something like vim or less.

@ShivamJoker
Copy link

@kovidgoyal do we have any updates on this? I would have loved if kitty could restore directories at least automatically if someone quits and reopens it.

@mkylmamaa
Copy link

I'm having this issue when my Mac wakes up from sleep. Kitty has stopped rendering and displays a still image, however the application has not stopped responding to the OS. Killing and restarting Kitty shows that TMUX has been receiving the keystrokes and the state has updated accordingly, it was only the rendering that was frozen.

@lkhrs
Copy link

lkhrs commented Jul 8, 2022

For anyone that might tackle the window position restore issue, GLFW seems to have support for it on macOS with the window hint GLFW_COCOA_FRAME_NAME while running glfwCreateWindow. I tried to tackle it myself in glfw.c, but had no success.

This also might be a clue in glfw's source for cocoa_window.m

@jammi
Copy link

jammi commented Feb 21, 2023

Lack of restoration is the biggest issue I have had with Kitty so far. The standard Terminal.app behavior is to restore terminal locations and sizes, background color and other attributes set per window. Within each, it restores terminal history along with a marker telling the date when the history was restored ( [Restored 21. Feb 2023 at 15.47.28]), and tries to restore the CWD of the shell. The lack of this feature makes one postpone necessary computer restarts as well as delay updates of Kitty itself.
image

@noizo
Copy link

noizo commented Jun 6, 2024

I use https://github.com/kasper/phoenix/ to launch kitty app in quake like style with just a shortcut. It can remember window size and position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests