From 2200de00bf85d0999f4af6f1535d97c6205ed2d8 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Thu, 30 Mar 2023 16:55:00 -0400 Subject: [PATCH] Reuse draft script for adhoc notes --- home/.xbindkeysrc | 9 +++++++-- home/bin/draft | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/home/.xbindkeysrc b/home/.xbindkeysrc index c9c1d51..e8216ec 100644 --- a/home/.xbindkeysrc +++ b/home/.xbindkeysrc @@ -153,15 +153,20 @@ "cd ~/doc/ideas && gvim ideas.md" Mod4 + i -#"cd ~/doc/drafts && drafts_prepend && gvim -c NERDTreeFind drafts.md" + "cd ~/doc/drafts && drafts_prepend && gvim drafts.md" Mod4 + d + Shift -"cd ~/doc/drafts && gvim $(draft)" +"cd ~/doc/drafts && gvim $(draft ~/doc/drafts/adhoc)" Mod4 + d + "cd ~/doc/notes && notes_prepend && gvim -c NERDTreeFind notes.md" + Mod4 + n + Shift +"cd ~/doc/notes && gvim $(draft ~/doc/notes/adhoc)" Mod4 + n + "cd ~/doc/bookmarks && gvim bookmarks.md" Mod4 + b + "cd ~/doc/quotations && gvim quotations.md" Mod4 + q diff --git a/home/bin/draft b/home/bin/draft index de7b6e4..d9f2c40 100755 --- a/home/bin/draft +++ b/home/bin/draft @@ -2,6 +2,8 @@ set -euo pipefail +DEFAULT_BASE="$HOME/doc/drafts/adhoc" + bar() { local -r len="${1:-80}" # 1st arg or 80. local -r char="${2:--}" # 2nd arg or a dash. @@ -10,10 +12,11 @@ bar() { } main() { + local -r base="${1:-$DEFAULT_BASE}" + local -r title_given='Untitled' local -r title_lower=$(echo "$title_given" | tr '[:upper:]' '[:lower:]') local -r title_lower_dashed=$(echo "$title_lower" | sed 's/\s\+/-/g') - local -r base="${HOME}/doc/drafts/adhoc" local -r timestamp="$(date --iso-8601=ns)" local -r file="${base}/${timestamp}--${title_lower_dashed}.md" -- 2.20.1