aboutsummaryrefslogtreecommitdiff
path: root/pastebin/new.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2018-12-22 19:21:56 -0200
committerEuAndreh <eu@euandre.org>2018-12-22 19:21:56 -0200
commitc32279f814da799b1f09709fe332d626455f19e5 (patch)
tree8eebcec919286029de1068daec97f50232d37527 /pastebin/new.sh
parentFix template path. (diff)
downloadeuandre.org-c32279f814da799b1f09709fe332d626455f19e5.tar.gz
euandre.org-c32279f814da799b1f09709fe332d626455f19e5.tar.xz
Add script to scaffold new pastebin skeleton.
Diffstat (limited to '')
-rwxr-xr-xpastebin/new.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/pastebin/new.sh b/pastebin/new.sh
new file mode 100755
index 0000000..b792e33
--- /dev/null
+++ b/pastebin/new.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+set -eo pipefail
+cd "$(dirname ${BASH_SOURCE[0]})"
+
+OUTDIR="../site/pastebin"
+
+# Taken from:
+# https://stackoverflow.com/a/49035906
+slugify () {
+ echo "$1" | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z
+}
+
+if [[ -z "$1" ]]; then
+ printf "Type the pastebin title: "
+ read title
+else
+ title="$1"
+fi
+
+slug=$(slugify "$title")
+
+export title
+cat skeleton.org | envsubst > "$OUTDIR/$slug.org"