Skip to content

Commit 26c5863

Browse files
committed
Allow override of rm and custom fzf options
1 parent e953fcd commit 26c5863

File tree

8 files changed

+26
-9
lines changed

8 files changed

+26
-9
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ By default fifc override `tab`, but you can assign another keybinding:
5151
set -U fifc_keybinding \cx
5252
```
5353

54+
fifc will also by default use `rm` to remove temporary files, this can changed:
55+
56+
```fish
57+
# Use trash instead of rm
58+
set -U fifc_rm_cmd trash
59+
```
60+
61+
To append a custom fzf command, for example to disable the `--exact` flag and increase the fuzziness:
62+
63+
```fish
64+
set -U fifc_custom_fzf_opts +e
65+
```
66+
5467
fifc can use modern tools if available:
5568

5669
| Prefer | Fallback to | Used for | Custom options |

conf.d/fifc.fish

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ if status is-interactive
66
set -qU fifc_open_keybinding
77
or set -U fifc_open_keybinding ctrl-o
88

9+
set -qU fifc_rm_cmd
10+
or set -U fifc_rm_cmd rm
11+
12+
set -qU fifc_custom_fzf_opts
13+
or set -U fifc_custom_fzf_opts
14+
915
for mode in default insert
1016
bind --mode $mode \t _fifc
1117
bind --mode $mode $fifc_keybinding _fifc

functions/_fifc.fish

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ function _fifc
33
set -l result
44
set -Ux _fifc_extract_regex
55
set -gx _fifc_complist_path (string join '' (mktemp) "_fifc")
6-
set -gx _fifc_custom_fzf_opts
76
set -gx fifc_extracted
87
set -gx fifc_commandline
98
set -gx fifc_token (commandline --current-token)
@@ -42,7 +41,7 @@ function _fifc
4241
--preview '_fifc_action preview {} {q}' \
4342
--bind='$fifc_open_keybinding:execute(_fifc_action open {} {q} &> /dev/tty)' \
4443
--query '$fifc_query' \
45-
$_fifc_custom_fzf_opts"
44+
$fifc_custom_fzf_opts"
4645

4746
set -l cmd (string join -- " | " $source_cmd $fzf_cmd)
4847
# We use eval hack because wrapping source command
@@ -79,10 +78,9 @@ function _fifc
7978

8079
commandline --function repaint
8180

82-
rm $_fifc_complist_path
81+
command $fifc_rm_cmd $_fifc_complist_path
8382
# Clean state
8483
set -e _fifc_extract_regex
85-
set -e _fifc_custom_fzf_opts
8684
set -e _fifc_complist_path
8785
set -e fifc_token
8886
set -e fifc_group

functions/_fifc_action.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function _fifc_action
5353
eval $$comp[$i][4]
5454
break
5555
else if test "$action" = source; and test -n "$$comp[$i][5]"
56-
set _fifc_custom_fzf_opts "$$comp[$i][6]"
56+
set fifc_custom_fzf_opts "$$comp[$i][6]"
5757
if functions "$$comp[$i][5]" 1>/dev/null
5858
eval $$comp[$i][5]
5959
else

tests/test_exposed_vars.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ set -x fifc_query
4040
set actual (_fifc_action "preview" "$dir/file 1.txt" "1")
4141
@test "exposed vars fifc_query" "$actual" = 1
4242

43-
rm $_fifc_complist_path
43+
command $fifc_rm_cmd $_fifc_complist_path

tests/test_group.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ set actual (_fifc_completion_group)
2020

2121
set -e _fifc_complist
2222
set -e fifc_commandline
23-
rm $_fifc_complist_path
23+
command $fifc_rm_cmd $_fifc_complist_path

tests/test_match_order.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ set actual (_fifc_action "preview" "$dir/file 1.txt")
5555
set -e fifc_commandline
5656
set -gx _fifc_unordered_comp $curr_fifc_unordered_comp
5757
set -gx _fifc_ordered_comp $curr_fifc_ordered_comp
58-
rm $_fifc_complist_path
58+
command $fifc_rm_cmd $_fifc_complist_path

tests/test_source.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ set actual (_fifc_action "source")
2424
set -e fifc_commandline
2525
set -gx _fifc_unordered_comp $curr_fifc_unordered_comp
2626
set -gx _fifc_unordered_comp $curr_fifc_ordered_comp
27-
rm $_fifc_complist_path
27+
command $fifc_rm_cmd $_fifc_complist_path

0 commit comments

Comments
 (0)