Previously I was able to output the tilde symbol in my bash terminal by pressing F10. Now when I press F10 I get two characters: 1~. Same goes for F9/F11/F12. Weirdly, the other function keys F1-F8 give me a tilde, but I want F10 to be my tilde key.

Any ideas how to fix this?


None of those keys are tilde keys. They all generate a multiple character sequence, such as ESC [24~ for the F12 key, or ESC [15~ for the F5 key (although F1–F4 are slightly different), or even ESC [5~ for the PgUp key.

The only reason you get a tilde is because Bash's key-sequence parser consumes the common part that it knows (ESC [2) and stops as soon as it knows that the full sequence will be unknown. Everything that follows (not neccessarily a tilde!) gets interpreted separately.

Note that this behavior may differ between terminal-based programs: Bash (readline) has its own code for interpreting special keys, Vim has its own, Irssi has its own again. Some programs might fully recognize your keypress as F10 (and therefore ignore it).

To make F10 an actual tilde key globally (OS-wide), search for "key remapper" tools (perhaps AutoHotkey).

To make F10 a tilde key in all terminal-based programs, search through the terminal's settings. (The 'terminal' in this case refers to ConEmu.)

The terminal might have its own functionality for redefining single keys, or perhaps creating "macros". (The ConEmu documentation suggests defining a macro with the print(…) action.)

To make F10 a tilde key in Bash (but only Bash):

  1. Make sure that your terminal emulator (ConEmu) hasn't bound F10 to some function of its own. (Plain F10 is usually not bound to anything – however, Shift+F10 is the standard key for opening the "right-click" menu.)

  2. In bash, press CtrlV (literal insert) and then F10. You will see a sequence like ^[[21~.

    (The initial ^[ represents ESC, while the rest are just literal symbols.)

    If, at this point, the key doesn't insert any sequence at all, that means it has been taken over by the terminal itself or another program – go back to step 1.

  3. Open (or create) the ~/.inputrc file in a text editor.

  4. Add this line, taking the sequence from step #2 and replacing ^[ with \e:

    "\e[21~": "~"

    This tells inputrc to insert a ~ upon receiving ESC [21~.

  5. Reopen the Bash shell (or press CtrlX, CtrlR to reload inputrc).

  • ~/.inputrc is for readline(3) library. Programs other than Bash may use it as well and some do. +1 nevertheless. – Kamil Maciorowski Sep 19 '18 at 10:41

What keyboard layout you are using?

There is a dedicated tilde ~ key just above Tab on standard US keyboard.

enter image description here


I fixed this my removing ~.inputrc which had nothing useful in it anyway.

  • 3
    Can you explain why removing this fixed the problem? In particular, consider the next person with this problem...what information do they need to consider to determine whether removing it will fix the problem for them? – I say Reinstate Monica Sep 26 '18 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.