I found a command a couple of months ago that made my bash history auto-complete on what's already on the line when pressing the up arrow:
$ vim fi
$ vim file.py
I'd like to set this up on my new computer, because it saves a lot of time when keeping a big history. The problem is that I can't for the life of me remember where it was mentioned and reading through endless bash references and tutorials unfortunately didn't help either.
Does anybody know the command?
Probably something like
# ~/.inputrc "\e[A": history-search-backward "\e[B": history-search-forward
# ~/.bashrc if [[ $- == *i* ]] then bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' fi
(the if statement checks for interactive mode)
Normally, Up and Down are bound to the Readline functions
next-history respectively. I prefer to bind PgUp/PgDn to these functions, instead of displacing the normal operation of Up/Down.
# ~/.inputrc "\e[5~": history-search-backward "\e[6~": history-search-forward
After you modify
~/.inputrc, restart your shell or use Ctrl+X, Ctrl+R to tell it to re-read
By the way, if you're looking for relevant documentation:
Bash uses The GNU Readline Library for the shell prompt and history.
Update .inputrc with the following:
"\C-[OA": history-search-backward "\C-[[A": history-search-backward "\C-[OB": history-search-forward "\C-[[B": history-search-forward