Save and restore session of the Gnome Terminal

INFO: Unfortunately „–save-config” option is no longer supported in the new versions of gnome-terminal so this script will not work.

I use terminal quite often in my work. I have a specific way how I work with terminal. I usually have about 10 tabs open in different directories so I can quickly switch between them. I felt quite frustrated when I was in the middle of something, but I had to reboot the PC for some reason. It is because it means I would need to set-up my perfect multi-tab terminal from scratch.
Fortunately I found very easy solution for this issue. This article describes easy way to save and restore the terminal session.

It is a basic solution. It allows you to restore all the tabs from the Gnome Terminal in the working directories, but it will not restore the content of the terminals.

Quick how-to:


  • Download and extract save-terminal and load-terminal files.
  • Save both files in ~/bin directory.
  • Create .terminal-session directory in your home directory.
  • Add ~/bin to $PATH:
    • add following line to your ~/.bashrc file
    • execute source ~/.bashrc


Every time you want to save a session execute (in any tab):

It will create a new file in the .terminal-session directory containing information about all currently opened Gnome Terminal tabs.

When you want to restore all tabs from the last saved session execute:

It will load the Gnome Terminal session from the latest file from .terminal-session directory.


Both save-terminal and load-terminal scripts use gnome-terminal commands with --save-config=PATH and --load-config=PATH parameters.
gnome-terminal command should be available on any GNU Linux distribution with Gnome packages installed.

Main responsibility of the save-terminal and load-terminal scripts is to properly save the file and then choose the latest file to load the terminal session from it. These scripts are extremely simple.


This code will create new file in the ~/.terminal-sessions directory with the current time as a file name.


This code will find the newest file from the ~/.terminal-sessions directory and use it to load Gnome Terminal session using gnome-terminal.

Complete source code can be found in GitHub repository.

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *