Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ v4.7.0

* Removed ``bin/todo``. It is no longer requierd, as the entry point generated
by setuptools no longer has performance issues.
* Added shell completions for fish.

v4.6.0
------
Expand Down
34 changes: 34 additions & 0 deletions contrib/completion/fish/todo.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
_TODO_COMPLETE=fish_source todo | source

function __fish_todo_complete_categories
set -l python (__fish_anypython) || return
todo --porcelain list | $python -c "
import json
import sys
events = json.load(sys.stdin)
categories = set()
for event in events:
for category in event['categories']:
categories.add(category)
print('\n'.join(categories))
"
end
complete -c todo -n "__fish_seen_subcommand_from list" -x -s c -l category -a "(__fish_todo_complete_categories)"

function __fish_todo_complete_statuses
set -l statuses NEEDS-ACTION CANCELLED COMPLETED IN-PROCESS ANY
set -l token (commandline -t)

if string match -qr ^-s -- $token
set token (string sub -s 3 -- $token)
end

set -l complete (string split , -- $token)[1..-2]

for s in $statuses
if ! string match -q -- $s $complete
string join -- , $complete $s
end
end
end
complete -c todo -n "__fish_seen_subcommand_from list" -x -s s -l status -a "(__fish_todo_complete_statuses)"
10 changes: 10 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ file ``contrib/autocompletion/zsh/_todo`` to any directory in your ``$fpath``.
Typically ``/usr/local/share/zsh/site-functions/`` is used for system-wide
installations.

fish autocompletion (optional)
------------------------------

Basic command completion for fish is provided in the contrib ``contrib``
directory. It uses the completion rules generated by ``click`` as a base and
defines some improvements on top of it. To use the completion, copy the file to
any directory read by fish, this is typically
``$XDG_CONFIG_HOME/fish/completions`` for user-specific files and something
like ``/usr/share/fish/vendor_completions.d`` for system-wide files.

Requirements
------------

Expand Down