mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-21 21:30:09 +00:00
Merge pull request #4237 from mcornella/fix-taskwarrior-plugin
Fix taskwarrior plugin
This commit is contained in:
commit
4f1caf0955
3 changed files with 183 additions and 150 deletions
13
plugins/taskwarrior/README.md
Normal file
13
plugins/taskwarrior/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# taskwarrior
|
||||
|
||||
This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/).
|
||||
It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
|
||||
completion definitions.
|
||||
|
||||
The latest version pulled in from the official project is of January 1st, 2015.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a
|
||||
list of available modifications for that task, etcetera.
|
|
@ -1,9 +1,6 @@
|
|||
#compdef task
|
||||
# zsh completion for taskwarrior
|
||||
#
|
||||
# taskwarrior - a command line task list manager.
|
||||
#
|
||||
# Copyright 2010 - 2011 Johannes Schlatow
|
||||
# Copyright 2010 - 2015 Johannes Schlatow
|
||||
# Copyright 2009 P.C. Shyamshankar
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
@ -30,6 +27,7 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
|
|||
_task_projects=($(task _projects))
|
||||
_task_tags=($(task _tags))
|
||||
_task_ids=($(task _ids))
|
||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
||||
_task_config=($(task _config))
|
||||
_task_columns=($(task _columns))
|
||||
_task_modifiers=(
|
||||
|
@ -50,11 +48,19 @@ _task_conjunctions=(
|
|||
'and' \
|
||||
'or' \
|
||||
'xor' \
|
||||
'\)'
|
||||
'\('
|
||||
'\)' \
|
||||
'\(' \
|
||||
'<' \
|
||||
'<=' \
|
||||
'=' \
|
||||
'!=' \
|
||||
'>=' \
|
||||
'>'
|
||||
)
|
||||
_task_cmds=($(task _commands))
|
||||
_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
|
||||
_task_cmds=($(task _commands; task _aliases))
|
||||
_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel )
|
||||
|
||||
_task_aliases=($(task _aliases))
|
||||
|
||||
_task() {
|
||||
_arguments -s -S \
|
||||
|
@ -89,11 +95,13 @@ _regex_words values 'task dates' \
|
|||
'soww:Start of work week' \
|
||||
'socw:Start of calendar week' \
|
||||
'som:Start of month' \
|
||||
'soq:Start of quarter' \
|
||||
'soy:Start of year' \
|
||||
'eow:End of week' \
|
||||
'eoww:End of work week' \
|
||||
'eocw:End of calendar week' \
|
||||
'eom:End of month' \
|
||||
'eoq:End of quarter' \
|
||||
'eoy:End of year' \
|
||||
'mon:Monday' \
|
||||
'tue:Tuesday'\
|
||||
|
@ -101,7 +109,16 @@ _regex_words values 'task dates' \
|
|||
'thu:Thursday' \
|
||||
'fri:Friday' \
|
||||
'sat:Saturday' \
|
||||
'sun:Sunday'
|
||||
'sun:Sunday' \
|
||||
'good*friday:Good Friday' \
|
||||
'easter:Easter' \
|
||||
'eastermonday:Easter Monday' \
|
||||
'ascension:Ascension' \
|
||||
'pentecost:Pentecost' \
|
||||
'midsommar:Midsommar' \
|
||||
'midsommarafton:Midsommarafton' \
|
||||
'later:Later' \
|
||||
'someday:Some Day'
|
||||
_task_dates=("$reply[@]")
|
||||
|
||||
local -a _task_reldates
|
||||
|
@ -121,6 +138,10 @@ task_dates=(
|
|||
\)
|
||||
)
|
||||
|
||||
local -a task_zshids
|
||||
_regex_words values 'task IDs' $_task_zshids
|
||||
task_zshids=("$reply[@]")
|
||||
|
||||
_regex_words values 'task frequencies' \
|
||||
'daily:Every day' \
|
||||
'day:Every day' \
|
||||
|
@ -128,7 +149,7 @@ _regex_words values 'task frequencies' \
|
|||
'weekly:Every week' \
|
||||
'biweekly:Every two weeks' \
|
||||
'fortnight:Every two weeks' \
|
||||
+ 'monthly:Every month' \
|
||||
'monthly:Every month' \
|
||||
'quarterly:Every three months' \
|
||||
'semiannual:Every six months' \
|
||||
'annual:Every year' \
|
||||
|
@ -154,20 +175,25 @@ task_freqs=(
|
|||
# attributes
|
||||
local -a task_attributes
|
||||
_regex_words -t ':' default 'task attributes' \
|
||||
'des*cription:Task description text' \
|
||||
'status:Status of task - pending, completed, deleted, waiting' \
|
||||
'pro*ject:Project name:$task_projects' \
|
||||
'du*e:Due date:$task_dates' \
|
||||
'wa*it:Date until task becomes pending:$task_dates' \
|
||||
're*cur:Recurrence frequency:$task_freqs' \
|
||||
'pri*ority:priority:$task_priorities' \
|
||||
'un*til:Recurrence end date:$task_dates' \
|
||||
'fg:Foreground color' \
|
||||
'bg:Background color' \
|
||||
'li*mit:Desired number of rows in report'
|
||||
'du*e:Due date:$task_dates' \
|
||||
're*cur:Recurrence frequency:$task_freqs' \
|
||||
'un*til:Expiration date:$task_dates' \
|
||||
'li*mit:Desired number of rows in report' \
|
||||
'wa*it:Date until task becomes pending:$task_dates' \
|
||||
'ent*ry:Date task was created:$task_dates' \
|
||||
'end:Date task was completed/deleted:$task_dates' \
|
||||
'st*art:Date task was started:$task_dates' \
|
||||
'sc*heduled:Date task is scheduled to start:$task_dates' \
|
||||
'dep*ends:Other tasks that this task depends upon:$task_zshids'
|
||||
task_attributes=("$reply[@]")
|
||||
|
||||
args=(
|
||||
\( "$task_attributes[@]" \|
|
||||
\( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
|
||||
\( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
|
||||
\( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
|
||||
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
|
||||
\( /"$word"/ \)
|
||||
|
@ -186,27 +212,6 @@ _task_filter() {
|
|||
_describe -t default 'task conjunctions' _task_conjunctions
|
||||
}
|
||||
|
||||
# merge completion
|
||||
(( $+functions[_task_merge] )) ||
|
||||
_task_merge() {
|
||||
# TODO match URIs in .taskrc
|
||||
_files
|
||||
}
|
||||
|
||||
# push completion
|
||||
(( $+functions[_task_push] )) ||
|
||||
_task_push() {
|
||||
# TODO match URIs in .taskrc
|
||||
_files
|
||||
}
|
||||
|
||||
# pull completion
|
||||
(( $+functions[_task_pull] )) ||
|
||||
_task_pull() {
|
||||
# TODO match URIs in .taskrc
|
||||
_files
|
||||
}
|
||||
|
||||
# execute completion
|
||||
(( $+functions[_task_execute] )) ||
|
||||
_task_execute() {
|
||||
|
@ -219,6 +224,34 @@ _task_id() {
|
|||
_describe -t values 'task IDs' _task_zshids
|
||||
}
|
||||
|
||||
# subcommand-only function
|
||||
(( $+functions[_task_subcommands] )) ||
|
||||
_task_subcommands() {
|
||||
local -a subcommands
|
||||
local _zshcmd
|
||||
local cmd category desc
|
||||
local lastcategory=''
|
||||
# The list is sorted by category, in the right order.
|
||||
for _zshcmd in "$_task_zshcmds[@]"; do
|
||||
# Parse out the three fields
|
||||
cmd=${_zshcmd%%:*}
|
||||
category=${${_zshcmd#*:}%%:*}
|
||||
desc=${_zshcmd#*:*:}
|
||||
|
||||
# Present each category as soon as the first entry in the *next* category
|
||||
# is seen.
|
||||
if [[ $category != $lastcategory && -n $lastcategory ]]; then
|
||||
_describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands
|
||||
subcommands=()
|
||||
fi
|
||||
|
||||
# Log the subcommand; we will process it in some future iteration.
|
||||
subcommands+=( "$cmd:$desc" )
|
||||
|
||||
lastcategory=$category
|
||||
done
|
||||
}
|
||||
|
||||
## first level completion => task sub-command completion
|
||||
(( $+functions[_task_default] )) ||
|
||||
_task_default() {
|
||||
|
@ -240,11 +273,12 @@ _task_default() {
|
|||
# update IDs
|
||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
||||
|
||||
_describe -t commands 'task command' _task_zshcmds
|
||||
_describe -t values 'task IDs' _task_zshids
|
||||
_task_subcommands
|
||||
_describe -t tasks 'task IDs' _task_zshids
|
||||
_describe -t aliases 'task aliases' _task_aliases
|
||||
_call_function ret _task_filter
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_task
|
||||
_task "$@"
|
||||
|
|
|
@ -1,17 +1,3 @@
|
|||
################################################################################
|
||||
# Author: Pete Clark
|
||||
# Email: pete[dot]clark[at]gmail[dot]com
|
||||
# Version: 0.1 (05/24/2011)
|
||||
# License: WTFPL<http://sam.zoy.org/wtfpl/>
|
||||
#
|
||||
# This oh-my-zsh plugin adds smart tab completion for
|
||||
# TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
|
||||
# script (_task) distributed with TaskWarrior for the completion definitions.
|
||||
#
|
||||
# Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
|
||||
# gives a list of available modifications for that task, etc.
|
||||
################################################################################
|
||||
|
||||
zstyle ':completion:*:*:task:*' verbose yes
|
||||
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
|
||||
|
||||
|
|
Loading…
Reference in a new issue