diff options
author | Ben Sima <ben@bsima.me> | 2022-03-14 22:05:22 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-03-14 22:05:22 -0400 |
commit | 8f32ad9e8828d3daaecac2ce46a45d277bfa8633 (patch) | |
tree | 7e8e432e25f5e234ecb56694023b78700195b74f | |
parent | 71065cfad2345bf143fe99d8fc1fccce939af68f (diff) |
z: add daily edit and title search
-rwxr-xr-x | z | 7 | ||||
-rwxr-xr-x | z-edit-daily | 12 |
2 files changed, 17 insertions, 2 deletions
@@ -3,6 +3,7 @@ # -- browse tags: # --bind "ctrl-t:unbind(change)+enable-search+preview[echo 'match: {}']+reload[rg --no-filename --only-matching '(^|\B)#\w+' | sort | uniq]" \ # - vim function to follow wiki links +# - search both title and content set -euo pipefail notesdir=${NOTES:-~/notes/notes} cd "$notesdir" @@ -15,17 +16,19 @@ fzf \ --disabled \ --header="alt+: 0=view 1=search 2=tags 3=outline 4=backlinks" \ --header-first \ + --delimiter : \ + --with-nth 1 \ --bind "ctrl-/:change-preview-window(90%|down|hidden|)" \ --bind "change:reload:$RG {q} || true" \ --bind "enter:execute($EDITOR {})" \ --bind "alt-enter:execute($EDITOR {q}.md)" \ - --bind "ctrl-space:execute($EDITOR daily/\$(date $DATEFMT).md)" \ + --bind "ctrl-space:execute($EDITOR $(z-edit-daily))" \ --bind "ctrl-r:replace-query" \ + --bind "ctrl-t:unbind(change,alt-enter)+change-prompt(title> )+enable-search+clear-query" \ --bind "pgdn:preview-page-down" \ --bind "pgup:preview-page-up" \ --bind "alt-0:preview:bat -p --color always {}" \ --bind "alt-1:preview($RG_VIEW {q} {})" \ - --bind "alt-1:+reload:$RG {q} || true" \ --bind "alt-2:preview:rg --only-matching '(^|\B)#\w+' {}" \ --bind "alt-3:preview:rg --only-matching '^[#]+ .*$' {}" \ --bind "alt-4:reload:rg -lF \$(tr -d '.md' <<< {+}) || true" \ diff --git a/z-edit-daily b/z-edit-daily new file mode 100755 index 0000000..05da963 --- /dev/null +++ b/z-edit-daily @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Return today's daily notes file. If it doesn't already exist, make it using the +# daily template. Must be executed from inside the notes directory. +# +DATEFMT="+%Y.%-m.%-d" +DATE=$(date $DATEFMT) +FILE="daily/$DATE" +if [[ ! -f "$FILE" ]]; then + cat templates/daily.md | sed "s/{{date:YYYY.M.D}}/$DATE/" > $FILE +fi +echo "$FILE" |