jschlatow / taskopen

Tool for taking notes and open urls with taskwarrior
GNU General Public License v2.0
363 stars 31 forks source link

Can't figure out how get default notes working with version 2 #159

Closed sdondley closed 1 year ago

sdondley commented 1 year ago

I used version 1 of this software and it worked fine. I'm upgrading to version 2 but I'm having problems getting things to work. I'm not sure if the README is still accurate or if I have something misconfigured. Either way, I'm having a hard time following exactly how to get this configured so it works.

My first problem is trying to get default notes working with the instructions at https://github.com/jschlatow/taskopen#add-default-notes

When I do task 1 annotate Notes all it does it add a text annotation called "Notes. When I try taskopen 1, it says `No actions applicable." I'm not sure what this means or how to resolve it. Here's the diagnostic output:

> $ taskopen diagnostics
Environment
  Platform:       Mac OSX
  Taskopen:       v2.0.0beta-7-gb006dce
  Taskwarrior:    2.6.2
  Configuration:  /Users/steve/.taskopenrc
Current configuration
  Binaries and paths:
    taskbin            = task
    taskargs           =
    editor             = nvim
    path_ext           = /usr/local/share/taskopen/scripts
  General:
    debug              = false
    no_annotation_hook = addnote
    task_attributes    = priority,project,tags,description
  Action groups:
  Subcommands:
    default            = normal
  Actions:
    files
      .target          = annotations
      .regex           = ^[\.\/~]+.*\.(.*)
      .labelregex      = .*
      .command         = open $FILE
      .modes           = batch,any,normal
    notes
      .target          = annotations
      .regex           = ^Notes\.(.*)
      .labelregex      = .*
      .command         = editnote ~/notes/tasknotes/$UUID.$LAST_MATCH "$TASK_DE
                         SCRIPTION" $UUID
      .modes           = batch,any,normal
    url
      .target          = annotations
      .regex           = ((?:www|http).*)
      .labelregex      = .*
      .command         = open $LAST_MATCH
      .modes           = batch,any,normal

The path to editnote appears to be fine, it returns: Usage: /Users/steve/bin/editnote <file-path> <description> <uuid>

Thanks.

jschlatow commented 1 year ago

@sdondley Thanks for opening this issue. It seems I made a mistake in the default config. Can you please change the following lines in your .taskopenrc file:

notes.regex = "^Notes\\.(.*)"
notes.command = "editnote ~/Notes/tasknotes/$UUID.$LAST_MATCH \"$TASK_DESCRIPTION\" $UUID"

into

notes.regex = "^Notes(\\..*)?"                                                                                                                                 
notes.command = "editnote ~/Notes/tasknotes/$UUID$LAST_MATCH \"$TASK_DESCRIPTION\" $UUID"
sdondley commented 1 year ago

Changing the notes.regex value to your suggestion didn't actually work but this did:

notes.regex="^Notes$"
notes.command="editnote ~/notes/tasknotes/$UUID$LAST_MATCH \"$TASK_DESCRIPTION\" $UUID"

Thanks for the hand.

sdondley commented 1 year ago

OK, I've been playing around with this a bit more to get a feel for how this might work. I would like the default notes to be recognized as a vimwiki/taskwiki file. So I add the following line to my vimwiki config:

{path = '~/Documents/notes/tasknotes', auto_toc = 1, syntax = 'markdown', ext = '.md', name = 'tasknotes'},

Now, I need the notes to be markdown files with an markdown extension of *.md to be recognized. So from the command line I do:

task 123 annotate Notes.md

To get this to work, I need the following config settings:

notes.regex="^Notes\\.(.*)?"
notes.command="editnote ~/Documents/notes/tasknotes/$UUID.$LAST_MATCH \"$TASK_DESCRIPTION\" $UUID"

So now when I do:

taskopen 123

It opens the file up as a markdown file with a filetype set to vimwiki.

Is this how it's intended to be used?

jschlatow commented 1 year ago

Yes, that is the intended use.

With the modified regex that I posted above, it should be possible to omit the extension though. At least it does so on my Linux machine.

sdondley commented 1 year ago

Is that regex used by bash or Nim?

I'm using zsh so maybe that's part of the problem?

sdondley commented 1 year ago

Changing the regex to notes.regex="^Notes\\.?(.*)?" seems to work well. Note the question mark after the first period, making the period optional.

jschlatow commented 1 year ago

It's used by Nim. Maybe there is a difference in the PCRE library on Mac.

sdondley commented 1 year ago

I just tried your initial suggestion for the regex again and it worked this time. I must have had a typo in my first attempt.

At any rate, I'm going to default to using .md files. Is there any good reason that I might not want to?

jschlatow commented 1 year ago

I just tried your initial suggestion for the regex again and it worked this time. I must have had a typo in my first attempt.

Perfect. Thanks for re-testing.

At any rate, I'm going to default to using .md files. Is there any good reason that I might not want to?

I cannot think of any ;-)