11

I usually use CTRL+Left and CTRL+Right to navigate between words on the command-line. I switched my laptop on this morning and can no longer do that. Instead, the CTRL+Left input code gets printed in the terminal.

Ie: Here's my output when I try to navigate with CTRL+Left:

~ $ test test ;5D;5D;5D

Curiously, I can still use CTRL+Left/Right just fine in VIM.

  • Mayne you put something in your bashrc to enable this? Because it doesn't work by default for me on Ubuntu 15.10... – Martin Tournoij Mar 11 '16 at 10:21
  • Please post the output of grep bind ~/.bashrc . Are you sourcing other files in ~/.bashrc (grep source ~/.bashrc)? – kos Mar 11 '16 at 13:23
  • 1
    Just curious, but what is the output of echo $0? – Aaron Mar 11 '16 at 15:27
12

Open ~/.inputrc file and add the following lines:

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

Close and reopen shell.Now you should be able to use those keys.

Reasons for this behavior ? Not quite certain. For some reason or the other your bash stopped reading /etc/inputrc file, but it should be reading the one in your home folder

  • I think this issue started for me when I created a ~/.inputrc file. Would that do it? – wjandrea Dec 1 '17 at 4:30
  • 1
    @wjandrea yep, I tested that just now. Prior to having blank ~/.inputrc the bash worked fine, started showing same control characters for output once blank ~/.inputrc was created. Removed it - Ctrl+arrow keys work again. strace reveals that if .inputrc exists, bash won't read /etc/inputrc. I'll mess around with this a bit more and update my answer – Sergiy Kolodyazhnyy Dec 1 '17 at 5:03

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.