From 35971a5c37369156ed1d711634ca31c6ae3c0445 Mon Sep 17 00:00:00 2001 From: IamTheFij Date: Fri, 27 Apr 2018 19:01:35 +0000 Subject: [PATCH] Initial commit --- LICENSE | 8 +++++ README.md | 29 +++++++++++++++ md.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ sample.md | 19 ++++++++++ tags | 10 ++++++ 5 files changed, 172 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 md.sh create mode 100644 sample.md create mode 100644 tags diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..472ac23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +MIT License +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9622499 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# markdone + +Simple extended syntax/conventions and tools to use Markdown making note taking and tasks easier + +Uses standard markdown with a few minor features: + +* Notes each will have their own file +* Notes can be tagged using a bang: `!mytag` +* Tags can be anywhere in the file +* Tasks can be written using empty brackets: `[ ]` +* They can be prefixed with `*`, if desired. This will allow for sub tasks to be organized +* Task can be tagged as well: `[ ] Task !tag` +* Checklist items should not show when listing tasks +* Similar to a task, a checklist can be prefixed with a `-` as so: `- [ ] List item` +* Dates and times can be added using some parseable or ISO format: `2018/04/10@4:00am` + +To make querying using this convention easier, a small script exists with help included. You can query tasks and notes as follows: + +```bash +$ ./md.sh help # displays help text +$ ./md.sh notes # list all notes +$ ./md.sh notes !demo # list all notes with the !demo tag +$ ./md.sh notes Shirt # list all notes that mention "Shirt" +$ ./md.sh tasks # list all open tasks +$ ./md.sh tasks done # list all done tasks +$ ./md.sh tasks all !urgent # list all tasks with the !urgent tag +``` + +The conventions listed above should make it easy to build tooling to automatically index notes and tasks, however the query script doesn't care so much as it just uses grep to search for arbitrary text. diff --git a/md.sh b/md.sh new file mode 100755 index 0000000..1c9b326 --- /dev/null +++ b/md.sh @@ -0,0 +1,106 @@ +#! /bin/bash +set -e + +GREPPRG=${GREPPRG:-grep} + +function list_notes { + echo "Notes" + echo "****************" + query="$@" + if [ "$query" == "" ]; then + query="." + fi + grep -l "$query" -R . +} + +function list_tasks { + echo "Tasks" + echo "****************" + scope=$1 + query="" + case "$scope" in + all) + inner_task=" xX" + query="${@:2}" + ;; + 'done'|closed|complete) + inner_task="xX" + query="${@:2}" + ;; + open|incomplete) + inner_task=" " + query="${@:2}" + ;; + *) + inner_task=" " + query="$@" + ;; + esac + query=".*$query" + grep "^[[:blank:]]*[^[:blank:]-][[:blank:]]*[*]\?[[:blank:]]*\[[$inner_task]\?\]$query" -R . -h +} + +function echo_help { + if [ "$1" == "notes" ]; then + cat << EOF +usage: md.sh notes [query] + +query: regex to search for in notes. [defaults to .*] + Tags are generally represented as !tagname + +EOF + + elif [ "$1" == "tasks" ]; then + cat << EOF +usage: md.sh tasks [scope] [query] + +scope: used to limit to completed or include all tasks + open|incomplete: include only open or incomplete tasks [default] + done|closed|complete: include only completed tasks + all: include all tasks, regardless of status + +query: regex to search for in each task. [defaults to .*] + Tags are generally represented as !tagname + +EOF + else + cat << EOF +usage: md.sh type [args] + +type: the type of markdone object to query + notes: list or query notes + tasks: list or query tasks + help: display this help text or help for a sub command + +EOF + fi +} + +function main { + subcmd=$1 + args=${@:2} + + case "$subcmd" in + notes) + list_notes $args + ;; + tasks) + list_tasks $args + ;; + all): + list_notes $args + echo "" + list_tasks $args + ;; + help) + echo_help $args + ;; + *) + echo "Unknown command: $subcmd" + echo_help $args + exit 1 + ;; + esac +} + +main $@ diff --git a/sample.md b/sample.md new file mode 100644 index 0000000..6b48b79 --- /dev/null +++ b/sample.md @@ -0,0 +1,19 @@ +# Sample note +!demo !project + +Got some notes here, but I need to do some stuff + +## Tasks +* [ ] Do this thing + * [ ] Sub-Related thing +* [x] Done this thing! +* [ ] Another thing with a tag !urgent +* [ ] Do something on 2018/10/10@1:00pm +* [ ] Don't forget this project! + - [ ] This has subtasks I don't want to show up in the overall list + +## Packing list for my trip: +- [ ] Shirt +- [ ] Shoes +- [ ] Pants + diff --git a/tags b/tags new file mode 100644 index 0000000..0c3b536 --- /dev/null +++ b/tags @@ -0,0 +1,10 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.8 // +echo_help md.sh /^function echo_help {$/;" f +list_notes md.sh /^function list_notes {$/;" f +list_tasks md.sh /^function list_tasks {$/;" f +main md.sh /^function main {$/;" f