mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-06 15:20:40 +01:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
146020d9b2 | ||
|
|
0636a39b51 | ||
|
|
6769c941ba | ||
|
|
371d6441c0 | ||
|
|
78e4379711 | ||
|
|
c80605595c | ||
|
|
cb52adf429 | ||
|
|
cdf6be4f06 | ||
|
|
66a6de3fb5 | ||
|
|
2498dbab75 | ||
|
|
676aebdf44 | ||
|
|
ec43fcfccf | ||
|
|
f5236c4351 | ||
|
|
d27983b7ca | ||
|
|
d14b17fb09 | ||
|
|
b24b607fbf | ||
|
|
a437544cc5 |
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.6.3
|
||||||
|
- Fixed bug moving cursor to end of buffer after accepting suggestion (#453)
|
||||||
|
|
||||||
|
## v0.6.2
|
||||||
|
- Fixed bug deleting the last character in the buffer in vi mode (#450)
|
||||||
|
- Degrade gracefully when user doesn't have `zsh/system` module installed (#447)
|
||||||
|
|
||||||
## v0.6.1
|
## v0.6.1
|
||||||
- Fixed bug occurring when `_complete` had been aliased (#443)
|
- Fixed bug occurring when `_complete` had been aliased (#443)
|
||||||
|
|
||||||
|
|||||||
20
INSTALL.md
20
INSTALL.md
@@ -1,6 +1,12 @@
|
|||||||
## Installation
|
# Installation
|
||||||
|
|
||||||
### Manual (Git Clone)
|
* [Manual](#manual-git-clone)
|
||||||
|
* [Antigen](#antigen)
|
||||||
|
* [Oh My Zsh](#oh-my-zsh)
|
||||||
|
* [Arch Linux](#arch-linux)
|
||||||
|
* [macOS via Homebrew](#macos-via-homebrew)
|
||||||
|
|
||||||
|
## Manual (Git Clone)
|
||||||
|
|
||||||
1. Clone this repository somewhere on your machine. This guide will assume `~/.zsh/zsh-autosuggestions`.
|
1. Clone this repository somewhere on your machine. This guide will assume `~/.zsh/zsh-autosuggestions`.
|
||||||
|
|
||||||
@@ -16,7 +22,7 @@
|
|||||||
|
|
||||||
3. Start a new terminal session.
|
3. Start a new terminal session.
|
||||||
|
|
||||||
### Antigen
|
## Antigen
|
||||||
|
|
||||||
1. Add the following to your `.zshrc`:
|
1. Add the following to your `.zshrc`:
|
||||||
|
|
||||||
@@ -26,7 +32,7 @@
|
|||||||
|
|
||||||
2. Start a new terminal session.
|
2. Start a new terminal session.
|
||||||
|
|
||||||
### Oh My Zsh
|
## Oh My Zsh
|
||||||
|
|
||||||
1. Clone this repository into `$ZSH_CUSTOM/plugins` (by default `~/.oh-my-zsh/custom/plugins`)
|
1. Clone this repository into `$ZSH_CUSTOM/plugins` (by default `~/.oh-my-zsh/custom/plugins`)
|
||||||
|
|
||||||
@@ -42,7 +48,7 @@
|
|||||||
|
|
||||||
3. Start a new terminal session.
|
3. Start a new terminal session.
|
||||||
|
|
||||||
### Arch Linux
|
## Arch Linux
|
||||||
|
|
||||||
1. Install [`zsh-autosuggestions`](https://www.archlinux.org/packages/community/any/zsh-autosuggestions/) from the `community` repository.
|
1. Install [`zsh-autosuggestions`](https://www.archlinux.org/packages/community/any/zsh-autosuggestions/) from the `community` repository.
|
||||||
|
|
||||||
@@ -60,7 +66,8 @@
|
|||||||
|
|
||||||
3. Start a new terminal session.
|
3. Start a new terminal session.
|
||||||
|
|
||||||
### macOS via Homebrew
|
## macOS via Homebrew
|
||||||
|
|
||||||
1. Install the `zsh-autosuggestions` package using [Homebrew](https://brew.sh/).
|
1. Install the `zsh-autosuggestions` package using [Homebrew](https://brew.sh/).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -74,4 +81,3 @@
|
|||||||
```
|
```
|
||||||
|
|
||||||
3. Start a new terminal session.
|
3. Start a new terminal session.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
_[Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for zsh._
|
_[Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for zsh._
|
||||||
|
|
||||||
It suggests commands as you type.
|
It suggests commands as you type based on history and completions.
|
||||||
|
|
||||||
Requirements: Zsh v4.3.11 or later
|
Requirements: Zsh v4.3.11 or later
|
||||||
|
|
||||||
@@ -44,6 +44,8 @@ ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"
|
|||||||
|
|
||||||
For more info, read the Character Highlighting section of the zsh manual: `man zshzle` or [online](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting).
|
For more info, read the Character Highlighting section of the zsh manual: `man zshzle` or [online](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting).
|
||||||
|
|
||||||
|
**Note:** Some iTerm2 users have reported [not being able to see the suggestions](https://github.com/zsh-users/zsh-autosuggestions/issues/416#issuecomment-486516333). If this affects you, the problem is likely caused by incorrect color settings. In order to correct this, go into iTerm2's setting, navigate to profile > colors and make sure that the colors for Basic Colors > Background and ANSI Colors > Bright Black are **different**.
|
||||||
|
|
||||||
|
|
||||||
### Suggestion Strategy
|
### Suggestion Strategy
|
||||||
|
|
||||||
@@ -106,8 +108,7 @@ bindkey '^ ' autosuggest-accept
|
|||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If you have a problem, please search through [the list of issues on GitHub](https://github.com/zsh-users/zsh-autosuggestions/issues) to see if someone else has already reported it.
|
If you have a problem, please search through [the list of issues on GitHub](https://github.com/zsh-users/zsh-autosuggestions/issues?q=) to see if someone else has already reported it.
|
||||||
|
|
||||||
|
|
||||||
### Reporting an Issue
|
### Reporting an Issue
|
||||||
|
|
||||||
|
|||||||
@@ -63,5 +63,18 @@ describe 'when using vi mode' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
describe '`vi-delete`' do
|
||||||
|
it 'should be able to remove the last character in the buffer' do
|
||||||
|
skip 'deleting last char did not work below zsh version 5.0.8' if session.zsh_version < Gem::Version.new('5.0.8')
|
||||||
|
|
||||||
|
session.
|
||||||
|
send_string('echo foo').
|
||||||
|
send_keys('escape').
|
||||||
|
send_keys('d').
|
||||||
|
send_keys('l')
|
||||||
|
|
||||||
|
wait_for { session.content }.to eq('echo fo')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ describe 'a zle widget' do
|
|||||||
context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do
|
context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do
|
||||||
let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] }
|
let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] }
|
||||||
|
|
||||||
it 'accepts the suggestion when invoked' do
|
it 'accepts the suggestion and moves the cursor to the end of the buffer when invoked' do
|
||||||
with_history('echo hello') do
|
with_history('echo hello') do
|
||||||
session.send_string('e')
|
session.send_string('e')
|
||||||
wait_for { session.content }.to eq('echo hello')
|
wait_for { session.content }.to eq('echo hello')
|
||||||
session.send_keys('C-b')
|
session.send_keys('C-b')
|
||||||
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
|
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
|
||||||
|
wait_for { session.cursor }.to eq([10, 0])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
# Async #
|
# Async #
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
zmodload zsh/system
|
|
||||||
|
|
||||||
_zsh_autosuggest_async_request() {
|
_zsh_autosuggest_async_request() {
|
||||||
|
zmodload zsh/system 2>/dev/null # For `$sysparams`
|
||||||
|
|
||||||
typeset -g _ZSH_AUTOSUGGEST_ASYNC_FD _ZSH_AUTOSUGGEST_CHILD_PID
|
typeset -g _ZSH_AUTOSUGGEST_ASYNC_FD _ZSH_AUTOSUGGEST_CHILD_PID
|
||||||
|
|
||||||
# If we've got a pending request, cancel it
|
# If we've got a pending request, cancel it
|
||||||
@@ -14,6 +14,8 @@ _zsh_autosuggest_async_request() {
|
|||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||||
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
||||||
|
|
||||||
|
# We won't know the pid unless the user has zsh/system module installed
|
||||||
|
if [[ -n "$_ZSH_AUTOSUGGEST_CHILD_PID" ]]; then
|
||||||
# Zsh will make a new process group for the child process only if job
|
# Zsh will make a new process group for the child process only if job
|
||||||
# control is enabled (MONITOR option)
|
# control is enabled (MONITOR option)
|
||||||
if [[ -o MONITOR ]]; then
|
if [[ -o MONITOR ]]; then
|
||||||
@@ -27,6 +29,7 @@ _zsh_autosuggest_async_request() {
|
|||||||
kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||||
|
|||||||
@@ -136,7 +136,11 @@ _zsh_autosuggest_accept() {
|
|||||||
unset POSTDISPLAY
|
unset POSTDISPLAY
|
||||||
|
|
||||||
# Move the cursor to the end of the buffer
|
# Move the cursor to the end of the buffer
|
||||||
CURSOR=${#BUFFER}
|
if [[ "$KEYMAP" = "vicmd" ]]; then
|
||||||
|
CURSOR=$(($#BUFFER - 1))
|
||||||
|
else
|
||||||
|
CURSOR=$#BUFFER
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_zsh_autosuggest_invoke_original_widget $@
|
_zsh_autosuggest_invoke_original_widget $@
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
||||||
# https://github.com/zsh-users/zsh-autosuggestions
|
# https://github.com/zsh-users/zsh-autosuggestions
|
||||||
# v0.6.1
|
# v0.6.3
|
||||||
# Copyright (c) 2013 Thiago de Arruda
|
# Copyright (c) 2013 Thiago de Arruda
|
||||||
# Copyright (c) 2016-2019 Eric Freese
|
# Copyright (c) 2016-2019 Eric Freese
|
||||||
#
|
#
|
||||||
@@ -398,7 +398,11 @@ _zsh_autosuggest_accept() {
|
|||||||
unset POSTDISPLAY
|
unset POSTDISPLAY
|
||||||
|
|
||||||
# Move the cursor to the end of the buffer
|
# Move the cursor to the end of the buffer
|
||||||
CURSOR=${#BUFFER}
|
if [[ "$KEYMAP" = "vicmd" ]]; then
|
||||||
|
CURSOR=$(($#BUFFER - 1))
|
||||||
|
else
|
||||||
|
CURSOR=$#BUFFER
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_zsh_autosuggest_invoke_original_widget $@
|
_zsh_autosuggest_invoke_original_widget $@
|
||||||
@@ -726,9 +730,9 @@ _zsh_autosuggest_fetch_suggestion() {
|
|||||||
# Async #
|
# Async #
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
zmodload zsh/system
|
|
||||||
|
|
||||||
_zsh_autosuggest_async_request() {
|
_zsh_autosuggest_async_request() {
|
||||||
|
zmodload zsh/system 2>/dev/null # For `$sysparams`
|
||||||
|
|
||||||
typeset -g _ZSH_AUTOSUGGEST_ASYNC_FD _ZSH_AUTOSUGGEST_CHILD_PID
|
typeset -g _ZSH_AUTOSUGGEST_ASYNC_FD _ZSH_AUTOSUGGEST_CHILD_PID
|
||||||
|
|
||||||
# If we've got a pending request, cancel it
|
# If we've got a pending request, cancel it
|
||||||
@@ -737,6 +741,8 @@ _zsh_autosuggest_async_request() {
|
|||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||||
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
||||||
|
|
||||||
|
# We won't know the pid unless the user has zsh/system module installed
|
||||||
|
if [[ -n "$_ZSH_AUTOSUGGEST_CHILD_PID" ]]; then
|
||||||
# Zsh will make a new process group for the child process only if job
|
# Zsh will make a new process group for the child process only if job
|
||||||
# control is enabled (MONITOR option)
|
# control is enabled (MONITOR option)
|
||||||
if [[ -o MONITOR ]]; then
|
if [[ -o MONITOR ]]; then
|
||||||
@@ -750,6 +756,7 @@ _zsh_autosuggest_async_request() {
|
|||||||
kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Fork a process to fetch a suggestion and open a pipe to read from it
|
# Fork a process to fetch a suggestion and open a pipe to read from it
|
||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
|
||||||
|
|||||||
Reference in New Issue
Block a user