7. Keybindings

This is where keyboard shortcuts for Multi Gnome Terminal functions and key definitions for various other purposes may be customized. It is accessed from the Settings menu. This selection will open a Window that displays the current settings. These may be customized to suit individual preferences by using the input fields at the top of the Window.

The Keybindings Window

7.1. Actions

At the top of the Window, there is a list of Multi Gnome Terminal Actions, with an initial entry of Shell->New Tab. Click here to see all available built-in "Actions" that can be customized. The input field to the right is labeled "String" and the last input field is labeled "Keybinding". The Keybinding field is where you enter your keyboard combination for a particular "Action" or usage.

To define a new shortcut, first select an item from the Action drop-down list with the mouse, then click on the Keybinding field, and then press the keyboard combination you want to use. Do NOT type the keystroke representations. Example: if you want SHIFT-F1, then press SHIFT-F1, and do not try to spell it. There is no limit on the number of keys that can be used for the key binding definition. This is your choice. The String field is not required for simple "Actions" such as these.

Example, shortcut to remove the current Tab:

Open the Action list at the top by clicking the button just to the right. Scroll down the list, and find Remove Term. Click on this, which closes the list. Now go all the way over to the Keybinding field, and click on the blank field to activate it. Now press whatever key combination you prefer. For example, press: CTRL-SHIFT-DELETE. This will be the new shortcut!

After setting the "Action" and the "Keybinding", click on Add, and then, of course, at the bottom of the Window, Apply to make your new addition permanent. Now try it!

7.2. Strings

The String input field gives even more flexibility for defining custom "Actions". It can be used with the special "Escape Sequence", "Command ->New Tab", and "Switch To" "Actions" (available from the drop-down list on the far left).

Use Escape Sequences to associate any string with a keystroke combination. This is helpful for forcing problem keys to do what you want, or to perform some custom function that you do repetitively.

As one example, select Escape Sequence from the list, and enter the following text to the String field:

  echo hello world\n

And then, click the Keybinding field, and press F7, then click the Add, and then Apply. Now press F7 to see the results. You should see:

 [bash]$ echo hello world
 hello world

A more useful example: Select Escape Sequence from the Action list and then enter:

  multi-gnome-terminal --add-tab --tpath=`pwd`\n

into the String field. Then whatever key combination you like for Keybinding (e.g. F9), then click Add, and lastly Apply. Now try it ;-) This should open a new Tab in the same Window and also land you in the same directory as your current directory.

You can also use any of Multi Gnome Terminal's raw escape sequences instead of the command syntax as above. The basic ones are:

 echo -e "\033]NT;<tab_name>\011<path>\011<command>\007"
 echo -e "\033]HS;<term_name>\011<path>\011<command>\007"
 echo -e "\033]VS;<term_name>\011<path>\011<command>\007"
 echo -e "\033]NW;<term_name>\011<path>\011<command>\007"
 echo -e "\033]WT;<term_name>\011<path>\011<command>\007"

In this order, these create: a "New Tab", a "Horizontal Split", "Vertical Split", a "New Window", and lastly a "New Window" with startup Tabs.

An interesting example:

  echo -e "\033]HS;$(hostname -s)\011 \011ssh $(hostname)\007"

This assumes you have an existing ssh connection to another host, and will open a second ssh connection to that same host in a split Tab.

Also, any custom "Commands" that have been created through Edit Commands, are automatically available for use as a Keybinding. To access these, open the Actions list in upper left hand corner, and select Command->New Tab (or any of the Command-> * functions), and then click the button to open the list next to the String input field. This list now will contain all of your custom defined "Commands". Now select one, and chose your shortcut key of choice, and then save as usual.

The "Switch To" Action can be used to define shortcuts for switching to specific Tabs. In the String field enter the ordinal number of the Tab to switch to, and then enter a shortcut key in the Keybinding field. So String would be "1" to switch the first (furthest to the left) Tab.

The String field will also recognize common meta-characters such as \n (as above) for newline, and also \r, \t, etc. \033 is used to represent the "escape" character. For instance, my keyboard generates ^[[1^ for CTRL-Home. This would be represented in the String field as \033[1^.

And, the String field will also recognize any octal ascii representation. Example: \141 octal equals the letter "a". This may be useful for non-printable characters. See man ascii for a complete listing of values.

7.3. Modifying Keybindings

Editing and removing key bindings, is similar, but first highlight the one to be changed from the main listbox, by clicking on it. Then either click Update to modify, or Remove to delete it. And again, click Apply at the bottom of the Window.

You can also easily re-set the default key bindings here. And also specify a different modifier key for the control Pop-up menu (default is CTRL-RightMouse, though often just RightMouse works).