Skip to content

aoyama-val/zsh-incsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Incremental search for zsh

Move cursor with incremental search within current line.

CAVEATS

This plugin is the reinvention of the zsh's builtin feature ^R and ^S. These commands also allow you to move the cursor within the current line, though the name history-incremental-search is not obvious that they has the capability.

demo

Install (zinit)

zplug "aoyama-val/zsh-incsearch"

Install (manual)

Clone this repository and

source {PATH_TO_REPO}/zsh-incsearch.plugin.zsh

Configuration

To your ~/.zshrc:

# bind to any keys you like
bindkey "^[l" incsearch-forward              # put cursor at the end of match
bindkey "^[h" incsearch-backward             # put cursor at the end of match
bindkey "^[L" incsearch-forward-beginning    # put cursor at the beginning of match
bindkey "^[H" incsearch-backward-beginning   # put cursor at the beginning of match

my_incsearch_hook_enter() {
    if [ "$TERM_PROGRAM" = "iTerm.app" ]; then
        # Change cursor to underline
        echo -ne "\e]50;CursorShape=2\a"
    fi
}

my_incsearch_hook_leave() {
    if [ "$TERM_PROGRAM" = "iTerm.app" ]; then
        # Restore cursor to block
        echo -ne "\e]50;CursorShape=0\a"
    fi
}

incsearch_hooks_enter+="my_incsearch_hook_enter"
incsearch_hooks_leave+="my_incsearch_hook_leave"

Keybindings while incremental search

Key Action
the key you bound to accept-line (usually Enter) Finish search
the key you bound to backward-delete-char (usually Backspace) Delete the last character from the search text

About

zsh plugin to incremental search within current line

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages