README.md 1.02 KB
Newer Older
1
# Globalias plugin
slavaGanzin's avatar
slavaGanzin committed
2

3
Expands all glob expressions, subcommands and aliases (including global).
slavaGanzin's avatar
slavaGanzin committed
4

Janosch Schwalm's avatar
Janosch Schwalm committed
5
Idea from: https://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

## 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
slavaGanzin's avatar
slavaGanzin committed
23
24
25

```
$ touch {1..10}<space>
26
# expands to
slavaGanzin's avatar
slavaGanzin committed
27
28
$ touch 1 2 3 4 5 6 7 8 9 10

29
30
31
32
33
34
35
36
$ ls **/*.json<space>
# expands to
$ ls folder/file.json anotherfolder/another.json
```

#### Subcommands

```
slavaGanzin's avatar
slavaGanzin committed
37
$ mkdir "`date -R`"
38
# expands to
slavaGanzin's avatar
slavaGanzin committed
39
40
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300

41
42
43
44
45
46
```

#### Aliases

```
# .zshrc:
slavaGanzin's avatar
slavaGanzin committed
47
48
49
50
alias -g G="| grep --color=auto -P"
alias l='ls --color=auto -lah'

$ l<space>G<space>
51
# expands to
slavaGanzin's avatar
slavaGanzin committed
52
53
54
55
$ ls --color=auto -lah | grep --color=auto -P
```

```
56
# .zsrc:
slavaGanzin's avatar
slavaGanzin committed
57
58
59
alias S="sudo systemctl"

$ S<space>
60
61
# expands to:
$ sudo systemctl
slavaGanzin's avatar
slavaGanzin committed
62
```