diff options
Diffstat (limited to '')
-rwxr-xr-x | pastebin/new.sh | 23 |
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" |