summaryrefslogtreecommitdiff
path: root/new.sh
diff options
context:
space:
mode:
Diffstat (limited to 'new.sh')
-rwxr-xr-xnew.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/new.sh b/new.sh
new file mode 100755
index 0000000..0664940
--- /dev/null
+++ b/new.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+read -rp 'Title: ' title
+draft=drafts/$(date +'%Y-%m-%d')-$(printf "$title" | tr -Cs '[:alnum:]' '-' | tr '[:upper:]' '[:lower:]').php
+
+cat > "$draft" << EOF
+<?php
+\$title = "$title";
+if (isset(\$early) && \$early) {
+return;
+}
+include(\$_SERVER['DOCUMENT_ROOT'] . '/includes/head.php');
+?>
+
+EOF
+
+$EDITOR "$draft"
+
+read -rp 'Publish? [y/N]: ' choice
+[ 'y' = "$choice" ] && mv "$draft" posts/ || echo Saved draft.
+
+read -rp 'Go live? [y/N]: ' choice
+[ 'y' = "$choice" ] && git commit && git push origin && git push live || echo Deferred publish.