]> git.donarmstrong.com Git - zsh.git/blob - .zsh/zshrc/80_abbreviations
make zle abbreviations work
[zsh.git] / .zsh / zshrc / 80_abbreviations
1 typeset -Ag abbreviations
2 abbreviations=(
3   '...'  '../..'
4   '....' '../../..'
5   'BG'   '& exit'
6   'C'    '| wc'
7   'G'    '|& grep '
8   'H'    '| head'
9   'HL'   ' --help |& less -r'
10   'L'    '| less'
11   'LL'   '|& less -r'
12   'N'    '&>/dev/null'
13   'SL'   '| sort | less'
14   'S'    '| sort -u'
15   'T'    '| tail'
16   'V'    '|& vim -'
17 )
18
19 magic-abbrev-expand() {
20     local MATCH
21     LBUFFER=${LBUFFER%%(#m)[_a-zA-Z0-9]#}
22     LBUFFER+=${abbreviations[$MATCH]:-$MATCH}
23     zle self-insert
24 }
25
26 no-magic-abbrev-expand() {
27   LBUFFER+=' '
28 }
29
30 zle -N magic-abbrev-expand
31 zle -N no-magic-abbrev-expand
32 bindkey " " magic-abbrev-expand
33 bindkey "^x " no-magic-abbrev-expand
34 bindkey -M isearch " " self-insert
35
36 # vim:ft=zsh