summaryrefslogtreecommitdiff
path: root/debian/zshrc
blob: 4a0bfb44f084197439b9eb6919d9013dbed45a2e (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# /etc/zsh/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

READNULLCMD=${PAGER:-/usr/bin/pager}

if [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] &&
   [[ "$TERM" != 'emacs' ]]
then

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

    function bind2maps () {
        local i sequence widget
        local -a maps

        while [[ "$1" != "--" ]]; do
            maps+=( "$1" )
            shift
        done
        shift

        sequence="${key[$1]}"
        widget="$2"

        [[ -z "$sequence" ]] && return 1

        for i in "${maps[@]}"; do
            bindkey -M "$i" "$sequence" "$widget"
        done
    }

    bind2maps emacs             -- Home   beginning-of-line
    bind2maps       viins vicmd -- Home   vi-beginning-of-line
    bind2maps emacs             -- End    end-of-line
    bind2maps       viins vicmd -- End    vi-end-of-line
    bind2maps emacs viins       -- Insert overwrite-mode
    bind2maps             vicmd -- Insert vi-insert
    bind2maps emacs             -- Delete delete-char
    bind2maps       viins vicmd -- Delete vi-delete-char
    bind2maps emacs viins vicmd -- Up     up-line-or-history
    bind2maps emacs viins vicmd -- Down   down-line-or-history
    bind2maps emacs             -- Left   backward-char
    bind2maps       viins vicmd -- Left   vi-backward-char
    bind2maps emacs             -- Right  forward-char
    bind2maps       viins vicmd -- Right  vi-forward-char

    # Make sure the terminal is in application mode, when zle is
    # active. Only then are the values from $terminfo valid.
    function zle-line-init () {
        echoti smkx
    }
    function zle-line-finish () {
        echoti rmkx
    }
    zle -N zle-line-init
    zle -N zle-line-finish

    unfunction bind2maps

fi # [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] && [[ "$TERM" != 'emacs' ]]

zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
                                           /usr/local/bin  \
                                           /usr/sbin       \
                                           /usr/bin        \
                                           /sbin           \
                                           /bin            \
                                           /usr/X11R6/bin

(( ${+aliases[run-help]} )) && unalias run-help
autoload -Uz run-help