-
Notifications
You must be signed in to change notification settings - Fork 6
/
intelli-shell.fish
executable file
·52 lines (47 loc) · 1.26 KB
/
intelli-shell.fish
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function intelli-shell --description 'IntelliShell'
$INTELLI_HOME/bin/intelli-shell $argv;
end
function _intelli_exec
set p_lines (fish_prompt | string split0 | wc -l)
# Swap stderr and stdout
if test (math $p_lines + 0) -gt "1"
set INTELLI_OUTPUT (intelli-shell --inline --inline-extra-line $argv 3>&1 1>&2 2>&3)
else
set INTELLI_OUTPUT (intelli-shell --inline $argv 3>&1 1>&2 2>&3)
end
# Replace line
commandline -f repaint
commandline -r "$INTELLI_OUTPUT"
end
function _intelli_search
set LINE (commandline)
_intelli_exec search "$LINE"
end
function _intelli_save
set LINE (commandline)
_intelli_exec new -c "$LINE"
end
function _intelli_label
set LINE (commandline)
_intelli_exec label "$LINE"
end
function fish_user_key_bindings
if [ "$INTELLI_SKIP_ESC_BIND" != "1" ]
bind --preset \e 'kill-whole-line'
end
if test -n "$INTELLI_SEARCH_HOTKEY"
bind $INTELLI_SEARCH_HOTKEY '_intelli_search'
else
bind -k nul '_intelli_search'
end
if test -n "$INTELLI_SAVE_HOTKEY"
bind $INTELLI_SAVE_HOTKEY '_intelli_save'
else
bind \cb '_intelli_save'
end
if test -n "$INTELLI_LABEL_HOTKEY"
bind $INTELLI_LABEL_HOTKEY '_intelli_label'
else
bind \cl '_intelli_label'
end
end