13

I have this ~/.inputrc file that I created for certain key bindings.

# 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

whenever I try to run source ~/.inputrc, it gives me the following error:

\e[1;5C:forward-word: Command not found. \e[1;5D:backward-word: Command not found. \e[5C:forward-word: Command not found. \e[5D:backward-word: Command not found. \e\e[C:forward-word: Command not found. \e\e[D:backward-word: Command not found.

It also doesn't work when I open a new terminal, I don't get the error but my ctrl key combinations are not working in new terminal as well. I created this file myself since I do not have root access to change /etc/inputrc. Can anybody help me out? Thanks.

EDIT: I've tried the file with space after the colon (:) sign as well. It doesn't work. I also tried my making it executable (chmod +x ~/.inputrc), didn't work.

EDIT: I realized that this procedure is only for 'bash' and I am running 'tcsh'. For 'csh', use .bindings file instead of .inputrc file and use bindkey syntax.

12

For bash, this will reload now the currently defined mappings

bind -f  ~/.inputrc
  • Where to get the bind command from? – danijar May 23 '18 at 10:57
  • bind is a shell builtin. What os are you running? – Paul May 24 '18 at 16:28
  • I'm using Debian with zsh. – danijar May 24 '18 at 16:50
  • this did not work for me with bash on RHEL 7. My .inputrc bindings are still not re-loading after running this command. – user5359531 Dec 5 '18 at 16:27
  • @user5359531, could it be that your previous bindings are not "un-loading"? (If they're not set explicitly, they'll remain as they were before.) Or maybe something else, like your ~/.inputrc doesn't $include /etc/inputrc? – mwfearnley Jan 19 at 13:39
6

The .inputrc file is not a file to be sourced. It should be taken into account automatically by bash or other software using the readline library. If this doesn't work, add a space after the colon, e.g.

"\e[1;5C": forward-word

(I've always seen a space in this config file).

  • 1
    +1 Emphasis on "other software using the readline library". .inputrc is not a shell script; it's a readline configuration file. – chepner Sep 2 '14 at 20:04
  • Actually, that's how I had it first and I changed it to without space just to try it out. It doesn't work either way. I've added that in the edit. Thanks. – rrlamichhane Sep 2 '14 at 21:36
5

The key bindings and ~/.inputrc file posted in question is for bash. For csh (or tcsh) use a file ~/.bindings and use following syntax.

bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word

Realized this after some googling.

  • For whatever reason, my tsch was ignoring the .bindings file. Adding source ~/.bindings to my ~/.cshrc file fixed this. – drmuelr Jun 7 '18 at 18:18

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.