summaryrefslogtreecommitdiff
path: root/dot_config/private_fish/functions
diff options
context:
space:
mode:
authorChloe Kudryavtsev <toast@toast.cafe>2021-03-02 20:25:29 -0500
committerChloe Kudryavtsev <toast@toast.cafe>2021-03-02 20:25:29 -0500
commite2465d5c67e8ebe6529879279c5c9e9a6efd76a1 (patch)
treedcf4a5cda24df211e7db558aa492e5e89c304f5d /dot_config/private_fish/functions
parentmigrate git email, explicitly configure foot $TERM (diff)
fish: add baseline plugs/configs
Diffstat (limited to '')
-rw-r--r--dot_config/private_fish/functions/.keep0
-rw-r--r--dot_config/private_fish/functions/autosource.fish30
2 files changed, 30 insertions, 0 deletions
diff --git a/dot_config/private_fish/functions/.keep b/dot_config/private_fish/functions/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/dot_config/private_fish/functions/.keep
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)"