Compare commits
26 Commits
fixes/asyn
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0e810e5afa | ||
![]() |
f9526195c5 | ||
![]() |
e52ee8ca55 | ||
![]() |
f8907cf32b | ||
![]() |
a50468ef4b | ||
![]() |
9aceef9646 | ||
![]() |
11d17e7fea | ||
![]() |
a593f4dfec | ||
![]() |
2c9e57fd50 | ||
![]() |
c3d4e576c9 | ||
![]() |
23f2943455 | ||
![]() |
95602e2dea | ||
![]() |
39aa7bed3a | ||
![]() |
27c298cf1a | ||
![]() |
a84d78f8b5 | ||
![]() |
309d32ac9e | ||
![]() |
9908eb49a3 | ||
![]() |
2b97cf3b30 | ||
![]() |
f29bb7f032 | ||
![]() |
c14ad9fc46 | ||
![]() |
fc391d6bf6 | ||
![]() |
7795a357e6 | ||
![]() |
56f10c3b5d | ||
![]() |
8072e52d96 | ||
![]() |
69bf058c23 | ||
![]() |
a411ef3e09 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# zsh word code files
|
||||
*.zwc
|
@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## v0.7.1
|
||||
- Clear POSTDISPLAY instead of unsetting (#634)
|
||||
- Always reset async file descriptor after consuming it (#630)
|
||||
- Always use builtin `exec` (#628)
|
||||
- Add `history-beginning-search-*-end` widgets to clear widget list (#619)
|
||||
- Switch CI from Circle CI to GitHub Actions
|
||||
|
||||
## v0.7.0
|
||||
- Enable asynchronous mode by default (#498)
|
||||
- No longer wrap user widgets starting with `autosuggest-` prefix (#496)
|
||||
|
21
INSTALL.md
21
INSTALL.md
@ -3,19 +3,21 @@
|
||||
* [Packages](#packages)
|
||||
* [Antigen](#antigen)
|
||||
* [Oh My Zsh](#oh-my-zsh)
|
||||
* [HomeBrew](#homebrew)
|
||||
* [Manual](#manual-git-clone)
|
||||
|
||||
## Packages
|
||||
|
||||
| System | Package |
|
||||
| ------------- | ------------- |
|
||||
| Alpine Linux | [zsh-autosuggestions](https://pkgs.alpinelinux.org/packages?name=zsh-autosuggestions) |
|
||||
| Debian / Ubuntu | [zsh-autosuggestions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions) |
|
||||
| Fedora / CentOS / RHEL / Scientific Linux | [zsh-autosuggestions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions) |
|
||||
| OpenSUSE / SLE | [zsh-autosuggestions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions) |
|
||||
| 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/shells/zsh/zsh-autosuggestions/default.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) |
|
||||
| Mac OS | [homebrew](https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-autosuggestions.rb) |
|
||||
| Mac OS | [homebrew](https://github.com/Homebrew/homebrew-core/blob/master/Formula/z/zsh-autosuggestions.rb) |
|
||||
| NetBSD | [pkgsrc](http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/shells/zsh-autosuggestions/README.html) |
|
||||
|
||||
## Antigen
|
||||
@ -47,6 +49,21 @@
|
||||
|
||||
3. Start a new terminal session.
|
||||
|
||||
## Homebrew
|
||||
|
||||
1. Install command:
|
||||
```sh
|
||||
brew install zsh-autosuggestions
|
||||
```
|
||||
|
||||
2. To activate the autosuggestions, add the following at the end of your .zshrc:
|
||||
|
||||
```sh
|
||||
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
```
|
||||
|
||||
3. Start a new terminal session.
|
||||
|
||||
## Manual (Git Clone)
|
||||
|
||||
1. Clone this repository somewhere on your machine. This guide will assume `~/.zsh/zsh-autosuggestions`.
|
||||
|
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
SRC_DIR := ./src
|
||||
SRC_DIR := ./src
|
||||
|
||||
SRC_FILES := \
|
||||
$(SRC_DIR)/config.zsh \
|
||||
|
@ -6,7 +6,6 @@ It suggests commands as you type based on history and completions.
|
||||
|
||||
Requirements: Zsh v4.3.11 or later
|
||||
|
||||
[](https://circleci.com/gh/zsh-users/zsh-autosuggestions)
|
||||
[](https://gitter.im/zsh-users/zsh-autosuggestions)
|
||||
|
||||
<a href="https://asciinema.org/a/37390" target="_blank"><img src="https://asciinema.org/a/37390.png" width="400" /></a>
|
||||
@ -53,7 +52,7 @@ For more info, read the Character Highlighting section of the zsh manual: `man z
|
||||
`ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated. The strategies in the array are tried successively until a suggestion is found. There are currently three built-in strategies to choose from:
|
||||
|
||||
- `history`: Chooses the most recent match from history.
|
||||
- `completion`: Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` module)
|
||||
- `completion`: Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` module, which is included with zsh since 4.0.1)
|
||||
- `match_prev_cmd`: Like `history`, but chooses the most recent match whose preceding history item matches the most recently executed command ([more info](src/strategies/match_prev_cmd.zsh)). Note that this strategy won't work as expected with ZSH options that don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`.
|
||||
|
||||
For example, setting `ZSH_AUTOSUGGEST_STRATEGY=(history completion)` will first try to find a suggestion from your history, but, if it can't find a match, will find a suggestion from the completion engine.
|
||||
|
@ -11,7 +11,7 @@ _zsh_autosuggest_async_request() {
|
||||
# If we've got a pending request, cancel it
|
||||
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
|
||||
# Close the file descriptor and remove the handler
|
||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
||||
|
||||
# We won't know the pid unless the user has zsh/system module installed
|
||||
@ -32,7 +32,7 @@ _zsh_autosuggest_async_request() {
|
||||
fi
|
||||
|
||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||
# Tell parent process our pid
|
||||
echo $sysparams[pid]
|
||||
|
||||
@ -68,9 +68,10 @@ _zsh_autosuggest_async_response() {
|
||||
zle autosuggest-suggest -- "$suggestion"
|
||||
|
||||
# Close the fd
|
||||
exec {1}<&-
|
||||
builtin exec {1}<&-
|
||||
fi
|
||||
|
||||
# Always remove the handler
|
||||
zle -F "$1"
|
||||
_ZSH_AUTOSUGGEST_ASYNC_FD=
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||
history-search-backward
|
||||
history-beginning-search-forward
|
||||
history-beginning-search-backward
|
||||
history-beginning-search-forward-end
|
||||
history-beginning-search-backward-end
|
||||
history-substring-search-up
|
||||
history-substring-search-down
|
||||
up-line-or-beginning-search
|
||||
|
@ -30,7 +30,7 @@ _zsh_autosuggest_toggle() {
|
||||
# Clear the suggestion
|
||||
_zsh_autosuggest_clear() {
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
}
|
||||
@ -47,7 +47,7 @@ _zsh_autosuggest_modify() {
|
||||
local orig_postdisplay="$POSTDISPLAY"
|
||||
|
||||
# Clear suggestion while waiting for next one
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
# Original widget may modify the buffer
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
@ -102,7 +102,7 @@ _zsh_autosuggest_suggest() {
|
||||
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
|
||||
POSTDISPLAY="${suggestion#$BUFFER}"
|
||||
else
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
fi
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ _zsh_autosuggest_accept() {
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
# Run the original widget before manually moving the cursor so that the
|
||||
# cursor movement doesn't make the widget do something unexpected
|
||||
@ -151,7 +151,7 @@ _zsh_autosuggest_execute() {
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
# Call the original `accept-line` to handle syntax highlighting or
|
||||
# other potential custom behavior
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
||||
# https://github.com/zsh-users/zsh-autosuggestions
|
||||
# v0.7.0
|
||||
# v0.7.1
|
||||
# Copyright (c) 2013 Thiago de Arruda
|
||||
# Copyright (c) 2016-2021 Eric Freese
|
||||
#
|
||||
@ -54,6 +54,8 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||
history-search-backward
|
||||
history-beginning-search-forward
|
||||
history-beginning-search-backward
|
||||
history-beginning-search-forward-end
|
||||
history-beginning-search-backward-end
|
||||
history-substring-search-up
|
||||
history-substring-search-down
|
||||
up-line-or-beginning-search
|
||||
@ -292,7 +294,7 @@ _zsh_autosuggest_toggle() {
|
||||
# Clear the suggestion
|
||||
_zsh_autosuggest_clear() {
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
}
|
||||
@ -309,7 +311,7 @@ _zsh_autosuggest_modify() {
|
||||
local orig_postdisplay="$POSTDISPLAY"
|
||||
|
||||
# Clear suggestion while waiting for next one
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
# Original widget may modify the buffer
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
@ -364,7 +366,7 @@ _zsh_autosuggest_suggest() {
|
||||
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
|
||||
POSTDISPLAY="${suggestion#$BUFFER}"
|
||||
else
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
fi
|
||||
}
|
||||
|
||||
@ -390,7 +392,7 @@ _zsh_autosuggest_accept() {
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
# Run the original widget before manually moving the cursor so that the
|
||||
# cursor movement doesn't make the widget do something unexpected
|
||||
@ -413,7 +415,7 @@ _zsh_autosuggest_execute() {
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
POSTDISPLAY=
|
||||
|
||||
# Call the original `accept-line` to handle syntax highlighting or
|
||||
# other potential custom behavior
|
||||
@ -766,7 +768,7 @@ _zsh_autosuggest_async_request() {
|
||||
# If we've got a pending request, cancel it
|
||||
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
|
||||
# Close the file descriptor and remove the handler
|
||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
||||
|
||||
# We won't know the pid unless the user has zsh/system module installed
|
||||
@ -787,7 +789,7 @@ _zsh_autosuggest_async_request() {
|
||||
fi
|
||||
|
||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||
# Tell parent process our pid
|
||||
echo $sysparams[pid]
|
||||
|
||||
@ -823,11 +825,12 @@ _zsh_autosuggest_async_response() {
|
||||
zle autosuggest-suggest -- "$suggestion"
|
||||
|
||||
# Close the fd
|
||||
exec {1}<&-
|
||||
builtin exec {1}<&-
|
||||
fi
|
||||
|
||||
# Always remove the handler
|
||||
zle -F "$1"
|
||||
_ZSH_AUTOSUGGEST_ASYNC_FD=
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
|
Loading…
x
Reference in New Issue
Block a user