commit
d7c796719e
@ -0,0 +1,67 @@
|
||||
## Installation
|
||||
|
||||
### Manual (Git Clone)
|
||||
|
||||
1. Clone this repository somewhere on your machine. This guide will assume `~/.zsh/zsh-autosuggestions`.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
|
||||
```
|
||||
|
||||
2. Add the following to your `.zshrc`:
|
||||
|
||||
```sh
|
||||
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
```
|
||||
|
||||
3. Start a new terminal session.
|
||||
|
||||
### Oh My Zsh
|
||||
|
||||
1. Clone this repository into `$ZSH_CUSTOM/plugins` (by default `~/.oh-my-zsh/custom/plugins`)
|
||||
|
||||
```sh
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
||||
```
|
||||
|
||||
2. Add the plugin to the list of plugins for Oh My Zsh to load:
|
||||
|
||||
```sh
|
||||
plugins=(zsh-autosuggestions)
|
||||
```
|
||||
|
||||
3. Start a new terminal session.
|
||||
|
||||
### Arch Linux
|
||||
|
||||
1. Install [`zsh-autosuggestions`](https://www.archlinux.org/packages/community/any/zsh-autosuggestions/) from the `community` repository.
|
||||
|
||||
```sh
|
||||
pacman -S zsh-autosuggestions
|
||||
```
|
||||
|
||||
or, to use a package based on the `master` branch, install [`zsh-autosuggestions-git`](https://aur.archlinux.org/packages/zsh-autosuggestions-git/) from the [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository).
|
||||
|
||||
2. Add the following to your `.zshrc`:
|
||||
|
||||
```sh
|
||||
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
```
|
||||
|
||||
3. Start a new terminal session.
|
||||
|
||||
### macOS via Homebrew
|
||||
1. Install the `zsh-autosuggestions` package using [Homebrew](https://brew.sh/).
|
||||
|
||||
```sh
|
||||
brew install zsh-autosuggestions
|
||||
```
|
||||
|
||||
2. Add the following to your `.zshrc`:
|
||||
|
||||
```sh
|
||||
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
```
|
||||
|
||||
3. Start a new terminal session.
|
||||
|
@ -0,0 +1,41 @@
|
||||
context 'with asynchronous suggestions enabled' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_USE_ASYNC="] }
|
||||
|
||||
describe '`up-line-or-beginning-search`' do
|
||||
let(:before_sourcing) do
|
||||
-> do
|
||||
session.
|
||||
run_command('autoload -U up-line-or-beginning-search').
|
||||
run_command('zle -N up-line-or-beginning-search').
|
||||
send_string('bindkey "').
|
||||
send_keys('C-v').send_keys('up').
|
||||
send_string('" up-line-or-beginning-search').
|
||||
send_keys('enter')
|
||||
end
|
||||
end
|
||||
|
||||
it 'should show previous history entries' do
|
||||
with_history(
|
||||
'echo foo',
|
||||
'echo bar',
|
||||
'echo baz'
|
||||
) do
|
||||
session.clear_screen
|
||||
3.times { session.send_keys('up') }
|
||||
wait_for { session.content }.to eq("echo foo")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'exiting a subshell' do
|
||||
it 'should not cause error messages to be printed' do
|
||||
session.run_command('$(exit)')
|
||||
|
||||
sleep 1
|
||||
|
||||
expect(session.content).to eq('$(exit)')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -0,0 +1,67 @@
|
||||
describe 'when using vi mode' do
|
||||
let(:before_sourcing) do
|
||||
-> do
|
||||
session.run_command('bindkey -v')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'moving the cursor after exiting insert mode' do
|
||||
it 'should not clear the current suggestion' do
|
||||
with_history('foobar foo') do
|
||||
session.
|
||||
send_string('foo').
|
||||
send_keys('escape').
|
||||
send_keys('h')
|
||||
|
||||
wait_for { session.content }.to eq('foobar foo')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '`vi-forward-word-end`' do
|
||||
it 'should accept through the end of the current word' do
|
||||
with_history('foobar foo') do
|
||||
session.
|
||||
send_string('foo').
|
||||
send_keys('escape').
|
||||
send_keys('e'). # vi-forward-word-end
|
||||
send_keys('a'). # vi-add-next
|
||||
send_string('baz')
|
||||
|
||||
wait_for { session.content }.to eq('foobarbaz')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '`vi-forward-word`' do
|
||||
it 'should accept through the first character of the next word' do
|
||||
with_history('foobar foo') do
|
||||
session.
|
||||
send_string('foo').
|
||||
send_keys('escape').
|
||||
send_keys('w'). # vi-forward-word
|
||||
send_keys('a'). # vi-add-next
|
||||
send_string('az')
|
||||
|
||||
wait_for { session.content }.to eq('foobar faz')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '`vi-find-next-char`' do
|
||||
it 'should accept through the next occurrence of the character' do
|
||||
with_history('foobar foo') do
|
||||
session.
|
||||
send_string('foo').
|
||||
send_keys('escape').
|
||||
send_keys('f'). # vi-find-next-char
|
||||
send_keys('o').
|
||||
send_keys('a'). # vi-add-next
|
||||
send_string('b')
|
||||
|
||||
wait_for { session.content }.to eq('foobar fob')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,23 @@
|
||||
context 'with some items in the kill ring' do
|
||||
before do
|
||||
session.
|
||||
send_string('echo foo').
|
||||
send_keys('C-u').
|
||||
send_string('echo bar').
|
||||
send_keys('C-u')
|
||||
end
|
||||
|
||||
describe '`yank-pop`' do
|
||||
it 'should cycle through all items in the kill ring' do
|
||||
session.send_keys('C-y')
|
||||
wait_for { session.content }.to eq('echo bar')
|
||||
|
||||
session.send_keys('escape').send_keys('y')
|
||||
wait_for { session.content }.to eq('echo foo')
|
||||
|
||||
session.send_keys('escape').send_keys('y')
|
||||
wait_for { session.content }.to eq('echo bar')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue