functions/__scriptura_new.fish (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function __scriptura_new --argument-names target
set --function remaining $argv[2..-1]
if not path is --type dir (path dirname $target)
mkdir -p $target
end
if path is --type file $target
echo "Error: $target already exists"
return 1
end
printf "%s\n%s\n" "#!/usr/bin/env fish" "$remaining" >$target
chmod +x $target
if test (count $remaining) -eq 0
__scriptura_edit $target
end
end
|