pub / plain_notes

Plain Text notes for GNULinux
git clone https://src.jayvii.de/pub/plain_notes.git
Home | Log | Files | Exports | Refs | README | RSS

commit 76cdf7c27c9cb219a3e06edb1e8c220e3b8ad55b
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Wed,  1 May 2024 17:12:52 +0200

initial script

Diffstat:
AREADME | 36++++++++++++++++++++++++++++++++++++
Anotes.sh | 44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,36 @@ +plain_notes +=========== + +requirements +------------ + +- bash +- GNU tools + - cat + - find + - sed + - sort + - uniq + - date +- some text editor (default: "vi") +- https://github.com/junegunn/fzf + +Getting started +--------------- + +Getting the script + + mkdir -p ~/.local/bin/ + wget https://src.jayvii.de/pub/plain_notes/exports/main.tar.gz -O ~/.local/bin/plain_notes.tar.gz + cd ~/.local/bin/ + tar xfvz plain_notes.tar.gz + chmod +x ~/.local/bin/notes.sh + +Ease of use additions + + echo "PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc + echo "alias notes=$HOME/.local/bin/notes.sh" >> ~/.bashrc + +Running the script may be done in an endless loop: + + while :; ~/.local/bin/notes.sh; done diff --git a/notes.sh b/notes.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2024 JayVii <jayvii[AT]posteo[DOT]de> +# SPDX-License-Identifier: GPL-3.0-or-later + +# Config ----------------------------------------------------------------------- +## Where is your notes folder? +NOTES_DIR="$HOME/Notes" +## Default category for your notes (sub-folder in $NOTES_DIR) +DEFAULT_CATEGORY="Work" +## Your Editor of choice (uses fallback, if $EDITOR is unset) +if [ -z "$EDITOR" ]; then + EDITOR="vi" +fi + +# List all Notes files --------------------------------------------------------- + +## List all present notes (remove full path from display) +FILES=$( + find "${NOTES_DIR}" -type f | \ + sed -e "s#${NOTES_DIR}/##g" +) + +## Add today's date as empty file +FILES=$( + printf "${DEFAULT_CATEGORY}/$(date +%Y_%m_%d).md\n${FILES}" | \ + sort --reverse | \ + uniq +) + +# Select Notes file ------------------------------------------------------------ +CHOOSEN=$( + echo "$FILES" | \ + fzf \ + --preview="if [ -f ${NOTES_DIR}/{} ]; then cat ${NOTES_DIR}/{}; fi" \ + --layout=reverse \ + --query="${DEFAULT_CATEGORY}" +) + +# Open Notes file -------------------------------------------------------------- +if [ ! -z "$CHOOSEN" ]; then + ${EDITOR} "${NOTES_DIR}/${CHOOSEN}" +fi + +# EOF notes.sh