Added public zet configuration

This commit is contained in:
2022-01-14 14:51:31 -05:00
parent ac03198f70
commit 41cf9345e5
3 changed files with 99 additions and 39 deletions

View File

@@ -1,39 +0,0 @@
#!/bin/sh
set -e
# Creates a new `zet` inside the public `Zettlekasten` directory.
_cmd_exists() {
command -v "$@" >/dev/null 2>&1
}
# Early out if the directory is not found.
! test -d "$ZETDIR" && echo "Can't find ${ZETDIR:-'Not Found in ENV'}" && exit 1
# Early out if `isosec` is not found.
! _cmd_exists isosec && echo "isosec not found." && exit
# Create a new directory for this note.
dir="$ZETDIR/$(isosec)"
mkdir "$dir"
# Create the readme file with the title (if supplied)
readme="$dir/README.md"
title="$*"
printf "# %s\n\n" "${title}" > "${readme}"
# Bail if the readme was not created.
! test -r "$readme" && echo "README was not created properly." && exit 1
# Auto commit the new note.
message="${title:-"Autocommit message"}"
cd "$dir"
git pull -q
git add -A "$dir"
git commit -m "$message"
git push
cd -
# Open the note.
exec vi "${readme}"