Update zet script

This commit is contained in:
2022-01-05 20:41:06 -05:00
parent 1c18e500f4
commit 500c648c5b
2 changed files with 26 additions and 5 deletions

View File

@@ -1,13 +1,32 @@
#!/bin/sh #!/bin/sh
set -e
# Creates a new `zet` inside the public `Zettlekasten` directory. # Creates a new `zet` inside the public `Zettlekasten` directory.
dirname="$(isosec)" _cmd_exists() {
mkdir "$ZETDIR/$dirname" command -v "$@" >/dev/null 2>&1
dir="$ZETDIR/$dirname" }
# 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" readme="$dir/README.md"
title="$*" title="$*"
printf "# %s\n\n" "${title}" > "${readme}" 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"}" message="${title:-"Autocommit message"}"
cd "$dir" cd "$dir"
git pull -q git pull -q
@@ -15,4 +34,6 @@ git add -A "$dir"
git commit -m "$message" git commit -m "$message"
git push git push
cd - cd -
vi "${readme}"
# Open the note.
exec vi "${readme}"

View File

@@ -33,7 +33,7 @@ set smarttab
set softtabstop=2 set softtabstop=2
set tabstop=2 set tabstop=2
set termguicolors set termguicolors
set textwidth=200 set textwidth=72 " Used with line wrapping
set ttyfast " faster scrolling set ttyfast " faster scrolling
set undodir=~/.vim/undodir set undodir=~/.vim/undodir
set undofile set undofile