config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 835c9217e15aac1c6183cd2ce3d1602a86958cab
parent 8d3b30cf54769a2480d805090dead0c4a35eb562
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Sun, 14 Feb 2021 21:30:21 -0800

Add jots script for quickly taking notes

Diffstat:
Amodules/scripts/.local/bin/jots | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+), 0 deletions(-)

diff --git a/modules/scripts/.local/bin/jots b/modules/scripts/.local/bin/jots @@ -0,0 +1,59 @@ +#!/bin/sh -e +# Copywrite 2021 Jacob R. Edwards +# License: GPLv3 +# +# jots -- jot down a note +# +# f[ind] Find notes +# l[ist] Find notes and display with timestamps +# s[how] Show note contents +# e[dit] Edit (or create) notes +# v[oid] Delete notes + +find() command find ${*:-.} -type f + +list() stat -t %F -f '%Sc - %N' `find $*` + +show() { + for n in `find $*` + do + list $n + awk 'BEGIN { print "" } { print " ", $0 } END { print "" }' $n + done +} + +edit() { + for n in $* + do + mkdir -p `dirname $n` + ${EDITOR:-vi} $n + done +} + +void() { + echo $* | fgrep -q .. && { + printf 'error: '\''..'\'': Invalid sequence in path.\n' 1>&2 + exit 1; + } + rm -r $* + command find . -type d -empty -delete +} + +cd "${XDG_DATA_DIR:-$HOME/.local/share}/note" + +case $1 +in +(f|find) + shift; find $*;; +(l|list) + shift; list $*;; +(s|show) + shift; show $*;; +(e|edit) + shift; edit $*;; +(v|void) + shift; void $*;; +(*) + printf 'usage: %s [list|show|edit|void] [file...]\n' `basename $0` 1>&2 + exit 1 +esac