├── README.markdown └── tasknote /README.markdown: -------------------------------------------------------------------------------- 1 | tasknote 2 | ======== 3 | 4 | The script automatically opens your text editor (defaults to vim) and allows you to edit notes. Upon saving notes, an annotation is added to the task to alert you to the fact that notes exist for that task. The annotation captures the first line of the note file and is updated with every modification to the file. 5 | 6 | History 7 | ------- 8 | * Original implementation: Alan Bowen 9 | * Update to taskwarrior 2.0: Michael Bobroski 10 | * Context-aware annotations: Bjoern Doebel 11 | 12 | Usage 13 | ----- 14 | 15 | **Create/Edit Note:** 16 | 17 | `tasknote ` 18 | 19 | **View Note:** 20 | 21 | `tasknote v` 22 | 23 | Actually, you can type anything after that comes to mind: v, view, show, list, cat etc. I left it open since no other features are planned. 24 | 25 | Configuration 26 | ------------- 27 | Save in a place like /usr/bin and flag as executable with sudo chmod a+x /usr/bin/tasknote. 28 | 29 | Be sure to edit the FOLDER var in the script. If it does not exist, you will be asked if you want to create it during the first run. 30 | 31 | You can also configure the EDITOR (default: vim), VIEWER (default: cat), as well as NOTEMSG, the annotation message appended to the task in taskwarrior. 32 | -------------------------------------------------------------------------------- /tasknote: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################### 4 | # tasknote - associate note file with individual tasks in taskwarrior 5 | # 6 | # Copyright 2011, Alan Bowen, bowen@tcnj.edu. 7 | # All rights reserved. 8 | # 9 | # based on taskopen - file based notes with taskwarrior 10 | # 11 | # Copyright 2010, Johannes Schlatow. 12 | # All rights reserved. 13 | # 14 | # This program is free software; you can redistribute it and/or modify it under 15 | # the terms of the GNU General Public License as published by the Free Software 16 | # Foundation; either version 2 of the License, or (at your option) any later 17 | # version. 18 | # 19 | # This program is distributed in the hope that it will be useful, but WITHOUT 20 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 21 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 22 | # details. 23 | # 24 | # You should have received a copy of the GNU General Public License along with 25 | # this program; if not, write to the 26 | # 27 | # Free Software Foundation, Inc., 28 | # 51 Franklin Street, Fifth Floor, 29 | # Boston, MA 30 | # 02110-1301 31 | # USA 32 | # 33 | ############################################################################### 34 | 35 | # Updated 2012, Michael Bobroski 36 | # - Updated to work with Taskwarrior 2.0 37 | # - View Note Feature 38 | # - Allow relative path for FOLDER 39 | 40 | EDITOR=vim 41 | TASKBIN=task 42 | VIEWER=cat 43 | 44 | # FOLDER to store notes in. Must already exist. 45 | # If you sync tasks, FOLDER should be a location that syncs and is available to 46 | # other computers, i.e. ~/dropbox/tasknotes 47 | FOLDER="~/Dropbox/tasks/notes/" 48 | 49 | # Check for existence of $FOLDER 50 | if [ ! -d $FOLDER ]; then 51 | echo "Notes folder '$FOLDER' does not exist." 52 | echo -n "Shall I create it (y/n)? " 53 | read answer 54 | if [ $answer == "y" ]; then 55 | echo "Creating '$FOLDER'." 56 | mkdir -p $FOLDER; 57 | else 58 | echo "Did NOT create $FOLDER. Exiting." 59 | exit 1; 60 | fi 61 | fi 62 | 63 | # Preferred extension for tasknotes 64 | EXT=".txt" 65 | 66 | # Message that gets annotated to the task to indicate that notes exist 67 | NOTEMSG="See Notes File" 68 | 69 | # Display usage if task number not supplied on cli 70 | if [ $# -lt 1 -o $# -gt 2 ]; then 71 | echo "Usage:" 72 | echo " New/Edit note: $0 " 73 | echo " View note: $0 v" 74 | exit 1 75 | fi 76 | 77 | #find UUID from given task 78 | uuid=`$TASKBIN $1 uuids` 79 | 80 | # build full path & file name to store notes in 81 | folder=`echo $FOLDER | sed "s|^~|$HOME|"` 82 | file="$folder$uuid$EXT" 83 | 84 | # determine if notes file already exists 85 | fileexists=0 86 | if [ -f $file ]; then 87 | fileexists=1 88 | fi 89 | 90 | # Display note if requested and exit 91 | if [ $# -gt 1 ]; then 92 | if [ $fileexists = 1 ]; then 93 | $SHELL -c "$VIEWER $file" 94 | else 95 | echo "File not found" 96 | fi 97 | exit 1 98 | fi 99 | 100 | #create/edit $file with editor 101 | $SHELL -c "$EDITOR $file" 102 | 103 | # Create a note message representing the first line of 104 | # the edited note file. 105 | if [ -f $file ]; then 106 | NOTEMSG="[tasknote] `head -1 $file`" 107 | # remove any previous annotation - we want only a single 108 | # tasknote annotation. Detection works through the 109 | # [tasknote] annotation prefix 110 | $SHELL -c "$TASKBIN $* denotate \"[tasknote]\"" 111 | $SHELL -c "$TASKBIN $* annotate '$NOTEMSG'" 112 | fi 113 | 114 | exit 0 115 | --------------------------------------------------------------------------------