From e2465d5c67e8ebe6529879279c5c9e9a6efd76a1 Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Tue, 2 Mar 2021 20:25:29 -0500 Subject: fish: add baseline plugs/configs --- dot_config/private_fish/functions/.keep | 0 dot_config/private_fish/functions/autosource.fish | 30 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 dot_config/private_fish/functions/.keep create mode 100644 dot_config/private_fish/functions/autosource.fish (limited to 'dot_config/private_fish/functions') diff --git a/dot_config/private_fish/functions/.keep b/dot_config/private_fish/functions/.keep new file mode 100644 index 0000000..e69de29 diff --git a/dot_config/private_fish/functions/autosource.fish b/dot_config/private_fish/functions/autosource.fish new file mode 100644 index 0000000..c064218 --- /dev/null +++ b/dot_config/private_fish/functions/autosource.fish @@ -0,0 +1,30 @@ +set -q __fish_autosource_path +or set __fish_autosource_path $__fish_config_dir/plug + +# you must include '' for completions to work +set -q __fish_autosource_exts +or set __fish_autosource_exts .fish '' + +function autosource -S -d 'Source plugin' + for plug in $argv + for f in $__fish_autosource_path/$plug$__fish_autosource_exts + if test -f $f -a -r $f + source $f + break + end + end + end +end + +function __complete_autosource + for d in $__fish_autosource_path + set -l len (math (string length $d) + 2) # 1-index + / + for f in $d/**$__fish_autosource_exts + if test -f $f -a -r $f + echo $f | string sub -s $len + end + end + end | sort | uniq +end + +complete -c autosource -x -a "(__complete_autosource)" -- cgit v1.2.3