I'm using "standard" just in case there's some obvious method, or this feature is part a larger issue that I'm not aware of (as in perhaps involving enabling related shortcuts and features). Otherwise I don't mind just adding my own shortcuts.

  • 1
    On what operating system? FreeBSD? TrueOS? OpenBSD? NetBSD? Illumos? A Linux operating system? ... – JdeBP Jan 3 '17 at 8:57
  • I just updated the tags. – argle Jan 3 '17 at 9:16

If your shell uses the readline library, here is what I have in my default /etc/inputrc file:

# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word

This file is only read if the INPUTRC environment variable is not set, and if you don't have any .inputrc file in your home directory.

Now, we must instruct the console to emit one of the backward-word strings when Ctrl-Left is pressed, and one of the forward-word strings when Ctrl-Right is pressed.

For this, we must add some special keyboard mappings to /etc/console-setup/remap.inc:

# Ctrl + Left arrows key (readline's backward-word)
control keycode 105 = F200
string F200 = "\033[5D"

# Ctrl + Right arrows key (readline's forward-word)
control keycode 106 = F201
string F201 = "\033[5C"

Here I have borrowed two keysyms F200 and F201 (picked up quasi randomly from the output of dumpkeys --long-info) in order to store the sequences expected by readline. keycode 105 is the left arrow, and keycode 106 is the right arrow (those keycodes were obtained with dumpkeys too).

Now, let's rebuild our new keymap :

setupcon --save-only

It should (re)create the file /etc/console-setup/cached.kmap.gz. You can load it manually with the command:

loadkeys /etc/console-setup/cached.kmap.gz

Or, better, similarly to when your machine boots:

service console-setup start
|improve this answer|||||
  • You have them (so do I), but do they work? In the non-GUI console? (That would be amazing.) – argle Jan 3 '17 at 10:21
  • @argle have you tried it yourself? – Mr Shunz Jan 3 '17 at 10:30
  • @MrShunz Just test them in the kernel console and you'll understand what I mean. – argle Jan 9 '17 at 6:57
  • @argle What i meant is that you asked if they work, as if you haven't tried them yourself. That said, I don't have a debian machine at hand, but on my ubuntu system they don't work on tty console (same /etc/inputrc though). – Mr Shunz Jan 9 '17 at 9:40
  • @MrShunz No, I haven't tried it myself (obviously). It's xhienne's machine and only he can try; that's why I needed to ask him :P. I could (and did) only try it on my machine (obviously; hence my SE question and note that I said I'd already had those very same configuration lines) and I found it amazing that (xhienne implied) it worked on his machine. By the way, try it on your non-Debian machine and you'll see that it's not working either. – argle Jan 10 '17 at 9:28

For Linux console, you can customize your keymap. The place to start is with dumpkeys. That's the standard approach. There's no applicable standard for Linux console bindings, but you can certainly imitate GUI (i.e., xterm as hinted by xhienne).

I don't see a duplicate, but these would be helpful:

|improve this answer|||||
  • +1 for the help. I'll test it as soon as I get some time and I'll return with updates. – argle Jan 3 '17 at 22:52
  • I did some more reading. It turns out I understood your solution; it was just unrelated to my question. I hope I'll make inputrc work and post the answer here soon. – argle Jan 9 '17 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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