mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
c1910348c7
Based on https://github.com/Valodim/zsh-capture-completion `zpty -r` with a pattern seems to have some funky behavior on older versions, giving unpredictable results Don't use `-s` option to `zmodload`. It is not available in zsh versions older than 5.3 If running in sync mode and a completion takes a long time, the user can ^C out of it. We need to use `always` in the strategy function or the pty will not be destroyed in this case and the next time we go to create it, it will fail, making the shell unusable. User can have many different completion styles set that will modify what they've already typed. These styles will result in suggestions that don't match what the user has already typed. We try our best to unset some of the more problematic ones, but add some code to fetch to invalidate suggestions that don't match what the user's already typed.
23 lines
954 B
Bash
23 lines
954 B
Bash
|
|
#--------------------------------------------------------------------#
|
|
# Start #
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Start the autosuggestion widgets
|
|
_zsh_autosuggest_start() {
|
|
# By default we re-bind widgets on every precmd to ensure we wrap other
|
|
# wrappers. Specifically, highlighting breaks if our widgets are wrapped by
|
|
# zsh-syntax-highlighting widgets. This also allows modifications to the
|
|
# widget list variables to take effect on the next precmd. However this has
|
|
# a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND
|
|
# to disable the automatic re-binding.
|
|
if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then
|
|
add-zsh-hook -d precmd _zsh_autosuggest_start
|
|
fi
|
|
|
|
_zsh_autosuggest_bind_widgets
|
|
}
|
|
|
|
# Start the autosuggestion widgets on the next precmd
|
|
autoload -Uz add-zsh-hook
|
|
add-zsh-hook precmd _zsh_autosuggest_start
|