kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.05k stars 971 forks source link

Feature request: Persist scrollback buffer #2454

Closed alephnull closed 4 years ago

alephnull commented 4 years ago

It is a shame to lose the buffer because a quick restart was needed.

If it is possible via a kitten, please do help me get started.

kovidgoyal commented 4 years ago

I'm afraid I dont have the time to help you write a kitten. But basically you would write a UI less kitten that uses the as_text() method of the window object to get the text and save it to a file.

And when called in the restarted kitty, read the file and use window.paste_bytes()

See https://sw.kovidgoyal.net/kitty/kittens/custom.html

jason0x43 commented 3 years ago

I'm interested in writing a kitten for saving and restoring the scrollback buffer. I figured out how to save a window's buffer to a file, but not how to load the contents into a new window. I'm assuming I'd want to paste the bytes into the buffer before loading the shell, but I'm not sure how to do that in a kitten. Any pointers?

kovidgoyal commented 3 years ago

assuming you are saving it as ANSI text simply call window.write_to_child(test). If you want to do it before the child process runs, then use launch with --stdin-source

jason0x43 commented 3 years ago

Apparently I was making that harder than I needed to. Calling launch with a simple script that cats the saved state before execing the new shell seems to work.

#!/bin/zsh
cat $HOME/scrollback.txt
exec zsh