diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/logger.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/logger.sh b/scripts/logger.sh new file mode 100755 index 0000000..0598c03 --- /dev/null +++ b/scripts/logger.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env sh + +set -e -o pipefail + +logger_path="$HOME/nixos/extras/notes/logger" + +journal() { + capture_and_edit_date_log journal << EOF +* $(date +%r) +New entry +EOF +} + +record() { + capture_and_edit_date_log record << EOF +* $(date +%r) +** Situation +- +** Thoughts +- +** Feelings +- +** Actions +- +EOF +} + +link() { capture_link "$@"; } + +capture_and_edit_date_log() { + path="${logger_path}/$1/$(date +%F).org"; + mkdir -p "${logger_path}/$1"; + cat >> "$path"; + echo -e "" >> "$path"; + edit "$path"; +} + +capture_link() { + [ $# -gt 0 ] || (echo "Please specify link to capture"; exit 1) + link="$1" + category="${2:-default}" + mkdir -p "${logger_path}/links"; + path="${logger_path}/links/$category.org"; + echo "[[$link]]" >> "$path"; + notify-send "Captured $link in $category" +} + +edit() { + setsid -f sh -c "exec ${EDITOR:-"${VISUAL:-kak}"} $@"; +} + +mkdir -p "$logger_path"; +cmd="$1"; shift 1; +case "$cmd" in + journal) journal ;; + record) record ;; + link) link "$@" ;; +esac |
