Save and restore terminal on reboot

15,932

Solution 1

The following method does not save the directories upon exit. It uses always the same directories until you change them in "Preferences", although you may have multiple indipendent groups of directories.

We will install "terminator".

These are the step-by-step instructions for three tabs. The steps are the same for any number of tabs.


sudo apt-get install terminator

Alternatively, you can install it with aptitude, or ubuntu software center.

  • Run terminator, f.e. from the "KDE" menu.
  • Right-click on the black screen.
  • Click "Open tab".
  • Then again, right-click on the black screen.
  • Click "Open tab".
  • Then again, right-click on the black screen.
  • Click "Preferences"
  • Click on the "Layouts" tab.
  • Click "Add".
  • Write a name and press ENTER. I will use the name "mylayout" in this procedure. Do NOT click "Save".

You can see on the right pane the words: "Window", "Notebook", "Terminal", "Terminal", "Terminal".


  • Click on the LOWEST of the words "Terminal".
  • Click inside the blank field to the right of "Working directory:".
  • Write the path of the directory which you want to be the first tab; f.e. /a/dir1.
  • Click on the word "Terminal" just above the lowest one.
  • Click inside the blank field to the right of "Working directory:".
  • Write the path of the directory which you want to be the second tab.
  • Click on the HIGHEST of the words "Terminal".
  • Click inside the blank field to the right of "Working directory:".
  • Write the path of the directory which you want to be the third tab.
  • Click "Close".
  • Click the "X" in the upper right corner to close terminator.

  • Right click on an empty space of the desktop.
  • Click "Create new".
  • Click "Link to application".
  • Click the tab "Application".
  • Click inside the blank field to the right of "Command:".
  • Write:

    terminator --layout=mylayout
    
  • Click "OK".


Now click on the new icon. You should see all your tabs.

You can create multiple layouts in the same way, and you can modify the directories and other settings by right-clicking on the black screen and clicking "Preferences".

Solution 2

As suggested by Bram, you can use a Terminal multiplexer (such as screen) to accomplish this.

Paraphrased from Wikipedia, terminal multiplexers allow:

  • Users to connect and disconnect from terminal sessions.
  • Have multiple terminal sessions in one window (similar to the tabs you suggested, or splitting a vim window).
  • Multiple users to access the same session.

If you used a terminal multiplexer such as tmux, there is a superuser thread asking how to save sessions over reboot. You could use install this suggested plugin called tmux-ressurect, and then your sessions, windows, panes, etc will be saved.

The default tmux prefix key is Ctrl+b, so in tmux once tmux-ressurect is installed to:

  • save your session , you can press Ctrl+b + Crtl+s.
  • restore your tmux session, you can press Ctrl+b + Crtl+r.

Solution 3

I don't know if you can do so with a terminal directly. But you could try screen.

It will not survive a reboot but you can define the tabs etc. you need so you can open them quickly.

Solution 4

tmux-resurrect saves all the little details from your tmux environment so it can be completely restored after a system restart (or when you feel like it). No configuration is required. You should feel like you never quit tmux.

https://github.com/tmux-plugins/tmux-resurrect

Share:
15,932

Related videos on Youtube

davewoodhall
Author by

davewoodhall

Full-time web developer since 2011. Most of my work involves one or multiple from : HTML / CSS Vanilla JavaScript jQuery Node.JS PHP WordPress I wish to add to the list : AI C C++ React.JS Vue.JS and so much more !

Updated on September 18, 2022

Comments

  • davewoodhall
    davewoodhall almost 2 years

    Is there a way to save my terminal emulator windows and tabs for when I reboot the computer?

    I generally have about 10 or so open tabs at any given time and opening each tab to set up everything after a reboot is relatively long. I would like to at least save the current working directories and name each tab works with so I can be more efficient.

    If it helps, I am running Xubuntu 14.04.