globalias.plugin.zsh 637 B

1234567891011121314151617181920212223
  1. globalias() {
  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. }
  12. zle -N globalias
  13. # space expands all aliases, including global
  14. bindkey -M emacs " " globalias
  15. bindkey -M viins " " globalias
  16. # control-space to make a normal space
  17. bindkey -M emacs "^ " magic-space
  18. bindkey -M viins "^ " magic-space
  19. # normal space during searches
  20. bindkey -M isearch " " magic-space