Shortcut Keys – Terminal Shortcut Ctrl + Alt + T Opens Different Sized Terminals

command linegnome-terminalresizeshortcut-keys

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.

Best Answer

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 bin directory /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 .sh.
So I now assume you have a script file /home/MYUSERNAME/bin/open-two-terminals.sh.

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!