LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Binding ctrl+a and ctrl+e (https://www.linuxquestions.org/questions/linux-general-1/binding-ctrl-a-and-ctrl-e-4175532850/)

rose_bud4201 02-02-2015 04:01 PM

Binding ctrl+a and ctrl+e
 
Hi all --

I've a Solaris 10 machine running bash 3.2.52 which has
Code:

set -o vi
in my .profile and there, ctrl+a and ctrl+e function as one would expect - taking the cursor to the beginning and ending of a line.

I've a RHEL 6.6 machine running bash 4.1.2 which also uses the vi keybindings, but ctrl+a and ctrl+e aren't working. I'm not using screen, which seems to most often be the culprit in other forum posts. I understand that it's weird for them to work with the vi keybindings anyway, so chances are someone fixed the other machine somewhere (or it's a Solaris thing).

I could use set -o emacs instead to get those specific bindings to work, but I'm more interested in how to bind them manually instead of changing the whole keymap?

Thanks!

rose_bud4201 02-03-2015 09:28 AM

Replying to myself - solved.

The answer is, create a new file ~/.inputrc with contents:
Code:

# LHH inputrc
set editing-mode vi
$if mode=vi
"\C-a":beginning-of-line
"\C-e":end-of-line
$endif
# prevent coworkers from wanting to kill me
set bell-style none

And then in .profile or .bashrc (or on the commandline, for one-time use/testing of .inputrc changes), include

Code:

bind -f ~/.inputrc
And voila, Ctrl+A and Ctrl+E work again.

Some useful links I used while figuring this out:
http://superuser.com/questions/81296...e-vi-shortcuts
https://www.gnu.org/software/bash/ma...Init-File.html
https://bbs.archlinux.org/viewtopic....428760#p428760


All times are GMT -5. The time now is 03:06 PM.