This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See: chisui/zsh-nix-shell#31 Also update globalias from upstream.
- Loading branch information
1 parent
0b4644b
commit bf4869a
Showing
2 changed files
with
27 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
globalias() { | ||
zle _expand_alias | ||
zle self-insert | ||
# 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]} | ||
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then | ||
zle _expand_alias | ||
zle expand-word | ||
fi | ||
zle self-insert | ||
} | ||
|
||
zle -N globalias | ||
|
||
bindkey " " magic-space | ||
bindkey "^ " globalias | ||
bindkey -M isearch " " magic-space # normal space during searches | ||
# space expands all aliases, including global | ||
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 | ||
|
||
# normal space during searches | ||
bindkey -M isearch " " magic-space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters