all repos — scriptura @ v0.0.3

a corner in $HOME for your scripts

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
20
21
function __scriptura_new
    argparse --stop-nonopt --move-unknown e/edit -- $argv
    set --function target $argv[1]
    set --function remaining $argv[2..]

    if not path is --type dir (path dirname $target)
        mkdir -p (path dirname $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; or set --query _flag_edit
        __scriptura_edit $target
    end
end