about summary refs log tree commit diff stats
path: root/hm/soispha/pkgs/scripts/wrappers/neorg
blob: 29060c972a27de3c4d1ebc67be98613d37562384 (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env dash

# shellcheck source=/dev/null
SHELL_LIBRARY_VERSION="1.3.1" . %SHELL_LIBRARY_PATH

# these are used in version()
AUTHORS="Soispha"
YEARS="2023"
VERSION="1.0.0"

NAME="neorg"

help() {
cat << EOF
This is a quick wrapper to make starting neorg easier.

Usage:
    $NAME [--help|--version] <neorg workspace>

Options:
    --help   | -h
                            Display this help and exit.
    --version   | -v
                            Display version and copyright information and exit.
    <neorg workspace>
                            The neorg workspace to open at startup, an empty value drops
                            you at a prompt to enter the workspace yourself
EOF
}

run_with_workspace() {
    nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace $1\n")"
}
run_without_workspace() {
    nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace ")"
}

neorg_workspace="";
run=true;

while [ "$#" -ne 0 ]; do
    case "$1" in
        "--help" | "-h")
            if [ "$run" = true ]; then
                help
            fi
            run=false;
            ;;
        "--version" | "-v")
            if [ "$run" = true ]; then
                version
            fi
            run=false;
            ;;
        *)
            neorg_workspace="$1";
            ;;
    esac
    shift 1
done

if [ "$neorg_workspace" ] && [ "$run" = true ];then
    run_with_workspace "$neorg_workspace";
elif [ "$run" = true ]; then
    run_without_workspace
fi

# vim: ft=sh