-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeta-create.sh
More file actions
executable file
·89 lines (80 loc) · 1.88 KB
/
Copy pathmeta-create.sh
File metadata and controls
executable file
·89 lines (80 loc) · 1.88 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# meta-create.sh — scaffold a project's .meta sidecar (a Bunch launcher or an
# Obsidian project note) for a repo where it was not generated at copier time.
# The emitted content mirrors template/.meta/, so a project can opt into a Bunch
# or Obsidian note after the fact. Run via `task util:bunch-add` /
# `task util:obsidian-add`; pair with `util:*-install` to move the file into its
# system folder and symlink it back into .meta.
#
# Usage:
# meta-create.sh bunch <project_name> <project_slug> <projects_directory>
# meta-create.sh obsidian <project_name> <author_full_name>
set -euo pipefail
repo="$(git rev-parse --show-toplevel)"
cd "$repo"
fail() {
echo "meta-create: $*" >&2
exit 1
}
kind="${1:-}"
mkdir -p .meta
case "$kind" in
bunch)
name="${2:?project name required}"
slug="${3:?project slug required}"
projects_dir="${4:?projects directory required}"
dest=".meta/Code Project - ${name}.bunch"
if [ -e "$dest" ]; then
fail "$dest already exists"
fi
cat >"$dest" <<EOF
---
title: Code Project - ${name} 🪛
---
< snippet.code
\$ open -a 'Visual Studio Code' ${projects_dir}/${slug}/${slug}.code-workspace
%Visual Studio Code^
< snippet.maximize
EOF
;;
obsidian)
name="${2:?project name required}"
author="${3:?author full name required}"
today="$(date +%Y-%m-%d)"
dest=".meta/${name}.md"
if [ -e "$dest" ]; then
fail "$dest already exists"
fi
cat >"$dest" <<EOF
---
aliases:
tags:
- Type/Intent/Project
- seed
publish: false
status:
due:
priority:
version: 1.1
dateCreated: ${today}
dateModified: ${today}
startDate:
by: "[[${author}|Me]]"
for:
of:
from:
- "[[Projects]]"
- "[[Professional]]"
related: []
contra: []
to: []
---
# ${name}
## Inbox
EOF
;;
*)
fail "usage: meta-create.sh {bunch|obsidian} <project_name> [args...]"
;;
esac
echo "meta-create: wrote $dest"