functions/__scriptura_seen_script.fish (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | function __scriptura_seen_script --description 'Check if script name has been seen'
test (count $argv) -ne 0
or set --function argv (commandline -xpc)[2..]
if contains $argv[1] run help edit cat which new
set --erase argv[1]
end
if not set --query argv[1]
return 1
end
set --function target $SCRIPTURA_ROOT
for arg in $argv
if test "$arg" = --
break
else if path is --type dir $target/$arg
set --function target $target/$arg
else if path is --type file --perm exec $target/$arg
return 0
else
if test $argv[1] = new
# the first non-directory argument is probably a script name
return 0
end
break
end
end
return 1
end
|