From d11ecda8ba64cc46d15fa5335f74cbb62bb5c36e Mon Sep 17 00:00:00 2001 From: Leonora Tindall Date: Thu, 29 Aug 2024 14:24:17 -0500 Subject: [PATCH] Delegate even more --- arbnote | 37 ------------------------------------- dnote | 13 +++++-------- gnote | 13 +++++-------- mnote | 13 +++++-------- nnote | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ ynote | 13 +++++-------- 6 files changed, 68 insertions(+), 69 deletions(-) delete mode 100755 arbnote create mode 100755 nnote diff --git a/arbnote b/arbnote deleted file mode 100755 index 4fb5466..0000000 --- a/arbnote +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -NOTETYPE="${1-}" -if [[ "$NOTETYPE" == "daily" ]]; then - DATESTRING="$(date +%Y/%m/%d)" - NOTEHEAD=" for $DATESTRING" -elif [[ "$NOTETYPE" == "monthly" ]]; then - DATESTRING="$(date +%Y/%m)" - NOTEHEAD=" for $DATESTRING" -elif [[ "$NOTETYPE" == "yearly" ]]; then - DATESTRING="$(date +%Y)" - NOTEHEAD=" for $DATESTRING" -elif [[ "$NOTETYPE" == "global" ]]; then - DATESTRING="" - NOTEHEAD="" -else - echo "usage: arbnote [notename]" - echo " create or edit a note" - echo " arbnote --help" - echo " print this help" - echo " " - echo "arbnote requires a type: daily, monthly, yearly, or global" - echo "if not provided, type is used for notename, too" - exit 1 -fi - -NOTESDIR="${NOTESDIR:-$HOME/Notes}" -NOTEKIND="$1" -NOTENAME="${2:-$NOTETYPE}" -DATEDIR="$NOTESDIR/$DATESTRING" -mkdir -p "$DATEDIR" -NOTEPATH="$DATEDIR/$NOTENAME" -echo "$NOTEPATH" -if ! [ -f "$NOTEPATH" ]; then - printf "$NOTENAME$NOTEHEAD\n---\n\n" > "$NOTEPATH" -fi -$EDITOR "$NOTEPATH" diff --git a/dnote b/dnote index 4c7737b..47d8a2f 100755 --- a/dnote +++ b/dnote @@ -1,14 +1,11 @@ #!/usr/bin/env bash set -euo pipefail -if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then - echo "usage: dnote [notename]" - echo " create a daily note in \$NOTESDIR/year/month/day" - echo " default \$NOTESDIR is ~/Notes" - echo " yours is ${NOTESDIR-$HOME/Notes}" - echo " default notename is 'daily'" - echo " multi word notenames accepted without quotes." +if [ -f "$(which nnote)" ]; then + NNOTE="$(which nnote)" else NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" - $NOTEBIN/arbnote daily "$*" + NNOTE="$NOTEBIN/nnote" fi +$NNOTE daily "$*" + diff --git a/gnote b/gnote index 6598ff6..4708494 100755 --- a/gnote +++ b/gnote @@ -1,14 +1,11 @@ #!/usr/bin/env bash set -euo pipefail -if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then - echo "usage: gnote [notename]" - echo " create a note in \$NOTESDIR/" - echo " default \$NOTESDIR is ~/Notes" - echo " yours is ${NOTESDIR-$HOME/Notes}" - echo " default notename is 'global'" - echo " multi word notenames accepted without quotes." +if [ -f "$(which nnote)" ]; then + NNOTE="$(which nnote)" else NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" - $NOTEBIN/arbnote global "$*" + NNOTE="$NOTEBIN/nnote" fi +$NNOTE global "$*" + diff --git a/mnote b/mnote index 9a10b4b..1499aa6 100755 --- a/mnote +++ b/mnote @@ -1,14 +1,11 @@ #!/usr/bin/env bash set -euo pipefail -if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then - echo "usage: mnote [notename]" - echo " create a monthly note in \$NOTESDIR/year/month" - echo " default \$NOTESDIR is ~/Notes" - echo " yours is ${NOTESDIR-$HOME/Notes}" - echo " default notename is 'monthly'" - echo " multi word notenames accepted without quotes." +if [ -f "$(which nnote)" ]; then + NNOTE="$(which nnote)" else NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" - $NOTEBIN/arbnote monthly "$*" + NNOTE="$NOTEBIN/nnote" fi +$NNOTE monthly "$*" + diff --git a/nnote b/nnote new file mode 100755 index 0000000..2d34dfa --- /dev/null +++ b/nnote @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -euo pipefail +NOTETYPE="${1-}" +if [[ "$NOTETYPE" == "daily" ]]; then + DATESTRING="$(date +%Y/%m/%d)" + NOTEHEAD=" for $DATESTRING" +elif [[ "$NOTETYPE" == "monthly" ]]; then + DATESTRING="$(date +%Y/%m)" + NOTEHEAD=" for $DATESTRING" +elif [[ "$NOTETYPE" == "yearly" ]]; then + DATESTRING="$(date +%Y)" + NOTEHEAD=" for $DATESTRING" +elif [[ "$NOTETYPE" == "global" ]]; then + DATESTRING="" + NOTEHEAD="" +else + echo "usage: nnote [notename]" + echo " create or edit a note" + echo " nnote --help | -h" + echo " get help for a note type" + echo " " + echo "nnote requires a type: daily, monthly, yearly, or global" + echo "if not provided, type is used for notename, too" + exit 1 +fi + +if [ "${2-}" == "--help" ] || [ "${2-}" == "-h" ]; then + echo "usage: nnote $NOTETYPE [notename]" + echo " create a $NOTETYPE note in \$NOTESDIR/$DATESTRING" + echo " default \$NOTESDIR is ~/Notes" + echo " yours is ${NOTESDIR-$HOME/Notes}" + echo " default notename is '$NOTETYPE'" + echo " multi word notenames accepted without quotes." +else + NOTESDIR="${NOTESDIR:-$HOME/Notes}" + NOTEKIND="$1" + NOTENAME="${2:-$NOTETYPE}" + DATEDIR="$NOTESDIR/$DATESTRING" + mkdir -p "$DATEDIR" + NOTEPATH="$DATEDIR/$NOTENAME" + echo "$NOTEPATH" + if ! [ -f "$NOTEPATH" ]; then + printf "$NOTENAME$NOTEHEAD\n---\n\n" > "$NOTEPATH" + fi + pushd "$NOTESDIR" > /dev/null + $EDITOR "$NOTEPATH" + popd > /dev/null +fi diff --git a/ynote b/ynote index b2518f5..1cd1c21 100755 --- a/ynote +++ b/ynote @@ -1,14 +1,11 @@ #!/usr/bin/env bash set -euo pipefail -if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then - echo "usage: ynote [notename]" - echo " create a yearly note in \$NOTESDIR/year" - echo " default \$NOTESDIR is ~/Notes" - echo " yours is ${NOTESDIR-$HOME/Notes}" - echo " default notename is 'yearly'" - echo " multi word notenames accepted without quotes." +if [ -f "$(which nnote)" ]; then + NNOTE="$(which nnote)" else NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" - $NOTEBIN/arbnote yearly "$*" + NNOTE="$NOTEBIN/nnote" fi +$NNOTE yearly "$*" +