feat: add fish completion
This commit is contained in:
26
completions/chot.fish
Normal file
26
completions/chot.fish
Normal 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)'
|
Reference in New Issue
Block a user