Skip to content

Instantly share code, notes, and snippets.

@ismarsantos
Forked from hardiksondagar/README.md
Created August 14, 2023 01:11
Show Gist options
  • Save ismarsantos/c4e9d36000b7f4681236c9d5557e2657 to your computer and use it in GitHub Desktop.
Save ismarsantos/c4e9d36000b7f4681236c9d5557e2657 to your computer and use it in GitHub Desktop.
Ubuntu: Bash history search, partial + up-arrow

Both methods below are almost equivalent, it just depends on which file you want to edit. I'd recommend .bashrc myself, as it doesn't involve editing a local copy of a system file.

If you experience any problems with this, please comment below so that it can be fixed.

Using ~/.bashrc

  1. Edit ~/.bashrc with this command:
gedit ~/.bashrc
  1. Add the following lines:
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
  1. Save then close the file.
  2. Execute this command in a terminal:
source ~/.bashrc

Using ~/.inputrc

  1. Execute this command in a terminal:
cp /etc/inputrc ~/.inputrc
  1. Edit the new ~/.inputrc file with this command:
gedit ~/.inputrc
  1. Append these lines to the file:
"\e[A": history-search-backward
"\e[B": history-search-forward

References:

Source:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment