mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-06 15:20:40 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b449a62f8 | ||
|
|
6d25df6864 | ||
|
|
0faa2b6584 | ||
|
|
a2d8d91196 | ||
|
|
dd9a8789a7 | ||
|
|
1b98af5b33 | ||
|
|
45ab49d1f2 | ||
|
|
41f15d5c9f |
@@ -38,7 +38,7 @@ _zsh_autosuggest_bind_widget() {
|
|||||||
# 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`).
|
||||||
eval "_zsh_autosuggest_bound_$widget() {
|
eval "_zsh_autosuggest_bound_$widget() {
|
||||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$widget $@
|
_zsh_autosuggest_widget_$autosuggest_action $prefix$widget \$@
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ _zsh_autosuggest_suggestion() {
|
|||||||
setopt localoptions extendedglob
|
setopt localoptions extendedglob
|
||||||
|
|
||||||
# Escape the prefix (requires EXTENDED_GLOB)
|
# Escape the prefix (requires EXTENDED_GLOB)
|
||||||
local prefix=${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}
|
local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}"
|
||||||
|
|
||||||
# Get all history items (reversed) that match pattern $prefix*
|
# Get all history items (reversed) that match pattern $prefix*
|
||||||
local history_matches
|
local history_matches
|
||||||
history_matches=(${history[(R)$prefix*]})
|
history_matches=(${(j:\0:s:\0:)history[(R)$prefix*]})
|
||||||
|
|
||||||
# Echo the first item that matches
|
# Echo the first item that matches
|
||||||
echo ${history_matches[1]}
|
echo "$history_matches[1]"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ _zsh_autosuggest_modify() {
|
|||||||
# Get a new suggestion if the buffer is not empty after modification
|
# Get a new suggestion if the buffer is not empty after modification
|
||||||
local suggestion
|
local suggestion
|
||||||
if [ $#BUFFER -gt 0 ]; then
|
if [ $#BUFFER -gt 0 ]; then
|
||||||
suggestion=$(_zsh_autosuggest_suggestion $BUFFER)
|
suggestion=$(_zsh_autosuggest_suggestion "$BUFFER")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the suggestion to the POSTDISPLAY
|
# Add the suggestion to the POSTDISPLAY
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
||||||
# https://github.com/tarruda/zsh-autosuggestions
|
# https://github.com/tarruda/zsh-autosuggestions
|
||||||
# v0.2.6
|
# v0.2.10
|
||||||
# Copyright (c) 2013 Thiago de Arruda
|
# Copyright (c) 2013 Thiago de Arruda
|
||||||
# Copyright (c) 2016 Eric Freese
|
# Copyright (c) 2016 Eric Freese
|
||||||
#
|
#
|
||||||
@@ -140,7 +140,7 @@ _zsh_autosuggest_bind_widget() {
|
|||||||
# 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`).
|
||||||
eval "_zsh_autosuggest_bound_$widget() {
|
eval "_zsh_autosuggest_bound_$widget() {
|
||||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$widget $@
|
_zsh_autosuggest_widget_$autosuggest_action $prefix$widget \$@
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
@@ -219,7 +219,7 @@ _zsh_autosuggest_modify() {
|
|||||||
# Get a new suggestion if the buffer is not empty after modification
|
# Get a new suggestion if the buffer is not empty after modification
|
||||||
local suggestion
|
local suggestion
|
||||||
if [ $#BUFFER -gt 0 ]; then
|
if [ $#BUFFER -gt 0 ]; then
|
||||||
suggestion=$(_zsh_autosuggest_suggestion $BUFFER)
|
suggestion=$(_zsh_autosuggest_suggestion "$BUFFER")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the suggestion to the POSTDISPLAY
|
# Add the suggestion to the POSTDISPLAY
|
||||||
@@ -291,14 +291,14 @@ _zsh_autosuggest_suggestion() {
|
|||||||
setopt localoptions extendedglob
|
setopt localoptions extendedglob
|
||||||
|
|
||||||
# Escape the prefix (requires EXTENDED_GLOB)
|
# Escape the prefix (requires EXTENDED_GLOB)
|
||||||
local prefix=${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}
|
local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}"
|
||||||
|
|
||||||
# Get all history items (reversed) that match pattern $prefix*
|
# Get all history items (reversed) that match pattern $prefix*
|
||||||
local history_matches
|
local history_matches
|
||||||
history_matches=(${history[(R)$prefix*]})
|
history_matches=(${(j:\0:s:\0:)history[(R)$prefix*]})
|
||||||
|
|
||||||
# Echo the first item that matches
|
# Echo the first item that matches
|
||||||
echo ${history_matches[1]}
|
echo "$history_matches[1]"
|
||||||
}
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user