aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/zsh/files/zshrc
blob: 37918523a9ff5c2a5eab4d2836f9f53c98b5c726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# /etc/zshrc: system-wide .zshrc file for zsh(1).
#
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# Global Order: zshenv, zprofile, zshrc, zlogin

typeset -A key

key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"    ]]  && bindkey -e "${key[Home]}"    beginning-of-line
[[ -n "${key[End]}"     ]]  && bindkey -e "${key[End]}"     end-of-line
[[ -n "${key[Insert]}"  ]]  && bindkey -e "${key[Insert]}"  overwrite-mode
[[ -n "${key[Delete]}"  ]]  && bindkey -e "${key[Delete]}"  delete-char
[[ -n "${key[Up]}"      ]]  && bindkey -e "${key[Up]}"      up-line-or-history
[[ -n "${key[Down]}"    ]]  && bindkey -e "${key[Down]}"    down-line-or-history
[[ -n "${key[Left]}"    ]]  && bindkey -e "${key[Left]}"    backward-char
[[ -n "${key[Right]}"   ]]  && bindkey -e "${key[Right]}"   forward-char

unset key

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
function zle-line-init () {
    emulate -L zsh
    printf '%s' $terminfo[smkx]
}
function zle-line-finish () {
    emulate -L zsh
    printf '%s' $terminfo[rmkx]
}
zle -N zle-line-init
zle -N zle-line-finish