2016-10-04 11:55:11 +00:00
|
|
|
# Globalias plugin
|
2016-10-04 11:03:37 +00:00
|
|
|
|
2016-10-04 11:55:11 +00:00
|
|
|
Expands all glob expressions, subcommands and aliases (including global).
|
2016-10-04 11:03:37 +00:00
|
|
|
|
2016-10-04 11:55:11 +00:00
|
|
|
Idea from: http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Add `globalias` to the plugins array in your zshrc file:
|
|
|
|
|
|
|
|
```zsh
|
|
|
|
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`.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
#### Glob expressions
|
2016-10-04 11:03:37 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
$ touch {1..10}<space>
|
2016-10-04 11:55:11 +00:00
|
|
|
# expands to
|
2016-10-04 11:03:37 +00:00
|
|
|
$ touch 1 2 3 4 5 6 7 8 9 10
|
|
|
|
|
2016-10-04 11:55:11 +00:00
|
|
|
$ ls **/*.json<space>
|
|
|
|
# expands to
|
|
|
|
$ ls folder/file.json anotherfolder/another.json
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Subcommands
|
|
|
|
|
|
|
|
```
|
2016-10-04 11:03:37 +00:00
|
|
|
$ mkdir "`date -R`"
|
2016-10-04 11:55:11 +00:00
|
|
|
# expands to
|
2016-10-04 11:03:37 +00:00
|
|
|
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
|
|
|
|
|
2016-10-04 11:55:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Aliases
|
|
|
|
|
|
|
|
```
|
|
|
|
# .zshrc:
|
2016-10-04 11:03:37 +00:00
|
|
|
alias -g G="| grep --color=auto -P"
|
|
|
|
alias l='ls --color=auto -lah'
|
|
|
|
|
|
|
|
$ l<space>G<space>
|
2016-10-04 11:55:11 +00:00
|
|
|
# expands to
|
2016-10-04 11:03:37 +00:00
|
|
|
$ ls --color=auto -lah | grep --color=auto -P
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
2016-10-04 11:55:11 +00:00
|
|
|
# .zsrc:
|
2016-10-04 11:03:37 +00:00
|
|
|
alias S="sudo systemctl"
|
|
|
|
|
|
|
|
$ S<space>
|
2016-10-04 11:55:11 +00:00
|
|
|
# expands to:
|
|
|
|
$ sudo systemctl
|
2016-10-04 11:03:37 +00:00
|
|
|
```
|