]> git.madduck.net Git - etc/zsh.git/blob - .zsh/zshrc/80-zle_magic_abbreviations

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Minor fixes to accomodate Zsh4
[etc/zsh.git] / .zsh / zshrc / 80-zle_magic_abbreviations
1 typeset -Ag zle_abbrevs
2 zle_abbrevs=(
3 #  '...'    '../..'
4 #  '....'   '../../..'
5 #  '.....'  '../../../..'
6 #  '......' '../../../../..'
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   'ND'     '*(/om[1])'
19   'NF'     '*(.om[1])'
20 )
21 # the ...## abbrevs are gone in favour of rationalise-dot
22
23 magic-abbrev-expand() {
24   emulate -L zsh
25   setopt extendedglob
26   local MATCH MBEGIN MEND
27   LBUFFER=${LBUFFER%%(#m)[.A-Z]#}
28   LBUFFER+=${zle_abbrevs[$MATCH]:-$MATCH}
29 }
30
31 no-magic-abbrev-expand() {
32   emulate -L zsh
33   LBUFFER+=' '
34 }
35
36 zle -N magic-abbrev-expand
37 zle -N no-magic-abbrev-expand
38
39 magic_space_functions+=magic-abbrev-expand
40 accept_line_functions+=magic-abbrev-expand
41
42 bindkey "^x " no-magic-abbrev-expand
43 bindkey -M isearch " " self-insert
44
45 function help-show-magic-abbrevs() {
46   zle -M "$(print "Available abbreviations for expansion:"; print -a -C 2 ${(kv)zle_abbrevs})"
47 }
48 zle -N help-show-magic-abbrevs
49 bindkey '\e?' help-show-magic-abbrevs
50
51 # vim:ft=zsh