aboutsummaryrefslogtreecommitdiff
path: root/tasks/.create.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/.create.sh')
-rwxr-xr-xtasks/.create.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/tasks/.create.sh b/tasks/.create.sh
new file mode 100755
index 0000000..5329191
--- /dev/null
+++ b/tasks/.create.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env sh
+
+set -e
+
+if [ "${#}" -eq 0 ]; then
+ echo "Title arguments are required"
+ exit 1
+fi
+
+cd "$(dirname "$(realpath "$0")")"
+
+title="$@"
+task_file="$(
+ printf %s "$title" | \
+ tr [:upper:] [:lower:] | \
+ tr [:space:] -
+).md"
+
+cp .template.md "$task_file"
+
+sed -i "s/^\(title: \)/\1$title/" "$task_file"
+sed -i "s/^\(created at: \)/\1$(date --utc +"%Y-%m-%dT%H:%M:%S")/" "$task_file"
+
+"${EDITOR:-vi}" "$task_file"