I have a Terminal window with a dozen named tabs open.

I would like to save the current configuration and have it restored with names and directories.

Is there a way to do this?


13 Answers 13


To save configuration into /tmp/cfg:

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

To load it back:

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


After playing around with bash I created following script which stores tab names into file /tmp/test as well:

#!/usr/bin/env bash

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

LINES=($(grep -n '\[Terminal' /tmp/test | cut -d: -f1))
for ((i=0; i<$(grep '\[Terminal' /tmp/test | wc -l); i++))
    TITLE=$(xprop -id $WINDOWID WM_NAME | sed -e 's/WM_NAME(STRING) = "//' -e 's/"$//';xdotool key ctrl+Page_Down;)
    sed -ri "$((${LINES[$i]}+$i))s/.*/&\nTitle=$TITLE/" /tmp/test 

To assign names properly you have to run it from first tab of your terminal. Loading same as before:

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


I can use following to get tab name:


I can use following to jump to next tab:

xdotool key ctrl+Page_Down;

I'm getting number of tabs after grepping configuration file I saved before:

$(grep '\[Terminal' /tmp/test | wc -l)

So I can iterate over tabs inside a loop. I have to add "Title=titlename" entry for each tab configuration section in file saved before. To do so, first I'm creating an array of line numbers where I'll be adding lines.

LINES=($(grep -n '\[Terminal' /tmp/test | cut -d: -f1))

I'm adding "Title=titlename" line inside of loop iterating over tabs:

sed -ri "$((${LINES[$i]}+$i))s/.*/&\nTitle=$TITLE/" /tmp/test 
  • 1
    You may want to look into the screen command. I don't use it, but I believe it can save and restore all sorts of sessions - even remote ones.
    – Joe
    Commented Jun 27, 2013 at 2:01
  • By the way, I first had to run sudo apt-get install xdotool. Commented Sep 24, 2013 at 8:24
  • @NicolasRaoul,it might be this bug: bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/876901 Can you change your title with command PROMPT_COMMAND='echo -ne "\033]0;Test\007"'?
    – Nykakin
    Commented Sep 24, 2013 at 13:45
  • 22
    gnome 3.18: Option "--save-config" is no longer supported in this version of gnome-terminal.
    – Marius
    Commented Nov 14, 2015 at 21:19
  • 2
    if anyone else didn't know, /tmp is cleared on a reboot. So if you want to retain the terminal config after a reboot, save somewhere else.
    – Matthias
    Commented Aug 22, 2016 at 10:57

An alternative is to just use Byobu. Press F2 to open new terminals inside it. Use F3 and F4 to switch left and right between terminals.

Close the GUI window anytime you want. When you reopen Byobu all your terminals are restored :)

  • 4
    Does it work across reboots? For me, the it resets back after reboot.
    – akshay2000
    Commented Jun 10, 2015 at 8:53
  • 11
    It does not work across reboots
    – maxgalbu
    Commented Sep 15, 2015 at 8:54

I've also looked for that feature in Gnome terminal but couldn't find it. The best option I found so far is to use konsole. It allows you to bookmark your tabs, so that you can get back to them by choosing them from a bookmarks menu. I hope this helps.


I Tried one more option,

I changed my default title for Terminal to use the Intital value in ~/.bashrc, rather than changing the ~/.profile settings.

# If this is an xterm set the title to user@host:dir
case "$TERM" in

If You do this, there is no need to change your Terminal Profile.
When you execute gnome-terminal --load-config all the tab names are restored properly. And you can also change as you like it and save the tabs again!!


I found a way to do it that I think is faster.

  1. Creates a profile with the title and the name you want like Yoga said.
  2. Type:

    gnome-terminal --tab-with-profile=PROFILENAME1 --tab-with-profile=PROFILENAME2 ... --tab-with-profile=PROFILENAME999

I made an alias with this command and it worked pretty fine for me. I just type workflow and a Terminal appears with 3 tabs and the titles that I chose in the profile definition that are placed into the tabs.

On my .bashrc file I placed:

