Up arrow key to search for two words specified using the zsh shell

With zsh / oh-my-zsh / iterm2, a great way to navigate through the history of terminal commands.

If I issued a command to say knife cookbook upload applicationa few days before and get a command, I can keither knior or knifand press the up arrow key, it will iterate over the command history, starting with the word knife.

But if similar commands are started, starting with knife, I will have to iterate over the commands using the up arrow key.

But if I wanted to search for more than one word, say, to get commands with knife node, zsh does not support this and starts showing commands starting with only knife.

So, is there a way to get commands starting with two words? so I just type two words and press the up arrow to show only those commands that start with the two words entered.

+5
source share
2 answers

In addition to @Shep's answer, I would suggest changing the behavior <C-r>from searching only simple strings to search for glob patterns:

bindkey "\C-r" history-incremental-pattern-search-backward

. , knife*node. , knife node<Up>, zsh , knife node, knife. , knife, node, , , knife node ( history-beginning-search-backward ).

+2

, , , C-r, , , . , -r ( ).

. .

+1

All Articles