In Ubuntu, you can change the default size of the terminal using (edit>profile preferences) to change the size. How can you use the shortcut for bringing up terminal ctrl+alt+T to create two terminals of different sizes so that they are placed one above each other on the right hand side of the screen? So that one has a smaller height than the other but of equal width.
I will provide you a detailed and tested guide on how you can achieve your desired result.
First a short summary of the steps:
- Write a short bash script that opens two terminal windows with specified sizes and positions.
- Set the "executable"-flag of the script file
- Test the script (to avoid typos and make sure everything works)
- Disable/Change the old terminal shortcut to free the accelerator keys Ctrl+Alt+T
- Set the new custom shortcut
Now follows the detailed guide:
As you can only launch a single command with a keyboard shortcut (as far as I know), we have to write a short bash script that opens the two windows. We can also hand a special parameter over to the gnome-terminal that sets the windows' size (in characters, not pixels) and position (in pixels on the screen). It should look like the following:
#!/bin/bash # File: open-two-terminals.sh # Purpose: launch two windows of gnome-terminal with different # sizes (in characters) and positions (in pixels) gnome-terminal --geometry=80x30+400+400 & gnome-terminal --geometry=60x20+500+50 & # geometry-syntax: --geometry=[width]x[height]+[x-position]+[y-position] # Info: & continues with the next command right after the execution # of the command it is written after, instead of waiting until # the program finished and returns.
Note that you can/must experiment a bit with the geometry values to size and position the windows in exactly the way you want them. I only used example values.
Save these lines (you only need the 1st and those without
#, as the others are only comments) into a file like
open-two-terminals.sh in whatever location you want. I would suggest your home
/home/MYUSERNAME/bin (create this directory if it does not exist), but you can change this to what you want (as long as it's somewhere in the
PATH) as well as the file name, it should only end with
So I now assume you have a script file
The next step is to make the script executable, as by now it is nothing more than a plain text file nice to look at. To do this, run the following command in a terminal:
chmod +x /home/MYUSERNAME/bin/open-two-terminals.sh
Now after the executable flag is set, you can do a first test whether you did everything right until now. Run the script by entering
open-two-terminals.sh in a terminal window or into the Alt+F2-HUD. It should open two new terminal windows with the different profiles and sizes.
If this works (else you made a mistake and should double-check and try all steps again), you can set the keyboard shortcut.
Go to your System settings panel and click on Keyboard. Change to the Shortcuts tab and select Launchers in the list on the left. You see the shortcut for Launch terminal in the list on the right.
First you have to either disable this shortcut (enter Backspace as new shortcut) or assign (a) different key(s) than Ctrl+Alt+T, as you want to use them later for your custom shortcut.
After that, select Custom shortcuts in the list on the left. Add a new shortcut by clicking on the + symbol below the right list. A window will pop up and request a name for the shortcut (anything you want, e.g.
Open Two Terminals) and the command to run (enter the script file created before, e.g.
open-two-terminals.sh). Confirm with a click on OK.
Now the last thing we still have to do is to assign the old terminal keys Ctrl+Alt+T to this new shortcut. Therefore click on the right column containing the accelerator keys (default value is Disabled - important, because a click on the left column containing the title opens the popup window) and then press/hold the keys you want to assign to the shortcut. You should see them written on the left of the shortcut's title now.
Close the control panel and enjoy your new double-terminal shortcut! :-D
Hope this detailed guide did help you and solve your question. If this is the case, please accept the answer with a quick click on the gray tick at the left side of it, to show your appreciation. Should you or anyone else reading this have a problem, need further clarification or find an error, please leave me a comment!
sudo apt-get install wmctrl
touch bin/twoterm.sh && sudo chmod +x bin/twoterm.sh
- Copy the script bellow and save it into
- Create custom shortcut Ctrl+Alt+R , which will call command `gnome-terminal -e /home/yourusername/bin/twoterm.sh
#!/bin/bash # Author: Serg Kolo # Date: 2/18/2015 # Description: A simple script to create two windows on right side # of the screen with specific size. sleep 1 gnome-terminal -t WINDOW-ONE gnome-terminal -t WINDOW-TWO if [ $? == 0 ] then wmctrl -r WINDOW-ONE -e 0,1300,300,250,250 sleep 0.5 wmctrl -r WINDOW-TWO -e 0,1300,0,250,250 fi
wmctrlis a program that helps interacting with window managers and open windows. more info in
man wmctrl, this and this askubuntu posts
gnome-terminal -t WINDOM-TITLEcalls for a gnome-terminal window with specific title. No need for creating different profiles, although you may if you decide so. Refer to ByteCommander's answer for that
wmctrl -r WINDOW-NAME -e g,x,y,w,h, tells a window with specific title WINDOW-NAME to have exact parameters gravity,x-position on screen, y-position on screen, window width, window height.
Apparently hud executes everything one by one , but gnome-terminal can execute parts of the script much faster, which is why in the short cut i call for
gnome-terminal -e '/home/username/bin/twoterm.sh'; This way there is one gnome-terminal window created for split second which allows two execute the script properly.
The reason for if statement is that the script for some reason fails to execute sequentially
- The reason for
sleepstatement is to allow the second window catch up with the first one. Apparently the script cannot call two instances of
wmctrlat the same time
- The shortcut+script can be executed only once. If you call the script more than once, you will end up with multiple windows, but the
wmctrlcommand will organize only the original two windows that you called first time
Per ByteCommander's suggestion, I've edited the script to be executed purely by the
/bin/sh and removed if statement.
#!/bin/bash # Author: Serg Kolo # Date: 2/18/2015 # Description: A simple script to create two windows on right side # of the screen with specific size. gnome-terminal -t WINDOW-ONE & gnome-terminal -t WINDOW-TWO & sleep 1 wmctrl -r WINDOW-ONE -e 0,1300,300,250,250 & wmctrl -r WINDOW-TWO -e 0,1300,0,250,250 &