ChristianLempa / dotfiles

This contain my personal config files. Here you'll find configs, customizations, themes, and whatever I need to personalize my Linux and mac OS experience.
MIT License
920 stars 316 forks source link

Updated goto.zsh to support zsh beginning search #14

Closed 0xiDen closed 1 year ago

0xiDen commented 1 year ago

One of my favorite features of zsh is history-beginning-search which can be done backward or forward in this commit I enabled this feature.

ChristianLempa commented 1 year ago

Sounds interesting, can you give me more info about how that works, and what I need to do to install and use the plugin?

0xiDen commented 1 year ago

I'm glad you're interested. No plugin is needed. this features comes with zsh however can be further improved by installing some plugins.

bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward

This binds Up and Down (adjust for your own escape sequences) to a history search, backwards and forwards, based upon what has already been entered at the prompt.

So, if you were to enter "vim" and hit Up, zsh will traverse backwards through your history for only those commands commencing with "vim". you can see the implemented code here: https://github.com/zsh-users/zsh/blob/master/Functions/Zle/up-line-or-beginning-search

ChristianLempa commented 1 year ago

Wouldn't it be better to add it to a separate vim.zsh file then?

0xiDen commented 1 year ago

I used vim as an example @ChristianLempa. It IS NOT specific to vim. It works with any command. suppose you enter command_x (for example vim or docker) and hit UP Arrow Key it searches your history and goes through commands starting with command_x (for example last vim file you opened or docker node ls since it was in your history) cause it covers under autoload config and you originally used this file for zsh autoload I added to this file however if you prefer it we can put it in a separate file with autoload configs and name it zsh_autoload or something.

ChristianLempa commented 1 year ago

Thanks for the clarification. I'll merge it then and might add it to another file later, as goto is something different.