Initial commit
This commit is contained in:
commit
35971a5c37
8
LICENSE
Normal file
8
LICENSE
Normal file
@ -0,0 +1,8 @@
|
||||
MIT License
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
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.
|
29
README.md
Normal file
29
README.md
Normal file
@ -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.
|
106
md.sh
Executable file
106
md.sh
Executable file
@ -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 $@
|
19
sample.md
Normal file
19
sample.md
Normal file
@ -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
|
||||
|
10
tags
Normal file
10
tags
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user