jschlatow / taskopen

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

Request: Ability to execute arbirtary shell commands #126

Closed ghost closed 4 years ago

ghost commented 4 years ago

In emacs org-mode, there's an ability to create links that can execute arbitrary commands. One use case for this is to do taskopen a task annotated as pacman -Syu to update the system.

jschlatow commented 4 years ago

@saheratarch thanks for the request. I am wondering whether the -x argument already satisfies your use case. Please try the following:

$> task add test
Created task 42
$> task 42 ann -- echo "Hello world!"
$> taskopen 42 -x
ghost commented 4 years ago

It didn't work. The output is:

$ taskopen 42 -x
No compatible annotation found.
jschlatow commented 4 years ago

Can you please provide the output of task <id> info and taskopen -V?

ghost commented 4 years ago
$ task 45 info

Name          Value
------------- -----------------------------------------
ID            45
Description   test
                2020-03-30 11:58:04 echo Hello world
Status        Pending
Entered       2020-03-30 11:57:43 (2min)
Last modified 2020-03-30 11:58:04 (1min)
Virtual tags  ANNOTATED PENDING READY UNBLOCKED LATEST
UUID          52badc2c-2144-4626-9c7d-0b176712e6b7
Urgency        2.6

    annotations      0.8 *    1 =    0.8
    UDA priority.      1 *  1.8 =    1.8
                                  ------
                                     2.6

Date                Modification
------------------- ---------------------------------------
2020-03-30 11:58:04 Annotation of 'echo Hello world' added.

The other output is

$ taskopen 45 -V

Taskopen, release v1.1.4, revision 286 (879c0ff)
Copyright 2010-2016, Johannes Schlatow.

Environment
    Platform:      linux
    Perl:          v5.30.1
    Taskwarrior:   2.5.1
    xdg-open:      xdg-open 1.1.3+
    Configuration: /home/saher/.config/taskopen/taskopenrc

Current configuration
  Binaries and paths:
    BROWSER            = xdg-open
    TASKBIN            = task rc.verbose=off rc.json.array=on
    EDITOR             = nvim
    FILE_CMD           = xdg-open
    PATH               = /usr/local//share/taskopen/scripts:/home/saher/scripts:/home/saher/scripts:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

  Others:
    NOTES_FOLDER       = $HOME/.task/notes/
    NOTES_EXT          = .md
    NOTES_FILE         = $HOME/.task/notes/UUID.md
    NOTES_CMD          = nvim "$HOME/.task/notes/UUID.md"
    DEFAULT_FILTER     = status.is:pending
    DEFAULT_SORT       = 
                current: 
    DEFAULT-i          = ls -la
                current: ls -la
    DEFAULT-x          = $FILE
    DEBUG              = 0
    NOTES_REGEX        = notes
    BROWSER_REGEX      = www|http
    FILE_REGEX         = \.|\/|~
    TEXT_REGEX         = 
    NO_ANNOTATION_HOOK = 
    TASK_ATTRIBUTES    = 
  Custom regex commands:
jschlatow commented 4 years ago

Unfortunately, you must set a regex so that the annotation is recognized by taskopen as a relevant annotation. For instance, you can set TEXT_REGEX=".*".

ghost commented 4 years ago

I've set it up, and it worked perfectly. Thank you for creating such an amazing program. I hope your script will be included in the core task warrior project in the future.