Skip to content

Commit 6ad7054

Browse files
committed
Allow override of rm and custom fzf options
1 parent 1bc3014 commit 6ad7054

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ 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+
5461
fifc can use modern tools if available:
5562

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

conf.d/fifc.fish

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ if not set --query --universal fifc_open_keybinding
1111
set --universal fifc_open_keybinding ctrl-o
1212
end
1313

14+
if not set --query --universal fifc_rm_cmd
15+
set --universal fifc_rm_cmd rm
16+
end
17+
18+
if not set --query --universal fifc_custom_fzf_opts
19+
set --universal fifc_custom_fzf_opts
20+
end
21+
1422

1523
# Private
1624
set -gx _fifc_comp_count 0

functions/_fifc.fish

Lines changed: 3 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,8 @@ 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"
45+
echo $fzf_cmd
4646

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

8080
commandline --function repaint
8181

82-
rm $_fifc_complist_path
82+
$fifc_rm_cmd $_fifc_complist_path
8383
# Clean state
8484
set -e _fifc_extract_regex
85-
set -e _fifc_custom_fzf_opts
8685
set -e _fifc_complist_path
8786
set -e fifc_token
8887
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+
$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+
$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+
$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+
$fifc_rm_cmd $_fifc_complist_path

0 commit comments

Comments
 (0)