diff --git a/completions/chot.fish b/completions/chot.fish new file mode 100644 index 0000000..e730179 --- /dev/null +++ b/completions/chot.fish @@ -0,0 +1,26 @@ +function __chot_script_dir + set -l default (string replace -r '/$' '' $XDG_DATA_HOME) + if test -z "$default" + set default "$HOME/.local/share" + end + set -l chotdir (string replace -r '/$' '' $CHOT_SCRIPT) + if test -z "$chotdir" + set chotdir "$default/chot/scripts" + end + echo $chotdir +end + +function __chot_list_scripts + set -l dir (__chot_script_dir) + if test -d $dir + for f in $dir/* + if test -f $f + basename $f + end + end + end +end + +complete -c chot -n '__fish_use_subcommand' --no-files -f -a 'edit help' +complete -c chot -n '__fish_seen_subcommand_from edit' --no-files -a '(__chot_list_scripts)' +complete -c chot -n 'not __fish_seen_subcommand_from edit' --no-files -a '(__chot_list_scripts)'