Interrpreting modifier codes in /etc/inputrc ??
Rick Stevens
ricks at nerd.com
Thu Aug 6 22:40:53 UTC 2009
William Case wrote:
> Thanks Rick;
>
> On Thu, 2009-08-06 at 14:46 -0700, Rick Stevens wrote:
>> William Case wrote:
>>> On Thu, 2009-08-06 at 15:29 -0500, Mikkel L. Ellertson wrote:
>>>> William Case wrote:
>
>>> Mikkel, I would prefer to be lazy too. However, Control+right-arrow
>>> simply produces ";5C" at the cursor on my command line and Control
>>> +left-arrow prints ";5D".
>> Mikkel is correct. CTRL-left-arrow generates <ESC>[1;5C (<ESC> meaning
>> "escape" or the "\e" from the previous posts), CTRL-right-arrow produces
>> <ESC>[1;5D.
>
> Yes that is what the keys are supposed to be designated as, but
> CTRL-right-arrow and CTRL-left-arrow. should produce movement one word
> at a time -- not just print out the code at the cursor location.
>
>> If you're curios, run "showkey -a" from a command prompt
>> and press those sequences:
>>
>> [root at prophead ~]# showkey -a
>
> Thanks for introducing me to the showkey command.
Useful utility, that. :-)
>
>> As to bash just displaying the ";5C" or whatever, you have to have data
>> on the command line for it to the sequences to operate on. If you're
>> just at a prompt and you hit one of those sequences, there's nothing to
>> act on and you'll probably rewarded with a beep and a display of the
>> remainder of the key sequence.
>
> I did have data in the command line when I tried CTRL-right-arrow and
> CTRL-left-arrow.
>
> Since I had used a command from 'history', I tried your suggestion to
> see if a new command/sentence/data made any difference. It shouldn't
> have.
>> Try putting "the quick brown fox" after a command prompt, then use
>> CTRL-left-arrow and watch the cursor move back by words.
>
> I did not get movement. I only got the same ";5C" and ";5D" code
> printed to stdout no matter where the cursor was placed in "the quick
> brown fox". The printed code appears exactly where the cursor is placed
> at the time of invoking CTRL-right-arrow or CTRL-left-arrow.
Hmmm. Works a treat here on F10 and F11 (x86_64), but I've not mucked
with my inputrc files:
[root at prophead ~]# cat /etc/inputrc
# do not bell on tab-completion
#set bell-style none
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on
$if mode=emacs
# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# for rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif
"CTRL-backspace" does NOT delete words to the left (just characters like
a normal backspace does, which makes sense since the backspace key is
just a CTRL-H), but "ALT-backspace" does delete words to the left.
"CTRL-delete" and "ALT-delete" don't do any deletes, they echo the
characters after the "<ESC>[" stuff as you see, but the default inputrc
doesn't have any mappings for those keys:
CTRL-delete = ^[[3;5~ ("^[" = "\e" escape)
ALT-delete = ^[[3;3~
You should also note that applications may install their own mappings
(hence the "ALT-F" bringing down the file menu, etc.), so even setting
inputrc may not give you the results you want, depending on the app
you're running.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer ricks at nerd.com -
- AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 -
- -
- Hard work has a future payoff. Laziness pays off now. -
----------------------------------------------------------------------
More information about the fedora-list
mailing list