Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to remap some of my keyboard shortcuts in bash. The problem is that when I try to display key code using Ctrl-V, not all keys work. For example, Typing Ctrl-V, then Home moves the terminal to the top, just as usual. Typing Ctrl-V, then Ctrl shows nothing. Typing Ctrl-V, then left arrow shows ^[OD, typing Ctrl-V, then Ctrl-left arrow shows the same thing.

I am trying to remap Home and End to move cursor to the beginning or end of line, and Ctrl-arrows to jump words. I am in Solaris, using DtTerm.



Dtterm*DtTerm*Translations: #override \n\
<KeyPress>osfBeginLine: string("0x1B")string("[1~") \n\
<KeyPress>osfEndLine:   string("0x1B")string("[4~") \n\
Ctrl<KeyPress>osfLeft:  string("0x1B")string("OC") \n\
Ctrl<KeyPress>osfRight: string("0x1B")string("OD")


"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\eOD": forward-word
"\eOC": backward-word
share|improve this question
up vote 2 down vote accepted

I've not used dtTerm in many years. You may be able to get it to work by setting both the keypad mode and cursor key mode to "Application mode" (found under Terminal -> Options).

If that doesn't work then you will probably have to go down the Xresources route, but it strikes me that the Home key (like the escape key) has a special meaning to DtTerm (ala OSF/Motif), and this needs extra work to get it to play nicely.

Apparently using #override in Translations is not 'officially supported', but as a hack it works.

You will need to find what keymapping are presently in place by running dtTerm from shell and then issuing a ShiftCtrl* to get dtTerm to dump it's keymap (which will appear on stdout on the shell that ran the dtTerm). * is the key on your numpad (sometimes known as KP_Multiply) when talking in terms of X Key bindings.

I imagine the keymapping dtTerm will assign will be something like osfBeginLine.

Next you need to get the actual key sequence you want to get (home key) by using something like xev. As an example my home key under my setup is keysym 0xff50.

KeyPress event, serial 30, synthetic NO, window 0x3600001,
    root 0x102, subw 0x0, time 643678606, (78,90), root:(1578,578),
    state 0x0, keycode 110 (keysym 0xff50, Home), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

Next you will need to edit your ~/.Xdefaults and add something like:

:<KeyPress>osfBeginLine: string("0xff50")

Then run dtaction ReloadResources, which should source your .Xdefaults file.

With a bit of luck you should get the mapping, and then be able to do your key binding as usual. If not, you may have to muck about in the land of virtual binding of Motif, which I remember being a gigantic pile of spaghetti.


dtTerm manual, dtTerm terminal options page

Standard Xresources dtTerm parses

share|improve this answer
Thank you for your answer, it has been most helpful. However, it appears that dtterm support only 8-bit ASCII, as when I put string("0xff50"), I get capital P (ASCII hex 0x50). So I just concatenated two strings to form an ANSI escape sequence, which I included in my .inputrc. See question edit for full solution. – Jakub Zaverka Aug 20 '13 at 7:45
Ah nice work around to that :) Glad you finally managed to get it sorted! (personally I moved over to xterm after having to battle too often with dtTerm) – Drav Sloan Aug 20 '13 at 9:01

Physical terminals didn't generate different code sequences for CTRL used with arrows. Terminal emulators have followed suit as they are trying to behave in the same way as their physical ancestors. Depending on the terminal emulator you are using, you may be able to define your own sequences. For instance, I've

XTerm*VT100*Translations:   #override \
    Ctrl<Key> Next:scroll-forw(1,halfpage)\n\

in my ressource file for XTerm.

share|improve this answer
Will this work even for DtTerm? I should just write DtTerm*VT100*Translations? – Jakub Zaverka Aug 19 '13 at 10:26
Most probably not. I've not used it for years (and it seems to me that it was already EOLived then), but I don't remember that DtTerm was as much customizable. Although I think it used the XRessource mechanism, I doubt it used the same widget as XTerm. – AProgrammer Aug 19 '13 at 10:49

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.