File: up-line-or-beginning-search

package info (click to toggle)
zsh 5.8-6%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 23,708 kB
  • sloc: ansic: 107,536; sh: 6,871; makefile: 726; perl: 687; awk: 389; sed: 16
file content (22 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Like up-line-or-search, but uses the whole line prefix up to the
# cursor position for searching backwards.

emulate -L zsh

typeset -g __searching __savecursor

if [[ $LBUFFER == *$'\n'* ]]; then
  zle .up-line-or-history
  __searching=''
elif [[ -n $PREBUFFER ]] && 
    zstyle -t ':zle:up-line-or-beginning-search' edit-buffer
then
  zle .push-line-or-edit
else
  [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
  __savecursor=$CURSOR
  __searching=$WIDGET
  zle .history-beginning-search-backward
  zstyle -T ':zle:up-line-or-beginning-search' leave-cursor &&
      zle .end-of-line
fi