1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# `zsh-autocomplete`
`zsh-autocomplete` adds **real-time type-ahead autocompletion** to Zsh. Find as you type, then
press <kbd>Tab</kbd> to insert the top completion, <kbd>Shift</kbd><kbd>Tab</kbd> to insert the
bottom one, or <kbd>↓</kbd>/<kbd>PgDn</kbd> to select another completion.
[](https://asciinema.org/a/377611)
> Enjoy using this software? [Become a sponsor!](https://github.com/sponsors/marlonrichert).
## Other Features
Besides live autocompletion, `zsh-autocomplete` comes with many other useful completion features.
### Optimized completion config
Zsh's completion system is powerful, but hard to configure. So, `zsh-autocomplete` [does it for
you](scripts/.autocomplete.config), while providing a manageable list of [configuration
settings](.zshrc) for changing the defaults.
### Live history search
Press <kbd>Ctrl</kbd><kbd>R</kbd> or <kbd>Ctrl</kbd><kbd>S</kbd> to do live, multi-line history
search.
[](https://asciinema.org/a/379844)
### History menu
Press <kbd>↑</kbd> (or <kbd>Alt</kbd><kbd>↑</kbd> or <kbd>PgUp</kbd>) to open a menu with the last
16 history items. If the command line is not empty, then the contents of the command line are used
to perform a fuzzy history search.

### Multi-selection
Press <kbd>Ctrl</kbd><kbd>Space</kbd> in the completion menu or the history menu to insert more
than one item.

### Recent dirs completion
Works out of the box with zero configuration, but also supports `zsh-z`, `zoxide`, `z.lua`,
`rupa/z.sh`, `autojump` and `fasd`.

## Key Bindings
On the command line:
| Key(s) | Action | <sub>[Widget](.zshrc)</sub> |
| ------ | ------ | --- |
| <kbd>Tab</kbd> | Insert top completion | <sub>`complete-word`</sub> |
| <kbd>Shift</kbd><kbd>Tab</kbd> | Insert bottom completion | <sub>`complete-word`</sub> |
| <kbd>Ctrl</kbd><kbd>Space</kbd> | Show additional completions | <sub>`list-expand`</sub> |
| <kbd>↓</kbd> | Cursor down (if able) or completion menu | <sub>`down-line-or-select`</sub> |
| <kbd>PgDn</kbd> / <kbd>Alt</kbd><kbd>↓</kbd> | Completion menu (always) | <sub>`menu-select`</sub> |
| <kbd>↑</kbd> | Cursor up (if able) or [history menu](#history-menu) | <sub>`up-line-or-search`</sub> |
| <kbd>PgUp</kbd> / <kbd>Alt</kbd><kbd>↑</kbd> | [History menu](#history-menu) (always) | <sub>`history-search`</sub> |
| <kbd>Ctrl</kbd><kbd>R</kbd> | [Live history search](#live-history-search), newest to oldest | <sub>`history-incremental-search-backward`</sub> |
| <kbd>Ctrl</kbd><kbd>S</kbd> | [Live history search](#live-history-search), oldest to newest | <sub>`history-incremental-search-forward`</sub> |
In the completion menu:
| Key(s) | Action |
| ------ | ------ |
| <kbd>↑</kbd> / <kbd>↓</kbd> / <kbd>←</kbd> / <kbd>→</kbd> | Change selection |
| <kbd>Alt</kbd><kbd>↑</kbd> | Backward one group |
| <kbd>Alt</kbd><kbd>↓</kbd> | Forward one group |
| <kbd>PgUp</kbd> / <kbd>PgDn</kbd> | Page up/down |
| <kbd>Ctrl</kbd><kbd>R</kbd> | Find text forward |
| <kbd>Ctrl</kbd><kbd>S</kbd> | Find text backward |
| <kbd>Tab</kbd> | Insert selection and exit menu |
| <kbd>Ctrl</kbd><kbd>Space</kbd> | Insert selection, but stay in menu |
| <kbd>Shift</kbd><kbd>Tab</kbd> | Insert bottom completion and exit menu |
| <kbd>Ctrl</kbd><kbd>-</kbd><br><kbd>Ctrl</kbd><kbd>/</kbd> | Undo and exit menu |
| <kbd>Enter</kbd> | Submit command line |
| other keys | Zsh [default behavior](https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#Menu-selection) |
In the history menu:
| Key(s) | Action |
| --- | --- |
| <kbd>↑</kbd> / <kbd>↓</kbd> | Change selection |
| <kbd>Tab</kbd> | Insert selection and exit menu |
| <kbd>Ctrl</kbd><kbd>Space</kbd> | Insert selection, but stay in menu |
| <kbd>Ctrl</kbd><kbd>-</kbd><br><kbd>Ctrl</kbd><kbd>/</kbd> | Undo and exit menu |
| <kbd>Enter</kbd> | Submit command line |
| other keys | Zsh [default behavior](https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#Menu-selection) |
## Requirements
Recommended:
* Tested to work with [Zsh](http://zsh.sourceforge.net) 5.7 or newer.
Minimum:
* Should theoretically work with Zsh 5.4 or newer, but I'm unable to test that.
## Installing & Updating
If you use [Znap](https://github.com/marlonrichert/zsh-snap), simply add the following to your
`.zshrc` file:
```zsh
znap source marlonrichert/zsh-autocomplete
```
Then restart your shell.
To update, do
```zsh
% znap pull
```
For configuration options, see the included [`.zshrc` file](.zshrc).
To uninstall, remove `znap source marlonrichert/zsh-autocomplete` from your `.zshrc` file, then run
```zsh
% znap uninstall
```
### Manual installation
1. Clone the repo:
```zsh
% cd ~/Git # ...or wherever you keep your Git repos/Zsh plugins
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
```
1. Add at or near the top of your `.zshrc` file (_before_ any calls to `compdef`):
```zsh
source ~/Git/zsh-autocomplete/zsh-autocomplete.plugin.zsh
```
1. Remove any calls to `compinit` from your `.zshrc` file.
1. If you're using Ubuntu, add to your `.zshenv` file:
```zsh
skip_global_compinit=1
```
Then restart your shell.
To update, do:
```zsh
% git -C ~zsh-autocomplete pull
```
To uninstall, simply undo the installation steps above in reverse order:
1. Restore the lines you deleted in step 3.
1. Delete the line you added in step 2.
1. Delete the repo you created in step 1.
Finally, restart your shell.
### Other Frameworks/Plugin Managers
To install with another Zsh framework or plugin manager, please refer to your
framework's/plugin manager's documentation for instructions.
## Troubleshooting
Try the steps in the [bug report template](.github/ISSUE_TEMPLATE/bug-report.md).
## Author
© 2020-2021 [Marlon Richert](https://github.com/marlonrichert)
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|