Last active
December 5, 2020 08:07
-
-
Save m-242/c7f51687ab4da8d0a90df0d1416a5acf to your computer and use it in GitHub Desktop.
Note taking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: use XDG vars and make it menu/term agnostic