From e74d5adc66ef1cb0aeb9353edbb0f9646ebb713c Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 1 Feb 2018 17:10:21 -0800 Subject: [PATCH] Add function to be used for experimental fish-fzf completion --- .../default/fish/functions/__fzf_complete.fish | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 assets/default/fish/functions/__fzf_complete.fish diff --git a/assets/default/fish/functions/__fzf_complete.fish b/assets/default/fish/functions/__fzf_complete.fish new file mode 100644 index 0000000..9fab9b4 --- /dev/null +++ b/assets/default/fish/functions/__fzf_complete.fish @@ -0,0 +1,16 @@ +function __fzf_complete --description "Prints values passed as args or through stdin for completion through fzf, if available. This can be disabled by using ENABLE_FZF_COMPLETE" + set -l cmd "" + if count $argv > /dev/null + set cmd "string split ' ' $argv" + else + set cmd "cat" + end + + # Make fzf completion opt-in + if type -q fzf ;and [ -n $ENABLE_FZF_COMPLETE ] + set -l last_arg (string trim (commandline -t)) + eval $cmd | fzf --query=$last_arg -d " " --exit-0 --select-1 --height 40% --min-height 10 --reverse + else + eval $cmd + end +end