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

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
  • 1
    I don't think that "<F9>" works in readline. To see what F9 really turns into, run cat in your terminal and then press the F9 key. You should see something like ^[[20~. Once you have established the exact escape, bind it to redraw-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.
    – user313992
    Commented Dec 20, 2019 at 3:03
  • @mosvy thank you. i did try this line "^[[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? Does bind '"^[[20~": redraw-current-line go in .bash_profile?
    – WEBjuju
    Commented Dec 20, 2019 at 16:30
  • 1
    Try "\e[20~" or "\033[20~", not "^[[20~". ^[ is how escape (ASCII 27) is echoed back by the terminal when its echoctl flag is on.
    – user313992
    Commented Dec 20, 2019 at 17:21
  • Thanks - i did just try both of those. I have to admit something, i went back and restested everything (same results), but the reason i retested is...i wasn't sourcing inputrc after each change. So...this is important content...but i'm getting this when i source inputrc: \e[20~:redraw-current-line: command not found
    – WEBjuju
    Commented Dec 20, 2019 at 18:46
  • 1
    ~/.inputrc is not a shell script, you could not source it. To test if the binding works, either run bind '"\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 pressing Ctrl-x Ctrl-r.
    – user313992
    Commented Dec 20, 2019 at 18:56

1 Answer 1


This is insane but true...i was on a new server today and having forgotten completely about this question (and the answer buried in comments), I was actually googling for how to do this today. I'm posting my answer for myself or for anyone else that is having problems disabling function key input in vi commandline:

  1. create or edit your ~/.inputrc file
  2. to disable through (MacOS, Ubuntu, CentOS at least) use the following:
set keymap vi-insert

As @mosvy indicates, redrawing the current line prevents the annoying "(arg: 20)" or "(arg: 21)" from ruining your command line input.

You must log in to answer this question.

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