File: task.fish

package info (click to toggle)
task 2.3.0%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,728 kB
  • ctags: 4,813
  • sloc: cpp: 34,267; perl: 18,509; python: 298; sh: 257; makefile: 73; ruby: 32
file content (152 lines) | stat: -rw-r--r-- 3,596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# tab completions for the Fish shell <http://fishshell.org>
#
# taskwarrior - a command line task list manager.
#
# Copy this script to ~/.config/fish/completions/task.fish, open a new shell,
# and enjoy.
#
# Objects completed:
#  * Commands
#  * Projects
#  * Priorities
#  * Tags
#  * Attribute names and modifiers
#
#  Copyright 2009 - 2014 Mick Koch <kchmck@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php

function __fish.task.bare
    test (count (commandline -c -o)) -eq 1
end

function __fish.task.complete
    complete -c task -u $argv
end

function __fish.task.head
    task _ids
    task _commands
end

function __fish.task.attrs
    echo project
    echo priority
    echo due
    echo recur
    echo until
    echo limit
    echo wait
    echo rc
end

function __fish.task.mods
    echo before
    echo after
    echo over
    echo under
    echo none
    echo is
    echo isnt
    echo has
    echo hasnt
    echo startswith
    echo endswith
    echo word
    echo noword
end

function __fish.task.combos
    echo $argv[1]:$argv[2]

    for mod in (__fish.task.mods)
        echo $argv[1].$mod:$argv[2]
    end
end

function __fish.task.combos.simple
    __fish.task.combos $argv ""
end

function __fish.task.projects
    __fish.task.combos.simple project

    for project in (task _projects)
        __fish.task.combos project $project
    end
end

function __fish.task.priorities
    __fish.task.combos.simple priority

    for priority in H M L
        __fish.task.combos priority $priority
    end
end

function __fish.task.rc
    echo rc:

    for value in (task _config)
        echo rc.$value:
    end
end

function __fish.task.tags
    for tag in (task _tags)
        echo +$tag
        echo -$tag
    end
end

function __fish.task.match
    __fish.task.attrs | grep \^(echo $argv | sed -E "s/(\w+).+/\1/")
end

function __fish.task.attr
    for attr in (__fish.task.match $argv)
        switch $attr
            case project
                __fish.task.projects
            case priority
                __fish.task.priorities
            case rc
                __fish.task.rc
            case "*"
                __fish.task.combos.simple $attr
        end
    end
end

function __fish.task.body
    set token (commandline -ct)

    if test -n $token
        __fish.task.attr $token
    else
        __fish.task.attrs
    end

    __fish.task.tags
end

__fish.task.complete -f -n __fish.task.bare -a "(__fish.task.head)"
__fish.task.complete -f -n "not __fish.task.bare" -a "(__fish.task.body)"