From e5874f0825b39211c4c54757f0c6ef9c0991d2d1 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Sat, 21 Nov 2020 17:48:44 -0500 Subject: [PATCH] Add notes-adding helpers --- home/.xbindkeysrc | 4 +++- home/bin/notes_prepend | 18 ++++++++++++++++++ home/lib/login_aliases.sh | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 home/bin/notes_prepend diff --git a/home/.xbindkeysrc b/home/.xbindkeysrc index 1bdc087..9e37e4a 100644 --- a/home/.xbindkeysrc +++ b/home/.xbindkeysrc @@ -120,7 +120,7 @@ "st -e htop" Mod4 + h "st -e ncmpcpp" - Mod4 + n + Mod4 + m "st -e ranger" Mod4 + r @@ -143,6 +143,8 @@ Mod4 + i "cd ~/doc/drafts && drafts_prepend && gvim drafts.md" Mod4 + d +"cd ~/doc/notes && notes_prepend && gvim notes.md" + Mod4 + n "cd ~/doc/bookmarks && gvim bookmarks.md" Mod4 + b "cd ~/doc/quotations && gvim quotations.md" diff --git a/home/bin/notes_prepend b/home/bin/notes_prepend new file mode 100755 index 0000000..b6b1d3f --- /dev/null +++ b/home/bin/notes_prepend @@ -0,0 +1,18 @@ +#! /bin/bash + +set -euo pipefail + +FILE="$HOME/doc/notes/notes.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 diff --git a/home/lib/login_aliases.sh b/home/lib/login_aliases.sh index 9448ba3..0bb1895 100644 --- a/home/lib/login_aliases.sh +++ b/home/lib/login_aliases.sh @@ -14,6 +14,7 @@ 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 && drafts_prepend && vim drafts.md' +alias notes='cd ~/doc/notes && notes_prepend && vim notes.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' -- 2.20.1