aboutsummaryrefslogtreecommitdiff
path: root/fish/functions/_fzf_wrapper.fish
diff options
context:
space:
mode:
authorIndrajith K L2024-06-27 17:51:18 +0530
committerIndrajith K L2024-06-27 17:51:18 +0530
commit57eb70137b5bbcdabdc0f02eea5477b3e5f845a1 (patch)
treee78187146c506d5a640545dee99cc3e9860e25dc /fish/functions/_fzf_wrapper.fish
downloaddots-57eb70137b5bbcdabdc0f02eea5477b3e5f845a1.tar.gz
dots-57eb70137b5bbcdabdc0f02eea5477b3e5f845a1.tar.bz2
dots-57eb70137b5bbcdabdc0f02eea5477b3e5f845a1.zip
Adds Arch Linux dotfiles
Diffstat (limited to 'fish/functions/_fzf_wrapper.fish')
-rw-r--r--fish/functions/_fzf_wrapper.fish21
1 files changed, 21 insertions, 0 deletions
diff --git a/fish/functions/_fzf_wrapper.fish b/fish/functions/_fzf_wrapper.fish
new file mode 100644
index 000000000..486e36c32
--- /dev/null
+++ b/fish/functions/_fzf_wrapper.fish
@@ -0,0 +1,21 @@
+function _fzf_wrapper --description "Prepares some environment variables before executing fzf."
+ # Make sure fzf uses fish to execute preview commands, some of which
+ # are autoloaded fish functions so don't exist in other shells.
+ # Use --function so that it doesn't clobber SHELL outside this function.
+ set -f --export SHELL (command --search fish)
+
+ # If neither FZF_DEFAULT_OPTS nor FZF_DEFAULT_OPTS_FILE are set, then set some sane defaults.
+ # See https://github.com/junegunn/fzf#environment-variables
+ set --query FZF_DEFAULT_OPTS FZF_DEFAULT_OPTS_FILE
+ if test $status -eq 2
+ # cycle allows jumping between the first and last results, making scrolling faster
+ # layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env
+ # border shows where the fzf window begins and ends
+ # height=90% leaves space to see the current command and some scrollback, maintaining context of work
+ # preview-window=wrap wraps long lines in the preview window, making reading easier
+ # marker=* makes the multi-select marker more distinguishable from the pointer (since both default to >)
+ set --export FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"'
+ end
+
+ fzf $argv
+end