zsh-alias-expand-space

March 16, 2026 ยท View on GitHub

Expand command-position Zsh aliases when you press space.

What it does

If you type:

gc

and then press space, the plugin turns it into:

git checkout 

This uses Zsh's _expand_alias completion helper and binds the space key to a small widget that expands the alias and then inserts a literal space.

Install

Source the plugin directly:

source /path/to/zsh-alias-expand-space.plugin.zsh

Or load it with your usual Zsh plugin manager.

Configuration

ZSH_ALIAS_EXPAND_SPACE_BIND_SPACE

Default: 1

When set to 1, bind the space key to the plugin widget.

When set to 0, load the widget definitions but do not bind space.

Example:

typeset -g ZSH_ALIAS_EXPAND_SPACE_BIND_SPACE=0

Set configuration before sourcing the plugin.

ZSH_ALIAS_EXPAND_SPACE_CONFIG

Default:

${XDG_CONFIG_HOME:-$HOME/.config}/zsh/aliases.conf.zsh

If the file exists, the plugin sources it before applying defaults. This lets a repo-managed shell setup keep the option in a tracked config file without editing the plugin loader.

Notes

  • This is intended for interactive shells only.
  • It only helps with normal command-position aliases.
  • If you have other plugins that also remap space, the last one loaded wins.

License

MIT