2013-10-26 18:05:17 +02:00
|
|
|
# zsh-autosuggestions
|
|
|
|
|
2013-10-29 20:08:56 +01:00
|
|
|
> [Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for zsh.
|
|
|
|
> [Shelr demo](http://shelr.tv/records/527007a99660803c5d000048).
|
2013-10-26 18:05:17 +02:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2013-11-08 00:17:10 +01:00
|
|
|
```sh
|
2013-10-26 18:05:17 +02:00
|
|
|
git clone git://github.com/tarruda/zsh-autosuggestions ~/.zsh-autosuggestions
|
2013-11-08 00:17:10 +01:00
|
|
|
|
2013-10-26 18:05:17 +02:00
|
|
|
cat >> ~/.zshrc << "EOF"
|
|
|
|
source ~/.zsh-autosuggestions/autosuggestions.zsh
|
2013-11-08 00:17:10 +01:00
|
|
|
|
2013-10-26 18:05:17 +02:00
|
|
|
# Enable autosuggestions automatically
|
|
|
|
zle-line-init() {
|
2013-10-29 18:32:51 +01:00
|
|
|
zle autosuggest-start
|
2013-10-26 18:05:17 +02:00
|
|
|
}
|
|
|
|
zle -N zle-line-init
|
2013-11-08 00:17:10 +01:00
|
|
|
|
2013-11-08 12:20:57 +01:00
|
|
|
# use ctrl+t to toggle autosuggestions(hopefully this wont be needed as
|
2013-11-08 12:24:02 +01:00
|
|
|
# zsh-autosuggestions is designed to be unobtrusive)
|
2013-10-29 18:32:51 +01:00
|
|
|
bindkey '^T' autosuggest-toggle
|
2014-01-25 23:44:37 +01:00
|
|
|
EOF
|
2013-11-08 12:20:57 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Any widget that moves the cursor to the right(forward-word, forward-char...)
|
|
|
|
will accept parts of the suggested text. For example, vi-mode users can do
|
|
|
|
this:
|
2013-11-08 00:17:10 +01:00
|
|
|
|
2013-11-08 12:20:57 +01:00
|
|
|
```sh
|
|
|
|
# Accept suggestions without leaving insert mode
|
|
|
|
bindkey '^f' vi-forward-word
|
2013-12-03 20:25:52 +01:00
|
|
|
# or
|
2013-11-08 12:20:57 +01:00
|
|
|
bindkey '^f' vi-forward-blank-word
|
2013-10-26 18:05:17 +02:00
|
|
|
```
|
2013-11-08 12:20:57 +01:00
|
|
|
|
|
|
|
Emacs-mode users can simply use alt+f which is bound to forward-word
|
|
|
|
|
|
|
|
The [zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search)
|
|
|
|
plugin is also recommended.
|
2013-12-03 20:45:56 +01:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
You may override default global config variables after plugin load.
|
|
|
|
|
|
|
|
- `AUTOSUGGESTION_HIGHLIGHT_COLOR`: suggestion highlight color, default is `'fg=8'`.
|
|
|
|
- `AUTOSUGGESTION_HIGHLIGHT_CURSOR`: highlight word after cursor or not. Must be integer value `1` or `0`, default is `1`.
|