Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ By default fifc override `tab`, but you can assign another keybinding:
set -U fifc_keybinding \cx
```

fifc will also by default use `rm` to remove temporary files, this can changed:

```fish
# Use trash instead of rm
set -U fifc_rm_cmd trash
```

To append custom fzf options globally, for example to disable the `--exact` flag and increase the fuzziness:

```fish
set -U fifc_custom_fzf_opts +e
```

fifc can use modern tools if available:

| Prefer | Fallback to | Used for | Custom options |
Expand Down
3 changes: 3 additions & 0 deletions conf.d/fifc.fish
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ if status is-interactive
set -qU fifc_open_keybinding
or set -U fifc_open_keybinding ctrl-o

set -qU fifc_rm_cmd
or set -U fifc_rm_cmd rm

for mode in default insert
bind --mode $mode \t _fifc
bind --mode $mode $fifc_keybinding _fifc
Expand Down
17 changes: 11 additions & 6 deletions functions/_fifc.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ function _fifc
set -l result
set -Ux _fifc_extract_regex
set -gx _fifc_complist_path (string join '' (mktemp) "_fifc")
set -gx _fifc_custom_fzf_opts
set -gx fifc_extracted
set -gx fifc_commandline
set -gx fifc_token (commandline --current-token)
set -gx fifc_query "$fifc_token"
set -gx fifc_effective_fzf_opts $fifc_custom_fzf_opts

# Get commandline buffer
if test "$argv" = ""
Expand All @@ -25,7 +25,7 @@ function _fifc
set -gx fifc_group (_fifc_completion_group)
set source_cmd (_fifc_action source)

set fifc_fzf_query (string trim --chars '\'' -- "$fifc_fzf_query")
set fifc_safe_query (string unescape -- "$fifc_query")

set -l fzf_cmd "
_fifc_launched_by_fzf=1 SHELL=fish fzf \
Expand All @@ -41,8 +41,8 @@ function _fifc
--header '$header' \
--preview '_fifc_action preview {} {q}' \
--bind='$fifc_open_keybinding:execute(_fifc_action open {} {q} &> /dev/tty)' \
--query '$fifc_query' \
$_fifc_custom_fzf_opts"
--query '$fifc_safe_query' \
$fifc_effective_fzf_opts"

set -l cmd (string join -- " | " $source_cmd $fzf_cmd)
# We use eval hack because wrapping source command
Expand Down Expand Up @@ -79,11 +79,16 @@ function _fifc

commandline --function repaint

rm $_fifc_complist_path
set -l fifc_rm_cmd_effective rm
if set -q fifc_rm_cmd
set fifc_rm_cmd_effective $fifc_rm_cmd
end

command $fifc_rm_cmd_effective $_fifc_complist_path
# Clean state
set -e _fifc_extract_regex
set -e _fifc_custom_fzf_opts
set -e _fifc_complist_path
set -e fifc_effective_fzf_opts
set -e fifc_token
set -e fifc_group
set -e fifc_extracted
Expand Down
2 changes: 1 addition & 1 deletion functions/_fifc_action.fish
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function _fifc_action
eval $$comp[$i][4]
break
else if test "$action" = source; and test -n "$$comp[$i][5]"
set _fifc_custom_fzf_opts "$$comp[$i][6]"
set fifc_effective_fzf_opts $fifc_custom_fzf_opts $$comp[$i][6]
if functions "$$comp[$i][5]" 1>/dev/null
eval $$comp[$i][5]
else
Expand Down