2 # t -- simple notes manager
3 # Copyright (C) 2013-2021 Sergey Matveev <stargrave@stargrave.org>
6 # * t -- just briefly print all notes: their number and stripped first
8 # * t N -- print N note's contents
9 # * t a [X X X] -- add a new note to the end. If arguments are specified
10 # then they will be the content. Otherwise $EDITOR is started
11 # * t d N -- delete note number N. Pay attention that other notes may
12 # change their numbers!
13 # * t m N -- edit note N with $EDITOR
14 # Also you can specify $N environment variable that acts like some kind
15 # of namespace for the notes (prepare directory first!). For example:
16 # $ N=work t a get job done
17 # $ N=work t a # it starts $EDITOR
19 # [0] get job done (1)
20 # [1] this is first line of 3-lines comment (3)
23 # [0] this is first line of 3-lines comment (3)
25 # [0] some earlier default namespace note (1)
31 find $NOTES_DIR -size 0 -delete
36 find $NOTES_DIR -maxdepth 1 -type f | sort | sed -n $(($1 + 1))p
42 for n in $(find $NOTES_DIR -maxdepth 1 -type f | sort); do
43 echo "[$cnt]" "$(sed 's/^\(.\{1,70\}\).*$/\1/;q' $n)" "($(sed -n '$=' $n))"
52 note=$NOTES_DIR/$(date "+%Y%m%d-%H%M%S")
53 [ $# -gt 0 ] && echo "$@" > $note || $EDITOR $note
59 $EDITOR $(get_note $2)
63 [ -e "$note" ] && cat $note || exit 1