Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tasko): new tasko plugin #12323

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions plugins/tasko/README.md
@@ -0,0 +1,11 @@
# TaskWarrior Plugin

Open annotation content with native open commands (xdg-open or open)

To use it add `tasko` to the plugins array in your zshrc file:

```zsh
plugins=(... tasko)
```

**Note:** you have to [install taskwarrior](https://github.com/GothenburgBitFactory/taskwarrior) first.
38 changes: 38 additions & 0 deletions plugins/tasko/tasko.plugin.zsh
@@ -0,0 +1,38 @@
function _tasko_print_help() {
echo
echo "Usage: tasko {TASK} {ROW}"
echo
}

function tasko () {
if [[ $# -ne 2 ]]; then
echo 'Error: Too many/few arguments, expecting two.' >&2
_tasko_print_help
return 1
fi

local annotation_desc=$(task _get $1.annotations.$2.description 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo "Error: Task or row not found." >&2
return 1
fi

if [[ $annotation_desc == "" ]]; then
echo "Error: No text found" >&2
return 1
fi

echo "Open $annotation_desc? [y/n]"
read answer
if [[ $answer == y* ]] || [[ $answer == Y* ]]; then
if [[ $(uname -s) == "Linux" ]]; then
xdg-open $annotation_desc
return 0
else
open $annotation_desc
return 0
fi
return 1
fi
return 0
}