Best way to save data #634
-
Is there any better way to save terminal content automatically on new data? pty.onData((data) => {
session[pid].terminalData += data;
ws.send(data);
}); But as expected it doesn't works because pty sends terminal sequence |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This is more of a general JS question, you could append it to a string like that but it's not very efficient. Alternatively you could append lines to a string array which is a little better, or persist to a file, etc. |
Beta Was this translation helpful? Give feedback.
-
Thanks 👍 |
Beta Was this translation helpful? Give feedback.
You can feed it into xterm.js (or xterm-headless on node) and then use the serialize addon. I think that would give you what you're after.
This is how terminal restoration works in vscode when reopening windows.