Delegate even more

This commit is contained in:
Leonora Tindall 2024-08-29 14:24:17 -05:00
parent fee04030e6
commit d11ecda8ba
6 changed files with 68 additions and 69 deletions

37
arbnote
View File

@ -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 <type> [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"

13
dnote
View File

@ -1,14 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then if [ -f "$(which nnote)" ]; then
echo "usage: dnote [notename]" NNOTE="$(which nnote)"
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."
else else
NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )"
$NOTEBIN/arbnote daily "$*" NNOTE="$NOTEBIN/nnote"
fi fi
$NNOTE daily "$*"

13
gnote
View File

@ -1,14 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then if [ -f "$(which nnote)" ]; then
echo "usage: gnote [notename]" NNOTE="$(which nnote)"
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."
else else
NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )"
$NOTEBIN/arbnote global "$*" NNOTE="$NOTEBIN/nnote"
fi fi
$NNOTE global "$*"

13
mnote
View File

@ -1,14 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then if [ -f "$(which nnote)" ]; then
echo "usage: mnote [notename]" NNOTE="$(which nnote)"
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."
else else
NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )"
$NOTEBIN/arbnote monthly "$*" NNOTE="$NOTEBIN/nnote"
fi fi
$NNOTE monthly "$*"

48
nnote Executable file
View File

@ -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 <type> [notename]"
echo " create or edit a note"
echo " nnote <type> --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

13
ynote
View File

@ -1,14 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
if [ "${1-}" == "--help" ] || [ "${1-}" == "-h" ]; then if [ -f "$(which nnote)" ]; then
echo "usage: ynote [notename]" NNOTE="$(which nnote)"
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."
else else
NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )" NOTEBIN="$( dirname -- "$( readlink -f -- "$0"; )"; )"
$NOTEBIN/arbnote yearly "$*" NNOTE="$NOTEBIN/nnote"
fi fi
$NNOTE yearly "$*"