Save multiple gnome-terminal layout?

24

6

I have multiple gnome-terminal windows open. Is there a way to save the settings (window position, no. of tabs, title etc). across OS reboots ?

Abhinav

Posted 2009-11-18T13:51:10.217

Reputation: 2 030

Answers

16

I found the following options which are helpful :

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

The above does restore the appropriate number of gnome-terminal windows with proper tabs, but the window position and title are not restored. Still, a start :)

Abhinav

Posted 2009-11-18T13:51:10.217

Reputation: 2 030

@srking progress! – drs – 2014-07-01T16:10:44.540

Window positions and size were saved when I just tried these commands with gnome-terminal 3.6.1--Linux Mint 15 with Cinnamon in this case--which makes this a good bit more useful. (Thanks!) – David Duncan – 2013-09-13T03:52:31.797

5The --save-config option was removed as "obsolete" from gnome-terminal as of (at least) 3.10.2. – srking – 2014-05-20T18:26:37.540

10

Once you have your gnome-terminal configured the way you like (i.e. number of tabs, open to certain directories), save the session state from within your gnome-terminal window with the following command:

gnome-terminal --save-config=mytabs

Then what I do is create a custom application launcher on my panel that executes the following command

gnome-terminal --load-config=/home/leif/mytabs

leif81

Posted 2009-11-18T13:51:10.217

Reputation: 367

This kind of works, but it doesn't save the output from previous commands, so I can't scroll up and view what I did. – samthebest – 2014-01-29T10:22:06.227

@samthebest Ya, it only saves and restores the current working dir of each tab, not the scroll history. – leif81 – 2014-01-29T14:41:23.507

2

You can create profiles for Gnome-Terminal from the Edit Profiles dialog under the Edit menu. To start Gnome-Terminal with a certain profile, you'd do this:

gnome-terminal --window-with-profile=<profile_name>

Naturally, you can configure different launcher icons to automatically launch different profiles, or you could include lines in an X-session startup script to start several different terminals, each with a different profile, when you login. Various options can be combined in a launcher icon to give you one specific terminal type, and you could create as many launchers as you need different terminal types.

Other commandline options might be useful to get exactly the effect you want, if the profile mechanism isn't fine-grained enough for you. See man gnome-terminal on your system for full details, but here are some suggestions from this Ubuntu forum discussion:

# define a terminal 100 columns by 20 lines
--geometry=100x20

# set the titlebar
--title=irssi

# run a particular program
--execute irssi

quack quixote

Posted 2009-11-18T13:51:10.217

Reputation: 37 382

1This is close, but wondering if what I want can be achieved more easily. I already have profiles, and open windows. Is there some session state for each gnome-terminal, which I can save and then "load/run" at any time so that whatever I saved takes effect ? – Abhinav – 2009-11-18T15:06:10.630

Probably something in .gconf ? – Abhinav – 2009-11-18T15:06:41.377

i'm afraid that's the extent of my knowledge; i haven't been a Gnome user for a couple of years now. – quack quixote – 2009-11-18T15:24:42.933

0

gnome-terminal --save-config and --load-config are good options though to make it full proof i have used the following script the script is slow but works for me. 1. save-terminals.sh

FILE=$1
gnome-terminal --save-config=$FILE

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

2. load-terminals.sh

FILE=$1
LINES=$(grep '\[Terminal' $FILE | wc -l)
TITLE=($(grep -n '\Title' $FILE | cut -d= -f2))
gnome-terminal --load-config=$FILE
for ((i=0; i<$LINES; i++))
do
    xdotool key Ctrl+Right
    xdotool key "Return"
    sleep 1
    xdotool key Alt+t
    sleep 1
    xdotool key s
    sleep 1
    xdotool type ${TITLE[$i]}
    xdotool key "Return"
    xdotool key "Return"
    sleep 1
done
xdotool key Alt+Tab
xdotool key Shift+Ctrl+Q
xdotool key "Return"

the sleeps are intended cause if it moves fast it will loose the track. Also you need xdotool installed. Create the alias in the .bashrc as

alias st='save-terminals.sh ~/.terminal.cfg'
alias lt='load-terminals.sh ~/.terminal.cfg'

Hope that helps

Manish

Posted 2009-11-18T13:51:10.217

Reputation: 1

0

I use a two-step approach with my xfce-terminal. First I open the windows:

xfce4-terminal --hide-menubar --hide-borders --hide-toolbars -e htop -T hTop

and then move them with wmctrl:

wmctrl -r 'hTop' -t 3
wmctrl -r 'hTop' -e 0,927,33,1000,550

Martin

Posted 2009-11-18T13:51:10.217

Reputation: 24

0

Window position:

gnome-terminal --geometry=115x30+0+670

EduSilva

Posted 2009-11-18T13:51:10.217

Reputation: