Searching previous command history with PageUp in 14.04

17,033

Solution 1

Try this in ~/.inputrc

"\e[5~": history-search-backward   
"\e[6~": history-search-forward  

and reopen terminal.

Solution 2

\e[A and \e[B are actually the Up and Down arrow keys. To test what a key is, run cat and then press the key:

$ cat
^[[A
^[[B

^[[5~
^[[6~

Those are , , Page Up and Page Down respectively. The ^[ stands for Esc, or \e in terms of .inputrc.

So, if you added \e[A and \e[B, you should be able to browse history using arrow keys. For Page Up and Page Down, use \e[5~ and \e[6~.

Share:
17,033
Juicy
Author by

Juicy

Updated on September 18, 2022

Comments

  • Juicy
    Juicy almost 2 years

    I got this working before (I believe it was on a 15.10, I recently downgraded to the LTS 14.04).

    According to this post the following should work

    ~ $ cat ~/.inputrc 
    "\e[A":history-search-backward
    "\e[B":history-search-forward
    

    But when I save that .inputrc and open a new terminal, typing PageUp or PageDown just prints the tilde character ~ in the terminal, instead of doing the search.

    Any help appreciated.

  • marlar
    marlar about 6 years
    Wow! I have so often see these escape sequences in the terminal, wondering what they were. Even though I already use them in eg. .inputrc, I have never made the connection. Very useful tip, thanks.
  • Tinashe Chinyanga
    Tinashe Chinyanga over 2 years
    Upvoting as the answer provides an explanation of what is happening. Brilliant. For those looking at where to find the inputrc file, you can also look for it in the path /etc/