Skip to content

Instantly share code, notes, and snippets.

@m-242
Last active December 5, 2020 08:07
Show Gist options
  • Save m-242/c7f51687ab4da8d0a90df0d1416a5acf to your computer and use it in GitHub Desktop.
Save m-242/c7f51687ab4da8d0a90df0d1416a5acf to your computer and use it in GitHub Desktop.
Note taking
#!/bin/sh
# A note simple note taking script, in Markdown format.
# Needs st and dmenu.
editnote() {
st "-c" 'Notes' "-i" "-e" "$EDITOR" "$1"
}
get_file() {
choice=$(printf \
"new note\n%s" "$(find "$NOTES_DIRECTORY" -type f)"\
| dmenu -p "What note ?")
case "$choice" in
"new note")
new_file=$(find "$NOTES_DIRECTORY" -type d \
| dmenu -p "file name ?")
echo "$new_file".md
;;
*)
echo "$choice"
;;
esac
}
NOTES_DIRECTORY="${NOTES_DIRECTORY:-$HOME/.local/notes/}"
[ -d "$NOTES_DIRECTORY" ] || mkdir -p "$NOTES_DIRECTORY"
file=$(get_file)
[ -n "$file" ] && editnote "$file"
@m-242
Copy link
Author

m-242 commented Dec 5, 2020

TODO: use XDG vars and make it menu/term agnostic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment