diff options
Diffstat (limited to 'home-config/fish/functions/_fzf_wrapper.fish')
-rw-r--r-- | home-config/fish/functions/_fzf_wrapper.fish | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/home-config/fish/functions/_fzf_wrapper.fish b/home-config/fish/functions/_fzf_wrapper.fish new file mode 100644 index 0000000..45556ce --- /dev/null +++ b/home-config/fish/functions/_fzf_wrapper.fish | |||
@@ -0,0 +1,20 @@ | |||
1 | function _fzf_wrapper --description "Prepares some environment variables before executing fzf." | ||
2 | # Make sure fzf uses fish to execute preview commands, some of which | ||
3 | # are autoloaded fish functions so don't exist in other shells. | ||
4 | # Use --function so that it doesn't clobber SHELL outside this function. | ||
5 | set -f --export SHELL (command --search fish) | ||
6 | |||
7 | # If FZF_DEFAULT_OPTS is not set, then set some sane defaults. | ||
8 | # See https://github.com/junegunn/fzf#environment-variables | ||
9 | if not set --query FZF_DEFAULT_OPTS | ||
10 | # cycle allows jumping between the first and last results, making scrolling faster | ||
11 | # layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env | ||
12 | # border shows where the fzf window begins and ends | ||
13 | # height=90% leaves space to see the current command and some scrollback, maintaining context of work | ||
14 | # preview-window=wrap wraps long lines in the preview window, making reading easier | ||
15 | # marker=* makes the multi-select marker more distinguishable from the pointer (since both default to >) | ||
16 | set --export FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"' | ||
17 | end | ||
18 | |||
19 | fzf $argv | ||
20 | end | ||