Fix multiline behavior in the bash widget (#308)

Fixes #306 

This only happens when using the bash widget
This commit is contained in:
Denis Isidoro 2020-03-24 08:38:42 -03:00 committed by GitHub
parent 77347231d1
commit ed0759f9e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -8,5 +8,5 @@ version="${1:-$(version_from_toml)}"
echo "version: $version..."
sleep 2
git tag -a "v${version}" -m 'WIP version written in Rust. Use 1.0.0 instead'
git tag -a "v${version}"
git push origin --tags

View file

@ -1,7 +1,26 @@
#!/usr/bin/env bash
__call_navi() {
printf "$(navi --print)"
local -r result="$(navi --print)"
local -r linecount="$(echo "$result" | wc -l)"
if [[ "$linecount" -lt 2 ]]; then
printf "$result"
return 0
fi
IFS=$'\n'
local i=1;
for line in $result; do
if echo "$line" | grep -q '\\$'; then
printf "${line::-1} "
elif [[ "$i" -eq "$linecount" ]]; then
printf "$line "
else
printf "${line}; "
fi
i=$((i+1))
done
}
bind '"\C-g": " \C-b\C-k \C-u`__call_navi`\e\C-e\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"'

View file

@ -35,6 +35,9 @@ echo "<x> <y> <x> <z>"
# with preview
cat "<file>"
# fzf
ls / | fzf
$ x: echo '1 2 3' | tr ' ' '\n'
$ y: echo 'a b c' | tr ' ' '\n'
$ z: echo 'foo bar' | tr ' ' '\n'