Use neovim in git
[khome.git] / home / bin / draft
CommitLineData
ab32f98a
SK
1#! /bin/bash
2
3set -euo pipefail
4
2200de00
SK
5DEFAULT_BASE="$HOME/doc/drafts/adhoc"
6
ab32f98a
SK
7bar() {
8 local -r len="${1:-80}" # 1st arg or 80.
9 local -r char="${2:--}" # 2nd arg or a dash.
10
11 seq -s "$char" "$len" | sed -E 's/[0-9]+//g'
12}
13
14main() {
2200de00
SK
15 local -r base="${1:-$DEFAULT_BASE}"
16
ab32f98a
SK
17 local -r title_given='Untitled'
18 local -r title_lower=$(echo "$title_given" | tr '[:upper:]' '[:lower:]')
19 local -r title_lower_dashed=$(echo "$title_lower" | sed 's/\s\+/-/g')
ab32f98a
SK
20 local -r timestamp="$(date --iso-8601=ns)"
21 local -r file="${base}/${timestamp}--${title_lower_dashed}.md"
22
23 mkdir -p "$base"
24 if [[ ! -a "$file" ]]
25 then
26 touch "$file"
27 {
28 echo "$title_given"
29 bar 80 '='
30 echo "started: $timestamp"
31 printf '\n\n'
32 } > "$file"
33 fi
34 echo "$file"
35}
36
37main "$@"
This page took 0.022903 seconds and 4 git commands to generate.