alias workflow='gnome-terminal --tab-with-profile=Git --tab-with-profile=Run | sublime-text &'
  • How does it save and restore paths? Commented Jan 23, 2020 at 15:45

I tried the below options after restoring the saved settings and the Title is also restored properly.

  1. Go Settings->Profiles and select on the Current Profile you are using
  2. Click on Edit and Go to "Title and command" Tab
  3. Make Initial Title Blank
  4. Select "Keep Initial Title" Option in the drop down box below.

This option avoid your initial title set to be overwritten.

Hope This helps and a great script indeed. Save a lot of time whenever u reboot and I can happily reboot my virtual box frequently.




Restore tmux environment after system restart.

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.

It even (optionally) restores vim and neovim sessions!


Screen or Byobu are my preferred methods of managing complex workflow in the terminal, and both allow saving your configurations.


Hyper (https://github.com/zeit/hyper) is a good cross platform alternative written in JavaScript and bundled with Electron.

There's a PR that is going to add support for session save/restore out of the box: https://github.com/zeit/hyper/pull/945


Here is an xfce terminal fork, with possibility to save/restore session just from menu: https://github.com/repu1sion/xfce4-terminal


A little improvement to the existed script which also checks xdotool installed on system and adds variable for changing path



if [ ! -f /usr/bin/xdotool ]; then
        echo "please install 'xdotool'"
        exit 1

gnome-terminal --save-config=$SAVEPATH

LINES=($(grep -n '\[Terminal' $SAVEPATH | cut -d: -f1))
for ((i=0; i<$(grep '\[Terminal' $SAVEPATH | wc -l); i++))
    TITLE=$(xprop -id $WINDOWID WM_NAME | sed -e 's/WM_NAME(STRING) = "//' -e 's/"$//';xdotool key ctrl+Page_Down;)
    sed -ri "$((${LINES[$i]}+$i))s/.*/&\nTitle=$TITLE/" $SAVEPATH

Expanding on Nyakin's answer above, this script will work for multiple window and tab configurations and correctly save tab titles for all tabs that have them.

This is currently tested on gnome-terminal 3.2 but could be configured for any terminal program with a similar save-config functionality.

This requires the 'xprop', 'xdotool', and 'wmctrl' tools.


#!/usr/bin/env bash

gnome-terminal --save-config=$FILE

WINDOWLINES=$(wmctrl -lx | grep gnome-terminal.Gnome-terminal)
WINDOWNUM=$(echo "$WINDOWLINES" | wc -l)
TABLISTS=$(grep "^Terminals" $FILE)

for ((i=1; i<=$WINDOWNUM; i++))
    WINDOWLINE=$(echo "$WINDOWLINES" | sed -n "$i{p;q}")
    WINDOW_ID=$(echo "$WINDOWLINE" | cut -d' ' -f1)
    #Switch to window
    wmctrl -i -a $WINDOW_ID

    LINE=$(echo "$TABLISTS" | sed -n "$i{p;q}"); LINE=${LINE#Terminals=}
    TERMINALNUM=$(echo "$LINE" | grep -o ';' | wc -l)
    #go to first tab of the window if more than 1
    [ $TERMINALNUM -gt 1 ] && xdotool key alt+1 && sleep .1

    for tab in ${LINE//;/ }
        #Get the current tab title
        TITLE=$(xprop -id $WINDOW_ID WM_NAME | sed -e 's/WM_NAME(STRING) = "//' -e 's/"$//')
        #Insert it into the config file
        [ "$TITLE" == "${TITLE//WM_NAME/}" ] && sed -ri "/\[${tab}\]/aTitle=${TITLE}" $FILE
        #Move to the next tab in the window
        xdotool key ctrl+Page_Down

Similar to Yoga's method, Edit >> Profile Preferences >> Title and Command >>Title >> When terminal commands set their own titles: >> Prepend initial title

Then execute:

gnome-terminals --save-config=terminals-cfg

Close terminal windows

Open a new terminal, and in it execute:

gnome-terminals --load-config=terminals-cfg

Works good for me, all titles kept.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .