Compare commits

...

8 Commits

Author SHA1 Message Date
Eric Freese
cd71081303 bump version v0.2.4 2016-02-14 01:08:21 -07:00
Eric Freese
9788c2ee49 Fix deprecation warnings. 2016-02-14 01:07:05 -07:00
Eric Freese
ebcfc46b72 Comment formatting 2016-02-14 00:29:43 -07:00
Eric Freese
b49d002888 [README] Add example of minimal .zshrc. 2016-02-13 23:53:32 -07:00
Eric Freese
266437c98a bump version v0.2.3 2016-02-13 23:47:24 -07:00
Eric Freese
51b39e210e Bound widgets now handle arguments correctly 2016-02-13 23:46:34 -07:00
Eric Freese
011f5420fc Version bump v0.2.2 2016-02-13 21:15:33 -07:00
Eric Freese
1a38fbf6a5 [README] Add note about workaround for bpm bug. 2016-02-13 21:14:59 -07:00
10 changed files with 84 additions and 90 deletions

View File

@@ -40,7 +40,7 @@ It suggests commands as you type, based on command history.
3. Start a new terminal session. 3. Start a new terminal session.
> **Note:** There is an open issue ([#102](https://github.com/tarruda/zsh-autosuggestions/issues/102)) when using this plugin with `bracketed-paste-magic`, which is enabled by default by Oh My Zsh. **Note:** There is an open issue ([#102](https://github.com/tarruda/zsh-autosuggestions/issues/102)) when using this plugin with `bracketed-paste-magic`, which is enabled by default by Oh My Zsh. See the comments in that issue for a workaround.
## Usage ## Usage
@@ -132,7 +132,7 @@ Before reporting an issue, please try temporarily disabling sections of your con
When reporting an issue, please include: When reporting an issue, please include:
- The smallest, simplest `.zshrc` configuration that will reproduce the problem - The smallest, simplest `.zshrc` configuration that will reproduce the problem. See [this comment](https://github.com/tarruda/zsh-autosuggestions/issues/102#issuecomment-180944764) for a good example of what this means.
- The version of zsh you're using (`zsh --version`) - The version of zsh you're using (`zsh --version`)
- Which operating system you're running - Which operating system you're running

View File

@@ -1 +1 @@
v0.2.0 v0.2.4

View File

@@ -1,7 +1,7 @@
#----------------# #--------------------------------------------------------------------#
# Widget Helpers # # Widget Helpers #
#----------------# #--------------------------------------------------------------------#
# Bind a single widget to an autosuggest widget, saving a reference to the original widget # Bind a single widget to an autosuggest widget, saving a reference to the original widget
_zsh_autosuggest_bind_widget() { _zsh_autosuggest_bind_widget() {
@@ -34,9 +34,9 @@ _zsh_autosuggest_bind_widget() {
# Set up widget to call $autosuggest_function if it exists # Set up widget to call $autosuggest_function if it exists
# Otherwise just call the original widget # Otherwise just call the original widget
if [ -n "$autosuggest_function" ]; then; if [ -n "$autosuggest_function" ]; then;
action=$autosuggest_function; action="$autosuggest_function \$@";
else; else;
action="zle $prefix$widget \$@" action="zle $prefix$widget -- \$@"
fi fi
# Create new function for the widget that highlights and calls the action # Create new function for the widget that highlights and calls the action
@@ -55,7 +55,7 @@ _zsh_autosuggest_bind_widgets() {
local widget; local widget;
# Find every widget we might want to bind and bind it appropriately # Find every widget we might want to bind and bind it appropriately
for widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|autosuggest-*|$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX*|run-help|which-command|beep|set-local-history|yank)}; do for widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|autosuggest-*|$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX*|zle-line-*|run-help|which-command|beep|set-local-history|yank)}; do
if [ ${ZSH_AUTOSUGGEST_MODIFY_WIDGETS[(r)$widget]} ]; then if [ ${ZSH_AUTOSUGGEST_MODIFY_WIDGETS[(r)$widget]} ]; then
_zsh_autosuggest_bind_widget $widget _zsh_autosuggest_modify _zsh_autosuggest_bind_widget $widget _zsh_autosuggest_modify
elif [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then elif [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
@@ -72,9 +72,9 @@ _zsh_autosuggest_bind_widgets() {
# Given the name of a widget, invoke the original we saved, if it exists # Given the name of a widget, invoke the original we saved, if it exists
_zsh_autosuggest_invoke_original_widget() { _zsh_autosuggest_invoke_original_widget() {
local original_widget_name="$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX$1" local original_widget_name="$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX$WIDGET"
if [ $widgets[$original_widget_name] ]; then if [ $widgets[$original_widget_name] ]; then
zle $original_widget_name zle $original_widget_name -- $@
fi fi
} }

View File

@@ -1,7 +1,7 @@
#--------------------------------# #--------------------------------------------------------------------#
# Global Configuration Variables # # Global Configuration Variables #
#--------------------------------# #--------------------------------------------------------------------#
# Color to use when highlighting suggestion # Color to use when highlighting suggestion
# Uses format of `region_highlight` # Uses format of `region_highlight`

View File

@@ -1,9 +1,11 @@
#-------------------------------------# #--------------------------------------------------------------------#
# Handle Deprecated Variables/Widgets # # Handle Deprecated Variables/Widgets #
#-------------------------------------# #--------------------------------------------------------------------#
unset _ZSH_AUTOSUGGEST_DEPRECATED_START_WIDGET_WARNING_SHOWN _zsh_autosuggest_deprecated_warning() {
>&2 echo "zsh-autosuggestions: $@"
}
_zsh_autosuggest_check_deprecated_config() { _zsh_autosuggest_check_deprecated_config() {
if [ -n "$AUTOSUGGESTION_HIGHLIGHT_COLOR" ]; then if [ -n "$AUTOSUGGESTION_HIGHLIGHT_COLOR" ]; then
@@ -23,17 +25,12 @@ _zsh_autosuggest_check_deprecated_config() {
fi fi
} }
_zsh_autosuggest_deprecated_warning() {
>&2 echo "zsh-autosuggestions: $@"
}
_zsh_autosuggest_deprecated_start_widget() { _zsh_autosuggest_deprecated_start_widget() {
if [ -z "$_ZSH_AUTOSUGGEST_DEPRECATED_START_WIDGET_WARNING_SHOWN" ]; then _zsh_autosuggest_deprecated_warning "The autosuggest-start widget is deprecated. For more info, see the README at https://github.com/tarruda/zsh-autosuggestions."
_zsh_autosuggest_deprecated_warning "The autosuggest-start widget is deprecated. Use the autosuggest_start function instead. For more info, see README at https://github.com/tarruda/zsh-autosuggestions." zle -D autosuggest-start
_ZSH_AUTOSUGGEST_DEPRECATED_START_WIDGET_WARNING_SHOWN=true eval "zle-line-init() {
fi $(echo $functions[${widgets[zle-line-init]#*:}] | sed -e 's/zle autosuggest-start//g')
}"
autosuggest_start
} }
zle -N autosuggest-start _zsh_autosuggest_deprecated_start_widget zle -N autosuggest-start _zsh_autosuggest_deprecated_start_widget

View File

@@ -1,7 +1,7 @@
#--------------# #--------------------------------------------------------------------#
# Highlighting # # Highlighting #
#--------------# #--------------------------------------------------------------------#
# If there was a highlight, remove it # If there was a highlight, remove it
_zsh_autosuggest_highlight_reset() { _zsh_autosuggest_highlight_reset() {

View File

@@ -1,7 +1,7 @@
#-------# #--------------------------------------------------------------------#
# Start # # Start #
#-------# #--------------------------------------------------------------------#
# Start the autosuggestion widgets # Start the autosuggestion widgets
_zsh_autosuggest_start() { _zsh_autosuggest_start() {

View File

@@ -1,7 +1,7 @@
#------------# #--------------------------------------------------------------------#
# Suggestion # # Suggestion #
#------------# #--------------------------------------------------------------------#
# Get a suggestion from history that matches a given prefix # Get a suggestion from history that matches a given prefix
_zsh_autosuggest_suggestion() { _zsh_autosuggest_suggestion() {

View File

@@ -1,20 +1,20 @@
#------------------------------------# #--------------------------------------------------------------------#
# Autosuggest Widget Implementations # # Autosuggest Widget Implementations #
#------------------------------------# #--------------------------------------------------------------------#
# Clear the suggestion # Clear the suggestion
_zsh_autosuggest_clear() { _zsh_autosuggest_clear() {
# Remove the suggestion # Remove the suggestion
unset POSTDISPLAY unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
} }
# Modify the buffer and get a new suggestion # Modify the buffer and get a new suggestion
_zsh_autosuggest_modify() { _zsh_autosuggest_modify() {
# Original widget modifies the buffer # Original widget modifies the buffer
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
# 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
@@ -44,7 +44,7 @@ _zsh_autosuggest_accept() {
CURSOR=${#BUFFER} CURSOR=${#BUFFER}
fi fi
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
} }
# Partially accept the suggestion # Partially accept the suggestion
@@ -56,7 +56,7 @@ _zsh_autosuggest_partial_accept() {
BUFFER="$BUFFER$POSTDISPLAY" BUFFER="$BUFFER$POSTDISPLAY"
# Original widget moves the cursor # Original widget moves the cursor
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
# If we've moved past the end of the original buffer # If we've moved past the end of the original buffer
if [ $CURSOR -gt $#original_buffer ]; then if [ $CURSOR -gt $#original_buffer ]; then
@@ -73,13 +73,13 @@ _zsh_autosuggest_partial_accept() {
_zsh_autosuggest_widget_accept() { _zsh_autosuggest_widget_accept() {
_zsh_autosuggest_highlight_reset _zsh_autosuggest_highlight_reset
_zsh_autosuggest_accept _zsh_autosuggest_accept $@
_zsh_autosuggest_highlight_apply _zsh_autosuggest_highlight_apply
} }
_zsh_autosuggest_widget_clear() { _zsh_autosuggest_widget_clear() {
_zsh_autosuggest_highlight_reset _zsh_autosuggest_highlight_reset
_zsh_autosuggest_clear _zsh_autosuggest_clear $@
_zsh_autosuggest_highlight_apply _zsh_autosuggest_highlight_apply
} }

View File

@@ -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.0 # v0.2.4
# Copyright (c) 2013 Thiago de Arruda # Copyright (c) 2013 Thiago de Arruda
# Copyright (c) 2016 Eric Freese # Copyright (c) 2016 Eric Freese
# #
@@ -25,9 +25,9 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE. # OTHER DEALINGS IN THE SOFTWARE.
#--------------------------------# #--------------------------------------------------------------------#
# Global Configuration Variables # # Global Configuration Variables #
#--------------------------------# #--------------------------------------------------------------------#
# Color to use when highlighting suggestion # Color to use when highlighting suggestion
# Uses format of `region_highlight` # Uses format of `region_highlight`
@@ -86,11 +86,13 @@ ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
vi-forward-blank-word-end vi-forward-blank-word-end
) )
#-------------------------------------# #--------------------------------------------------------------------#
# Handle Deprecated Variables/Widgets # # Handle Deprecated Variables/Widgets #
#-------------------------------------# #--------------------------------------------------------------------#
unset _ZSH_AUTOSUGGEST_DEPRECATED_START_WIDGET_WARNING_SHOWN _zsh_autosuggest_deprecated_warning() {
>&2 echo "zsh-autosuggestions: $@"
}
_zsh_autosuggest_check_deprecated_config() { _zsh_autosuggest_check_deprecated_config() {
if [ -n "$AUTOSUGGESTION_HIGHLIGHT_COLOR" ]; then if [ -n "$AUTOSUGGESTION_HIGHLIGHT_COLOR" ]; then
@@ -110,24 +112,19 @@ _zsh_autosuggest_check_deprecated_config() {
fi fi
} }
_zsh_autosuggest_deprecated_warning() {
>&2 echo "zsh-autosuggestions: $@"
}
_zsh_autosuggest_deprecated_start_widget() { _zsh_autosuggest_deprecated_start_widget() {
if [ -z "$_ZSH_AUTOSUGGEST_DEPRECATED_START_WIDGET_WARNING_SHOWN" ]; then _zsh_autosuggest_deprecated_warning "The autosuggest-start widget is deprecated. For more info, see the README at https://github.com/tarruda/zsh-autosuggestions."
_zsh_autosuggest_deprecated_warning "The autosuggest-start widget is deprecated. Use the autosuggest_start function instead. For more info, see README at https://github.com/tarruda/zsh-autosuggestions." zle -D autosuggest-start
_ZSH_AUTOSUGGEST_DEPRECATED_START_WIDGET_WARNING_SHOWN=true eval "zle-line-init() {
fi $(echo $functions[${widgets[zle-line-init]#*:}] | sed -e 's/zle autosuggest-start//g')
}"
autosuggest_start
} }
zle -N autosuggest-start _zsh_autosuggest_deprecated_start_widget zle -N autosuggest-start _zsh_autosuggest_deprecated_start_widget
#----------------# #--------------------------------------------------------------------#
# Widget Helpers # # Widget Helpers #
#----------------# #--------------------------------------------------------------------#
# Bind a single widget to an autosuggest widget, saving a reference to the original widget # Bind a single widget to an autosuggest widget, saving a reference to the original widget
_zsh_autosuggest_bind_widget() { _zsh_autosuggest_bind_widget() {
@@ -160,9 +157,9 @@ _zsh_autosuggest_bind_widget() {
# Set up widget to call $autosuggest_function if it exists # Set up widget to call $autosuggest_function if it exists
# Otherwise just call the original widget # Otherwise just call the original widget
if [ -n "$autosuggest_function" ]; then; if [ -n "$autosuggest_function" ]; then;
action=$autosuggest_function; action="$autosuggest_function \$@";
else; else;
action="zle $prefix$widget \$@" action="zle $prefix$widget -- \$@"
fi fi
# Create new function for the widget that highlights and calls the action # Create new function for the widget that highlights and calls the action
@@ -181,7 +178,7 @@ _zsh_autosuggest_bind_widgets() {
local widget; local widget;
# Find every widget we might want to bind and bind it appropriately # Find every widget we might want to bind and bind it appropriately
for widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|autosuggest-*|$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX*|run-help|which-command|beep|set-local-history|yank)}; do for widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|autosuggest-*|$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX*|zle-line-*|run-help|which-command|beep|set-local-history|yank)}; do
if [ ${ZSH_AUTOSUGGEST_MODIFY_WIDGETS[(r)$widget]} ]; then if [ ${ZSH_AUTOSUGGEST_MODIFY_WIDGETS[(r)$widget]} ]; then
_zsh_autosuggest_bind_widget $widget _zsh_autosuggest_modify _zsh_autosuggest_bind_widget $widget _zsh_autosuggest_modify
elif [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then elif [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
@@ -198,16 +195,16 @@ _zsh_autosuggest_bind_widgets() {
# Given the name of a widget, invoke the original we saved, if it exists # Given the name of a widget, invoke the original we saved, if it exists
_zsh_autosuggest_invoke_original_widget() { _zsh_autosuggest_invoke_original_widget() {
local original_widget_name="$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX$1" local original_widget_name="$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX$WIDGET"
if [ $widgets[$original_widget_name] ]; then if [ $widgets[$original_widget_name] ]; then
zle $original_widget_name zle $original_widget_name -- $@
fi fi
} }
#--------------# #--------------------------------------------------------------------#
# Highlighting # # Highlighting #
#--------------# #--------------------------------------------------------------------#
# If there was a highlight, remove it # If there was a highlight, remove it
_zsh_autosuggest_highlight_reset() { _zsh_autosuggest_highlight_reset() {
@@ -227,22 +224,22 @@ _zsh_autosuggest_highlight_apply() {
fi fi
} }
#------------------------------------# #--------------------------------------------------------------------#
# Autosuggest Widget Implementations # # Autosuggest Widget Implementations #
#------------------------------------# #--------------------------------------------------------------------#
# Clear the suggestion # Clear the suggestion
_zsh_autosuggest_clear() { _zsh_autosuggest_clear() {
# Remove the suggestion # Remove the suggestion
unset POSTDISPLAY unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
} }
# Modify the buffer and get a new suggestion # Modify the buffer and get a new suggestion
_zsh_autosuggest_modify() { _zsh_autosuggest_modify() {
# Original widget modifies the buffer # Original widget modifies the buffer
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
# 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
@@ -272,7 +269,7 @@ _zsh_autosuggest_accept() {
CURSOR=${#BUFFER} CURSOR=${#BUFFER}
fi fi
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
} }
# Partially accept the suggestion # Partially accept the suggestion
@@ -284,7 +281,7 @@ _zsh_autosuggest_partial_accept() {
BUFFER="$BUFFER$POSTDISPLAY" BUFFER="$BUFFER$POSTDISPLAY"
# Original widget moves the cursor # Original widget moves the cursor
_zsh_autosuggest_invoke_original_widget $WIDGET _zsh_autosuggest_invoke_original_widget $@
# If we've moved past the end of the original buffer # If we've moved past the end of the original buffer
if [ $CURSOR -gt $#original_buffer ]; then if [ $CURSOR -gt $#original_buffer ]; then
@@ -301,22 +298,22 @@ _zsh_autosuggest_partial_accept() {
_zsh_autosuggest_widget_accept() { _zsh_autosuggest_widget_accept() {
_zsh_autosuggest_highlight_reset _zsh_autosuggest_highlight_reset
_zsh_autosuggest_accept _zsh_autosuggest_accept $@
_zsh_autosuggest_highlight_apply _zsh_autosuggest_highlight_apply
} }
_zsh_autosuggest_widget_clear() { _zsh_autosuggest_widget_clear() {
_zsh_autosuggest_highlight_reset _zsh_autosuggest_highlight_reset
_zsh_autosuggest_clear _zsh_autosuggest_clear $@
_zsh_autosuggest_highlight_apply _zsh_autosuggest_highlight_apply
} }
zle -N autosuggest-accept _zsh_autosuggest_widget_accept zle -N autosuggest-accept _zsh_autosuggest_widget_accept
zle -N autosuggest-clear _zsh_autosuggest_widget_clear zle -N autosuggest-clear _zsh_autosuggest_widget_clear
#------------# #--------------------------------------------------------------------#
# Suggestion # # Suggestion #
#------------# #--------------------------------------------------------------------#
# Get a suggestion from history that matches a given prefix # Get a suggestion from history that matches a given prefix
_zsh_autosuggest_suggestion() { _zsh_autosuggest_suggestion() {
@@ -333,9 +330,9 @@ _zsh_autosuggest_suggestion() {
echo ${history_matches[1]} echo ${history_matches[1]}
} }
#-------# #--------------------------------------------------------------------#
# Start # # Start #
#-------# #--------------------------------------------------------------------#
# Start the autosuggestion widgets # Start the autosuggestion widgets
_zsh_autosuggest_start() { _zsh_autosuggest_start() {