Generate a new header for each drafts summon
authorSiraaj Khandkar <siraaj@khandkar.net>
Fri, 20 Nov 2020 14:00:27 +0000 (09:00 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Fri, 20 Nov 2020 14:00:27 +0000 (09:00 -0500)
home/.xbindkeysrc
home/bin/drafts_prepend [new file with mode: 0755]
home/lib/login_aliases.sh

index 5c7a51c..1bdc087 100644 (file)
     Mod4 + t
 "cd ~/doc/ideas && gvim ideas.md"
     Mod4 + i
-"cd ~/doc/drafts && gvim drafts.md"
+"cd ~/doc/drafts && drafts_prepend && gvim drafts.md"
     Mod4 + d
 "cd ~/doc/bookmarks && gvim bookmarks.md"
     Mod4 + b
diff --git a/home/bin/drafts_prepend b/home/bin/drafts_prepend
new file mode 100755 (executable)
index 0000000..44df097
--- /dev/null
@@ -0,0 +1,18 @@
+#! /bin/bash
+
+set -euo pipefail
+
+FILE="$HOME/doc/drafts/drafts.md"
+
+bar() {
+    seq -s - 80 | sed -E 's/[0-9]+//g'
+}
+
+header() {
+    printf 'untitled\n'
+    bar
+    date +'started: %Y-%m-%d %H:%M:%S %z'
+    printf '\n\n'
+}
+
+(header && cat "$FILE") | sponge "$FILE"  # sponge is in moreutils package
index 2ef69b6..9448ba3 100644 (file)
@@ -13,7 +13,7 @@ alias mans='man $(man -k . | sort | fzf -e | awk "{print \$1}")'
 alias twread='twtxt timeline --limit 1000 | less'
 alias todo='cd ~/doc/TODO && vim TODO.md'
 alias work_todo="cd $DIR_WORK/docs/TODO && vim -c NERDTreeFind TODO.txt"
-alias drafts='cd ~/doc/drafts && vim drafts.md'
+alias drafts='cd ~/doc/drafts && drafts_prepend && vim drafts.md'
 alias bookmarks='cd ~/doc/bookmarks && vim bookmarks.md'
 alias ideas='cd ~/doc/ideas && vim ideas.md'
 alias quotes='cd ~/doc/quotations && vim quotations.md'
This page took 0.025012 seconds and 4 git commands to generate.