feat: add fish completion

This commit is contained in:
inkch
2025-07-09 01:16:43 +09:00
parent eaa4034210
commit ea8fbd0c22

26
completions/chot.fish Normal file
View File

@@ -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)'