[NTLUG:Discuss] Customizing terminal characteristics
Leroy Tennison
leroy_tennison at prodigy.net
Sun Dec 10 01:02:07 CST 2006
Leroy Tennison wrote:
> I'm using bash as my shell and would prefer that Ctrl-LeftArrow key
> sequence perform a "move to beginning of previous word" and
> Ctrl-RightArrow a "move to beginning of next word". It appears from
> 'man bash' that the readline library is used for handling keyboard
> input and that the file named by the INPUT shell environment variable
> (/etc/inputrc for my system) can contain "key: action" bindings.
>
> I'm assuming I need to edit this file to make the desired changes,
> correct?
>
> I know what to use to identify the Control and Alt keys, what do I use
> to identify the left and right arrow keys?
>
> Thanks for any input.
>
I didn't get any replies but finally found the solution so I thought I'd
post it for anyone who might be interested. (I emailed the reference in
'man readline' and the reply I received ultimately led to the solution).
/etc/inputrc (or ~/.inputrc) is indeed the file to edit
Knowing what to use to identify the Control and Alt keys was
inadequate. The information which is needed is what the specific key
combination is sending. I had wondered how to do this but the
documentation didn't answer the question. After discovering I felt kind
of dumb for not trying it earlier but anyway, here's what I did:
cat>test
{Pressed just the Escape key followed by Enter to see what it sent}
{Pressed Control-LeftArrow and Enter, noted what was on screen and the
part which represented the Escape}
{Pressed Control-RightArrow and Enter ...}
Control-D (to save the file)
Added these in the form
"\e ...": [forward | backward]-word
to /etc/inputrc then logged out and in again. Everything worked as
desired. I also discovered that 'less' would accurately display the
file after I has saved it. I was prompted ' "test" may be a binary
file. See it anyway?' and replied Yes. It showed the Escapes and the
other characters.
In case you're curious, in my case Control-LeftArrow produced ESC[D and
Control-RightArrow produced ESC[C so I put:
"\e[D": backward-word
"\e[C": forward-word
in my inputrc file. Caveat: Past performance is no guarantee of future
results, your mileage may vary ...
More information about the Discuss
mailing list