question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support saving and restoring of terminal state

See original GitHub issue

Hi everyone,

With xterm.js maturing, I think a great feature to expand the range of applications xterm.js could be useful for would be the formalization of a headless mode. What do I mean? Well basically, for the ability to:

  1. Run a client without a renderer.
  2. Communicate to a client with a renderer the state of a headless client and vice versa.

Right now, the only way to reliably “set” the state of a client is to replay the set of all commands that produced that editor’s state (at least via the public API). However, you could easily imagine wanting to do things like:

  • scrubbing back and forth through a terminal’s history
  • running a terminal in the cloud that you intermittently connect to via the client
  • (my use case) having multiple users have literally the same terminal with the ability to come and go

A lot of this is basically almost already possible if you just serialize term.rows and assorted state flags, but the adoption of a formal API would help a lot. It may also help improve the testability and robustness of the core library, too!

Thoughts? Vincent

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
ebertmicommented, Apr 5, 2018

Any updates on this one? I am also having a similar use case.

3reactions
Tyriarcommented, Mar 17, 2017

Some more things we probably want to serialize:

  • All the options
  • The alt buffer

@parisk I was thinking a getState or serialize function would perform the serialization at that point, we could put everything into some json object and return the json pretty easily. All the state you’re mentioning may not be owned by the Terminal object, for example the buffer lives in CircularList. It would make more sense to tell the CircularList to serialize itself on a call to the function. Something like this:

Terminal.prototype.getState() {
  const state = {};
  // this.serializableComponents is an ISerializable[] which ensures they
  // have componentKey/getState()
  this.serializableComponents.forEach(c => {
    state[c.componentKey] = c.getState();
  });
  // TODO: Add anything owned by Terminal to state
  // ...
  return state;
}

// Restore using something like this which would do the reverse
Terminal.prototype.restoreState(state: Object): void;

// A static method that returns a Terminal might be better:
Terminal.restoreTerminal(state: Object): Terminal;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Some fast way to save and restore tabs of Terminal?
I would like to save the current configuration and have it restored with names and directories. Is there a way to do this?...
Read more >
Save and restore terminal content - linux - Stack Overflow
I want to be able to restore terminal command history when my program exists. Many terminal programs (e.g. less , man , vim...
Read more >
Save and restore terminal on reboot - linux - Super User
I would like to at least save the current working directories and name each tab works with so I can be more efficient....
Read more >
Save and Restore a Linux Process | Baeldung on Linux
In this tutorial, we'll look at how we can save and restore a process that we can use across multiple reboots. While most...
Read more >
How to restore manually Saved State files of Terminal?
Kill the terminal explicitly, e.g.: killall Terminal . Run again, it should have the previous message/state. Removing files and restoring from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found