From ff9b9013947f210bc121018ea7911f621c1f791b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20VANTOMME?= <akarzim@gmail.com>
Date: Thu, 2 Nov 2017 01:00:32 +0100
Subject: [PATCH] Set key binding (^space) to expand all aliases including
 global (#1500)

---
 modules/editor/init.zsh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh
index e5fee927..415d6530 100644
--- a/modules/editor/init.zsh
+++ b/modules/editor/init.zsh
@@ -226,6 +226,14 @@ function prepend-sudo {
 }
 zle -N prepend-sudo
 
+# Expand aliases
+function glob-alias {
+  zle _expand_alias
+  zle expand-word
+  zle magic-space
+}
+zle -N glob-alias
+
 # Reset to default key bindings.
 bindkey -d
 
@@ -368,6 +376,9 @@ for keymap in 'emacs' 'viins'; do
 
   # Insert 'sudo ' at the beginning of the line.
   bindkey -M "$keymap" "$key_info[Control]X$key_info[Control]S" prepend-sudo
+
+  # control-space expands all aliases, including global
+  bindkey -M "$keymap" "$key_info[Control] " glob-alias
 done
 
 # Delete key deletes character in vimcmd cmd mode instead of weird default functionality