4

In Ubuntu, I use the default gnome-terminal to run my commands. I typically have a couple of windows open, each with several tabs. When my OS crashes∗, for whatever reason, and I reboot, I lose all these terminals.

Sublime Text, Firefox and Chrome have spoilt me, as all of them give me the option to restore all the windows and tabs to exactly what they were doing prior to the crash, and I would like to be able to do the same with my terminal windows and tabs.

How can this be accomplished?

Spelling out the specifics of what I would like:

  • Must have:
    • Upon reboot, when I open terminal for the first time, the windows and tabs that were there before get re-opened
      • Either with or without a prompt is fine
    • Each tab is cd-ed into the folder that it was in before
  • Nice to have:
    • The bash_history for that tab is still there
    • so when I press the "up" and "down" keys, I would get what I expect within that tab

∗ Ubuntu running on a laptop whose drivers are not the most friendly, happens more often than I would like (in case you are wondering)

bguiz
  • 2,141

2 Answers2

1

The closest they could get was.

You can use the following options:

--save-config=FILE              Save the terminal configuration to a file
--load-config=FILE              Load a terminal configuration file

Example:

To save:

gnome-terminal --save-config=/tmp/cfgtab

To load it back:

gnome-terminal --load-config=/tmp/cfgtab

enter image description here

stderr
  • 10,569
  • 2
  • 36
  • 50
1

Here is the solution that I came up with:

https://gist.github.com/bguiz/9262902

It is a shell script that automates the above.

For normal use:

~/watcher.sh

After a crash and reboot:

~/watcher.sh restore
bguiz
  • 2,141