]> git.donarmstrong.com Git - zsh.git/blob - .zsh/zshrc/80_abbreviations
add zsh modes to everything
[zsh.git] / .zsh / zshrc / 80_abbreviations
1 # -*- mode: sh -*-
2 typeset -Ag abbreviations
3 abbreviations=(
4   '...'  '../..'
5   '....' '../../..'
6   'BG'   '& exit'
7   'WC'   '| wc'
8   'GR'   '|& grep '
9   'HD'   '| head'
10   'HL'   ' --help |& less -r'
11   'LS'   '| less'
12   'LR'   '|& less -r'
13   'NL'   '&>/dev/null'
14   'SL'   '| sort | less'
15   'SU'   '| sort -u'
16   'TL'   '| tail'
17   'VI'   '|& vim -'
18 )
19
20 magic-abbrev-expand() {
21     local MATCH
22     LBUFFER=${LBUFFER%%(#m)[-_a-zA-Z0-9]#}
23     LBUFFER+=${abbreviations[$MATCH]:-$MATCH}
24     zle self-insert
25 }
26
27 no-magic-abbrev-expand() {
28   LBUFFER+=' '
29 }
30
31 zle -N magic-abbrev-expand
32 zle -N no-magic-abbrev-expand
33 bindkey " " magic-abbrev-expand
34 bindkey "^x " no-magic-abbrev-expand
35 bindkey -M isearch " " self-insert
36
37 # vim:ft=zsh