summaryrefslogtreecommitdiff
path: root/wd-journal
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-11-12 14:12:36 +0800
committerGuangxiong Lin <[email protected]>2022-11-12 14:12:36 +0800
commit8671b7b71a4b44db9144eaeb603ec94212cb94b3 (patch)
tree6a8a6f841570c8721b7704165f8d6e9023f34132 /wd-journal
parent35970f2cf022d5d475a92e3909ad311b38868c65 (diff)
downloadwd-8671b7b71a4b44db9144eaeb603ec94212cb94b3.tar.gz
wd-8671b7b71a4b44db9144eaeb603ec94212cb94b3.tar.bz2
wd-8671b7b71a4b44db9144eaeb603ec94212cb94b3.zip
Refactor
Diffstat (limited to 'wd-journal')
-rwxr-xr-xwd-journal52
1 files changed, 0 insertions, 52 deletions
diff --git a/wd-journal b/wd-journal
deleted file mode 100755
index 28edd46..0000000
--- a/wd-journal
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env bash
-
-year=$(date +%Y)
-week_number=$(date +%W)
-
-weekly_journal_title="# Week $week_number $year"
-weekly_journal_subtitle="## $(date '+%Y-%m-%d %A')"
-
-monthly_journal_title="# $(date '+%B %Y')"
-monthly_journal_subtitle="## [Week $week_number $year](week$week_number.md)"
-
-weekly_journal="$WD_JOURNALS_DIR/$year/week$week_number.md"
-monthly_journal="$WD_JOURNALS_DIR/$year/$(date '+%Y-%m').md"
-
-# Open weekly journal by default.
-# TODO: maybe I can add a environment variable on it.
-file_to_edit="$weekly_journal"
-
-init_journal_with_title () {
- local filepath=$1
- local journal_title=$2
-
- [ ! -f "$filepath" ] && echo "$journal_title" > "$filepath"
-}
-
-append_line_if_not_in_file () {
- local filepath=$1
- local line=$2
-
- if ! grep -qF "$line" "$filepath"; then
- echo "$line" >> "$filepath"
- fi
-}
-
-init_weekly_journal () {
- init_journal_with_title "$weekly_journal" "$weekly_journal_title"
-
- append_line_if_not_in_file "$weekly_journal" "$weekly_journal_subtitle"
-}
-
-init_monthly_journal () {
- init_journal_with_title "$monthly_journal" "$monthly_journal_title"
-
- append_line_if_not_in_file "$monthly_journal" "$monthly_journal_subtitle"
-}
-
-case "$1" in
- --monthly|-m) shift; init_monthly_journal; file_to_edit="$monthly_journal";;
- --weekly|-w) shift; init_weekly_journal; file_to_edit="$weekly_journal";;
-esac
-
-$EDITOR "$file_to_edit"