-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfzshell.bash
32 lines (29 loc) · 841 Bytes
/
fzshell.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
if [[ -z $FZSHELL_BIN ]]; then
export FZSHELL_BIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fzshell"
fi
fuzzycompl_widget() {
local completion
completion=$("$FZSHELL_BIN" --cursor $READLINE_POINT "${READLINE_LINE}")
if [[ $? != 0 ]]; then
echo $completion
return 1
fi
if [[ -z $completion ]]; then
return
fi
READLINE_LINE="$completion${READLINE_LINE:$READLINE_POINT}"
READLINE_POINT=${#completion}
}
__bind_fzshell_key() {
bind -m vi-command -x "\"${1}\": fuzzycompl_widget"
bind -m vi-insert -x "\"${1}\": fuzzycompl_widget"
bind -m emacs-standard -x "\"${1}\": fuzzycompl_widget"
}
if [[ -n $FZSHELL_BIND_KEY ]]; then
__bind_fzshell_key "$FZSHELL_BIND_KEY"
else
__bind_fzshell_key "\C-n"
fi
unset -f __bind_fzshell_key
# vim:ft=bash:sw=2: