dotfiles/.config/shell/bin/ned

36 lines
700 B
Text
Raw Normal View History

2022-01-13 14:47:59 -08:00
#!/bin/bash
# NEd: Note Editor (and your best friend!)
# Ned can edit and create notes in a folder you tell him to!
2022-01-20 03:18:04 -08:00
# shellcheck disable=SC2068
# set default value for $NOTES_DIR
${NOTES_DIR:="$HOME/Documents/college/2y/2q/"}
2022-01-13 14:47:59 -08:00
[ -d "$NOTES_DIR"/misc ] && mkdir "$NOTES_DIR/misc"
2022-01-20 03:18:04 -08:00
# Create misc note if no input
2022-01-13 14:47:59 -08:00
if [ -z "$1" ]; then
"$EDITOR" "$NOTES_DIR/unsorted/$(date)"
zsh
fi
2022-01-20 03:18:04 -08:00
new() {
if [ -z "$1" ]; then
"$EDITOR" "$NOTES_DIR/unsorted/$(date)"
zsh
fi
"$EDITOR" "$NOTES_DIR/$2"*"/notes/$3"
}
2022-01-13 14:47:59 -08:00
# Parse arguments
case "$1" in
# create and edit new note
2022-01-20 03:18:04 -08:00
'new'|'n') new $@;;
2022-01-13 14:47:59 -08:00
# edit ned
'e') "$EDITOR" "$(realpath "$0")";;
*) echo "no such option";;
esac