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
Press ↑
$ 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?
With ohmyzsh, use this in your .zshrc :
To reload,
source ~/.zshrc
or relaunch terminal.Source: https://superuser.com/a/418299/71680
Probably something like
or equivalently,
(the if statement checks for interactive mode)
Normally, Up and Down are bound to the Readline functions
previous-history
andnext-history
respectively. I prefer to bind PgUp/PgDn to these functions, instead of displacing the normal operation of Up/Down.After you modify
~/.inputrc
, restart your shell or use Ctrl+X, Ctrl+R to tell it to re-read~/.inputrc
.By the way, if you're looking for relevant documentation:
Bash uses The GNU Readline Library for the shell prompt and history.
You may need to enabled bash completion.
Check
/etc/profile
/etc/bash.bashrc
~/.bashrc
to see if any of the above files source
/etc/bash_completion
. i.e.If
/etc/bash___completion
is not sourced by any of the above files you will need to add it to one of them.If you want all bash users on your machine to have bash completion, source
/etc/bash_completion
from/etc/bash.bashrc
.If it's just you who wants bash completion, source
/etc/bash_completion
from your~/.bashrc
.Update .inputrc with the following:
If
set enable-keypad on
is in your~/.inputrc
as some st (suckless simple terminal) users might, be aware that the arrows keys are in keypad mode. Ubuntu ships with this useful/usr/share/doc/bash/inputrc.arrows
:So I'm not sure if you'll need all, but it might not hurt to have in your
~/.inputrc
:This is also on the same topic: My cursor keys do not work and also this xterm: special keys