Merge pull request #330 from kaizhang91/fix/zsh

The original behavior:
1. The whole line in terminal will be killed
2. The new command will be printed one character by one character

The new behavior:
1. The selected command will be printed on terminal directly.

The code is based on <https://github.com/junegunn/fzf/wiki/examples#locate>.
This commit is contained in:
Denis Isidoro 2020-04-07 16:00:43 -03:00 committed by GitHub
commit c81aa29eb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,11 @@
#!/usr/bin/env zsh
_call_navi() {
local -r buff="$BUFFER"
local -r r="$(printf "$(navi --print </dev/tty)")"
zle kill-whole-line
zle -U "${buff}${r}"
local selected
if selected="$(printf "$(navi --print </dev/tty)")"; then
LBUFFER="$selected"
fi
zle redisplay
}
zle -N _call_navi