Regarding mapping function keys in vi readline, I have read these two stackexchanges:
I have a MacBookPro with a touchbar. The function keys are always on, but unlike physical keys, the virtual touch bar function keys are tempermental and frequently inject junk into the commands i'm typing (this is particularly a problem when attempting to type an underscore...i get a lot of F9
, F10
, and maybe some F11
). I don't use these keys...so i wish i could disable them. But, let's say that i could make them simply go to the end of the line.
This is one of my many attempts to map to go to the end of the line (when in insert mode):
set editing-mode vi
$if mode=vi
set keymap vi-insert
"<F9>": end-of-line
$endif
the result of typing "asdf" at a prompt is as follows:
TT->~$ [] (arg: 20)
I have placed "[]", above, where the cursor remains after pressing <F9>
, in case that is any help.
The variations i have tried are as follows:
"<F9>": end-of-line
<F9>": end-of-line
20: end-of-line
"20": end-of-line
"arg: 20": end-of-line
(arg: 20): end-of-line
"(arg: 20)": end-of-line
Update: the following .inputrc
is now working to "ignore" :
set keymap vi-insert
"\e[20~":redraw-current-line
"<F9>"
works in readline. To see whatF9
really turns into, runcat
in your terminal and then press theF9
key. You should see something like^[[20~
. Once you have established the exact escape, bind it toredraw-current-line
:bind '"\e[20~": redraw-current-line'
(or whatever command you like). You should, of course, use just the"\e[20~": redraw-current-line
in~/.inputrc
. – Dec 20 '19 at 03:03"^[[20~": redraw-current-line
after cat showed me the^[[20~
output. Unfortunately i'm still getting(arg: 20)
. Could this be related to it being the MBP touch bar? Doesbind '"^[[20~": redraw-current-line
go in.bash_profile
? – WEBjuju Dec 20 '19 at 16:30"\e[20~"
or"\033[20~"
, not"^[[20~"
.^[
is how escape (ASCII 27) is echoed back by the terminal when itsechoctl
flag is on. – Dec 20 '19 at 17:21\e[20~:redraw-current-line: command not found
– WEBjuju Dec 20 '19 at 18:46~/.inputrc
is not a shell script, you could notsource
it. To test if the binding works, either runbind '"\e[20~": redraw-current-line'
in your current shell, or add just the binding the~/.inputrc
and start a new shell. If you're using the emacs keybindings, you can also re-source the~/.inputrc
file by pressingCtrl-x Ctrl-r
. – Dec 20 '19 at 18:56\e[20~
forredraw-current-line
as the command, and (c) start a new shell to source inputrc. i have already put in 20-23 and find no reaction at all from purposeful (or accidental) input from