mirror of
https://github.com/denisidoro/navi
synced 2025-02-16 12:38:28 +00:00
Add fallback widget for bash < 4 (#375)
This commit is contained in:
parent
13a3b9d949
commit
4c0151c95c
1 changed files with 28 additions and 1 deletions
|
@ -16,4 +16,31 @@ _call_navi() {
|
|||
fi
|
||||
}
|
||||
|
||||
bind -x '"\C-g": _call_navi'
|
||||
__call_navi_legacy_versions() {
|
||||
local -r result="$(navi --print)"
|
||||
local -r linecount="$(echo "$result" | wc -l)"
|
||||
|
||||
if [[ "$linecount" -lt 2 ]]; then
|
||||
printf "%s" "$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
|
||||
}
|
||||
|
||||
if [ ${BASH_VERSION:0:1} -lt 4 ]; then
|
||||
bind '"\C-g": " \C-b\C-k \C-u`__call_navi_legacy_versions`\e\C-e\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"'
|
||||
else
|
||||
bind -x '"\C-g": _call_navi'
|
||||
fi
|
Loading…
Add table
Reference in a new issue