Compare commits
8 Commits
0dab86133d
...
a562859b09
| Author | SHA1 | Date |
|---|---|---|
|
|
a562859b09 | |
|
|
85919cd1ff | |
|
|
dc8dcf7425 | |
|
|
da75fc226d | |
|
|
a00927c673 | |
|
|
33f442af07 | |
|
|
36f37f50d1 | |
|
|
6e15a2d3de |
|
|
@ -17,8 +17,9 @@
|
||||||
| Arch Linux / Manjaro / Antergos / Hyperbola | [zsh-autosuggestions](https://www.archlinux.org/packages/zsh-autosuggestions), [zsh-autosuggestions-git](https://aur.archlinux.org/packages/zsh-autosuggestions-git) |
|
| Arch Linux / Manjaro / Antergos / Hyperbola | [zsh-autosuggestions](https://www.archlinux.org/packages/zsh-autosuggestions), [zsh-autosuggestions-git](https://aur.archlinux.org/packages/zsh-autosuggestions-git) |
|
||||||
| NixOS | [zsh-autosuggestions](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/zs/zsh-autosuggestions/package.nix) |
|
| NixOS | [zsh-autosuggestions](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/zs/zsh-autosuggestions/package.nix) |
|
||||||
| Void Linux | [zsh-autosuggestions](https://github.com/void-linux/void-packages/blob/master/srcpkgs/zsh-autosuggestions/template) |
|
| Void Linux | [zsh-autosuggestions](https://github.com/void-linux/void-packages/blob/master/srcpkgs/zsh-autosuggestions/template) |
|
||||||
| Mac OS | [homebrew](https://github.com/Homebrew/homebrew-core/blob/master/Formula/z/zsh-autosuggestions.rb) |
|
| Mac OS | [homebrew](https://formulae.brew.sh/formula/zsh-autosuggestions) |
|
||||||
| NetBSD | [pkgsrc](http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/shells/zsh-autosuggestions/README.html) |
|
| NetBSD | [pkgsrc](http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/shells/zsh-autosuggestions/README.html) |
|
||||||
|
| FreeBSD | [pkg](https://cgit.freebsd.org/ports/tree/shells/zsh-autosuggestions) |
|
||||||
|
|
||||||
## Antigen
|
## Antigen
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,16 @@ _zsh_autosuggest_bind_widget() {
|
||||||
# correctly. $WIDGET cannot be trusted because other plugins call
|
# correctly. $WIDGET cannot be trusted because other plugins call
|
||||||
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
||||||
# `zle self-insert -w`).
|
# `zle self-insert -w`).
|
||||||
|
# Preserve the ZLE_KILL | ZLE_YANK flags for builtin widgets for ZSH >= 5.2
|
||||||
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
||||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
||||||
|
if [[ ! "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
|
case ${(q)widget} in
|
||||||
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';;
|
||||||
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';;
|
||||||
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,41 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
run-help
|
run-help
|
||||||
set-local-history
|
set-local-history
|
||||||
which-command
|
which-command
|
||||||
yank
|
|
||||||
yank-pop
|
yank-pop
|
||||||
zle-\*
|
zle-\*
|
||||||
)
|
)
|
||||||
|
if [[ "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
|
ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(yank)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pty name for capturing completions for completion suggestion strategy
|
# Pty name for capturing completions for completion suggestion strategy
|
||||||
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
||||||
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_KILL flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS=(
|
||||||
|
kill-\*
|
||||||
|
backward-kill-\*
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANK flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS=(
|
||||||
|
bracketed-paste
|
||||||
|
vi-put-after
|
||||||
|
yank
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANKBEFORE flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS=(
|
||||||
|
vi-put-before
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,16 +110,45 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
run-help
|
run-help
|
||||||
set-local-history
|
set-local-history
|
||||||
which-command
|
which-command
|
||||||
yank
|
|
||||||
yank-pop
|
yank-pop
|
||||||
zle-\*
|
zle-\*
|
||||||
)
|
)
|
||||||
|
if [[ "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
|
ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(yank)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pty name for capturing completions for completion suggestion strategy
|
# Pty name for capturing completions for completion suggestion strategy
|
||||||
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
||||||
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_KILL flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS=(
|
||||||
|
kill-\*
|
||||||
|
backward-kill-\*
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANK flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS=(
|
||||||
|
bracketed-paste
|
||||||
|
vi-put-after
|
||||||
|
yank
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANKBEFORE flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS=(
|
||||||
|
vi-put-before
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
# Utility Functions #
|
# Utility Functions #
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
@ -183,8 +212,16 @@ _zsh_autosuggest_bind_widget() {
|
||||||
# correctly. $WIDGET cannot be trusted because other plugins call
|
# correctly. $WIDGET cannot be trusted because other plugins call
|
||||||
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
||||||
# `zle self-insert -w`).
|
# `zle self-insert -w`).
|
||||||
|
# Preserve the ZLE_KILL | ZLE_YANK flags for builtin widgets for ZSH >= 5.2
|
||||||
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
||||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
||||||
|
if [[ ! "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
|
case ${(q)widget} in
|
||||||
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';;
|
||||||
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';;
|
||||||
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|
@ -859,9 +896,9 @@ autoload -Uz add-zsh-hook is-at-least
|
||||||
# older versions because there is a bug when using async mode where ^C does not
|
# older versions because there is a bug when using async mode where ^C does not
|
||||||
# work immediately after fetching a suggestion.
|
# work immediately after fetching a suggestion.
|
||||||
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||||
if is-at-least 5.0.8; then
|
# if is-at-least 5.0.8; then
|
||||||
typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=
|
# typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# Start the autosuggestion widgets on the next precmd
|
# Start the autosuggestion widgets on the next precmd
|
||||||
add-zsh-hook precmd _zsh_autosuggest_start
|
add-zsh-hook precmd _zsh_autosuggest_start
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue