taskbook
taskbook copied to clipboard
zsh completion script for taskbook
I have written a zsh completion script for taskbook, and i think it can make taskbook‘s operation more fast and convenient. Welcome everyone to try it and give some useful advice. Thanks.

Is it possible to create an Oh My Fish extension.? :thinking:
For me, it's very slow on ZSH where I can put sh file?
I see this has been dormant for a while.
But for anyone else looking.
Although not a full app, here is a script that will help with completion for fish
function __fish_taskbook_no_subcommand --description 'Test if taskbook has yet to be given the subcommand'
for i in (commandline -opc)
if contains -- $i archive begin check copy clear delete edit find list move note priority restore star task timeline version
return 1
end
end
return 0
end
function __fish_print_taskbook_id --description 'Print a list of ids for tasks and notes in taskbook' -a select
switch $select
case notes
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | select(._isTask==false) | ._id' | sed 's/:/\\:/g'
case archive_notes
cat ~/.taskbook/archive/archive.json | jq --raw-output '.[] | select(._isTask==false) | ._id' | sed 's/:/\\:/g'
case tasks
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | select(._isTask==true) | ._id' | sed 's/:/\\:/g'
case archive_tasks
cat ~/.taskbook/archive/archive.json | jq --raw-output '.[] | select(._isTask==true) | ._id' | sed 's/:/\\:/g'
case all
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | ._id' | sed 's/:/\\:/g' #.description
end
end
function __fish_print_taskbook_description --description 'Print a list of names for tasks and notes in taskbook' -a select
switch $select
case notes
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | select(._isTask==false) | .description' | sed 's/:/\\:/g'
case archive_notes
cat ~/.taskbook/archive/archive.json | jq --raw-output '.[] | select(._isTask==false) | .description' | sed 's/:/\\:/g'
case tasks
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | select(._isTask==true) | .description' | sed 's/:/\\:/g'
case archive_tasks
cat ~/.taskbook/archive/archive.json | jq --raw-output '.[] | select(._isTask==true) | .description' | sed 's/:/\\:/g'
case all
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | ._id' | sed 's/:/\\:/g' #.description
end
end
function __fish_print_taskbook_boards --description 'Print a list of boards in taskbook'
cat ~/.taskbook/storage/storage.json | jq --raw-output '.[] | @sh "\(.boards | .[])"' | sort | uniq | awk '{sub(/^\'My\sBoard\'/, "@myboard"); gsub(/\\\\|\\\.\'/,""); print $0}' | tr -d "'" | tr -d "@"
end
set -l commands None -a --archive -b --begin -c --check -y --copy --clear -d --delete -e --edit -f --find -h --help -l --list -m --move -n --note -p --priority -r --restore -s --star -t --task -i --timeline -v --version
# Main entry
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -d 'Display board view'
complete -c taskbook -f -n "not __fish_seen_subcommand_from $commands" -a 'None --archive --begin --check --copy --clear --delete --edit --find --help --list --move --note --priority --restore --star --task --timeline --version' -d 'Command'
# No sub commands
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s a -l archive -d 'Display archived items'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -l clear -d 'Delete all checked items'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s i -l timeline -d 'Display timeline view'
# Look up items by name
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s b -l begin -d 'Start/pause task'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s c -l check -d 'Check/uncheck task'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s d -l delete -d 'Delete item'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s y -l copy -d 'Copy item description'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s s -l star -d 'Star/unstar item'
complete -c taskbook -f -n '__fish_seen_subcommand_from -d --delete -b --begin -c --check -y --copy -s --star' -a '(__fish_print_taskbook_id tasks)' -d 'Task'
complete -c taskbook -f -n '__fish_seen_subcommand_from -d --delete -b --begin -c --check -y --copy -s --star' -a '(__fish_print_taskbook_id notes)' -d 'Note'
# Look up form archive
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s r -l restore -d 'Restore items from archive'
complete -c taskbook -f -n '__fish_seen_subcommand_from -r --restore' -a '(__fish_print_taskbook_id archive_tasks)' -d 'Task'
complete -c taskbook -f -n '__fish_seen_subcommand_from -r --restore' -a '(__fish_print_taskbook_id archive_notes)' -d 'Note'
# List options
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s l -l list -d 'List items by attributes'
complete -c taskbook -f -n '__fish_seen_subcommand_from -l --list' -a 'tasks' -d 'Task'
complete -c taskbook -f -n '__fish_seen_subcommand_from -l --list' -a 'notes' -d 'Notes'
complete -c taskbook -f -n '__fish_seen_subcommand_from -l --list' -a 'pending' -d 'Pending Items'
complete -c taskbook -f -n '__fish_seen_subcommand_from -l --list' -a 'started ' -d 'Tasks in-progress'
complete -c taskbook -f -n '__fish_seen_subcommand_from -l --list' -a 'done' -d 'Completed Tasks'
complete -c taskbook -f -n '__fish_seen_subcommand_from -l --list' -a 'starred' -d 'Starred Items'
#
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s m -l move -d 'Move item between boards'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s e -l edit -d 'Edit item description'
complete -c taskbook -f -n '__fish_seen_subcommand_from -m --move' -a '@(__fish_print_taskbook_id tasks)' -d 'Task'
complete -c taskbook -f -n '__fish_seen_subcommand_from -m --move' -a '@(__fish_print_taskbook_id notes)' -d 'Note'
complete -c taskbook -f -n '__fish_seen_subcommand_from -m --move' -a '(__fish_print_taskbook_boards)' -d 'Board'
complete -c taskbook -f -n '__fish_seen_subcommand_from -e --edit' -a '@(__fish_print_taskbook_id all)' -d 'Itme'
# Crete Note
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s n -l note -d 'Create note'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s t -l task -d 'Create task'
complete -c taskbook -f -n '__fish_seen_subcommand_from -n --note -t --task' -a '@(__fish_print_taskbook_boards)' -d 'Board'
complete -c taskbook -f -n '__fish_seen_subcommand_from -n --note -t --task' -a 'p:1 p:2 p:3' -d 'Set Priority'
# Set Priority
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s p -l priority -d 'Update priority of task'
complete -c taskbook -f -n '__fish_seen_subcommand_from -p --priority' -a '@(__fish_print_taskbook_id all)' -d 'Itme'
complete -c taskbook -f -n '__fish_seen_subcommand_from -p --priority' -a '1 2 3' -d 'Priority'
# Any or no Input
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s f -l find -d 'Search for items'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s h -l help -d 'Display help message'
complete -c taskbook -f -n '__fish_taskbook_no_subcommand' -s v -l version -d 'Display installed version'