aboutsummaryrefslogtreecommitdiff
path: root/pastebin/new.sh
blob: b792e334faa04b43a241752abd0578d85099a89e (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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"