aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-02-16 01:31:34 +0100
committerDuncaen <mail@duncano.de>2017-02-16 01:32:30 +0100
commit11803e667f4d5ac218368f51cefa1f3361675d20 (patch)
tree926d865d130dffb9962c634f8a5c5f720146515e
parent2532a4ef46003b9c537474133f12db3cc6619855 (diff)
downloaddotfiles-11803e667f4d5ac218368f51cefa1f3361675d20.tar.gz
bin: add jour
-rwxr-xr-xbin/jour18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/jour b/bin/jour
new file mode 100755
index 0000000..b551b7a
--- /dev/null
+++ b/bin/jour
@@ -0,0 +1,18 @@
+#!/bin/sh
+# jour [-d YYYY.MM.DD] [ls|read|write] - simple text journal
+
+: ${JOURNAL_DIR:=~/journal}
+: ${DAY:=$(date +%Y.%m.%d)}
+[ -d "${JOURNAL_DIR}" ] || mkdir -p "${JOURNAL_DIR}"
+while getopts "d:" opt; do
+ case "$opt" in
+ d) DAY=$OPTARG ;;
+ esac
+done
+shift $((OPTIND-1))
+case "${1:-write}" in
+l|ls) ls -1 "${JOURNAL_DIR}" ;;
+r|read) ${PAGER:-more} "${JOURNAL_DIR}/${DAY}" ;;
+w|write) ${EDITOR:-vi} "${JOURNAL_DIR}/${DAY}" ;;
+*) false ;;
+esac