mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
Added public zet configuration
This commit is contained in:
@@ -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}"
|
||||
Reference in New Issue
Block a user