18

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.

3 Answers 3

16

For bash, this will reload now the currently defined mappings

bind -f  ~/.inputrc
5
  • Where to get the bind command from?
    – danijar
    May 23, 2018 at 10:57
  • bind is a shell builtin. What os are you running?
    – Paul
    May 24, 2018 at 16:28
  • I'm using Debian with zsh.
    – danijar
    May 24, 2018 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. Dec 5, 2018 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, 2019 at 13:39
7

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).

2
  • 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, 2014 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. Sep 2, 2014 at 21:36
7

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.

2
  • 2
    For whatever reason, my tsch was ignoring the .bindings file. Adding source ~/.bindings to my ~/.cshrc file fixed this.
    – drmuelr
    Jun 7, 2018 at 18:18
  • @drmuelr, if you need to do a source, you may as well have called the file .bindkeys (or any other name as a matter of fact). I have the same issue as that my tcsh (version 6.17 does not automatically source the .bindings file). Maybe @rrlamichhane can comment on what tcsh version he is using ? Oct 10, 2022 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .