Skip to content

Commit 98ea370

Browse files
committed
Add bash keybindings file
1 parent 7cd3a48 commit 98ea370

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/shelloracle/shelloracle.bash

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
__shelloracle__() {
2+
local output
3+
output=$(python3 -m shelloracle) || return
4+
READLINE_LINE=${output#*$'\t'}
5+
if [[ -z "$READLINE_POINT" ]]; then
6+
echo "$READLINE_LINE"
7+
else
8+
READLINE_POINT=0x7fffffff
9+
fi
10+
}
11+
12+
if (( BASH_VERSINFO[0] < 4 )); then
13+
bind -m emacs-standard '"\C-f": "\C-e \C-u\C-y\ey\C-u"$(__shelloracle__)"\e\C-e\er"'
14+
bind -m vi-command '"\C-f": "\C-z\C-r\C-z"'
15+
bind -m vi-insert '"\C-f": "\C-z\C-r\C-z"'
16+
else
17+
bind -m emacs-standard -x '"\C-f": __shelloracle__'
18+
bind -m vi-command -x '"\C-f": __shelloracle__'
19+
bind -m vi-insert -x '"\C-f": __shelloracle__'
20+
fi

0 commit comments

Comments
 (0)