Marc Cornellà 53cbd658f5 globalias: use ${(z)var} to split into words using shell parsing | 4 年之前 | |
---|---|---|
.. | ||
README.md | 4 年之前 | |
globalias.plugin.zsh | 4 年之前 |
Expands all glob expressions, subcommands and aliases (including global).
Idea from: https://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html.
Add globalias
to the plugins array in your zshrc file:
plugins=(... globalias)
Then just press SPACE
to trigger the expansion of a command you've written.
If you only want to insert a space without expanding the command line, press
CTRL
+SPACE
.
if you would like to filter out any values from expanding set GLOBALIAS_FILTER_VALUES
to
an array of said values. See Filtered values.
$ touch {1..10}<space>
# expands to
$ touch 1 2 3 4 5 6 7 8 9 10
$ ls **/*.json<space>
# expands to
$ ls folder/file.json anotherfolder/another.json
$ mkdir "`date -R`"
# expands to
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
# .zshrc:
alias -g G="| grep --color=auto -P"
alias l='ls --color=auto -lah'
$ l<space>G<space>
# expands to
$ ls --color=auto -lah | grep --color=auto -P
# .zsrc:
alias S="sudo systemctl"
$ S<space>
# expands to:
$ sudo systemctl
# .zshrc
alias l='ls -lh'
alias la='ls --color=auto -lah'
GLOBALIAS_FILTER_VALUES=(l)
$ l<space>
# does not expand
$ la<space>
# expands to:
$ ls --color=auto -lah