set --query SD_ROOT or set --local SD_ROOT "~/sd" complete --command scriptura --no-files complete --command scriptura \ --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --short-option h --long-option help \ --description 'Display help information' complete --command scriptura \ --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --short-option n --long-option new \ --description 'Create new script' complete --command scriptura \ --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --short-option e --long-option edit \ --description 'Edit existing script' complete --command scriptura \ --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --short-option c --long-option cat \ --description 'Display script content' complete --command scriptura \ --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --short-option w --long-option which \ --description 'Display script path' complete --command scriptura \ --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --arguments '$(__scriptura_complete $SD_ROOT)' complete --command scriptura \ --condition '__fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ --condition 'not __scriptura_seen_script $(commandline -xpc)' \ --condition 'not __fish_seen_argument --short n --long new' \ --arguments '$(__scriptura_complete $SD_ROOT/$(commandline -xpc)[-1])' complete --command scriptura \ --condition '__scriptura_seen_script $(commandline -xpc)' \ --force-files function __scriptura_print --argument-names from path basename $(path filter --type file,dir --perm exec $from/*) end function __scriptura_complete --argument-names from for entry in $(path filter --type file,dir --perm exec $from/*) printf "%s\t%s\n" $(path basename $entry) $(__scriptura_help $entry) end end function __scriptura_seen_script set --function argv $argv[2..-1] set --function target $SD_ROOT if not set --query argv[1] return 1 end for i in (seq 1 (count $argv)) if test "$argv[$i]" = -- break else if path is --type dir $target/$argv[$i] set --function target $target/$argv[$i] else if path is --type file --perm exec $target/$argv[$i] return 0 else break end end return 1 end