oh-my-zsh history completion
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Underwater World
--
Chapters
00:00 Oh-My-Zsh History Completion
00:27 Accepted Answer Score 84
01:27 Answer 2 Score 16
01:52 Thank you
--
Full question
https://superuser.com/questions/417627/o...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#zsh #autocomplete #commandhistory #ohmyzsh
#avk47
ACCEPTED ANSWER
Score 84
I have found the solution to my problem in the ZSH documentation. Oh-my-zsh seems to map the ↑ and ↓ Keys to something like
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
Which yields the exact behavior I described above. The ZSH Documentation describes the behavior of history-search-backward
as
Search backward in the history for a line beginning with the first word in the buffer.
What I wanted instead was the following mapping, which I inserted into my ~/.zshrc
:
bindkey '\e[A' history-beginning-search-backward
bindkey '\e[B' history-beginning-search-forward
The behavior of history-beginning-search-backward
is as follows:
Search forward in the history for a line beginning with the current line up to the cursor. This leaves the cursor in its original position.
Also, if \e[A
doesn't work for the up or down arrows, press <ctrl-v><KEY (e.g., up arrow)>
in another terminal which gives ^[OA
. Then you can use this instead of \e[A
. The process is described here: http://zshwiki.org/home/zle/bindkeys
ANSWER 2
Score 16
I wanted the same behaviour for zsh with oh-my-zsh
installed and found plugin history-substring-search
.
I achieved the same behaviour described above by adding the plugin to my ~/.zshrc
:
plugins=(git brew npm history-substring-search)
I guess this plugin did not exist back when this question was raised. Just an alternate way to achieve the same thing.