aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-11-03 23:30:23 +0530
committerAkshay Nair <phenax5@gmail.com>2025-11-03 23:30:23 +0530
commit57e213f93cf6e535e57a7b67390820927d6b79f1 (patch)
treeb32cc75dbcae9acefd6daa381a56bb54831713ae /scripts
parent5893d956b075d7e58d8c9151fa508bc190a2f747 (diff)
downloadkakoune-config-57e213f93cf6e535e57a7b67390820927d6b79f1.tar.gz
kakoune-config-57e213f93cf6e535e57a7b67390820927d6b79f1.zip
Add capturing with logger.sh
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/logger.sh58
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