globalias: allow filtering values not to be expanded (#9331)
This commit is contained in:
parent
fb80eb8e05
commit
82856bfbd8
|
@ -17,6 +17,9 @@ 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
|
If you only want to insert a space without expanding the command line, press
|
||||||
`CTRL`+`SPACE`.
|
`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](#filtered-values).
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
#### Glob expressions
|
#### Glob expressions
|
||||||
|
@ -37,7 +40,6 @@ $ ls folder/file.json anotherfolder/another.json
|
||||||
$ mkdir "`date -R`"
|
$ mkdir "`date -R`"
|
||||||
# expands to
|
# expands to
|
||||||
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
|
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Aliases
|
#### Aliases
|
||||||
|
@ -60,3 +62,18 @@ $ S<space>
|
||||||
# expands to:
|
# expands to:
|
||||||
$ sudo systemctl
|
$ sudo systemctl
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Filtered values
|
||||||
|
|
||||||
|
```
|
||||||
|
# .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
|
||||||
|
```
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
globalias() {
|
globalias() {
|
||||||
zle _expand_alias
|
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$LBUFFER] -eq 0 ]]; then
|
||||||
zle expand-word
|
zle _expand_alias
|
||||||
|
zle expand-word
|
||||||
|
fi
|
||||||
zle self-insert
|
zle self-insert
|
||||||
}
|
}
|
||||||
zle -N globalias
|
zle -N globalias
|
||||||
|
|
Loading…
Reference in a new issue