|
1 | | -# Keybindings |
2 | | -for mode in default insert |
3 | | - if not set --query --universal fifc_keybinding |
| 1 | +if status is-interactive |
| 2 | + # Keybindings |
| 3 | + set -qU fifc_keybinding |
| 4 | + or set -U fifc_keybinding \t |
| 5 | + |
| 6 | + set -qU fifc_open_keybinding |
| 7 | + or set -U fifc_open_keybinding ctrl-o |
| 8 | + |
| 9 | + for mode in default insert |
4 | 10 | bind --mode $mode \t _fifc |
5 | | - else |
6 | 11 | bind --mode $mode $fifc_keybinding _fifc |
7 | 12 | end |
8 | | -end |
9 | | - |
10 | | -if not set --query --universal fifc_open_keybinding |
11 | | - set --universal fifc_open_keybinding ctrl-o |
12 | | -end |
13 | | - |
14 | 13 |
|
15 | | -# Private |
16 | | -set -gx _fifc_comp_count 0 |
17 | | -set -gx _fifc_unordered_comp |
18 | | -set -gx _fifc_ordered_comp |
| 14 | + # Only load fifc rules when fish is launched fzf |
| 15 | +else if set -q _fifc_launched_by_fzf |
| 16 | + # Private |
| 17 | + set -gx _fifc_comp_count 0 |
| 18 | + set -gx _fifc_unordered_comp |
| 19 | + set -gx _fifc_ordered_comp |
19 | 20 |
|
20 | | -# Set sources |
21 | | -fifc \ |
22 | | - -n 'test "$fifc_group" = "directories"' \ |
23 | | - -s _fifc_source_directories |
24 | | -fifc \ |
25 | | - -n 'test "$fifc_group" = "files"' \ |
26 | | - -s _fifc_source_files |
27 | | -fifc \ |
28 | | - -n 'test "$fifc_group" = processes' \ |
29 | | - -s 'ps -ax -o pid=,command=' |
30 | | - |
31 | | -# Builtin preview/open commands |
32 | | -fifc \ |
33 | | - -n 'test "$fifc_group" = "options"' \ |
34 | | - -p _fifc_preview_opt \ |
35 | | - -o _fifc_open_opt |
36 | | -fifc \ |
37 | | - -n 'test \( -n "$fifc_desc" -o -z "$fifc_commandline" \); and type -q -f -- "$fifc_candidate"' \ |
38 | | - -r '^(?!\\w+\\h+)' \ |
39 | | - -p _fifc_preview_cmd \ |
40 | | - -o _fifc_open_cmd |
41 | | -fifc \ |
42 | | - -n 'test -n "$fifc_desc" -o -z "$fifc_commandline"' \ |
43 | | - -r '^(functions)?\\h+' \ |
44 | | - -p _fifc_preview_fn \ |
45 | | - -o _fifc_open_fn |
46 | | -fifc \ |
47 | | - -n 'test -f "$fifc_candidate"' \ |
48 | | - -p _fifc_preview_file \ |
49 | | - -o _fifc_open_file |
50 | | -fifc \ |
51 | | - -n 'test -d "$fifc_candidate"' \ |
52 | | - -p _fifc_preview_dir \ |
53 | | - -o _fifc_open_dir |
54 | | -fifc \ |
55 | | - -n 'test "$fifc_group" = processes -a (ps -p (_fifc_parse_pid "$fifc_candidate") &>/dev/null)' \ |
56 | | - -p _fifc_preview_process \ |
57 | | - -o _fifc_open_process \ |
58 | | - -e '^\\h*([0-9]+)' |
| 21 | + # Set sources |
| 22 | + fifc \ |
| 23 | + -n 'test "$fifc_group" = "directories"' \ |
| 24 | + -s _fifc_source_directories |
| 25 | + fifc \ |
| 26 | + -n 'test "$fifc_group" = "files"' \ |
| 27 | + -s _fifc_source_files |
| 28 | + fifc \ |
| 29 | + -n 'test "$fifc_group" = processes' \ |
| 30 | + -s 'ps -ax -o pid=,command=' |
59 | 31 |
|
| 32 | + # Builtin preview/open commands |
| 33 | + fifc \ |
| 34 | + -n 'test "$fifc_group" = "options"' \ |
| 35 | + -p _fifc_preview_opt \ |
| 36 | + -o _fifc_open_opt |
| 37 | + fifc \ |
| 38 | + -n 'test \( -n "$fifc_desc" -o -z "$fifc_commandline" \); and type -q -f -- "$fifc_candidate"' \ |
| 39 | + -r '^(?!\\w+\\h+)' \ |
| 40 | + -p _fifc_preview_cmd \ |
| 41 | + -o _fifc_open_cmd |
| 42 | + fifc \ |
| 43 | + -n 'test -n "$fifc_desc" -o -z "$fifc_commandline"' \ |
| 44 | + -r '^(functions)?\\h+' \ |
| 45 | + -p _fifc_preview_fn \ |
| 46 | + -o _fifc_open_fn |
| 47 | + fifc \ |
| 48 | + -n 'test -f "$fifc_candidate"' \ |
| 49 | + -p _fifc_preview_file \ |
| 50 | + -o _fifc_open_file |
| 51 | + fifc \ |
| 52 | + -n 'test -d "$fifc_candidate"' \ |
| 53 | + -p _fifc_preview_dir \ |
| 54 | + -o _fifc_open_dir |
| 55 | + fifc \ |
| 56 | + -n 'test "$fifc_group" = processes -a (ps -p (_fifc_parse_pid "$fifc_candidate") &>/dev/null)' \ |
| 57 | + -p _fifc_preview_process \ |
| 58 | + -o _fifc_open_process \ |
| 59 | + -e '^\\h*([0-9]+)' |
| 60 | +end |
60 | 61 |
|
61 | 62 | # Fisher |
62 | 63 | function _fifc_uninstall --on-event fifc_uninstall |
63 | | - for i in (seq (count $_fifc_unordered_comp)) |
64 | | - set -e $_fifc_unordered_comp[$i] |
65 | | - end |
66 | | - |
67 | | - for i in (seq (count $_fifc_ordered_comp)) |
68 | | - set -e $_fifc_ordered_comp[$i] |
69 | | - end |
70 | | - |
71 | | - set -e _fifc_comp_count |
72 | | - set -e _fifc_source_count |
73 | | - set -e _fifc_unordered_comp |
74 | | - set -e _fifc_ordered_comp |
75 | 64 | end |
0 commit comments