diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2022-10-05 16:33:10 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2022-10-05 16:33:10 +0100 |
commit | 9fff448654308b1e1b3d1129c0255544f56c25cc (patch) | |
tree | eda78717611d7a6b2204ba8e9f73af90e69ae90b /fish/completions |
initial
Diffstat (limited to 'fish/completions')
-rw-r--r-- | fish/completions/bcompiler.fish | 7 | ||||
-rw-r--r-- | fish/completions/catnote.fish | 1 | ||||
-rw-r--r-- | fish/completions/fisher.fish | 1 | ||||
-rw-r--r-- | fish/completions/hl-monthly-for-account.fish | 1 | ||||
-rw-r--r-- | fish/completions/hl-weekly-for-account.fish | 1 | ||||
-rw-r--r-- | fish/completions/pass.fish | 117 | ||||
-rw-r--r-- | fish/completions/pipenv.fish | 1 | ||||
-rw-r--r-- | fish/completions/poetry.fish | 145 | ||||
-rw-r--r-- | fish/completions/task.fish | 449 | ||||
-rw-r--r-- | fish/completions/task.sh | 194 | ||||
-rw-r--r-- | fish/completions/twdft.fish | 6 |
11 files changed, 923 insertions, 0 deletions
diff --git a/fish/completions/bcompiler.fish b/fish/completions/bcompiler.fish new file mode 100644 index 0000000..57d6433 --- /dev/null +++ b/fish/completions/bcompiler.fish @@ -0,0 +1,7 @@ +complete -c "bcompiler" -s h -l help -d "Get help for bcompiler" +complete -c "bcompiler" -s c -l clean-datamap -d "Clean the datamap" +complete -c "bcompiler" -s v -l version -d "Ask for version" +complete -c "bcompiler" -s p -l parse -d "Parse master.csv and transpose" -a "(find ~/Documents/bcompiler/source -maxdepth 1 | grep master)" +complete -c "bcompiler" -s a -l all -d "Create new populated templates from master.csv" +complete -c "bcompiler" -l compare -d "Compare old master with current one" -a "old_master" +complete -c "bcompiler" -s ll -d "Debugging options" -a "DEBUG INFO WARNING ERROR CRITICAL" diff --git a/fish/completions/catnote.fish b/fish/completions/catnote.fish new file mode 100644 index 0000000..d4d7165 --- /dev/null +++ b/fish/completions/catnote.fish @@ -0,0 +1 @@ +complete -c "catnote" -a "(find /home/lemon/Nextcloud/Textnotes -type f)" diff --git a/fish/completions/fisher.fish b/fish/completions/fisher.fish new file mode 100644 index 0000000..61a3810 --- /dev/null +++ b/fish/completions/fisher.fish @@ -0,0 +1 @@ +fisher --complete diff --git a/fish/completions/hl-monthly-for-account.fish b/fish/completions/hl-monthly-for-account.fish new file mode 100644 index 0000000..1c38c98 --- /dev/null +++ b/fish/completions/hl-monthly-for-account.fish @@ -0,0 +1 @@ +complete -c "hl-monthly-for-account" -d "hledger register by month for account" -a "(hledger account)" diff --git a/fish/completions/hl-weekly-for-account.fish b/fish/completions/hl-weekly-for-account.fish new file mode 100644 index 0000000..bd0e801 --- /dev/null +++ b/fish/completions/hl-weekly-for-account.fish @@ -0,0 +1 @@ +complete -c "hl-weekly-for-account" -d "hledger register by month for account" -a "(hledger account)" diff --git a/fish/completions/pass.fish b/fish/completions/pass.fish new file mode 100644 index 0000000..3e70af1 --- /dev/null +++ b/fish/completions/pass.fish @@ -0,0 +1,117 @@ +#!/usr/bin/env fish + +# Copyright (C) 2012-2014 Dmitry Medvinsky <me@dmedvinsky.name>. All Rights Reserved. +# This file is licensed under the GPLv2+. Please see COPYING for more information. + +set -l PROG 'pass' + +function __fish_pass_get_prefix + set -l prefix "$PASSWORD_STORE_DIR" + if [ -z "$prefix" ] + set prefix "$HOME/.password-store" + end + echo "$prefix" +end + +function __fish_pass_needs_command + [ (count (commandline -opc)) -eq 1 ] +end + +function __fish_pass_uses_command + set -l cmd (commandline -opc) + if [ (count $cmd) -gt 1 ] + if [ $argv[1] = $cmd[2] ] + return 0 + end + end + return 1 +end + +function __fish_pass_print_gpg_keys + gpg2 --list-keys | grep uid | sed 's/.*<\(.*\)>/\1/' +end + +function __fish_pass_print + set -l ext $argv[1] + set -l strip $argv[2] + set -l prefix (__fish_pass_get_prefix) + set -l matches $prefix/**$ext + printf '%s\n' $matches | sed "s#$prefix/\(.*\)$strip#\1#" +end + +function __fish_pass_print_entry_dirs + __fish_pass_print "/" +end + +function __fish_pass_print_entries + __fish_pass_print ".gpg" ".gpg" +end + +function __fish_pass_print_entries_and_dirs + __fish_pass_print_entry_dirs + __fish_pass_print_entries +end + +function __fish_pass_git_complete + set -l prefix (__fish_pass_get_prefix) + set -l git_cmd (commandline -opc) (commandline -ct) + set -e git_cmd[1 2] # Drop "pass git". + complete -C"git -C $prefix $git_cmd" +end + +complete -c $PROG -f -n '__fish_pass_needs_command' -a help -d 'Command: show usage help' +complete -c $PROG -f -n '__fish_pass_needs_command' -a version -d 'Command: show program version' + +complete -c $PROG -f -n '__fish_pass_needs_command' -a init -d 'Command: initialize new password storage' +complete -c $PROG -f -n '__fish_pass_uses_command init' -s p -l path -d 'Assign gpg-id for specified sub folder of password store' + +complete -c $PROG -f -n '__fish_pass_needs_command' -a ls -d 'Command: list passwords' +complete -c $PROG -f -n '__fish_pass_uses_command ls' -a "(__fish_pass_print_entry_dirs)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a insert -d 'Command: insert new password' +complete -c $PROG -f -n '__fish_pass_uses_command insert' -s e -l echo -d 'Echo the password on console' +complete -c $PROG -f -n '__fish_pass_uses_command insert' -s m -l multiline -d 'Provide multiline password entry' +complete -c $PROG -f -n '__fish_pass_uses_command insert' -s f -l force -d 'Do not prompt before overwritting' +complete -c $PROG -f -n '__fish_pass_uses_command insert' -a "(__fish_pass_print_entry_dirs)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a generate -d 'Command: generate new password' +complete -c $PROG -f -n '__fish_pass_uses_command generate' -s n -l no-symbols -d 'Do not use special symbols' +complete -c $PROG -f -n '__fish_pass_uses_command generate' -s c -l clip -d 'Put the password in clipboard' +complete -c $PROG -f -n '__fish_pass_uses_command generate' -s f -l force -d 'Do not prompt before overwritting' +complete -c $PROG -f -n '__fish_pass_uses_command generate' -s i -l in-place -d 'Replace only the first line with the generated password' +complete -c $PROG -f -n '__fish_pass_uses_command generate' -a "(__fish_pass_print_entry_dirs)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a mv -d 'Command: rename existing password' +complete -c $PROG -f -n '__fish_pass_uses_command mv' -s f -l force -d 'Force rename' +complete -c $PROG -f -n '__fish_pass_uses_command mv' -a "(__fish_pass_print_entries_and_dirs)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a cp -d 'Command: copy existing password' +complete -c $PROG -f -n '__fish_pass_uses_command cp' -s f -l force -d 'Force copy' +complete -c $PROG -f -n '__fish_pass_uses_command cp' -a "(__fish_pass_print_entries_and_dirs)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a rm -d 'Command: remove existing password' +complete -c $PROG -f -n '__fish_pass_uses_command rm' -s r -l recursive -d 'Remove password groups recursively' +complete -c $PROG -f -n '__fish_pass_uses_command rm' -s f -l force -d 'Force removal' +complete -c $PROG -f -n '__fish_pass_uses_command rm' -a "(__fish_pass_print_entries_and_dirs)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a edit -d 'Command: edit password using text editor' +complete -c $PROG -f -n '__fish_pass_uses_command edit' -a "(__fish_pass_print_entries)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a show -d 'Command: show existing password' +complete -c $PROG -f -n '__fish_pass_uses_command show' -s c -l clip -d 'Put password in clipboard' +complete -c $PROG -f -n '__fish_pass_uses_command show' -a "(__fish_pass_print_entries)" +# When no command is given, `show` is defaulted. +complete -c $PROG -f -n '__fish_pass_needs_command' -s c -l clip -d 'Put password in clipboard' +complete -c $PROG -f -n '__fish_pass_needs_command' -a "(__fish_pass_print_entries)" +complete -c $PROG -f -n '__fish_pass_uses_command -c' -a "(__fish_pass_print_entries)" +complete -c $PROG -f -n '__fish_pass_uses_command --clip' -a "(__fish_pass_print_entries)" + +complete -c $PROG -f -n '__fish_pass_needs_command' -a git -d 'Command: execute a git command' +complete -c $PROG -f -n '__fish_pass_uses_command git' -a '(__fish_pass_git_complete)' +complete -c $PROG -f -n '__fish_pass_needs_command' -a find -d 'Command: find a password file or directory matching pattern' +complete -c $PROG -f -n '__fish_pass_needs_command' -a grep -d 'Command: search inside of decrypted password files for matching pattern' +complete -c $PROG -f -n '__fish_pass_uses_command grep' -a '(begin + set -l cmd (commandline -opc) (commandline -ct) + set -e cmd[1 2] # Drop "pass grep". + complete -C"grep $cmd" +end)' diff --git a/fish/completions/pipenv.fish b/fish/completions/pipenv.fish new file mode 100644 index 0000000..01ca3be --- /dev/null +++ b/fish/completions/pipenv.fish @@ -0,0 +1 @@ +eval (pipenv --completion) diff --git a/fish/completions/poetry.fish b/fish/completions/poetry.fish new file mode 100644 index 0000000..2d3f76c --- /dev/null +++ b/fish/completions/poetry.fish @@ -0,0 +1,145 @@ +function __fish_poetry_3a61cd031c563512_complete_no_subcommand + for i in (commandline -opc) + if contains -- $i about add build cache:clear check config debug:info debug:resolve develop help init install list lock new publish remove run script search self:update shell show update version + return 1 + end + end + return 0 +end + +# global options +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l ansi -d 'Force ANSI output' +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l help -d 'Display this help message' +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l no-ansi -d 'Disable ANSI output' +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l no-interaction -d 'Do not ask any interactive question' +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l quiet -d 'Do not output any message' +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l verbose -d 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug' +complete -c poetry -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -l version -d 'Display this application version' + +# commands +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a about -d 'Short information about Poetry.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a add -d 'Add a new dependency to pyproject.toml.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a build -d 'Builds a package, as a tarball and a wheel by default.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a cache:clear -d 'Clears poetry\'s cache.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a check -d 'Checks the validity of the pyproject.toml file.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a config -d 'Sets/Gets config options.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a debug:info -d 'Shows debug information.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a debug:resolve -d 'Debugs dependency resolution.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a develop -d 'Installs the current project in development mode. (Deprecated)' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a help -d 'Displays help for a command' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a init -d 'Creates a basic pyproject.toml file in the current directory.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a install -d 'Installs the project dependencies.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a list -d 'Lists commands' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a lock -d 'Locks the project dependencies.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a new -d 'Creates a new Python project at <path>' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a publish -d 'Publishes a package to a remote repository.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a remove -d 'Removes a package from the project dependencies.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a run -d 'Runs a command in the appropriate environment.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a script -d 'Executes a script defined in pyproject.toml. (Deprecated)' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a search -d 'Searches for packages on remote repositories.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a self:update -d 'Updates poetry to the latest version.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a shell -d 'Spawns a shell within the virtual environment.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a show -d 'Shows information about packages.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a update -d 'Update dependencies as according to the pyproject.toml file.' +complete -c poetry -f -n '__fish_poetry_3a61cd031c563512_complete_no_subcommand' -a version -d 'Bumps the version of the project.' + +# command options + +# about + +# add +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l allow-prereleases -d 'Accept prereleases.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l dev -d 'Add package as development dependency.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l dry-run -d 'Outputs the operations but will not execute anything (implicitly enables --verbose).' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l extras -d 'Extras to activate for the dependency.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l git -d 'The url of the Git repository.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l optional -d 'Add as an optional dependency.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l path -d 'The path to a dependency.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l platform -d 'Platforms for which the dependencies must be installed.' +complete -c poetry -A -n '__fish_seen_subcommand_from add' -l python -d 'Python version( for which the dependencies must be installed.' + +# build +complete -c poetry -A -n '__fish_seen_subcommand_from build' -l format -d 'Limit the format to either wheel or sdist.' + +# cache:clear +complete -c poetry -A -n '__fish_seen_subcommand_from cache:clear' -l all -d 'Clear all entries in cache.' + +# check + +# config +complete -c poetry -A -n '__fish_seen_subcommand_from config' -l list -d 'List configuration settings' +complete -c poetry -A -n '__fish_seen_subcommand_from config' -l unset -d 'Unset configuration setting' + +# debug:info + +# debug:resolve +complete -c poetry -A -n '__fish_seen_subcommand_from debug:resolve' -l extras -d 'Extras to activate for the dependency.' +complete -c poetry -A -n '__fish_seen_subcommand_from debug:resolve' -l install -d 'Show what would be installed for the current system.' +complete -c poetry -A -n '__fish_seen_subcommand_from debug:resolve' -l python -d 'Python version(s) to use for resolution.' +complete -c poetry -A -n '__fish_seen_subcommand_from debug:resolve' -l tree -d 'Displays the dependency tree.' + +# develop + +# help +complete -c poetry -A -n '__fish_seen_subcommand_from help' -l format -d 'The output format (txt, json, or md)' +complete -c poetry -A -n '__fish_seen_subcommand_from help' -l raw -d 'To output raw command help' + +# init +complete -c poetry -A -n '__fish_seen_subcommand_from init' -l author -d 'Author name of the package' +complete -c poetry -A -n '__fish_seen_subcommand_from init' -l dependency -d 'Package to require with an optional version constraint, e.g. requests:^2.10.0 or requests=2.11.1' +complete -c poetry -A -n '__fish_seen_subcommand_from init' -l description -d 'Description of the package' +complete -c poetry -A -n '__fish_seen_subcommand_from init' -l dev-dependency -d 'Package to require for development with an optional version constraint, e.g. requests:^2.10.0 or requests=2.11.1' +complete -c poetry -A -n '__fish_seen_subcommand_from init' -l license -d 'License of the package' +complete -c poetry -A -n '__fish_seen_subcommand_from init' -l name -d 'Name of the package' + +# install +complete -c poetry -A -n '__fish_seen_subcommand_from install' -l develop -d 'Install given packages in development mode.' +complete -c poetry -A -n '__fish_seen_subcommand_from install' -l dry-run -d 'Outputs the operations but will not execute anything (implicitly enables --verbose).' +complete -c poetry -A -n '__fish_seen_subcommand_from install' -l extras -d 'Extra sets of dependencies to install.' +complete -c poetry -A -n '__fish_seen_subcommand_from install' -l no-dev -d 'Do not install dev dependencies.' + +# list +complete -c poetry -A -n '__fish_seen_subcommand_from list' -l format -d 'The output format (txt, json, or md)' +complete -c poetry -A -n '__fish_seen_subcommand_from list' -l raw -d 'To output raw command list' + +# lock + +# new +complete -c poetry -A -n '__fish_seen_subcommand_from new' -l name -d 'Set the resulting package name.' +complete -c poetry -A -n '__fish_seen_subcommand_from new' -l src -d 'Use the src layout for the project.' + +# publish +complete -c poetry -A -n '__fish_seen_subcommand_from publish' -l build -d 'Build the package before publishing.' +complete -c poetry -A -n '__fish_seen_subcommand_from publish' -l password -d 'The password to access the repository.' +complete -c poetry -A -n '__fish_seen_subcommand_from publish' -l repository -d 'The repository to publish the package to.' +complete -c poetry -A -n '__fish_seen_subcommand_from publish' -l username -d 'The username to access the repository.' + +# remove +complete -c poetry -A -n '__fish_seen_subcommand_from remove' -l dev -d 'Removes a package from the development dependencies.' +complete -c poetry -A -n '__fish_seen_subcommand_from remove' -l dry-run -d 'Outputs the operations but will not execute anything (implicitly enables --verbose).' + +# run + +# script + +# search +complete -c poetry -A -n '__fish_seen_subcommand_from search' -l only-name -d 'Search only in name.' + +# self:update +complete -c poetry -A -n '__fish_seen_subcommand_from self:update' -l preview -d 'Install prereleases.' + +# shell + +# show +complete -c poetry -A -n '__fish_seen_subcommand_from show' -l all -d 'Show all packages (even those not compatible with current system).' +complete -c poetry -A -n '__fish_seen_subcommand_from show' -l latest -d 'Show the latest version.' +complete -c poetry -A -n '__fish_seen_subcommand_from show' -l no-dev -d 'Do not list the dev dependencies.' +complete -c poetry -A -n '__fish_seen_subcommand_from show' -l outdated -d 'Show the latest version but only for packages that are outdated.' +complete -c poetry -A -n '__fish_seen_subcommand_from show' -l tree -d 'List the dependencies as a tree.' + +# update +complete -c poetry -A -n '__fish_seen_subcommand_from update' -l dry-run -d 'Outputs the operations but will not execute anything (implicitly enables --verbose).' +complete -c poetry -A -n '__fish_seen_subcommand_from update' -l lock -d 'Do not perform install (only update the lockfile).' +complete -c poetry -A -n '__fish_seen_subcommand_from update' -l no-dev -d 'Do not install dev dependencies.' + +# version diff --git a/fish/completions/task.fish b/fish/completions/task.fish new file mode 100644 index 0000000..f7057b8 --- /dev/null +++ b/fish/completions/task.fish @@ -0,0 +1,449 @@ +# Taskwarrior completions for the Fish shell <https://fishshell.com> +# +# taskwarrior - a command line task list manager. +# +# Completions should work out of box. If it isn't, fill the bug report on your +# operation system bug tracker. +# +# As a workaround you can copy this script to +# ~/.config/fish/completions/task.fish, and open a new shell. +# +# Objects completed: +# * Commands +# * Projects +# * Priorities +# * Tags +# * Attribute names and modifiers +# +# +# You can override some default options in your config.fish: +# +# # Tab-completion of task descriptions. +# # Warning: This often creates a list of suggestions which spans several pages, +# # and it usually pushes some of the commands and attributes to the end of the +# # list. +# set -g task_complete_task yes +# +# # Tab-completion of task IDs outside of the "depends" attribute. +# # Warning: This often creates a list of suggestions which spans several pages, +# # and it pushes all commands and attributes to the end of the list. +# set -g task_complete_id yes +# +# # Attribute modifiers (DEPRECATED since 2.4.0) +# set -g task_complete_attribute_modifiers yes +# +# +# Copyright 2014 - 2021, Roman Inflianskas <infroma@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. +# +# https://www.opensource.org/licenses/mit-license.php + +# NOTE: remember that sed on OS X is different in some aspects. E.g. it does +# not understand \t for tabs. + +# convinience functions + +function __fish.task.log + for line in $argv + echo $line >&2 + end +end + +function __fish.task.partial + set wrapped $argv[1] + set what $argv[2] + set -q argv[3]; and set f_argv $argv[3..-1] + set f __fish.task.$wrapped.$what + functions -q $f; and eval $f $f_argv +end + +function __fish.task.zsh + set -q argv[2]; and set task_argv $argv[2..-1] + task _zsh$argv[1] $task_argv | sed 's/:/ /' +end + + +# command line state detection + +function __fish.task.bare + test (count (commandline -c -o)) -eq 1 +end + +function __fish.task.current.command + # find command in commandline by list intersection + begin; commandline -pco; and echo $__fish_task_static_commands; end | sort | uniq -d | xargs +end + +function __fish.task.before_command + test -z (__fish.task.current.command) +end + + +# checking need to complete + +function __fish.task.need_to_complete.attr_name + __fish.task.need_to_complete.filter; or contains (__fish.task.current.command) (__fish.task.list.command_mods) +end + +function __fish.task.need_to_complete.attr_value + __fish.task.need_to_complete.attr_name + or return 1 + # only start completion when there's a colon in attr_name + set -l cmd (commandline -ct) + string match -q -- "*:*" "$cmd[-1]" +end + +function __fish.task.need_to_complete.command + switch $argv + case all + __fish.task.bare + case filter + __fish.task.before_command + end +end + +function __fish.task.need_to_complete.config + contains (__fish.task.current.command) 'config' 'show' +end + +function __fish.task.need_to_complete.filter + __fish.task.before_command +end + +function __fish.task.need_to_complete.tag + __fish.task.need_to_complete.attr_name + or return 1 + set -l cmd (commandline -ct) + # only start complete when supplied + or - + string match -qr -- "^[+-][^+-]*" "$cmd[-1]" +end + +function __fish.task.need_to_complete.id + __fish.task.need_to_complete.filter +end + +function __fish.task.need_to_complete.task + __fish.task.need_to_complete.filter +end + +function __fish.task.need_to_complete + __fish.task.partial need_to_complete $argv +end + + +# list printers + +function __fish.task.token_clean + sed 's/[^a-z_.]//g; s/^\.$//g' +end + +function __fish.task.list.attr_name + # # BUG: doesn't support file completion + for attr in (task _columns) + if set -l idx (contains -i -- $attr $__fish_task_static_attr_desc_keys) + # use builtin friendly description + echo -e "$attr:\tattribute:$__fish_task_static_attr_desc_vals[$idx]" + else + echo -e "$attr:\tattribute" + end + end + echo -e "rc\tConfiguration for taskwarrior" +end + +function __fish.task.list.attr_value + set token (commandline -ct | cut -d ':' -f 1 | cut -d '.' -f 1 | __fish.task.token_clean) + if test -n $token + set attr_names (__fish.task.list.attr_name | sed 's/: / /g' | grep '^'$token | cut -d ' ' -f 1) + for attr_name in $attr_names + if test -n $attr_name + __fish.task.list.attr_value_by_name $attr_name + end + end + end +end + +function __fish.task.list.attr_value_by_name + set attr $argv[1] + switch $attr + case 'rc' + __fish.task.list.rc + case 'depends' 'limit' 'priority' 'status' + __fish.task.combos_simple $attr (__fish.task.list $attr) + case 'recur' + __fish.task.combos_simple $attr (__fish.task.list.date_freq) + case 'due' 'until' 'wait' 'entry' 'end' 'start' 'scheduled' + __fish.task.combos_simple $attr (__fish.task.list.dates) + # case 'description' 'project' + case '*' + if [ "$task_complete_attribute_modifiers" = 'yes' ]; and echo (commandline -ct) | grep -q '\.' + __fish.task.combos_with_mods $attr (__fish.task.list $attr) + else + __fish.task.combos_simple $attr (__fish.task.list $attr) + end + end +end + +function __fish.task.list._command + echo -e $__fish_task_static_commands_with_desc +end + +function __fish.task.list.command + # ignore special commands + __fish.task.list._command $argv | command grep -Ev '^_' +end + +function __fish.task.list.command_mods + echo -e $__fish_task_static_command_mods +end + +function __fish.task.list.config + task _config +end + +function __fish.task.list.depends + __fish.task.list.id with_description +end + +function __fish.task.list.description + __fish.task.zsh ids $argv | awk -F"\t" '{print $2 "\tid=" $1}' +end + +function __fish.task.list.id + set show_type $argv[1] + if test -z $show_type + task _ids + else if [ $show_type = 'with_description' ] + __fish.task.zsh ids + end +end + +function __fish.task.list.date_freq + set -l cmd (commandline -ct) + if set -l user_input_numeric (echo $cmd[-1] | grep -o '[0-9]\+') + # show numeric freq like 2d, 4m, etc. + echo -e (string replace --all -r "^|\n" "\n$user_input_numeric" $__fish_task_static_freq_numeric | string collect) + else + echo -e $__fish_task_static_freq + end +end + +function __fish.task.list.dates + set -l cmd (commandline -ct) + if set -l user_input_numeric (echo $cmd[-1] | grep -o '[0-9]\+') + # show numeric date like 2hrs, 4th, etc. + echo -e (string replace --all -r "^|\n" "\n$user_input_numeric" $__fish_task_static_reldates | string collect) + # special cases for 1st, 2nd and 3rd, and 4-0th + set -l suffix 'th' '4th, 5th, etc.' + if string match -q -- "*1" $user_input_numeric + set suffix 'st' 'first' + else if string match -q -- "*2" $user_input_numeric + set suffix 'nd' 'second' + else if string match -q -- "*3" $user_input_numeric + set suffix 'rd' 'third' + end + echo -e $user_input_numeric"$suffix[1]\t$suffix[2]" + else + echo -e $__fish_task_static_dates + end +end + +# Attribure modifiers (DEPRECATED since 2.4.0) +function __fish.task.list.mod + echo -e $__fish_task_static_mod +end + +function __fish.task.list.priority + echo -e $__fish_task_static_priority +end + +function __fish.task.list.project + task _projects +end + +function __fish.task.list.rc + task _config +end + +function __fish.task.list.status + echo -e $__fish_task_static_status +end + +function __fish.task.list.tag + set -l tags (task _tags) + printf -- '+%s\n' $tags + printf -- '-%s\n' $tags +end + +function __fish.task.list.task + __fish.task.zsh ids | sed -E 's/^(.*) (.*)$/\2 task [id = \1]/g' +end + +function __fish.task.list + __fish.task.partial list $argv +end + +function __fish.task.results_var_name + echo $argv | sed 's/^/__fish.task.list /g; s/$/ results/g; s/[ .]/_/g;' +end + +function __fish.task.list_results + set var_name (__fish.task.results_var_name $name) + for line in $$var_name + echo $line + end +end + + +# working with attributes + +function __fish.task.combos_simple + set attr_name $argv[1] + set -q argv[2]; and set attr_values $argv[2..-1] + if [ (count $attr_values) -gt 0 ] + for attr_value in $attr_values + echo "$attr_name:$attr_value" + end + else + echo "$attr_name:" + end +end + +# Attribure modifiers (DEPRECATED since 2.4.0) +function __fish.task.combos_with_mods + __fish.task.combos_simple $argv + for mod in (__fish.task.list.mod) + __fish.task.combos_simple $argv[1].$mod $argv[2..-1] + end +end + + +# actual completion + +function __fish.task.complete + set what $argv + set list_command "__fish.task.list $what" + set check_function "__fish.task.need_to_complete $what" + complete -c task -u -k -f -n $check_function -a "(eval $list_command)" +end + +# static variables that won't changes even when taskw's data is modified +set __fish_task_static_commands_with_desc (__fish.task.zsh commands | sort | string collect) +set __fish_task_static_commands (echo -e $__fish_task_static_commands_with_desc | cut -d ' ' -f 1 | string collect) +set __fish_task_static_command_mods (printf -- '%s\n' 'add' 'annotate' 'append' 'delete' 'done' 'duplicate' 'log' 'modify' 'prepend' 'start' 'stop' | string collect) +set __fish_task_static_mod (printf -- '%s\n' 'before' 'after' 'over' 'under' 'none' 'is' 'isnt' 'has' 'hasnt' 'startswith' 'endswith' 'word' 'noword' | string collect) +set __fish_task_static_status (printf -- '%s\tstatus\n' 'pending' 'completed' 'deleted' 'waiting' | string collect) +set __fish_task_static_priority (printf -- '%s\n' 'H\tHigh' 'M\tMiddle' 'L\tLow' | string collect) + +set __fish_task_static_freq 'daily:Every day' \ + 'day:Every day' \ + 'weekdays:Every day skipping weekend days' \ + 'weekly:Every week' \ + 'biweekly:Every two weeks' \ + 'fortnight:Every two weeks' \ + 'monthly:Every month' \ + 'quarterly:Every three months' \ + 'semiannual:Every six months' \ + 'annual:Every year' \ + 'yearly:Every year' \ + 'biannual:Every two years' \ + 'biyearly:Every two years' +set __fish_task_static_freq (printf -- '%s\n' $__fish_task_static_freq | sed 's/:/\t/' | string collect) +set __fish_task_static_freq_numeric 'd:days' \ + 'w:weeks' \ + 'q:quarters' \ + 'y:years' +set __fish_task_static_freq_numeric (printf -- '%s\n' $__fish_task_static_freq_numeric | sed 's/:/\t/' | string collect) +set __fish_task_static_freq_numeric 'd:days' \ + 'w:weeks' \ + 'q:quarters' \ + 'y:years' +set __fish_task_static_freq_numeric (printf -- '%s\n' $__fish_task_static_freq_numeric | sed 's/:/\t/' | string collect) +set __fish_task_static_dates 'today:Today' \ + 'yesterday:Yesterday' \ + 'tomorrow:Tomorrow' \ + 'sow:Start of week' \ + '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'\ + 'wed:Wednesday' \ + 'thu:Thursday' \ + 'fri:Friday' \ + 'sat:Saturday' \ + 'sun:Sunday' \ + 'goodfriday:Good Friday' \ + 'easter:Easter' \ + 'eastermonday:Easter Monday' \ + 'ascension:Ascension' \ + 'pentecost:Pentecost' \ + 'midsommar:Midsommar' \ + 'midsommarafton:Midsommarafton' \ + 'later:Later' \ + 'someday:Some Day' +set __fish_task_static_dates (printf -- '%s\n' $__fish_task_static_dates | sed 's/:/\t/' | string collect) +set __fish_task_static_reldates 'hrs:n hours' \ + 'day:n days' \ + # '1st:first' \ + # '2nd:second' \ + # '3rd:third' \ + # 'th:4th, 5th, etc.' \ + 'wks:weeks' +set __fish_task_static_reldates (printf -- '%s\n' $__fish_task_static_reldates | sed 's/:/\t/' | string collect) +# the followings are actually not used for autocomplete, but to retrieve friendly description that aren't present in internal command +set __fish_task_static_attr_desc_keys 'description' 'status' 'project' \ + 'priority' 'due' 'recur' \ + 'until' 'limit' 'wait' \ + 'entry' 'end' 'start' \ + 'scheduled' 'dependson' +set __fish_task_static_attr_desc_vals 'Task description text' 'Status of task - pending, completed, deleted, waiting' \ + 'Project name' 'Task priority' 'Due date' 'Recurrence frequency' 'Expiration date' \ + 'Desired number of rows in report' 'Date until task becomes pending' \ + 'Date task was created' 'Date task was completed/deleted' 'Date task was started' \ + 'Date task is scheduled to start' 'Other tasks that this task depends upon' + +# fish's auto-completion when multiple `complete` have supplied with '-k' flag, the last will be displayed first +__fish.task.complete config +__fish.task.complete attr_value +__fish.task.complete attr_name +__fish.task.complete tag +# __fish.task.complete command all +# __fish.task.complete command filter +# The following are static so we will expand it when initialised. Display underscore (internal) commands last +set -l __fish_task_static_commands_underscore (echo -e $__fish_task_static_commands_with_desc | grep '^[_]' | string collect | string escape) +set -l __fish_task_static_commands_normal (echo -e $__fish_task_static_commands_with_desc | grep '^[^_]' | string collect | string escape) +complete -c task -u -k -f -n "__fish.task.before_command" -a "$__fish_task_static_commands_underscore" +complete -c task -u -k -f -n "__fish.task.before_command" -a "$__fish_task_static_commands_normal" + +if [ "$task_complete_task" = 'yes' ] + __fish.task.complete task +end + +if [ "$task_complete_id" = 'yes' ] + __fish.task.complete id with_description +end diff --git a/fish/completions/task.sh b/fish/completions/task.sh new file mode 100644 index 0000000..7b33e39 --- /dev/null +++ b/fish/completions/task.sh @@ -0,0 +1,194 @@ +################################################################################ +# +# Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez. +# +# 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. +# +# https://www.opensource.org/licenses/mit-license.php +# +################################################################################ +# +# The routines will do completion of: +# +# *) task subcommands +# *) project names +# *) tag names +# *) aliases +# +# To use these routines: +# +# 1) Copy this file to somewhere (e.g. ~/.bash_completion.d/task.sh). +# 2) Add the following line to your .bashrc: +# source ~/.bash_completion.d/task.sh +# +# OR +# +# 3) Copy the file to /etc/bash_completion.d +# 4) source /etc/bash_completion +# +# To submit patches/bug reports: +# +# *) Go to the project's website at +# +# https://taskwarrior.org +# +################################################################################ +#the following variable is substituted for by ../../test/bash_completion.t +taskbin='task' +taskrc='' +taskcommand="rc.verbose:nothing rc.confirmation:no rc.hooks:off ${taskrc}" + +_task_get_tags() { + "$taskbin" $taskcommand _tags +} + +_task_get_config() { + "$taskbin" $taskcommand _config +} + +_task_offer_priorities() { + COMPREPLY=( $(compgen -W "L M H" -- ${cur/*:/}) ) +} + +_task_offer_projects() { + COMPREPLY=( $(compgen -W "$("$taskbin" $taskcommand _projects)" -- ${cur/*:/}) ) +} + +_task_offer_contexts() { + COMPREPLY=( $(compgen -W "$("$taskbin" $taskcommand _context) define delete list none show" -- $cur) ) +} + +_task_context_alias=$("$taskbin" $taskcommand show | grep 'alias.*context' | cut -d' ' -f1 | cut -d. -f2) + +_task() +{ + local cur prev opts base + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + if [ ${#COMP_WORDS[*]} -gt 2 ] + then + prev2="${COMP_WORDS[COMP_CWORD-2]}" + else + prev2="" + fi +# useful for debugging: +# echo -e "\ncur='$cur'" +# echo "prev='$prev'" +# echo "prev2='$prev2'" + + abbrev_min=$("$taskbin" $taskcommand show | grep "abbreviation.minimum" | awk {'print $2'}) + commands_aliases=$(echo $("$taskbin" $taskcommand _commands; "$taskbin" $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ") + opts="$commands_aliases $("$taskbin" $taskcommand _columns)" + + case "${prev}" in + $_task_context_alias|cont|conte|contex|context) + _task_offer_contexts + return 0 + ;; + :) + case "${prev2}" in + pri|prior|priori|priorit|priority) + if [ ${#prev2} -ge $abbrev_min ]; then + _task_offer_priorities + fi + return 0 + ;; + pro|proj|proje|projec|project) + if [ ${#prev2} -ge $abbrev_min ]; then + _task_offer_projects + fi + return 0 + ;; + rc) + # not activated when only "rc:" but is activated if anything after "rc:" + _filedir + return 0 + ;; + rc.data.location) + _filedir -d + return 0 + ;; + esac + ;; + *) + case "${cur}" in + pro:*|proj:*|proje:*|projec:*|project:*) + _task_offer_projects + return 0 + ;; + :) + case "${prev}" in + pri|prior|priori|priorit|priority) + if [ ${#prev} -ge $abbrev_min ]; then + _task_offer_priorities + fi + return 0 + ;; + pro|proj|proje|projec|project) + if [ ${#prev} -ge $abbrev_min ]; then + _task_offer_projects + fi + return 0 + ;; + rc) + # activated only when "rc:" + cur="" # otherwise ":" is passed. + _filedir + return 0 + ;; + rc.data.location) + cur="" + _filedir -d + return 0 + ;; + esac + ;; + +*) + local tags=$(_task_get_tags | sed 's/^/+/') + COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) ) + return 0 + ;; + -*) + local tags=$(_task_get_tags | sed 's/^/-/') + COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) ) + return 0 + ;; + rc.*) + local config=$(_task_get_config | sed -e 's/^/rc\./' -e 's/$/:/') + COMPREPLY=( $(compgen -W "${config}" -- ${cur}) ) + return 0 + ;; + *) + case "${prev}" in + import) + COMPREPLY=( $(compgen -o "default" -- ${cur}) ) + return 0 + ;; + esac + ;; + esac + ;; + esac + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} +complete -o nospace -F _task task diff --git a/fish/completions/twdft.fish b/fish/completions/twdft.fish new file mode 100644 index 0000000..7474227 --- /dev/null +++ b/fish/completions/twdft.fish @@ -0,0 +1,6 @@ +#complete -c twdft -l create_inspection -d "Port Facility Name" -a "(twdft complete_site (commandline -cp))" +#complete -f -c twdft -d "Create inspection" -a "(twdft complete_site)" +complete -f -c twdft -d "Port Facility" -a "(twdft_complete_site)" +complete -f -c twdft -l inspectiondate -d "Inspection date" +complete -f -c twdft -l inspectiontime -d "Inspection time" +complete -f -c twdft -l opencard -d "Open inspection card in vim" |