globalias.plugin.zsh 637 Bytes
Newer Older
slavaGanzin's avatar
slavaGanzin committed
1
globalias() {
2
3
4
5
   # Get last word to the left of the cursor:
   # (z) splits into words using shell parsing
   # (A) makes it an array even if there's only one element
   local word=${${(Az)LBUFFER}[-1]}
6
   if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
7
8
9
      zle _expand_alias
      zle expand-word
   fi
slavaGanzin's avatar
slavaGanzin committed
10
11
12
   zle self-insert
}
zle -N globalias
slavaGanzin's avatar
slavaGanzin committed
13

slavaGanzin's avatar
slavaGanzin committed
14
# space expands all aliases, including global
slavaGanzin's avatar
slavaGanzin committed
15
16
17
18
19
20
bindkey -M emacs " " globalias
bindkey -M viins " " globalias

# control-space to make a normal space
bindkey -M emacs "^ " magic-space
bindkey -M viins "^ " magic-space
slavaGanzin's avatar
slavaGanzin committed
21
22
23

# normal space during searches
bindkey -M isearch " " magic-space