From c2ead888dd2efd1f2e565007513ebcea3878cb32 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 23 Jul 2024 12:00:00 +0100 Subject: [PATCH] Add `notetaker` script Add a script to quickly and easily create and edit a daily note. --- lib/shared/home-manager-packages.nix | 2 ++ lib/shared/scripts/notetaker.nix | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 lib/shared/scripts/notetaker.nix diff --git a/lib/shared/home-manager-packages.nix b/lib/shared/home-manager-packages.nix index 7e5c2ac..22023f8 100644 --- a/lib/shared/home-manager-packages.nix +++ b/lib/shared/home-manager-packages.nix @@ -6,11 +6,13 @@ let inherit (pkgs) writeShellApplication; scripts = { + notetaker = writeShellApplication (import ./scripts/notetaker.nix); t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; }); }; in with pkgs; [ + scripts.notetaker scripts.t awscli2 diff --git a/lib/shared/scripts/notetaker.nix b/lib/shared/scripts/notetaker.nix new file mode 100644 index 0000000..e1cc36a --- /dev/null +++ b/lib/shared/scripts/notetaker.nix @@ -0,0 +1,25 @@ +{ + name = "notetaker"; + + runtimeInputs = [ ]; + + text = '' + # Based on https://github.com/CalinLeafshade/dots/blob/fe685d45201f267829b75fe5ca7e3da9d4aa4c02/bin/bin/notetaker. + + today="$(date +%Y-%m-%d)" + note_path="''${NOTES_PATH:-$HOME/Documents/wiki}" + note_filename="$note_path/daily-notes/$(date +%Y)/$(date +%m)/$today.md" + + if [[ ! -f "$note_filename" ]]; then + mkdir -p "$(dirname "$note_filename")" + + echo "# $today" > "$note_filename" + fi + + nvim -c "normal Go" \ + -c "normal Go## $(date +%H:%M)" \ + -c "normal G2o" \ + -c "normal zz" \ + -c "startinsert" "$note_filename" + ''; +}