mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-08 04:34:00 +02:00
Merge 6a67c11930 into 291e96dcd0
This commit is contained in:
commit
13b68de080
2 changed files with 47 additions and 0 deletions
25
plugins/expand_aliases/README.md
Normal file
25
plugins/expand_aliases/README.md
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# expand-aliases
|
||||||
|
|
||||||
|
**Maintainer:** [Jarmo Pertman](https://github.com/jarmo)
|
||||||
|
|
||||||
|
This plugin expands aliases while typing them in terminal.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
```zsh
|
||||||
|
alias foo="bar baz"
|
||||||
|
|
||||||
|
$ foo
|
||||||
|
# pressing space will expand that alias to... surprise, surprise
|
||||||
|
$ bar baz
|
||||||
|
```
|
||||||
|
|
||||||
|
To **skip** expansion, use `control-space` instead of just `space`.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Just add it to `oh-my-zsh` plugins list in `~/.zshrc`, but make sure it is added last (or not
|
||||||
|
last if you prefer some aliases not to be expanded).
|
||||||
|
|
||||||
|
`
|
||||||
|
plugins=(... expand-aliases)
|
||||||
|
`
|
||||||
22
plugins/expand_aliases/expand-aliases.plugin.zsh
Normal file
22
plugins/expand_aliases/expand-aliases.plugin.zsh
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Expand aliases when typing
|
||||||
|
#
|
||||||
|
# Read README.md for setup instructions.
|
||||||
|
#
|
||||||
|
# Initially inspired by Gautam Iyer (https://wiki.math.cmu.edu/iki/wiki/tips/20140625-zsh-expand-alias.html)
|
||||||
|
|
||||||
|
typeset -a ealiases
|
||||||
|
ealiases=(`alias | sed -e 's/=.*//'`)
|
||||||
|
|
||||||
|
_expand-ealias() {
|
||||||
|
if [[ $LBUFFER =~ "(^|[;|&])\s*(${(j:|:)ealiases})\$" ]]; then
|
||||||
|
zle _expand_alias
|
||||||
|
zle expand-word
|
||||||
|
fi
|
||||||
|
zle magic-space
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N _expand-ealias
|
||||||
|
|
||||||
|
bindkey ' ' _expand-ealias
|
||||||
|
bindkey '^ ' magic-space # control-space to bypass completion
|
||||||
|
bindkey -M isearch " " magic-space # normal space during searches
|
||||||
Loading…
Add table
Add a link
Reference in a new issue