1globalias() { 2 # Get last word to the left of the cursor: 3 # (z) splits into words using shell parsing 4 # (A) makes it an array even if there's only one element 5 local word=${${(Az)LBUFFER}[-1]} 6 if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then 7 zle _expand_alias 8 zle expand-word 9 fi 10 zle self-insert 11} 12zle -N globalias 13 14# space expands all aliases, including global 15bindkey -M emacs " " globalias 16bindkey -M viins " " globalias 17 18# control-space to make a normal space 19bindkey -M emacs "^ " magic-space 20bindkey -M viins "^ " magic-space 21 22# normal space during searches 23bindkey -M isearch " " magic-space 24