add the functions needed for some keybindings
[zsh.git] / .zsh / functions / beginning-or-end-of-somewhere
1 # -*- mode:sh -*-
2
3 ## beginning-of-line OR beginning-of-buffer OR beginning of history
4 ## by: Bart Schaefer <schaefer@brasslantern.com>, Bernhard Tittelbach
5 beginning-or-end-of-somewhere() {
6 local hno=$HISTNO
7 if [[ ( "${LBUFFER[-1]}" == $'\n' && "${WIDGET}" == beginning-of* ) || \
8 ( "${RBUFFER[1]}" == $'\n' && "${WIDGET}" == end-of* ) ]]; then
9 zle .${WIDGET:s/somewhere/buffer-or-history/} "$@"
10 else
11 zle .${WIDGET:s/somewhere/line-hist/} "$@"
12 if (( HISTNO != hno )); then
13 zle .${WIDGET:s/somewhere/buffer-or-history/} "$@"
14 fi
15 fi
16 }