Update xlaunch setxkbmap
[khome.git] / home / bin / draft
1 #! /bin/bash
2
3 set -euo pipefail
4
5 DEFAULT_BASE="$HOME/doc/drafts/adhoc"
6
7 bar() {
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
14 main() {
15 local -r base="${1:-$DEFAULT_BASE}"
16
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')
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
37 main "$@"
This page took 0.069433 seconds and 4 git commands to generate.