diff --git a/.gitmodules b/.gitmodules index a8a9e57a..518a2795 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "modules/prompt/functions/pure"] path = modules/prompt/external/pure url = https://github.com/sindresorhus/pure.git +[submodule "modules/autosuggestions/external"] + path = modules/autosuggestions/external + url = https://github.com/tarruda/zsh-autosuggestions diff --git a/modules/README.md b/modules/README.md index 2a49804c..db851f36 100644 --- a/modules/README.md +++ b/modules/README.md @@ -10,6 +10,11 @@ Archive Provides functions to list and extract archives. +Autosuggestions +--------------- + +Integrates zsh-autosuggestions into Prezto. + Command-Not-Found ----------------- diff --git a/modules/autosuggestions/README.md b/modules/autosuggestions/README.md new file mode 100644 index 00000000..70243798 --- /dev/null +++ b/modules/autosuggestions/README.md @@ -0,0 +1,53 @@ +Autosuggestions +--------------- + +Integrates zsh-autosuggestions into Prezto. + +Autosuggestions +=============== + +Integrates [zsh-autosuggestions][1] into Prezto, which implements the +[Fish shell][2]'s autosuggestions feature, where the user can type in any part +of a previously entered command and Zsh suggests commands as you type based on +history and completions. + +If this module is used in conjuncture with the *syntax-highlighting* module, it +must be loaded **after** it. + +If this module is used in conjuncture with the *history-substring-search* +module, it must be loaded **after** it. + +Contributors +------------ + +New features and bug fixes should be submitted to the [zsh-autosuggestions][1] +project according to its rules and regulations. This module will be synchronized +against it. + +Settings +-------- + +### Highlighting + +If colors are enabled, *autosuggestions* will automatically highlight +positive results. + +To enable highlighting for this module only, add the following line to +*zpreztorc*: + + zstyle ':prezto:module:autosuggestions' color 'yes' + +To set the query found color, add the following line to *zpreztorc*: + + zstyle ':prezto:module:autosuggestions:color' found '' + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][3].* + + - [Sorin Ionescu](https://github.com/sorin-ionescu) + +[1]: https://github.com/tarruda/zsh-autosuggestions +[2]: http://fishshell.com +[3]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/autosuggestions/external b/modules/autosuggestions/external new file mode 160000 index 00000000..f0a74557 --- /dev/null +++ b/modules/autosuggestions/external @@ -0,0 +1 @@ +Subproject commit f0a745576ff69fa608421ee7214d4cd77b43e62f diff --git a/modules/autosuggestions/init.zsh b/modules/autosuggestions/init.zsh new file mode 100644 index 00000000..a3a772e5 --- /dev/null +++ b/modules/autosuggestions/init.zsh @@ -0,0 +1,35 @@ +# +# Integrates zsh-autosuggestions into Prezto. +# +# Authors: +# Sorin Ionescu +# + +# Load dependencies. +pmodload 'editor' + +# Source module files. +source "${0:h}/external/zsh-autosuggestions.zsh" || return 1 + +# +# Highlighting +# + +# Set highlight color, default 'fg=8'. +zstyle -s ':prezto:module:autosuggestions:color' found \ + 'ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE' || ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + +# Disable highlighting. +if ! zstyle -t ':prezto:module:autosuggestions' color; then + ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='' +fi + +# +# Key Bindings +# + +if [[ -n "$key_info" ]]; then + # vi + bindkey -M viins "$key_info[Control]F" vi-forward-word + bindkey -M viins "$key_info[Control]E" vi-add-eol +fi diff --git a/modules/completion/external b/modules/completion/external index c2dde89f..3a2bb878 160000 --- a/modules/completion/external +++ b/modules/completion/external @@ -1 +1 @@ -Subproject commit c2dde89fb34e2734106e50689bf4127f6b0a288d +Subproject commit 3a2bb8781d32d05d1bf05deeeb476beb651e8272 diff --git a/modules/history-substring-search/external b/modules/history-substring-search/external index 2c295432..7a4b54b7 160000 --- a/modules/history-substring-search/external +++ b/modules/history-substring-search/external @@ -1 +1 @@ -Subproject commit 2c295432175990c1bb4e90bc13f609daa67a25d6 +Subproject commit 7a4b54b708ab88e0421097614f1acaa7a973c795 diff --git a/modules/prompt/external/pure b/modules/prompt/external/pure index 95e7fd7d..fb4c37da 160000 --- a/modules/prompt/external/pure +++ b/modules/prompt/external/pure @@ -1 +1 @@ -Subproject commit 95e7fd7de7af9cf68678c31cac22b79816b44c90 +Subproject commit fb4c37dad3c5cbdebca61a8ff5545397c11d450f diff --git a/modules/syntax-highlighting/external b/modules/syntax-highlighting/external index 44e5323b..7044c198 160000 --- a/modules/syntax-highlighting/external +++ b/modules/syntax-highlighting/external @@ -1 +1 @@ -Subproject commit 44e5323b53edd221a79a585869cf4833d555ba58 +Subproject commit 7044c1986e2f6b15eec27a03651207fccb0a2fbe diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 4778944c..e93ac6bf 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -34,6 +34,13 @@ zstyle ':prezto:load' pmodule \ 'completion' \ 'prompt' +# +# Autosuggestions +# + +# Set the query found color. +# zstyle ':prezto:module:autosuggestions:color' found '' + # # Editor # @@ -121,6 +128,7 @@ zstyle ':prezto:module:prompt' theme 'sorin' # 'main' \ # 'brackets' \ # 'pattern' \ +# 'line' \ # 'cursor' \ # 'root' #