1

Not sure I'm wording the question very well, but an example is worth a thousand words of mine. eg., using oh-my-zsh :

git <up arrow>

Will cycle up all the git commands I have used...

git rebase brancha
git commit foo
git rebase branchb
etc

Is there a way to limit that history to the second/third word given. eg.

git rebase <up arrow>

To only cycle through git rebase commands :

git rebase brancha
git rebase branchb
3

You're looking for the zle widget history-beginning-search-backward, which is not bound to a key by default.

You can bind this command to a key, for example Ctrl+Up (and the symmetric command on Ctrl+Down). Keychords like Ctrl+Up send different escape sequences on different terminals, so check what yours sends by typing Ctrl+V Ctrl+Up; \e represents an escape character (displayed as ^[ by most terminals) which is the first character of all escape sequences.

bindkey '\e[1;5A' history-beginning-search-backward
bindkey '\e[1;5B' history-beginning-search-forward
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.