Skip to content

Commit

Permalink
Fix multiline behavior in the bash widget (#308)
Browse files Browse the repository at this point in the history
Fixes #306 

This only happens when using the bash widget
  • Loading branch information
denisidoro authored Mar 24, 2020
1 parent 7734723 commit ed0759f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/tag
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 20 additions & 1 deletion shell/navi.plugin.bash
Original file line number Diff line number Diff line change
@@ -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"'
3 changes: 3 additions & 0 deletions tests/cheats/more_cases.cheat
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit ed0759f

Please sign in to comment.