Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to disable Shift+Home, Shift+End keybindings in Gnome Terminal / Ubuntu 12.04? (they scroll to top/bottom).

I already tried:

  1. Disable shotcuts in Gnome Terminal Keyboard Shortcuts (no such shortcuts available).

  2. Looked into gconf-editor: gnome-terminal and metacity shortcuts (couldn't find Shift+Home or Shift+End shortcuts here).

  3. Run gsettings for different schemas, like "gsettings list-recursively org.gnome.desktop.wm.keybindings" - no such shortcuts here.

  4. Went through keybindings in CompizConfig Settings. No luck here either.

Is there other way to disable keyboard shortcuts for Gnome Terminal in Ubuntu?

share|improve this question
add comment

migrated from stackoverflow.com Apr 14 '13 at 0:25

This question came from our site for professional and enthusiast programmers.

1 Answer

Gnome Terminal indeed has predefined actions bound to Shift + Home and Shift + End. However, it is not GT that defines this behaviour, but rather it's because of VTE which GT is based on. As far as I can tell this aspect is not configurable and the only way to fix it is to patch VTE. I described how to do this in my blog post Fixing Ctrl-Home, Ctrl-End, Shift-Home, and Shift-End shortcuts in Gnome Terminal in Ubuntu 13.04. Below is mostly a copy-paste of that post.

What I basically had to do was to follow the Classic instructions from this answer. I changed them for my particular case.

Note: The instructions below are based on Ubuntu 13.04, which I have at hand, but I suppose they can be applied, probably with some minor alterations, to other versions of the distro.

There are two libvte* packages in Ubuntu 13.04. So first of all, I had to find out which one Gnome Terminal depends on:

$ apt-cache depends gnome-terminal | grep libvte

The required version was libvte-2.90-9. I downloaded the source code:

$ apt-get source libvte-2.90-9

Then I modified it:

$ cd vte3-0.34.2 
$ vim src/vte.c

Here I had to find the unwanted shortcuts, they followed after this comment:

/* Keypad/motion keys. */

So I just removed everything up to the next comment:

/* Let Shift +/- tweak the font, like XTerm does. */

It turned out that removing these shortcuts was not enough because of this VTE's bug. So I applied the patch mentioned in the comments to the bug:

--- a/src/keymap.c
+++ b/src/keymap.c
@@ -284,6 +284,8 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Home[] = {
    {cursor_all, keypad_all, fkey_vt220, 0, _VTE_CAP_CSI "1~", -1, X_NULL},
    {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "h", -1, X_NULL},
    {cursor_all, keypad_all, fkey_nothpvt, 0, X_NULL, 0, "kh"},
+   {cursor_default, keypad_all, fkey_default, 0, _VTE_CAP_CSI "H", -1, X_NULL},
+   {cursor_app, keypad_all, fkey_default, 0, _VTE_CAP_SS3 "H", -1, X_NULL},
    {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };

@@ -291,6 +293,8 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_End[] = {
    {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "@7"},
    {cursor_all, keypad_all, fkey_vt220, 0, _VTE_CAP_CSI "4~", -1, X_NULL},
    {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "@7"},
+   {cursor_default, keypad_all, fkey_default, 0, _VTE_CAP_CSI "F", -1, X_NULL},
+   {cursor_app, keypad_all, fkey_default, 0, _VTE_CAP_SS3 "F", -1, X_NULL},
    {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };

@@ -507,6 +511,8 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_End[] = {
    {cursor_all, keypad_default, fkey_vt220, 0, "1", 1, X_NULL},
    {cursor_all, keypad_app, fkey_notvt220, 0, _VTE_CAP_CSI "4~", -1, X_NULL},
    {cursor_all, keypad_app, fkey_vt220, 0, _VTE_CAP_SS3 "q", -1, X_NULL},
+   {cursor_default, keypad_all, fkey_default, 0, _VTE_CAP_CSI "F", -1, X_NULL},
+   {cursor_app, keypad_all, fkey_default, 0, _VTE_CAP_SS3 "F", -1, X_NULL},
    {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };

@@ -568,6 +574,8 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Home[] = {
    {cursor_all, keypad_default, fkey_vt220, 0, "7", 1, X_NULL},
    {cursor_all, keypad_app, fkey_notvt220, 0, _VTE_CAP_CSI "1~", -1, X_NULL},
    {cursor_all, keypad_app, fkey_vt220, 0, _VTE_CAP_SS3 "w", -1, X_NULL},
+   {cursor_default, keypad_all, fkey_default, 0, _VTE_CAP_CSI "H", -1, X_NULL},
+   {cursor_app, keypad_all, fkey_default, 0, _VTE_CAP_SS3 "H", -1, X_NULL},
    {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };

@@ -1279,6 +1287,8 @@ _vte_keymap_key_get_modifier_encoding_method(guint keyval)
    case GDK_KEY (Right):
    case GDK_KEY (Insert):
    case GDK_KEY (Delete):
+   case GDK_KEY (Home):
+   case GDK_KEY (End):
    case GDK_KEY (Page_Up):
    case GDK_KEY (Page_Down):
    case GDK_KEY (KP_Up):
@@ -1287,6 +1297,8 @@ _vte_keymap_key_get_modifier_encoding_method(guint keyval)
    case GDK_KEY (KP_Right):
    case GDK_KEY (KP_Insert):
    case GDK_KEY (KP_Delete):
+   case GDK_KEY (KP_Home):
+   case GDK_KEY (KP_End):
    case GDK_KEY (KP_Page_Up):
    case GDK_KEY (KP_Page_Down):
    case GDK_KEY (F1):

There were no conflicts.

Then I rebuilt the package:

$ sudo apt-get build-dep libvte-2.90-9
$ dch -i # here I updated the version to 0.34.2-customized-0ubuntu3
$ debuild -us -uc -b

And installed it:

$ cd ..
$ sudo dpkg -i libvte-2.90-common_0.34.2-customized-0ubuntu3_all.deb
$ sudo dpkg -i libvte-2.90-9_0.34.2-customized-0ubuntu3_amd64.deb

Although it was enough to install these two packages to fix the problem, I installed all the others that were generated by the debuild command as well.

After restarting Gnome Terminal, Shift + Home and Shift + End started working as expected.

share|improve this answer
    
When linking to something, always provide long enough summary of that content. That link will be broken sooner or later, and after that this post is pretty much useless. –  Olli Feb 9 at 11:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.