Subject: Re: Announcement of Zsh Command Architect v1.0
From: Christian Neukirchen <[email-masked]>
To: [email-masked]
Date: Mon, 11 Jan 2016 15:21:37 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Dominik Vogt <[email-masked]> writes:

> To me it appears that cases where a complicated part of a former
> history line needs to be copied and the same cannot easily be done
> with completion is quite rare.  And even then I could just edit
> the complicated line instead of copying a part of it to a new
> line.

I needed this quite often and thus changed my incremental search to
keep the rest of the line and just insert the freshly found line:

# History search with globs.
# 21sep2011  +chris+
# 05jun2012  +chris+  and keeping the rest of the line
autoload -Uz narrow-to-region
_history-incremental-preserving-pattern-search-backward() {
  local state
  MARK=CURSOR  # magick, else multiple ^R don't work
  narrow-to-region -p "$LBUFFER${BUFFER:+>>}" -P "${BUFFER:+<<}$RBUFFER" -S state
  zle end-of-history
  zle history-incremental-pattern-search-backward
  narrow-to-region -R state
}
zle -N _history-incremental-preserving-pattern-search-backward
bindkey "^R" _history-incremental-preserving-pattern-search-backward
bindkey -M isearch "^R" history-incremental-pattern-search-backward
bindkey "^S" history-incremental-pattern-search-forward

-- 
Christian Neukirchen  <[email-masked]>  http://chneukirchen.org