aboutsummaryrefslogtreecommitdiff
path: root/files/.zsh/rc/S01_auto_rehash
blob: 7936ce8885926441dcd443cbe98508a9268f5c79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# https://github.com/cofi/dotfiles/blob/master/zsh/auto_rehash

emulate -L zsh

rehash_preexec() {
    case "$1" in
        # debian
        *apt*|*apt-get*|*aptitude*)
            __rehash=1
            ;;
    esac
}

rehash_precmd() {
    if [[ -n __rehash ]]; then
        rehash
        unset __rehash
    fi
}
typeset -ga preexec_functions
typeset -ga precmd_functions
preexec_functions+=rehash_preexec
precmd_functions+=rehash_precmd