From 93619f7f3d4ed85abf56d57d531752a6306d39e4 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 7 Jan 2023 21:57:26 +0100 Subject: [PATCH] added zsh-server --- cpConfigsToHere.sh | 2 +- home/.wakeonlan/all | 2 +- .../.fast-make-targets | 98 + .../.fast-read-ini-file | 30 + .../.fast-run-command | 37 + .../.fast-run-git-command | 60 + .../.fast-zts-read-all | 17 + .../fast-syntax-highlighting/.gitignore | 24 + .../fast-syntax-highlighting/.travis.yml | 13 + .../fast-syntax-highlighting/.zunit.yml | 8 + .../CHROMA_GUIDE.adoc | 166 ++ .../plugins/fast-syntax-highlighting/LICENSE | 23 + .../fast-syntax-highlighting/README.md | 290 +++ .../fast-syntax-highlighting/THEME_GUIDE.md | 76 + .../fast-syntax-highlighting/_fast-theme | 39 + .../fast-syntax-highlighting/fast-highlight | 1463 ++++++++++++++ .../fast-string-highlight | 77 + .../fast-syntax-highlighting.plugin.zsh | 384 ++++ .../fast-syntax-highlighting/fast-theme | 385 ++++ .../share/free_theme.zsh | 61 + .../fast-syntax-highlighting/themes/clean.ini | 81 + .../themes/default.ini | 84 + .../themes/forest.ini | 81 + .../fast-syntax-highlighting/themes/free.ini | 81 + .../themes/q-jmnemonic.ini | 163 ++ .../themes/safari.ini | 83 + .../fast-syntax-highlighting/themes/spa.ini | 82 + .../themes/sv-orple.ini | 100 + .../themes/sv-plant.ini | 100 + .../themes/zdharma.ini | 81 + .../→chroma/-alias.ch | 29 + .../→chroma/-autoload.ch | 104 + .../→chroma/-autorandr.ch | 22 + .../fast-syntax-highlighting/→chroma/-awk.ch | 108 ++ .../→chroma/-docker.ch | 90 + .../→chroma/-example.ch | 120 ++ .../→chroma/-fast-theme.ch | 40 + .../→chroma/-fpath_peq.ch | 61 + .../fast-syntax-highlighting/→chroma/-git.ch | 954 ++++++++++ .../fast-syntax-highlighting/→chroma/-grep.ch | 89 + .../fast-syntax-highlighting/→chroma/-hub.ch | 51 + .../→chroma/-ionice.ch | 117 ++ .../fast-syntax-highlighting/→chroma/-lab.ch | 59 + .../fast-syntax-highlighting/→chroma/-make.ch | 105 + .../fast-syntax-highlighting/→chroma/-nice.ch | 138 ++ .../→chroma/-nmcli.ch | 58 + .../fast-syntax-highlighting/→chroma/-node.ch | 37 + .../fast-syntax-highlighting/→chroma/-ogit.ch | 383 ++++ .../fast-syntax-highlighting/→chroma/-perl.ch | 80 + .../→chroma/-precommand.ch | 17 + .../→chroma/-printf.ch | 86 + .../fast-syntax-highlighting/→chroma/-ruby.ch | 81 + .../fast-syntax-highlighting/→chroma/-scp.ch | 87 + .../fast-syntax-highlighting/→chroma/-sh.ch | 72 + .../→chroma/-source.ch | 75 + .../fast-syntax-highlighting/→chroma/-ssh.ch | 156 ++ .../→chroma/-subcommand.ch | 25 + .../→chroma/-subversion.ch | 250 +++ .../fast-syntax-highlighting/→chroma/-vim.ch | 51 + .../→chroma/-whatis.ch | 138 ++ .../→chroma/-which.ch | 96 + .../→chroma/-zinit.ch | 378 ++++ .../→chroma/main-chroma.ch | 460 +++++ .../zsh-autosuggestions/.circleci/config.yml | 15 + .../plugins/zsh-autosuggestions/.editorconfig | 18 + .../.github/ISSUE_TEMPLATE/bug-report.md | 36 + .../.github/ISSUE_TEMPLATE/feature_request.md | 20 + .../plugins/zsh-autosuggestions/.rspec | 3 + .../plugins/zsh-autosuggestions/.rubocop.yml | 30 + .../plugins/zsh-autosuggestions/.ruby-version | 1 + .../plugins/zsh-autosuggestions/CHANGELOG.md | 117 ++ .../plugins/zsh-autosuggestions/DESCRIPTION | 1 + .../plugins/zsh-autosuggestions/Dockerfile | 20 + .../plugins/zsh-autosuggestions/Gemfile | 5 + .../plugins/zsh-autosuggestions/Gemfile.lock | 41 + .../plugins/zsh-autosuggestions/INSTALL.md | 64 + .../plugins/zsh-autosuggestions/LICENSE | 23 + .../plugins/zsh-autosuggestions/Makefile | 35 + .../plugins/zsh-autosuggestions/README.md | 191 ++ .../plugins/zsh-autosuggestions/URL | 1 + .../plugins/zsh-autosuggestions/VERSION | 1 + .../plugins/zsh-autosuggestions/ZSH_VERSIONS | 17 + .../zsh-autosuggestions/install_test_zsh.sh | 26 + .../zsh-autosuggestions/spec/async_spec.rb | 70 + .../spec/integrations/auto_cd_spec.rb | 14 + .../bracketed_paste_magic_spec.rb | 43 + .../spec/integrations/client_zpty_spec.rb | 14 + .../spec/integrations/glob_subst_spec.rb | 12 + .../spec/integrations/rebound_bracket_spec.rb | 13 + .../spec/integrations/vi_mode_spec.rb | 80 + .../spec/integrations/wrapped_widget_spec.rb | 39 + .../spec/integrations/zle_input_stack_spec.rb | 24 + .../spec/kill_ring_spec.rb | 23 + .../spec/line_init_spec.rb | 17 + .../spec/multi_line_spec.rb | 8 + .../spec/options/buffer_max_size_spec.rb | 30 + .../spec/options/highlight_style_spec.rb | 7 + .../options/original_widget_prefix_spec.rb | 7 + .../spec/options/strategy_spec.rb | 55 + .../spec/options/widget_lists_spec.rb | 121 ++ .../zsh-autosuggestions/spec/spec_helper.rb | 54 + .../spec/strategies/completion_spec.rb | 72 + .../spec/strategies/history_spec.rb | 23 + .../spec/strategies/match_prev_cmd_spec.rb | 34 + .../strategies/special_characters_helper.rb | 75 + .../spec/terminal_session.rb | 99 + .../spec/widgets/disable_spec.rb | 19 + .../spec/widgets/enable_spec.rb | 42 + .../spec/widgets/fetch_spec.rb | 24 + .../spec/widgets/toggle_spec.rb | 26 + .../plugins/zsh-autosuggestions/src/async.zsh | 76 + .../plugins/zsh-autosuggestions/src/bind.zsh | 106 ++ .../zsh-autosuggestions/src/config.zsh | 93 + .../plugins/zsh-autosuggestions/src/fetch.zsh | 27 + .../zsh-autosuggestions/src/highlight.zsh | 26 + .../plugins/zsh-autosuggestions/src/start.zsh | 33 + .../src/strategies/completion.zsh | 137 ++ .../src/strategies/history.zsh | 32 + .../src/strategies/match_prev_cmd.zsh | 66 + .../plugins/zsh-autosuggestions/src/util.zsh | 11 + .../zsh-autosuggestions/src/widgets.zsh | 231 +++ .../zsh-autosuggestions.plugin.zsh | 1 + .../zsh-autosuggestions.zsh | 864 +++++++++ .../plugins/zsh-completions/.editorconfig | 10 + .../zsh-completions/.github/ISSUE_TEMPLATE.md | 1 + .../.github/PULL_REQUEST_TEMPLATE.md | 10 + .../plugins/zsh-completions/.gitignore | 6 + .../plugins/zsh-completions/CONTRIBUTING.md | 39 + .../plugins/zsh-completions/LICENSE | 25 + .../plugins/zsh-completions/README.md | 71 + .../plugins/zsh-completions/src/_afew | 65 + .../plugins/zsh-completions/src/_android | 308 +++ .../zsh-completions/src/_archlinux-java | 85 + .../plugins/zsh-completions/src/_artisan | 63 + .../plugins/zsh-completions/src/_atach | 71 + .../plugins/zsh-completions/src/_bitcoin-cli | 211 +++ .../plugins/zsh-completions/src/_bower | 163 ++ .../plugins/zsh-completions/src/_bundle | 353 ++++ .../plugins/zsh-completions/src/_caffeinate | 50 + .../plugins/zsh-completions/src/_cap | 93 + .../plugins/zsh-completions/src/_cask | 89 + .../plugins/zsh-completions/src/_ccache | 325 ++++ .../plugins/zsh-completions/src/_cf | 994 ++++++++++ .../plugins/zsh-completions/src/_choc | 60 + .../plugins/zsh-completions/src/_chromium | 211 +++ .../plugins/zsh-completions/src/_cmake | 592 ++++++ .../plugins/zsh-completions/src/_coffee | 76 + .../plugins/zsh-completions/src/_conan | 626 ++++++ .../plugins/zsh-completions/src/_concourse | 1517 +++++++++++++++ .../plugins/zsh-completions/src/_console | 64 + .../plugins/zsh-completions/src/_cppcheck | 116 ++ .../plugins/zsh-completions/src/_dad | 68 + .../plugins/zsh-completions/src/_debuild | 40 + .../plugins/zsh-completions/src/_dget | 70 + .../plugins/zsh-completions/src/_dhcpcd | 53 + .../plugins/zsh-completions/src/_diana | 150 ++ .../plugins/zsh-completions/src/_direnv | 125 ++ .../plugins/zsh-completions/src/_docpad | 90 + .../plugins/zsh-completions/src/_drush | 191 ++ .../plugins/zsh-completions/src/_ecdsautil | 53 + .../plugins/zsh-completions/src/_emulator | 137 ++ .../plugins/zsh-completions/src/_envdir | 49 + .../plugins/zsh-completions/src/_exportfs | 51 + .../plugins/zsh-completions/src/_fab | 109 ++ .../zsh-completions/src/_fail2ban-client | 339 ++++ .../plugins/zsh-completions/src/_ffind | 62 + .../plugins/zsh-completions/src/_fleetctl | 123 ++ .../plugins/zsh-completions/src/_flutter | 633 +++++++ .../plugins/zsh-completions/src/_fvm | 183 ++ .../plugins/zsh-completions/src/_fwupdmgr | 293 +++ .../plugins/zsh-completions/src/_gas | 69 + .../plugins/zsh-completions/src/_ghc | 618 ++++++ .../plugins/zsh-completions/src/_gist | 126 ++ .../plugins/zsh-completions/src/_git-flow | 444 +++++ .../plugins/zsh-completions/src/_git-pulls | 83 + .../plugins/zsh-completions/src/_git-revise | 71 + .../plugins/zsh-completions/src/_git-wtf | 65 + .../plugins/zsh-completions/src/_glances | 125 ++ .../plugins/zsh-completions/src/_golang | 1132 +++++++++++ .../plugins/zsh-completions/src/_google | 94 + .../plugins/zsh-completions/src/_gpgconf | 69 + .../plugins/zsh-completions/src/_gtk-launch | 87 + .../plugins/zsh-completions/src/_hello | 19 + .../plugins/zsh-completions/src/_hledger | 286 +++ .../plugins/zsh-completions/src/_homestead | 53 + .../plugins/zsh-completions/src/_httpie | 218 +++ .../plugins/zsh-completions/src/_ibus | 109 ++ .../zsh-completions/src/_include-what-you-use | 65 + .../plugins/zsh-completions/src/_inxi | 146 ++ .../plugins/zsh-completions/src/_jmeter | 58 + .../zsh-completions/src/_jmeter-plugins | 42 + .../plugins/zsh-completions/src/_jonas | 100 + .../plugins/zsh-completions/src/_jrnl | 66 + .../plugins/zsh-completions/src/_kak | 78 + .../plugins/zsh-completions/src/_kitchen | 86 + .../plugins/zsh-completions/src/_knife | 324 ++++ .../zsh-completions/src/_language_codes | 250 +++ .../plugins/zsh-completions/src/_lilypond | 134 ++ .../plugins/zsh-completions/src/_lunchy | 138 ++ .../plugins/zsh-completions/src/_mc | 82 + .../plugins/zsh-completions/src/_middleman | 156 ++ .../plugins/zsh-completions/src/_mina | 68 + .../plugins/zsh-completions/src/_mix | 236 +++ .../plugins/zsh-completions/src/_mssh | 108 ++ .../plugins/zsh-completions/src/_mussh | 86 + .../plugins/zsh-completions/src/_mvn | 613 ++++++ .../plugins/zsh-completions/src/_nano | 74 + .../plugins/zsh-completions/src/_nanoc | 162 ++ .../plugins/zsh-completions/src/_nftables | 500 +++++ .../plugins/zsh-completions/src/_node | 192 ++ .../plugins/zsh-completions/src/_nvm | 235 +++ .../plugins/zsh-completions/src/_openssl | 1687 +++++++++++++++++ .../plugins/zsh-completions/src/_openvpn3 | 246 +++ .../plugins/zsh-completions/src/_optirun | 75 + .../plugins/zsh-completions/src/_opustools | 113 ++ .../plugins/zsh-completions/src/_patool | 95 + .../plugins/zsh-completions/src/_periscope | 36 + .../plugins/zsh-completions/src/_pgsql_utils | 590 ++++++ .../plugins/zsh-completions/src/_phing | 94 + .../plugins/zsh-completions/src/_pixz | 100 + .../plugins/zsh-completions/src/_pkcon | 137 ++ .../plugins/zsh-completions/src/_play | 190 ++ .../plugins/zsh-completions/src/_pm2 | 370 ++++ .../plugins/zsh-completions/src/_port | 278 +++ .../plugins/zsh-completions/src/_protoc | 84 + .../plugins/zsh-completions/src/_pygmentize | 149 ++ .../plugins/zsh-completions/src/_qmk | 240 +++ .../plugins/zsh-completions/src/_rails | 624 ++++++ .../plugins/zsh-completions/src/_ralio | 146 ++ .../plugins/zsh-completions/src/_redis-cli | 184 ++ .../plugins/zsh-completions/src/_rfkill | 102 + .../plugins/zsh-completions/src/_rkt | 369 ++++ .../plugins/zsh-completions/src/_rmlint | 422 +++++ .../plugins/zsh-completions/src/_rslsync | 72 + .../plugins/zsh-completions/src/_rspec | 108 ++ .../plugins/zsh-completions/src/_rsvm | 88 + .../plugins/zsh-completions/src/_rubocop | 120 ++ .../plugins/zsh-completions/src/_sbt | 93 + .../plugins/zsh-completions/src/_scala | 249 +++ .../plugins/zsh-completions/src/_scrub | 93 + .../plugins/zsh-completions/src/_sdd | 66 + .../plugins/zsh-completions/src/_setcap | 108 ++ .../plugins/zsh-completions/src/_setup.py | 715 +++++++ .../plugins/zsh-completions/src/_sfdx | 935 +++++++++ .../plugins/zsh-completions/src/_shellcheck | 65 + .../plugins/zsh-completions/src/_showoff | 163 ++ .../plugins/zsh-completions/src/_srm | 84 + .../plugins/zsh-completions/src/_stack | 134 ++ .../plugins/zsh-completions/src/_subliminal | 81 + .../zsh-completions/src/_supervisorctl | 174 ++ .../plugins/zsh-completions/src/_svm | 172 ++ .../plugins/zsh-completions/src/_teamocil | 56 + .../plugins/zsh-completions/src/_thor | 133 ++ .../plugins/zsh-completions/src/_tmuxinator | 65 + .../plugins/zsh-completions/src/_tmuxp | 191 ++ .../plugins/zsh-completions/src/_tox | 67 + .../plugins/zsh-completions/src/_udisksctl | 164 ++ .../plugins/zsh-completions/src/_ufw | 145 ++ .../plugins/zsh-completions/src/_virtualbox | 322 ++++ .../plugins/zsh-completions/src/_vnstat | 124 ++ .../plugins/zsh-completions/src/_wemux | 82 + .../plugins/zsh-completions/src/_wg-quick | 25 + .../plugins/zsh-completions/src/_xinput | 208 ++ .../plugins/zsh-completions/src/_xsel | 63 + .../plugins/zsh-completions/src/_yaourt | 368 ++++ .../plugins/zsh-completions/src/_yarn | 502 +++++ .../plugins/zsh-completions/src/_zcash-cli | 181 ++ .../zsh-completions/zsh-completions-howto.org | 464 +++++ .../zsh-completions.plugin.zsh | 1 + home/.zsh-server/themes/bira/bira.zsh-theme | 32 + home/.zsh-server/zshrc | 54 + home/.zsh/zshrc | 3 + usr/share/fzf/key-bindings.zsh | 3 +- 273 files changed, 42102 insertions(+), 3 deletions(-) create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.fast-make-targets create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.fast-read-ini-file create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-command create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-git-command create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.fast-zts-read-all create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.gitignore create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.travis.yml create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/.zunit.yml create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/CHROMA_GUIDE.adoc create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/LICENSE create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/README.md create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/THEME_GUIDE.md create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/_fast-theme create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/fast-highlight create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/fast-string-highlight create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/fast-theme create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/share/free_theme.zsh create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/clean.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/default.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/forest.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/free.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/q-jmnemonic.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/safari.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/spa.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-orple.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-plant.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/themes/zdharma.ini create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-alias.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autoload.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autorandr.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-awk.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-docker.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-example.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fast-theme.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fpath_peq.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-git.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-grep.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-hub.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ionice.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-lab.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-make.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nice.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nmcli.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-node.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ogit.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-perl.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-precommand.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-printf.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ruby.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-scp.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-sh.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-source.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ssh.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subcommand.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subversion.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-vim.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-whatis.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-which.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-zinit.ch create mode 100644 home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/main-chroma.ch create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.circleci/config.yml create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.editorconfig create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/bug-report.md create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.rspec create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.rubocop.yml create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/.ruby-version create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/CHANGELOG.md create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/DESCRIPTION create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/Dockerfile create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/Gemfile create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/Gemfile.lock create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/INSTALL.md create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/LICENSE create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/Makefile create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/README.md create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/URL create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/VERSION create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/ZSH_VERSIONS create mode 100755 home/.zsh-server/plugins/zsh-autosuggestions/install_test_zsh.sh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/async_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/auto_cd_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/bracketed_paste_magic_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/client_zpty_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/glob_subst_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/rebound_bracket_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/vi_mode_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/wrapped_widget_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/zle_input_stack_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/kill_ring_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/line_init_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/multi_line_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/options/buffer_max_size_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/options/highlight_style_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/options/original_widget_prefix_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/options/strategy_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/options/widget_lists_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/spec_helper.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/completion_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/history_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/match_prev_cmd_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/special_characters_helper.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/terminal_session.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/disable_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/enable_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/fetch_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/toggle_spec.rb create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/async.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/bind.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/config.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/fetch.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/highlight.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/start.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/completion.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/history.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/match_prev_cmd.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/util.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/src/widgets.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh create mode 100644 home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh create mode 100644 home/.zsh-server/plugins/zsh-completions/.editorconfig create mode 100644 home/.zsh-server/plugins/zsh-completions/.github/ISSUE_TEMPLATE.md create mode 100644 home/.zsh-server/plugins/zsh-completions/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 home/.zsh-server/plugins/zsh-completions/.gitignore create mode 100644 home/.zsh-server/plugins/zsh-completions/CONTRIBUTING.md create mode 100644 home/.zsh-server/plugins/zsh-completions/LICENSE create mode 100644 home/.zsh-server/plugins/zsh-completions/README.md create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_afew create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_android create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_archlinux-java create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_artisan create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_atach create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_bitcoin-cli create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_bower create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_bundle create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_caffeinate create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_cap create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_cask create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ccache create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_cf create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_choc create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_chromium create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_cmake create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_coffee create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_conan create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_concourse create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_console create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_cppcheck create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_dad create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_debuild create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_dget create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_dhcpcd create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_diana create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_direnv create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_docpad create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_drush create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ecdsautil create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_emulator create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_envdir create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_exportfs create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_fab create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_fail2ban-client create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ffind create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_fleetctl create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_flutter create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_fvm create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_fwupdmgr create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_gas create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ghc create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_gist create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_git-flow create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_git-pulls create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_git-revise create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_git-wtf create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_glances create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_golang create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_google create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_gpgconf create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_gtk-launch create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_hello create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_hledger create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_homestead create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_httpie create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ibus create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_include-what-you-use create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_inxi create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_jmeter create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_jmeter-plugins create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_jonas create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_jrnl create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_kak create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_kitchen create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_knife create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_language_codes create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_lilypond create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_lunchy create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_mc create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_middleman create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_mina create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_mix create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_mssh create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_mussh create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_mvn create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_nano create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_nanoc create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_nftables create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_node create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_nvm create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_openssl create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_openvpn3 create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_optirun create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_opustools create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_patool create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_periscope create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_pgsql_utils create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_phing create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_pixz create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_pkcon create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_play create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_pm2 create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_port create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_protoc create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_pygmentize create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_qmk create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rails create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ralio create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_redis-cli create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rfkill create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rkt create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rmlint create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rslsync create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rspec create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rsvm create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_rubocop create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_sbt create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_scala create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_scrub create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_sdd create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_setcap create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_setup.py create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_sfdx create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_shellcheck create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_showoff create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_srm create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_stack create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_subliminal create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_supervisorctl create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_svm create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_teamocil create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_thor create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_tmuxinator create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_tmuxp create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_tox create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_udisksctl create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_ufw create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_virtualbox create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_vnstat create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_wemux create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_wg-quick create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_xinput create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_xsel create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_yaourt create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_yarn create mode 100644 home/.zsh-server/plugins/zsh-completions/src/_zcash-cli create mode 100644 home/.zsh-server/plugins/zsh-completions/zsh-completions-howto.org create mode 100644 home/.zsh-server/plugins/zsh-completions/zsh-completions.plugin.zsh create mode 100644 home/.zsh-server/themes/bira/bira.zsh-theme create mode 100644 home/.zsh-server/zshrc diff --git a/cpConfigsToHere.sh b/cpConfigsToHere.sh index 7f39127..6ed1cc6 100755 --- a/cpConfigsToHere.sh +++ b/cpConfigsToHere.sh @@ -11,4 +11,4 @@ cp -fr ~/.zsh ./home/ cp -fr ~/.zshrc ./home/ cp -fr ~/.p10k.zsh ./home cp -fr ~/.gitconfig ./home -cp -fr /usr/share/fzf ./usr/share/fzf +#cp -fr /usr/share/fzf ./usr/share/fzf diff --git a/home/.wakeonlan/all b/home/.wakeonlan/all index 0d08385..f6b4846 100644 --- a/home/.wakeonlan/all +++ b/home/.wakeonlan/all @@ -1 +1 @@ -FF:FF:FF:FF:FF:FF 255.255.255.255 +FF:FF:FF:FF:FF:FF 192.168.178.255 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-make-targets b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-make-targets new file mode 100644 index 0000000..e2cbd32 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-make-targets @@ -0,0 +1,98 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Almost all code borrowed from Zshell's _make function +# +# Copyright (c) 2018 Sebastian Gniazdowski + +local -a TARGETS + +.make-expandVars() { + local open close var val front='' rest=$1 + + while [[ $rest == (#b)[^$]#($)* ]]; do + front=$front${rest[1,$mbegin[1]-1]} + rest=${rest[$mbegin[1],-1]} + + case $rest[2] in + ($) # '$$'. may not appear in target and variable's value + front=$front\$\$ + rest=${rest[3,-1]} + continue + ;; + (\() # Variable of the form $(foobar) + open='(' + close=')' + ;; + ({) # ${foobar} + open='{' + close='}' + ;; + ([[:alpha:]]) # $foobar. This is exactly $(f)oobar. + open='' + close='' + var=$rest[2] + ;; + (*) # bad parameter name + print -- $front$rest + return 1 + ;; + esac + + if [[ -n $open ]]; then + if [[ $rest == \$$open(#b)([[:alnum:]_]##)(#B)$close* ]]; then + var=$match + else # unmatched () or {}, or bad parameter name + print -- $front$rest + return 1 + fi + fi + + val='' + if [[ -n ${VAR_ARGS[(i)$var]} ]]; then + val=${VAR_ARGS[$var]} + else + if [[ -n $opt_args[(I)(-e|--environment-overrides)] ]]; then + if [[ $parameters[$var] == scalar-export* ]]; then + val=${(P)var} + elif [[ -n ${VARIABLES[(i)$var]} ]]; then + val=${VARIABLES[$var]} + fi + else + if [[ -n ${VARIABLES[(i)$var]} ]]; then + val=${VARIABLES[$var]} + elif [[ $parameters[$var] == scalar-export* ]]; then + val=${(P)var} + fi + fi + fi + rest=${rest//\$$open$var$close/$val} + done + + print -- ${front}${rest} +} + + +.make-parseMakefile () { + local input var val target dep TAB=$'\t' tmp IFS= + + while read input + do + case "$input " in + # TARGET: dependencies + # TARGET1 TARGET2 TARGET3: dependencies + ([[*?[:alnum:]$][^$TAB:=%]#:[^=]*) + target=$(.make-expandVars ${input%%:*}) + TARGETS+=( ${(z)target} ) + ;; + esac + done +} + +if [[ -z "${FAST_HIGHLIGHT[chroma-make-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[chroma-make-cache-born-at] )) -gt 7 ]]; then + .make-parseMakefile + FAST_HIGHLIGHT[chroma-make-cache-born-at]="$EPOCHSECONDS" + FAST_HIGHLIGHT[chroma-make-cache]="${(j:;:)TARGETS}" +fi + +reply2=( "${(s:;:)FAST_HIGHLIGHT[chroma-make-cache]}" ) + +# vim:ft=zsh:et diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-read-ini-file b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-read-ini-file new file mode 100644 index 0000000..2e57d10 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-read-ini-file @@ -0,0 +1,30 @@ +# Copyright (c) 2018 Sebastian Gniazdowski +# +# $1 - path to the ini file to parse +# $2 - name of output hash (INI by default) +# $3 - prefix for keys in the hash (can be empty) +# +# Writes to given hash under keys built in following way: ${3}
_field. +# Values are values from ini file. + +local __ini_file="$1" __out_hash="${2:-INI}" __key_prefix="$3" +local IFS='' __line __cur_section="void" __access_string +local -a match mbegin mend + +[[ ! -r "$__ini_file" ]] && { builtin print -r "fast-syntax-highlighting: an ini file is unreadable ($__ini_file)"; return 1; } + +while read -r -t 1 __line; do + if [[ "$__line" = [[:blank:]]#\;* ]]; then + continue + elif [[ "$__line" = (#b)[[:blank:]]#\[([^\]]##)\][[:blank:]]# ]]; then + __cur_section="${match[1]}" + elif [[ "$__line" = (#b)[[:blank:]]#([^[:blank:]=]##)[[:blank:]]#[=][[:blank:]]#(*) ]]; then + match[2]="${match[2]%"${match[2]##*[! $'\t']}"}" # remove trailing whitespace + __access_string="${__out_hash}[${__key_prefix}<$__cur_section>_${match[1]}]" + : "${(P)__access_string::=${match[2]}}" + fi +done < "$__ini_file" + +return 0 + +# vim:ft=zsh:sw=4:sts=4:et diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-command b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-command new file mode 100644 index 0000000..e251bcc --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-command @@ -0,0 +1,37 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# FAST_HIGHLIGHT hash serves as container for variables that +# prevents creating them in global scope. (P) flag is not used, +# output array is fixed (__lines_list). +# +# $1 - the command, e.g. "git remote"; 2>/dev/null redirection is +# added automatically +# $2 - FAST_HIGHLIGHT field name, e.g. "chroma-git-branches"; two +# additional fields will be used, $2-cache, $2-cache-born-at +# $3 - what to remove from beginning of the lines returned by the +# command +# $4 - cache validity time, default 5 (seconds) +# +# Output: array __lines_list, with output of the command ran + +# User should not forget to define this array, the below code +# will only ensure that it's array (can also define a global) +typeset -ga __lines_list +local -a __response + +if [[ -z "${FAST_HIGHLIGHT[$2-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[$2-cache-born-at] )) -gt ${4:-5} ]]; then + FAST_HIGHLIGHT[$2-cache-born-at]="$EPOCHSECONDS" + __response=( ${${(f)"$(command ${(Qz)1#+} 2>/dev/null)"}#${~3}} ) + [[ "$1" = "+"* ]] && __lines_list+=( "${__response[@]}" ) || __lines_list=( "${__response[@]}" ) + FAST_HIGHLIGHT[$2-cache]="${(j:;:)__response}" +else + # Quoted (s:;:) flag without @ will skip empty elements. It + # still produces array output, interesingly. All this is for + # the trailing ";" above, to skip last, empty element. + [[ "$1" = "+"* ]] && \ + __lines_list+=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) || \ + __lines_list=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) +fi + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-git-command b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-git-command new file mode 100644 index 0000000..4a42b97 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-run-git-command @@ -0,0 +1,60 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# It runs given command, which in general will be a git command, +# automatically looking at cache first (a field named *-cache, +# in FAST_HIGHLIGHT), which is valid for 5 seconds, and in case +# of outdated or not existing cache, runs the command, splitting +# on new-lines, first checking if PWD is inside git repository. +# +# FAST_HIGHLIGHT hash serves as container for variables that +# prevents creating them in global scope. (P) flag is not used, +# output array is fixed (__lines_list). +# +# $1 - the command, e.g. "git remote"; 2>/dev/null redirection is +# added automatically +# $2 - FAST_HIGHLIGHT field name, e.g. "chroma-git-branches"; two +# additional fields will be used, $2-cache, $2-cache-born-at +# $3 - what to remove from beginning of the lines returned by the +# command +# $4 - cache validity time, default 5 (seconds) +# +# Output: array __lines_list, with output of the (git) command ran + +# User should not forget to define this array, the below code +# will only ensure that it's array (can also define a global) +typeset -ga __lines_list +local -a __response + +if [[ $1 == --status ]] { + integer __status=1 + shift +} + +if [[ -z ${FAST_HIGHLIGHT[$2-cache]} || $(( EPOCHSECONDS - FAST_HIGHLIGHT[$2-cache-born-at] )) -gt ${4:-5} ]]; then + FAST_HIGHLIGHT[$2-cache-born-at]=$EPOCHSECONDS + if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = true ]]; then + __response=( ${${(f)"$(command ${(Qz)${1#+}} 2>/dev/null)"}#$3} ) + integer retval=$? + if (( __status )) { + __response=( $retval ) + __lines_list=( $retval ) + } else { + [[ "$1" = "+"* ]] && \ + __lines_list+=( "${__response[@]}" ) || \ + __lines_list=( "${__response[@]}" ) + } + else + __lines_list=() + fi + FAST_HIGHLIGHT[$2-cache]="${(j:;:)__response}" +else + # Quoted (s:;:) flag without @ will skip empty elements. It + # still produces array output, interesingly. All this is for + # the trailing ";" above, to skip last, empty element. + [[ "$1" = "+"* ]] && \ + __lines_list+=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) || \ + __lines_list=( "${(@s:;:)FAST_HIGHLIGHT[$2-cache]}" ) +fi + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-zts-read-all b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-zts-read-all new file mode 100644 index 0000000..96c52ab --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.fast-zts-read-all @@ -0,0 +1,17 @@ +# $1 - file-descriptor to be read from +# $2 - name of output variable (default: REPLY) + +local __in_fd=${1:-0} __out_var=${2:-REPLY} +local -a __tmp +integer __ret=1 __repeat=10 __tmp_size=0 + +while sysread -s 65535 -i "$__in_fd" '__tmp[__tmp_size + 1]'; do + (( ( __ret=$? ) == 0 )) && (( ++ __tmp_size )) + (( __ret == 5 )) && { __ret=0; (( --__repeat == 0 )) && break; } +done + +: ${(P)__out_var::="${(j::)__tmp}"} + +return __ret + +# vim: ft=zsh:et:sw=4:sts=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.gitignore b/home/.zsh-server/plugins/fast-syntax-highlighting/.gitignore new file mode 100644 index 0000000..a863220 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.gitignore @@ -0,0 +1,24 @@ +current_theme.zsh +secondary_theme.zsh +theme_overlay.zsh +*.txt +test/out.parse +test/res +hold/* +*.zwc + +### Vim +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.travis.yml b/home/.zsh-server/plugins/fast-syntax-highlighting/.travis.yml new file mode 100644 index 0000000..351b593 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.travis.yml @@ -0,0 +1,13 @@ +addons: + apt: + packages: + zsh +install: + - mkdir .bin + - curl -L https://github.com/zunit-zsh/zunit/releases/download/v0.8.2/zunit > .bin/zunit + - curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > .bin/revolver + - curl -L https://raw.githubusercontent.com/molovo/color/master/color.zsh > .bin/color +before_script: + - chmod u+x .bin/{color,revolver,zunit} + - export PATH="$PWD/.bin:$PATH" +script: zunit diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/.zunit.yml b/home/.zsh-server/plugins/fast-syntax-highlighting/.zunit.yml new file mode 100644 index 0000000..e4fd57f --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/.zunit.yml @@ -0,0 +1,8 @@ +tap: false +directories: + tests: tests + output: tests/_output + support: tests/_support +time_limit: 0 +fail_fast: false +allow_risky: false diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/CHROMA_GUIDE.adoc b/home/.zsh-server/plugins/fast-syntax-highlighting/CHROMA_GUIDE.adoc new file mode 100644 index 0000000..579f192 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/CHROMA_GUIDE.adoc @@ -0,0 +1,166 @@ +# Chroma Guide for F-Sy-H + +## Motivation + +Someone might want to create a detailed highlighting for a **specific program** +and this document helps achieving this. It explains how chroma functions – the +code behind such detailed highlighting – are constructed and used. + +## Keywords + +- `chroma` - a shorthand for `chroma function` – the thing that literally colorizes selected commands, like `git`, `grep`, etc. invocations, see `chroma function` below, +- `big loop` - main highlighting code, a loop over tokens and at least 2 large structular constructs (big `if` and `case`); + it is advanced, e.g. parses `case` statements, here-string, it basically constitutes 90% of the F-Sy-H project, +- `chroma function` - a plugin-function that is called when a specific command occurs (e.g. when user enters `git` at + command line) suppressing activity of `big loop` (i.e. no standard highlighting unless requested), +- `token` - result of splitting whole command line (i.e. `$BUFFER`, the Zle variable) into bits called tokens, which are + words in general, separated by spaces on the command line. + +## Overview Of Functioning + +1. Big loop is working – token by token processes command line, changes states (e.g. enters state "inside case + statement") and in the end decides on color of the token currently processed. + +2. Big loop occurs a command that has a chroma, e.g. `git`. + +3. Big loop enters "chroma" state, calls associated chroma function. + +4. Chroma takes care of "chroma" state, ensures it will be set also for next token. + +5. "chroma" state is active, so all following tokens are routed to the chroma (in general skipping big-loop, see next items), + +6. When processing of a single token is complete, the associated chroma returns 0 + (shell-truth) to request no further processing by the big loop. + +7. It can also return 1 so that single, current token will be passed into big-loop + for processing (to do a standard highlighting). + +## Chroma-Function Arguments + +- `$1` - 0 or 1, denoting if it's the first call to the chroma, or a following one, + +- `$2` - the current token, also accessible by `$\__arg` from the upper scope - + basically a private copy of `$__arg`; the token can be eg.: "grep", + +- `$3` - a private copy of `$_start_pos`, i.e. the position of the token in the + command line buffer, used to add region_highlight entry (see man), + because Zsh colorizes by *ranges* applied onto command line buffer (e.g. + `from-10 to-13 fg=red`), + +- `$4` - a private copy of `$_end_pos` from the upper scope; denotes where current token + ends (at which index in the string being the command line). + +So example invocation could look like this: + +---- +chroma/-example.ch 1 "grep" "$_start_pos" "$_end_pos" +---- + +Big-loop will be doing such calls for the user, after occurring a specific chroma-enabled command (like e.g. `awk`), and then until chroma will detect end of this chroma-enabled command (end of whole invocation, with arguments, etc.; in other words, when e.g. new line or `;`-character occurs, etc.). + +## Example Chroma-Function + +[source,zsh] +---- +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Example chroma function. It colorizes first two arguments as `builtin' style, +# third and following arguments as `globbing' style. First two arguments may +# be "strings", they will be passed through to normal higlighter (by returning 1). +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - like above document says +# +# $3 - ... +# +# $4 - ... +# +# Other tips are: +# - $CURSOR holds cursor position +# - $BUFFER holds whole command line buffer +# - $LBUFFER holds command line buffer that is left from the cursor, i.e. it's a +# BUFFER substring 1 .. $CURSOR +# - $RBUFFER is the same as LBUFFER but holds part of BUFFER right to the cursor +# +# The function receives $BUFFER but via sequence of tokens, which are shell words, +# e.g. "a b c" is a shell word, while a b c are 3 shell words. +# +# FAST_HIGHLIGHT is a friendly hash array which allows to store strings without +# creating global parameters (variables). If you need hash, go ahead and use it, +# declaring first, under some distinct name like: typeset -gA CHROMA_EXPLE_DICT. +# Remember to reset the hash and others at __first_call == 1, so that you have +# a fresh state for new command. + +# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. +# So the below 8192 assignment takes care that next token will be routed to chroma. +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global string variables. + FAST_HIGHLIGHT[chroma-example-counter]=0 + + # Set style for region_highlight entry. It is used below in + # '[[ -n "$__style" ]] ...' line, which adds highlight entry, + # like "10 12 fg=green", through `reply' array. + # + # Could check if command `example' exists and set `unknown-token' + # style instead of `command' + __style=${FAST_THEME_NAME}command + +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + else + # Count non-option tokens + (( FAST_HIGHLIGHT[chroma-example-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-example-counter] )) + + # Colorize 1..2 as builtin, 3.. as glob + if (( FAST_HIGHLIGHT[chroma-example-counter] <= 2 )); then + if [[ "$__wrd" = \"* ]]; then + # Pass through, fsh main code will do the highlight! + return 1 + else + __style=${FAST_THEME_NAME}builtin + fi + else + __style=${FAST_THEME_NAME}globbing + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# If 1 will be added to __start_pos, this will highlight "oken". +# If 1 will be subtracted from __end_pos, this will highlight "toke". +# $PREBUFFER is for specific situations when users does command \ +# i.e. when multi-line command using backslash is entered. +# +# This is a common place of adding such entry, but any above code can do +# it itself (and it does in other chromas) and skip setting __style to +# this way disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves. +# _start_pos=$_end_pos advainces pointers in command line buffer. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 +---- + diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/LICENSE b/home/.zsh-server/plugins/fast-syntax-highlighting/LICENSE new file mode 100644 index 0000000..3d6b811 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2010-2016 zsh-syntax-highlighting contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of + conditions and the following disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors + may be used to endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/README.md b/home/.zsh-server/plugins/fast-syntax-highlighting/README.md new file mode 100644 index 0000000..6c069f3 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/README.md @@ -0,0 +1,290 @@ +[![paypal](https://img.shields.io/badge/-Donate-yellow.svg?longCache=true&style=for-the-badge)](https://www.paypal.me/ZdharmaInitiative) +[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D54B3S7C6HGME) +[![patreon](https://img.shields.io/badge/-Patreon-orange.svg?longCache=true&style=for-the-badge)](https://www.patreon.com/psprint) +
New: You can request a feature when donating, even fancy or advanced ones get implemented this way. [There are +reports](DONATIONS.md) about what is being done with the money received. + +# Fast Syntax Highlighting (F-Sy-H) + +Feature rich syntax highlighting for Zsh. + +
+ image could not be loaded +
+ +### Table of Contents + +- [News](#news) +- [Installation](#installation) +- [Features](#features) +- [Performance](#performance) +- [IRC Channel](#irc-channel) + +### Other Contents +- [License](https://github.com/zdharma/fast-syntax-highlighting/blob/master/LICENSE) +- [Changelog](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHANGELOG.md) +- [Theme Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/THEME_GUIDE.md) +- [Chroma Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHROMA_GUIDE.adoc) + +# News + +* 15-06-2019 + - A new architecture for defining the highlighting for **specific commands**: it now + uses **abstract definitions** instead of **top-down, regular code**. The first effect + is the highlighting for the `git` command it is now **maximally faithful**, it + follows the `git` command almost completely. + [Screencast](https://asciinema.org/a/253411) + +# Installation + +### Manual + +Clone the Repository. + +```zsh +git clone https://github.com/zdharma/fast-syntax-highlighting ~/path/to/fsh +``` + +And add the following to your `zshrc` file. +```zsh +source ~/path/to/fsh/fast-syntax-highlighting.plugin.zsh +``` + +### Zinit + +Add the following to your `zshrc` file. + +```zsh +zinit light zdharma/fast-syntax-highlighting +``` + +Here's an example of how to load the plugin together with a few other popular +ones with the use of +[Turbo](https://zdharma.org/zinit/wiki/INTRODUCTION/#turbo_mode_zsh_62_53), +i.e.: speeding up the Zsh startup by loading the plugin right after the first +prompt, in background: + +```zsh +zinit wait lucid for \ + atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \ + zdharma/fast-syntax-highlighting \ + blockf \ + zsh-users/zsh-completions \ + atload"!_zsh_autosuggest_start" \ + zsh-users/zsh-autosuggestions +``` + +### Antigen + +Add the following to your `zshrc` file. + +```zsh +antigen bundle zdharma/fast-syntax-highlighting +``` + +### Zgen + +Add the following to your `.zshrc` file in the same place you're doing +your other `zgen load` calls in. + +```zsh +zgen load zdharma/fast-syntax-highlighting +``` + + +### Oh-My-Zsh + +Clone the Repository. + +```zsh +git clone https://github.com/zdharma/fast-syntax-highlighting.git \ + ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting +``` + +And add `fast-syntax-highlighting` to your plugin list. + +# Features + +### Themes + +Switch themes via `fast-theme {theme-name}`. + +
+ image could not be loaded +
+ +Run `fast-theme -t {theme-name}` option to obtain the snippet above. + +Run `fast-theme -l` to list available themes. + +### Variables + +Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): + +
+ image could not be loaded +
+ +
+ image could not be loaded +
+ +### Brackets + +
+ image could not be loaded +
+ +### Conditions + +Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): + +
+ image could not be loaded +
+ +### Strings + +Exact highlighting that recognizes quotings. + +
+ image could not be loaded +
+ + +### here-strings + +
+ image could not be loaded +
+ +### `exec` descriptor-variables + +Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): + +
+ image could not be loaded +
+ +### for-loops and alternate syntax (brace `{`/`}` blocks) + +
+ image could not be loaded +
+ +### Function definitions + +Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper 2 lines): + +
+ image could not be loaded +
+ +### Recursive `eval` and `$( )` highlighting + +Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line): + +
+ image could not be loaded +
+ +### Chroma functions + +Highlighting that is specific for a given command. + +
+ image could not be loaded +
+ +The [chromas](https://github.com/zdharma/fast-syntax-highlighting/tree/master/chroma) +that are enabled by default can be found +[here](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L166). + +### Math-mode highlighting + +
+ image could not be loaded +
+ +### Zcalc highlighting + +
+ image could not be loaded +
+ +# Performance +Performance differences can be observed in this Asciinema recording, where a `10 kB` function is being edited. + +
+ + asciicast + +
+ +## IRC Channel + +Channel `#zinit@freenode` is a support place for all author's projects. Connect to: +[chat.freenode.net:6697](ircs://chat.freenode.net:6697/%23zinit) (SSL) or [chat.freenode.net:6667](irc://chat.freenode.net:6667/%23zinit) + and join #zinit. + +Following is a quick access via Webchat [![IRC](https://kiwiirc.com/buttons/chat.freenode.net/zinit.png)](https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit) diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/THEME_GUIDE.md b/home/.zsh-server/plugins/fast-syntax-highlighting/THEME_GUIDE.md new file mode 100644 index 0000000..1d66dac --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/THEME_GUIDE.md @@ -0,0 +1,76 @@ +# Theme Guide for F-Sy-H + +`fast-theme` tool is used to select a theme. There are 6 shipped themes, they can be listed with `fast-theme -l`. +Themes are basic [INI files](https://github.com/zdharma/fast-syntax-highlighting/tree/master/themes) where each +key is a *style*. +Besides shipped themes, user can point this tool to any other theme, by simple `fast-theme ~/mytheme.ini`. To +obtain template to work on when creating own theme, issue `fast-theme --copy-shipped-theme {theme-name}`. + +To alter just a few styles and not create a whole new theme, use **overlay**. What is overlay? It is in the same +format as full theme, but can have only a few styles defined, and these styles will overwrite styles in main-theme. +Example overlay file: + +```ini +; overlay.ini +[base] +commandseparator = yellow,bold +comment = 17 + +[command-point] +function = green +command = 180 +``` + +File name `overlay.ini` is treated specially. + +When specifing path, following short-hands can be used: + +``` +XDG: = ~/.config/fsh (respects $XDG_CONFIG_HOME env var) +LOCAL: = /usr/local/share/fsh/ +HOME: = ~/.fsh/ +OPT: = /opt/local/share/fsh/ +``` + +So for example, issue `fast-theme XDG:overlay` to load `~/.config/fsh/overlay.ini` as overlay. The `.ini` +extension is optional. + +## Secondary Theme + +Each theme has key `secondary`, e.g. for theme `free`: + +```ini +; free.ini +[base] +default = none +unknown-token = red,bold +; ... +; ... +; ... +secondary = zdharma +``` + +Secondary theme (`zdharma` in the example) will be used for highlighting of argument for `eval` +and of `$( ... )` interior (i.e. of interior of command substitution). Basically, recursive +highlighting uses alternate theme to make the highlighted code distinct: + +![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cmdsubst.png) + +In the above screen-shot the interior of `$( ... )` uses different colors than the rest of the +code. Example for `eval`: + +![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/eval_cmp.png) + +First line doesn't use recursive highlighting, highlights `eval` argument as regular string. +Second line switches theme to `zdharma` and does full recursive highlighting of eval argument. + +## Custom Working Directory + +Set `$FAST_WORK_DIR` before loading the plugin to have e.g. processed theme files (ready to +load, in Zsh format, not INI) kept under specified location. This is handy if e.g. you install +Fast-Syntax-Highlighting system-wide (e.g. from AUR on ArchLinux) and want to have per-user +theme setup. + +You can use "~" in the path, e.g. `FAST_WORK_DIR=~/.fsh` and also the `XDG:`, `LOCAL:`, `OPT:`, +etc. short-hands, so e.g. `FAST_WORK_DIR=XDG` or `FAST_WORK_DIR=XDG:` is allowed (in this case +it will be changed to `$HOME/.config/fsh` by default by F-Sy-H loader). diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/_fast-theme b/home/.zsh-server/plugins/fast-syntax-highlighting/_fast-theme new file mode 100644 index 0000000..67f8a4d --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/_fast-theme @@ -0,0 +1,39 @@ +#compdef fast-theme + +# +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Completion for theme-switching function, fast-theme, +# part of zdharma/fast-syntax-highlighting. +# + +integer ret=1 +local -a arguments + +arguments=( + {-h,--help}'[display help text]' + {-l,--list}'[list available themes]' + {-r,--reset}'[unset any theme (revert to default highlighting)]' + {-R,--ov-reset}'[unset overlay, use styles only from main-theme (requires restart)]' + {-q,--quiet}'[no default messages]' + {-s,--show}'[get and display the theme currently being set]' + {-v,--verbose}'[more messages during operation]' + {-t,--test}'[test theme after setting it (show example code)]' + {-p,--palette}'[just print all 256 colors and exit (useful when creating a theme)]' + {-w,--workdir}'[cd into $FAST_WORK_DIR (if not set, then into the plugin directory)]' +) + +typeset -a themes +themes=( "$FAST_WORK_DIR"/themes/*.ini(:t:r) ) + +if [[ -d ${XDG_CONFIG_HOME:-$HOME/.config}/fsh ]] { + typeset -a themes2 + themes2=( "${XDG_CONFIG_HOME:-$HOME/.config}"/fsh/*.ini(:t:r) ) + themes+=( XDG:${^themes2[@]} ) +} + +_wanted themes expl "Themes" \ + compadd "$@" -a - themes && ret=0 +_arguments -s $arguments && ret=0 + +return $ret diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/fast-highlight b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-highlight new file mode 100644 index 0000000..d47ed5b --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-highlight @@ -0,0 +1,1463 @@ +# -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors +# Copyright (c) 2016-2019 Sebastian Gniazdowski (modifications) +# All rights reserved. +# +# The only licensing for this file follows. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- + +typeset -gA __fast_highlight_main__command_type_cache FAST_BLIST_PATTERNS +typeset -g FAST_WORK_DIR +: ${FAST_WORK_DIR:=$FAST_BASE_DIR} +FAST_WORK_DIR=${~FAST_WORK_DIR} +() { + emulate -L zsh -o extendedglob + local -A map + map=( "XDG:" "${XDG_CONFIG_HOME:-$HOME/.config}/fsh/" + "LOCAL:" "/usr/local/share/fsh/" + "HOME:" "$HOME/.fsh/" + "OPT:" "/opt/local/share/fsh/" + ) + FAST_WORK_DIR=${${FAST_WORK_DIR/(#m)(#s)(XDG|LOCAL|HOME|OPT):(#c0,1)/${map[${MATCH%:}:]}}%/} +} + +# Define default styles. You can set this after loading the plugin in +# Zshrc and use 256 colors via numbers, like: fg=150 +typeset -gA FAST_HIGHLIGHT_STYLES +if [[ -e $FAST_WORK_DIR/current_theme.zsh ]]; then + source $FAST_WORK_DIR/current_theme.zsh +else +# built-in theme +zstyle :plugin:fast-syntax-highlighting theme default +: ${FAST_HIGHLIGHT_STYLES[default]:=none} +: ${FAST_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold} +: ${FAST_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[subcommand]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[alias]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[suffix-alias]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[global-alias]:=bg=blue} +: ${FAST_HIGHLIGHT_STYLES[builtin]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[function]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[command]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[precommand]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[commandseparator]:=none} +: ${FAST_HIGHLIGHT_STYLES[hashed-command]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[path]:=fg=magenta} +: ${FAST_HIGHLIGHT_STYLES[path-to-dir]:=fg=magenta,underline} +: ${FAST_HIGHLIGHT_STYLES[path_pathseparator]:=} +: ${FAST_HIGHLIGHT_STYLES[globbing]:=fg=blue,bold} +: ${FAST_HIGHLIGHT_STYLES[globbing-ext]:=fg=13} +: ${FAST_HIGHLIGHT_STYLES[history-expansion]:=fg=blue,bold} +: ${FAST_HIGHLIGHT_STYLES[single-hyphen-option]:=fg=cyan} +: ${FAST_HIGHLIGHT_STYLES[double-hyphen-option]:=fg=cyan} +: ${FAST_HIGHLIGHT_STYLES[back-quoted-argument]:=none} +: ${FAST_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[back-or-dollar-double-quoted-argument]:=fg=cyan} +: ${FAST_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan} +: ${FAST_HIGHLIGHT_STYLES[assign]:=none} +: ${FAST_HIGHLIGHT_STYLES[redirection]:=none} +: ${FAST_HIGHLIGHT_STYLES[comment]:=fg=black,bold} +: ${FAST_HIGHLIGHT_STYLES[variable]:=fg=113} +: ${FAST_HIGHLIGHT_STYLES[mathvar]:=fg=blue,bold} +: ${FAST_HIGHLIGHT_STYLES[mathnum]:=fg=magenta} +: ${FAST_HIGHLIGHT_STYLES[matherr]:=fg=red} +: ${FAST_HIGHLIGHT_STYLES[assign-array-bracket]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[for-loop-variable]:=none} +: ${FAST_HIGHLIGHT_STYLES[for-loop-operator]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[for-loop-number]:=fg=magenta} +: ${FAST_HIGHLIGHT_STYLES[for-loop-separator]:=fg=yellow,bold} +: ${FAST_HIGHLIGHT_STYLES[here-string-tri]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[here-string-text]:=bg=18} +: ${FAST_HIGHLIGHT_STYLES[here-string-var]:=fg=cyan,bg=18} +: ${FAST_HIGHLIGHT_STYLES[case-input]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[case-parentheses]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[case-condition]:=bg=blue} +: ${FAST_HIGHLIGHT_STYLES[paired-bracket]:=bg=blue} +: ${FAST_HIGHLIGHT_STYLES[bracket-level-1]:=fg=green,bold} +: ${FAST_HIGHLIGHT_STYLES[bracket-level-2]:=fg=yellow,bold} +: ${FAST_HIGHLIGHT_STYLES[bracket-level-3]:=fg=cyan,bold} +: ${FAST_HIGHLIGHT_STYLES[single-sq-bracket]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[double-sq-bracket]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[double-paren]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[correct-subtle]:=fg=12} +: ${FAST_HIGHLIGHT_STYLES[incorrect-subtle]:=fg=red} +: ${FAST_HIGHLIGHT_STYLES[subtle-separator]:=fg=green} +: ${FAST_HIGHLIGHT_STYLES[subtle-bg]:=bg=18} +: ${FAST_HIGHLIGHT_STYLES[secondary]:=free} +fi + +# This can overwrite some of *_STYLES fields +[[ -r $FAST_WORK_DIR/theme_overlay.zsh ]] && source $FAST_WORK_DIR/theme_overlay.zsh + +typeset -gA __FAST_HIGHLIGHT_TOKEN_TYPES + +__FAST_HIGHLIGHT_TOKEN_TYPES=( + + # Precommand + + 'builtin' 1 + 'command' 1 + 'exec' 1 + 'nocorrect' 1 + 'noglob' 1 + 'pkexec' 1 # immune to #121 because it's usually not passed --option flags + + # Control flow + # Tokens that, at (naively-determined) "command position", are followed by + # a de jure command position. All of these are reserved words. + + $'\x7b' 2 # block '{' + $'\x28' 2 # subshell '(' + '()' 2 # anonymous function + 'while' 2 + 'until' 2 + 'if' 2 + 'then' 2 + 'elif' 2 + 'else' 2 + 'do' 2 + 'time' 2 + 'coproc' 2 + '!' 2 # reserved word; unrelated to $histchars[1] + + # Command separators + + '|' 3 + '||' 3 + ';' 3 + '&' 3 + '&&' 3 + '|&' 3 + '&!' 3 + '&|' 3 + # ### 'case' syntax, but followed by a pattern, not by a command + # ';;' ';&' ';|' +) + +# A hash instead of multiple globals +typeset -gA FAST_HIGHLIGHT + +# Brackets highlighter active by default +: ${FAST_HIGHLIGHT[use_brackets]:=1} + +FAST_HIGHLIGHT+=( + chroma-fast-theme →chroma/-fast-theme.ch + chroma-alias →chroma/-alias.ch + chroma-autoload →chroma/-autoload.ch + chroma-autorandr →chroma/-autorandr.ch + chroma-docker →chroma/-docker.ch + chroma-example →chroma/-example.ch + chroma-ionice →chroma/-ionice.ch + chroma-make →chroma/-make.ch + chroma-nice →chroma/-nice.ch + chroma-nmcli →chroma/-nmcli.ch + chroma-node →chroma/-node.ch + chroma-perl →chroma/-perl.ch + chroma-printf →chroma/-printf.ch + chroma-ruby →chroma/-ruby.ch + chroma-scp →chroma/-scp.ch + chroma-ssh →chroma/-ssh.ch + + chroma-git →chroma/main-chroma.ch%git + chroma-hub →chroma/-hub.ch + chroma-lab →chroma/-lab.ch + chroma-svn →chroma/-subversion.ch + chroma-svnadmin →chroma/-subversion.ch + chroma-svndumpfilter →chroma/-subversion.ch + + chroma-egrep →chroma/-grep.ch + chroma-fgrep →chroma/-grep.ch + chroma-grep →chroma/-grep.ch + + chroma-awk →chroma/-awk.ch + chroma-gawk →chroma/-awk.ch + chroma-mawk →chroma/-awk.ch + + chroma-source →chroma/-source.ch + chroma-. →chroma/-source.ch + + chroma-bash →chroma/-sh.ch + chroma-fish →chroma/-sh.ch + chroma-sh →chroma/-sh.ch + chroma-zsh →chroma/-sh.ch + + chroma-whatis →chroma/-whatis.ch + chroma-man →chroma/-whatis.ch + + chroma-- →chroma/-precommand.ch + chroma-xargs →chroma/-precommand.ch + chroma-nohup →chroma/-precommand.ch + chroma-strace →chroma/-precommand.ch + chroma-ltrace →chroma/-precommand.ch + + chroma-hg →chroma/-subcommand.ch + chroma-cvs →chroma/-subcommand.ch + chroma-pip →chroma/-subcommand.ch + chroma-pip2 →chroma/-subcommand.ch + chroma-pip3 →chroma/-subcommand.ch + chroma-gem →chroma/-subcommand.ch + chroma-bundle →chroma/-subcommand.ch + chroma-yard →chroma/-subcommand.ch + chroma-cabal →chroma/-subcommand.ch + chroma-npm →chroma/-subcommand.ch + chroma-nvm →chroma/-subcommand.ch + chroma-yarn →chroma/-subcommand.ch + chroma-brew →chroma/-subcommand.ch + chroma-port →chroma/-subcommand.ch + chroma-yum →chroma/-subcommand.ch + chroma-dnf →chroma/-subcommand.ch + chroma-tmux →chroma/-subcommand.ch + chroma-pass →chroma/-subcommand.ch + chroma-aws →chroma/-subcommand.ch + chroma-apt →chroma/-subcommand.ch + chroma-apt-get →chroma/-subcommand.ch + chroma-apt-cache →chroma/-subcommand.ch + chroma-aptitude →chroma/-subcommand.ch + chroma-keyctl →chroma/-subcommand.ch + chroma-systemctl →chroma/-subcommand.ch + chroma-asciinema →chroma/-subcommand.ch + chroma-ipfs →chroma/-subcommand.ch + chroma-zinit →chroma/main-chroma.ch%zinit + chroma-aspell →chroma/-subcommand.ch + chroma-bspc →chroma/-subcommand.ch + chroma-cryptsetup →chroma/-subcommand.ch + chroma-diskutil →chroma/-subcommand.ch + chroma-exercism →chroma/-subcommand.ch + chroma-gulp →chroma/-subcommand.ch + chroma-i3-msg →chroma/-subcommand.ch + chroma-openssl →chroma/-subcommand.ch + chroma-solargraph →chroma/-subcommand.ch + chroma-subliminal →chroma/-subcommand.ch + chroma-svnadmin →chroma/-subcommand.ch + chroma-travis →chroma/-subcommand.ch + chroma-udisksctl →chroma/-subcommand.ch + chroma-xdotool →chroma/-subcommand.ch + chroma-zmanage →chroma/-subcommand.ch + chroma-zsystem →chroma/-subcommand.ch + chroma-zypper →chroma/-subcommand.ch + + chroma-fpath+=\( →chroma/-fpath_peq.ch + chroma-fpath=\( →chroma/-fpath_peq.ch + chroma-FPATH+= →chroma/-fpath_peq.ch + chroma-FPATH= →chroma/-fpath_peq.ch + #chroma-which →chroma/-which.ch + #chroma-vim →chroma/-vim.ch +) + +if [[ $OSTYPE == darwin* ]] { + noglob unset FAST_HIGHLIGHT[chroma-man] FAST_HIGHLIGHT[chroma-whatis] +} + +# Assignments seen, to know if math parameter exists +typeset -gA FAST_ASSIGNS_SEEN + +# Exposing tokens found on command position, +# for other scripts to process +typeset -ga ZLAST_COMMANDS + +# Get the type of a command. +# +# Uses the zsh/parameter module if available to avoid forks, and a +# wrapper around 'type -w' as fallback. +# +# Takes a single argument. +# +# The result will be stored in REPLY. +-fast-highlight-main-type() { + REPLY=$__fast_highlight_main__command_type_cache[(e)$1] + [[ -z $REPLY ]] && { + + if zmodload -e zsh/parameter; then + if (( $+aliases[(e)$1] )); then + REPLY=alias + elif (( ${+galiases[(e)$1]} )); then + REPLY="global alias" + elif (( $+functions[(e)$1] )); then + REPLY=function + elif (( $+builtins[(e)$1] )); then + REPLY=builtin + elif (( $+commands[(e)$1] )); then + REPLY=command + elif (( $+saliases[(e)${1##*.}] )); then + REPLY='suffix alias' + elif (( $reswords[(Ie)$1] )); then + REPLY=reserved + # zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly + # runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo + # exists and is in $PATH). Avoid triggering the bug, at the expense of + # falling through to the $() below, incurring a fork. (Issue #354.) + # + # The second disjunct mimics the isrelative() C call from the zsh bug. + elif [[ $1 != */* || ${+ZSH_ARGZERO} = "1" ]] && ! builtin type -w -- $1 >/dev/null 2>&1; then + REPLY=none + fi + fi + + [[ -z $REPLY ]] && REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }" + + [[ $REPLY = "none" ]] && { + [[ -n ${FAST_BLIST_PATTERNS[(k)${${(M)1:#/*}:-$PWD/$1}]} ]] || { + [[ -d $1 ]] && REPLY="dirpath" || { + for cdpath_dir in $cdpath; do + [[ -d $cdpath_dir/$1 ]] && { REPLY="dirpath"; break; } + done + } + } + } + + __fast_highlight_main__command_type_cache[(e)$1]=$REPLY + + } +} + +# Below are variables that must be defined in outer +# scope so that they are reachable in *-process() +-fast-highlight-fill-option-variables() { + if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then + FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]=0 + else + FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]=1 + fi + + if [[ -o path_dirs ]]; then + FAST_HIGHLIGHT[path_dirs_was_set]=1 + else + FAST_HIGHLIGHT[path_dirs_was_set]=0 + fi + + if [[ -o multi_func_def ]]; then + FAST_HIGHLIGHT[multi_func_def]=1 + else + FAST_HIGHLIGHT[multi_func_def]=0 + fi + + if [[ -o interactive_comments ]]; then + FAST_HIGHLIGHT[ointeractive_comments]=1 + else + FAST_HIGHLIGHT[ointeractive_comments]=0 + fi +} + +# Main syntax highlighting function. +-fast-highlight-process() +{ + emulate -L zsh + setopt extendedglob bareglobqual nonomatch typesetsilent + + [[ $CONTEXT == "select" ]] && return 0 + + (( FAST_HIGHLIGHT[path_dirs_was_set] )) && setopt PATH_DIRS + (( FAST_HIGHLIGHT[ointeractive_comments] )) && local interactive_comments= # _set_ to empty + + # Variable declarations and initializations + # in_array_assignment true between 'a=(' and the matching ')' + # braces_stack: "R" for round, "Q" for square, "Y" for curly + # _mybuf, cdpath_dir are used in sub-functions + local _start_pos=$3 _end_pos __start __end highlight_glob=1 __arg __style in_array_assignment=0 MATCH expanded_path braces_stack __buf=$1$2 _mybuf __workbuf cdpath_dir active_command alias_target _was_double_hyphen=0 __nul=$'\0' __tmp + # __arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator + # __idx and _end_idx are used in sub-functions + # for this_word and next_word look below at commented integers and at state machine description + integer __arg_type=0 MBEGIN MEND in_redirection __len=${#__buf} __PBUFLEN=${#1} already_added offset __idx _end_idx this_word=1 next_word=0 __pos __asize __delimited=0 itmp iitmp + local -a match mbegin mend __inputs __list + + # This comment explains the numbers: + # BIT_for - word after reserved-word-recognized `for' + # BIT_afpcmd - word after a precommand that can take options, like `command' and `exec' + # integer BIT_start=1 BIT_regular=2 BIT_sudo_opt=4 BIT_sudo_arg=8 BIT_always=16 BIT_for=32 BIT_afpcmd=64 + # integer BIT_chroma=8192 + + integer BIT_case_preamble=512 BIT_case_item=1024 BIT_case_nempty_item=2048 BIT_case_code=4096 + + # Braces stack + # T - typeset, local, etc. + + # State machine + # + # The states are: + # - :__start: Command word + # - :sudo_opt: A leading-dash option to sudo (such as "-u" or "-i") + # - :sudo_arg: The argument to a sudo leading-dash option that takes one, + # when given as a separate word; i.e., "foo" in "-u foo" (two + # words) but not in "-ufoo" (one word). + # - :regular: "Not a command word", and command delimiters are permitted. + # Mainly used to detect premature termination of commands. + # - :always: The word 'always' in the «{ foo } always { bar }» syntax. + # + # When the kind of a word is not yet known, $this_word / $next_word may contain + # multiple states. For example, after "sudo -i", the next word may be either + # another --flag or a command name, hence the state would include both :__start: + # and :sudo_opt:. + # + # The tokens are always added with both leading and trailing colons to serve as + # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} + # will DTRT regardless of how many elements or repetitions $x has.. + # + # Handling of redirections: upon seeing a redirection token, we must stall + # the current state --- that is, the value of $this_word --- for two iterations + # (one for the redirection operator, one for the word following it representing + # the redirection target). Therefore, we set $in_redirection to 2 upon seeing a + # redirection operator, decrement it each iteration, and stall the current state + # when it is non-zero. Thus, upon reaching the next word (the one that follows + # the redirection operator and target), $this_word will still contain values + # appropriate for the word immediately following the word that preceded the + # redirection operator. + # + # The "the previous word was a redirection operator" state is not communicated + # to the next iteration via $next_word/$this_word as usual, but via + # $in_redirection. The value of $next_word from the iteration that processed + # the operator is discarded. + # + + # Command exposure for other scripts + ZLAST_COMMANDS=() + # Restart observing of assigns + FAST_ASSIGNS_SEEN=() + # Restart function's gathering + FAST_HIGHLIGHT[chroma-autoload-elements]="" + # Restart FPATH elements gathering + FAST_HIGHLIGHT[chroma-fpath_peq-elements]="" + # Restart svn zinit's ICE gathering + FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=0 + FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]="" + + [[ -n $ZCALC_ACTIVE ]] && { + _start_pos=0; _end_pos=__len; __arg=$__buf + -fast-highlight-math-string + return 0 + } + + # Processing buffer + local proc_buf=$__buf needle + for __arg in ${interactive_comments-${(z)__buf}} \ + ${interactive_comments+${(zZ+c+)__buf}}; do + + # Initialize $next_word to its default value? + (( in_redirection = in_redirection > 0 ? in_redirection - 1 : in_redirection )); + (( next_word = (in_redirection == 0) ? 2 : next_word )) # else Stall $next_word. + (( next_word = next_word | (this_word & (BIT_case_code|8192)) )) + + # If we have a good delimiting construct just ending, and '{' + # occurs, then respect this and go for alternate syntax, i.e. + # treat '{' (\x7b) as if it's on command position + [[ $__arg = '{' && $__delimited = 2 ]] && { (( this_word = (this_word & ~2) | 1 )); __delimited=0; } + + __asize=${#__arg} + + # Reset state of working variables + already_added=0 + __style=${FAST_THEME_NAME}unknown-token + (( this_word & 1 )) && { in_array_assignment=0; [[ $__arg == 'noglob' ]] && highlight_glob=0; } + + # Compute the new $_start_pos and $_end_pos, skipping over whitespace in $__buf. + if [[ $__arg == ';' ]] ; then + braces_stack=${braces_stack#T} + __delimited=0 + + # Both ; and \n are rendered as a ";" (SEPER) by the ${(z)..} flag. + needle=$';\n' + [[ $proc_buf = (#b)[^$needle]#([$needle]##)* ]] && offset=${mbegin[1]}-1 + (( _start_pos += offset )) + (( _end_pos = _start_pos + __asize )) + + # Prepare next loop cycle + (( this_word & BIT_case_item )) || { (( in_array_assignment )) && (( this_word = 2 | (this_word & BIT_case_code) )) || { (( this_word = 1 | (this_word & BIT_case_code) )); highlight_glob=1; }; } + in_redirection=0 + + # Chance to highlight ';' + [[ ${proc_buf[offset+1]} != $'\n' ]] && { + [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}commandseparator]} != "none" ]] && \ + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}commandseparator]}") + } + + proc_buf=${proc_buf[offset + __asize + 1,__len]} + _start_pos=$_end_pos + continue + else + offset=0 + if [[ $proc_buf = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then + # The first, outer parenthesis + offset=${mend[1]} + fi + (( _start_pos += offset )) + (( _end_pos = _start_pos + __asize )) + + # No-hit will result in value 0 + __arg_type=${__FAST_HIGHLIGHT_TOKEN_TYPES[$__arg]} + fi + + (( this_word & 1 )) && ZLAST_COMMANDS+=( $__arg ); + + proc_buf=${proc_buf[offset + __asize + 1,__len]} + + # Handle the INTERACTIVE_COMMENTS option. + # + # We use the (Z+c+) flag so the entire comment is presented as one token in $__arg. + if [[ -n ${interactive_comments+'set'} && $__arg == ${histchars[3]}* ]]; then + if (( this_word & 3 )); then + __style=${FAST_THEME_NAME}comment + else + __style=${FAST_THEME_NAME}unknown-token # prematurely terminated + fi + # ADD + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + _start_pos=$_end_pos + continue + fi + + # Redirection? + [[ $__arg == (<0-9>|)(\<|\>)* && $__arg != (\<|\>)$'\x28'* && $__arg != "<<<" ]] && \ + in_redirection=2 + + # Special-case the first word after 'sudo'. + if (( ! in_redirection )); then + (( this_word & 4 )) && [[ $__arg != -* ]] && (( this_word = this_word ^ 4 )) + + # Parse the sudo command line + if (( this_word & 4 )); then + case $__arg in + # Flag that requires an argument + '-'[Cgprtu]) + (( this_word = this_word & ~1 )) + (( next_word = 8 | (this_word & BIT_case_code) )) + ;; + # This prevents misbehavior with sudo -u -otherargument + '-'*) + (( this_word = this_word & ~1 )) + (( next_word = next_word | 1 | 4 )) + ;; + esac + elif (( this_word & 8 )); then + (( next_word = next_word | 4 | 1 )) + elif (( this_word & 64 )); then + [[ $__arg = -[pvV-]## && $active_command = "command" ]] && (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 )) + [[ $__arg = -[cla-]## && $active_command = "exec" ]] && (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 )) + [[ $__arg = \{[a-zA-Z_][a-zA-Z0-9_]#\} && $active_command = "exec" ]] && { + # Highlight {descriptor} passed to exec + (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 )) + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}exec-descriptor]}") + already_added=1 + } + fi + fi + + (( this_word & 8192 )) && { + __list=( ${(z@)${aliases[$active_command]:-${active_command##*/}}##[[:space:]]#(command|builtin|exec|noglob|nocorrect|pkexec)[[:space:]]#} ) + ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 0 "$__arg" $_start_pos $_end_pos 2>/dev/null && continue + } + + (( this_word & 1 )) && { + # !in_redirection needed particularly for exec {A}>b {C}>d + (( !in_redirection )) && active_command=$__arg + _mybuf=${${aliases[$active_command]:-${active_command##*/}}##[[:space:]]#(command|builtin|exec|noglob|nocorrect|pkexec)[[:space:]]#} + [[ "$_mybuf" = (#b)(FPATH+(#c0,1)=)* ]] && _mybuf="${match[1]} ${(j: :)${(s,:,)${_mybuf#FPATH+(#c0,1)=}}}" + [[ -n ${FAST_HIGHLIGHT[chroma-${_mybuf%% *}]} ]] && { + __list=( ${(z@)_mybuf} ) + if (( ${#__list} > 1 )) || [[ $active_command != $_mybuf ]]; then + __style=${FAST_THEME_NAME}alias + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + + ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 1 "${__list[1]}" "-100000" $_end_pos 2>/dev/null || \ + (( this_word = next_word, next_word = 2 )) + + for _mybuf in "${(@)__list[2,-1]}"; do + (( next_word = next_word | (this_word & (BIT_case_code|8192)) )) + ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 0 "$_mybuf" "-100000" $_end_pos 2>/dev/null || \ + (( this_word = next_word, next_word = 2 )) + done + + # This might have been done multiple times in chroma, but + # as _end_pos doesn't change, it can be done one more time + _start_pos=$_end_pos + + continue + else + ${${FAST_HIGHLIGHT[chroma-${__list[1]}]}%\%*} ${(M)FAST_HIGHLIGHT[chroma-${__list[1]}]%\%*} 1 "$__arg" $_start_pos $_end_pos 2>/dev/null && continue + fi + } || (( 1 )) + } + + expanded_path="" + + # The Great Fork: is this a command word? Is this a non-command word? + if (( this_word & 16 )) && [[ $__arg == 'always' ]]; then + # try-always construct + __style=${FAST_THEME_NAME}reserved-word # de facto a reserved word, although not de jure + (( next_word = 1 | (this_word & BIT_case_code) )) + elif (( (this_word & 1) && (in_redirection == 0) )) || [[ $braces_stack = T* ]]; then # T - typedef, etc. + if (( __arg_type == 1 )); then + __style=${FAST_THEME_NAME}precommand + [[ $__arg = "command" || $__arg = "exec" ]] && (( next_word = next_word | 64 )) + elif [[ $__arg = (sudo|doas) ]]; then + __style=${FAST_THEME_NAME}precommand + (( next_word = (next_word & ~2) | 4 | 1 )) + else + _mybuf=${${(Q)__arg}#\"} + if (( ${+parameters} )) && \ + [[ $_mybuf = (#b)(*)(*)\$([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) || \ + $_mybuf = (#b)(*)(*)\$\{([a-zA-Z_][a-zA-Z0-9_:-]#|[0-9]##)(*) ]] && \ + (( ${+parameters[${match[3]%%:-*}]} )) + then + -fast-highlight-main-type ${match[1]}${match[2]}${(P)match[3]%%:-*}${match[4]#\}} + elif [[ $braces_stack = T* ]]; then # T - typedef, etc. + REPLY=none + else + : ${expanded_path::=${~_mybuf}} + -fast-highlight-main-type $expanded_path + fi + + case $REPLY in + reserved) # reserved word + [[ $__arg = "[[" ]] && __style=${FAST_THEME_NAME}double-sq-bracket || __style=${FAST_THEME_NAME}reserved-word + if [[ $__arg == $'\x7b' ]]; then # Y - '{' + braces_stack='Y'$braces_stack + + elif [[ $__arg == $'\x7d' && $braces_stack = Y* ]]; then # Y - '}' + # We're at command word, so no need to check right_brace_is_recognised_everywhere + braces_stack=${braces_stack#Y} + __style=${FAST_THEME_NAME}reserved-word + (( next_word = next_word | 16 )) + + elif [[ $__arg == "[[" ]]; then # A - [[ + braces_stack='A'$braces_stack + + # Counting complex brackets (for brackets-highlighter): 1. [[ as command + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) ) + elif [[ $__arg == "for" ]]; then + (( next_word = next_word | 32 )) # BIT_for + + elif [[ $__arg == "case" ]]; then + (( next_word = BIT_case_preamble )) + + elif [[ $__arg = (typeset|declare|local|float|integer|export|readonly) ]]; then + braces_stack='T'$braces_stack + fi + ;; + 'suffix alias') __style=${FAST_THEME_NAME}suffix-alias;; + 'global alias') __style=${FAST_THEME_NAME}global-alias;; + + alias) + if [[ $__arg = ?*'='* ]]; then + # The so called (by old code) "insane_alias" + __style=${FAST_THEME_NAME}unknown-token + else + __style=${FAST_THEME_NAME}alias + (( ${+aliases} )) && alias_target=${aliases[$__arg]} || alias_target="${"$(alias -- $__arg)"#*=}" + [[ ${__FAST_HIGHLIGHT_TOKEN_TYPES[$alias_target]} = "1" && $__arg_type != "1" ]] && __FAST_HIGHLIGHT_TOKEN_TYPES[$__arg]="1" + fi + ;; + + builtin) [[ $__arg = "[" ]] && { + __style=${FAST_THEME_NAME}single-sq-bracket + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) ) + } || __style=${FAST_THEME_NAME}builtin + # T - typeset, etc. mode + [[ $__arg = (typeset|declare|local|float|integer|export|readonly) ]] && braces_stack='T'$braces_stack + [[ $__arg = eval ]] && (( next_word = next_word | 256 )) + ;; + + function) __style=${FAST_THEME_NAME}function;; + + command) __style=${FAST_THEME_NAME}command;; + + hashed) __style=${FAST_THEME_NAME}hashed-command;; + + dirpath) __style=${FAST_THEME_NAME}path-to-dir;; + + none) # Assign? + if [[ $__arg == [a-zA-Z_][a-zA-Z0-9_]#(|\[[^\]]#\])(|[^\]]#\])(|[+])=* || $__arg == [0-9]##(|[+])=* || ( $braces_stack = T* && ${__arg_type} != 3 ) ]] { + __style=${FAST_THEME_NAME}assign + FAST_ASSIGNS_SEEN[${__arg%%=*}]=1 + + # Handle array assignment + [[ $__arg = (#b)*=(\()*(\))* || $__arg = (#b)*=(\()* ]] && { + (( __start=_start_pos-__PBUFLEN+${mbegin[1]}-1, __end=__start+1, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}assign-array-bracket]}") + # Counting complex brackets (for brackets-highlighter): 2. ( in array assign + _FAST_COMPLEX_BRACKETS+=( $__start ) + (( mbegin[2] >= 1 )) && { + (( __start=_start_pos-__PBUFLEN+${mbegin[2]}-1, __end=__start+1, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}assign-array-bracket]}") + # Counting complex brackets (for brackets-highlighter): 3a. ) in array assign + _FAST_COMPLEX_BRACKETS+=( $__start ) + } || in_array_assignment=1 + } || { [[ ${braces_stack[1]} != 'T' ]] && (( next_word = (next_word | 1) & ~2 )); } + + # Handle no-string highlight, string "/' highlight, math mode highlight + local ctmp="\"" dtmp="'" + itmp=${__arg[(i)$ctmp]}-1 iitmp=${__arg[(i)$dtmp]}-1 + integer jtmp=${__arg[(b:itmp+2:i)$ctmp]} jjtmp=${__arg[(b:iitmp+2:i)$dtmp]} + (( itmp < iitmp && itmp <= __asize - 1 )) && (( jtmp > __asize && (jtmp = __asize), 1 > 0 )) && \ + (( __start=_start_pos-__PBUFLEN+itmp, __end=_start_pos-__PBUFLEN+jtmp, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") && \ + { itmp=${__arg[(i)=]}; __arg=${__arg[itmp,__asize]}; (( _start_pos += itmp - 1 )); + -fast-highlight-string; (( _start_pos = _start_pos - itmp + 1, 1 > 0 )); } || \ + { + (( iitmp <= __asize - 1 )) && (( jjtmp > __asize && (jjtmp = __asize), 1 > 0 )) && \ + (( __start=_start_pos-__PBUFLEN+iitmp, __end=_start_pos-__PBUFLEN+jjtmp, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}single-quoted-argument]}") + } || \ + { + itmp=${__arg[(i)=]}; __arg=${__arg[itmp,__asize]}; (( _start_pos += itmp - 1 )); + [[ ${__arg[2,4]} = '$((' ]] && { -fast-highlight-math-string; + (( __start=_start_pos-__PBUFLEN+2, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") + # Counting complex brackets (for brackets-highlighter): 4. $(( in assign argument + _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) + (( jtmp = ${__arg[(I)\)\)]}-1, jtmp > 0 )) && { + (( __start=_start_pos-__PBUFLEN+jtmp, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") + # Counting complex brackets (for brackets-highlighter): 5. )) in assign argument + _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) + } + } || -fast-highlight-string; + (( _start_pos = _start_pos - itmp + 1, 1 > 0 )) + } + + } elif [[ $__arg = ${histchars[1]}* && -n ${__arg[2]} ]] { + __style=${FAST_THEME_NAME}history-expansion + + } elif [[ $__arg == ${histchars[2]}* ]] { + __style=${FAST_THEME_NAME}history-expansion + + } elif (( __arg_type == 3 )) { + # This highlights empty commands (semicolon follows nothing) as an error. + # Zsh accepts them, though. + (( this_word & 3 )) && __style=${FAST_THEME_NAME}commandseparator + + } elif [[ $__arg[1,2] == '((' ]] { + # Arithmetic evaluation. + # + # Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...} + # splitter would only output the '((' token if the matching '))' had + # been typed. Therefore, under those versions of zsh, BUFFER="(( 42" + # would be highlighted as an error until the matching "))" are typed. + # + # We highlight just the opening parentheses, as a reserved word; this + # is how [[ ... ]] is highlighted, too. + + # ADD + (( __start=_start_pos-__PBUFLEN, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") + already_added=1 + + # Counting complex brackets (for brackets-highlighter): 6. (( as command + _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) + + -fast-highlight-math-string + + # ADD + [[ $__arg[-2,-1] == '))' ]] && { + (( __start=_end_pos-__PBUFLEN-2, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") + (( __delimited = __delimited ? 2 : __delimited )) + + # Counting complex brackets (for brackets-highlighter): 7. )) for as-command (( + _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) + } + + } elif [[ $__arg == '()' ]] { + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) ) + # anonymous function + __style=${FAST_THEME_NAME}reserved-word + } elif [[ $__arg == $'\x28' ]] { + # subshell '(', stack: letter 'R' + __style=${FAST_THEME_NAME}reserved-word + braces_stack='R'$braces_stack + + } elif [[ $__arg == $'\x29' ]] { + # ')', stack: letter 'R' for subshell + [[ $braces_stack = R* ]] && { braces_stack=${braces_stack#R}; __style=${FAST_THEME_NAME}reserved-word; } + + } elif (( this_word & 14 )) { + __style=${FAST_THEME_NAME}default + + } elif [[ $__arg = (';;'|';&'|';|') ]] && (( this_word & BIT_case_code )) { + (( next_word = (next_word | BIT_case_item) & ~(BIT_case_code+3) )) + __style=${FAST_THEME_NAME}default + + } elif [[ $__arg = \$\([^\(]* ]] { + already_added=1 + } + ;; + *) + # ADD + # (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end commandtypefromthefuture-$REPLY") + already_added=1 + ;; + esac + fi + # in_redirection || BIT_regular || BIT_sudo_opt || BIT_sudo_arg + elif (( in_redirection + this_word & 14 )) + then # $__arg is a non-command word + case $__arg in + ']]') + # A - [[ + [[ $braces_stack = A* ]] && { + __style=${FAST_THEME_NAME}double-sq-bracket + (( __delimited = __delimited ? 2 : __delimited )) + # Counting complex brackets (for brackets-highlighter): 8a. ]] for as-command [[ + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) + } || { + [[ $braces_stack = *A* ]] && { + __style=${FAST_THEME_NAME}unknown-token + # Counting complex brackets (for brackets-highlighter): 8b. ]] for as-command [[ + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) + } || __style=${FAST_THEME_NAME}default + } + braces_stack=${braces_stack#A} + ;; + ']') + __style=${FAST_THEME_NAME}single-sq-bracket + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) ) + ;; + $'\x28') + # '(' inside [[ + __style=${FAST_THEME_NAME}reserved-word + braces_stack='R'$braces_stack + ;; + $'\x29') # ')' - subshell or end of array assignment + if (( in_array_assignment )); then + in_array_assignment=0 + (( next_word = next_word | 1 )) + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}assign-array-bracket]}") + already_added=1 + # Counting complex brackets (for brackets-highlighter): 3b. ) in array assign + _FAST_COMPLEX_BRACKETS+=( $__start ) + elif [[ $braces_stack = R* ]]; then + braces_stack=${braces_stack#R} + __style=${FAST_THEME_NAME}reserved-word + # Zsh doesn't tokenize final ) if it's just single ')', + # but logically what's below is correct, so it is kept + # in case Zsh will be changed / fixed, etc. + elif [[ $braces_stack = F* ]]; then + __style=${FAST_THEME_NAME}builtin + fi + ;; + $'\x28\x29') # '()' - possibly a function definition + # || false # TODO: or if the previous word was a command word + (( FAST_HIGHLIGHT[multi_func_def] )) && (( next_word = next_word | 1 )) + __style=${FAST_THEME_NAME}reserved-word + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) ) + # Remove possible annoying unknown-token __style, or misleading function __style + reply[-1]=() + __fast_highlight_main__command_type_cache[$active_command]="function" + ;; + '--'*) [[ $__arg == "--" ]] && { _was_double_hyphen=1; __style=${FAST_THEME_NAME}double-hyphen-option; } || { + (( !_was_double_hyphen )) && { + [[ "$__arg" = (#b)(--[a-zA-Z0-9_]##)=(*) ]] && { + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") + (( __start=_start_pos-__PBUFLEN+1+mend[1], __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-${${${(M)match[2]:#<->}:+number}:-string}]}") + already_added=1 + } || __style=${FAST_THEME_NAME}double-hyphen-option + } || __style=${FAST_THEME_NAME}default + } + ;; + '-'*) (( !_was_double_hyphen )) && __style=${FAST_THEME_NAME}single-hyphen-option || __style=${FAST_THEME_NAME}default;; + \$\'*) + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}dollar-quoted-argument]}") + -fast-highlight-dollar-string + already_added=1 + ;; + [\"\']*|[^\"\\]##([\\][\\])#\"*|[^\'\\]##([\\][\\])#\'*) + # 256 is eval-mode + if (( this_word & 256 )) && [[ $__arg = [\'\"]* ]]; then + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}recursive-base]}") + if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then + __idx=1 + _mybuf=$FAST_THEME_NAME + FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):} + (( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh + else + __idx=0 + fi + (( _start_pos-__PBUFLEN >= 0 )) && \ + -fast-highlight-process "$PREBUFFER" "${${__arg%[\'\"]}#[\'\"]}" $(( _start_pos + 1 )) + (( __idx )) && FAST_THEME_NAME=$_mybuf + already_added=1 + else + [[ $__arg = *([^\\][\#][\#]|"(#b)"|"(#B)"|"(#m)"|"(#c")* && $highlight_glob -ne 0 ]] && \ + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}globbing-ext]}") + # Reusing existing vars, treat this code like C++ STL + # header, full of underscores and unhelpful var names + itmp=0 __workbuf=$__arg __tmp="" cdpath_dir=$__arg + while [[ $__workbuf = (#b)[^\"\'\\]#(([\"\'])|[\\](*))(*) ]]; do + [[ -n ${match[3]} ]] && { + itmp+=${mbegin[1]} + # Optionally skip 1 quoted char + [[ $__tmp = \' ]] && __workbuf=${match[3]} || { itmp+=1; __workbuf=${match[3]:1}; } + } || { + itmp+=${mbegin[1]} + __workbuf=${match[4]} + # Toggle quoting + [[ ( ${match[1]} = \" && $__tmp != \' ) || ( ${match[1]} = \' && $__tmp != \" ) ]] && { + [[ $__tmp = [\"\'] ]] && { + # End of quoting + (( __start=_start_pos-__PBUFLEN+iitmp-1, __end=_start_pos-__PBUFLEN+itmp, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}${${${__tmp#\'}:+double-quoted-argument}:-single-quoted-argument}]}") + already_added=1 + + [[ $__tmp = \" ]] && { + __arg=${cdpath_dir[iitmp+1,itmp-1]} + (( _start_pos += iitmp - 1 + 1 )) + -fast-highlight-string + (( _start_pos = _start_pos - iitmp + 1 - 1 )) + } + # The end-of-quoting proper algorithm action + __tmp= + } || { + # Beginning of quoting + iitmp=itmp + # The beginning-of-quoting proper algorithm action + __tmp=${match[1]} + } + } + } + done + [[ $__tmp = [\"\'] ]] && { + (( __start=_start_pos-__PBUFLEN+iitmp-1, __end=_start_pos-__PBUFLEN+__asize, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}${${${__tmp#\'}:+double-quoted-argument}:-single-quoted-argument}]}") + already_added=1 + + [[ $__tmp = \" ]] && { + __arg=${cdpath_dir[iitmp+1,__asize]} + (( _start_pos += iitmp - 1 + 1 )) + -fast-highlight-string + (( _start_pos = _start_pos - iitmp + 1 - 1 )) + } + } + fi + ;; + \$\(\(*) + already_added=1 + -fast-highlight-math-string + # ADD + (( __start=_start_pos-__PBUFLEN+1, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") + # Counting complex brackets (for brackets-highlighter): 9. $(( as argument + _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) + # ADD + [[ $__arg[-2,-1] == '))' ]] && (( __start=_end_pos-__PBUFLEN-2, __end=__start+2, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}") + # Counting complex brackets (for brackets-highlighter): 10. )) for as-argument $(( + _FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) ) + ;; + '`'*) + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-quoted-argument]}") + if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then + __idx=1 + _mybuf=$FAST_THEME_NAME + FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):} + (( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh + else + __idx=0 + fi + (( _start_pos-__PBUFLEN >= 0 )) && \ + -fast-highlight-process "$PREBUFFER" "${${__arg%[\`]}#[\`]}" $(( _start_pos + 1 )) + (( __idx )) && FAST_THEME_NAME=$_mybuf + already_added=1 + ;; + '((') # 'F' - (( after for + (( this_word & 32 )) && { + braces_stack='F'$braces_stack + __style=${FAST_THEME_NAME}double-paren + # Counting complex brackets (for brackets-highlighter): 11. (( as for-syntax + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) + # This is set after __arg_type == 2, and also here, + # when another alternate-syntax capable command occurs + __delimited=1 + } + ;; + '))') # 'F' - (( after for + [[ $braces_stack = F* ]] && { + braces_stack=${braces_stack#F} + __style=${FAST_THEME_NAME}double-paren + # Counting complex brackets (for brackets-highlighter): 12. )) as for-syntax + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN+1 )) ) + (( __delimited = __delimited ? 2 : __delimited )) + } + ;; + '<<<') + (( next_word = (next_word | 128) & ~3 )) + [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-tri]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-tri]}") + already_added=1 + ;; + *) # F - (( after for + if [[ $braces_stack = F* ]]; then + -fast-highlight-string + _mybuf=$__arg + __idx=_start_pos + while [[ $_mybuf = (#b)[^a-zA-Z\{\$]#([a-zA-Z][a-zA-Z0-9]#)(*) ]]; do + (( __start=__idx-__PBUFLEN+${mbegin[1]}-1, __end=__idx-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-variable]}") + __idx+=${mend[1]} + _mybuf=${match[2]} + done + + _mybuf=$__arg + __idx=_start_pos + while [[ $_mybuf = (#b)[^+\<\>=:\*\|\&\^\~-]#([+\<\>=:\*\|\&\^\~-]##)(*) ]]; do + (( __start=__idx-__PBUFLEN+${mbegin[1]}-1, __end=__idx-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-operator]}") + __idx+=${mend[1]} + _mybuf=${match[2]} + done + + _mybuf=$__arg + __idx=_start_pos + while [[ $_mybuf = (#b)[^0-9]#([0-9]##)(*) ]]; do + (( __start=__idx-__PBUFLEN+${mbegin[1]}-1, __end=__idx-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-number]}") + __idx+=${mend[1]} + _mybuf=${match[2]} + done + + if [[ $__arg = (#b)[^\;]#(\;)[\ ]# ]]; then + (( __start=_start_pos-__PBUFLEN+${mbegin[1]}-1, __end=_start_pos-__PBUFLEN+${mend[1]}+1-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}") + fi + + already_added=1 + elif [[ $__arg = *([^\\][\#][\#]|"(#b)"|"(#B)"|"(#m)"|"(#c")* ]]; then + (( highlight_glob )) && __style=${FAST_THEME_NAME}globbing-ext || __style=${FAST_THEME_NAME}default + elif [[ $__arg = ([*?]*|*[^\\][*?]*) ]]; then + (( highlight_glob )) && __style=${FAST_THEME_NAME}globbing || __style=${FAST_THEME_NAME}default + elif [[ $__arg = \$* ]]; then + __style=${FAST_THEME_NAME}variable + elif [[ $__arg = $'\x7d' && $braces_stack = Y* && ${FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]} = "1" ]]; then + # right brace, i.e. $'\x7d' == '}' + # Parsing rule: # { + # + # Additionally, `tt(})' is recognized in any position if neither the + # tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.""" + braces_stack=${braces_stack#Y} + __style=${FAST_THEME_NAME}reserved-word + (( next_word = next_word | 16 )) + elif [[ $__arg = (';;'|';&'|';|') ]] && (( this_word & BIT_case_code )); then + (( next_word = (next_word | BIT_case_item) & ~(BIT_case_code+3) )) + __style=${FAST_THEME_NAME}default + elif [[ $__arg = ${histchars[1]}* && -n ${__arg[2]} ]]; then + __style=${FAST_THEME_NAME}history-expansion + elif (( __arg_type == 3 )); then + __style=${FAST_THEME_NAME}commandseparator + elif (( in_redirection == 2 )); then + __style=${FAST_THEME_NAME}redirection + elif (( ${+galiases[(e)$__arg]} )); then + __style=${FAST_THEME_NAME}global-alias + else + if [[ ${FAST_HIGHLIGHT[no_check_paths]} != 1 ]]; then + if [[ ${FAST_HIGHLIGHT[use_async]} != 1 ]]; then + if -fast-highlight-check-path noasync; then + # ADD + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + already_added=1 + + # TODO: path separators, optimize and add to async code-path + [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} ]] && { + for (( __pos = _start_pos; __pos <= _end_pos; __pos++ )) ; do + # ADD + [[ ${__buf[__pos]} == "/" ]] && (( __start=__pos-__PBUFLEN, __start >= 0 )) && reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}") + done + } + else + __style=${FAST_THEME_NAME}default + fi + else + if [[ -z ${FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}]} || $(( EPOCHSECONDS - FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}-born-at] )) -gt 8 ]]; then + if [[ $LASTWIDGET != *-or-beginning-search ]]; then + exec {PCFD}< <(-fast-highlight-check-path; sleep 5) + command sleep 0 + FAST_HIGHLIGHT[path-queue]+=";$_start_pos $_end_pos;" + is-at-least 5.0.6 && __pos=1 || __pos=0 + zle -F ${${__pos:#0}:+-w} $PCFD fast-highlight-check-path-handler + already_added=1 + else + __style=${FAST_THEME_NAME}default + fi + elif [[ ${FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}]%D} -eq 1 ]]; then + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path${${(M)FAST_HIGHLIGHT[cache-path-${(q)__arg}-${_start_pos}]%D}:+-to-dir}]}") + already_added=1 + else + __style=${FAST_THEME_NAME}default + fi + fi + else + __style=${FAST_THEME_NAME}default + fi + fi + ;; + esac + elif (( this_word & 128 )) + then + (( next_word = (next_word | 2) & ~129 )) + [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-text]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-text]}") + -fast-highlight-string ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-var]:#none} + already_added=1 + elif (( this_word & (BIT_case_preamble + BIT_case_item) )) + then + if (( this_word & BIT_case_preamble )); then + [[ $__arg = "in" ]] && { + __style=${FAST_THEME_NAME}reserved-word + (( next_word = BIT_case_item )) + } || { + __style=${FAST_THEME_NAME}case-input + (( next_word = BIT_case_preamble )) + } + else + if (( this_word & BIT_case_nempty_item == 0 )) && [[ $__arg = "esac" ]]; then + (( next_word = 1 )) + __style=${FAST_THEME_NAME}reserved-word + elif [[ $__arg = (\(*\)|\)|\() ]]; then + [[ $__arg = *\) ]] && (( next_word = BIT_case_code | 1 )) || (( next_word = BIT_case_item | BIT_case_nempty_item )) + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) ) + (( ${#__arg} > 1 )) && { + _FAST_COMPLEX_BRACKETS+=( $(( _start_pos+${#__arg}-1-__PBUFLEN )) ) + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}") + (( __start=_start_pos+1-__PBUFLEN, __end=_end_pos-1-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}") + already_added=1 + } || { + __style=${FAST_THEME_NAME}case-parentheses + } + else + (( next_word = BIT_case_item | BIT_case_nempty_item )) + __style=${FAST_THEME_NAME}case-condition + fi + fi + fi + if [[ $__arg = (#b)*'#'(([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])|([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]))* || $__arg = (#b)*'rgb('(([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)))* ]]; then + if [[ -n $match[2] ]]; then + if [[ $match[2] = ?? || $match[3] = ?? || $match[4] = ?? ]]; then + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#${(l:2::0:)match[2]}${(l:2::0:)match[3]}${(l:2::0:)match[4]}") + else + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#$match[2]$match[3]$match[4]") + fi + else + (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#$match[5]$match[6]$match[7]") + fi + already_added=1 + fi + + # ADD + (( already_added == 0 )) && [[ ${FAST_HIGHLIGHT_STYLES[$__style]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + + if (( (__arg_type == 3) && ((this_word & (BIT_case_preamble|BIT_case_item)) == 0) )); then + if [[ $__arg == ';' ]] && (( in_array_assignment )); then + # literal newline inside an array assignment + (( next_word = 2 | (next_word & BIT_case_code) )) + elif [[ -n ${braces_stack[(r)A]} ]]; then + # 'A' in stack -> inside [[ ... ]] + (( next_word = 2 | (next_word & BIT_case_code) )) + else + braces_stack=${braces_stack#T} + (( next_word = 1 | (next_word & BIT_case_code) )) + highlight_glob=1 + # A new command means that we should not expect that alternate + # syntax will occur (this is also in the ';' short-path), but + # || and && mean going down just 1 step, not all the way to 0 + [[ $__arg != ("||"|"&&") ]] && __delimited=0 || (( __delimited = __delimited == 2 ? 1 : __delimited )) + fi + elif (( ( (__arg_type == 1) || (__arg_type == 2) ) && (this_word & 1) )); then # (( __arg_type == 1 || __arg_type == 2 )) && (( this_word & 1 )) + __delimited=1 + (( next_word = 1 | (next_word & (64 | BIT_case_code)) )) + elif [[ $__arg == "repeat" ]] && (( this_word & 1 )); then + __delimited=1 + # skip the repeat-count word + in_redirection=2 + # The redirection mechanism assumes $this_word describes the word + # following the redirection. Make it so. + # + # That word can be a command word with shortloops (`repeat 2 ls`) + # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`). + # + # The repeat-count word will be handled like a redirection target. + (( this_word = 3 )) + fi + _start_pos=$_end_pos + # This is the default/common codepath. + (( this_word = in_redirection == 0 ? next_word : this_word )) #else # Stall $this_word. + done + + # Do we have whole buffer? I.e. start at zero + [[ $3 != 0 ]] && return 0 + + # The loop overwrites ")" with "x", except those from $( ) substitution + # + # __pos: current nest level, starts from 0 + # __workbuf: copy of __buf, with limit on 250 characters + # __idx: index in whole command line buffer + # __list: list of coordinates of ) which shouldn't be ovewritten + _mybuf=${__buf[1,250]} __workbuf=$_mybuf __idx=0 __pos=0 __list=() + + while [[ $__workbuf = (#b)[^\(\)]#([\(\)])(*) ]]; do + if [[ ${match[1]} == \( ]]; then + __arg=${_mybuf[__idx+${mbegin[1]}-1,__idx+${mbegin[1]}-1+2]} + [[ $__arg = '$('[^\(] ]] && __list+=( $__pos ) + [[ $__arg = '$((' ]] && _mybuf[__idx+${mbegin[1]}-1]=x + # Increase parenthesis level + __pos+=1 + else + # Decrease parenthesis level + __pos=__pos-1 + [[ -z ${__list[(r)$__pos]} ]] && [[ $__pos -gt 0 ]] && _mybuf[__idx+${mbegin[1]}]=x + fi + __idx+=${mbegin[2]}-1 + __workbuf=${match[2]} + done + + # Run on fake buffer with replaced parentheses: ")" into "x" + if [[ "$_mybuf" = *$__nul* ]]; then + # Try to avoid conflict with the \0, however + # we have to split at *some* character - \7 + # is ^G, so one cannot have null and ^G at + # the same time on the command line + __nul=$'\7' + fi + + __inputs=( ${(ps:$__nul:)${(S)_mybuf//(#b)*\$\(([^\)]#)(\)|(#e))/${mbegin[1]};${mend[1]}${__nul}}%$__nul*} ) + if [[ "${__inputs[1]}" != "$_mybuf" && -n "${__inputs[1]}" ]]; then + if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then + __idx=1 + __tmp=$FAST_THEME_NAME + FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):} + (( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh + else + __idx=0 + fi + for _mybuf in $__inputs; do + (( __start=${_mybuf%%;*}-__PBUFLEN-1, __end=${_mybuf##*;}-__PBUFLEN, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${__tmp}recursive-base]}") + # Pass authentic buffer for recursive analysis + -fast-highlight-process "$PREBUFFER" "${__buf[${_mybuf%%;*},${_mybuf##*;}]}" $(( ${_mybuf%%;*} - 1 )) + done + # Restore theme + (( __idx )) && FAST_THEME_NAME=$__tmp + fi + + return 0 +} + +-fast-highlight-check-path() +{ + (( _start_pos-__PBUFLEN >= 0 )) || \ + { [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; } + [[ $1 != "noasync" ]] && { + print -r -- ${sysparams[pid]} + # This is to fill cache + print -r -- $__arg + } + + : ${expanded_path:=${(Q)~__arg}} + [[ -n ${FAST_BLIST_PATTERNS[(k)${${(M)expanded_path:#/*}:-$PWD/$expanded_path}]} ]] && { [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; } + + [[ -z $expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; } + [[ -d $expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos ${_end_pos}D" || __style=${FAST_THEME_NAME}path-to-dir; return 0; } + [[ -e $expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos $_end_pos" || __style=${FAST_THEME_NAME}path; return 0; } + + # Search the path in CDPATH, only for CD command + [[ $active_command = "cd" ]] && for cdpath_dir in $cdpath; do + [[ -d $cdpath_dir/$expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos ${_end_pos}D" || __style=${FAST_THEME_NAME}path-to-dir; return 0; } + [[ -e $cdpath_dir/$expanded_path ]] && { [[ $1 != "noasync" ]] && print -r -- "$_start_pos $_end_pos" || __style=${FAST_THEME_NAME}path; return 0; } + done + + # It's not a path. + [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos" + return 1 +} + +-fast-highlight-check-path-handler() { + local IFS=$'\n' pid PCFD=$1 line stripped val + integer idx + + if read -r -u $PCFD pid; then + if read -r -u $PCFD val; then + if read -r -u $PCFD line; then + stripped=${${line#- }%D} + FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}-born-at]=$EPOCHSECONDS + idx=${${FAST_HIGHLIGHT[path-queue]}[(I)$stripped]} + (( idx > 0 )) && { + if [[ $line != -* ]]; then + FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]="1${(M)line%D}" + region_highlight+=("${line%% *} ${${line##* }%D} ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path${${(M)line%D}:+-to-dir}]}") + else + FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]=0 + fi + val=${FAST_HIGHLIGHT[path-queue]} + val[idx-1,idx+${#stripped}]="" + FAST_HIGHLIGHT[path-queue]=$val + [[ ${FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]%D} = 1 && ${#val} -le 27 ]] && zle -R + } + fi + fi + kill -9 $pid 2>/dev/null + fi + + zle -F -w ${PCFD} + exec {PCFD}<&- +} + +zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler + +# Highlight special blocks inside double-quoted strings +# +# The while [[ ... ]] pattern is logically ((A)|(B)|(C)|(D)|(E))(*), where: +# - A matches $var[abc] +# - B matches ${(...)var[abc]} +# - C matches $ +# - D matches \$ or \" or \' +# - E matches \* +# +# and the first condition -n ${match[7] uses D to continue searching when +# backslash-something (not ['"$]) is occured. +# +# $1 - additional style to glue-in to added style +-fast-highlight-string() +{ + (( _start_pos-__PBUFLEN >= 0 )) || return 0 + _mybuf=$__arg + __idx=_start_pos + + # 7 8 + while [[ $_mybuf = (#b)[^\$\\]#((\$(#B)([#+^=~](#c1,2))(#c0,1)(#B)([a-zA-Z_:][a-zA-Z0-9_:]#|[0-9]##)(#b)(\[[^\]]#\])(#c0,1))|(\$[{](#B)([#+^=~](#c1,2))(#c0,1)(#b)(\([a-zA-Z0-9_:@%#]##\))(#c0,1)[a-zA-Z0-9_:#]##(\[[^\]]#\])(#c0,1)[}])|\$|[\\][\'\"\$]|[\\](*))(*) ]]; do + [[ -n ${match[7]} ]] && { + # Skip following char – it is quoted. Choice is + # made to not highlight such quoting + __idx+=${mbegin[1]}+1 + _mybuf=${match[7]:1} + } || { + __idx+=${mbegin[1]}-1 + _end_idx=__idx+${mend[1]}-${mbegin[1]}+1 + _mybuf=${match[8]} + + # ADD + (( __start=__idx-__PBUFLEN, __end=_end_idx-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${${1:+$1}:-${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}}") + + __idx=_end_idx + } + done + return 0 +} + +# Highlight math and non-math context variables inside $(( )) and (( )) +# +# The while [[ ... ]] pattern is logically ((A)|(B)|(C)|(D))(*), where: +# - A matches $var[abc] +# - B matches ${(...)var[abc]} +# - C matches $ +# - D matches words [a-zA-Z]## (variables) +# +# Parameters used: _mybuf, __idx, _end_idx, __style +-fast-highlight-math-string() +{ + (( _start_pos-__PBUFLEN >= 0 )) || return 0 + _mybuf=$__arg + __idx=_start_pos + + # 7 + while [[ $_mybuf = (#b)[^\$_a-zA-Z0-9]#((\$(#B)(+|)(#B)([a-zA-Z_:][a-zA-Z0-9_:]#|[0-9]##)(#b)(\[[^\]]##\])(#c0,1))|(\$[{](#B)(+|)(#b)(\([a-zA-Z0-9_:@%#]##\))(#c0,1)[a-zA-Z0-9_:#]##(\[[^\]]##\])(#c0,1)[}])|\$|[a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) ]]; do + __idx+=${mbegin[1]}-1 + _end_idx=__idx+${mend[1]}-${mbegin[1]}+1 + _mybuf=${match[7]} + + [[ ${match[1]} = [0-9]* ]] && __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]} || { + [[ ${match[1]} = [a-zA-Z_]* ]] && { + [[ ${+parameters[${match[1]}]} = 1 || ${FAST_ASSIGNS_SEEN[${match[1]}]} = 1 ]] && \ + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathvar]} || \ + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]} + } || { + [[ ${match[1]} = "$"* ]] && { + match[1]=${match[1]//[\{\}+]/} + if [[ ${match[1]} = "$" || ${FAST_ASSIGNS_SEEN[${match[1]:1}]} = 1 ]] || \ + { eval "[[ -n \${(P)\${match[1]:1}} ]]" } 2>> /dev/null; then + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]} + else + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]} + fi + } + } + } + + # ADD + [[ $__style != "none" && -n $__style ]] && (( __start=__idx-__PBUFLEN, __end=_end_idx-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end $__style") + + __idx=_end_idx + done +} + +# Highlight special chars inside dollar-quoted strings +-fast-highlight-dollar-string() +{ + (( _start_pos-__PBUFLEN >= 0 )) || return 0 + local i j k __style + local AA + integer c + + # Starting dollar-quote is at 1:2, so __start parsing at offset 3 in the string. + for (( i = 3 ; i < _end_pos - _start_pos ; i += 1 )) ; do + (( j = i + _start_pos - 1 )) + (( k = j + 1 )) + + case ${__arg[$i]} in + "\\") __style=${FAST_THEME_NAME}back-dollar-quoted-argument + for (( c = i + 1 ; c <= _end_pos - _start_pos ; c += 1 )); do + [[ ${__arg[$c]} != ([0-9xXuUa-fA-F]) ]] && break + done + AA=$__arg[$i+1,$c-1] + # Matching for HEX and OCT values like \0xA6, \xA6 or \012 + if [[ "$AA" == (#m)(#s)(x|X)[0-9a-fA-F](#c1,2) + || "$AA" == (#m)(#s)[0-7](#c1,3) + || "$AA" == (#m)(#s)u[0-9a-fA-F](#c1,4) + || "$AA" == (#m)(#s)U[0-9a-fA-F](#c1,8) + ]]; then + (( k += MEND )) + (( i += MEND )) + else + if (( __asize > i+1 )) && [[ $__arg[i+1] == [xXuU] ]]; then + # \x not followed by hex digits is probably an error + __style=${FAST_THEME_NAME}unknown-token + fi + (( k += 1 )) # Color following char too. + (( i += 1 )) # Skip parsing the escaped char. + fi + ;; + *) continue ;; + + esac + # ADD + (( __start=j-__PBUFLEN, __end=k-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + done +} + +-fast-highlight-init() { + _FAST_COMPLEX_BRACKETS=() + __fast_highlight_main__command_type_cache=() +} + +typeset -ga FSH_LIST +-fsh_sy_h_shappend() { + FSH_LIST+=( "$(( $1 - 1 ));;$(( $2 ))" ) +} + +functions -M fsh_sy_h_append 2 2 -fsh_sy_h_shappend 2>/dev/null + +# vim:ft=zsh:sw=2:sts=2 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/fast-string-highlight b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-string-highlight new file mode 100644 index 0000000..cc8d860 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-string-highlight @@ -0,0 +1,77 @@ +# vim:ft=zsh:sw=4:sts=4 + +# +# $1 - PREBUFFER +# $2 - BUFFER +# +function -fast-highlight-string-process { + emulate -LR zsh + setopt extendedglob warncreateglobal typesetsilent + + local -A pos_to_level level_to_pos pair_map final_pairs + local input=$1$2 _mybuf=$1$2 __style __quoting + integer __idx=0 __pair_idx __level=0 __start __end + local -a match mbegin mend + + pair_map=( "(" ")" "{" "}" "[" "]" ) + + while [[ $_mybuf = (#b)([^"{}()[]\\\"'"]#)((["({[]})\"'"])|[\\](*))(*) ]]; do + if [[ -n ${match[4]} ]] { + __idx+=${mbegin[2]} + + [[ $__quoting = \' ]] && _mybuf=${match[4]} || { _mybuf=${match[4]:1}; (( ++ __idx )); } + } else { + __idx+=${mbegin[2]} + [[ -z $__quoting && -z ${_FAST_COMPLEX_BRACKETS[(r)$((__idx-${#PREBUFFER}-1))]} ]] && { + if [[ ${match[2]} = ["({["] ]]; then + pos_to_level[$__idx]=$(( ++__level )) + level_to_pos[$__level]=$__idx + elif [[ ${match[2]} = ["]})"] ]]; then + if (( __level > 0 )); then + __pair_idx=${level_to_pos[$__level]} + pos_to_level[$__idx]=$(( __level -- )) + [[ ${pair_map[${input[__pair_idx]}]} = ${input[__idx]} ]] && { + final_pairs[$__idx]=$__pair_idx + final_pairs[$__pair_idx]=$__idx + } + else + pos_to_level[$__idx]=-1 + fi + fi + } + + if [[ ${match[2]} = \" && $__quoting != \' ]] { + [[ $__quoting = '"' ]] && __quoting="" || __quoting='"'; + } + if [[ ${match[2]} = \' && $__quoting != \" ]] { + if [[ $__quoting = ("'"|"$'") ]] { + __quoting="" + } else { + if [[ $match[1] = *\$ ]] { + __quoting="\$'"; + } else { + __quoting="'"; + } + } + } + _mybuf=${match[5]} + } + done + + for __idx in ${(k)pos_to_level}; do + (( ${+final_pairs[$__idx]} )) && __style=${FAST_THEME_NAME}bracket-level-$(( ( (pos_to_level[$__idx]-1) % 3 ) + 1 )) || __style=${FAST_THEME_NAME}unknown-token + (( __start=__idx-${#PREBUFFER}-1, __end=__idx-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + done + + # If cursor is on a bracket, then highlight corresponding bracket, if any. + if [[ $WIDGET != zle-line-finish ]]; then + __idx=$(( CURSOR + 1 )) + if (( ${+pos_to_level[$__idx]} )) && (( ${+final_pairs[$__idx]} )); then + (( __start=final_pairs[$__idx]-${#PREBUFFER}-1, __end=final_pairs[$__idx]-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}paired-bracket]}") && \ + reply+=("$CURSOR $__idx ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}paired-bracket]}") + fi + fi + return 0 +} diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh new file mode 100644 index 0000000..68a5a99 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh @@ -0,0 +1,384 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors +# Copyright (c) 2017-2019 Sebastian Gniazdowski (modifications) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + + +# Standarized way of handling finding plugin dir, +# regardless of functionargzero and posixargzero, +# and with an option for a plugin manager to alter +# the plugin directory (i.e. set ZERO parameter) +# http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" + +typeset -g FAST_HIGHLIGHT_VERSION=1.55 +typeset -g FAST_BASE_DIR="${0:h}" +typeset -ga _FAST_MAIN_CACHE +# Holds list of indices pointing at brackets that +# are complex, i.e. e.g. part of "[[" in [[ ... ]] +typeset -ga _FAST_COMPLEX_BRACKETS + +typeset -g FAST_WORK_DIR=${FAST_WORK_DIR:-${XDG_CACHE_HOME:-~/.cache}/fast-syntax-highlighting} +: ${FAST_WORK_DIR:=$FAST_BASE_DIR} +# Expand any tilde in the (supposed) path. +FAST_WORK_DIR=${~FAST_WORK_DIR} + +# Last (currently, possibly) loaded plugin isn't "fast-syntax-highlighting"? +# And FPATH isn't containing plugin dir? +if [[ ${zsh_loaded_plugins[-1]} != */fast-syntax-highlighting && -z ${fpath[(r)${0:h}]} ]] +then + fpath+=( "${0:h}" ) +fi + +if [[ ! -w $FAST_WORK_DIR ]]; then + FAST_WORK_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/fsh" + command mkdir -p "$FAST_WORK_DIR" +fi + +# Invokes each highlighter that needs updating. +# This function is supposed to be called whenever the ZLE state changes. +_zsh_highlight() +{ + # Store the previous command return code to restore it whatever happens. + local ret=$? + + # Remove all highlighting in isearch, so that only the underlining done by zsh itself remains. + # For details see FAQ entry 'Why does syntax highlighting not work while searching history?'. + if [[ $WIDGET == zle-isearch-update ]] && ! (( $+ISEARCHMATCH_ACTIVE )); then + region_highlight=() + return $ret + fi + + emulate -LR zsh + setopt extendedglob warncreateglobal typesetsilent noshortloops + + local REPLY # don't leak $REPLY into global scope + local -a reply + + # Do not highlight if there are more than 300 chars in the buffer. It's most + # likely a pasted command or a huge list of files in that case.. + [[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret + + # Do not highlight if there are pending inputs (copy/paste). + [[ $PENDING -gt 0 ]] && return $ret + + # Reset region highlight to build it from scratch + # may need to remove path_prefix highlighting when the line ends + if [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified; then + -fast-highlight-init + -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 + (( FAST_HIGHLIGHT[use_brackets] )) && { + _FAST_MAIN_CACHE=( $reply ) + -fast-highlight-string-process "$PREBUFFER" "$BUFFER" + } + region_highlight=( $reply ) + else + local char="${BUFFER[CURSOR+1]}" + if [[ "$char" = ["{([])}"] || "${FAST_HIGHLIGHT[prev_char]}" = ["{([])}"] ]]; then + FAST_HIGHLIGHT[prev_char]="$char" + (( FAST_HIGHLIGHT[use_brackets] )) && { + reply=( $_FAST_MAIN_CACHE ) + -fast-highlight-string-process "$PREBUFFER" "$BUFFER" + region_highlight=( $reply ) + } + fi + fi + + { + local cache_place + local -a region_highlight_copy + + # Re-apply zle_highlight settings + + # region + if (( REGION_ACTIVE == 1 )); then + _zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR" + elif (( REGION_ACTIVE == 2 )); then + () { + local needle=$'\n' + integer min max + if (( MARK > CURSOR )) ; then + min=$CURSOR max=$(( MARK + 1 )) + else + min=$MARK max=$CURSOR + fi + (( min = ${${BUFFER[1,$min]}[(I)$needle]} )) + (( max += ${${BUFFER:($max-1)}[(i)$needle]} - 1 )) + _zsh_highlight_apply_zle_highlight region standout "$min" "$max" + } + fi + + # yank / paste (zsh-5.1.1 and newer) + (( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END" + + # isearch + (( $+ISEARCHMATCH_ACTIVE )) && (( ISEARCHMATCH_ACTIVE )) && _zsh_highlight_apply_zle_highlight isearch underline "$ISEARCHMATCH_START" "$ISEARCHMATCH_END" + + # suffix + (( $+SUFFIX_ACTIVE )) && (( SUFFIX_ACTIVE )) && _zsh_highlight_apply_zle_highlight suffix bold "$SUFFIX_START" "$SUFFIX_END" + + return $ret + + } always { + typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER="$BUFFER" + typeset -g _ZSH_HIGHLIGHT_PRIOR_RACTIVE="$REGION_ACTIVE" + typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR + } +} + +# Apply highlighting based on entries in the zle_highlight array. +# This function takes four arguments: +# 1. The exact entry (no patterns) in the zle_highlight array: +# region, paste, isearch, or suffix +# 2. The default highlighting that should be applied if the entry is unset +# 3. and 4. Two integer values describing the beginning and end of the +# range. The order does not matter. +_zsh_highlight_apply_zle_highlight() { + local entry="$1" default="$2" + integer first="$3" second="$4" + + # read the relevant entry from zle_highlight + local region="${zle_highlight[(r)${entry}:*]}" + + if [[ -z "$region" ]]; then + # entry not specified at all, use default value + region=$default + else + # strip prefix + region="${region#${entry}:}" + + # no highlighting when set to the empty string or to 'none' + if [[ -z "$region" ]] || [[ "$region" == none ]]; then + return + fi + fi + + integer start end + if (( first < second )); then + start=$first end=$second + else + start=$second end=$first + fi + region_highlight+=("$start $end $region") +} + + +# ------------------------------------------------------------------------------------------------- +# API/utility functions for highlighters +# ------------------------------------------------------------------------------------------------- + +# Whether the command line buffer has been modified or not. +# +# Returns 0 if the buffer has changed since _zsh_highlight was last called. +_zsh_highlight_buffer_modified() +{ + [[ "${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-}" != "$BUFFER" ]] || [[ "$REGION_ACTIVE" != "$_ZSH_HIGHLIGHT_PRIOR_RACTIVE" ]] || { _zsh_highlight_cursor_moved && [[ "$REGION_ACTIVE" = 1 || "$REGION_ACTIVE" = 2 ]] } +} + +# Whether the cursor has moved or not. +# +# Returns 0 if the cursor has moved since _zsh_highlight was last called. +_zsh_highlight_cursor_moved() +{ + [[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR)) +} + +# ------------------------------------------------------------------------------------------------- +# Setup functions +# ------------------------------------------------------------------------------------------------- + +# Helper for _zsh_highlight_bind_widgets +# $1 is name of widget to call +_zsh_highlight_call_widget() +{ + integer ret + builtin zle "$@" + ret=$? + _zsh_highlight + return $ret +} + +# Rebind all ZLE widgets to make them invoke _zsh_highlights. +_zsh_highlight_bind_widgets() +{ + setopt localoptions noksharrays + local -F2 SECONDS + local prefix=orig-s${SECONDS/./}-r$(( RANDOM % 1000 )) # unique each time, in case we're sourced more than once + + # Load ZSH module zsh/zleparameter, needed to override user defined widgets. + zmodload zsh/zleparameter 2>/dev/null || { + print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' + return 1 + } + + # Override ZLE widgets to make them invoke _zsh_highlight. + local -U widgets_to_bind + widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank|zle-line-pre-redraw)}) + + # Always wrap special zle-line-finish widget. This is needed to decide if the + # current line ends and special highlighting logic needs to be applied. + # E.g. remove cursor imprint, don't highlight partial paths, ... + widgets_to_bind+=(zle-line-finish) + + # Always wrap special zle-isearch-update widget to be notified of updates in isearch. + # This is needed because we need to disable highlighting in that case. + widgets_to_bind+=(zle-isearch-update) + + local cur_widget + for cur_widget in $widgets_to_bind; do + case $widgets[$cur_widget] in + + # Already rebound event: do nothing. + user:_zsh_highlight_widget_*);; + + # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function + # definition time is used. + # + # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with + # NO_function_argzero, regardless of the option's setting here. + + # User defined widget: override and rebind old one with prefix "orig-". + user:*) zle -N -- $prefix-$cur_widget ${widgets[$cur_widget]#*:} + eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" + zle -N -- $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; + + # Completion widget: override and rebind old one with prefix "orig-". + completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} + eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" + zle -N -- $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; + + # Builtin widget: override and make it call the builtin ".widget". + builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" + zle -N -- $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; + + # Incomplete or nonexistent widget: Bind to z-sy-h directly. + *) + if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then + _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight } + zle -N -- $cur_widget _zsh_highlight_widget_$cur_widget + else + # Default: unhandled case. + print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}" + fi + esac + done +} + +# ------------------------------------------------------------------------------------------------- +# Setup +# ------------------------------------------------------------------------------------------------- + +# Try binding widgets. +_zsh_highlight_bind_widgets || { + print -r -- >&2 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' + return 1 +} + +# Reset scratch variables when commandline is done. +_zsh_highlight_preexec_hook() +{ + typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER= + typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=0 + typeset -ga _FAST_MAIN_CACHE + _FAST_MAIN_CACHE=() +} + +autoload -Uz add-zsh-hook +add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || { + print -r -- >&2 'zsh-syntax-highlighting: failed loading add-zsh-hook.' +} + +/fshdbg() { + print -r -- "$@" >>! /tmp/reply +} + +ZSH_HIGHLIGHT_MAXLENGTH=10000 + +# Load zsh/parameter module if available +zmodload zsh/parameter 2>/dev/null +zmodload zsh/system 2>/dev/null + +autoload -Uz -- is-at-least fast-theme .fast-read-ini-file .fast-run-git-command \ + .fast-make-targets .fast-run-command .fast-zts-read-all +autoload -Uz -- →chroma/-git.ch →chroma/-hub.ch →chroma/-lab.ch →chroma/-example.ch \ + →chroma/-grep.ch →chroma/-perl.ch →chroma/-make.ch →chroma/-awk.ch \ + →chroma/-vim.ch →chroma/-source.ch →chroma/-sh.ch →chroma/-docker.ch \ + →chroma/-autoload.ch →chroma/-ssh.ch →chroma/-scp.ch →chroma/-which.ch \ + →chroma/-printf.ch →chroma/-ruby.ch →chroma/-whatis.ch →chroma/-alias.ch \ + →chroma/-subcommand.ch →chroma/-autorandr.ch →chroma/-nmcli.ch \ + →chroma/-fast-theme.ch →chroma/-node.ch →chroma/-fpath_peq.ch \ + →chroma/-precommand.ch →chroma/-subversion.ch →chroma/-ionice.ch \ + →chroma/-nice.ch →chroma/main-chroma.ch →chroma/-ogit.ch →chroma/-zinit.ch + +source "${0:h}/fast-highlight" +source "${0:h}/fast-string-highlight" + +local __fsyh_theme +zstyle -s :plugin:fast-syntax-highlighting theme __fsyh_theme + +[[ ( "${+termcap}" != 1 || "${termcap[Co]}" != <-> || "${termcap[Co]}" -lt "256" ) && "$__fsyh_theme" = (default|) ]] && { + FAST_HIGHLIGHT_STYLES[defaultvariable]="none" + FAST_HIGHLIGHT_STYLES[defaultglobbing-ext]="fg=blue,bold" + FAST_HIGHLIGHT_STYLES[defaulthere-string-text]="bg=blue" + FAST_HIGHLIGHT_STYLES[defaulthere-string-var]="fg=cyan,bg=blue" + FAST_HIGHLIGHT_STYLES[defaultcorrect-subtle]="bg=blue" + FAST_HIGHLIGHT_STYLES[defaultsubtle-bg]="bg=blue" + [[ "${FAST_HIGHLIGHT_STYLES[variable]}" = "fg=113" ]] && FAST_HIGHLIGHT_STYLES[variable]="none" + [[ "${FAST_HIGHLIGHT_STYLES[globbing-ext]}" = "fg=13" ]] && FAST_HIGHLIGHT_STYLES[globbing-ext]="fg=blue,bold" + [[ "${FAST_HIGHLIGHT_STYLES[here-string-text]}" = "bg=18" ]] && FAST_HIGHLIGHT_STYLES[here-string-text]="bg=blue" + [[ "${FAST_HIGHLIGHT_STYLES[here-string-var]}" = "fg=cyan,bg=18" ]] && FAST_HIGHLIGHT_STYLES[here-string-var]="fg=cyan,bg=blue" + [[ "${FAST_HIGHLIGHT_STYLES[correct-subtle]}" = "fg=12" ]] && FAST_HIGHLIGHT_STYLES[correct-subtle]="bg=blue" + [[ "${FAST_HIGHLIGHT_STYLES[subtle-bg]}" = "bg=18" ]] && FAST_HIGHLIGHT_STYLES[subtle-bg]="bg=blue" +} + +unset __fsyh_theme + +alias fsh-alias=fast-theme + +-fast-highlight-fill-option-variables + +if [[ ! -e $FAST_WORK_DIR/secondary_theme.zsh ]] { + if { type curl &>/dev/null } { + curl -fsSL -o "$FAST_WORK_DIR/secondary_theme.zsh" \ + https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/share/free_theme.zsh \ + &>/dev/null + } elif { type wget &>/dev/null } { + wget -O "$FAST_WORK_DIR/secondary_theme.zsh" \ + https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/share/free_theme.zsh \ + &>/dev/null + } + touch "$FAST_WORK_DIR/secondary_theme.zsh" +} + +if [[ $(uname -a) = (#i)*darwin* ]] { + typeset -gA FAST_HIGHLIGHT + FAST_HIGHLIGHT[chroma-man]= +} + +[[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/fast-theme b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-theme new file mode 100644 index 0000000..06ad005 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/fast-theme @@ -0,0 +1,385 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# Copyright (c) 2018, 2019 Philippe Troin (F-i-f on GitHub) +# +# Theme support using ini-files. +# + +zmodload zsh/zutil 2>/dev/null + +emulate -LR zsh +setopt extendedglob typesetsilent warncreateglobal +autoload colors; colors + +typeset -g FAST_WORK_DIR +: ${FAST_WORK_DIR:=$FAST_BASE_DIR} +FAST_WORK_DIR=${~FAST_WORK_DIR} + +local -A map +map=( "XDG:" "${XDG_CONFIG_HOME:-$HOME/.config}/fsh/" + "LOCAL:" "/usr/local/share/fsh/" + "HOME:" "$HOME/.fsh/" + "OPT:" "/opt/local/share/fsh/" +) + +FAST_WORK_DIR=${${FAST_WORK_DIR/(#m)(#s)(XDG|LOCAL|HOME|OPT):(#c0,1)/${map[${MATCH%:}:]}}%/} + +local OPT_HELP OPT_VERBOSE OPT_QUIET OPT_RESET OPT_LIST OPT_TEST OPT_SECONDARY OPT_SHOW OPT_COPY OPT_OV_RESET +local OPT_PALETTE OPT_CDWD OPT_XCHG OPT_OV_XCHG +local -A opthash +zparseopts -E -D -A opthash h -help v -verbose q -quiet r -reset l -list t -test -secondary \ + s -show -copy-shipped-theme: R -ov-reset p -palette w -workdir \ + x -xchg y -ov-xchg || \ + { echo "Improper options given, see help (-h/--help)"; return 1; } + +(( ${+opthash[-h]} + ${+opthash[--help]} )) && OPT_HELP="-h" +(( ${+opthash[-v]} + ${+opthash[--verbose]} )) && OPT_VERBOSE="-v" +(( ${+opthash[-q]} + ${+opthash[--quiet]} )) && OPT_QUIET="-q" +(( ${+opthash[-r]} + ${+opthash[--reset]} )) && OPT_RESET="-r" +(( ${+opthash[-l]} + ${+opthash[--list]} )) && OPT_LIST="-l" +(( ${+opthash[-t]} + ${+opthash[--test]} )) && OPT_TEST="-t" +(( ${+opthash[--secondary]} )) && OPT_SECONDARY="--secondary" +(( ${+opthash[-s]} + ${+opthash[--show]} )) && OPT_SHOW="-s" +(( ${+opthash[--copy-shipped-theme]} )) && OPT_COPY="${opthash[--copy-shipped-theme]}" +(( ${+opthash[-R]} + ${+opthash[--ov-reset]} )) && OPT_OV_RESET="-R" +(( ${+opthash[-p]} + ${+opthash[--palette]} )) && OPT_PALETTE="-p" +(( ${+opthash[-w]} + ${+opthash[--workdir]} )) && OPT_CDWD="-w" +(( ${+opthash[-x]} + ${+opthash[--xchg]} )) && OPT_XCHG="-x" +(( ${+opthash[-y]} + ${+opthash[--ov-xchg]} )) && OPT_OV_XCHG="-y" + +local -a match mbegin mend +local MATCH; integer MBEGIN MEND + +[[ -n "$OPT_CDWD" ]] && { + builtin cd $FAST_WORK_DIR + return 0 +} + +[[ -n "$OPT_PALETTE" ]] && { + local n + local -a __colors + for n in {000..255} + do + __colors+=("%F{$n}$n%f") + done + print -cP $__colors + return +} + +[[ -n "$OPT_SHOW" ]] && { + print -r -- "Currently active theme: ${fg_bold[yellow]}$FAST_THEME_NAME$reset_color" + ( source "$FAST_WORK_DIR"/current_theme.zsh 2>/dev/null && print "Main theme (loaded at startup of a session): ${fg_bold[yellow]}$FAST_THEME_NAME$reset_color" || print "No main theme is set"; ) + return 0 +} + +[[ -n "$OPT_COPY" ]] && { + [[ ! -f "$FAST_BASE_DIR"/themes/"${OPT_COPY%.ini}.ini" ]] && { print "Theme \`$OPT_COPY' doesn't exist in FSH plugin dir ($FAST_BASE_DIR/themes)"; return 1; } + [[ ! -r "$FAST_BASE_DIR"/themes/"${OPT_COPY%.ini}.ini" ]] && { print "Theme \`$OPT_COPY' isn't readable in FSH plugin dir ($FAST_BASE_DIR/themes)"; return 1; } + [[ -n "$1" ]] && { + [[ ! -e "$1" && ! -e ${1:h} ]] && { print "Destination path doesn't exist, aborting"; return 1; } + } + command cp -vf "$FAST_BASE_DIR"/themes/"${OPT_COPY%.ini}.ini" "${${1:-.}%.ini}.ini" || return 1 + return 0 +} + +[[ -n "$OPT_RESET" ]] && { command rm -f "$FAST_WORK_DIR"/{current_theme.zsh,secondary_theme.zsh}; [[ -z "$OPT_QUIET" ]] && print "Reset done (no theme is now set, restart is required)"; return 0; } + +[[ -n "$OPT_OV_RESET" ]] && { command rm -f "$FAST_WORK_DIR"/theme_overlay.zsh; [[ -z "$OPT_QUIET" ]] && print "Overlay-reset done, it is inactive (restart is required)"; return 0; } + +[[ -n "$OPT_LIST" ]] && { + [[ -z "$OPT_QUIET" ]] && print -r -- "Available themes:" + print -rl -- "$FAST_BASE_DIR"/themes/*.ini(:t:r) + return 0 +} + +[[ -n "$OPT_HELP" ]] && { + print -r -- "Usage: fast-theme [-h/--help] [-v/--verbose] [-q/--quiet] [-t/--test] " + print -r -- " fast-theme [-r/--reset] [-l/--list] [-s/--show] [-p/--palette] [-w/--workdir]" + print -r -- " fast-theme --copy-shipped-theme {theme-name} [destination-path]" + print -r -- "" + print -r -- "Default action (after providing or ) is to switch" + print -r -- "current session and any future sessions to the new theme. Using ," + print -r -- "i.e.: a path to an ini file means using custom, own theme. The path can use an" + print -r -- "\"XDG:\" shorthand (e.g.: \"XDG:mytheme\") that will point to ~/.config/fsh/.ini" + print -r -- "(or \$XDG_CONFIG_HOME/fsh/.ini in general if the variable is set in the" + print -r -- "environment). If the INI file pointed in the path is \"*overlay*\", then it is" + print -r -- "not a full theme, but an additional theme-snippet that overwrites only selected" + print -r -- "styles of the main theme." + print -r -- "" + print -r -- "Other path-shorthands:" + print -r -- "LOCAL: = /usr/local/share/fsh/" + print -r -- "HOME: = $HOME/.fsh/" + print -r -- "OPT: = /opt/local/share/fsh/" + print -r -- "" + print -r -- "-r/--reset - unset any theme, use default highlighting (requires restart)" + print -r -- "-R/--ov-reset - unset overlay, use styles only from main-theme (requires restart)" + print -r -- "-l/--list - list names of available themes" + print -r -- "-t/--test - show test block of code after switching theme" + print -r -- "-s/--show - get and display the theme currently being set" + print -r -- "-p/--palette - just print all 256 colors and exit (useful when creating a theme)" + print -r -- "-w/--workdir - cd into \$FAST_WORK_DIR (if not set, then into the plugin directory)" + print -r -- "-v/--verbose - more messages during operation" + print -r -- "-q/--quiet - no default messages" + print -r -- "" + print -r -- "The option --copy-shipped-theme allows easy copying of one of the 6 shipped" + print -r -- "themes into given destination path. Normal use means changing directory to" + print -r -- "e.g.: ~/.config/fsh, and then issuing e.g.: \`fast-theme --copy-shipped-theme" + print -r -- "clean mytheme', to obtain a template for own new theme." + return 0 +} + +[[ -z "$1" ]] && { print -u2 "Provide a theme (its name or path to its file) to switch to, aborting (see -h/--help)"; return 1; } + +# FAST_HIGHLIGHT_STYLES key onto ini-file key +map=( + default "-" + unknown-token "-" + reserved-word "-" + subcommand "- reserved-word" + alias "- command builtin" + suffix-alias "- alias command builtin" + builtin "-" + function "- builtin command" + command "-" + precommand "- command" + commandseparator "-" + hashed-command "- command" + path "-" + path_pathseparator "pathseparator" + globbing "- back-or-dollar-double-quoted-argument" # fallback: variable in string "text $var text" + globbing-ext "- double-quoted-argument" # fallback: the string "abc..." + history-expansion "-" + single-hyphen-option "- single-quoted-argument" + double-hyphen-option "- double-quoted-argument" + back-quoted-argument "-" + single-quoted-argument "-" + double-quoted-argument "-" + dollar-quoted-argument "-" + back-or-dollar-double-quoted-argument "- back-dollar-quoted-argument" + back-dollar-quoted-argument "- back-or-dollar-double-quoted-argument" + assign "- reserved-word" + redirection "- reserved-word" + comment "-" + variable "-" + mathvar "- forvar variable" + mathnum "- fornum" + matherr "- incorrect-subtle" + assign-array-bracket "-" + for-loop-variable "forvar mathvar variable" + for-loop-number "fornum mathnum" + for-loop-operator "foroper reserved-word" + for-loop-separator "forsep commandseparator" + exec-descriptor "- reserved-word" + here-string-tri "-" + here-string-text "- subtle-bg" + here-string-var "- back-or-dollar-double-quoted-argument" + secondary "-" + recursive-base "- default" + case-input "- variable" + case-parentheses "- reserved-word" + case-condition "- correct-subtle" + correct-subtle "-" + incorrect-subtle "-" + subtle-separator "- commandseparator" + subtle-bg "- correct-subtle" + path-to-dir "- path" + paired-bracket "- subtle-bg correct-subtle" + bracket-level-1 "-" + bracket-level-2 "-" + bracket-level-3 "-" + global-alias "- alias suffix-alias" + single-sq-bracket "-" + double-sq-bracket "-" + double-paren "-" + optarg-string "- double-quoted-argument" + optarg-number "- mathnum" +) + +# In which order to generate entries +local -a order +order=( + default unknown-token reserved-word alias suffix-alias builtin function command precommand + commandseparator hashed-command path path_pathseparator globbing globbing-ext history-expansion + single-hyphen-option double-hyphen-option back-quoted-argument single-quoted-argument + double-quoted-argument dollar-quoted-argument back-or-dollar-double-quoted-argument + back-dollar-quoted-argument assign redirection comment variable mathvar + mathnum matherr assign-array-bracket for-loop-variable for-loop-number for-loop-operator + for-loop-separator exec-descriptor here-string-tri here-string-text here-string-var secondary + case-input case-parentheses case-condition correct-subtle incorrect-subtle subtle-separator subtle-bg + path-to-dir paired-bracket bracket-level-1 bracket-level-2 bracket-level-3 + global-alias subcommand single-sq-bracket double-sq-bracket double-paren + optarg-string optarg-number recursive-base +) + +[[ -n "$OPT_VERBOSE" ]] && print "Number of styles available for customization: ${#order}" + +# Named colors +local -a color +color=( red green blue yellow cyan magenta black white default ) + +# +# Execution starts here +# + +local -A out +local THEME_NAME THEME_PATH="$1" +if [[ "$1" = */* || "$1" = (XDG|LOCAL|HOME|OPT):* ]]; then + 1="${${1/(#s)XDG:/${${XDG_CONFIG_HOME:-$HOME/.config}%/}/fsh/}%.ini}.ini" + 1="${${1/(#s)LOCAL://usr/local/share/fsh/}%.ini}.ini" + 1="${${1/(#s)HOME:/$HOME/.fsh/}%.ini}.ini" + 1="${${1/(#s)OPT://opt/local/share/fsh/}%.ini}.ini" + 1=${~1} # allow user to quote ~ + + [[ ! -f "$1" ]] && { print -u2 "No such theme \`$1', aborting"; return 1; } + [[ ! -r "$1" ]] && { print -u2 "Theme \`$1' unreadable, aborting"; return 1; } + + THEME_NAME="${1:t:r}" + .fast-read-ini-file "$1" out "" +else + [[ ! -f "$FAST_BASE_DIR/themes/$1.ini" ]] && { print -u2 "No such theme \`$1', aborting"; return 1; } + [[ ! -r "$FAST_BASE_DIR/themes/$1.ini" ]] && { print -u2 "Theme \`$1' unreadable, aborting"; return 1; } + + THEME_NAME="$1" + .fast-read-ini-file "$FAST_BASE_DIR/themes/$1.ini" out "" +fi + +[[ -z "$OPT_SECONDARY" ]] && { [[ "$THEME_NAME" = *"overlay"* ]] && local outfile="theme_overlay.zsh" || local outfile="current_theme.zsh"; } || local outfile="secondary_theme.zsh" +[[ -z "$OPT_XCHG" && -z "$OPT_OV_XCHG" ]] && command rm -f "$FAST_WORK_DIR"/"$outfile" + +# Set a zstyle and a parameter to carry theme name +if [[ -z "$OPT_SECONDARY" && -z "$OPT_XCHG" && -z "$OPT_OV_XCHG" ]]; then + [[ "$THEME_NAME" != *"overlay"* ]] && { + print -r -- 'zstyle :plugin:fast-syntax-highlighting theme "'"$THEME_NAME"'"' >>! "$FAST_WORK_DIR"/"$outfile" + print -r -- 'typeset -g FAST_THEME_NAME="'"$THEME_NAME"'"' >>! "$FAST_WORK_DIR"/"$outfile" + zstyle :plugin:fast-syntax-highlighting theme "$THEME_NAME" + typeset -g FAST_THEME_NAME="$THEME_NAME" + } +elif [[ -z "$OPT_XCHG" && -z "$OPT_OV_XCHG" ]]; then + local FAST_THEME_NAME="$THEME_NAME" +fi + +# Store from which file the theme or overlay is being loaded +[[ "$THEME_NAME" != *"overlay" && -z "$OPT_OV_XCHG" ]] && FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}-path]="$THEME_PATH" || FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}-ov-path]="$THEME_PATH" + +# Generate current_theme.zsh or secondary_theme.zsh, traversing ini-file associative array +local k kk +local inikey inival result result2 first_val isbg +integer ov_counter=0 first +for k in "${order[@]}"; do + first=1 + for kk in ${(s. .)map[$k]} default; do + [[ "$kk" = "-" ]] && kk="$k" + (( first )) && first_val="$kk" + inikey="${out[(i)<*>_${kk}]}" + [[ -n "$inikey" ]] && { + (( !first )) && [[ -z "$OPT_QUIET" ]] && { + [[ $kk = default ]] && { + [[ "$THEME_NAME" != *"overlay"* ]] && print "Missing style: $first_val" + } || print "For style $first_val, went for fallback style $kk" + } + break + } + first=0 + [[ "$THEME_NAME" = *"overlay"* ]] && break + done + + # ORIG: Clear orig-style when loading a new theme, not overlay + [[ -z "$OPT_OV_XCHG" ]] && unset "FAST_HIGHLIGHT_STYLES[orig-style-$k]" + # ORIG: Restore orig-style when loading a new overlay + [[ -n "$OPT_OV_XCHG" && -n "${FAST_HIGHLIGHT_STYLES[orig-style-$k]}" ]] && { FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]="${FAST_HIGHLIGHT_STYLES[orig-style-$k]}"; unset "FAST_HIGHLIGHT_STYLES[orig-style-$k]"; } + # Set only the keys provided in theme + [[ -z "$inikey" ]] && { [[ -z "$OPT_QUIET" && "$THEME_NAME" != *"overlay"* ]] && print "Missing style $first_val"; continue; } + + inival="${out[$inikey]}" + if [[ "$k" = "secondary" && -z "$OPT_SECONDARY" && -n "$inival" ]]; then + fast-theme -q --secondary "$inival" + fi + + result="" + if [[ $k = secondary ]]; then + result="$inival" + else + for kk in ${(s:,:)inival} + do + if [[ $kk = (none|(no-|)(bold|blink|conceal|reverse|standout|underline)) ]]; then + result+="${result:+,}$kk" + else + isbg=0 + if [[ $kk = bg:* ]]; then + isbg=1 + kk=${kk#bg:} + fi + if [[ $kk = (${(~j:|:)color}) || $kk = [0-9]## || $kk = \#[0-9a-fA-F](#c6,6) ]]; then + result+="${result:+,}" + (( isbg )) && result+="bg=" || result+="fg=" + result+="$kk" + else + print "cannot parse style $k: unknown color or style element $kk" + fi + fi + done + fi + + if [[ "$THEME_NAME" = *"overlay"* || -n "$OPT_OV_XCHG" ]]; then + (( ++ ov_counter )) + [[ -z "$OPT_XCHG$OPT_OV_XCHG" ]] && print -r -- ': ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}'"$k"']::='"$result"'}' >>! "$FAST_WORK_DIR"/"$outfile" + # ORIG: Save original value of the overwritten style + FAST_HIGHLIGHT_STYLES[orig-style-$k]=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]} + # Overwrite theme's style + FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]="$result" + else + [[ -z "$OPT_XCHG$OPT_OV_XCHG" ]] && print -r -- ': ${FAST_HIGHLIGHT_STYLES['"${FAST_THEME_NAME}$k"']:='"$result"'}' >>! "$FAST_WORK_DIR"/"$outfile" + FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}$k]="$result" + fi +done + +# This can overwrite some of *_STYLES fields +# Re-apply overlay on top of the theme we switched to +[[ "$THEME_NAME" != *"overlay"* ]] && [[ -r "$FAST_WORK_DIR"/theme_overlay.zsh ]] && source "$FAST_WORK_DIR"/theme_overlay.zsh + +zcompile $FAST_WORK_DIR/$outfile 2>/dev/null + +[[ -z "$OPT_QUIET" ]] && { + if [[ "$THEME_NAME" != *"overlay"* ]]; then + print "Switched to theme \`$THEME_NAME' (current session, and future sessions)" || \ + else + print "Processed the overlay ($ov_counter keys found), it is now active (for current session, and future sessions)" + fi +} + +[[ -n "$OPT_TEST" ]] && { + print -zr ' +# Subshell, assignments, math-mode +echo $(cat /etc/hosts |& grep -i "hello337") +local param1="text ${+variable[test]} text ${var} text"; typeset param2='"'"'other $variable'"'"' +math=$(( 10 + HISTSIZ + HISTSIZE + $SAVEHIST )) size=$(( 0 )) + +# Programming-like usage, bracket matching - through distinct colors; note the backslash quoting +for (( ii = 1; ii <= size; ++ ii )); do + if [[ "${cmds[ii]} string" = "| string" ]] + then + sidx=${buffer[(in:ii:)\$\(?#[^\\\\]\)]} # find opening cmd-subst + (( sidx <= len + 100 )) && { + eidx=${buffer[(b:sidx:ii)[^\\\\]\)]} # find closing cmd-subst + } + fi +done + +# Regular command-line usage +repeat 0 { + zsh -i -c "cat /etc/shells* | grep -x --line-buffered -i '"'/bin/zsh'"'" + builtin exit $return_value + fast-theme -tq default + fsh-alias -tq default-X # alias '"'"'fsh-alias=fast-theme'"'"' works just like the previous line + command -v git | grep ".+git" && echo $'"'"'Git is installed'"'"' + git checkout -m --ours /etc/shells && git status-X + gem install asciidoctor + cat <<<$PATH | tr : \\n > /dev/null 2>/usr/local + man -a fopen fopen-X + CFLAGS="-g -Wall -O0" ./configure +} +' +} + +return 0 +# vim:ft=zsh:et:sw=4:sts=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/share/free_theme.zsh b/home/.zsh-server/plugins/fast-syntax-highlighting/share/free_theme.zsh new file mode 100644 index 0000000..0f32d66 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/share/free_theme.zsh @@ -0,0 +1,61 @@ +: ${FAST_HIGHLIGHT_STYLES[freedefault]:=none} +: ${FAST_HIGHLIGHT_STYLES[freeunknown-token]:=fg=red,bold} +: ${FAST_HIGHLIGHT_STYLES[freereserved-word]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freealias]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freesuffix-alias]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freebuiltin]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freefunction]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freecommand]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freeprecommand]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freecommandseparator]:=none} +: ${FAST_HIGHLIGHT_STYLES[freehashed-command]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freepath]:=fg=166} +: ${FAST_HIGHLIGHT_STYLES[freepath_pathseparator]:=} +: ${FAST_HIGHLIGHT_STYLES[freeglobbing]:=fg=112} +: ${FAST_HIGHLIGHT_STYLES[freeglobbing-ext]:=fg=118} +: ${FAST_HIGHLIGHT_STYLES[freehistory-expansion]:=fg=blue,bold} +: ${FAST_HIGHLIGHT_STYLES[freesingle-hyphen-option]:=fg=110} +: ${FAST_HIGHLIGHT_STYLES[freedouble-hyphen-option]:=fg=110} +: ${FAST_HIGHLIGHT_STYLES[freeback-quoted-argument]:=none} +: ${FAST_HIGHLIGHT_STYLES[freesingle-quoted-argument]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freedouble-quoted-argument]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freedollar-quoted-argument]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freeback-or-dollar-double-quoted-argument]:=fg=110} +: ${FAST_HIGHLIGHT_STYLES[freeback-dollar-quoted-argument]:=fg=110} +: ${FAST_HIGHLIGHT_STYLES[freeassign]:=none} +: ${FAST_HIGHLIGHT_STYLES[freeredirection]:=none} +: ${FAST_HIGHLIGHT_STYLES[freecomment]:=fg=black,bold} +: ${FAST_HIGHLIGHT_STYLES[freevariable]:=none} +: ${FAST_HIGHLIGHT_STYLES[freemathvar]:=fg=blue,bold} +: ${FAST_HIGHLIGHT_STYLES[freemathnum]:=fg=166} +: ${FAST_HIGHLIGHT_STYLES[freematherr]:=fg=red} +: ${FAST_HIGHLIGHT_STYLES[freeassign-array-bracket]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freefor-loop-variable]:=none} +: ${FAST_HIGHLIGHT_STYLES[freefor-loop-number]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freefor-loop-operator]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freefor-loop-separator]:=fg=109} +: ${FAST_HIGHLIGHT_STYLES[freeexec-descriptor]:=fg=yellow,bold} +: ${FAST_HIGHLIGHT_STYLES[freehere-string-tri]:=fg=yellow} +: ${FAST_HIGHLIGHT_STYLES[freehere-string-text]:=bg=19} +: ${FAST_HIGHLIGHT_STYLES[freehere-string-var]:=fg=110,bg=19} +: ${FAST_HIGHLIGHT_STYLES[freesecondary]:=zdharma} +: ${FAST_HIGHLIGHT_STYLES[freecase-input]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freecase-parentheses]:=fg=116} +: ${FAST_HIGHLIGHT_STYLES[freecase-condition]:=bg=19} +: ${FAST_HIGHLIGHT_STYLES[freecorrect-subtle]:=bg=55} +: ${FAST_HIGHLIGHT_STYLES[freeincorrect-subtle]:=bg=52} +: ${FAST_HIGHLIGHT_STYLES[freesubtle-separator]:=none} +: ${FAST_HIGHLIGHT_STYLES[freesubtle-bg]:=bg=18} +: ${FAST_HIGHLIGHT_STYLES[freepath-to-dir]:=fg=166,underline} +: ${FAST_HIGHLIGHT_STYLES[freepaired-bracket]:=bg=blue} +: ${FAST_HIGHLIGHT_STYLES[freebracket-level-1]:=fg=130} +: ${FAST_HIGHLIGHT_STYLES[freebracket-level-2]:=fg=70} +: ${FAST_HIGHLIGHT_STYLES[freebracket-level-3]:=fg=69} +: ${FAST_HIGHLIGHT_STYLES[freeglobal-alias]:=bg=19} +: ${FAST_HIGHLIGHT_STYLES[freesubcommand]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freesingle-sq-bracket]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freedouble-sq-bracket]:=fg=180} +: ${FAST_HIGHLIGHT_STYLES[freedouble-paren]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freeoptarg-string]:=fg=150} +: ${FAST_HIGHLIGHT_STYLES[freeoptarg-number]:=fg=166} +: ${FAST_HIGHLIGHT_STYLES[freerecursive-base]:=fg=183} diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/clean.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/clean.ini new file mode 100644 index 0000000..f89b536 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/clean.ini @@ -0,0 +1,81 @@ +[base] +default = none +unknown-token = 124,bold +commandseparator = none +redirection = none +here-string-tri = yellow +here-string-text = bg:19 +here-string-var = 185,bg:19 +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:17 +secondary = zdharma +recursive-base = 183 + +[command-point] +reserved-word = 146 +subcommand = 146 +alias = 109 +suffix-alias = 109 +global-alias = bg:19 +builtin = 109 +function = 109 +command = 109 +precommand = 109 +hashed-command = 109 +single-sq-bracket = 109 +double-sq-bracket = 109 +double-paren = 146 + +[paths] +path = 208 +pathseparator = +path-to-dir = 208,underline +globbing = 220 +globbing-ext = 225 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 115 +bracket-level-2 = 177 +bracket-level-3 = 220 + +[arguments] +single-hyphen-option = 185 +double-hyphen-option = 185 +back-quoted-argument = none +single-quoted-argument = 147 +double-quoted-argument = 147 +dollar-quoted-argument = 147 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 185 +; backslash or $... in "..." (i.e. variable in string) +back-or-dollar-double-quoted-argument = 185 + +[other] +variable = none +assign = none +assign-array-bracket = 109 +history-expansion = blue,bold + +[math] +mathvar = blue,bold +mathnum = 208 +matherr = 124 + +[for-loop] +forvar = none +fornum = 208 +; operator +foroper = 147 +; separator +forsep = 109 + +[case] +case-input = 109 +case-parentheses = 116 +case-condition = bg:19 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/default.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/default.ini new file mode 100644 index 0000000..c0840fb --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/default.ini @@ -0,0 +1,84 @@ +; default theme, also embedded in the source of fast-syntax-highlighting + +[base] +default = none +unknown-token = red,bold +commandseparator = none +redirection = none +here-string-tri = yellow +here-string-text = 18 +here-string-var = cyan,bg:18 +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = 12 +incorrect-subtle = red +subtle-separator = green +subtle-bg = bg:18 +secondary = free +; recursive-base = + +[command-point] +reserved-word = yellow +subcommand = yellow +alias = green +suffix-alias = green +global-alias = bg:blue +builtin = green +function = green +command = green +precommand = green +hashed-command = green +single-sq-bracket = green +double-sq-bracket = green +double-paren = yellow + +[paths] +path = magenta +pathseparator = +path-to-dir = magenta,underline +globbing = blue,bold +globbing-ext = 13 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = green,bold +bracket-level-2 = yellow,bold +bracket-level-3 = cyan,bold + +[arguments] +single-hyphen-option = cyan +double-hyphen-option = cyan +back-quoted-argument = none +single-quoted-argument = yellow +double-quoted-argument = yellow +dollar-quoted-argument = yellow + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = cyan +; backslash or $... in "..." +back-or-dollar-double-quoted-argument = cyan + +[other] +variable = 113 +assign = none +assign-array-bracket = green +history-expansion = blue,bold + +[math] +mathvar = blue,bold +mathnum = magenta +matherr = red + +[for-loop] +forvar = none +fornum = magenta +; operator +foroper = yellow +; separator +forsep = yellow,bold + +[case] +case-input = green +case-parentheses = yellow +case-condition = bg:blue diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/forest.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/forest.ini new file mode 100644 index 0000000..d4b145e --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/forest.ini @@ -0,0 +1,81 @@ +[base] +default = none +unknown-token = 124,bold +commandseparator = none +redirection = none +here-string-tri = yellow +here-string-text = underline +here-string-var = 65,underline +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:18 +secondary = zdharma +recursive-base = 183 + +[command-point] +reserved-word = 186 +subcommand = 186 +alias = 101 +suffix-alias = 101 +global-alias = bg:55 +builtin = 101 +function = 101 +command = 101 +precommand = 101 +hashed-command = 101 +single-sq-bracket = 101 +double-sq-bracket = 101 +double-paren = 186 + +[paths] +path = 107 +pathseparator = +path-to-dir = 107,underline +globbing = 114 +globbing-ext = 118 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = green,bold +bracket-level-2 = yellow,bold +bracket-level-3 = cyan,bold + +[arguments] +single-hyphen-option = 65 +double-hyphen-option = 65 +back-quoted-argument = none +single-quoted-argument = 186 +double-quoted-argument = 186 +dollar-quoted-argument = 186 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 65 +; backslash or $... in "..." +back-or-dollar-double-quoted-argument = 65 + +[other] +variable = none +assign = none +assign-array-bracket = 101 +history-expansion = 114 + +[math] +mathvar = 114 +mathnum = 107 +matherr = 124 + +[for-loop] +forvar = none +fornum = 107 +; operator +foroper = 186 +; separator +forsep = 109 + +[case] +case-input = 101 +case-parentheses = 65 +case-condition = underline diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/free.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/free.ini new file mode 100644 index 0000000..108f7da --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/free.ini @@ -0,0 +1,81 @@ +[base] +default = none +unknown-token = red,bold +commandseparator = none +redirection = none +here-string-tri = yellow +here-string-text = bg:19 +here-string-var = 110,bg:19 +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:18 +secondary = zdharma +recursive-base = 183 + +[command-point] +reserved-word = 150 +subcommand = 150 +alias = 180 +suffix-alias = 180 +global-alias = bg:19 +builtin = 180 +function = 180 +command = 180 +precommand = 180 +hashed-command = 180 +single-sq-bracket = 180 +double-sq-bracket = 180 +double-paren = 150 + +[paths] +path = 166 +pathseparator = +path-to-dir = 166,underline +globbing = 112 +globbing-ext = 118 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 130 +bracket-level-2 = 70 +bracket-level-3 = 69 + +[arguments] +single-hyphen-option = 110 +double-hyphen-option = 110 +back-quoted-argument = none +single-quoted-argument = 150 +double-quoted-argument = 150 +dollar-quoted-argument = 150 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 110 +; backslash or $... in "..." (i.e. variable inside a string) +back-or-dollar-double-quoted-argument = 110 + +[other] +variable = none +assign = none +assign-array-bracket = 180 +history-expansion = blue,bold + +[math] +mathvar = blue,bold +mathnum = 166 +matherr = red + +[for-loop] +forvar = none +fornum = 150 +; operator +foroper = 150 +; separator +forsep = 109 + +[case] +case-input = 180 +case-parentheses = 116 +case-condition = bg:19 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/q-jmnemonic.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/q-jmnemonic.ini new file mode 100644 index 0000000..cfefd7a --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/q-jmnemonic.ini @@ -0,0 +1,163 @@ +; X-JMnemonic theme for Fast-Syntax-Highlighting: +; https://github.com/zdharma/fast-syntax-highlighting +; Version: 1.1 +; +; Copyright (c) 2018 Sebastian Gniazdowski +; +; Based on: https://www.syntaxenvy.com/0753499 +; +; When I first saw the above theme upon syntaxenvy.com generated it randomly, +; I've had a quick, bold association with the Johnny Mnemonic movie. I don't +; know why, but I've decided to name the theme like this and who knows, maybe +; someone will decipher the connection one day. The theme looks suprisingly +; well IMO and maybe it's the effect of having this movie property/connection. +; +; This theme is a descent of the 40 work hours (or more) non-public theme X-Paragon, +; which was created to say `thanks' to the patrons at Patreon.com/psprint. It should +; carry the same quality. +; +; The palette - naive and CIE L*a*b conversion: +; +; main: +; #5e6466 -> 59 -> CIELab: 241 +; comment: +; #434749 -> 16 -> CIELab: 238 +; keyword: +; #b77c4b -> 137 -> CIELab: 173 +; number, string: +; #5794a2 -> 67 -> CIELab: 66 +; title, section, name, selector-id: +; #778ce0 -> 104 -> CIELab: 104 +; attribute, variable, type: +; #d55383 -> 168 -> CIELab: 168 +; symbol, link: +; #e66493 -> 168 -> CIELab: 168 +; builtin, deletion: +; #bd5ac0 -> 133 -> CIELab: 170 +; formula-bg: +; #363a3b -> 16 -> CIELab: 237 +; +; Token.Literal: "#dc5be0" -> CIELab: 170 (Orchid; naive: 170) +; Token.Operator: "#677dcf" -> CIELab: 68 (SteelBlue3; naive: 68) +; + +[base] +default = none +unknown-token = 196 +secondary = sv-orple +recursive-base = 183 + +[background] +correct-subtle = bg:18 +incorrect-subtle = bg:238 +subtle-bg = bg:17 +global-alias = bg:20 + +;; +;; COLOR-GROUPS +;; + +[gray] +comment = 243 + + + +[pastel] +here-string-tri = 217 + + + +[no-color] +assign = none +back-quoted-argument = none +redirection = none +variable = none + + + + +[magenta-3] +dollar-quoted-argument = 173 +double-quoted-argument = 173 +history-expansion = 173 +globbing-ext = 173 +precommand = 173 + +[light-salmon-3] +builtin = 137 +subcommand = 137 +single-quoted-argument = 137 + +[steel-blue-3] +command = 68 +double-sq-bracket = 68 +double-paren = 68 +single-sq-bracket = 68 + +[steel-blue] +reserved-word = 67 + + + +[medium-purple] +; backslash in $'...' +back-dollar-quoted-argument = 104 +commandseparator = 104 +single-hyphen-option = 104 + +[dark-khaki] +double-hyphen-option = 143 + + + +[hot-pink-3] +alias = 168 +exec-descriptor = 168 +function = 168 +hashed-command = 168 +here-string-var = 168 +suffix-alias = 168 + +[pale-green-3] +assign-array-bracket = 114 +; variable $... or backslash in "..." (i.e. variable in string) +back-or-dollar-double-quoted-argument = 114 +globbing = 114 +here-string-text = 114 + + + +[orchid] +path = 170 +path-to-dir = 170,underline +pathseparator = + + + +;; +;; FUNCTIONALITY-GROUPS +;; + +[brackets] +paired-bracket = black,bg:216 +bracket-level-1 = 117 +bracket-level-2 = 217 +bracket-level-3 = 220 + +[math] +mathvar = 68 +mathnum = 173 +matherr = 124 + +[for-loop] +forvar = 68 +fornum = 173 +; operator +foroper = 133 +; separator +forsep = 104 + +[case] +case-input = 168 +case-parentheses = 217 +case-condition = bg:25 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/safari.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/safari.ini new file mode 100644 index 0000000..e103c4d --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/safari.ini @@ -0,0 +1,83 @@ +; Light theme with colors of a Sahara oasis + +[base] +default = none +unknown-token = red,bold +commandseparator = none +redirection = none +here-string-tri = yellow +here-string-text = bg:19 +here-string-var = 153,bg:19 +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:18 +secondary = zdharma +recursive-base = 183 + +[command-point] +reserved-word = 150 +subcommand = 150 +alias = 185 +suffix-alias = 185 +global-alias = bg:19 +builtin = 185 +function = 185 +command = 185 +precommand = 185 +hashed-command = 185 +single-sq-bracket = 185 +double-sq-bracket = 185 +double-paren = 150 + +[paths] +path = 187 +pathseparator = +path-to-dir = 187,underline +globbing = 180 +globbing-ext = 184 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 178 +bracket-level-2 = 148 +bracket-level-3 = 141 + +[arguments] +single-hyphen-option = 152 +double-hyphen-option = 152 +back-quoted-argument = none +single-quoted-argument = 151 +double-quoted-argument = 151 +dollar-quoted-argument = 151 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 153 +; backslash or $... in "..." (i.e. variable inside a string) +back-or-dollar-double-quoted-argument = 153 + +[other] +variable = none +assign = none +assign-array-bracket = 185 +history-expansion = blue,bold + +[math] +mathvar = blue,bold +mathnum = 187 +matherr = red + +[for-loop] +forvar = none +fornum = 187 +; operator +foroper = 151 +; separator +forsep = 109 + +[case] +case-input = 185 +case-parentheses = 116 +case-condition = bg:19 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/spa.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/spa.ini new file mode 100644 index 0000000..651acdb --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/spa.ini @@ -0,0 +1,82 @@ +; 144, 187, 110, 203 +[base] +default = none +unknown-token = 196 +commandseparator = 150 +redirection = none +here-string-tri = yellow +here-string-text = bg:19 +here-string-var = 186,bg:19 +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:17 +secondary = zdharma +recursive-base = 183 + +[command-point] +reserved-word = 144 +subcommand = 144 +alias = 187 +suffix-alias = 187 +global-alias = bg:19 +builtin = 150 +function = 187 +command = 187 +precommand = 187 +hashed-command = 187 +single-sq-bracket = 150 +double-sq-bracket = 150 +double-paren = 144 + +[paths] +path = 110 +pathseparator = +path-to-dir = 110,underline +globbing = 220 +globbing-ext = 225 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 115 +bracket-level-2 = 177 +bracket-level-3 = 220 + +[arguments] +single-hyphen-option = 185 +double-hyphen-option = 185 +back-quoted-argument = none +single-quoted-argument = 110 +double-quoted-argument = 110 +dollar-quoted-argument = 110 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 186 +; backslash or $... in "..." (i.e. variable in string) +back-or-dollar-double-quoted-argument = 186 + +[other] +variable = none +assign = none +assign-array-bracket = 187 +history-expansion = blue,bold + +[math] +mathvar = 150 +mathnum = 110 +matherr = 196 + +[for-loop] +forvar = 71 +fornum = 110 +; operator +foroper = 203 +; separator +forsep = 147 + +[case] +case-input = 187 +case-parentheses = 116 +case-condition = bg:19 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-orple.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-orple.ini new file mode 100644 index 0000000..f7e8fc5 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-orple.ini @@ -0,0 +1,100 @@ +; https://www.syntaxenvy.com/0073437 +; +; comment: +; #363355 -> 61 +; keyword: +; #dda69f -> 181 (138) +; number, string: +; #ca887e -> 174 (173) +; title, section, name, selector-id: +; #b3afd9 -> 146 (146) +; attribute, variable, type: +; #be85c0 -> 139 (140) +; symbol, link: +; #d6a2d8 -> 182 (182) +; builtin, deletion: +; #969c77 -> 108 (108) +; formula-bg: +; #211f37 -> 16 (17) + +[base] +default = none +unknown-token = 124 +commandseparator = 146 +redirection = none +here-string-tri = 138 +here-string-text = bg:25 +here-string-var = 140,bg:25 +exec-descriptor = 140 +comment = 61 +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:17 +secondary = clean +recursive-base = 186 + +[command-point] +reserved-word = 138 +subcommand = 182 +alias = 140 +suffix-alias = 140 +global-alias = bg:17 +builtin = 173 +function = 140 +command = 108 +precommand = 138 +hashed-command = 140 +single-sq-bracket = 173 +double-sq-bracket = 173 +double-paren = 138 + +[paths] +path = 182 +pathseparator = +path-to-dir = 182,underline +globbing = 138 +globbing-ext = 141 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 173 +bracket-level-2 = 177 +bracket-level-3 = 220 + +[arguments] +single-hyphen-option = 140 +double-hyphen-option = 140 +back-quoted-argument = none +single-quoted-argument = 173 +double-quoted-argument = 173 +dollar-quoted-argument = 173 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 146 +; backslash or $... in "..." (i.e. variable in string) +back-or-dollar-double-quoted-argument = 140 + +[other] +variable = none +assign = none +assign-array-bracket = 182 +history-expansion = blue,bold + +[math] +mathvar = 140 +mathnum = 173 +matherr = 124 + +[for-loop] +forvar = 140 +fornum = 173 +; operator +foroper = 147 +; separator +forsep = 182 + +[case] +case-input = 140 +case-parentheses = 17 +case-condition = bg:25 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-plant.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-plant.ini new file mode 100644 index 0000000..2191b21 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/sv-plant.ini @@ -0,0 +1,100 @@ +; https://www.syntaxenvy.com/0854668 +; +; comment: +; #5b4e3f -> 58 +; keyword: +; #a1f2b2 -> 157 +; number, string: +; #91cf9e -> 115 (114) +; title, section, name, selector-id: +; #dadff0 -> 189 +; attribute, variable, type: +; #debb91 -> 180 +; symbol, link: +; #f1dcc6 -> 224 +; builtin, deletion: +; #95cbc1 -> 115 +; formula: +; #3f352a -> 16 + +[base] +default = none +unknown-token = 124 +commandseparator = 189 +redirection = none +here-string-tri = 157 +here-string-text = bg:25 +here-string-var = 180,bg:25 +exec-descriptor = 180 +comment = 58 +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:17 +secondary = zdharma +recursive-base = 183 + +[command-point] +reserved-word = 157 +subcommand = 224 +alias = 180 +suffix-alias = 180 +global-alias = bg:58 +builtin = 115 +function = 180 +command = 180 +precommand = 157 +hashed-command = 180 +single-sq-bracket = 115 +double-sq-bracket = 115 +double-paren = 157 + +[paths] +path = 224 +pathseparator = +path-to-dir = 224,underline +globbing = 157 +globbing-ext = 159 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 115 +bracket-level-2 = 177 +bracket-level-3 = 220 + +[arguments] +single-hyphen-option = 180 +double-hyphen-option = 180 +back-quoted-argument = none +single-quoted-argument = 114 +double-quoted-argument = 114 +dollar-quoted-argument = 114 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 189 +; backslash or $... in "..." (i.e. variable in string) +back-or-dollar-double-quoted-argument = 180 + +[other] +variable = none +assign = none +assign-array-bracket = 224 +history-expansion = blue,bold + +[math] +mathvar = 180 +mathnum = 114 +matherr = 124 + +[for-loop] +forvar = 180 +fornum = 114 +; operator +foroper = 147 +; separator +forsep = 224 + +[case] +case-input = 180 +case-parentheses = 58 +case-condition = bg:25 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/themes/zdharma.ini b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/zdharma.ini new file mode 100644 index 0000000..95e3e7e --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/themes/zdharma.ini @@ -0,0 +1,81 @@ +[base] +default = none +unknown-token = red,bold +commandseparator = none +redirection = none +here-string-tri = 141 +here-string-text = bg:19 +here-string-var = 177,bg:19 +exec-descriptor = yellow,bold +comment = black,bold +correct-subtle = bg:55 +incorrect-subtle = bg:52 +subtle-bg = bg:17 +secondary = safari +recursive-base = 186 + +[command-point] +reserved-word = 146 +reserved-word = 146 +alias = 63 +suffix-alias = 63 +global-alias = bg:19 +builtin = 63 +function = 63 +command = 63 +precommand = 63 +hashed-command = 63 +single-sq-bracket = 63 +double-sq-bracket = 63 +double-paren = 146 + +[paths] +path = 154 +pathseparator = +path-to-dir = 154,underline +globbing = 114 +globbing-ext = 153 + +[brackets] +paired-bracket = bg:blue +bracket-level-1 = 117 +bracket-level-2 = 141 +bracket-level-3 = 90 + +[arguments] +single-hyphen-option = 177 +double-hyphen-option = 177 +back-quoted-argument = none +single-quoted-argument = 146 +double-quoted-argument = 146 +dollar-quoted-argument = 146 + +[in-string] +; backslash in $'...' +back-dollar-quoted-argument = 177 +; backslash or $... in "..." +back-or-dollar-double-quoted-argument = 177 + +[other] +variable = none +assign = none +assign-array-bracket = 63 +history-expansion = blue,bold + +[math] +mathvar = blue,bold +mathnum = 154 +matherr = red + +[for-loop] +forvar = none +fornum = 154 +; operator +foroper = 146 +; separator +forsep = 109 + +[case] +case-input = 63 +case-parentheses = 141 +case-condition = bg:19 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-alias.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-alias.ch new file mode 100644 index 0000000..d581341 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-alias.ch @@ -0,0 +1,29 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +local __first_call="$1" __wrd="${2%%=*}" __start_pos="$3" __end_pos="$4" + +if (( __first_call )) || [[ "$2" = -* ]]; then + return 1 +else + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + elif (( $+aliases[(e)$__wrd] )) || (( ${+galiases[(e)$__wrd]} )); then + (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + elif (( $+functions[(e)$__wrd] )) || (( $+builtins[(e)$__wrd] )) || (( $+commands[(e)$__wrd] )) || (( $reswords[(Ie)$__wrd] )); then + (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + else + return 1 + fi + if [[ "$__wrd" != "$2" ]]; then + return 1 + fi +fi + +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autoload.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autoload.ch new file mode 100644 index 0000000..78a8924 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autoload.ch @@ -0,0 +1,104 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Tracks autoload command - highlights function names if they exist somewhere +# in $fpath. Also warns that the autoloaded function is already defined. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __chars +integer __idx1 __idx2 +local -a __results __deserialized __noshsplit + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-autoload-counter]=0 + FAST_HIGHLIGHT[chroma-autoload-counter-all]=1 + FAST_HIGHLIGHT[chroma-autoload-message]="" + #FAST_HIGHLIGHT[chroma-autoload-message-shown]="" + [[ -z ${FAST_HIGHLIGHT[chroma-autoload-message-shown-at]} ]] && FAST_HIGHLIGHT[chroma-autoload-message-shown-at]=0 + FAST_HIGHLIGHT[chroma-autoload-elements]="" + __style=${FAST_THEME_NAME}command + +} || { + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + (( FAST_HIGHLIGHT[chroma-autoload-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-autoload-counter-all] )) + + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if [[ "$__wrd" = [-+]* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + else + # Count non-option tokens. + (( FAST_HIGHLIGHT[chroma-autoload-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-autoload-counter] )) + + if [[ $__wrd != (\$|\"\$)* && $__wrd != (/|\"/|\'/)* && $__wrd != \`* ]]; then + __results=( ${^fpath}/$__wrd(N) ) + __deserialized=( "${(Q@)${(z@)FAST_HIGHLIGHT[chroma-fpath_peq-elements]}}" ) + __results+=( ${^__deserialized}/$__wrd(N) ) + [[ "${#__results}" -gt 0 ]] && { + __style=${FAST_THEME_NAME}correct-subtle + __deserialized=( "${(Q@)${(z@)FAST_HIGHLIGHT[chroma-autoload-elements]}}" ) + [[ -z "${__deserialized[1]}" && ${#__deserialized} -eq 1 ]] && __deserialized=() + # Cannot use ${abc:+"$abc"} trick with ${~...}, so handle most + # cases of the possible shwordsplit through an additional array + __noshsplit=( ${~__wrd} ) + __deserialized+=( "${(j: :)__noshsplit}" ) + FAST_HIGHLIGHT[chroma-autoload-elements]="${(j: :)${(q@)__deserialized}}" + # Make the function defined for big-loop's *main-type mechanism + __fast_highlight_main__command_type_cache[${(j: :)__noshsplit}]="function" + } || __style=${FAST_THEME_NAME}incorrect-subtle + fi + + if (( ${+functions[${(Q)__wrd}]} )); then + FAST_HIGHLIGHT[chroma-autoload-message]+="Warning: Function ${(Q)__wrd} already defined (e.g. loaded)"$'\n' + fi + fi + + # Display only when processing last autoload argument + if (( ${#${(z)BUFFER}} == FAST_HIGHLIGHT[chroma-autoload-counter-all] )); then + # Display only if already shown message differs or when it timeouts + if [[ ${FAST_HIGHLIGHT[chroma-autoload-message]} != ${FAST_HIGHLIGHT[chroma-autoload-message-shown]} || + $(( EPOCHSECONDS - FAST_HIGHLIGHT[chroma-autoload-message-shown-at] )) -gt 7 + ]]; then + FAST_HIGHLIGHT[chroma-autoload-message-shown]=${FAST_HIGHLIGHT[chroma-autoload-message]} + FAST_HIGHLIGHT[chroma-autoload-message-shown-at]=$EPOCHSECONDS + zle -M "${FAST_HIGHLIGHT[chroma-autoload-message]}" + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above code +# can do it itself and skip setting __style to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autorandr.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autorandr.ch new file mode 100644 index 0000000..9687db3 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-autorandr.ch @@ -0,0 +1,22 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" + +if (( __first_call )) || [[ "$__wrd" = -* ]]; then + return 1 +else + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + if [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/autorandr/$__wrd" ]] then + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + fi +fi + +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-awk.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-awk.ch new file mode 100644 index 0000000..47b3ec7 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-awk.ch @@ -0,0 +1,108 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __chars __val __style2 +integer __idx1 __idx2 + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-awk-counter]=0 + FAST_HIGHLIGHT[chroma-awk-f-seen]=0 + return 1 +} || { + # Following call, i.e. not the first one. + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + [[ "$__wrd" = "-f" ]] && FAST_HIGHLIGHT[chroma-awk-f-seen]=1 + else + # Count non-option tokens. + (( FAST_HIGHLIGHT[chroma-awk-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-awk-counter] )) + + # First non-option token is the pattern (regex), we will + # highlight it. + if (( FAST_HIGHLIGHT[chroma-awk-counter] == 1 && FAST_HIGHLIGHT[chroma-awk-f-seen] == 0 )); then + if print -r -- "${(Q)__wrd}" | gawk --source 'BEGIN { exit } END { exit 0 }' -f - >/dev/null 2>&1; then + __style2="${FAST_THEME_NAME}subtle-bg" + else + __style2="${FAST_THEME_NAME}incorrect-subtle" + fi + + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style2]}") + + # Highlight keywords + FSH_LIST=() + : "${__wrd//(#m)(BEGIN|END|FIELDWIDTHS|RS|ARGC|ARGV|ENVIRON|NF|NR|IGNORECASE|FILENAME|if|then|else|while|toupper|tolower|function|print|sub)/$(( fsh_sy_h_append($MBEGIN, $MEND) ))}"; + for __val in "${FSH_LIST[@]}" ; do + [[ ${__wrd[${__val%%;;*}]} = [a-zA-Z0-9_] || ${__wrd[${__val##*;;}+1]} = [a-zA-Z0-9_] ]] && continue + __idx1=$(( __start_pos + ${__val%%;;*} )) + __idx2=__idx1+${__val##*;;}-${__val%%;;*}+1 + (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}reserved-word]},${FAST_HIGHLIGHT_STYLES[$__style2]}") + done + + # Highlight regex characters + __chars="*+\\)(\{\}[]^" + __idx1=__start_pos + __idx2=__start_pos + while [[ "$__wrd" = (#b)[^$__chars]#([\\][\\])#((+|\*|\[|\]|\)|\(|\^|\}|\{)|[\\](+|\*|\[|\]|\)|\(|\^|\{|\}))(*) ]]; do + if [[ -n "${match[3]}" ]]; then + __idx1+=${mbegin[3]}-1 + __idx2=__idx1+${mend[3]}-${mbegin[3]}+1 + (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]},${FAST_HIGHLIGHT_STYLES[$__style2]}") + __idx1=__idx2 + else + __idx1+=${mbegin[5]}-1 + fi + __wrd="${match[5]}" + done + elif (( FAST_HIGHLIGHT[chroma-awk-counter] >= 2 || FAST_HIGHLIGHT[chroma-awk-f-seen] == 1 )); then + FAST_HIGHLIGHT[chroma-awk-f-seen]=0 + # Handle paths, etc. normally - just pass-through to the big + # highlighter (the main FSH highlighter, used before chromas). + return 1 + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does) and skip setting __style +# to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-docker.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-docker.ch new file mode 100644 index 0000000..31772f2 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-docker.ch @@ -0,0 +1,90 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma function for command `docker'. It verifies command line, by denoting +# wrong and good arguments by color. Currently implemented: verification of +# image IDs passed to: docker image rm . +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 +local -a __lines_list + +(( __first_call )) && { + # Called for the first time - new command + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global variables + FAST_HIGHLIGHT[chroma-docker-counter]=0 + FAST_HIGHLIGHT[chroma-docker-got-subcommand]=0 + FAST_HIGHLIGHT[chroma-docker-subcommand]="" + FAST_HIGHLIGHT[chrome-docker-got-msg1]=0 + return 1 +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-docker-got-subcommand]} -eq 0 ]]; then + __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} + else + if (( FAST_HIGHLIGHT[chroma-docker-got-subcommand] == 0 )); then + FAST_HIGHLIGHT[chroma-docker-got-subcommand]=1 + FAST_HIGHLIGHT[chroma-docker-subcommand]="$__wrd" + __style=${FAST_THEME_NAME}subcommand + (( FAST_HIGHLIGHT[chroma-docker-counter] += 1 )) + else + __wrd="${__wrd//\`/x}" + __arg="${__arg//\`/x}" + __wrd="${(Q)__wrd}" + if [[ "${FAST_HIGHLIGHT[chroma-docker-subcommand]}" = "image" ]]; then + [[ "$__wrd" != -* ]] && { + (( FAST_HIGHLIGHT[chroma-docker-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-docker-counter] )) + + if (( __idx1 == 2 )); then + __style=${FAST_THEME_NAME}subcommand + elif (( __idx1 == 3 )); then + .fast-run-command "docker images -q" chroma-docker-list "" + [[ -n "${__lines_list[(r)$__wrd]}" ]] && { + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + } || { + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + } + fi + } || __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} + else + return 1 + fi + fi + fi +} + +# Add region_highlight entry (via `reply' array) +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-example.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-example.ch new file mode 100644 index 0000000..8814922 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-example.ch @@ -0,0 +1,120 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Example chroma function. It colorizes first two arguments as `builtin' style, +# third and following arguments as `globbing' style. First two arguments may +# be "strings", they will be passed through to normal higlighter (by returning 1). +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# +# +# Overall functioning is: when command "example" is occured, this function +# is called with $1 == 1, it ("example") is the first token ($2), then for any +# following token, this function is called with $1 == 0, until end of command +# is occured (i.e. till enter is pressed or ";" is put into source, or the +# command line simply ends). +# +# Other tips are: +# - $CURSOR holds cursor position +# - $BUFFER holds whole command line buffer +# - $LBUFFER holds command line buffer that is left from the cursor, i.e. it's a +# BUFFER substring 1 .. $CURSOR +# - $RBUFFER is the same as LBUFFER but holds part of BUFFER right to the cursor +# +# The function receives $BUFFER but via sequence of tokens, which are shell words, +# e.g. "a b c" is a shell word, while a b c are 3 shell words. +# +# FAST_HIGHLIGHT is a friendly hash array which allows to store strings without +# creating global parameters (variables). If you need hash, just use it first +# declaring, under some distinct name like: typeset -gA CHROMA_EXPLE_DICT. +# Remember to reset the hash and others at __first_call == 1, so that you have +# a fresh state for new command. + +# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. +# So the below 8192 assignment takes care that next token will be routed to chroma. +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global string variables. + FAST_HIGHLIGHT[chroma-example-counter]=0 + + # Set style for region_highlight entry. It is used below in + # '[[ -n "$__style" ]] ...' line, which adds highlight entry, + # like "10 12 fg=green", through `reply' array. + # + # Could check if command `example' exists and set `unknown-token' + # style instead of `command' + __style=${FAST_THEME_NAME}command + +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + else + # Count non-option tokens + (( FAST_HIGHLIGHT[chroma-example-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-example-counter] )) + + # Colorize 1..2 as builtin, 3.. as glob + if (( FAST_HIGHLIGHT[chroma-example-counter] <= 2 )); then + if [[ "$__wrd" = \"* ]]; then + # Pass through, fsh main code will do the highlight! + return 1 + else + __style=${FAST_THEME_NAME}builtin + fi + else + __style=${FAST_THEME_NAME}globbing + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# If 1 will be added to __start_pos, this will highlight "oken". +# If 1 will be subtracted from __end_pos, this will highlight "toke". +# $PREBUFFER is for specific situations when users does command \ +# i.e. when multi-line command using backslash is entered. +# +# This is a common place of adding such entry, but any above code can do +# it itself (and it does in other chromas) and skip setting __style to +# this way disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves. +# _start_pos=$_end_pos advainces pointers in command line buffer. +# +# To pass through means to `return 1'. The highlighting of +# this single token is then done by fast-syntax-highlighting's +# main code and chroma doesn't have to do anything. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fast-theme.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fast-theme.ch new file mode 100644 index 0000000..15bc210 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fast-theme.ch @@ -0,0 +1,40 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +local __first_call="$1" __wrd="${(Q)2}" __start_pos="$3" __end_pos="$4" +local __style + +if (( __first_call )); then + FAST_HIGHLIGHT[chroma-fast-theme-first]=0 + return 1 +elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +elif (( ${FAST_HIGHLIGHT[chroma-fast-theme-first]} )) || [[ $__wrd = -* ]]; then + return 1 +else + FAST_HIGHLIGHT[chroma-fast-theme-first]=1 +fi + +if [[ "$__wrd" = */* || "$__wrd" = (XDG|LOCAL|HOME|OPT):* ]]; then + __wrd="${${__wrd/(#s)XDG:/${${XDG_CONFIG_HOME:-$HOME/.config}%/}/fsh/}%.ini}.ini" + __wrd="${${__wrd/(#s)LOCAL://usr/local/share/fsh/}%.ini}.ini" + __wrd="${${__wrd/(#s)HOME:/$HOME/.fsh/}%.ini}.ini" + __wrd="${${__wrd/(#s)OPT://opt/local/share/fsh/}%.ini}.ini" + __wrd=${~__wrd} # allow user to quote ~ +else + __wrd="$FAST_BASE_DIR/themes/$__wrd.ini" +fi + +if [[ -f $__wrd ]]; then + __style=${FAST_THEME_NAME}path +else + __style=${FAST_THEME_NAME}incorrect-subtle +fi + +(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fpath_peq.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fpath_peq.ch new file mode 100644 index 0000000..072cee3 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-fpath_peq.ch @@ -0,0 +1,61 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# This chroma does a narrow, obscure but prestigious parsing of fpath+=( elem1 +# elem2 ... ) construct to provide *the* *future* contents of $fpath to +# -autoload.ch, so that it can detect functions in those provided directories +# `elem1', `elem2', etc. and highlight the functions with `correct-subtle' +# instead of `incorrect-subtle'. Basically all thit is for command-lines like: +# +# % fpath+=( `pwd` ); autoload my-fun-from-PWD + +# Keep chroma-takever state meaning: until ; or similar (see $__arg_type below) +# The 8192 sum takes care that the next token will be routed to this chroma +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local -a deserialized + +(( __first_call )) && { + case $__wrd in + (fpath=\() + FAST_HIGHLIGHT[fpath_peq_mode]=1 + ;; + (fpath+=\() + FAST_HIGHLIGHT[fpath_peq_mode]=2 + ;; + (FPATH=) + FAST_HIGHLIGHT[fpath_peq_mode]=4 + ;; + (FPATH+=) + FAST_HIGHLIGHT[fpath_peq_mode]=8 + ;; + esac + if (( FAST_HIGHLIGHT[fpath_peq_mode] & 5 )); then + FAST_HIGHLIGHT[chroma-fpath_peq-elements]="! ${FAST_HIGHLIGHT[chroma-fpath_peq-elements]}" + fi + return 1 +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + [[ "$__wrd" != ")" ]] && { + deserialized=( "${(Q@)${(z@)FAST_HIGHLIGHT[chroma-fpath_peq-elements]}}" ) + [[ -z "${deserialized[1]}" && ${#deserialized} -eq 1 ]] && deserialized=() + # Support ~ and $VAR, for [a-zA-Z_][a-ZA-Z0-9_]# characters in "VAR" + deserialized+=( "${(Q)${${(j: :)__wrd}//(#b)((\$([0-9]##|[a-zA-Z_][a-zA-Z0-9_]#))|(\$\{([0-9]##|[a-zA-Z_][a-zA-Z0-9_]#)\})|(#s)~)/${(P)${${${${match[1]##\$\{(#c0,1)}%\}}:#\~}:-HOME}}}}" ) + FAST_HIGHLIGHT[chroma-fpath_peq-elements]="${(j: :)${(q@)deserialized}}" + } + + return 1 +} + +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-git.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-git.ch new file mode 100644 index 0000000..12a97b3 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-git.ch @@ -0,0 +1,954 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma function for command `git'. It colorizes the part of command +# line that holds `git' invocation. + +(( FAST_HIGHLIGHT[-git.ch-chroma-def] )) && return 1 + +FAST_HIGHLIGHT[-git.ch-chroma-def]=1 + +typeset -gA fsh__git__chroma__def +fsh__git__chroma__def=( + ## + ## No subcommand + ## + ## {{{ + + subcmd:NULL "NULL_0_opt" + NULL_0_opt "(-C|--exec-path=|--git-dir=|--work-tree=|--namespace=|--super-prefix=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || -c + <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP + <<>> __style=\${FAST_THEME_NAME}optarg-string // NO-OP + || (--version|--help|--html-path|--man-path|--info-path|-p|--paginate| + -P|--no-pager|--no-replace-objects|--bare) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + + "subcommands" "::→chroma/-git-get-subcommands" # run a function (the :: causes this) and use `reply' + #"subcommands" "(fetch|pull)" # run a function (the :: causes this) and use `reply' + + "subcmd-hook" "→chroma/-git-check-if-alias" + + "subcommands-blacklist" "mv,other" + + ## }}} + + ## + ## `FETCH' + ## + ## {{{ + + subcmd:fetch "FETCH_MULTIPLE_0_opt^ // FETCH_ALL_0_opt^ // FETCH_0_opt // + REMOTE_GR_1_arg // REF_#_arg // NO_MATCH_#_opt" + + # Special options (^ - has directives, currently - an :add and :del directive) + "FETCH_MULTIPLE_0_opt^" " + --multiple + <<>> __style=\${FAST_THEME_NAME}double-hyphen-option // NO-OP + || --multiple:add + <<>> REMOTE_GR_#_arg + || --multiple:del + <<>> REMOTE_GR_1_arg // REF_#_arg" # when --multiple is passed, then + # there is no refspec argument, only remotes-ids + # follow unlimited # of them, hence the # in the + # REMOTE_GR_#_arg + + # Special options (^ - has directives - an :del-directive) + "FETCH_ALL_0_opt^" " + --all + <<>> __style=\${FAST_THEME_NAME}double-hyphen-option // NO-OP + || --all:del + <<>> REMOTE_GR_1_arg // REF_#_arg" # --all can be only followed by options + + # FETCH_0_opt. FETCH-options (FETCH is an identifier) at position 0 -> + # -> before any argument + FETCH_0_opt " + (--depth=|--deepen=|--shallow-exclude=|--shallow-since=|--receive-pack=| + --refmap=|--recurse-submodules=|-j|--jobs=|--submodule-prefix=| + --recurse-submodules-default=|-o|--server-option=|--upload-pack| + --negotiation-tip=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (--help|--all|-a|--append|--unshallow|--update-shallow|--dry-run|-f|--force| + -k|--keep|--multiple|-p|--prune|-n|--no-tags|-t|--tags|--no-recurse-submodules| + -u|--update-head-ok|-q|--quiet|-v|--verbose|--progress| + -4|--ipv4|-6|--ipv6) + <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP" + # Above: note the two <<>>-separated blocks for options that have + # some arguments – the second pair of action/handler is being + # run when an option argument is occurred (first one: the option + # itself). If there is only one <<>>-separated block, then the option + # is set to be argument-less. The argument is a) -o/--option argument + # and b) -o/--option=argument. + + REMOTE_GR_1_arg "NO-OP // ::→chroma/-git-verify-remote-or-group" # This definition is generic, reused later + "REF_#_arg" "NO-OP // ::→chroma/-git-verify-ref" # This too + "REMOTE_GR_#_arg" "NO-OP // ::→chroma/-git-verify-remote-or-group" # and this too + # The hash `#' above denotes: an argument at any position + # It will nicely match any following (above the first explicitly + # numbered ones) arguments passed when using --multiple + + # A generic action + NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" + NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" + + ## }}} + + ## + ## PUSH + ## + ## {{{ + + subcmd:push "PUSH_0_opt // REMOTE_1_arg // REF_#_arg // NO_MATCH_#_opt" + + PUSH_0_opt " + (--receive-pack=|--exec=|--repo=|--push-option=|--signed=| + --force-with-lease=|--signed=|--recurse-submodules=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (--help|--all|--mirror|--tags|--follow-tags|--atomic|-n|--dry-run| + --porcelain|--delete|--tags|--follow-tags|--signed|--no-signed| + --atomic|--no-atomic|-o|--push-option|--force-with-lease| + --no-force-with-lease|-f|--force|-u|--set-upstream|--thin| + --no-thin|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules| + --verify|--no-verify|-4|--ipv4|-6|--ipv6) + <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP" + + REMOTE_1_arg "NO-OP // ::→chroma/-git-verify-remote" # This definition is generic, reused later + + ### }}} + + ## + ## PULL + ## + ## {{{ + + subcmd:pull "PULL_0_opt // REMOTE_1_arg // REF_#_arg // NO_MATCH_#_opt" + + PULL_0_opt " + (--recurse-submodules=|-S|--gpg-sign=|--log=|-s|--strategy=|-X| + --strategy-option=|--rebase=|--depth=|--deepen=|--shallow-exclude=| + --shallow-since=|--negotiation-tip|--upload-pack|-o|--server-option=| + --no-recurse-submodules=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (--help|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules| + --commit|--no-commit|--edit|--no-edit|--ff|--no-ff|--ff-only| + --log|--no-log|--signoff|--no-signoff|--stat|-n|--no-stat|--squash| + --no-squash|--verify-signatures|--no-verify-signatures|--summary| + --no-summary|--allow-unrelated-histories|-r|--rebase|--no-rebase| + --autostash|--no-autostash|--all|-a|--append|--unshallow| + --update-shallow|-f|--force|-k|--keep|--no-tags|-u|--update-head-ok| + --progress|-4|--ipv4|-6|--ipv6|--recurse-submodules) + <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP" + + ## }}} + + ## + ## COMMIT + ## + ## {{{ + + subcmd:commit "COMMIT_#_opt // FILE_#_arg // NO_MATCH_#_opt" + + "COMMIT_#_opt" " + (-m|--message=|-am) + <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action + <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action + || (--help|-a|--all|-p|--patch|--reset-author|--short|--branch| + --porcelain|--long|-z|--null|-s|--signoff|-n|--no-verify| + --allow-empty|--allow-empty-message|-e|--edit|--no-edit| + --amend|--no-post-rewrite|-i|--include|-o|--only|--untracked-files| + -v|--verbose|-q|--quiet|--dry-run|--status|--no-status|--no-gpg-sign) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || (-C|--reuse-message=|-c|--reedit-message=|--fixup=|--squash=| + -F|--file=|--author=|--date=|-t|--template=|--cleanup=| + -u|--untracked-files=|-S|--gpg-sign=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action" + + # A generic action + "FILE_#_arg" "NO-OP // ::→chroma/-git-verify-file" + + ## }}} + + ## + ## MERGE + ## + ## {{{ + + subcmd:merge "MERGE_0_opt // COMMIT_#_arg" + MERGE_0_opt + "(-m) + <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action + <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action + (-S|--gpg-sign=|--log=|-e|--strategy=|-X|--strategy-option=|-F| + --file) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (--help|--commit|--no-commit|-e|--edit|--no-edit|--ff|--no-ff|--ff-only| + --log|--no-log|--signoff|--no-signoff|-n|--stat|--no-stat|--squash| + --no-squash|--verify-signatures|--no-verify-signatures|--summary| + --no-summary|-q|--quiet|-v|--verbose|--progress|--no-progress| + --allow-unrelated-histories|--rerere-autoupdate|--no-rerere-autoupdate| + --abort|--continue) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + COMMIT_\#_arg "NO-OP // ::→chroma/-git-verify-commit" + + ## }}} + + ## + ## RESET + ## + ## {{{ + + subcmd:reset "RESET_0_opt^ // RESET_0_opt // RESET_#_arg // NO_MATCH_#_opt" + "RESET_0_opt^" " + (--soft|--mixed|--hard|--merge|--keep) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || (--soft|--mixed|--hard|--merge|--keep):del + <<>> RESET_0_opt // RESET_#_arg + || (--soft|--mixed|--hard|--merge|--keep):add + <<>> RESET_1_arg // NO_MATCH_#_arg + " + + RESET_0_opt " + (-q|-p|--patch) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + RESET_1_arg "NO-OP // ::→chroma/-git-verify-commit" + + "RESET_#_arg" "NO-OP // ::→chroma/-git-RESET-verify-commit-or-file" + + + ## }}} + + ## + ## REVERT + ## + ## {{{ + + subcmd:revert "REVERT_SEQUENCER_0_opt^ // REVERT_0_opt // REVERT_#_arg // NO_MATCH_#_opt" + REVERT_0_opt " + (-m|--mainline|-S|--gpg-sign=|--strategy=|-X|--strategy-option=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (-e|--edit|--no-edit|-n|--no-commit|-s|--signoff) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + "REVERT_SEQUENCER_0_opt^" " + (--continue|--quit|--abort) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || (--continue|--quit|--abort):del + <<>> REVERT_0_opt // REVERT_#_arg + || (--continue|--quit|--abort):add + <<>> NO_MATCH_#_arg" + + "REVERT_#_arg" "NO-OP // ::→chroma/-git-verify-commit" + + ## }}} + + ## + ## DIFF + ## + ## TODO: When a second argument is also a path and it points to a directory, then + ## git appends the previous file name to it – good to implement this too + ## {{{ + + subcmd:diff "DIFF_NO_INDEX_0_opt^ // DIFF_0_opt // COMMIT_FILE_DIR_#_arg // NO_MATCH_#_opt" + + "DIFF_NO_INDEX_0_opt^" " + --no-index + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || --no-index:del + <<>> COMMIT_FILE_DIR_#_arg + || --no-index:add + <<>> FILE_1_arg // FILE_2_arg // NO_MATCH_#_arg" + DIFF_0_opt " + (-U|--unified=|--anchored=|--diff-algorithm=|--stat=|--dirstat| + --submodule=|--color=|--color-moved=|--color-moved-ws=|--word-diff=| + --word-diff-regex=|--color-words=|--ws-error-highlight=|--abbrev=| + -B|--break-rewrites=|-M|--find-renames=|-C|--find-copies=|-l| + --diff-filter=|-S|-G|--find-object=|--relative=|-O|--relative=| + --inter-hunk-context=|--ignore-submodules=|--src-prefix=|--dst-prefix=| + --line-prefix=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (-p|--patch|-u|-s|--no-patch|--raw|--patch-with-raw|--indent-heuristic| + --no-indent-heuristic|--minimal|--patience|--histogram|--stat| + --compact-summary|--numstat|--shortstat|--dirstat|--summary| + --patch-with-stat|-z|--name-only|--name-status|--submodule|--no-color| + --color-moved|--word-diff|--color-words|--no-renames|--check| + --full-index|--binary|--abbrev|--break-rewrites|--find-renames| + --find-copies|--find-copies-harder|-D|--pickaxe-all|--pickaxe-regex| + --irreversible-delete|-R|--relative|-a|--text|--ignore-cr-at-eol| + --ignore-space-at-eol|-b|--ignore-space-change|-w|--ignore-all-space| + --ignore-blank-lines|-W|--function-context|--exit-code|--quiet| + --ext-diff|--no-ext-diff|--textconv|--no-textconv|--ignore-submodules| + --no-prefix|--ita-invisible-in-index|-1|--base|-2|--ours|-3|--theirs| + -0|--cached) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + # A generic action + "COMMIT_FILE_DIR_#_arg" "NO-OP // ::→chroma/-git-verify-commit-or-file-or-dir" + + # A generic action + "FILE_1_arg" "NO-OP // ::→chroma/-git-verify-file" + + # A generic action + "FILE_2_arg" "NO-OP // ::→chroma/-git-verify-file" + + ## }}} + + ## + ## ADD + ## + ## {{{ + + subcmd:add "ADD_0_opt // FILE_OR_DIR_#_arg // NO_MATCH_#_opt" + + ADD_0_opt " + --chmod= + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (-v|--verbose|-f|--force|-i|--interactive|-n|--dry-run| + -p|--patch|-e|--edit|--all|--no-all|-A|--all|--no-all| + --ignore-removal|--no-ignore-removal|-u|--update|-N| + --intent-to-add|--refresh|--ignore-errors|--ignore-missing| + --renormalize|--no-warn-embedded-repo) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + FILE_OR_DIR_#_arg "NO-OP // ::→chroma/-git-verify-file-or-dir" + + ## }}} + + ## + ## CHECKOUT + ## + ## {{{ + + subcmd:checkout "CHECKOUT_BRANCH_0_opt^ // + CHECKOUT_0_opt // FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg // + FILE_#_arg // NO_MATCH_#_opt" + + "CHECKOUT_BRANCH_0_opt^" " + (-b|-B|--orphan) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || (-b|-B|--orphan):del + <<>> FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg // FILE_#_arg + || (-b|-B|--orphan):add + <<>> NEW_BRANCH_1_arg // COMMIT_2_arg // NO_MATCH_#_arg" + + NEW_BRANCH_1_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" + + COMMIT_2_arg "NO-OP // ::→chroma/-git-verify-commit" + + CHECKOUT_0_opt " + --conflict= + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (-q|--quiet|--progress|--no-progress|-f|--force|--ours|--theirs| + -b|-B|-t|--track|--no-track|-l|--detach|--orphan| + --ignore-skip-worktree-bits|-m|--merge|-p|--patch| + --ignore-other-worktrees|--no-ignore-other-worktrees) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + # A generic action + COMMIT_1_arg "NO-OP // ::→chroma/-git-verify-commit" + + # Unused + FILE_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-ubranch-or-commit-verify" + FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-dir-or-ubranch-or-commit-verify" + + ## }}} + + ## + ## REMOTE + ## + ## {{{ + + subcmd:remote "REMOTE_0_opt // REMOTE_ADD_1_arg // REMOTE_RENAME_1_arg // REMOTE_REMOVE_1_arg // + REMOTE_SET_HEAD_1_arg // REMOTE_SET_BRANCHES_1_arg // + REMOTE_GET_URL_1_arg // REMOTE_SET_URL_1_arg // REMOTE_SHOW_1_arg // + REMOTE_PRUNE_1_arg // REMOTE_UPDATE_1_arg" + + REMOTE_0_opt "(-v|--verbose) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_ADD_1_arg "add ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_ADD_OPTS_1_opt // REMOTE_A_NAME_2_arg // + REMOTE_A_URL_3_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + REMOTE_RENAME_1_arg "rename ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_2_arg // REMOTE_A_NAME_3_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + REMOTE_REMOVE_1_arg "remove ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + REMOTE_SET_HEAD_1_arg "set-head ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_2_arg // BRANCH_3_arg // + REMOTE_SET_HEAD_OPTS_1_opt // REMOTE_SET_HEAD_OPTS_2_opt // + NO_MATCH_#_opt // NO_MATCH_#_arg" + + REMOTE_SET_BRANCHES_1_arg "set-branches ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_SET_BRANCHES_OPTS_1_opt // REMOTE_2_arg // + BRANCH_#_arg // NO_MATCH_#_opt" + + REMOTE_GET_URL_1_arg "get-url ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_GET_URL_OPTS_1_opt // REMOTE_2_arg // + NO_MATCH_#_opt // NO_MATCH_#_arg" + + REMOTE_SET_URL_1_arg "set-url ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_SET_URL_OPTS_1_opt^ // + REMOTE_2_arg // REMOTE_A_URL_3_arg // REMOTE_A_URL_4_arg // + NO_MATCH_#_opt // NO_MATCH_#_arg" + + REMOTE_SHOW_1_arg "show ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_SHOW_OPTS_1_opt // REMOTE_#_arg // NO_MATCH_#_opt" + + REMOTE_PRUNE_1_arg "prune ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_PRUNE_OPTS_1_opt // REMOTE_#_arg // NO_MATCH_#_opt" + + REMOTE_UPDATE_1_arg "update ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>> + add:REMOTE_UPDATE_OPTS_1_opt // REMOTE_GR_#_arg // NO_MATCH_#_opt" + + REMOTE_ADD_OPTS_1_opt " + (-t|-m|--mirror=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (-f|--tags|--no-tags) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_SET_HEAD_OPTS_1_opt " + (-a|--auto|-d|--delete) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_SET_HEAD_OPTS_2_opt " + (-a|--auto|-d|--delete) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_SET_BRANCHES_OPTS_1_opt " + --add + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_GET_URL_OPTS_1_opt " + (--push|--all) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + "REMOTE_SET_URL_OPTS_1_opt^" " + --push|--add|--delete + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || (--add|--delete):del + <<>> REMOTE_A_URL_4_arg" + + REMOTE_SHOW_OPTS_1_opt " + -n + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_PRUNE_OPTS_1_opt " + (-n|--dry-run) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_UPDATE_OPTS_1_opt " + (-p|--prune) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + REMOTE_A_NAME_2_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" + REMOTE_A_NAME_3_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" + REMOTE_A_URL_3_arg "NO-OP // ::→chroma/main-chroma-std-verify-url" + REMOTE_A_URL_4_arg "NO-OP // ::→chroma/main-chroma-std-verify-url" + BRANCH_3_arg "NO-OP // ::→chroma/-git-verify-branch" + BRANCH_\#_arg "NO-OP // ::→chroma/-git-verify-branch" + REMOTE_2_arg "NO-OP // ::→chroma/-git-verify-remote" + REMOTE_\#_arg "NO-OP // ::→chroma/-git-verify-remote" + + ## }}} + + ## + ## LOG + ## + + subcmd:log "LOG_0_opt // LOG_1_arg // FILE_#_arg // NO_MATCH_#_opt" + + LOG_0_opt " + (--decorate=|--decorate-refs=|--decorate-refs-exclude=|-L|-n|--max-count=| + --skip=|--since=|--after=|--until=|--before=|--author=|--committer=| + --grep-reflog=|--grep=|--min-parents=|--max-parents=|--branches=|--tags=| + --remotes=|--glob=|--exclude=|--no-walk=|--pretty=|--format=|--encoding=| + --expand-tabs=|--notes=|--show-notes=|--date=|--show-linear-break=|-U| + --unified=|--anchored=|--diff-algorithm=|--stat=|--dirstat=|--submodule=| + --color=|--color-moved=|--color-moved-ws=|--word-diff=|--word-diff-regex=| + --color-words=|--ws-error-highlight=|--abbrev=|-B|--break-rewrites=|-M| + --find-renames=|-C|--find-copies=|-l|--diff-filter=|-S|-G|--find-object=| + --relative=|-O|--relative=|--inter-hunk-context=|--ignore-submodules=| + --src-prefix=|--dst-prefix=|--line-prefix=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + + || (--follow|--decorate|--no-decorate|--source|--use-mailmap|--full-diff| + --log-size|--all-match|--invert-grep|-i|--regexp-ignore-case|--basic-regexp| + -E|--extended-regexp|-F|--fixed-strings|-P|--perl-regexp|--remove-empty| + --merges|--no-merges|--no-min-parents|--no-max-parents|--first-parent| + --not|--all|--branches|--tags|--remotes|--reflog|--single-worktree| + --ignore-missing|--bisect|--stdin|--cherry-mark|--cherry-pick|--left-only| + --right-only|--cherry|-g|--walk-reflogs|--merge|--boundary|--simplify-by-decoration| + --full-history|--dense|--sparse|--simplify-merges|--ancestry-path|--date-order| + --author-date-order|--topo-order|--reverse|--no-walk|--do-walk|--pretty| + --abbrev-commit|--no-abbrev-commit|--oneline|--expand-tabs|--no-expand-tabs| + --notes|--no-notes|--show-notes|--no-standard-notes|--show-signature| + --relative-date|--parents|--children|--left-right|--graph|--show-linear-break| + -c|--cc|-m|-r|-t|-p|-u|--patch|-s|--no-patch|--raw|--patch-with-raw| + --indent-heuristic|--no-indent-heuristic|--minimal|--patience|--histogram| + --stat|--compact-summary|--numstat|--shortstat|--dirstat|--summary| + --patch-with-stat|-z|--name-only|--name-status|--submodule|--color|--no-color| + --color-moved|--word-diff|--color-words|--no-renames|--check|--full-index| + --binary|--abbrev|--break-rewrites|--find-renames| + --find-copies|--find-copies-harder|-D|--irreversible-delete| + --pickaxe-all|--pickaxe-regex|-R|--relative|-a|--text|--ignore-cr-at-eol| + --ignore-space-at-eol|-b|--ignore-space-change|-w|--ignore-all-space| + --ignore-blank-lines|-W|--function-context|--ext-diff|--no-ext-diff| + --textconv|--no-textconv|--ignore-submodules|--no-prefix| + --ita-invisible-in-index) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + LOG_1_arg "NO-OP // ::→chroma/-git-verify-rev-range-or-file" + + ## + ## TAG + ## + + subcmd:tag "TAG_D_0_opt^ // TAG_L_0_opt^ // TAG_V_0_opt^ // TAG_0_opt^" + + "TAG_0_opt^" " + (-u|--local-user=|--cleanup=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || -m + <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action + <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action + || (-F|--file) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/-git-verify-file + || (-a|--annotate|-s|--sign|-f|-e|--edit) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || (-u|--local-user=|--cleanup=|-m|-F|--file|-a|--annotate|-s|--sign| + -f|-e|--edit):add + <<>> TAG_NEW_1_arg // COMMIT_2_arg // NO_MATCH_#_arg // + NO_MATCH_#_opt" + + TAG_NEW_1_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name" + + TAG_1_arg "NO-OP // ::→chroma/-git-verify-tag-name" + + "TAG_D_0_opt^" " + (-d) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || -d:add + <<>> TAG_#_arg // NO_MATCH_#_opt + || -d:del + <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg" + + "TAG_#_arg" "NO-OP // ::→chroma/-git-verify-tag-name" + + "TAG_L_0_opt^" " + (-l) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || -l:add + <<>> TAG_L_0_opt // TAG_PAT_#_arg // NO_MATCH_#_opt + || -l:del + <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg" + + TAG_L_0_opt " + (-n|--contains|--no-contains|--points-at|--column=|--sort=|--format=| + --color=) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action + || (--column|--no-column|--create-reflog|--merged|--no-merged|--color|-i) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + "TAG_PAT_#_arg" "NO-OP // ::→chroma/main-chroma-std-verify-pattern" + + "TAG_V_0_opt^" " + (-v) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + || -v:add + <<>> TAG_V_0_opt // TAG_#_arg // NO_MATCH_#_opt + || -v:del + <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg" + + TAG_V_0_opt " + --format= + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action" + + ## + ## All remaining subcommands + ## + ## {{{ + + "subcmd:*" "CATCH_ALL_#_opt" + "CATCH_ALL_#_opt" "* <<>> NO-OP // ::→chroma/main-chroma-std-aopt-SEMI-action" + + ## }}} +) + +# Called after entering just "git" on the command line +→chroma/-git-first-call() { + # Called for the first time - new command + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global variables + FAST_HIGHLIGHT[chroma-git-counter]=0 + FAST_HIGHLIGHT[chroma-git-got-subcommand]=0 + FAST_HIGHLIGHT[chroma-git-subcommand]="" + FAST_HIGHLIGHT[chrome-git-got-msg1]=0 + FAST_HIGHLIGHT[chrome-git-got-anymsg]=0 + FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=0 + FAST_HIGHLIGHT[chroma-git-checkout-new]=0 + FAST_HIGHLIGHT[chroma-git-fetch-multiple]=0 + FAST_HIGHLIGHT[chroma-git-branch-change]=0 + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 + FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit]=0 + FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=0 + return 1 +} + +→chroma/-git-check-if-alias() { + local _wrd="$1" + local -a _result + + typeset -ga fsh__chroma__git__aliases + _result=( ${(M)fsh__chroma__git__aliases[@]:#${_wrd}[[:space:]]##*} ) + →chroma/main-chroma-print "Got is-alias-_result: $_result" + [[ -n "$_result" ]] && \ + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="${${${_result#* }## ##}%% *}" +} + +# A hook that returns the list of git's +# available subcommands in $reply +→chroma/-git-get-subcommands() { + local __svalue + integer __ivalue + LANG=C .fast-run-command "git help -a" chroma-${FAST_HIGHLIGHT[chroma-current]}-subcmd-list "" $(( 15 * 60 )) + if [[ "${__lines_list[1]}" = See* ]]; then + # (**) + # git >= v2.20, the aliases in the `git help -a' command + __lines_list=( ${${${${(M)__lines_list[@]:#([[:space:]](#c3,3)[a-zA-Z0-9_]*|Command aliases)}##[[:space:]]##}//(#s)Command\ aliases(#e)/Command_aliases}} ) + __svalue="+${__lines_list[(I)Command_aliases]}" + __lines_list[1,__svalue-1]=( ${(@)__lines_list[1,__svalue-1]%%[[:space:]]##*} ) + else + # (**) + # git < v2.20, add aliases through extra code + __lines_list=( ${(s: :)${(M)__lines_list[@]:# [a-z]*}} ) + + __svalue=${#__lines_list} + # This allows to check if the command is an alias - we want to + # highlight the aliased command just like the target command of + # the alias + .fast-run-command "+git config --get-regexp 'alias.*'" chroma-${FAST_HIGHLIGHT[chroma-current]}-alias-list "[[:space:]]#alias." $(( 15 * 60 )) + fi + + __tmp=${#__lines_list} + typeset -ga fsh__chroma__git__aliases + fsh__chroma__git__aliases=( ${__lines_list[__svalue+1,__tmp]} ) + [[ ${__lines_list[__svalue]} != "Command_aliases" ]] && (( ++ __svalue, __ivalue=0, 1 )) || (( __ivalue=1 )) + __lines_list[__svalue,__tmp]=( ${(@)__lines_list[__svalue+__ivalue,__tmp]%%[[:space:]]##*} ) + reply=( "${__lines_list[@]}" ) +} + +# A generic handler +→chroma/-git-verify-remote() { + local _wrd="$4" + .fast-run-git-command "git remote" "chroma-git-remotes-$PWD" "" 10 + [[ -n ${__lines_list[(r)$_wrd]} ]] && { + __style=${FAST_THEME_NAME}correct-subtle; return 0 + } || { + [[ $_wrd != *:* ]] && { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } + } +} + +# A generic handler - checks if given ref is correct +→chroma/-git-verify-ref() { + local _wrd="$4" + _wrd="${_wrd%%:*}" + .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-refs-$PWD" "refs/heads" 10 + [[ -n ${__lines_list[(r)$_wrd]} ]] && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } +} + +# A generic handler - checks if given remote or group is correct +→chroma/-git-verify-remote-or-group() { + →chroma/-git-verify-remote "$@" && return 0 + # The check for a group is to follow below + integer _start="$2" _end="$3" + local _scmd="$1" _wrd="$4" +} + +# A generic handler - checks whether the file exists +→chroma/-git-verify-file() { + integer _start="$2" _end="$3" __pos __start __end + local _wrd="$4" bg + + [[ -f $_wrd ]] && { + (( __start=_start, __end=_end, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*} + ((1)) + } || { + (( __start=_start, __end=_end, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*} + } + + [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \ + ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \ + ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} + ]] && \ + for (( __pos = 1; __pos <= (_end-_start); __pos++ )) { + [[ ${_wrd[__pos]} == "/" ]] && { + [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && { + (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}") + ((1)) + } || { + (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}") + } + } + } +} + +# A generic handler - checks whether the file exists +→chroma/-git-verify-file-or-dir() { + integer _start="$2" _end="$3" __pos __start __end retval + local _wrd="$4" bg + + __style= + [[ -f $_wrd || -d $_wrd ]] && { + (( __start=_start, __end=_end, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*} + ((1)) + } || { + (( __start=_start, __end=_end, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*} + retval=1 + } + + [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \ + ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \ + ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} + ]] && \ + for (( __pos = 1; __pos <= (_end-_start); __pos++ )) { + [[ ${_wrd[__pos]} == "/" ]] && { + [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && { + (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}") + ((1)) + } || { + (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \ + reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}") + } + } + } + return $retval +} + +→chroma/-git-verify-branch() { + local _wrd="$4" + .fast-run-git-command "git for-each-ref --format='%(refname:short)'" "chroma-git-branches-$PWD" "refs/heads" 10 + if [[ -n ${__lines_list[(r)$_wrd]} ]] { + __style=${FAST_THEME_NAME}correct-subtle; return 0 + } elif [[ -n ${__lines_list[(r)origin/$_wrd]} ]] { + __style=${FAST_THEME_NAME}correct-subtle; return 0 + } else { + __style=${FAST_THEME_NAME}incorrect-subtle; return 1 + } +} + +→chroma/-git-verify-also-unfetched-ref() { + local _wrd="$4" + .fast-run-git-command "git config --get checkout.defaultRemote" \ + "chroma-git-defaultRemote-$PWD" "" 10 + local remote="${__lines_list[1]:-origin}" + .fast-run-git-command "git rev-list --count --no-walk + --glob=\"refs/remotes/$remote/$_wrd\"" \ + "chroma-git-unfetched-ref-$PWD" "" 10 + + (( __lines_list[1] )) && { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } +} + +# A generic handler +→chroma/-git-file-or-ubranch-or-commit-verify() { + →chroma/-git-verify-commit "$@" && return + →chroma/-git-verify-file "$@" && return + →chroma/-git-verify-branch "$@" && return + →chroma/-git-verify-also-unfetched-ref "$@" +} + +# A generic handler +→chroma/-git-file-or-dir-or-ubranch-or-commit-verify() { + →chroma/-git-verify-commit "$@" && return + →chroma/-git-verify-file-or-dir "$@" && return + →chroma/-git-verify-branch "$@" && return + →chroma/-git-verify-also-unfetched-ref "$@" +} + +# A generic handler +→chroma/-git-verify-correct-branch-name() { + local _wrd="$4" + →chroma/-git-verify-commit "$@" && \ + { __style=${FAST_THEME_NAME}incorrect-subtle; return 0; } + + →chroma/-git-verify-remote "$@" && \ + { __style=${FAST_THEME_NAME}incorrect-subtle; return 0; } + + [[ "$_wrd" != ./* && "$_wrd" != *..* && "$_wrd" != *[~\^\ $'\t']* && + "$_wrd" != */ && "$_wrd" != *.lock && "$_wrd" != *\\* ]] && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } +} + +# A generic handler that checks if given commit reference is correct +→chroma/-git-verify-commit() { + local _wrd="$4" + __lines_list=() + .fast-run-git-command --status "git rev-parse --verify --quiet \"$_wrd\"" \ + "chroma-git-commits-$PWD-$_wrd" "" $(( 1.5 * 60 )) + if (( __lines_list[1] == 0 )); then + __style=${FAST_THEME_NAME}correct-subtle + return 0 + fi + __style=${FAST_THEME_NAME}incorrect-subtle + return 1 +} + +# A generic handler that checks if given commit reference +# is correct or if it's a file that exists +→chroma/-git-verify-commit-or-file() { + →chroma/-git-verify-commit "$@" && return + →chroma/-git-verify-file "$@" +} + +# A generic handler that checks if given commit reference +# is correct or if it's a file or directives that exists +→chroma/-git-verify-commit-or-file-or-dir() { + →chroma/-git-verify-commit "$@" && return + →chroma/-git-verify-file-or-dir "$@" +} + +# A generic handler that checks if given revision range +# is correct or if a file of that name exists +→chroma/-git-verify-rev-range-or-file() { + local _wrd="$4" + + →chroma/-git-verify-commit "$@" && return 0 + + if [[ "$_wrd" = *..* ]]; then + (( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] )) && { + →chroma/-git-verify-file "$@" && return 0 + __style=${FAST_THEME_NAME}unknown-token + return 1 + } + + __style="" + return 0 + fi + + →chroma/-git-verify-file "$@" && \ + { FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; } + + __style="" + return 1 +} + +→chroma/-git-verify-tag-name() { + local _wrd="$4" + .fast-run-git-command "git tag" "chroma-git-tags-$PWD" "" $(( 2*60 )) + [[ -n ${__lines_list[(r)$_wrd]} ]] && \ + __style=${FAST_THEME_NAME}correct-subtle || \ + __style=${FAST_THEME_NAME}incorrect-subtle +} + +# A handler for the commit's -m/--message options.Currently +# does the same what →chroma/main-chroma-std-aopt-action does +→chroma/-git-commit-msg-opt-action() { + →chroma/main-chroma-std-aopt-action "$@" +} + +# A handler for the commit's -m/--message options' argument +→chroma/-git-commit-msg-opt-ARG-action() { + integer _start="$2" _end="$3" + local _scmd="$1" _wrd="$4" + + (( __start >= 0 )) || return + + # Match the message body in case of an --message= option + if [[ "$_wrd" = (#b)(--message=)(*) && -n "${match[2]}" ]]; then + _wrd="${(Q)${match[2]//\`/x}}" + # highlight --message=>>something<< + reply+=("$(( __start+10 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") + elif [[ "$_wrd" != --message ]]; then + # highlight the message's body + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") + fi + + integer length=${FAST_HIGHLIGHT[git-cmsg-len]:-50} + + if (( ${#_wrd} > length )); then + for (( __idx1 = 1, __idx2 = 1; __idx1 <= length; ++ __idx1, ++ __idx2 )); do + # Use __arg from the fast-highlight-process's scope + while [[ "${__arg[__idx2]}" != "${_wrd[__idx1]}" ]]; do + (( ++ __idx2 )) + (( __idx2 > __asize )) && { __idx2=-1; break; } + done + (( __idx2 == -1 )) && break + done + if (( __idx2 != -1 )); then + if [[ -n "${match[1]}" ]]; then + reply+=("$(( __start+__idx2 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + else + reply+=("$(( __start+__idx2-1 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + fi + fi + fi +} + +# A RESET handler +# TODO: differentiate tree-ish from commit +→chroma/-git-RESET-verify-commit-or-file() { + →chroma/-git-verify-commit "$@" && { + →chroma/-git-verify-file "$@" && { + # TODO: with -p/--patch, the are optional, + # and this argument will be taken as a commit in a + # specific circumstances + FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1 + return 0 + } + + (( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] || + FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit] )) && \ + { __style=${FAST_THEME_NAME}unknown-token; return 1; } + + FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit]=1 + + __style=${FAST_THEME_NAME}correct-subtle + + return 0 + } + + →chroma/-git-verify-file "$@" && \ + { FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; } + + return 1 +} + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-grep.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-grep.ch new file mode 100644 index 0000000..54309bf --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-grep.ch @@ -0,0 +1,89 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __chars +integer __idx1 __idx2 + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-grep-counter]=0 + return 1 +} || { + # Following call, i.e. not the first one. + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + else + # Count non-option tokens. + (( FAST_HIGHLIGHT[chroma-grep-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-grep-counter] )) + + # First non-option token is the pattern (regex), we will + # highlight it. + if (( FAST_HIGHLIGHT[chroma-grep-counter] == 1 )); then + [[ "$__wrd" = \"* ]] && __style=${FAST_THEME_NAME}double-quoted-argument + [[ "$__wrd" = \'* ]] && __style=${FAST_THEME_NAME}single-quoted-argument + [[ "$__wrd" = \$\'* ]] && __style=${FAST_THEME_NAME}dollar-quoted-argument + [[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + __style="" + + __chars="*+\\)([]^\$" + __idx1=__start_pos + __idx2=__start_pos + while [[ "$__wrd" = (#b)[^$__chars]#([\\][\\])#((+|\*|\[|\]|\)|\(|\^|\$)|[\\](+|\*|\[|\]|\)|\(|\^|\$))(*) ]]; do + if [[ -n "${match[3]}" ]]; then + __idx1+=${mbegin[3]}-1 + __idx2=__idx1+${mend[3]}-${mbegin[3]}+1 + (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-operator]}") + __idx1=__idx2 + else + __idx1+=${mbegin[5]}-1 + fi + __wrd="${match[5]}" + done + elif (( FAST_HIGHLIGHT[chroma-grep-counter] == 2 )); then + # Handle paths, etc. normally - just pass-through to the big + # highlighter (the main FSH highlighter, used before chromas). + return 1 + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does) and skip setting __style +# to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-hub.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-hub.ch new file mode 100644 index 0000000..2f0626a --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-hub.ch @@ -0,0 +1,51 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" + +if (( __first_call )); then + chroma/-git.ch $* + return 1 +fi +[[ "$__arg_type" = 3 ]] && return 2 + +if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +fi + +if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then + .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 )) + # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix + __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) + + if (( ${#__lines_list} > 0 )); then + # (*) + # First remove alias name (#*[[:space:]]) and the space after it, then + # remove any leading spaces from what's left (##[[:space:]]##), then + # remove everything except the first word that's in the left line + # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") + FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" + else + FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" + fi + if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "browse" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci-status" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "compare" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "create" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "delete" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fork" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "issue" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pr" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull-request" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "release" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "sync" ]]; then + FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") + (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) + (( this_word = next_word )) + _start_pos=$4 + return 0 + fi +fi + +chroma/-git.ch $* diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ionice.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ionice.ch new file mode 100644 index 0000000..f328f83 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ionice.ch @@ -0,0 +1,117 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 Sebastian Gniazdowski +# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) +# All rights reserved. +# +# The only licensing for this file follows. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- + +setopt local_options extendedglob warn_create_global typeset_silent + +# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. +# So the below 8192 assignment takes care that next token will be routed to chroma. +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style option_start=0 option_end=0 number_start=0 number_end=0 +local -a match mbegin mend + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global string variables. + FAST_HIGHLIGHT[ionice-option-argument]=0 + + # Set style for region_highlight entry. It is used below in + # '[[ -n "$__style" ]] ...' line, which adds highlight entry, + # like "10 12 fg=green", through `reply' array. + # + # Could check if command `example' exists and set `unknown-token' + # style instead of `command' + __style=${FAST_THEME_NAME}precommand + +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if (( FAST_HIGHLIGHT[ionice-option-argument] )); then + (( FAST_HIGHLIGHT[ionice-option-argument] = 0 )) + [[ $__wrd == [0-9]# ]] && __style=${FAST_THEME_NAME}mathnum || __style=${FAST_THEME_NAME}incorrect-subtle + else + case $__wrd in + --(class(data|)|(u|p(g|))id)) + __style=${FAST_THEME_NAME}double-hyphen-option + FAST_HIGHLIGHT[ionice-option-argument]=1 + ;; + -[cnpPu]) + __style=${FAST_THEME_NAME}single-hyphen-option + FAST_HIGHLIGHT[ionice-option-argument]=1 + ;; + --*) + __style=${FAST_THEME_NAME}double-hyphen-option + ;; + -*) + __style=${FAST_THEME_NAME}single-hyphen-option + ;; + *) + this_word=1 + next_word=2 + return 1 + ;; + esac + fi +} + +# Add region_highlight entry (via `reply' array). +# If 1 will be added to __start_pos, this will highlight "oken". +# If 1 will be subtracted from __end_pos, this will highlight "toke". +# $PREBUFFER is for specific situations when users does command \ +# i.e. when multi-line command using backslash is entered. +# +# This is a common place of adding such entry, but any above code can do +# it itself (and it does in other chromas) and skip setting __style to +# this way disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves. +# _start_pos=$_end_pos advainces pointers in command line buffer. +# +# To pass through means to `return 1'. The highlighting of +# this single token is then done by fast-syntax-highlighting's +# main code and chroma doesn't have to do anything. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-lab.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-lab.ch new file mode 100644 index 0000000..9c76e03 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-lab.ch @@ -0,0 +1,59 @@ +# vim:ft=zsh:et:sw=4 +# +# The `lab' tool after which this chroma is modeled after: +# https://github.com/zaquestion/lab +# +(( next_word = 2 | 8192 )) +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" + +if (( __first_call )); then + chroma/-git.ch $* + return 1 +fi +[[ "$__arg_type" = 3 ]] && return 2 + +if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +fi + +if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then + .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 )) + # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix + __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) + + if (( ${#__lines_list} > 0 )); then + # (*) + # First remove alias name (#*[[:space:]]) and the space after it, then + # remove any leading spaces from what's left (##[[:space:]]##), then + # remove everything except the first word that's in the left line + # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") + FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" + else + FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" + fi + if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "browse" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "mr" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "project" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "snippet" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci-status" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "compare" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "create" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "delete" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fork" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "issue" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pr" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull-request" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "release" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "sync" ]]; then + FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") + (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) + (( this_word = next_word )) + _start_pos=$4 + return 0 + fi +fi + +chroma/-git.ch $* diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-make.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-make.ch new file mode 100644 index 0000000..e91746d --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-make.ch @@ -0,0 +1,105 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma function for command `make'. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 +local -a __lines_list reply2 + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global variables. + FAST_HIGHLIGHT[chroma-make-counter]=0 + FAST_HIGHLIGHT[chroma-make-skip-two]=0 + FAST_HIGHLIGHT[chroma-make-custom-dir]="./" + FAST_HIGHLIGHT[chroma-make-custom-file]="Makefile" + FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt]=0 + FAST_HIGHLIGHT[chroma-make-got-custom-file-opt]=0 + return 1 +} || { + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* || "$__wrd" = *=* ]]; then + [[ "$__wrd" = *=* ]] && { + __style=${FAST_THEME_NAME}variable + } || { + __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} + } + + if [[ "$__wrd" = (-I|-o|-W) ]]; then + FAST_HIGHLIGHT[chroma-make-skip-two]=1 + elif [[ "$__wrd" = "-C" ]]; then + FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt]=1 + elif [[ "$__wrd" = "-f" ]]; then + FAST_HIGHLIGHT[chroma-make-got-custom-file-opt]=1 + fi + else + if (( FAST_HIGHLIGHT[chroma-make-skip-two] )); then + FAST_HIGHLIGHT[chroma-make-skip-two]=0 + elif (( FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt] )); then + FAST_HIGHLIGHT[chroma-make-got-custom-dir-opt]=0 + FAST_HIGHLIGHT[chroma-make-custom-dir]="$__wrd" + elif (( FAST_HIGHLIGHT[chroma-make-got-custom-file-opt] )); then + FAST_HIGHLIGHT[chroma-make-got-custom-file-opt]=0 + FAST_HIGHLIGHT[chroma-make-custom-file]="$__wrd" + else + # Count non-option tokens. + (( FAST_HIGHLIGHT[chroma-make-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-make-counter] )) + if (( FAST_HIGHLIGHT[chroma-make-counter] == 1 )); then + __wrd="${__wrd//\`/x}" + __wrd="${(Q)__wrd}" + + if [[ -f "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" ]] && \ + .fast-make-targets < "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" + then + if [[ "${reply2[(r)$__wrd]}" ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + else + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + fi + fi + else + # Pass-through to the big-loop outside + return 1 + fi + fi + fi +} + +# Add region_highlight entry (via `reply' array) +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does) and skip setting __style +# to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nice.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nice.ch new file mode 100644 index 0000000..7fa8a94 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nice.ch @@ -0,0 +1,138 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 Sebastian Gniazdowski +# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) +# All rights reserved. +# +# The only licensing for this file follows. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- + +setopt local_options extendedglob warn_create_global typeset_silent + +# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. +# So the below 8192 assignment takes care that next token will be routed to chroma. +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style option_start=0 option_end=0 number_start=0 number_end=0 +local -a match mbegin mend + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global string variables. + FAST_HIGHLIGHT[nice-arg-count]=0 + FAST_HIGHLIGHT[nice-increment-argument]=0 + + # Set style for region_highlight entry. It is used below in + # '[[ -n "$__style" ]] ...' line, which adds highlight entry, + # like "10 12 fg=green", through `reply' array. + # + # Could check if command `example' exists and set `unknown-token' + # style instead of `command' + __style=${FAST_THEME_NAME}precommand + +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if (( FAST_HIGHLIGHT[nice-increment-argument] )); then + (( FAST_HIGHLIGHT[nice-increment-argument] = 0 )) + [[ $__wrd = (-|+|)[0-9]## ]] \ + && __style=${FAST_THEME_NAME}mathnum \ + || __style=${FAST_THEME_NAME}incorrect-subtle + else + case $__wrd in + -(-|+|)[0-9]##) + (( option_start = __start_pos-${#PREBUFFER} , + option_end = option_start+1 , + number_start = option_end , + number_end = __end_pos-${#PREBUFFER} )) + option_style=${FAST_THEME_NAME}single-hyphen-option + ;; + (#b)(--adjustment)(=(-|+|)[0-9]#|)) + (( option_start = __start_pos-${#PREBUFFER} , + option_end = option_start+mend[1] )) + option_style=${FAST_THEME_NAME}double-hyphen-option + [[ -z $match[2] ]] \ + && (( FAST_HIGHLIGHT[nice-increment-argument] = 1 )) \ + || (( option_end += 1 , + number_start = option_start+mbegin[2]-mbegin[1]+1 , + number_end = __end_pos-${#PREBUFFER} )) + ;; + -n) + __style=${FAST_THEME_NAME}double-hyphen-option + FAST_HIGHLIGHT[nice-increment-argument]=1 + ;; + --*) + __style=${FAST_THEME_NAME}double-hyphen-option + ;; + -*) + __style=${FAST_THEME_NAME}single-hyphen-option + ;; + *) + this_word=1 + next_word=2 + return 1 + ;; + esac + + (( option_start > 0 && option_end )) \ + && reply+=("$option_start $option_end ${FAST_HIGHLIGHT_STYLES[$option_style]}") + (( number_start > 0 && number_end )) \ + && reply+=("$number_start $number_end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]}") + fi +} + +# Add region_highlight entry (via `reply' array). +# If 1 will be added to __start_pos, this will highlight "oken". +# If 1 will be subtracted from __end_pos, this will highlight "toke". +# $PREBUFFER is for specific situations when users does command \ +# i.e. when multi-line command using backslash is entered. +# +# This is a common place of adding such entry, but any above code can do +# it itself (and it does in other chromas) and skip setting __style to +# this way disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves. +# _start_pos=$_end_pos advainces pointers in command line buffer. +# +# To pass through means to `return 1'. The highlighting of +# this single token is then done by fast-syntax-highlighting's +# main code and chroma doesn't have to do anything. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nmcli.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nmcli.ch new file mode 100644 index 0000000..be444e5 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-nmcli.ch @@ -0,0 +1,58 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +typeset -A subcommands +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" subcommand +subcommands=( + help "_" + general "help status hostname permissions logging _" + networking "help on off connectivity _" + radio "help all wifi wwan _" + connection "help show up down add modify clone edit delete monitor reload load import export _" + device "help status show set connect reapply modify disconnect delete monitor wifi lldp _" + agent "help secret polkit all _" + monitor "help _" + _ "_" +) + +if (( __first_call )); then + FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]="" + FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]="" + return 1 +elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +elif [[ "$2" = -* ]]; then + return 1 +elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]} ]]; then + for subcommand in ${(@k)subcommands}; do + [[ $subcommand = $__wrd* ]] && break || subcommand="_" + done + if [[ $subcommand = _ ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + else + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") + fi + FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]="$subcommand" +elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]} ]]; then + for subcommand in ${(s. .)subcommands[${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]}]}; do + [[ "$subcommand" = $__wrd* ]] && break || subcommand="_" + done + if [[ $subcommand = _ ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + else + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") + fi + FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]="$subcommand" +else + return 1 +fi + +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-node.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-node.ch new file mode 100644 index 0000000..65f214c --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-node.ch @@ -0,0 +1,37 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style + +if (( __first_call )); then + FAST_HIGHLIGHT[chroma-node-file]=1 +elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +elif [[ "$__wrd" = -- ]]; then + FAST_HIGHLIGHT[chroma-node-file]=2 +elif (( FAST_HIGHLIGHT[chroma-node-file] != 2 )) && [[ "$__wrd" = -* ]]; then + if [[ "$__wrd" = -*e* || "$__wrd" = --eval ]]; then + FAST_HIGHLIGHT[chroma-node-file]=0 + fi +elif (( FAST_HIGHLIGHT[chroma-node-file] )); then + if [[ "$__wrd" = debug || "$__wrd" = inspect ]]; then + __style=${FAST_THEME_NAME}subcommand + else + FAST_HIGHLIGHT[chroma-node-file]=0 + if [[ -f ${~__wrd} || -f ${~__wrd}.js || -f ${~__wrd}/index.js ]]; then + __style=${FAST_THEME_NAME}path + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + fi + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + (( this_word = next_word )) + _start_pos=$_end_pos + + return 0 +fi + +return 1 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ogit.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ogit.ch new file mode 100644 index 0000000..6f76674 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ogit.ch @@ -0,0 +1,383 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# Copyright (c) 2018 plexigras +# +# The old chroma function for command `git'. It colorizes the part of command +# line that holds `git' invocation. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 +local -a __lines_list chroma_git_remote_subcommands +chroma_git_remote_subcommands=(add rename remove set-head set-branches get-url set-url set-url set-url show prune update) + +if (( __first_call )); then + # Called for the first time - new command + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global variables + FAST_HIGHLIGHT[chroma-git-counter]=0 + FAST_HIGHLIGHT[chroma-git-got-subcommand]=0 + FAST_HIGHLIGHT[chroma-git-subcommand]="" + FAST_HIGHLIGHT[chrome-git-got-msg1]=0 + FAST_HIGHLIGHT[chrome-git-got-anymsg]=0 + FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=0 + FAST_HIGHLIGHT[chroma-git-checkout-new]=0 + FAST_HIGHLIGHT[chroma-git-fetch-multiple]=0 + FAST_HIGHLIGHT[chroma-git-branch-change]=0 + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 + return 1 +else + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if [[ "$__wrd" = "--" ]]; then + FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=1 + __style=${FAST_THEME_NAME}double-hyphen-option + elif [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-git-got-subcommand]} -eq 0 ]]; then + # Options occuring before a subcommand + if (( FAST_HIGHLIGHT[chroma-git-option-with-argument-active] == 0 )); then + if [[ "$__wrd" = -[^[:space:]-]#C ]]; then + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=2 + elif [[ "$__wrd" = -[^[:space:]-]#c ]]; then + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=1 + fi + fi + return 1 + else + # If at e.g. '>' or destination/source spec (of the redirection) + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + # If at main git option taking argument in a separate word (-C and -c) + elif (( FAST_HIGHLIGHT[chroma-git-option-with-argument-active] > 0 && \ + 0 == FAST_HIGHLIGHT[chroma-git-got-subcommand] )) + then + # Remember the value + __idx2=${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]} + # Reset the is-argument mark-field + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 + + (( __idx2 == 2 )) && return 1 + # Other options' args (i.e. arg of -c) aren't routed to the big-loop + # as they aren't paths and aren't handled in any special way there + elif (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then + FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 + + # Check if the command is an alias - we want to highlight the + # aliased command just like the target command of the alias + .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 10 * 60 )) + # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix + __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) + + if (( ${#__lines_list} > 0 )); then + # (*) + # First remove alias name (#*[[:space:]]) and the space after it, then + # remove any leading spaces from what's left (##[[:space:]]##), then + # remove everything except the first word that's in the left line + # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") + FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" + else + FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" + fi + if (( __start_pos >= 0 )); then + # if subcommand exists + LANG=C .fast-run-command "git help -a" chroma-git-subcmd-list "" $(( 10 * 60 )) + # (s: :) will split on every space, but because the expression + # isn't double-quoted, the empty elements will be eradicated + # Some further knowledge-base: s-flag is special, it skips + # empty elements and creates an array (not a concatenated + # string) even when double-quoted. The normally needed @-flag + # that logically breaks the concaetnated string back into array + # in case of double-quoting has additional effect for s-flag: + # it finally blocks empty-elements eradication. + if [[ "${__lines_list[1]}" = See* ]]; then + # (**) + # git >= v2.20 + __lines_list=( ${(M)${${${(M)__lines_list[@]:# [[:blank:]]#[a-z]*}##[[:blank:]]##}%%[[:blank:]]##*}:#${FAST_HIGHLIGHT[chroma-git-subcommand]}} ) + else + # (**) + # git < v2.20 + __lines_list=( ${(M)${(s: :)${(M)__lines_list[@]:# [a-z]*}}:#${FAST_HIGHLIGHT[chroma-git-subcommand]}} ) + fi + + # Above we've checked: + # 1) If given subcommand is an alias (*) + # 2) If the command, or command pointed by the alias, exists (**) + # 3) There's little problem, git v2.20 outputs aliases in git help -a, + # which means that alias will be recognized as correct if it will + # point at another alias or on itself. That's a minor problem, a + # TODO for future planned optimization for v2.20 Git + # 4) Notice that the above situation is better than the previous - the + # alias is being verified to point to a valid git subcommand + # That's all that's needed to decide on the correctnes: + if (( ${#__lines_list} > 0 )); then + __style=${FAST_THEME_NAME}subcommand + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + fi + # The counter includes the subcommand itself + (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) + else + __wrd="${__wrd//\`/x}" + __arg="${__arg//\`/x}" + __wrd="${(Q)__wrd}" + if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "push" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fetch" ]] \ + && (( ${FAST_HIGHLIGHT[chroma-git-fetch-multiple]} == 0 )); then + # if not option + if [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" -eq 1 ]]; then + (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) + if (( __idx1 == 2 )); then + .fast-run-git-command "git remote" "chroma-git-remotes" "" + else + __wrd="${__wrd%%:*}" + .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads" + fi + # if remote/ref exists + if [[ -n ${__lines_list[(r)$__wrd]} ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + # if ref (__idx1 == 3) does not exist and subcommand is push + elif (( __idx1 != 2 )) && [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "push" ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + # if not existing remote name, because not an URL (i.e. no colon) + elif [[ $__idx1 -eq 2 && $__wrd != *:* ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + fi + # if option + else + if [[ "$__wrd" = "--multiple" && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fetch" ]]; then + FAST_HIGHLIGHT[chroma-git-fetch-multiple]=1 + __style=${FAST_THEME_NAME}double-hyphen-option + else + return 1 + fi + fi + elif (( ${FAST_HIGHLIGHT[chroma-git-fetch-multiple]} )) \ + && [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" -eq 1 ]]; then + .fast-run-git-command "git remote" "chroma-git-remotes" "" + if [[ -n ${__lines_list[(r)$__wrd]} ]]; then + __style=${FAST_THEME_NAME}correct-subtle + fi + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "commit" ]]; then + match[1]="" + match[2]="" + # if previous argument is -m or current argument is --message=something + if (( FAST_HIGHLIGHT[chrome-git-got-msg1] == 1 && ! FAST_HIGHLIGHT[chrome-git-got-anymsg] )) \ + || [[ "$__wrd" = (#b)(--message=)(*) && "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 ]]; then + FAST_HIGHLIGHT[chrome-git-got-msg1]=0 + FAST_HIGHLIGHT[chrome-git-got-anymsg]=1 + if [[ -n "${match[1]}" ]]; then + __wrd="${(Q)${match[2]//\`/x}}" + # highlight (--message=)something + (( __start=__start_pos-${#PREBUFFER}, __end=__start_pos-${#PREBUFFER}+10, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") + # highlight --message=(something) + (( __start=__start_pos-${#PREBUFFER}+10, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") + else + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") + fi + local __firstline=${__wrd%%$'\n'*} + if (( ${#__firstline} > 50 )); then + for (( __idx1 = 1, __idx2 = 1; __idx1 <= 50; ++ __idx1, ++ __idx2 )); do + while [[ "${__arg[__idx2]}" != "${__firstline[__idx1]}" ]]; do + (( ++ __idx2 )) + (( __idx2 > __asize )) && { __idx2=-1; break; } + done + (( __idx2 == -1 )) && break + done + if (( __idx2 != -1 )); then + if [[ -n "${match[1]}" ]]; then + (( __start=__start_pos-${#PREBUFFER}+__idx2, __end=__end_pos-${#PREBUFFER}-$#__wrd+$#__firstline-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + else + (( __start=__start_pos-${#PREBUFFER}+__idx2-1, __end=__end_pos-${#PREBUFFER}-$#__wrd+$#__firstline-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + fi + fi + fi + # if before -- + elif [[ "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 ]]; then + if [[ "$__wrd" = -[^[:space:]-]#m ]]; then + FAST_HIGHLIGHT[chrome-git-got-msg1]=1 + __style=${FAST_THEME_NAME}single-hyphen-option + else + return 1 + fi + # if after -- is file + elif [[ -e "$__wrd" ]]; then + __style=${FAST_THEME_NAME}path + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" ]] \ + || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "revert" ]] \ + || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "merge" ]] \ + || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]] \ + || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "reset" ]] \ + || [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "rebase" ]]; then + + # if doing `git checkout -b ...' + if [[ "$__wrd" = -[^[:space:]-]#b && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" ]]; then + FAST_HIGHLIGHT[chroma-git-checkout-new]=1 + __style=${FAST_THEME_NAME}single-hyphen-option + # if command is not checkout -b something + elif [[ "${FAST_HIGHLIGHT[chroma-git-checkout-new]}" = 0 ]]; then + # if not option + if [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 1 ]]; then + (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) + if (( __idx1 == 2 )) || \ + [[ "$__idx1" = 3 && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]]; then + # if is ref + if command git rev-parse --verify --quiet "$__wrd" >/dev/null 2>&1; then + __style=${FAST_THEME_NAME}correct-subtle + # if is file and subcommand is checkout or diff + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "reset" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]] && [[ -e ${~__wrd} ]]; then + __style=${FAST_THEME_NAME}path + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" && \ + "1" = "$(command git rev-list --count --no-walk --glob="refs/remotes/${$(git \ + config --get checkout.defaultRemote):-*}/$__wrd")" ]] + then + __style=${FAST_THEME_NAME}correct-subtle + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + fi + # if option + else + return 1 + fi + # if option + elif [[ "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 && "$__wrd" = -* ]]; then + return 1 + fi + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "remote" && "$__wrd" != -* ]]; then + (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) + if [[ "$__idx1" = 2 ]]; then + if (( ${chroma_git_remote_subcommands[(I)$__wrd]} )); then + FAST_HIGHLIGHT[chroma-git-remote-subcommand]="$__wrd" + __style=${FAST_THEME_NAME}subcommand + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + elif [[ "$__idx1" = 3 && "$FAST_HIGHLIGHT[chroma-git-remote-subcommand]" = "add" ]]; then + .fast-run-git-command "git remote" "chroma-git-remotes" "" + if [[ -n ${__lines_list[(r)$__wrd]} ]]; then + __style=${FAST_THEME_NAME}incorrect-subtle + fi + elif [[ "$__idx1" = 3 && -n "$FAST_HIGHLIGHT[chroma-git-remote-subcommand]" ]]; then + .fast-run-git-command "git remote" "chroma-git-remotes" "" + if [[ -n ${__lines_list[(r)$__wrd]} ]]; then + __style=${FAST_THEME_NAME}correct-subtle + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + fi + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "branch" ]]; then + if [[ "$__wrd" = --delete \ + || "$__wrd" = --edit-description \ + || "$__wrd" = --set-upstream-to=* \ + || "$__wrd" = --unset-upstream \ + || "$__wrd" = -[^[:space:]-]#d \ + || "$__wrd" = -[^[:space:]-]#D ]]; then + FAST_HIGHLIGHT[chroma-git-branch-change]=1 + return 1 + elif [[ "$__wrd" != -* ]]; then + .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads" + if [[ -n ${__lines_list[(r)$__wrd]} ]]; then + __style=${FAST_THEME_NAME}correct-subtle + elif (( FAST_HIGHLIGHT[chroma-git-branch-change] )); then + __style=${FAST_THEME_NAME}incorrect-subtle + fi + else + return 1 + fi + elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "tag" ]]; then + if [[ "${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}" -le 0 ]]; then + if [[ "$__wrd" = -[^[:space:]-]#(u|m) ]]; then + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=1 + elif [[ "$__wrd" = -[^[:space:]-]#F ]]; then + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=2 + elif [[ "$__wrd" = -[^[:space:]-]#d ]]; then + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=3 + elif [[ "$__wrd" = (--contains|--no-contains|--points-at|--merged|--no-merged) ]]; then + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=4 + fi + if [[ "$__wrd" != -* ]]; then + (( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] )) + if [[ ${FAST_HIGHLIGHT[chroma-git-counter]} -eq 2 ]]; then + .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads" + .fast-run-git-command "+git tag" "chroma-git-tags" "" + [[ -n ${__lines_list[(r)$__wrd]} ]] && __style=${FAST_THEME_NAME}incorrect-subtle + elif [[ ${FAST_HIGHLIGHT[chroma-git-counter]} -eq 3 ]]; then + fi + else + return 1 + fi + else + case "${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}" in + (1) + __style=${FAST_THEME_NAME}optarg-string + ;; + (2) + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 + return 1; + ;; + (3) + .fast-run-git-command "git tag" "chroma-git-tags" "" + [[ -n ${__lines_list[(r)$__wrd]} ]] && \ + __style=${FAST_THEME_NAME}correct-subtle || \ + __style=${FAST_THEME_NAME}incorrect-subtle + ;; + (4) + if git rev-parse --verify --quiet "$__wrd" >/dev/null 2>&1; then + __style=${FAST_THEME_NAME}correct-subtle + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + ;; + esac + FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0 + fi + else + return 1 + fi + fi + fi +fi + +# Add region_highlight entry (via `reply' array) +if [[ -n "$__style" ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") +fi + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-perl.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-perl.ch new file mode 100644 index 0000000..49f0ad3 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-perl.ch @@ -0,0 +1,80 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma function for command `perl'. It highlights code passed to perl +# with -e option - does syntax check by calling `perl -ce', then highlights +# as correct or incorrect code. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global variables. + FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0 + return 1 +} || { + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-perl-got-subcommand]} -eq 0 ]]; then + __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} + + if [[ "$__wrd" = "-e" || ("$__wrd" = -*e* && "$__wrd" != --*) ]]; then + FAST_HIGHLIGHT[chrome-perl-got-eswitch]=1 + fi + else + __wrd="${__wrd//\`/x}" + __arg="${__arg//\`/x}" + __wrd="${(Q)__wrd}" + if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 1 )); then + FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0 + if perl -ce "$__wrd" >/dev/null 2>&1; then + # Add correct-subtle style + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + else + # Add incorrect-subtle style + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + fi + else + # Pass-through to the big-loop outside + return 1 + fi + fi +} + +# Add region_highlight entry (via `reply' array) +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does) and skip setting __style +# to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-precommand.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-precommand.ch new file mode 100644 index 0000000..7e85a06 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-precommand.ch @@ -0,0 +1,17 @@ +# vim:ft=zsh:et:sw=4 + +local __first_call="$1" __start_pos="$3" __end_pos="$4" + +[[ "$__arg_type" = 3 ]] && return 2 + +(( __first_call )) && { + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}precommand]}") + (( next_word = (next_word & ~2) | 4 | 1 )) +} || { + return 1 +} + +(( this_word = next_word )) +_start_pos=$_end_pos +return 0 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-printf.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-printf.ch new file mode 100644 index 0000000..89d2789 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-printf.ch @@ -0,0 +1,86 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Highlights the special sequences like "%s" in string passed to `printf'. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __val +integer __idx1 __idx2 + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-printf-counter]=0 + FAST_HIGHLIGHT[chroma-printf-counter-all]=1 + FAST_HIGHLIGHT[chroma-printf-message]="" + FAST_HIGHLIGHT[chroma-printf-skip-two]=0 + return 1 +# Following call (not first one). +} || { + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + (( FAST_HIGHLIGHT[chroma-printf-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-printf-counter-all] )) + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if [[ "$__wrd" = -* ]]; then + if [[ "$__wrd" = "-v" ]]; then + FAST_HIGHLIGHT[chroma-printf-skip-two]=1 + fi + return 1 + else + # Count non-option tokens. + if (( FAST_HIGHLIGHT[chroma-printf-skip-two] )); then + FAST_HIGHLIGHT[chroma-printf-skip-two]=0 + return 1 + else + (( FAST_HIGHLIGHT[chroma-printf-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-printf-counter] )) + if [[ "$__idx1" -eq 1 ]]; then + [[ "$__wrd" = \"* ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}") + [[ "$__wrd" = \'* ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}single-quoted-argument]}") + FSH_LIST=() # use fsh_sy_h_append function to write to FSH_LIST + : "${__wrd//(#m)\%[\#\+\ 0-]#[0-9]#([.][0-9]#)(#c0,1)[diouxXfFeEgGaAcsb]/$(( fsh_sy_h_append($MBEGIN, $MEND) ))}"; + for __val in "${FSH_LIST[@]}" ; do + __idx1=$(( __start_pos + ${__val%%;;*} )) + __idx2=__idx1+${__val##*;;}-${__val%%;;*}+1 + (( __start=__idx1-${#PREBUFFER}, __end=__idx2-${#PREBUFFER}-1, __start >= 0 )) && \ + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]}") + done + else + return 1 + fi + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above code +# can do it itself and skip setting __style to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ruby.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ruby.ch new file mode 100644 index 0000000..3495cc8 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ruby.ch @@ -0,0 +1,81 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma function for command `ruby'. It highlights code passed to ruby +# with -e option - does syntax check by calling `ruby -ce', then highlights +# as correct or incorrect code. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global variables. + FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0 + return 1 +} || { + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-ruby-got-subcommand]} -eq 0 ]]; then + __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} + + if [[ "$__wrd" = "-e" || ("$__wrd" = -*e* && "$__wrd" != --*) ]]; then + FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=1 + fi + else + __wrd="${__wrd//\`/x}" + __arg="${__arg//\`/x}" + __wrd="${(Q)__wrd}" + if (( FAST_HIGHLIGHT[chrome-ruby-got-eswitch] == 1 )); then + FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0 + if ruby -ce "$__wrd" >/dev/null 2>&1; then + # Add correct-subtle style + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") + else + # Add incorrect-subtle style + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") + fi + else + # Pass-through to the big-loop outside + return 1 + fi + FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0 + fi +} + +# Add region_highlight entry (via `reply' array) +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does) and skip setting __style +# to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-scp.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-scp.ch new file mode 100644 index 0000000..d162284 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-scp.ch @@ -0,0 +1,87 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Tracks scp command and emits message when one tries to pass port to hostspec. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __chars +integer __idx1 __idx2 +local -a __results + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-scp-counter]=0 + FAST_HIGHLIGHT[chroma-scp-counter-all]=1 + FAST_HIGHLIGHT[chroma-scp-message]="" + FAST_HIGHLIGHT[chroma-scp-skip-two]=0 + return 1 +} || { + (( FAST_HIGHLIGHT[chroma-scp-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-scp-counter-all] )) + + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + if [[ "$__wrd" = (-c|-F|-i|-l|-o|-P|-S) ]]; then + FAST_HIGHLIGHT[chroma-scp-skip-two]=1 + fi + else + # Count non-option tokens. + if (( FAST_HIGHLIGHT[chroma-scp-skip-two] )); then + FAST_HIGHLIGHT[chroma-scp-skip-two]=0 + else + (( FAST_HIGHLIGHT[chroma-scp-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-scp-counter] )) + if [[ "${FAST_HIGHLIGHT[chroma-scp-counter]}" -eq 1 ]]; then + if [[ "$__arg" = [^:]##:[0-9]## ]]; then + FAST_HIGHLIGHT[chroma-scp-message]+="Format of hostname incorrect, use -P to pass port number" + else + return 1 + fi + else + return 1 + fi + fi + fi + + if (( ${#${(z)BUFFER}} <= FAST_HIGHLIGHT[chroma-scp-counter-all] )); then + [[ -n "${FAST_HIGHLIGHT[chroma-scp-message]}" ]] && zle -M "${FAST_HIGHLIGHT[chroma-scp-message]}" + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above code +# can do it itself and skip setting __style to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-sh.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-sh.ch new file mode 100644 index 0000000..43fa8f9 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-sh.ch @@ -0,0 +1,72 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma function for `sh' shell. It colorizes string passed with -c option. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call=$1 __wrd=$2 __start_pos=$3 __end_pos=$4 +local __style +integer __idx1 __idx2 +local -a __lines_list + +(( __first_call )) && { + # Called for the first time - new command + FAST_HIGHLIGHT[chrome-git-got-c]=0 + return 1 +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ $__arg_type = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + __wrd=${${${(Q)__wrd}#[\"\']}%[\"\']} + if [[ $__wrd = -* && $__wrd != -*c* ]]; then + __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option} + else + if (( FAST_HIGHLIGHT[chrome-git-got-c] == 1 )); then + for (( __idx1 = 1, __idx2 = 1; __idx2 <= __asize; ++ __idx1 )); do + [[ ${__arg[__idx2]} = ${__wrd[__idx1]} ]] && break + while [[ ${__arg[__idx2]} != ${__wrd[__idx1]} ]]; do + (( ++ __idx2 )) + (( __idx2 > __asize )) && { __idx2=0; break; } + done + (( __idx2 == 0 )) && break + [[ ${__arg[__idx2]} = ${__wrd[__idx1]} ]] && break + done + + FAST_HIGHLIGHT[chrome-git-got-c]=0 + (( _start_pos-__PBUFLEN >= 0 )) && \ + -fast-highlight-process "$PREBUFFER" "${__wrd}" "$(( __start_pos + __idx2 - 1 ))" + elif [[ $__wrd = -*c* ]]; then + FAST_HIGHLIGHT[chrome-git-got-c]=1 + else + return 1 + fi + fi +} + +# Add region_highlight entry (via `reply' array) +[[ -n $__style ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-source.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-source.ch new file mode 100644 index 0000000..dc27e76 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-source.ch @@ -0,0 +1,75 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma for `source' builtin - verifies if file to be sourced compiles +# correctly. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __chars __home=${XDG_CACHE_HOME:-$HOME/.cache}/fsh +integer __idx1 __idx2 + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-src-counter]=0 + __style=${FAST_THEME_NAME}builtin + +} || { + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + else + # Count non-option tokens. + (( FAST_HIGHLIGHT[chroma-src-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-src-counter] )) + + if (( FAST_HIGHLIGHT[chroma-src-counter] == 1 )); then + command mkdir -p "$__home" + command cp -f "${__wrd}" "$__home" 2>/dev/null && { + zcompile "$__home"/"${__wrd:t}" 2>/dev/null 1>&2 && __style=${FAST_THEME_NAME}correct-subtle || __style=${FAST_THEME_NAME}incorrect-subtle + } + elif (( FAST_HIGHLIGHT[chroma-src-counter] == 2 )); then + # Handle paths, etc. normally - just pass-through to the big + # highlighter (the main FSH highlighter, used before chromas). + return 1 + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does) and skip setting __style +# to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ssh.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ssh.ch new file mode 100644 index 0000000..879158f --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-ssh.ch @@ -0,0 +1,156 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) +# +# Tracks ssh command and emits message when one tries to pass port to hostspec. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +emulate -LR zsh +setopt extended_glob warn_create_global typeset_silent + +# This chroma guards that port number isn't passed in hostname (no :{port} occurs). + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style check_port=0 host_start_offset host_style user_style possible_host +local -a match mbegin mend completions_user completions_host + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-ssh-counter]=0 + FAST_HIGHLIGHT[chroma-ssh-counter-all]=1 + FAST_HIGHLIGHT[chroma-ssh-message]="" + FAST_HIGHLIGHT[chroma-ssh-skip-two]=0 + return 1 +} || { + # Following call, i.e. not the first one. + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + (( FAST_HIGHLIGHT[chroma-ssh-counter-all] += 1 )) + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + if [[ "$__wrd" = (-b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-O|-o|-p|Q|R|-S|-W|-w) ]]; then + FAST_HIGHLIGHT[chroma-ssh-skip-two]=1 + fi + else + if (( FAST_HIGHLIGHT[chroma-ssh-skip-two] )); then + FAST_HIGHLIGHT[chroma-ssh-skip-two]=0 + else + # Count non-option tokens. + (( FAST_HIGHLIGHT[chroma-ssh-counter] += 1 )) + if [[ "${FAST_HIGHLIGHT[chroma-ssh-counter]}" -eq 1 ]]; then + if [[ $__arg = (#b)(([^@]#)(@)|)(*) ]] + then + [[ -n $match[2] ]] \ + && { + user_style= + () { + # Zstyle clobbers reply for sure + zstyle -a ":completion:*:users" users completions_users + } + (( ! $#completions_users )) && completions_users=(${(k)userdirs}) + if (( $#completions_users )); then + [[ $match[2] = ${~${:-(${(j:|:)completions_users})}} ]] \ + && user_style=${FAST_THEME_NAME}correct-subtle \ + || user_style=${FAST_THEME_NAME}incorrect-subtle + fi + [[ -n $user_style ]] \ + && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-(mend[5]-mend[2]), __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$user_style]}") + } + [[ -n $match[3] ]] \ + && (( __start=__start_pos-${#PREBUFFER}+(mbegin[3]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[5]-mend[3]), __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subtle-separator]}") + + host_style= + case $match[4] in + (<->|<0-255>.<0-255>.<0-255>.<0-255>) + host_style=${FAST_THEME_NAME}mathnum + check_port=1 + ;; + (([0-9a-fA-F][0-9a-fA-F:]#|)::([0-9a-fA-F:]#[0-9a-fA-F]|)|[0-9a-fA-F]##:[0-9a-fA-F:]#[0-9a-fA-F]) + host_style=${FAST_THEME_NAME}mathnum + ;; + (*) + check_port=1 + ;; + esac + possible_host=$match[4] + (( host_start_offset = mbegin[4] - mbegin[1], host_end_offset = 0 )) + + if (( check_port )) && [[ $possible_host = (#b)(*)(:[0-9]##) ]]; then + (( __start=__start_pos-${#PREBUFFER}+(host_start_offset+mbegin[2]-mbegin[1]), __end=__end_pos-host_end_offset-${#PREBUFFER}, __start >= 0, + host_end_offset+=mend[2]-mend[1] )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") \ + && possible_host=$match[1] \ + && FAST_HIGHLIGHT[chroma-ssh-message]+="Format of hostname incorrect, use -p to pass port number" + + fi + + if [[ -z $host_style ]]; then + () { + # Zstyle clobbers reply for sure + local mbegin mend match reply + zstyle -a ":completion:*:hosts" hosts completions_host + } + (( ! $#completions_host && $+_cache_hosts )) && completions_host=($_cache_hosts[*]) + if (( $#completions_host )); then + [[ $possible_host = ${~${:-(${(j:|:)completions_host})}} ]] \ + && host_style=${FAST_THEME_NAME}correct-subtle \ + || host_style=${FAST_THEME_NAME}incorrect-subtle + fi + fi + + [[ -n $host_style ]] \ + && (( __start=__start_pos-${#PREBUFFER}+host_start_offset, __end=__end_pos-${#PREBUFFER}-host_end_offset, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$host_style]}") + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + + (( next_word = 1 )) + + fi + fi + fi + + if (( ${#${(z)BUFFER}} <= FAST_HIGHLIGHT[chroma-ssh-counter-all] )); then + [[ -n "${FAST_HIGHLIGHT[chroma-ssh-message]}" ]] && zle -M "${FAST_HIGHLIGHT[chroma-ssh-message]}" + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above code +# can do it itself and skip setting __style to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subcommand.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subcommand.ch new file mode 100644 index 0000000..0665548 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subcommand.ch @@ -0,0 +1,25 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" + +if (( __first_call )); then + FAST_HIGHLIGHT[chroma-subcommand]="" + return 1 +elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +elif [[ "$2" = -* ]]; then + return 1 +elif [[ -z "${FAST_HIGHLIGHT[chroma-subcommand]}" ]]; then + FAST_HIGHLIGHT[chroma-subcommand]="$__wrd" + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") +else + return 1 +fi + +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subversion.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subversion.ch new file mode 100644 index 0000000..4149cc6 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-subversion.ch @@ -0,0 +1,250 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 Sebastian Gniazdowski +# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub) +# All rights reserved. +# +# The only licensing for this file follows. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- + +→chroma/-subversion.ch/parse-revision() { + setopt local_options extendedglob warn_create_global typeset_silent + local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end + case $__wrd in + (r|)[0-9]##) __style=${FAST_THEME_NAME}mathnum ;; + (HEAD|BASE|COMITTED|PREV)) __style=${FAST_THEME_NAME}correct-subtle ;; + '{'[^}]##'}') __style=${FAST_THEME_NAME}subtle-bg ;; + *) __style=${FAST_THEME_NAME}incorrect-subtle ;; + esac + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") +} + +→chroma/-subversion.ch/parse-target() { + setopt local_options extendedglob warn_create_global typeset_silent + local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end + if [[ $__wrd == *@[^/]# ]] + then + local place=${__wrd%@[^/]#} + local rev=$__wrd[$(($#place+2)),$#__wrd] + if [[ -e $place ]]; then + local __style + [[ -d $place ]] && __style="${FAST_THEME_NAME}path-to-dir" || __style="${FAST_THEME_NAME}path" + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-$#rev-1, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + fi + (( __start=__start_pos-${#PREBUFFER}+$#place, __end=__end_pos-${#PREBUFFER}-$#rev, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}") + →chroma/-subversion.ch/parse-revision $rev $((__start_pos+$#place+1)) $__end_pos + else + return 1 + fi +} + +setopt local_options extendedglob warn_create_global + +# Keep chroma-takever state meaning: until ;, handle highlighting via chroma. +# So the below 8192 assignment takes care that next token will be routed to chroma. +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style +integer __idx1 __idx2 + +(( __first_call )) && { + # Called for the first time - new command. + # FAST_HIGHLIGHT is used because it survives between calls, and + # allows to use a single global hash only, instead of multiple + # global string variables. + FAST_HIGHLIGHT[subversion-command]=$__wrd + FAST_HIGHLIGHT[subversion-option-argument]= + FAST_HIGHLIGHT[subversion-subcommand]= + FAST_HIGHLIGHT[subversion-subcommand-arguments]=0 + + # Set style for region_highlight entry. It is used below in + # '[[ -n "$__style" ]] ...' line, which adds highlight entry, + # like "10 12 fg=green", through `reply' array. + # + # Could check if command `example' exists and set `unknown-token' + # style instead of `command' + __style=${FAST_THEME_NAME}command + +} || { + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + case $FAST_HIGHLIGHT[subversion-command]/$FAST_HIGHLIGHT[subversion-subcommand] in + svn/) + case $__wrd in + --username|-u) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --password|-p) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --config-(dir|option)) FAST_HIGHLIGHT[subversion-option-argument]=any;; + esac + ;; + svn/?*) + case $__wrd in + --accept) FAST_HIGHLIGHT[subversion-option-argument]=accept;; + --change|-c) FAST_HIGHLIGHT[subversion-option-argument]=revision;; + --changelist|--cl) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --(set-|)depth) FAST_HIGHLIGHT[subversion-option-argument]=depth;; + --diff(3|)-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;; + --editor-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;; + --encoding) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --file) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --limit|-l) FAST_HIGHLIGHT[subversion-option-argument]=number;; + --message|-m) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --native-eol) FAST_HIGHLIGHT[subversion-option-argument]=eol;; + --new|--old) FAST_HIGHLIGHT[subversion-option-argument]=target;; + --revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;; + --show-revs) FAST_HIGHLIGHT[subversion-option-argument]=show-revs;; + --strip) FAST_HIGHLIGHT[subversion-option-argument]=number;; + --with-revprop) FAST_HIGHLIGHT[subversion-option-argument]=revprop;; + esac + ;; + svnadmin/*) + case $__wrd in + --config-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --fs-type) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --memory-cache-size|-M) FAST_HIGHLIGHT[subversion-option-argument]=number;; + --parent-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;; + --revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;; + esac + ;; + svndumpfilter/*) + case $__wrd in + --targets) FAST_HIGHLIGHT[subversion-option-argument]=any;; + esac + ;; + esac + elif [[ -n $FAST_HIGHLIGHT[subversion-option-argument] ]]; then + case $FAST_HIGHLIGHT[subversion-option-argument] in + any) + FAST_HIGHLIGHT[subversion-option-argument]= + return 1 + ;; + accept) + [[ $__wrd = (p(|ostpone)|e(|dit)|l(|aunch)|base|working|recommended|[mt][cf]|(mine|theirs)-(conflict|full)) ]] \ + && __style=${FAST_THEME_NAME}correct-subtle \ + || __style=${FAST_THEME_NAME}incorrect-subtle + ;; + depth) + [[ $__wrd = (empty|files|immediates|infinity) ]] \ + && __style=${FAST_THEME_NAME}correct-subtle \ + || __style=${FAST_THEME_NAME}incorrect-subtle + ;; + number) + [[ $__wrd = [0-9]## ]] \ + && __style=${FAST_THEME_NAME}mathnum \ + || __style=${FAST_THEME_NAME}incorrect-subtle + ;; + eol) + [[ $__wrd = (CR(|LF)|LF) ]] \ + && __style=${FAST_THEME_NAME}correct-subtle \ + || __style=${FAST_THEME_NAME}incorrect-subtle + ;; + show-revs) + [[ $__wrd = (merged|eligible) ]] \ + && __style=${FAST_THEME_NAME}correct-subtle \ + || __style=${FAST_THEME_NAME}incorrect-subtle + ;; + revision) + →chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos + ;; + revision-pair) + local -a match mbegin mend + if [[ $__wrd = (#b)(\{[^}]##\}|[^:]##)(:)(*) ]]; then + →chroma/-subversion.ch/parse-revision $match[1] $__start_pos $(( __end_pos - ( mend[3]-mend[2] ) - 1 )) + →chroma/-subversion.ch/parse-revision $match[3] $(( __start_pos + ( mbegin[3]-mbegin[1] ) )) $__end_pos + (( __start=__start_pos-${#PREBUFFER}+(mbegin[2]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[3]-mend[2]), __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}") + else + →chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos + fi + ;; + target) + →chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $? + ;; + cmd) + this_word=1 + return 1 + ;; + esac + FAST_HIGHLIGHT[subversion-option-argument]= + elif [[ -z $FAST_HIGHLIGHT[subversion-subcommand] ]] + then + FAST_HIGHLIGHT[subversion-subcommand]=$__wrd + local subcmds + case $FAST_HIGHLIGHT[subversion-command] in + svn) subcmds='(add|auth|blame|praise|annotate|ann|cat|changelist|cl|checkout|co|cleanup|commit|ci|copy|cp|delete|del|remove|rm|diff|di|export|help|\?|h|import|info|list|ls|lock|log|merge|mergeinfo|mkdir|move|mv|rename|ren|patch|propdel|pdel|pd|propedit|pedit|pe|propget|pget|pg|proplist|plist|pl|propset|pset|ps|relocate|resolve|resolved|revert|status|stat|st|switch|sw|unlock|update|up|upgrade|x-shelf-diff|x-shelf-drop|x-shelf-list|x-shelves|x-shelf-list-by-paths|x-shelf-log|x-shelf-save|x-shelve|x-unshelve)' ;; + svnadmin) subcmds="(crashtest|create|delrevprop|deltify|dump|dump-revprops|freeze|help|\?|h|hotcopy|info|list-dblogs|list-unused-dblogs|load|load-revprops|lock|lslocks|lstxns|pack|recover|rmlocks|rmtxns|setlog|setrevprop|setuuid|unlock|upgrade|verify)";; + svndumpfilter) subcmds='(include|exclude|help|\?)';; + esac + [[ $FAST_HIGHLIGHT[subversion-subcommand] = $~subcmds ]] \ + && __style=${FAST_THEME_NAME}subcommand \ + || __style=${FAST_THEME_NAME}incorrect-subtle + FAST_HIGHLIGHT[subversion-subcommand-arguments]=0 + else + (( FAST_HIGHLIGHT[subversion-subcommand-arguments]+=1 )) + if [[ ( $FAST_HIGHLIGHT[subversion-subcommand] == (checkout|co|export|log|merge|switch|sw) && $FAST_HIGHLIGHT[subversion-subcommand-arguments] -eq 1 ) \ + || $FAST_HIGHLIGHT[subversion-subcommand] == (blame|praise|annotate|ann|cat|copy|cp|diff|info|list|ls|mergeinfo) ]]; then + →chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $? + else + return 1 + fi + fi +} + +# Add region_highlight entry (via `reply' array). +# If 1 will be added to __start_pos, this will highlight "oken". +# If 1 will be subtracted from __end_pos, this will highlight "toke". +# $PREBUFFER is for specific situations when users does command \ +# i.e. when multi-line command using backslash is entered. +# +# This is a common place of adding such entry, but any above code can do +# it itself (and it does in other chromas) and skip setting __style to +# this way disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through, do obligatory things ourselves. +# _start_pos=$_end_pos advainces pointers in command line buffer. +# +# To pass through means to `return 1'. The highlighting of +# this single token is then done by fast-syntax-highlighting's +# main code and chroma doesn't have to do anything. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-vim.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-vim.ch new file mode 100644 index 0000000..b3fecd1 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-vim.ch @@ -0,0 +1,51 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Chroma for vim, shows last opened files under prompt. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __chars +integer __idx1 __idx2 +local -a __viminfo + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + (( ${+commands[vim]} )) && __style=${FAST_THEME_NAME}command || __style=${FAST_THEME_NAME}unknown-token + + { __viminfo=( ${(f)"$(<$HOME/.viminfo)"} ); } >> /dev/null + __viminfo=( "${${(M)__viminfo[@]:#>*}[@]:t}" ) + __viminfo=( "${__viminfo[@]:#COMMIT_EDITMSG}" ) + zle -M "Last opened:"$'\n'"${(F)__viminfo[1,5]}" +} || { + # Pass almost everything to big loop + return 1 +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above +# code can do it itself (and it does, see other chromas) and +# skip setting __style to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-whatis.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-whatis.ch new file mode 100644 index 0000000..993f989 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-whatis.ch @@ -0,0 +1,138 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018-2019 Sebastian Gniazdowski + +(( next_word = 2 | 8192 )) +local THEFD check __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style + +(( ! ${+FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]} )) && \ + FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]=0 + +(( ! ${+FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]} )) && { + is-at-least 5.0.6 && local __res=1 || local __res=0 + FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]="$__res" +} + +-fast-whatis-chroma-callback() { + emulate -L zsh + setopt extendedglob warncreateglobal typesetsilent + + local THEFD="$1" input check=2 nl=$'\n' __wrd __style + + .fast-zts-read-all "$THEFD" input + + zle -F "$THEFD" + exec {THEFD}<&- + + __wrd="${${input#[^$nl]#$nl}%%$nl*}" + if [[ "$input" = test* ]]; then + if [[ "${input%$nl}" = *[^0-9]'0' ]]; then + if [[ "${input#test$nl}" = *nothing\ appropriate* ]]; then + FAST_HIGHLIGHT[whatis_chroma_type]=2 + else + FAST_HIGHLIGHT[whatis_chroma_type]=0 + fi + else + FAST_HIGHLIGHT[whatis_chroma_type]=1 + fi + elif [[ "$input" = type2* ]]; then + [[ "$input" != *nothing\ appropriate* ]] && check=1 || check=0 + elif [[ "$input" = type1* ]]; then + [[ "${input%$nl}" = *0 ]] && check=1 || check=0 + fi + + if (( check != 2 )); then + FAST_HIGHLIGHT[whatis-cache-$__wrd]=$check + if (( check )) then + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]} + elif [[ ${~__wrd} = */* && -e ${~__wrd} ]] then + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} + else + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]} + fi + local -a start_end + start_end=( ${(s:/:)${${(M)${${input#type?${nl}[^$nl]#$nl}}#*$nl}%$nl}} ) + (( start_end[1] >= 0 )) && region_highlight+=("$start_end[1] $start_end[2] $__style") + zle -R + fi + + FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]=1 + return 0 +} + +zle -N -- -fast-whatis-chroma-callback + +if (( __first_call )) && [[ -z "${FAST_HIGHLIGHT[whatis_chroma_type]}" ]] ;then + if ! command -v whatis > /dev/null; then + FAST_HIGHLIGHT[whatis_chroma_type]=0 + return 1 + fi + + exec {THEFD}< <( + print "test" + LANG=C whatis "osx whatis fallback check" + print "$?" + ) + command true # a workaround of Zsh bug + zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback +fi + +[[ "$__arg_type" = 3 ]] && return 2 + +if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +fi + +if (( __first_call )) || [[ "$__wrd" = -* ]]; then + return 1 +elif (( ! FAST_HIGHLIGHT[whatis_chroma_type] )); then + # Return 1 (i.e. treat the argument as a path) only if the callback have + # had a chance to establish the whatis_chroma_type field + (( FAST_HIGHLIGHT[whatis_chroma_callback_was_ran] )) && return 1 +else + if [[ -z "${FAST_HIGHLIGHT[whatis-cache-$__wrd]}" ]]; then + if (( FAST_HIGHLIGHT[whatis_chroma_type] == 2 )); then + exec {THEFD}< <( + print "type2" + print "$__wrd" + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} )) + print "$__start/$__end" + LANG=C whatis "$__wrd" 2>/dev/null + ) + command true # see above + zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback + else + exec {THEFD}< <( + print "type1" + print "$__wrd" + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} )) + print "$__start/$__end" + LANG=C whatis "$__wrd" &> /dev/null + print "$?" + ) + command true + zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback + fi + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]} + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end $__style") + else + check=${FAST_HIGHLIGHT[whatis-cache-$__wrd]} + if (( check )) then + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]} + elif [[ ${~__wrd} = */* && -e ${~__wrd} ]] then + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} + elif (( FAST_HIGHLIGHT[whatis_chroma_type] )); then + __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]} + fi + [[ -n "$__style" ]] && \ + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \ + reply+=("$__start $__end $__style") + fi +fi +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4:sts=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-which.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-which.ch new file mode 100644 index 0000000..5a5d7b3 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-which.ch @@ -0,0 +1,96 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Outputs (under prompt) result of query done with `which', `type -w', +# `whence -v', `whereis', `whatis'. +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg; the token can be eg.: "grep" +# +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style __output __chars +integer __idx1 __idx2 +local -a __results + +# First call, i.e. command starts, i.e. "grep" token etc. +(( __first_call )) && { + FAST_HIGHLIGHT[chroma-which-counter]=0 + FAST_HIGHLIGHT[chroma-which-counter-all]=1 + FAST_HIGHLIGHT[chroma-which-message]="" + FAST_HIGHLIGHT[chroma-which-skip-two]=0 + __style=${FAST_THEME_NAME}command + __output="" + +# Following call (not first one). +} || { + (( FAST_HIGHLIGHT[chroma-which-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-which-counter-all] )) + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + fi + + if [[ "$__wrd" = -* ]]; then + # Detected option, add style for it. + [[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + if [[ "$__wrd" = "-x" ]]; then + FAST_HIGHLIGHT[chroma-which-skip-two]=1 + fi + else + # Count non-option tokens. + if (( FAST_HIGHLIGHT[chroma-which-skip-two] )); then + FAST_HIGHLIGHT[chroma-which-skip-two]=0 + else + (( FAST_HIGHLIGHT[chroma-which-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-which-counter] )) + if [[ "$__idx1" -eq 1 ]]; then + __chars="{" + __output="$(command which "$__wrd" 2>/dev/null)" + FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"command which: $__output" + __output="$(builtin which "$__wrd" 2>/dev/null)" + FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"builtin which: ${${${${__output[1,100]}//$'\n'/;}//$'\t'/ }//$__chars;/$__chars}${__output[101,101]:+...}" + __output="$(builtin type -w "$__wrd" 2>/dev/null)" + FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"type -w: $__output" + __output="$(builtin whence -v "$__wrd" 2>/dev/null)" + FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"whence -v: $__output" + __output="$(command whereis "$__wrd" 2>/dev/null)" + FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"whereis: $__output" + __output="$(command whatis "$__wrd" 2>/dev/null)" + __output="${${__output%%$'\n'*}//[[:blank:]]##/ }" + FAST_HIGHLIGHT[chroma-which-message]+=$'\n'"whatis: $__output" + fi + fi + fi + + if (( ${#${(z)BUFFER}} <= FAST_HIGHLIGHT[chroma-which-counter-all] )); then + [[ -n "${FAST_HIGHLIGHT[chroma-which-message]}" ]] && zle -M "${FAST_HIGHLIGHT[chroma-which-message]#$'\n'}" + fi +} + +# Add region_highlight entry (via `reply' array). +# +# This is a common place of adding such entry, but any above code +# can do it itself and skip setting __style to disable this code. +[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + +# We aren't passing-through (no return 1 occured), do obligatory things ourselves. +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-zinit.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-zinit.ch new file mode 100644 index 0000000..06637a8 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/-zinit.ch @@ -0,0 +1,378 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# Copyright (c) 2018-2019 Sebastian Gniazdowski +# +# Chroma function for command `git'. It colorizes the part of command +# line that holds `git' invocation. + +(( FAST_HIGHLIGHT[-zinit.ch-chroma-def] )) && return 1 + +FAST_HIGHLIGHT[-zinit.ch-chroma-def]=1 + +typeset -gA fsh__zinit__chroma__def +fsh__zinit__chroma__def=( + ## + ## No subcommand + ## + ## {{{ + + subcmd:NULL "NULL_0_opt" + NULL_0_opt "(-help|--help|-h) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + "subcommands" "(help|man|self-update|cd|times|zstatus|load|light|unload|snippet|ls|ice||update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|completions|cdisable|cname|cenable|cname|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|dunload|dreport|dclear|compile|uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|env-whitelist|bindkeys|module)" + + ## }}} + + # Generic actions + NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" + NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP" + + + ## + ## `ice' + ## + ## {{{ + + subcmd:ice "ICE_#_arg // NO_MATCH_#_opt" + + "ICE_#_arg" "NO-OP // ::→chroma/-zinit-check-ice-mod" + + ## }}} + + ## + ## `snippet' + ## + ## {{{ + + subcmd:snippet "SNIPPET_0_opt // SNIPPET_1_arg // NO_MATCH_#_opt // + NO_MATCH_#_arg" + + SNIPPET_0_opt "(-f|--command) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + SNIPPET_1_arg "NO-OP // ::→chroma/-zinit-verify-snippet" + + ## }}} + + ## + ## `load' + ## + ## {{{ + + "subcmd:load" + "LOAD_1_arg // LOAD_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + LOAD_1_arg "NO-OP // ::→chroma/-zinit-verify-plugin" + + LOAD_2_arg "NO-OP // ::→chroma/-zinit-verify-plugin" + + ## }}} + + ## + ## `compile|uncompile|stress|edit|glance|recall|status|cd|changes` + ## + ## {{{ + + "subcmd:(compile|uncompile|stress|edit|glance|recall|status|cd|changes)" + "PLGSNP_1_arg // PLGSNP_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + PLGSNP_1_arg "NO-OP // ::→chroma/-zinit-verify-plugin-or-snippet" + + PLGSNP_2_arg "NO-OP // ::→chroma/-zinit-verify-plugin-or-snippet" + + ## }}} + + ## + ## `update' + ## + ## {{{ + + subcmd:update "UPDATE_0_opt // PLGSNP_1_arg // PLGSNP_2_arg // + NO_MATCH_#_opt // NO_MATCH_#_arg" + + UPDATE_0_opt " + (--all|-r|--reset|-q|--quiet|-p|--parallel) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + ## }}} + + ## + ## `light' + ## + ## {{{ + + subcmd:light "LIGHT_0_opt // LOAD_1_arg // LOAD_2_arg // NO_MATCH_#_opt // + NO_MATCH_#_arg" + + LIGHT_0_opt "-b + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + ## }}} + + ## + ## `unload' + ## + ## {{{ + + subcmd:unload "UNLOAD_0_opt // UNLOAD_1_arg // UNLOAD_2_arg // NO_MATCH_#_opt // + NO_MATCH_#_arg" + + UNLOAD_0_opt "-q + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + UNLOAD_1_arg "NO-OP // ::→chroma/-zinit-verify-loaded-plugin" + + UNLOAD_2_arg "NO-OP // ::→chroma/-zinit-verify-loaded-plugin" + + ## }}} + + ## + ## `report' + ## + ## {{{ + + subcmd:report "REPORT_0_opt // UNLOAD_1_arg // UNLOAD_2_arg // NO_MATCH_#_opt // + NO_MATCH_#_arg" + + REPORT_0_opt "--all + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + ## }}} + + ## + ## `delete' + ## + ## {{{ + + "subcmd:delete" + "DELETE_0_opt // PLGSNP_1_arg // PLGSNP_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + DELETE_0_opt " + (--all|--clean|-y|--yes|-q|--quiet) + <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action" + + ## }}} + + ## + ## `cenable' + ## + ## {{{ + + subcmd:cenable "COMPLETION_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + COMPLETION_1_arg "NO-OP // ::→chroma/-zinit-verify-disabled-completion" + + ## }}} + + ## + ## `cdisable' + ## + ## {{{ + + subcmd:cdisable "DISCOMPLETION_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + DISCOMPLETION_1_arg "NO-OP // ::→chroma/-zinit-verify-completion" + + ## }}} + + + ## + ## `light' + ## + ## {{{ + + subcmd:uncompile "UNCOMPILE_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg" + + UNCOMPILE_1_arg "NO-OP // ::→chroma/-zinit-verify-compiled-plugin" + + ## }}} + + ## + ## `*' + ## + ## {{{ + + "subcmd:*" "CATCH_ALL_#_opt" + "CATCH_ALL_#_opt" "* <<>> NO-OP // ::→chroma/main-chroma-std-aopt-SEMI-action" + + ## }}} +) + +#→chroma/-zinit-first-call() { + # This is being done in the proper place - in -fast-highlight-process + #FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=0 +#} + +→chroma/-zinit-verify-plugin() { + local _scmd="$1" _wrd="$4" + + [[ -d "$_wrd" ]] && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } + + typeset -a plugins + plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) + plugins=( "${plugins[@]//---//}" ) + plugins=( "${plugins[@]:#_local/zinit}" ) + plugins=( "${plugins[@]:#custom}" ) + + [[ -n "${plugins[(r)$_wrd]}" ]] && \ + __style=${FAST_THEME_NAME}correct-subtle || \ + return 1 + #__style=${FAST_THEME_NAME}incorrect-subtle + return 0 +} + +→chroma/-zinit-verify-plugin-or-snippet() { + →chroma/-zinit-verify-plugin "$1" "" "" "$4" || \ + →chroma/-zinit-verify-snippet "$1" "" "" "$4" + return $? +} + +→chroma/-zinit-verify-loaded-plugin() { + local _scmd="$1" _wrd="$4" + typeset -a plugins absolute1 absolute2 absolute3 normal + plugins=( "${ZINIT_REGISTERED_PLUGINS[@]:#_local/zinit}" ) + normal=( "${plugins[@]:#%*}" ) + absolute1=( "${(M)plugins[@]:#%*}" ) + absolute1=( "${absolute1[@]/\%\/\//%/}" ) + local hm="${HOME%/}" + absolute2=( "${absolute1[@]/$hm/HOME}" ) + absolute3=( "${absolute1[@]/\%/}" ) + plugins=( $absolute1 $absolute2 $absolute3 $normal ) + + [[ -n "${plugins[(r)$_wrd]}" ]] && \ + __style=${FAST_THEME_NAME}correct-subtle || \ + return 1 + #__style=${FAST_THEME_NAME}incorrect-subtle + + return 0 +} + +→chroma/-zinit-verify-completion() { + local _scmd="$1" _wrd="$4" + # Find enabled completions + typeset -a completions + completions=( "${ZINIT[COMPLETIONS_DIR]}"/_*(N:t) ) + completions=( "${completions[@]#_}" ) + + [[ -n "${completions[(r)${_wrd#_}]}" ]] && \ + __style=${FAST_THEME_NAME}correct-subtle || \ + return 1 + + return 0 +} + +→chroma/-zinit-verify-disabled-completion() { + local _scmd="$1" _wrd="$4" + # Find enabled completions + typeset -a completions + completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_]*(N:t) ) + + [[ -n "${completions[(r)${_wrd#_}]}" ]] && \ + __style=${FAST_THEME_NAME}correct-subtle || \ + return 1 + + return 0 +} + +→chroma/-zinit-verify-compiled-plugin() { + local _scmd="$1" _wrd="$4" + + typeset -a plugins + plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N) ) + + typeset -a show_plugins p matches + for p in "${plugins[@]}"; do + matches=( $p/*.zwc(N) ) + if [ "$#matches" -ne "0" ]; then + p="${p:t}" + [[ "$p" = (_local---zinit|custom) ]] && continue + p="${p//---//}" + show_plugins+=( "$p" ) + fi + done + + [[ -n "${show_plugins[(r)$_wrd]}" ]] && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + return 1 +} + +→chroma/-zinit-verify-snippet() { + local _scmd="$1" url="$4" dirname local_dir + url="${${url#"${url%%[! $'\t']*}"}%/}" + id_as="${FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]:-${ZINIT_ICE[id-as]:-$url}}" + + filename="${${id_as%%\?*}:t}" + dirname="${${id_as%%\?*}:t}" + local_dir="${${${id_as%%\?*}:h}/:\/\//--}" + [[ "$local_dir" = "." ]] && local_dir="" || local_dir="${${${${${local_dir#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}" + local_dir="${ZINIT[SNIPPETS_DIR]}${local_dir:+/$local_dir}" + + (( ${+ZINIT_ICE[svn]} || ${FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]} )) && { + # TODO: handle the SVN path's specifics + [[ -d "$local_dir/$dirname" ]] && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + return 1 + } || { + # TODO: handle the non-SVN path's specifics + [[ -d "$local_dir/$dirname" ]] && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + return 1 + } +} + +→chroma/-zinit-check-ice-mod() { + local _scmd="$1" _wrd="$4" + [[ "$_wrd" = (svn(\'|\")*|svn) ]] && \ + FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=1 + [[ "$_wrd" = (#b)(id-as(:|)(\'|\")(*)(\'|\")|id-as:(*)|id-as(*)) ]] && \ + FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]="${match[4]}${match[6]}${match[7]}" + + # Copy from zinit-autoload.zsh / -zplg-recall + local -a ice_order nval_ices ext_val_ices + ext_val_ices=( ${(@)${(@Ms.|.)ZINIT_EXTS[ice-mods]:#*\'\'*}//\'\'/} ) + + ice_order=( + svn proto from teleid bindmap cloneopts id-as depth if wait load + unload blockf pick bpick src as ver silent lucid notify mv cp + atinit atclone atload atpull nocd run-atpull has cloneonly make + service trackbinds multisrc compile nocompile nocompletions + reset-prompt wrap-track reset sh \!sh bash \!bash ksh \!ksh csh + \!csh aliases countdown ps-on-unload ps-on-update trigger-load + light-mode is-snippet atdelete pack git verbose on-update-of + subscribe param extract + # Include all additional ices – after + # stripping them from the possible: '' + ${(@s.|.)${ZINIT_EXTS[ice-mods]//\'\'/}} + ) + nval_ices=( + blockf silent lucid trackbinds cloneonly nocd run-atpull + nocompletions sh \!sh bash \!bash ksh \!ksh csh \!csh + aliases countdown light-mode is-snippet git verbose + + # Include only those additional ices, + # don't have the '' in their name, i.e. + # aren't designed to hold value + ${(@)${(@s.|.)ZINIT_EXTS[ice-mods]}:#*\'\'*} + + # Must be last + svn + ) + + if [[ "$_wrd" = (#b)(${(~j:|:)${ice_order[@]:#(${(~j:|:)nval_ices[@]:#(${(~j:|:)ext_val_ices[@]})})}})(*) ]]; then + reply+=("$(( __start )) $(( __start+${mend[1]} )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") + reply+=("$(( __start+${mbegin[2]} )) $(( __end )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-string]}") + -fast-highlight-string + return 0 + elif [[ "$_wrd" = (#b)(${(~j:|:)nval_ices[@]}) ]]; then + __style=${FAST_THEME_NAME}single-hyphen-option + return 0 + else + __style=${FAST_THEME_NAME}incorrect-subtle + return 1 + fi +} + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/main-chroma.ch b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/main-chroma.ch new file mode 100644 index 0000000..323a978 --- /dev/null +++ b/home/.zsh-server/plugins/fast-syntax-highlighting/→chroma/main-chroma.ch @@ -0,0 +1,460 @@ +# Copyright (c) 2018 Sebastian Gniazdowski +# +# Main chroma function. It allows to create the command-dedicated chromas +# (like -git.ch) through a definition provided by `chroma_def' array (read +# from the upper scope). +# +# $1 - 0 or 1, denoting if it's first call to the chroma, or following one +# $2 - the current token, also accessible by $__arg from the above scope - +# basically a private copy of $__arg +# $3 - a private copy of $_start_pos, i.e. the position of the token in the +# command line buffer, used to add region_highlight entry (see man), +# because Zsh colorizes by *ranges* in command line buffer +# $4 - a private copy of $_end_pos from the above scope +# + +(( next_word = 2 | 8192 )) + +→chroma/main-chroma-print() { + (( FAST_HIGHLIGHT[DEBUG] )) && print "$@" >> /tmp/fsh-dbg +} + +local __chroma_name="${1#\%}" __first_call="$2" __wrd="$3" __start_pos="$4" __end_pos="$5" + +# Not a well formed chroma name +[[ -z "$__chroma_name" ]] && return 1 + +# Load the fsh_{name-of-the-chroma}_chroma_def array +(( !FAST_HIGHLIGHT[-${__chroma_name}.ch-chroma-def] )) && →chroma/-${__chroma_name}.ch + +→chroma/main-chroma-print -r -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +→chroma/main-chroma-print -r -- @@@@@@@ local __chroma_name="${1#\%}" __first_call="$2" __wrd="$3" __start_pos="$4" __end_pos="$5" @@@@@@@ +local __style __entry __value __action __handler __tmp __svalue __hspaces=$'\t ' __nl=$'\n' __ch_def_name +integer __idx1 __idx2 __start __end __ivalue __have_value=0 +local -a __lines_list __avalue +local -A map +map=( "#" "_H" "^" "_D" "*" "_S" ) + +(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN )) + +# Handler that highlights the options +→chroma/main-chroma-std-aopt-action() { + integer _start="$2" _end="$3" + local _scmd="$1" _wrd="$4" + + [[ "$_wrd" = (#b)(--[a-zA-Z0-9_-]##)=(*) ]] && { + reply+=("$_start $(( _end - mend[2] + mbegin[2] - 1 )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") + } || { + [[ "$_wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + } +} + +# Handler that highlights the options' arguments +→chroma/main-chroma-std-aopt-ARG-action() { + integer _start="$2" _end="$3" + local _scmd="$1" _wrd="$4" + + [[ "$_wrd" = (#b)(--[a-zA-Z0-9_-]##)=(*) ]] && { + reply+=("$(( _start + 1 + mend[1] )) $_end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-${${${(M)match[2]:#<->}:+number}:-string}]}") + } || __style=${FAST_THEME_NAME}optarg-${${${(M)_wrd:#(-|)<->}:+number}:-string} +} + +# This handler also highlights explicit arguments, i.e. --opt=the-explicit-arg +→chroma/main-chroma-std-aopt-SEMI-action() { + integer _start="$2" _end="$3" + local _scmd="$1" _wrd="$4" + + [[ "$_wrd" = (#b)(--[a-zA-Z0-9_-]##)=(*) ]] && { + reply+=("$_start $(( _end - mend[2] + mbegin[2] - 1 )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}") + reply+=("$(( _start + 1 + mend[1] )) $_end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-${${${(M)match[2]:#<->}:+number}:-string}]}") + } || { + [[ "$_wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \ + __style=${FAST_THEME_NAME}single-hyphen-option + } +} + +# A handler which verifies the token as an GIT url +→chroma/main-chroma-std-verify-url() { + setopt localoptions extendedglob + local _wrd="$4" + integer url_correct=0 + # Correct matches + # Correct matches + if [[ "$_wrd" = (#b)(git|http|https|ftp|ftps|file)://([a-zA-Z0-9._~-]##)(:[0-9]##)(#c0,1)(/([a-zA-Z0-9./_~:-]##))(#c0,1) ]]; then + url_correct=1 + elif [[ "$_wrd" = (#b)rsync://([a-zA-Z0-9._~-]##)(/([a-zA-Z0-9./_~:-]##))(#c0,1) ]]; then + url_correct=1 + elif [[ "$_wrd" = (#b)ssh://([a-zA-Z0-9._~-]##@)(#c0,1)([a-zA-Z0-9._~-]##)(:[0-9]##)(#c0,1)(/([a-zA-Z0-9./_~:-]##))(#c0,1) ]]; then + url_correct=1 + elif [[ "$_wrd" = (#b)([a-zA-Z0-9._~-]##@)(#c0,1)([a-zA-Z0-9._~-]##):([a-zA-Z0-9./_~:-](#c0,1)[a-zA-Z0-9._~:-][a-zA-Z0-9./_~:-]#)(#c0,1) ]]; then + url_correct=1 + elif [[ "$_wrd" = (#b)[[:alnum:]/_~:.-]## ]]; then + url_correct=1 + fi + + (( url_correct )) && \ + { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \ + { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; } +} + +# A handler which verifies the token as a shell wildcard +→chroma/main-chroma-std-verify-pattern() { + setopt localoptions extendedglob + local _wrd="$4" + __style=${FAST_THEME_NAME}globbing-ext +} + +# Creates a hash table for given option set (an *_opt field in the chroma def.) +→chroma/main-create-OPTION-hash.ch() { + local __subcmd="$1" __option_set_id="$2" __the_hash_name="$3" __ __e __el __the_hash_name __var_name + local -a __split __sp __s + + →chroma/main-chroma-print -rl "======================" " **## STARTING ##** →chroma/main-##CREATE##-option-HASH.ch // subcmd:$__subcmd // option_set_id:$__option_set_id // h-nam:$__the_hash_name" + →chroma/main-chroma-print "[D] Got option-set: ${(j:,:)__option_set_id}" + typeset -gA "$__the_hash_name" + →chroma/main-chroma-print "[E] __the_hash_name ${__the_hash_name}:[$__option_set_id]" + + # Split on || + __ch_def_name="fsh__${__chroma_name}__chroma__def[${__option_set_id}]" + __split=( "${(P@s:||:)__ch_def_name}" ) + [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() + # Remove only leading and trailing whitespace + __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + + →chroma/main-chroma-print -rl "[F] Got ||-__split: _________" ${${(@)${${__split[@]##[[:space:]]##}[@]//[${__hspaces}]##/ }[@]//[${__nl}]##/$__nl}[@]//(#s)/:::} "_________" + for __el in $__split; do + __sp=( "${(@s:<<>>:)__el}" ) + [[ ${#__sp} -eq 1 && -z "${__sp[1]}" ]] && __sp=() + __sp=( "${__sp[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + + →chroma/main-chroma-print -l -- "Processing an ||-part - got <<>>-split: _________" "${${__sp[@]}[@]/(#s)/-\\t}" "_________" + __e="${__sp[1]}" + local __e1=${${__e#\(}%\)(:add|:del|)} + local __e2=${(M)__e##\(*\)(:add|:del)} + # Split on | with the ( and ) and :add/:del stripped and then append + # the :add or :del depending on what's on the input line + __s=() + for __ in ${(@s:|:)__e1}; do + __s+=( $__${__e2:+${(M)__e%(:add|:del)}} ) + done + [[ ${#__s} -eq 1 && -z "${__s[1]}" ]] && __s=() + __s=( "${__s[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + shift __sp + + for __ in $__s; do + __=${__%\^} + [[ "$__" = -*:(add|del) ]] && __var_name="${__the_hash_name}[${__}-directive]" || __var_name="${__the_hash_name}[${__}-opt-action]" + →chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[1]}${${${#__sp}:#(0|1)}:+ +}<<" + : ${(P)__var_name::=${__sp[1]}${${${#__sp}:#(0|1)}:+ +}} + + if (( ${#__sp} >= 2 )); then + __var_name="${__the_hash_name}[${__}-opt-arg-action]" + →chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[2]}<<}" + : ${(P)__var_name::=$__sp[2]} + fi + done + done +} + +# Processes given token +→chroma/main-process-token.ch() { + local __subcmd="$1" __wrd="$2" __val __var_name __main_hash_name __the_hash_name __i __size + local -a __splitted __split __added + + →chroma/main-chroma-print "\n******************* Starting →chroma/main-process-token <<$__wrd>>// subcmd:${(qq)__subcmd}" + __main_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^\*])/${map[${match[1]}]}}" + __var_name="${__main_hash_name}[subcmd:$__subcmd]" + __splitted=( "${(@s://:P)__var_name}" ) + [[ ${#__splitted} -eq 1 && -z "${__splitted[1]}" ]] && __splitted=() + __splitted=( "${__splitted[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + + →chroma/main-chroma-print -rl -- "[B] MAIN-PROCESS-TOKEN: got [OPTION/ARG-**S-E-T-S**] //-splitted from subcmd:$__subcmd: ${${(j:, :)__splitted}:-EMPTY-SET!}" "----- __splitted\\Deleted: -----" ${${(j:, :)${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (deleted)!} "----- Added\\Deleted: -----" ${${(j:, :)${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (added)!} -----\ Deleted:\ ----- ${(j:, :)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}} >> /tmp/reply + + (( ! ${#__splitted} )) && { + __var_name="${__main_hash_name}[subcmd:*]" + __splitted=( "${(@s://:P)__var_name}" ) + [[ ${#__splitted} -eq 1 && -z "${__splitted[1]}" ]] && __splitted=() + __splitted=( "${__splitted[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + (( ! ${#__splitted} )) && return 1 + } + + →chroma/main-chroma-print -rl -- "---NO-HASH-CREATE-FROM-NOW-ON---" + + if [[ -z "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" ]]; then + →chroma/main-chroma-print -rl -- "-z OPT-WITH-ARG-ACTIVE == true" + if [[ "$__wrd" = -* ]]; then + →chroma/main-chroma-print "1st-PATH (-z opt-with-arg-active, non-opt-arg branch, i.e. OPTION BRANCH) [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]" + for __val in ${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})} ${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}; do + [[ "${__val}" != "${__val%%_([0-9]##|\#)##*}"_${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}_opt(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_opt(\*|\^|) ]] && { →chroma/main-chroma-print "DIDN'T MATCH $__val / arg counter:${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue; } || →chroma/main-chroma-print "Got candidate: $__val" + # Create the hash cache-parameter if needed + __the_hash_name="fsh__chroma__${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}__${__subcmd//[^a-zA-Z0-9_]/_}__${${__val//(#b)([\#\^\*])/${map[${match[1]}]}}//[^a-zA-Z0-9_]/_}" + [[ "$__val" = *_opt(\*|\^|) && "${(P)+__the_hash_name}" -eq 0 ]] && →chroma/main-create-OPTION-hash.ch "$__subcmd" "$__val" "$__the_hash_name" || →chroma/main-chroma-print "Not creating, the hash already exists..." + # Try dedicated-entry for the option + __var_name="${__the_hash_name}[${${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action]" + __split=( "${(@s://:P)__var_name}" ) + [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() + # If no result, then try with catch-all entry + (( ! ${#__split} )) && { + →chroma/main-chroma-print "% no ${(q-)${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action, retrying with *-opt-action" "|__var_name|:$__var_name" + __var_name="${__the_hash_name}[*-opt-action]" + __split=( "${(@s://:P)__var_name}" ) + [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() + } + __svalue="$__var_name" + # Remove whitespace + __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + →chroma/main-chroma-print -l -- "\`$__val' // ${#__split} // $__wrd: (ch.run #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]}), deref. of \`$__var_name'" + if (( ${#__split} )); then + →chroma/main-chroma-print -l -- "Got split of {\$#__split:$#__split} ${__wrd}-opt-action or *-opt-action" "${${(q-)__split[@]}[@]/(#s)/->\\t}" + if [[ "${__split[2]}" = *[[:blank:]]+ ]]; then + →chroma/main-chroma-print "YES handling the value (the OPT.ARGUMENT)! [${__split[2]}]" + if [[ "$__wrd" = *=* ]]; then + →chroma/main-chroma-print "The-immediate Arg-Acquiring, of option" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="${__svalue%-opt-action\]}-opt-arg-action]" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="${__wrd#*=}" + __have_value=2 + else + →chroma/main-chroma-print "Enable Arg-Awaiting, of option" + →chroma/main-chroma-print "FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]=\"${__svalue%-opt-action\]}-opt-arg-action]\"" + __have_value=0 + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="${__svalue%-opt-action\]}-opt-arg-action]" + fi + fi + + __action="${__split[1]}" + __handler="${__split[2]%[[:blank:]]+}" + + # Check for directives (like :add) + if [[ "$__val" = *_opt\^ ]]; then + __var_name="${__the_hash_name}[${${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}:add-directive]" + (( ${(P)+__var_name} )) && __split=( "${(@s://:P)__var_name}" ) || __split=() + [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split[1]=() + __ivalue=${#__split} + __var_name="${__var_name%:add-*}:del-directive]" + (( ${(P)+__var_name} )) && __split+=( "${(@s://:P)__var_name}" ) + [[ ${#__split} -eq $(( __ivalue + 1 )) && -z "${__split[__ivalue+1]}" ]] && __split[__ivalue+1]=() + __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + __tmp=${#__split} + + # First: del-directive + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]+="${(j: :)__split[__ivalue+1,__tmp]} " + + →chroma/main-chroma-print -rl ":add / :del directives: __ivalue:$__ivalue, THE __SPLIT[#$__tmp]: " "${__split[@]}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]} >> /tmp/reply + + # Second: add-directive + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]+="${(j: :)__split[1,__ivalue]} " + fi + [[ "$__handler" = ::[^[:space:]]* ]] && __handler="${__handler#::}" || __handler="" + [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running handler(1): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; } + [[ "$__have_value" -ne 2 && -n "$__action" && "$__action" != "NO-OP" ]] && { →chroma/main-chroma-print -rl "Running action (1): $__action" ; eval "() { $__action; }"; } + [[ "$__val" != *\* ]] && break + else + →chroma/main-chroma-print -rl -- "NO-MATCH ROUTE TAKEN" + fi + done + else + →chroma/main-chroma-print "1st-PATH-B (-z opt-with-arg-active, non-opt-arg branch, ARGUMENT BRANCH [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]) //// added-nodes: ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}" + for __val in ${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})} ${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}; do + [[ "${__val}" != "${__val%%_([0-9]##|\#)*}"_"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"_arg(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_arg(\*|\^|) ]] && { →chroma/main-chroma-print "Continuing for $__val / arg counter ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue } + # Create the hash cache-parameter if needed + __the_hash_name="fsh__chroma__${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}__${__subcmd//[^a-zA-Z0-9_]/_}__${${__val//\#/H}//[^a-zA-Z0-9_]/_}" + __action="" __handler="" + →chroma/main-chroma-print "A hit, chosen __val:$__val!" + __ch_def_name="fsh__${__chroma_name}__chroma__def[$__val]" + __split=( "${(P@s:<<>>:)__ch_def_name}" ) + __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + + __sp=( "${(@s://:)__split[1]}" ) + __sp=( "${__sp[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + __action="${__sp[1]#*::::: ##}" + + # Verify if it's the expected argument + [[ "${__sp[1]}" = *:::::* && "$__wrd" != ${~${__sp[1]%% ##:::::*}} ]] && \ + { →chroma/main-chroma-print -r "mismatch ${__sp[1]%% ##:::::*} != $__wrd, continuing" ; continue; } + + →chroma/main-chroma-print -l -- "Got action record for $__val, i.e. the split:" "${__sp[@]//(#s)/-\t}" "_________" + + [[ "${__sp[2]}" = ::[^[:space:]]* ]] && __handler="${__sp[2]#::}" || { [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && →chroma/main-chroma-print "=== Error === In chroma definition: a handler entry ${(q)__sp[2]} without leading \`::'" ; } + [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running handler(3): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; } + [[ -n "$__action" && "$__action" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running action(3): $__action" ; eval "() { $__action; } \"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}\" \"$__start\" \"$__end\" \"$__wrd\""; } + + # Check for argument directives (like :add) + if (( ${#__split} >= 2 )); then + for __ in "${(@)__split[2,-1]}"; do + __splitted=( "${(@s://:)__}" ) + if [[ "${__splitted[1]}" = add:* ]]; then + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]+="${__splitted[1]#add:} ${(j: :)__splitted[2,-1]} " + elif [[ "${__splitted[1]}" = del:* ]]; then + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]+="${__splitted[1]#del:} ${(j: :)__splitted[2,-1]} " + fi + done + →chroma/main-chroma-print -l "ARGUMENT :add / :del directives: THE __SPLIT[#${#__split}]: " "${__split[@]//(#s)/-\\t}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}//(#s)/-\\t} "The FAST_HIGHLIGHT[chroma-*added-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}//(#s)/-\\t} + fi + + [[ "$__val" != *\* ]] && break + done + fi + else + →chroma/main-chroma-print -- "2nd-PATH (-n opt-with-arg-active) NON-EMPTY arg-active:\nThe actual opt-val <<< \$__wrd:$__wrd >>> store (after the \`Arg-Awaiting' in the chroma-run: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]-1 )) [current: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] ))])" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="$__wrd" + __have_value=1 + fi + + # Execute the action if not during simulated opt-argument (--opt=...) + →chroma/main-chroma-print "** BEFORE: \`if (( __have_value ))'" + if (( __have_value )); then + →chroma/main-chroma-print "In the \`if (( __have_value ))' [have_value: $__have_value]" + # Split + __var_name="${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="" + __split=( "${(@s://:P)__var_name}" ) + [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && { →chroma/main-chroma-print -rl "NULL at __var_name:$__var_name" ; __split=(); } + __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + + # Remember 1st level action + (( __have_value == 2 )) && __value="$__action" || __value="" + + if (( ${#__split} )); then + →chroma/main-chroma-print -l -- "Got //-split (3, for opt-ARG-action, from [$__var_name]):" "${${(q-)__split[@]}[@]/(#s)/+\\t}" + __action="${__split[1]}" + __handler="${__split[2]}" + [[ "$__handler" = ::[^[:space:]]* ]] && __handler="${__handler#::}" + + [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running handler(2): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; } + [[ -n "$__action" && "$__action" != "NO-OP" ]] && { →chroma/main-chroma-print -rl -- "Running action(2): $__action" ; eval "$__action"; } + →chroma/main-chroma-print -rl -- "The __action value: [$__value]" + [[ "$__have_value" -eq 2 && -n "$__value" && "$__value" != "NO-OP" ]] && { →chroma/main-chroma-print -rl "Running action (of 1, at 2): $__value" ; eval "$__value"; } + fi + fi + →chroma/main-chroma-print -- "_________ Exiting →chroma/main-process-token.ch $__subcmd / $__wrd _________" +} + +# Iterates over the chroma def. fields and creates initial +# fields in the fsh__${__chroma_name}__chroma__def hash +→chroma/-pre_process_chroma_def.ch() { + local __key __value __ke _val __the_hash_name="$1" __var_name + local -a __split + + →chroma/main-chroma-print -rl -- "Starting PRE_PROCESS for __the_hash_name:$__the_hash_name" + + __ch_def_name="fsh__${__chroma_name}__chroma__def[subcommands]" + local __subcmds="${(P)__ch_def_name}" + if [[ "$__subcmds" = "::"* ]]; then + ${__subcmds#::} + __var_name="${__the_hash_name}[subcommands]" + : ${(P)__var_name::=(${(j:|:)reply})} + else + __var_name="${__the_hash_name}[subcommands]" + : ${(P)__var_name::=$__subcmds} + fi + →chroma/main-chroma-print "Got SUBCOMMANDS: ${(P)__var_name}" + + __ch_def_name="fsh__${__chroma_name}__chroma__def[subcmd-hook]" + local __subcmd_hook="${(P)__ch_def_name}" + if [[ -n "$__subcmd_hook" ]]; then + __var_name="${__the_hash_name}[subcmd-hook]" + : ${(P)__var_name::=$__subcmd_hook} + fi + + __ch_def_name="fsh__${__chroma_name}__chroma__def[(I)subcmd:*]" + for __key in "${(P@)__ch_def_name}"; do + __split=( "${(@s:|:)${${__key##subcmd:\((#c0,1)}%\)}}" ) + [[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=() + __split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" ) + for __ke in "${__split[@]}"; do + __var_name="${__the_hash_name}[subcmd:$__ke]" + __ch_def_name="fsh__${__chroma_name}__chroma__def[$__key]" + : ${(P)__var_name::=${(P)__ch_def_name}} + →chroma/main-chroma-print -rl -- "Storred ${__var_name}=chroma_def[$__key], i.e. = ${(P)__ch_def_name}" + done + done +} + +if (( __first_call )); then + →chroma/-${__chroma_name}-first-call + FAST_HIGHLIGHT[chroma-current]="$__wrd" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]=0 + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand]=0 + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="" + FAST_HIGHLIGHT[chrome-${FAST_HIGHLIGHT[chroma-current]}-occurred-double-hyphen]=0 + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]=1 + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]="" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]="" + __the_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^])/${map[${match[1]}]}}" + (( 0 == ${(P)+__the_hash_name} )) && { + typeset -gA "$__the_hash_name" + →chroma/-pre_process_chroma_def.ch "$__the_hash_name" + } || →chroma/main-chroma-print "...No... [\${+$__the_hash_name} ${(P)+__the_hash_name}]" + return 1 +else + (( ++ FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] )) + # Following call, i.e. not the first one + + # Check if chroma should end – test if token is of type + # "starts new command", if so pass-through – chroma ends + [[ "$__arg_type" = 3 ]] && return 2 + + →chroma/main-chroma-print "== @@ Starting @@ #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]} Main-Chroma-call == // << __WORD:$__wrd >> ## Subcommand: ${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL} //@@// -n option-with-arg-active:${(q-)FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" + if [[ "$__wrd" = -* || -n "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" + ]]; then + →chroma/main-chroma-print "## The \`if -*' i.e. \`IF OPTION' MAIN branch" + →chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd" + else + # If at e.g. '>' or destination/source spec (of the redirection) + if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 + elif (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand] == 0 )) { + __the_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^])/${map[${match[1]}]}}" + __var_name="${__the_hash_name}[subcommands]" + if [[ "$__wrd" = ${(P)~__var_name} ]]; then + →chroma/main-chroma-print "GOT-SUBCOMMAND := $__wrd, subcmd verification / OK" + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand]=1 + FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="$__wrd" + __var_name="${__the_hash_name}[subcmd-hook]" + (( ${(P)+__var_name} )) && { →chroma/main-chroma-print -r -- "Running subcmd-hook: ${(P)__var_name}" ; "${(P)__var_name}" "$__wrd"; } + __style="${FAST_THEME_NAME}subcommand" + else + →chroma/main-chroma-print "subcmd verif / NOT OK; Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))" >> /tmp/fsh-dbg + (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 )) + →chroma/main-chroma-print "UNRECOGNIZED ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" + →chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd" + fi + } else { + __wrd="${__wrd//\`/x}" + __arg="${__arg//\`/x}" + __wrd="${(Q)__wrd}" + + local __tmp_def_name="fsh__${__chroma_name}__chroma__def[subcommands-blacklist]" + if [[ ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]} = \ + (${(~j:|:)${(@s:,:)${(PA)__tmp_def_name}}}) + ]] { + return 1 + } + + →chroma/main-chroma-print "Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))" + (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 )) + →chroma/main-chroma-print "ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" + + →chroma/main-chroma-print "ELSE *-got-subcommand == 1 is TRUE" + →chroma/main-process-token.ch "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}" "$__wrd" + } + fi +fi + + +# Add region_highlight entry (via `reply' array) +if [[ -n "$__style" ]]; then + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") +fi + +# We aren't passing-through, do obligatory things ourselves +(( this_word = next_word )) +_start_pos=$_end_pos + +return 0 + +# vim:ft=zsh:et:sw=4 diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.circleci/config.yml b/home/.zsh-server/plugins/zsh-autosuggestions/.circleci/config.yml new file mode 100644 index 0000000..d95fa98 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.circleci/config.yml @@ -0,0 +1,15 @@ +version: 2 +jobs: + build: + parallelism: 4 + shell: /bin/bash --login + docker: + - image: ericfreese/zsh-autosuggestions-test:latest + steps: + - checkout + - run: + name: Running tests + command: | + for v in $(grep "^[^#]" ZSH_VERSIONS | awk "(NR + $CIRCLE_NODE_INDEX) % $CIRCLE_NODE_TOTAL == 0"); do + TEST_ZSH_BIN=zsh-$v make test || exit 1 + done diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.editorconfig b/home/.zsh-server/plugins/zsh-autosuggestions/.editorconfig new file mode 100644 index 0000000..ddabb17 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.editorconfig @@ -0,0 +1,18 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 4 + +[*.md] +indent_style = space + +[*.rb] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/bug-report.md b/home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..7663df6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,36 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +### Describe the bug + + +### To Reproduce +Steps to reproduce the behavior: + + + +```sh +% zsh -df +% source path/to/zsh-autosuggestions.zsh +% ... # what do you do to reproduce? +``` + +### Expected behavior + + +### Screenshots + + +### Desktop + - OS + distribution: + - Zsh version: + - Plugin version: + +### Additional context + diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/feature_request.md b/home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..5874625 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +### Is your feature request related to a problem? Please describe. + + +### Describe the solution you'd like + + +### Describe alternatives you've considered + + +### Additional context + diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.rspec b/home/.zsh-server/plugins/zsh-autosuggestions/.rspec new file mode 100644 index 0000000..43ae203 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format documentation diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.rubocop.yml b/home/.zsh-server/plugins/zsh-autosuggestions/.rubocop.yml new file mode 100644 index 0000000..97facac --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.rubocop.yml @@ -0,0 +1,30 @@ +# Rails: +# Enabled: true + +AllCops: + TargetRubyVersion: 2.3 + Include: + - '**/Rakefile' + - '**/config.ru' + - '**/Gemfile' + +Metrics/LineLength: + Max: 120 + +Style/Documentation: + Enabled: false + +Style/DotPosition: + EnforcedStyle: trailing + +Style/FrozenStringLiteralComment: + Enabled: false + +Style/Lambda: + Enabled: false + +Style/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Style/TrailingUnderscoreVariable: + Enabled: false diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/.ruby-version b/home/.zsh-server/plugins/zsh-autosuggestions/.ruby-version new file mode 100644 index 0000000..aedc15b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/.ruby-version @@ -0,0 +1 @@ +2.5.3 diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/CHANGELOG.md b/home/.zsh-server/plugins/zsh-autosuggestions/CHANGELOG.md new file mode 100644 index 0000000..15d65a9 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/CHANGELOG.md @@ -0,0 +1,117 @@ +# Changelog + +## v0.7.0 +- Enable asynchronous mode by default (#498) +- No longer wrap user widgets starting with `autosuggest-` prefix (#496) +- Fix a bug wrapping widgets that modify the buffer (#541) + + +## v0.6.4 +- Fix `vi-forward-char` triggering a bell when using it to accept a suggestion (#488) +- New configuration option to skip completion suggestions when buffer matches a pattern (#487) +- New configuration option to ignore history entries matching a pattern (#456) + +## v0.6.3 +- Fixed bug moving cursor to end of buffer after accepting suggestion (#453) + +## v0.6.2 +- Fixed bug deleting the last character in the buffer in vi mode (#450) +- Degrade gracefully when user doesn't have `zsh/system` module installed (#447) + +## v0.6.1 +- Fixed bug occurring when `_complete` had been aliased (#443) + +## v0.6.0 +- Added `completion` suggestion strategy powered by completion system (#111) +- Allow setting `ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE` to an empty string (#422) +- Don't fetch suggestions after copy-earlier-word (#439) +- Allow users to unignore zle-\* widgets (e.g. zle-line-init) (#432) + + +## v0.5.2 +- Allow disabling automatic widget re-binding for better performance (#418) +- Fix async suggestions when `SH_WORD_SPLIT` is set +- Refactor async mode to use process substitution instead of zpty (#417) + +## v0.5.1 +- Speed up widget rebinding (#413) +- Clean up global variable creations (#403) +- Respect user's set options when running original widget (#402) + +## v0.5.0 +- Don't overwrite config with default values (#335) +- Support fallback strategies by supplying array to suggestion config var +- Rename "default" suggestion strategy to "history" to name it based on what it actually does +- Reset opts in some functions affected by `GLOB_SUBST` (#334) +- Support widgets starting with dashes (ex: `-a-widget`) (#337) +- Skip async tests in zsh versions less than 5.0.8 because of reliability issues +- Fix handling of newline + carriage return in async pty (#333) + + +## v0.4.3 +- Avoid bell when accepting suggestions with `autosuggest-accept` (#228) +- Don't fetch suggestions after [up,down]-line-or-beginning-search (#227, #241) +- We are now running CI against new 5.5.1 version +- Fix partial-accept in vi mode (#188) +- Fix suggestion disappearing on fast movement after switching to `vicmd` mode (#290) +- Fix issue rotating through kill ring with `yank-pop` (#301) +- Fix issue creating new pty for async mode when previous pty is not properly cleaned up (#249) + +## v0.4.2 +- Fix bug in zsh versions older than 5.0.8 (#296) +- Officially support back to zsh v4.3.11 + +## v0.4.1 +- Switch to [[ and (( conditionals instead of [ (#257) +- Avoid warnnestedvar warnings with `typeset -g` (#275) +- Replace tabs with spaces in yaml (#268) +- Clean up and fix escaping of special characters (#267) +- Add `emacs-forward-word` to default list of partial accept widgets (#246) + +## v0.4.0 +- High-level integration tests using RSpec and tmux +- Add continuous integration with Circle CI +- Experimental support for asynchronous suggestions (#170) +- Fix problems with multi-line suggestions (#225) +- Optimize case where manually typing in suggestion +- Avoid wrapping any zle-\* widgets (#206) +- Remove support for deprecated options from v0.0.x +- Handle history entries that begin with dashes +- Gracefully handle being sourced multiple times (#126) +- Add enable/disable/toggle widgets to disable/enable suggestions (#219) + + +## v0.3.3 +- Switch from $history array to fc builtin for better performance with large HISTFILEs (#164) +- Fix tilde handling when extended_glob is set (#168) +- Add config option for maximum buffer length to fetch suggestions for (#178) +- Add config option for list of widgets to ignore (#184) +- Don't fetch a new suggestion unless a modification widget actually modifies the buffer (#183) + +## v0.3.2 +- Test runner now supports running specific tests and choosing zsh binary +- Return code from original widget is now correctly passed through (#135) +- Add `vi-add-eol` to list of accept widgets (#143) +- Escapes widget names within evals to fix problems with irregular widget names (#152) +- Plugin now clears suggestion while within a completion menu (#149) +- .plugin file no longer relies on symbolic link support, fixing issues on Windows (#156) + +## v0.3.1 + +- Fixes issue with `vi-next-char` not accepting suggestion (#137). +- Fixes global variable warning when WARN_CREATE_GLOBAL option enabled (#133). +- Split out a separate test file for each widget. + +## v0.3.0 + +- Adds `autosuggest-execute` widget (PR #124). +- Adds concept of suggestion "strategies" for different ways of fetching suggestions. +- Adds "match_prev_cmd" strategy (PR #131). +- Uses git submodules for testing dependencies. +- Lots of test cleanup. +- Various bug fixes for zsh 5.0.x and `sh_word_split` option. + + +## v0.2.17 + +Start of changelog. diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/DESCRIPTION b/home/.zsh-server/plugins/zsh-autosuggestions/DESCRIPTION new file mode 100644 index 0000000..b69200f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/DESCRIPTION @@ -0,0 +1 @@ +Fish-like fast/unobtrusive autosuggestions for zsh. diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/Dockerfile b/home/.zsh-server/plugins/zsh-autosuggestions/Dockerfile new file mode 100644 index 0000000..0d51407 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/Dockerfile @@ -0,0 +1,20 @@ +FROM ruby:2.5.3-alpine + +RUN apk add --no-cache autoconf +RUN apk add --no-cache libtool +RUN apk add --no-cache libcap-dev +RUN apk add --no-cache pcre-dev +RUN apk add --no-cache curl +RUN apk add --no-cache build-base +RUN apk add --no-cache ncurses-dev +RUN apk add --no-cache tmux + +WORKDIR /zsh-autosuggestions + +ADD ZSH_VERSIONS /zsh-autosuggestions/ZSH_VERSIONS +ADD install_test_zsh.sh /zsh-autosuggestions/install_test_zsh.sh +RUN ./install_test_zsh.sh + +ADD Gemfile /zsh-autosuggestions/Gemfile +ADD Gemfile.lock /zsh-autosuggestions/Gemfile.lock +RUN bundle install diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/Gemfile b/home/.zsh-server/plugins/zsh-autosuggestions/Gemfile new file mode 100644 index 0000000..8b5deec --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'rspec' +gem 'rspec-wait' +gem 'pry-byebug' diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/Gemfile.lock b/home/.zsh-server/plugins/zsh-autosuggestions/Gemfile.lock new file mode 100644 index 0000000..63ee778 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/Gemfile.lock @@ -0,0 +1,41 @@ +GEM + remote: https://rubygems.org/ + specs: + byebug (9.0.5) + coderay (1.1.1) + diff-lcs (1.3) + method_source (0.8.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.4.0) + byebug (~> 9.0) + pry (~> 0.10) + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + rspec-wait (0.0.9) + rspec (>= 3, < 4) + slop (3.6.0) + +PLATFORMS + ruby + +DEPENDENCIES + pry-byebug + rspec + rspec-wait + +BUNDLED WITH + 1.13.6 diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/INSTALL.md b/home/.zsh-server/plugins/zsh-autosuggestions/INSTALL.md new file mode 100644 index 0000000..196524f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/INSTALL.md @@ -0,0 +1,64 @@ +# Installation + +* [Packages](#packages) +* [Antigen](#antigen) +* [Oh My Zsh](#oh-my-zsh) +* [Manual](#manual-git-clone) + +## Packages + +| System | Package | +| ------------- | ------------- | +| Debian / Ubuntu | [zsh-autosuggestions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions) | +| Fedora / CentOS / RHEL / Scientific Linux | [zsh-autosuggestions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions) | +| OpenSUSE / SLE | [zsh-autosuggestions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions) | +| Arch Linux / Manjaro / Antergos / Hyperbola | [zsh-autosuggestions](https://www.archlinux.org/packages/zsh-autosuggestions), [zsh-autosuggestions-git](https://aur.archlinux.org/packages/zsh-autosuggestions-git) | +| NixOS | [zsh-autosuggestions](https://github.com/NixOS/nixpkgs/blob/master/pkgs/shells/zsh/zsh-autosuggestions/default.nix) | +| Void Linux | [zsh-autosuggestions](https://github.com/void-linux/void-packages/blob/master/srcpkgs/zsh-autosuggestions/template) | +| Mac OS | [homebrew](https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-autosuggestions.rb) | +| NetBSD | [pkgsrc](http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/shells/zsh-autosuggestions/README.html) | + +## Antigen + +1. Add the following to your `.zshrc`: + + ```sh + antigen bundle zsh-users/zsh-autosuggestions + ``` + +2. Start a new terminal session. + +## Oh My Zsh + +1. Clone this repository into `$ZSH_CUSTOM/plugins` (by default `~/.oh-my-zsh/custom/plugins`) + + ```sh + git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions + ``` + +2. Add the plugin to the list of plugins for Oh My Zsh to load (inside `~/.zshrc`): + + ```sh + plugins=( + # other plugins... + zsh-autosuggestions + ) + ``` + +3. Start a new terminal session. + +## Manual (Git Clone) + +1. Clone this repository somewhere on your machine. This guide will assume `~/.zsh/zsh-autosuggestions`. + + ```sh + git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions + ``` + +2. Add the following to your `.zshrc`: + + ```sh + source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh + ``` + +3. Start a new terminal session. diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/LICENSE b/home/.zsh-server/plugins/zsh-autosuggestions/LICENSE new file mode 100644 index 0000000..7ea78cc --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2013 Thiago de Arruda +Copyright (c) 2016-2021 Eric Freese + +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. diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/Makefile b/home/.zsh-server/plugins/zsh-autosuggestions/Makefile new file mode 100644 index 0000000..f6d13a7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/Makefile @@ -0,0 +1,35 @@ +SRC_DIR := ./src + +SRC_FILES := \ + $(SRC_DIR)/config.zsh \ + $(SRC_DIR)/util.zsh \ + $(SRC_DIR)/bind.zsh \ + $(SRC_DIR)/highlight.zsh \ + $(SRC_DIR)/widgets.zsh \ + $(SRC_DIR)/strategies/*.zsh \ + $(SRC_DIR)/fetch.zsh \ + $(SRC_DIR)/async.zsh \ + $(SRC_DIR)/start.zsh + +HEADER_FILES := \ + DESCRIPTION \ + URL \ + VERSION \ + LICENSE + +PLUGIN_TARGET := zsh-autosuggestions.zsh + +all: $(PLUGIN_TARGET) + +$(PLUGIN_TARGET): $(HEADER_FILES) $(SRC_FILES) + cat $(HEADER_FILES) | sed -e 's/^/# /g' > $@ + cat $(SRC_FILES) >> $@ + +.PHONY: clean +clean: + rm $(PLUGIN_TARGET) + +.PHONY: test +test: all + @test -n "$$TEST_ZSH_BIN" && echo "Testing zsh binary: $(TEST_ZSH_BIN)" || true + bundle exec rspec $(TESTS) diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/README.md b/home/.zsh-server/plugins/zsh-autosuggestions/README.md new file mode 100644 index 0000000..3cfd2e8 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/README.md @@ -0,0 +1,191 @@ +# zsh-autosuggestions + +_[Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for zsh._ + +It suggests commands as you type based on history and completions. + +Requirements: Zsh v4.3.11 or later + +[![CircleCI](https://img.shields.io/circleci/build/github/zsh-users/zsh-autosuggestions.svg)](https://circleci.com/gh/zsh-users/zsh-autosuggestions) +[![Chat on Gitter](https://img.shields.io/gitter/room/zsh-users/zsh-autosuggestions.svg)](https://gitter.im/zsh-users/zsh-autosuggestions) + + + + +## Installation + +See [INSTALL.md](INSTALL.md). + + +## Usage + +As you type commands, you will see a completion offered after the cursor in a muted gray color. This color can be changed by setting the `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` variable. See [configuration](#configuration). + +If you press the key (`forward-char` widget) or End (`end-of-line` widget) with the cursor at the end of the buffer, it will accept the suggestion, replacing the contents of the command line buffer with the suggestion. + +If you invoke the `forward-word` widget, it will partially accept the suggestion up to the point that the cursor moves to. + + +## Configuration + +You may want to override the default global config variables. Default values of these variables can be found [here](src/config.zsh). + +**Note:** If you are using Oh My Zsh, you can put this configuration in a file in the `$ZSH_CUSTOM` directory. See their comments on [overriding internals](https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals). + + +### Suggestion Highlight Style + +Set `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` to configure the style that the suggestion is shown with. The default is `fg=8`, which will set the foreground color to color 8 from the [256-color palette](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). If your terminal only supports 8 colors, you will need to use a number between 0 and 7. + +Background color can also be set, and the suggestion can be styled bold, underlined, or standout. For example, this would show suggestions with bold, underlined, pink text on a cyan background: + +```sh +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline" +``` + +For more info, read the Character Highlighting section of the zsh manual: `man zshzle` or [online](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting). + +**Note:** Some iTerm2 users have reported [not being able to see the suggestions](https://github.com/zsh-users/zsh-autosuggestions/issues/416#issuecomment-486516333). If this affects you, the problem is likely caused by incorrect color settings. In order to correct this, go into iTerm2's setting, navigate to profile > colors and make sure that the colors for Basic Colors > Background and ANSI Colors > Bright Black are **different**. + + +### Suggestion Strategy + +`ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated. The strategies in the array are tried successively until a suggestion is found. There are currently three built-in strategies to choose from: + +- `history`: Chooses the most recent match from history. +- `completion`: Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` module) +- `match_prev_cmd`: Like `history`, but chooses the most recent match whose preceding history item matches the most recently executed command ([more info](src/strategies/match_prev_cmd.zsh)). Note that this strategy won't work as expected with ZSH options that don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`. + +For example, setting `ZSH_AUTOSUGGEST_STRATEGY=(history completion)` will first try to find a suggestion from your history, but, if it can't find a match, will find a suggestion from the completion engine. + + +### Widget Mapping + +This plugin works by triggering custom behavior when certain [zle widgets](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets) are invoked. You can add and remove widgets from these arrays to change the behavior of this plugin: + +- `ZSH_AUTOSUGGEST_CLEAR_WIDGETS`: Widgets in this array will clear the suggestion when invoked. +- `ZSH_AUTOSUGGEST_ACCEPT_WIDGETS`: Widgets in this array will accept the suggestion when invoked. +- `ZSH_AUTOSUGGEST_EXECUTE_WIDGETS`: Widgets in this array will execute the suggestion when invoked. +- `ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS`: Widgets in this array will partially accept the suggestion when invoked. +- `ZSH_AUTOSUGGEST_IGNORE_WIDGETS`: Widgets in this array will not trigger any custom behavior. + +Widgets that modify the buffer and are not found in any of these arrays will fetch a new suggestion after they are invoked. + +**Note:** A widget shouldn't belong to more than one of the above arrays. + + +### Disabling suggestion for large buffers + +Set `ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE` to an integer value to disable autosuggestion for large buffers. The default is unset, which means that autosuggestion will be tried for any buffer size. Recommended value is 20. +This can be useful when pasting large amount of text in the terminal, to avoid triggering autosuggestion for strings that are too long. + +### Asynchronous Mode + +Suggestions are fetched asynchronously by default in zsh versions 5.0.8 and greater. To disable asynchronous suggestions and fetch them synchronously instead, `unset ZSH_AUTOSUGGEST_USE_ASYNC` after sourcing the plugin. + +Alternatively, if you are using a version of zsh older than 5.0.8 and want to enable asynchronous mode, set the `ZSH_AUTOSUGGEST_USE_ASYNC` variable after sourcing the plugin (it can be set to anything). Note that there is [a bug](https://github.com/zsh-users/zsh-autosuggestions/issues/364#issuecomment-481423232) in versions of zsh older than 5.0.8 where ctrl + c will fail to reset the prompt immediately after fetching a suggestion asynchronously. + +### Disabling automatic widget re-binding + +Set `ZSH_AUTOSUGGEST_MANUAL_REBIND` (it can be set to anything) to disable automatic widget re-binding on each precmd. This can be a big boost to performance, but you'll need to handle re-binding yourself if any of the widget lists change or if you or another plugin wrap any of the autosuggest widgets. To re-bind widgets, run `_zsh_autosuggest_bind_widgets`. + +### Ignoring history suggestions that match a pattern + +Set `ZSH_AUTOSUGGEST_HISTORY_IGNORE` to a [glob pattern](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators) to prevent offering suggestions for history entries that match the pattern. For example, set it to `"cd *"` to never suggest any `cd` commands from history. Or set to `"?(#c50,)"` to never suggest anything 50 characters or longer. + +**Note:** This only affects the `history` and `match_prev_cmd` suggestion strategies. + +### Skipping completion suggestions for certain cases + +Set `ZSH_AUTOSUGGEST_COMPLETION_IGNORE` to a [glob pattern](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators) to prevent offering completion suggestions when the buffer matches that pattern. For example, set it to `"git *"` to disable completion suggestions for git subcommands. + +**Note:** This only affects the `completion` suggestion strategy. + + +### Key Bindings + +This plugin provides a few widgets that you can use with `bindkey`: + +1. `autosuggest-accept`: Accepts the current suggestion. +2. `autosuggest-execute`: Accepts and executes the current suggestion. +3. `autosuggest-clear`: Clears the current suggestion. +4. `autosuggest-fetch`: Fetches a suggestion (works even when suggestions are disabled). +5. `autosuggest-disable`: Disables suggestions. +6. `autosuggest-enable`: Re-enables suggestions. +7. `autosuggest-toggle`: Toggles between enabled/disabled suggestions. + +For example, this would bind ctrl + space to accept the current suggestion. + +```sh +bindkey '^ ' autosuggest-accept +``` + + +## Troubleshooting + +If you have a problem, please search through [the list of issues on GitHub](https://github.com/zsh-users/zsh-autosuggestions/issues?q=) to see if someone else has already reported it. + +### Reporting an Issue + +Before reporting an issue, please try temporarily disabling sections of your configuration and other plugins that may be conflicting with this plugin to isolate the problem. + +When reporting an issue, please include: + +- The smallest, simplest `.zshrc` configuration that will reproduce the problem. See [this comment](https://github.com/zsh-users/zsh-autosuggestions/issues/102#issuecomment-180944764) for a good example of what this means. +- The version of zsh you're using (`zsh --version`) +- Which operating system you're running + + +## Uninstallation + +1. Remove the code referencing this plugin from `~/.zshrc`. + +2. Remove the git repository from your hard drive + + ```sh + rm -rf ~/.zsh/zsh-autosuggestions # Or wherever you installed + ``` + + +## Development + +### Build Process + +Edit the source files in `src/`. Run `make` to build `zsh-autosuggestions.zsh` from those source files. + + +### Pull Requests + +Pull requests are welcome! If you send a pull request, please: + +- Request to merge into the `develop` branch (*NOT* `master`) +- Match the existing coding conventions. +- Include helpful comments to keep the barrier-to-entry low for people new to the project. +- Write tests that cover your code as much as possible. + + +### Testing + +Tests are written in ruby using the [`rspec`](http://rspec.info/) framework. They use [`tmux`](https://tmux.github.io/) to drive a pseudoterminal, sending simulated keystrokes and making assertions on the terminal content. + +Test files live in `spec/`. To run the tests, run `make test`. To run a specific test, run `TESTS=spec/some_spec.rb make test`. You can also specify a `zsh` binary to use by setting the `TEST_ZSH_BIN` environment variable (ex: `TEST_ZSH_BIN=/bin/zsh make test`). + +A docker image for testing is available [on docker hub](https://hub.docker.com/r/ericfreese/zsh-autosuggestions-test). It comes with ruby, the bundler dependencies, and all supported versions of zsh installed. + +Pull the docker image with: + +```sh +docker pull ericfreese/zsh-autosuggestions-test +``` + +To run the tests for a specific version of zsh (where `` below is substituted with the contents of a line from the [`ZSH_VERSIONS`](ZSH_VERSIONS) file): + +```sh +docker run -it -e TEST_ZSH_BIN=zsh- -v $PWD:/zsh-autosuggestions zsh-autosuggestions-test make test +``` + + +## License + +This project is licensed under [MIT license](http://opensource.org/licenses/MIT). +For the full text of the license, see the [LICENSE](LICENSE) file. diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/URL b/home/.zsh-server/plugins/zsh-autosuggestions/URL new file mode 100644 index 0000000..4e2bd94 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/URL @@ -0,0 +1 @@ +https://github.com/zsh-users/zsh-autosuggestions diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/VERSION b/home/.zsh-server/plugins/zsh-autosuggestions/VERSION new file mode 100644 index 0000000..8b20e48 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/VERSION @@ -0,0 +1 @@ +v0.7.0 diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/ZSH_VERSIONS b/home/.zsh-server/plugins/zsh-autosuggestions/ZSH_VERSIONS new file mode 100644 index 0000000..18ed7a6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/ZSH_VERSIONS @@ -0,0 +1,17 @@ +# Zsh releases to run tests against +# See https://github.com/zsh-users/zsh/releases +# +# When modifying this file, rebuild and push docker image: +# $ docker build -t ericfreese/zsh-autosuggestions-test . +# $ docker push ericfreese/zsh-autosuggestions-test +4.3.11 +5.0.2 +5.0.8 +5.1.1 +5.2 +5.3.1 +5.4.2 +5.5.1 +5.6.2 +5.7.1 +5.8 diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/install_test_zsh.sh b/home/.zsh-server/plugins/zsh-autosuggestions/install_test_zsh.sh new file mode 100755 index 0000000..40dc4c5 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/install_test_zsh.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -ex + +for v in $(grep "^[^#]" ZSH_VERSIONS); do + mkdir zsh-$v + cd zsh-$v + + curl -L https://api.github.com/repos/zsh-users/zsh/tarball/zsh-$v | tar xz --strip=1 + + ./Util/preconfig + ./configure --enable-pcre \ + --enable-cap \ + --enable-multibyte \ + --with-term-lib='ncursesw tinfo' \ + --with-tcsetpgrp \ + --program-suffix="-$v" + + make install.bin + make install.modules + make install.fns + + cd .. + + rm -rf zsh-$v +done diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/async_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/async_spec.rb new file mode 100644 index 0000000..0af7232 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/async_spec.rb @@ -0,0 +1,70 @@ +context 'with asynchronous suggestions enabled' do + let(:options) { ["ZSH_AUTOSUGGEST_USE_ASYNC="] } + + describe '`up-line-or-beginning-search`' do + let(:before_sourcing) do + -> do + session. + run_command('autoload -U up-line-or-beginning-search'). + run_command('zle -N up-line-or-beginning-search'). + send_string('bindkey "'). + send_keys('C-v').send_keys('up'). + send_string('" up-line-or-beginning-search'). + send_keys('enter') + end + end + + it 'should show previous history entries' do + with_history( + 'echo foo', + 'echo bar', + 'echo baz' + ) do + session.clear_screen + 3.times { session.send_keys('up') } + wait_for { session.content }.to eq("echo foo") + end + end + end + + describe '`copy-earlier-word`' do + let(:before_sourcing) do + -> do + session. + run_command('autoload -Uz copy-earlier-word'). + run_command('zle -N copy-earlier-word'). + run_command('bindkey "^N" copy-earlier-word') + end + end + + it 'should cycle through previous words in the buffer' do + session.clear_screen + session.send_string('foo bar baz') + sleep 0.5 + session.send_keys('C-n') + wait_for { session.content }.to eq('foo bar bazbaz') + session.send_keys('C-n') + wait_for { session.content }.to eq('foo bar bazbar') + session.send_keys('C-n') + wait_for { session.content }.to eq('foo bar bazfoo') + end + end + + describe 'pressing ^C after fetching a suggestion' do + before do + skip 'Workaround does not work below v5.0.8' if session.zsh_version < Gem::Version.new('5.0.8') + end + + it 'terminates the prompt and begins a new one' do + session.send_keys('e') + sleep 0.5 + session.send_keys('C-c') + sleep 0.5 + session.send_keys('echo') + + wait_for { session.content }.to eq("e\necho") + end + end +end + + diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/auto_cd_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/auto_cd_spec.rb new file mode 100644 index 0000000..94bd24b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/auto_cd_spec.rb @@ -0,0 +1,14 @@ +describe 'with `AUTO_CD` option set' do + let(:after_sourcing) do + -> { + session.run_command('setopt AUTO_CD') + session.run_command('autoload compinit && compinit') + } + end + + it 'directory names are still completed' do + session.send_string('sr') + session.send_keys('C-i') + wait_for { session.content }.to eq('src/') + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/bracketed_paste_magic_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/bracketed_paste_magic_spec.rb new file mode 100644 index 0000000..41ff267 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/bracketed_paste_magic_spec.rb @@ -0,0 +1,43 @@ +describe 'pasting using bracketed-paste-magic' do + let(:before_sourcing) do + -> do + session. + run_command('autoload -Uz bracketed-paste-magic'). + run_command('zle -N bracketed-paste bracketed-paste-magic') + end + end + + context 'with suggestions disabled while pasting' do + before do + session. + run_command('bpm_init() { zle autosuggest-disable }'). + run_command('bpm_finish() { zle autosuggest-enable }'). + run_command('zstyle :bracketed-paste-magic paste-init bpm_init'). + run_command('zstyle :bracketed-paste-magic paste-finish bpm_finish') + end + + it 'does not show an incorrect suggestion' do + with_history('echo hello') do + session.paste_string("echo #{'a' * 60}") + sleep 1 + expect(session.content).to eq("echo #{'a' * 60}") + end + end + end + + context 'with `bracketed-paste` added to the list of widgets that clear the suggestion' do + let(:options) { ['ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste)'] } + + it 'does not retain an old suggestion' do + with_history ('echo foo') do + session.send_string('echo ') + wait_for { session.content }.to eq('echo foo') + session.paste_string('bar') + wait_for { session.content }.to eq('echo bar') + session.send_keys('C-a') # Any cursor movement works + sleep 1 + expect(session.content).to eq('echo bar') + end + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/client_zpty_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/client_zpty_spec.rb new file mode 100644 index 0000000..b8abb37 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/client_zpty_spec.rb @@ -0,0 +1,14 @@ +describe 'a running zpty command' do + let(:before_sourcing) { -> { session.run_command('zmodload zsh/zpty && zpty -b kitty cat') } } + + context 'when using `completion` strategy' do + let(:options) { ["ZSH_AUTOSUGGEST_STRATEGY=completion"] } + + it 'is not affected' do + session.send_keys('a').send_keys('C-h') + session.run_command('zpty -t kitty; echo $?') + + wait_for { session.content }.to end_with("\n0") + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/glob_subst_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/glob_subst_spec.rb new file mode 100644 index 0000000..c3dd671 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/glob_subst_spec.rb @@ -0,0 +1,12 @@ +describe 'with `GLOB_SUBST` option set' do + let(:after_sourcing) do + -> { + session.run_command('setopt GLOB_SUBST') + } + end + + it 'error messages are not printed' do + session.send_string('[[') + wait_for { session.content }.to eq('[[') + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/rebound_bracket_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/rebound_bracket_spec.rb new file mode 100644 index 0000000..8b420f0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/rebound_bracket_spec.rb @@ -0,0 +1,13 @@ +describe 'rebinding [' do + context 'initialized before sourcing the plugin' do + before do + session.run_command("function [ { $commands[\\[] \"$@\" }") + session.clear_screen + end + + it 'executes the custom behavior and the built-in behavior' do + session.send_string('asdf') + wait_for { session.content }.to eq('asdf') + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/vi_mode_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/vi_mode_spec.rb new file mode 100644 index 0000000..0a295c2 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/vi_mode_spec.rb @@ -0,0 +1,80 @@ +describe 'when using vi mode' do + let(:before_sourcing) do + -> do + session.run_command('bindkey -v') + end + end + + describe 'moving the cursor after exiting insert mode' do + it 'should not clear the current suggestion' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('h') + + wait_for { session.content }.to eq('foobar foo') + end + end + end + + describe '`vi-forward-word-end`' do + it 'should accept through the end of the current word' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('e'). # vi-forward-word-end + send_keys('a'). # vi-add-next + send_string('baz') + + wait_for { session.content }.to eq('foobarbaz') + end + end + end + + describe '`vi-forward-word`' do + it 'should accept through the first character of the next word' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('w'). # vi-forward-word + send_keys('a'). # vi-add-next + send_string('az') + + wait_for { session.content }.to eq('foobar faz') + end + end + end + + describe '`vi-find-next-char`' do + it 'should accept through the next occurrence of the character' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('f'). # vi-find-next-char + send_keys('o'). + send_keys('a'). # vi-add-next + send_string('b') + + wait_for { session.content }.to eq('foobar fob') + end + end + end + + describe '`vi-delete`' do + it 'should be able to remove the last character in the buffer' do + skip 'deleting last char did not work below zsh version 5.0.8' if session.zsh_version < Gem::Version.new('5.0.8') + + session. + send_string('echo foo'). + send_keys('escape'). + send_keys('d'). + send_keys('l') + + wait_for { session.content }.to eq('echo fo') + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/wrapped_widget_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/wrapped_widget_spec.rb new file mode 100644 index 0000000..61dfc2d --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/wrapped_widget_spec.rb @@ -0,0 +1,39 @@ +describe 'a wrapped widget' do + let(:widget) { 'backward-delete-char' } + + context 'initialized before sourcing the plugin' do + let(:before_sourcing) do + -> do + session. + run_command("_orig_#{widget}() { zle .#{widget} }"). + run_command("zle -N orig-#{widget} _orig_#{widget}"). + run_command("#{widget}-magic() { zle orig-#{widget}; BUFFER+=b }"). + run_command("zle -N #{widget} #{widget}-magic") + end + end + + it 'executes the custom behavior and the built-in behavior' do + with_history('foobar', 'foodar') do + session.send_string('food').send_keys('C-h') + wait_for { session.content }.to eq('foobar') + end + end + end + + context 'initialized after sourcing the plugin' do + before do + session. + run_command("zle -N orig-#{widget} ${widgets[#{widget}]#*:}"). + run_command("#{widget}-magic() { zle orig-#{widget}; BUFFER+=b }"). + run_command("zle -N #{widget} #{widget}-magic"). + clear_screen + end + + it 'executes the custom behavior and the built-in behavior' do + with_history('foobar', 'foodar') do + session.send_string('food').send_keys('C-h') + wait_for { session.content }.to eq('foobar') + end + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/zle_input_stack_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/zle_input_stack_spec.rb new file mode 100644 index 0000000..12cfbc7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/integrations/zle_input_stack_spec.rb @@ -0,0 +1,24 @@ +describe 'using `zle -U`' do + let(:before_sourcing) do + -> do + session. + run_command('_zsh_autosuggest_strategy_test() { sleep 1; _zsh_autosuggest_strategy_history "$1" }'). + run_command('foo() { zle -U - "echo hello" }; zle -N foo; bindkey ^B foo') + end + end + + let(:options) { ['unset ZSH_AUTOSUGGEST_USE_ASYNC', 'ZSH_AUTOSUGGEST_STRATEGY=test'] } + + # TODO: This is only possible with the $KEYS_QUEUED_COUNT widget parameter, coming soon... + xit 'does not fetch a suggestion for every inserted character' do + session.send_keys('C-b') + wait_for { session.content }.to eq('echo hello') + end + + it 'shows a suggestion when the widget completes' do + with_history('echo hello world') do + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to match(/\Aecho hello\e\[[0-9]+m world/) + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/kill_ring_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/kill_ring_spec.rb new file mode 100644 index 0000000..4d0178f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/kill_ring_spec.rb @@ -0,0 +1,23 @@ +context 'with some items in the kill ring' do + before do + session. + send_string('echo foo'). + send_keys('C-u'). + send_string('echo bar'). + send_keys('C-u') + end + + describe '`yank-pop`' do + it 'should cycle through all items in the kill ring' do + session.send_keys('C-y') + wait_for { session.content }.to eq('echo bar') + + session.send_keys('escape').send_keys('y') + wait_for { session.content }.to eq('echo foo') + + session.send_keys('escape').send_keys('y') + wait_for { session.content }.to eq('echo bar') + end + end +end + diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/line_init_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/line_init_spec.rb new file mode 100644 index 0000000..826277f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/line_init_spec.rb @@ -0,0 +1,17 @@ +context 'with zle-line-init unignored' do + let(:after_sourcing) do + -> do + session. + run_command('setopt extendedglob'). + run_command('ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(${(@)ZSH_AUTOSUGGEST_IGNORE_WIDGETS:#zle-\*} zle-\^line-init)'). + run_command('zle-line-init() { BUFFER="echo" }') + end + end + + it 'should fetch a suggestion on each line initialization' do + with_history('echo foo') do + session.run_command('zle -N zle-line-init') + wait_for { session.content }.to end_with('echo foo') + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/multi_line_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/multi_line_spec.rb new file mode 100644 index 0000000..364780a --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/multi_line_spec.rb @@ -0,0 +1,8 @@ +describe 'a multi-line suggestion' do + it 'should be displayed on multiple lines' do + with_history("echo \"\n\"") do + session.send_keys('e') + wait_for { session.content }.to eq("echo \"\n\"") + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/buffer_max_size_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/buffer_max_size_spec.rb new file mode 100644 index 0000000..29ca8bc --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/buffer_max_size_spec.rb @@ -0,0 +1,30 @@ +describe 'a suggestion' do + let(:term_opts) { { width: 200 } } + let(:long_command) { "echo #{'a' * 100}" } + + around do |example| + with_history(long_command) { example.run } + end + + it 'is provided for any buffer length' do + session.send_string(long_command[0...-1]) + wait_for { session.content }.to eq(long_command) + end + + context 'when ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE is specified' do + let(:buffer_max_size) { 10 } + let(:options) { ["ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=#{buffer_max_size}"] } + + it 'is provided when the buffer is shorter than the specified length' do + session.send_string(long_command[0...(buffer_max_size - 1)]) + wait_for { session.content }.to eq(long_command) + end + + it 'is provided when the buffer is equal to the specified length' do + session.send_string(long_command[0...(buffer_max_size)]) + wait_for { session.content }.to eq(long_command) + end + + it 'is not provided when the buffer is longer than the specified length' + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/highlight_style_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/highlight_style_spec.rb new file mode 100644 index 0000000..a7e39b3 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/highlight_style_spec.rb @@ -0,0 +1,7 @@ +describe 'a displayed suggestion' do + it 'is shown in the default style' + + describe 'when ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE is set to a zle_highlight string' do + it 'is shown in the specified style' + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/original_widget_prefix_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/original_widget_prefix_spec.rb new file mode 100644 index 0000000..a4b6e98 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/original_widget_prefix_spec.rb @@ -0,0 +1,7 @@ +describe 'an original zle widget' do + context 'is accessible with the default prefix' + + context 'when ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX is set' do + it 'is accessible with the specified prefix' + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/strategy_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/strategy_spec.rb new file mode 100644 index 0000000..58562d0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/strategy_spec.rb @@ -0,0 +1,55 @@ +describe 'a suggestion for a given prefix' do + let(:history_strategy) { '_zsh_autosuggest_strategy_history() { suggestion="history" }' } + let(:foobar_strategy) { '_zsh_autosuggest_strategy_foobar() { [[ "foobar baz" = $1* ]] && suggestion="foobar baz" }' } + let(:foobaz_strategy) { '_zsh_autosuggest_strategy_foobaz() { [[ "foobaz bar" = $1* ]] && suggestion="foobaz bar" }' } + + let(:after_sourcing) do + -> do + session.run_command(history_strategy) + end + end + + it 'by default is determined by calling the `history` strategy function' do + session.send_string('h') + wait_for { session.content }.to eq('history') + end + + context 'when ZSH_AUTOSUGGEST_STRATEGY is set to an array' do + let(:after_sourcing) do + -> do + session. + run_command(foobar_strategy). + run_command(foobaz_strategy). + run_command('ZSH_AUTOSUGGEST_STRATEGY=(foobar foobaz)') + end + end + + it 'is determined by the first strategy function to return a suggestion' do + session.send_string('foo') + wait_for { session.content }.to eq('foobar baz') + + session.send_string('baz') + wait_for { session.content }.to eq('foobaz bar') + end + end + + context 'when ZSH_AUTOSUGGEST_STRATEGY is set to a string' do + let(:after_sourcing) do + -> do + session. + run_command(foobar_strategy). + run_command(foobaz_strategy). + run_command('ZSH_AUTOSUGGEST_STRATEGY="foobar foobaz"') + end + end + + it 'is determined by the first strategy function to return a suggestion' do + session.send_string('foo') + wait_for { session.content }.to eq('foobar baz') + + session.send_string('baz') + wait_for { session.content }.to eq('foobaz bar') + end + end +end + diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/widget_lists_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/widget_lists_spec.rb new file mode 100644 index 0000000..421b84e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/options/widget_lists_spec.rb @@ -0,0 +1,121 @@ +describe 'a zle widget' do + let(:widget) { 'my-widget' } + let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } } + + context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] } + + it 'accepts the suggestion and moves the cursor to the end of the buffer when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to eq('echo hello') + wait_for { session.cursor }.to eq([10, 0]) + end + end + end + + context 'when added to ZSH_AUTOSUGGEST_CLEAR_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(#{widget})"] } + + it 'clears the suggestion when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content }.to eq('e') + end + end + end + + context 'when added to ZSH_AUTOSUGGEST_EXECUTE_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_EXECUTE_WIDGETS+=(#{widget})"] } + + it 'executes the suggestion when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content }.to end_with("\nhello") + end + end + end + + context 'when added to ZSH_AUTOSUGGEST_IGNORE_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(#{widget})"] } + + it 'should not be wrapped with an autosuggest widget' do + session.run_command("echo $widgets[#{widget}]") + wait_for { session.content }.to end_with("\nuser:#{widget}") + end + end + + context 'that moves the cursor forward' do + before { session.run_command("#{widget}() { zle forward-char }") } + + context 'when added to ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(#{widget})"] } + + it 'accepts the suggestion as far as the cursor is moved when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to start_with('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to match(/\Aec\e\[[0-9]+mho hello/) + end + end + end + end + + context 'that modifies the buffer' do + before { session.run_command("#{widget}() { BUFFER=\"foo\" }") } + + context 'when not added to any of the widget lists' do + it 'modifies the buffer and fetches a new suggestion' do + with_history('foobar') do + session.send_keys('C-b') + wait_for { session.content }.to eq('foobar') + end + end + end + end +end + +describe 'a modification to the widget lists' do + let(:widget) { 'my-widget' } + let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } } + before { session.run_command("ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})") } + + it 'takes effect on the next cmd line' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to eq('echo hello') + end + end + + context 'when manual rebind is enabled' do + let(:options) { ["ZSH_AUTOSUGGEST_MANUAL_REBIND=true"] } + + it 'does not take effect until bind command is re-run' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + sleep 1 + expect(session.content(esc_seqs: true)).not_to eq('echo hello') + + session.send_keys('C-c') + session.run_command('_zsh_autosuggest_bind_widgets').clear_screen + wait_for { session.content }.to eq('') + + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to eq('echo hello') + end + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/spec_helper.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/spec_helper.rb new file mode 100644 index 0000000..dc1abb0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/spec_helper.rb @@ -0,0 +1,54 @@ +require 'pry' +require 'rspec/wait' +require 'terminal_session' +require 'tempfile' + +RSpec.shared_context 'terminal session' do + let(:term_opts) { {} } + let(:session) { TerminalSession.new(term_opts) } + let(:before_sourcing) { -> {} } + let(:after_sourcing) { -> {} } + let(:options) { [] } + + around do |example| + before_sourcing.call + session.run_command(['source zsh-autosuggestions.zsh', *options].join('; ')) + after_sourcing.call + session.clear_screen + + example.run + + session.destroy + end + + def with_history(*commands, &block) + Tempfile.create do |f| + f.write(commands.map{|c| c.gsub("\n", "\\\n")}.join("\n")) + f.flush + + session.run_command('fc -p') + session.run_command("fc -R #{f.path}") + + session.clear_screen + + yield block + + session.send_keys('C-c') + session.run_command('fc -P') + end + end +end + +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + config.wait_timeout = 2 + + config.include_context 'terminal session' +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/completion_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/completion_spec.rb new file mode 100644 index 0000000..92794d6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/completion_spec.rb @@ -0,0 +1,72 @@ +describe 'the `completion` suggestion strategy' do + let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=completion'] } + let(:before_sourcing) do + -> do + session. + run_command('autoload compinit && compinit'). + run_command('_foo() { compadd bar; compadd bat }'). + run_command('_num() { compadd two; compadd three }'). + run_command('compdef _foo baz'). + run_command('compdef _num one') + end + end + + it 'suggests the first completion result' do + session.send_string('baz ') + wait_for { session.content }.to eq('baz bar') + end + + it 'does not add extra carriage returns when prefix has a line feed' do + skip '`stty` does not work inside zpty below zsh version 5.0.3' if session.zsh_version < Gem::Version.new('5.0.3') + session.send_string('baz \\').send_keys('C-v', 'C-j') + wait_for { session.content }.to eq("baz \\\nbar") + end + + context 'when `_complete` is aliased' do + let(:before_sourcing) do + -> do + session. + run_command('autoload compinit && compinit'). + run_command('_foo() { compadd bar; compadd bat }'). + run_command('compdef _foo baz'). + run_command('alias _complete=_complete') + end + end + + it 'suggests the first completion result' do + session.send_string('baz ') + wait_for { session.content }.to eq('baz bar') + end + end + + context 'when ZSH_AUTOSUGGEST_COMPLETION_IGNORE is set to a pattern' do + let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=completion', 'ZSH_AUTOSUGGEST_COMPLETION_IGNORE="one *"'] } + + it 'makes suggestions when the buffer does not match the pattern' do + session.send_string('baz ') + wait_for { session.content }.to eq('baz bar') + end + + it 'does not make suggestions when the buffer matches the pattern' do + session.send_string('one t') + sleep 1 + expect(session.content).to eq('one t') + end + end + + context 'when async mode is enabled' do + let(:options) { ['ZSH_AUTOSUGGEST_USE_ASYNC=true', 'ZSH_AUTOSUGGEST_STRATEGY=completion'] } + + it 'suggests the first completion result' do + session.send_string('baz ') + wait_for { session.content }.to eq('baz bar') + end + + it 'does not add extra carriage returns when prefix has a line feed' do + skip '`stty` does not work inside zpty below zsh version 5.0.3' if session.zsh_version < Gem::Version.new('5.0.3') + session.send_string('baz \\').send_keys('C-v', 'C-j') + wait_for { session.content }.to eq("baz \\\nbar") + end + end +end + diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/history_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/history_spec.rb new file mode 100644 index 0000000..eee8efd --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/history_spec.rb @@ -0,0 +1,23 @@ +require 'strategies/special_characters_helper' + +describe 'the `history` suggestion strategy' do + it 'suggests the last matching history entry' do + with_history('ls foo', 'ls bar', 'echo baz') do + session.send_string('ls') + wait_for { session.content }.to eq('ls bar') + end + end + + context 'when ZSH_AUTOSUGGEST_HISTORY_IGNORE is set to a pattern' do + let(:options) { ['ZSH_AUTOSUGGEST_HISTORY_IGNORE="* bar"'] } + + it 'does not make suggestions that match the pattern' do + with_history('ls foo', 'ls bar', 'echo baz') do + session.send_string('ls') + wait_for { session.content }.to eq('ls foo') + end + end + end + + include_examples 'special characters' +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/match_prev_cmd_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/match_prev_cmd_spec.rb new file mode 100644 index 0000000..c435f16 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/match_prev_cmd_spec.rb @@ -0,0 +1,34 @@ +require 'strategies/special_characters_helper' + +describe 'the `match_prev_cmd` strategy' do + let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd'] } + + let(:history) { [ + 'echo what', + 'ls foo', + 'echo what', + 'ls bar', + 'ls baz', + 'echo what' + ] } + + it 'suggests the last matching history entry after the previous command' do + with_history(*history) do + session.send_string('ls') + wait_for { session.content }.to eq('ls bar') + end + end + + context 'when ZSH_AUTOSUGGEST_HISTORY_IGNORE is set to a pattern' do + let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd', 'ZSH_AUTOSUGGEST_HISTORY_IGNORE="* bar"'] } + + it 'does not make suggestions that match the pattern' do + with_history(*history) do + session.send_string('ls') + wait_for { session.content }.to eq('ls foo') + end + end + end + + include_examples 'special characters' +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/special_characters_helper.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/special_characters_helper.rb new file mode 100644 index 0000000..eb1f0cd --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/strategies/special_characters_helper.rb @@ -0,0 +1,75 @@ +shared_examples 'special characters' do + describe 'a special character in the buffer should be treated like any other character' do + it 'asterisk' do + with_history('echo "hello*"', 'echo "hello."') do + session.send_string('echo "hello*') + wait_for { session.content }.to eq('echo "hello*"') + end + end + + it 'question mark' do + with_history('echo "hello?"', 'echo "hello."') do + session.send_string('echo "hello?') + wait_for { session.content }.to eq('echo "hello?"') + end + end + + it 'backslash' do + with_history('echo "hello\nworld"') do + session.send_string('echo "hello\\') + wait_for { session.content }.to eq('echo "hello\nworld"') + end + end + + it 'double backslash' do + with_history('echo "\\\\"') do + session.send_string('echo "\\\\') + wait_for { session.content }.to eq('echo "\\\\"') + end + end + + it 'tilde' do + with_history('echo ~/foo') do + session.send_string('echo ~') + wait_for { session.content }.to eq('echo ~/foo') + end + end + + it 'parentheses' do + with_history('echo "$(ls foo)"') do + session.send_string('echo "$(') + wait_for { session.content }.to eq('echo "$(ls foo)"') + end + end + + it 'square bracket' do + with_history('echo "$history[123]"') do + session.send_string('echo "$history[') + wait_for { session.content }.to eq('echo "$history[123]"') + session.send_string('123]') + wait_for { session.content }.to eq('echo "$history[123]"') + end + end + + it 'octothorpe' do + with_history('echo "#yolo"') do + session.send_string('echo "#') + wait_for { session.content }.to eq('echo "#yolo"') + end + end + + it 'caret' do + with_history('echo "^A"', 'echo "^B"') do + session.send_string('echo "^A') + wait_for { session.content }.to eq('echo "^A"') + end + end + + it 'dash' do + with_history('-foo() {}') do + session.send_string('-') + wait_for { session.content }.to eq('-foo() {}') + end + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/terminal_session.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/terminal_session.rb new file mode 100644 index 0000000..f91ee6c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/terminal_session.rb @@ -0,0 +1,99 @@ +require 'securerandom' + +class TerminalSession + ZSH_BIN = ENV['TEST_ZSH_BIN'] || 'zsh' + + def initialize(opts = {}) + opts = { + width: 80, + height: 24, + prompt: '', + term: 'xterm-256color', + zsh_bin: ZSH_BIN + }.merge(opts) + + @opts = opts + + cmd="PS1=\"#{opts[:prompt]}\" TERM=#{opts[:term]} #{ZSH_BIN} -f" + tmux_command("new-session -d -x #{opts[:width]} -y #{opts[:height]} '#{cmd}'") + end + + def zsh_version + @zsh_version ||= Gem::Version.new(`#{ZSH_BIN} -c 'echo -n $ZSH_VERSION'`) + end + + def tmux_socket_name + @tmux_socket_name ||= SecureRandom.hex(6) + end + + def run_command(command) + send_string(command) + send_keys('enter') + + self + end + + def send_string(str) + tmux_command("send-keys -t 0 -l -- '#{str.gsub("'", "\\'")}'") + + self + end + + def send_keys(*keys) + tmux_command("send-keys -t 0 #{keys.join(' ')}") + + self + end + + def paste_string(str) + tmux_command("set-buffer -- '#{str}'") + tmux_command("paste-buffer -dpr -t 0") + + self + end + + def content(esc_seqs: false) + cmd = 'capture-pane -p -t 0' + cmd += ' -e' if esc_seqs + tmux_command(cmd).strip + end + + def clear_screen + send_keys('C-l') + + i = 0 + until content == opts[:prompt] || i > 20 do + sleep(0.1) + i = i + 1 + end + + self + end + + def destroy + tmux_command('kill-session') + end + + def cursor + tmux_command("display-message -t 0 -p '\#{cursor_x},\#{cursor_y}'"). + strip. + split(','). + map(&:to_i) + end + + def attach! + tmux_command('attach-session') + end + + private + + attr_reader :opts + + def tmux_command(cmd) + out = `tmux -u -L #{tmux_socket_name} #{cmd}` + + raise("tmux error running: '#{cmd}'") unless $?.success? + + out + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/disable_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/disable_spec.rb new file mode 100644 index 0000000..b387a59 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/disable_spec.rb @@ -0,0 +1,19 @@ +describe 'the `autosuggest-disable` widget' do + before do + session.run_command('bindkey ^B autosuggest-disable') + end + + it 'disables suggestions and clears the suggestion' do + with_history('echo hello') do + session.send_string('echo') + wait_for { session.content }.to eq('echo hello') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo') + + session.send_string(' h') + sleep 1 + expect(session.content).to eq('echo h') + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/enable_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/enable_spec.rb new file mode 100644 index 0000000..3ad35a8 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/enable_spec.rb @@ -0,0 +1,42 @@ +describe 'the `autosuggest-enable` widget' do + before do + session. + run_command('typeset -g _ZSH_AUTOSUGGEST_DISABLED'). + run_command('bindkey ^B autosuggest-enable') + end + + it 'enables suggestions and fetches a suggestion' do + with_history('echo hello') do + session.send_string('e') + sleep 1 + expect(session.content).to eq('e') + + session.send_keys('C-b') + session.send_string('c') + wait_for { session.content }.to eq('echo hello') + end + end + + context 'invoked on an empty buffer' do + it 'does not fetch a suggestion' do + with_history('echo hello') do + session.send_keys('C-b') + sleep 1 + expect(session.content).to eq('') + end + end + end + + context 'invoked on a non-empty buffer' do + it 'fetches a suggestion' do + with_history('echo hello') do + session.send_string('e') + sleep 1 + expect(session.content).to eq('e') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo hello') + end + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/fetch_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/fetch_spec.rb new file mode 100644 index 0000000..eb8f2ba --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/fetch_spec.rb @@ -0,0 +1,24 @@ +describe 'the `autosuggest-fetch` widget' do + context 'when suggestions are disabled' do + before do + session. + run_command('bindkey ^B autosuggest-disable'). + run_command('bindkey ^F autosuggest-fetch'). + send_keys('C-b') + end + + it 'will fetch and display a suggestion' do + with_history('echo hello') do + session.send_string('echo h') + sleep 1 + expect(session.content).to eq('echo h') + + session.send_keys('C-f') + wait_for { session.content }.to eq('echo hello') + + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + end + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/toggle_spec.rb b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/toggle_spec.rb new file mode 100644 index 0000000..8f9f3c3 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/spec/widgets/toggle_spec.rb @@ -0,0 +1,26 @@ +describe 'the `autosuggest-toggle` widget' do + before do + session.run_command('bindkey ^B autosuggest-toggle') + end + + it 'toggles suggestions' do + with_history('echo world', 'echo hello') do + session.send_string('echo') + wait_for { session.content }.to eq('echo hello') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo') + + session.send_string(' h') + sleep 1 + expect(session.content).to eq('echo h') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo hello') + + session.send_keys('C-h') + session.send_string('w') + wait_for { session.content }.to eq('echo world') + end + end +end diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/async.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/async.zsh new file mode 100644 index 0000000..218eb26 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/async.zsh @@ -0,0 +1,76 @@ + +#--------------------------------------------------------------------# +# Async # +#--------------------------------------------------------------------# + +_zsh_autosuggest_async_request() { + zmodload zsh/system 2>/dev/null # For `$sysparams` + + typeset -g _ZSH_AUTOSUGGEST_ASYNC_FD _ZSH_AUTOSUGGEST_CHILD_PID + + # If we've got a pending request, cancel it + if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then + # Close the file descriptor and remove the handler + exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&- + zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD + + # We won't know the pid unless the user has zsh/system module installed + if [[ -n "$_ZSH_AUTOSUGGEST_CHILD_PID" ]]; then + # Zsh will make a new process group for the child process only if job + # control is enabled (MONITOR option) + if [[ -o MONITOR ]]; then + # Send the signal to the process group to kill any processes that may + # have been forked by the suggestion strategy + kill -TERM -$_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null + else + # Kill just the child process since it wasn't placed in a new process + # group. If the suggestion strategy forked any child processes they may + # be orphaned and left behind. + kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null + fi + fi + fi + + # Fork a process to fetch a suggestion and open a pipe to read from it + exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <( + # Tell parent process our pid + echo $sysparams[pid] + + # Fetch and print the suggestion + local suggestion + _zsh_autosuggest_fetch_suggestion "$1" + echo -nE "$suggestion" + ) + + # There's a weird bug here where ^C stops working unless we force a fork + # See https://github.com/zsh-users/zsh-autosuggestions/issues/364 + autoload -Uz is-at-least + is-at-least 5.8 || command true + + # Read the pid from the child process + read _ZSH_AUTOSUGGEST_CHILD_PID <&$_ZSH_AUTOSUGGEST_ASYNC_FD + + # When the fd is readable, call the response handler + zle -F "$_ZSH_AUTOSUGGEST_ASYNC_FD" _zsh_autosuggest_async_response +} + +# Called when new data is ready to be read from the pipe +# First arg will be fd ready for reading +# Second arg will be passed in case of error +_zsh_autosuggest_async_response() { + emulate -L zsh + + local suggestion + + if [[ -z "$2" || "$2" == "hup" ]]; then + # Read everything from the fd and give it as a suggestion + IFS='' read -rd '' -u $1 suggestion + zle autosuggest-suggest -- "$suggestion" + + # Close the fd + exec {1}<&- + fi + + # Always remove the handler + zle -F "$1" +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/bind.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/bind.zsh new file mode 100644 index 0000000..1dde137 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/bind.zsh @@ -0,0 +1,106 @@ + +#--------------------------------------------------------------------# +# Widget Helpers # +#--------------------------------------------------------------------# + +_zsh_autosuggest_incr_bind_count() { + typeset -gi bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]+1)) + _ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count +} + +# Bind a single widget to an autosuggest widget, saving a reference to the original widget +_zsh_autosuggest_bind_widget() { + typeset -gA _ZSH_AUTOSUGGEST_BIND_COUNTS + + local widget=$1 + local autosuggest_action=$2 + local prefix=$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX + + local -i bind_count + + # Save a reference to the original widget + case $widgets[$widget] in + # Already bound + user:_zsh_autosuggest_(bound|orig)_*) + bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$widget])) + ;; + + # User-defined widget + user:*) + _zsh_autosuggest_incr_bind_count $widget + zle -N $prefix$bind_count-$widget ${widgets[$widget]#*:} + ;; + + # Built-in widget + builtin) + _zsh_autosuggest_incr_bind_count $widget + eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }" + zle -N $prefix$bind_count-$widget _zsh_autosuggest_orig_$widget + ;; + + # Completion widget + completion:*) + _zsh_autosuggest_incr_bind_count $widget + eval "zle -C $prefix$bind_count-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}" + ;; + esac + + # Pass the original widget's name explicitly into the autosuggest + # function. Use this passed in widget name to call the original + # widget instead of relying on the $WIDGET variable being set + # correctly. $WIDGET cannot be trusted because other plugins call + # zle without the `-w` flag (e.g. `zle self-insert` instead of + # `zle self-insert -w`). + eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() { + _zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@ + }" + + # Create the bound widget + zle -N -- $widget _zsh_autosuggest_bound_${bind_count}_$widget +} + +# Map all configured widgets to the right autosuggest widgets +_zsh_autosuggest_bind_widgets() { + emulate -L zsh + + local widget + local ignore_widgets + + ignore_widgets=( + .\* + _\* + ${_ZSH_AUTOSUGGEST_BUILTIN_ACTIONS/#/autosuggest-} + $ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\* + $ZSH_AUTOSUGGEST_IGNORE_WIDGETS + ) + + # Find every widget we might want to bind and bind it appropriately + for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do + if [[ -n ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget clear + elif [[ -n ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget accept + elif [[ -n ${ZSH_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget execute + elif [[ -n ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget partial_accept + else + # Assume any unspecified widget might modify the buffer + _zsh_autosuggest_bind_widget $widget modify + fi + done +} + +# Given the name of an original widget and args, invoke it, if it exists +_zsh_autosuggest_invoke_original_widget() { + # Do nothing unless called with at least one arg + (( $# )) || return 0 + + local original_widget_name="$1" + + shift + + if (( ${+widgets[$original_widget_name]} )); then + zle $original_widget_name -- $@ + fi +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/config.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/config.zsh new file mode 100644 index 0000000..5a0ebd8 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/config.zsh @@ -0,0 +1,93 @@ + +#--------------------------------------------------------------------# +# Global Configuration Variables # +#--------------------------------------------------------------------# + +# Color to use when highlighting suggestion +# Uses format of `region_highlight` +# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets +(( ! ${+ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE} )) && +typeset -g ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + +# Prefix to use when saving original versions of bound widgets +(( ! ${+ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX} )) && +typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- + +# Strategies to use to fetch a suggestion +# Will try each strategy in order until a suggestion is returned +(( ! ${+ZSH_AUTOSUGGEST_STRATEGY} )) && { + typeset -ga ZSH_AUTOSUGGEST_STRATEGY + ZSH_AUTOSUGGEST_STRATEGY=(history) +} + +# Widgets that clear the suggestion +(( ! ${+ZSH_AUTOSUGGEST_CLEAR_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_CLEAR_WIDGETS + ZSH_AUTOSUGGEST_CLEAR_WIDGETS=( + history-search-forward + history-search-backward + history-beginning-search-forward + history-beginning-search-backward + history-substring-search-up + history-substring-search-down + up-line-or-beginning-search + down-line-or-beginning-search + up-line-or-history + down-line-or-history + accept-line + copy-earlier-word + ) +} + +# Widgets that accept the entire suggestion +(( ! ${+ZSH_AUTOSUGGEST_ACCEPT_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_ACCEPT_WIDGETS + ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=( + forward-char + end-of-line + vi-forward-char + vi-end-of-line + vi-add-eol + ) +} + +# Widgets that accept the entire suggestion and execute it +(( ! ${+ZSH_AUTOSUGGEST_EXECUTE_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_EXECUTE_WIDGETS + ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=( + ) +} + +# Widgets that accept the suggestion as far as the cursor moves +(( ! ${+ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS + ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=( + forward-word + emacs-forward-word + vi-forward-word + vi-forward-word-end + vi-forward-blank-word + vi-forward-blank-word-end + vi-find-next-char + vi-find-next-char-skip + ) +} + +# Widgets that should be ignored (globbing supported but must be escaped) +(( ! ${+ZSH_AUTOSUGGEST_IGNORE_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_IGNORE_WIDGETS + ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( + orig-\* + beep + run-help + set-local-history + which-command + yank + yank-pop + zle-\* + ) +} + +# Pty name for capturing completions for completion suggestion strategy +(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) && +typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/fetch.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/fetch.zsh new file mode 100644 index 0000000..fef2715 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/fetch.zsh @@ -0,0 +1,27 @@ + +#--------------------------------------------------------------------# +# Fetch Suggestion # +#--------------------------------------------------------------------# +# Loops through all specified strategies and returns a suggestion +# from the first strategy to provide one. +# + +_zsh_autosuggest_fetch_suggestion() { + typeset -g suggestion + local -a strategies + local strategy + + # Ensure we are working with an array + strategies=(${=ZSH_AUTOSUGGEST_STRATEGY}) + + for strategy in $strategies; do + # Try to get a suggestion from this strategy + _zsh_autosuggest_strategy_$strategy "$1" + + # Ensure the suggestion matches the prefix + [[ "$suggestion" != "$1"* ]] && unset suggestion + + # Break once we've found a valid suggestion + [[ -n "$suggestion" ]] && break + done +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/highlight.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/highlight.zsh new file mode 100644 index 0000000..273c03d --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/highlight.zsh @@ -0,0 +1,26 @@ + +#--------------------------------------------------------------------# +# Highlighting # +#--------------------------------------------------------------------# + +# If there was a highlight, remove it +_zsh_autosuggest_highlight_reset() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then + region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}") + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} + +# If there's a suggestion, highlight it +_zsh_autosuggest_highlight_apply() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if (( $#POSTDISPLAY )); then + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" + region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT") + else + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/start.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/start.zsh new file mode 100644 index 0000000..5d4ee52 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/start.zsh @@ -0,0 +1,33 @@ + +#--------------------------------------------------------------------# +# Start # +#--------------------------------------------------------------------# + +# Start the autosuggestion widgets +_zsh_autosuggest_start() { + # By default we re-bind widgets on every precmd to ensure we wrap other + # wrappers. Specifically, highlighting breaks if our widgets are wrapped by + # zsh-syntax-highlighting widgets. This also allows modifications to the + # widget list variables to take effect on the next precmd. However this has + # a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND + # to disable the automatic re-binding. + if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then + add-zsh-hook -d precmd _zsh_autosuggest_start + fi + + _zsh_autosuggest_bind_widgets +} + +# Mark for auto-loading the functions that we use +autoload -Uz add-zsh-hook is-at-least + +# Automatically enable asynchronous mode in newer versions of zsh. Disable for +# older versions because there is a bug when using async mode where ^C does not +# work immediately after fetching a suggestion. +# See https://github.com/zsh-users/zsh-autosuggestions/issues/364 +if is-at-least 5.0.8; then + typeset -g ZSH_AUTOSUGGEST_USE_ASYNC= +fi + +# Start the autosuggestion widgets on the next precmd +add-zsh-hook precmd _zsh_autosuggest_start diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/completion.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/completion.zsh new file mode 100644 index 0000000..e2d114c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/completion.zsh @@ -0,0 +1,137 @@ + +#--------------------------------------------------------------------# +# Completion Suggestion Strategy # +#--------------------------------------------------------------------# +# Fetches a suggestion from the completion engine +# + +_zsh_autosuggest_capture_postcompletion() { + # Always insert the first completion into the buffer + compstate[insert]=1 + + # Don't list completions + unset 'compstate[list]' +} + +_zsh_autosuggest_capture_completion_widget() { + # Add a post-completion hook to be called after all completions have been + # gathered. The hook can modify compstate to affect what is done with the + # gathered completions. + local -a +h comppostfuncs + comppostfuncs=(_zsh_autosuggest_capture_postcompletion) + + # Only capture completions at the end of the buffer + CURSOR=$#BUFFER + + # Run the original widget wrapping `.complete-word` so we don't + # recursively try to fetch suggestions, since our pty is forked + # after autosuggestions is initialized. + zle -- ${(k)widgets[(r)completion:.complete-word:_main_complete]} + + if is-at-least 5.0.3; then + # Don't do any cr/lf transformations. We need to do this immediately before + # output because if we do it in setup, onlcr will be re-enabled when we enter + # vared in the async code path. There is a bug in zpty module in older versions + # where the tty is not properly attached to the pty slave, resulting in stty + # getting stopped with a SIGTTOU. See zsh-workers thread 31660 and upstream + # commit f75904a38 + stty -onlcr -ocrnl -F /dev/tty + fi + + # The completion has been added, print the buffer as the suggestion + echo -nE - $'\0'$BUFFER$'\0' +} + +zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget + +_zsh_autosuggest_capture_setup() { + # There is a bug in zpty module in older zsh versions by which a + # zpty that exits will kill all zpty processes that were forked + # before it. Here we set up a zsh exit hook to SIGKILL the zpty + # process immediately, before it has a chance to kill any other + # zpty processes. + if ! is-at-least 5.4; then + zshexit() { + # The zsh builtin `kill` fails sometimes in older versions + # https://unix.stackexchange.com/a/477647/156673 + kill -KILL $$ 2>&- || command kill -KILL $$ + + # Block for long enough for the signal to come through + sleep 1 + } + fi + + # Try to avoid any suggestions that wouldn't match the prefix + zstyle ':completion:*' matcher-list '' + zstyle ':completion:*' path-completion false + zstyle ':completion:*' max-errors 0 not-numeric + + bindkey '^I' autosuggest-capture-completion +} + +_zsh_autosuggest_capture_completion_sync() { + _zsh_autosuggest_capture_setup + + zle autosuggest-capture-completion +} + +_zsh_autosuggest_capture_completion_async() { + _zsh_autosuggest_capture_setup + + zmodload zsh/parameter 2>/dev/null || return # For `$functions` + + # Make vared completion work as if for a normal command line + # https://stackoverflow.com/a/7057118/154703 + autoload +X _complete + functions[_original_complete]=$functions[_complete] + function _complete() { + unset 'compstate[vared]' + _original_complete "$@" + } + + # Open zle with buffer set so we can capture completions for it + vared 1 +} + +_zsh_autosuggest_strategy_completion() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable extended glob for completion ignore pattern + setopt EXTENDED_GLOB + + typeset -g suggestion + local line REPLY + + # Exit if we don't have completions + whence compdef >/dev/null || return + + # Exit if we don't have zpty + zmodload zsh/zpty 2>/dev/null || return + + # Exit if our search string matches the ignore pattern + [[ -n "$ZSH_AUTOSUGGEST_COMPLETION_IGNORE" ]] && [[ "$1" == $~ZSH_AUTOSUGGEST_COMPLETION_IGNORE ]] && return + + # Zle will be inactive if we are in async mode + if zle; then + zpty $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME _zsh_autosuggest_capture_completion_sync + else + zpty $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME _zsh_autosuggest_capture_completion_async "\$1" + zpty -w $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME $'\t' + fi + + { + # The completion result is surrounded by null bytes, so read the + # content between the first two null bytes. + zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0' + + # Extract the suggestion from between the null bytes. On older + # versions of zsh (older than 5.3), we sometimes get extra bytes after + # the second null byte, so trim those off the end. + # See http://www.zsh.org/mla/workers/2015/msg03290.html + suggestion="${${(@0)line}[2]}" + } always { + # Destroy the pty + zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME + } +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/history.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/history.zsh new file mode 100644 index 0000000..0672a13 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/history.zsh @@ -0,0 +1,32 @@ + +#--------------------------------------------------------------------# +# History Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix. +# + +_zsh_autosuggest_strategy_history() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) and (x~y) glob operator + setopt EXTENDED_GLOB + + # Escape backslashes and all of the glob operators so we can use + # this string as a pattern to search the $history associative array. + # - (#m) globbing flag enables setting references for match data + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get the history items that match the prefix, excluding those that match + # the ignore pattern + local pattern="$prefix*" + if [[ -n $ZSH_AUTOSUGGEST_HISTORY_IGNORE ]]; then + pattern="($pattern)~($ZSH_AUTOSUGGEST_HISTORY_IGNORE)" + fi + + # Give the first history item matching the pattern as the suggestion + # - (r) subscript flag makes the pattern match on values + typeset -g suggestion="${history[(r)$pattern]}" +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/match_prev_cmd.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/match_prev_cmd.zsh new file mode 100644 index 0000000..b709783 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/strategies/match_prev_cmd.zsh @@ -0,0 +1,66 @@ + +#--------------------------------------------------------------------# +# Match Previous Command Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix and whose preceding history item also matches the most +# recently executed command. +# +# For example, suppose your history has the following entries: +# - pwd +# - ls foo +# - ls bar +# - pwd +# +# Given the history list above, when you type 'ls', the suggestion +# will be 'ls foo' rather than 'ls bar' because your most recently +# executed command (pwd) was previously followed by 'ls foo'. +# +# Note that this strategy won't work as expected with ZSH options that don't +# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or +# `HIST_EXPIRE_DUPS_FIRST`. + +_zsh_autosuggest_strategy_match_prev_cmd() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) and (x~y) glob operator + setopt EXTENDED_GLOB + + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get the history items that match the prefix, excluding those that match + # the ignore pattern + local pattern="$prefix*" + if [[ -n $ZSH_AUTOSUGGEST_HISTORY_IGNORE ]]; then + pattern="($pattern)~($ZSH_AUTOSUGGEST_HISTORY_IGNORE)" + fi + + # Get all history event numbers that correspond to history + # entries that match the pattern + local history_match_keys + history_match_keys=(${(k)history[(R)$~pattern]}) + + # By default we use the first history number (most recent history entry) + local histkey="${history_match_keys[1]}" + + # Get the previously executed command + local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")" + + # Iterate up to the first 200 history event numbers that match $prefix + for key in "${(@)history_match_keys[1,200]}"; do + # Stop if we ran out of history + [[ $key -gt 1 ]] || break + + # See if the history entry preceding the suggestion matches the + # previous command, and use it if it does + if [[ "${history[$((key - 1))]}" == "$prev_cmd" ]]; then + histkey="$key" + break + fi + done + + # Give back the matched history entry + typeset -g suggestion="$history[$histkey]" +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/util.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/util.zsh new file mode 100644 index 0000000..1f55d36 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/util.zsh @@ -0,0 +1,11 @@ + +#--------------------------------------------------------------------# +# Utility Functions # +#--------------------------------------------------------------------# + +_zsh_autosuggest_escape_command() { + setopt localoptions EXTENDED_GLOB + + # Escape special chars in the string (requires EXTENDED_GLOB) + echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}" +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/src/widgets.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/src/widgets.zsh new file mode 100644 index 0000000..bd61666 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/src/widgets.zsh @@ -0,0 +1,231 @@ + +#--------------------------------------------------------------------# +# Autosuggest Widget Implementations # +#--------------------------------------------------------------------# + +# Disable suggestions +_zsh_autosuggest_disable() { + typeset -g _ZSH_AUTOSUGGEST_DISABLED + _zsh_autosuggest_clear +} + +# Enable suggestions +_zsh_autosuggest_enable() { + unset _ZSH_AUTOSUGGEST_DISABLED + + if (( $#BUFFER )); then + _zsh_autosuggest_fetch + fi +} + +# Toggle suggestions (enable/disable) +_zsh_autosuggest_toggle() { + if (( ${+_ZSH_AUTOSUGGEST_DISABLED} )); then + _zsh_autosuggest_enable + else + _zsh_autosuggest_disable + fi +} + +# Clear the suggestion +_zsh_autosuggest_clear() { + # Remove the suggestion + unset POSTDISPLAY + + _zsh_autosuggest_invoke_original_widget $@ +} + +# Modify the buffer and get a new suggestion +_zsh_autosuggest_modify() { + local -i retval + + # Only available in zsh >= 5.4 + local -i KEYS_QUEUED_COUNT + + # Save the contents of the buffer/postdisplay + local orig_buffer="$BUFFER" + local orig_postdisplay="$POSTDISPLAY" + + # Clear suggestion while waiting for next one + unset POSTDISPLAY + + # Original widget may modify the buffer + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + emulate -L zsh + + # Don't fetch a new suggestion if there's more input to be read immediately + if (( $PENDING > 0 || $KEYS_QUEUED_COUNT > 0 )); then + POSTDISPLAY="$orig_postdisplay" + return $retval + fi + + # Optimize if manually typing in the suggestion or if buffer hasn't changed + if [[ "$BUFFER" = "$orig_buffer"* && "$orig_postdisplay" = "${BUFFER:$#orig_buffer}"* ]]; then + POSTDISPLAY="${orig_postdisplay:$(($#BUFFER - $#orig_buffer))}" + return $retval + fi + + # Bail out if suggestions are disabled + if (( ${+_ZSH_AUTOSUGGEST_DISABLED} )); then + return $? + fi + + # Get a new suggestion if the buffer is not empty after modification + if (( $#BUFFER > 0 )); then + if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then + _zsh_autosuggest_fetch + fi + fi + + return $retval +} + +# Fetch a new suggestion based on what's currently in the buffer +_zsh_autosuggest_fetch() { + if (( ${+ZSH_AUTOSUGGEST_USE_ASYNC} )); then + _zsh_autosuggest_async_request "$BUFFER" + else + local suggestion + _zsh_autosuggest_fetch_suggestion "$BUFFER" + _zsh_autosuggest_suggest "$suggestion" + fi +} + +# Offer a suggestion +_zsh_autosuggest_suggest() { + emulate -L zsh + + local suggestion="$1" + + if [[ -n "$suggestion" ]] && (( $#BUFFER )); then + POSTDISPLAY="${suggestion#$BUFFER}" + else + unset POSTDISPLAY + fi +} + +# Accept the entire suggestion +_zsh_autosuggest_accept() { + local -i retval max_cursor_pos=$#BUFFER + + # When vicmd keymap is active, the cursor can't move all the way + # to the end of the buffer + if [[ "$KEYMAP" = "vicmd" ]]; then + max_cursor_pos=$((max_cursor_pos - 1)) + fi + + # If we're not in a valid state to accept a suggestion, just run the + # original widget and bail out + if (( $CURSOR != $max_cursor_pos || !$#POSTDISPLAY )); then + _zsh_autosuggest_invoke_original_widget $@ + return + fi + + # Only accept if the cursor is at the end of the buffer + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Run the original widget before manually moving the cursor so that the + # cursor movement doesn't make the widget do something unexpected + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Move the cursor to the end of the buffer + if [[ "$KEYMAP" = "vicmd" ]]; then + CURSOR=$(($#BUFFER - 1)) + else + CURSOR=$#BUFFER + fi + + return $retval +} + +# Accept the entire suggestion and execute it +_zsh_autosuggest_execute() { + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Call the original `accept-line` to handle syntax highlighting or + # other potential custom behavior + _zsh_autosuggest_invoke_original_widget "accept-line" +} + +# Partially accept the suggestion +_zsh_autosuggest_partial_accept() { + local -i retval cursor_loc + + # Save the contents of the buffer so we can restore later if needed + local original_buffer="$BUFFER" + + # Temporarily accept the suggestion. + BUFFER="$BUFFER$POSTDISPLAY" + + # Original widget moves the cursor + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Normalize cursor location across vi/emacs modes + cursor_loc=$CURSOR + if [[ "$KEYMAP" = "vicmd" ]]; then + cursor_loc=$((cursor_loc + 1)) + fi + + # If we've moved past the end of the original buffer + if (( $cursor_loc > $#original_buffer )); then + # Set POSTDISPLAY to text right of the cursor + POSTDISPLAY="${BUFFER[$(($cursor_loc + 1)),$#BUFFER]}" + + # Clip the buffer at the cursor + BUFFER="${BUFFER[1,$cursor_loc]}" + else + # Restore the original buffer + BUFFER="$original_buffer" + fi + + return $retval +} + +() { + typeset -ga _ZSH_AUTOSUGGEST_BUILTIN_ACTIONS + + _ZSH_AUTOSUGGEST_BUILTIN_ACTIONS=( + clear + fetch + suggest + accept + execute + enable + disable + toggle + ) + + local action + for action in $_ZSH_AUTOSUGGEST_BUILTIN_ACTIONS modify partial_accept; do + eval "_zsh_autosuggest_widget_$action() { + local -i retval + + _zsh_autosuggest_highlight_reset + + _zsh_autosuggest_$action \$@ + retval=\$? + + _zsh_autosuggest_highlight_apply + + zle -R + + return \$retval + }" + done + + for action in $_ZSH_AUTOSUGGEST_BUILTIN_ACTIONS; do + zle -N autosuggest-$action _zsh_autosuggest_widget_$action + done +} diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh new file mode 100644 index 0000000..16c2256 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh @@ -0,0 +1 @@ +source ${0:A:h}/zsh-autosuggestions.zsh diff --git a/home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh b/home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh new file mode 100644 index 0000000..b19cac7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh @@ -0,0 +1,864 @@ +# Fish-like fast/unobtrusive autosuggestions for zsh. +# https://github.com/zsh-users/zsh-autosuggestions +# v0.7.0 +# Copyright (c) 2013 Thiago de Arruda +# Copyright (c) 2016-2021 Eric Freese +# +# 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. + +#--------------------------------------------------------------------# +# Global Configuration Variables # +#--------------------------------------------------------------------# + +# Color to use when highlighting suggestion +# Uses format of `region_highlight` +# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets +(( ! ${+ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE} )) && +typeset -g ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + +# Prefix to use when saving original versions of bound widgets +(( ! ${+ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX} )) && +typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- + +# Strategies to use to fetch a suggestion +# Will try each strategy in order until a suggestion is returned +(( ! ${+ZSH_AUTOSUGGEST_STRATEGY} )) && { + typeset -ga ZSH_AUTOSUGGEST_STRATEGY + ZSH_AUTOSUGGEST_STRATEGY=(history) +} + +# Widgets that clear the suggestion +(( ! ${+ZSH_AUTOSUGGEST_CLEAR_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_CLEAR_WIDGETS + ZSH_AUTOSUGGEST_CLEAR_WIDGETS=( + history-search-forward + history-search-backward + history-beginning-search-forward + history-beginning-search-backward + history-substring-search-up + history-substring-search-down + up-line-or-beginning-search + down-line-or-beginning-search + up-line-or-history + down-line-or-history + accept-line + copy-earlier-word + ) +} + +# Widgets that accept the entire suggestion +(( ! ${+ZSH_AUTOSUGGEST_ACCEPT_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_ACCEPT_WIDGETS + ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=( + forward-char + end-of-line + vi-forward-char + vi-end-of-line + vi-add-eol + ) +} + +# Widgets that accept the entire suggestion and execute it +(( ! ${+ZSH_AUTOSUGGEST_EXECUTE_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_EXECUTE_WIDGETS + ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=( + ) +} + +# Widgets that accept the suggestion as far as the cursor moves +(( ! ${+ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS + ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=( + forward-word + emacs-forward-word + vi-forward-word + vi-forward-word-end + vi-forward-blank-word + vi-forward-blank-word-end + vi-find-next-char + vi-find-next-char-skip + ) +} + +# Widgets that should be ignored (globbing supported but must be escaped) +(( ! ${+ZSH_AUTOSUGGEST_IGNORE_WIDGETS} )) && { + typeset -ga ZSH_AUTOSUGGEST_IGNORE_WIDGETS + ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( + orig-\* + beep + run-help + set-local-history + which-command + yank + yank-pop + zle-\* + ) +} + +# Pty name for capturing completions for completion suggestion strategy +(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) && +typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty + +#--------------------------------------------------------------------# +# Utility Functions # +#--------------------------------------------------------------------# + +_zsh_autosuggest_escape_command() { + setopt localoptions EXTENDED_GLOB + + # Escape special chars in the string (requires EXTENDED_GLOB) + echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}" +} + +#--------------------------------------------------------------------# +# Widget Helpers # +#--------------------------------------------------------------------# + +_zsh_autosuggest_incr_bind_count() { + typeset -gi bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]+1)) + _ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count +} + +# Bind a single widget to an autosuggest widget, saving a reference to the original widget +_zsh_autosuggest_bind_widget() { + typeset -gA _ZSH_AUTOSUGGEST_BIND_COUNTS + + local widget=$1 + local autosuggest_action=$2 + local prefix=$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX + + local -i bind_count + + # Save a reference to the original widget + case $widgets[$widget] in + # Already bound + user:_zsh_autosuggest_(bound|orig)_*) + bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$widget])) + ;; + + # User-defined widget + user:*) + _zsh_autosuggest_incr_bind_count $widget + zle -N $prefix$bind_count-$widget ${widgets[$widget]#*:} + ;; + + # Built-in widget + builtin) + _zsh_autosuggest_incr_bind_count $widget + eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }" + zle -N $prefix$bind_count-$widget _zsh_autosuggest_orig_$widget + ;; + + # Completion widget + completion:*) + _zsh_autosuggest_incr_bind_count $widget + eval "zle -C $prefix$bind_count-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}" + ;; + esac + + # Pass the original widget's name explicitly into the autosuggest + # function. Use this passed in widget name to call the original + # widget instead of relying on the $WIDGET variable being set + # correctly. $WIDGET cannot be trusted because other plugins call + # zle without the `-w` flag (e.g. `zle self-insert` instead of + # `zle self-insert -w`). + eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() { + _zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@ + }" + + # Create the bound widget + zle -N -- $widget _zsh_autosuggest_bound_${bind_count}_$widget +} + +# Map all configured widgets to the right autosuggest widgets +_zsh_autosuggest_bind_widgets() { + emulate -L zsh + + local widget + local ignore_widgets + + ignore_widgets=( + .\* + _\* + ${_ZSH_AUTOSUGGEST_BUILTIN_ACTIONS/#/autosuggest-} + $ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\* + $ZSH_AUTOSUGGEST_IGNORE_WIDGETS + ) + + # Find every widget we might want to bind and bind it appropriately + for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do + if [[ -n ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget clear + elif [[ -n ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget accept + elif [[ -n ${ZSH_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget execute + elif [[ -n ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget partial_accept + else + # Assume any unspecified widget might modify the buffer + _zsh_autosuggest_bind_widget $widget modify + fi + done +} + +# Given the name of an original widget and args, invoke it, if it exists +_zsh_autosuggest_invoke_original_widget() { + # Do nothing unless called with at least one arg + (( $# )) || return 0 + + local original_widget_name="$1" + + shift + + if (( ${+widgets[$original_widget_name]} )); then + zle $original_widget_name -- $@ + fi +} + +#--------------------------------------------------------------------# +# Highlighting # +#--------------------------------------------------------------------# + +# If there was a highlight, remove it +_zsh_autosuggest_highlight_reset() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then + region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}") + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} + +# If there's a suggestion, highlight it +_zsh_autosuggest_highlight_apply() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if (( $#POSTDISPLAY )); then + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" + region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT") + else + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} + +#--------------------------------------------------------------------# +# Autosuggest Widget Implementations # +#--------------------------------------------------------------------# + +# Disable suggestions +_zsh_autosuggest_disable() { + typeset -g _ZSH_AUTOSUGGEST_DISABLED + _zsh_autosuggest_clear +} + +# Enable suggestions +_zsh_autosuggest_enable() { + unset _ZSH_AUTOSUGGEST_DISABLED + + if (( $#BUFFER )); then + _zsh_autosuggest_fetch + fi +} + +# Toggle suggestions (enable/disable) +_zsh_autosuggest_toggle() { + if (( ${+_ZSH_AUTOSUGGEST_DISABLED} )); then + _zsh_autosuggest_enable + else + _zsh_autosuggest_disable + fi +} + +# Clear the suggestion +_zsh_autosuggest_clear() { + # Remove the suggestion + unset POSTDISPLAY + + _zsh_autosuggest_invoke_original_widget $@ +} + +# Modify the buffer and get a new suggestion +_zsh_autosuggest_modify() { + local -i retval + + # Only available in zsh >= 5.4 + local -i KEYS_QUEUED_COUNT + + # Save the contents of the buffer/postdisplay + local orig_buffer="$BUFFER" + local orig_postdisplay="$POSTDISPLAY" + + # Clear suggestion while waiting for next one + unset POSTDISPLAY + + # Original widget may modify the buffer + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + emulate -L zsh + + # Don't fetch a new suggestion if there's more input to be read immediately + if (( $PENDING > 0 || $KEYS_QUEUED_COUNT > 0 )); then + POSTDISPLAY="$orig_postdisplay" + return $retval + fi + + # Optimize if manually typing in the suggestion or if buffer hasn't changed + if [[ "$BUFFER" = "$orig_buffer"* && "$orig_postdisplay" = "${BUFFER:$#orig_buffer}"* ]]; then + POSTDISPLAY="${orig_postdisplay:$(($#BUFFER - $#orig_buffer))}" + return $retval + fi + + # Bail out if suggestions are disabled + if (( ${+_ZSH_AUTOSUGGEST_DISABLED} )); then + return $? + fi + + # Get a new suggestion if the buffer is not empty after modification + if (( $#BUFFER > 0 )); then + if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then + _zsh_autosuggest_fetch + fi + fi + + return $retval +} + +# Fetch a new suggestion based on what's currently in the buffer +_zsh_autosuggest_fetch() { + if (( ${+ZSH_AUTOSUGGEST_USE_ASYNC} )); then + _zsh_autosuggest_async_request "$BUFFER" + else + local suggestion + _zsh_autosuggest_fetch_suggestion "$BUFFER" + _zsh_autosuggest_suggest "$suggestion" + fi +} + +# Offer a suggestion +_zsh_autosuggest_suggest() { + emulate -L zsh + + local suggestion="$1" + + if [[ -n "$suggestion" ]] && (( $#BUFFER )); then + POSTDISPLAY="${suggestion#$BUFFER}" + else + unset POSTDISPLAY + fi +} + +# Accept the entire suggestion +_zsh_autosuggest_accept() { + local -i retval max_cursor_pos=$#BUFFER + + # When vicmd keymap is active, the cursor can't move all the way + # to the end of the buffer + if [[ "$KEYMAP" = "vicmd" ]]; then + max_cursor_pos=$((max_cursor_pos - 1)) + fi + + # If we're not in a valid state to accept a suggestion, just run the + # original widget and bail out + if (( $CURSOR != $max_cursor_pos || !$#POSTDISPLAY )); then + _zsh_autosuggest_invoke_original_widget $@ + return + fi + + # Only accept if the cursor is at the end of the buffer + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Run the original widget before manually moving the cursor so that the + # cursor movement doesn't make the widget do something unexpected + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Move the cursor to the end of the buffer + if [[ "$KEYMAP" = "vicmd" ]]; then + CURSOR=$(($#BUFFER - 1)) + else + CURSOR=$#BUFFER + fi + + return $retval +} + +# Accept the entire suggestion and execute it +_zsh_autosuggest_execute() { + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Call the original `accept-line` to handle syntax highlighting or + # other potential custom behavior + _zsh_autosuggest_invoke_original_widget "accept-line" +} + +# Partially accept the suggestion +_zsh_autosuggest_partial_accept() { + local -i retval cursor_loc + + # Save the contents of the buffer so we can restore later if needed + local original_buffer="$BUFFER" + + # Temporarily accept the suggestion. + BUFFER="$BUFFER$POSTDISPLAY" + + # Original widget moves the cursor + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Normalize cursor location across vi/emacs modes + cursor_loc=$CURSOR + if [[ "$KEYMAP" = "vicmd" ]]; then + cursor_loc=$((cursor_loc + 1)) + fi + + # If we've moved past the end of the original buffer + if (( $cursor_loc > $#original_buffer )); then + # Set POSTDISPLAY to text right of the cursor + POSTDISPLAY="${BUFFER[$(($cursor_loc + 1)),$#BUFFER]}" + + # Clip the buffer at the cursor + BUFFER="${BUFFER[1,$cursor_loc]}" + else + # Restore the original buffer + BUFFER="$original_buffer" + fi + + return $retval +} + +() { + typeset -ga _ZSH_AUTOSUGGEST_BUILTIN_ACTIONS + + _ZSH_AUTOSUGGEST_BUILTIN_ACTIONS=( + clear + fetch + suggest + accept + execute + enable + disable + toggle + ) + + local action + for action in $_ZSH_AUTOSUGGEST_BUILTIN_ACTIONS modify partial_accept; do + eval "_zsh_autosuggest_widget_$action() { + local -i retval + + _zsh_autosuggest_highlight_reset + + _zsh_autosuggest_$action \$@ + retval=\$? + + _zsh_autosuggest_highlight_apply + + zle -R + + return \$retval + }" + done + + for action in $_ZSH_AUTOSUGGEST_BUILTIN_ACTIONS; do + zle -N autosuggest-$action _zsh_autosuggest_widget_$action + done +} + +#--------------------------------------------------------------------# +# Completion Suggestion Strategy # +#--------------------------------------------------------------------# +# Fetches a suggestion from the completion engine +# + +_zsh_autosuggest_capture_postcompletion() { + # Always insert the first completion into the buffer + compstate[insert]=1 + + # Don't list completions + unset 'compstate[list]' +} + +_zsh_autosuggest_capture_completion_widget() { + # Add a post-completion hook to be called after all completions have been + # gathered. The hook can modify compstate to affect what is done with the + # gathered completions. + local -a +h comppostfuncs + comppostfuncs=(_zsh_autosuggest_capture_postcompletion) + + # Only capture completions at the end of the buffer + CURSOR=$#BUFFER + + # Run the original widget wrapping `.complete-word` so we don't + # recursively try to fetch suggestions, since our pty is forked + # after autosuggestions is initialized. + zle -- ${(k)widgets[(r)completion:.complete-word:_main_complete]} + + if is-at-least 5.0.3; then + # Don't do any cr/lf transformations. We need to do this immediately before + # output because if we do it in setup, onlcr will be re-enabled when we enter + # vared in the async code path. There is a bug in zpty module in older versions + # where the tty is not properly attached to the pty slave, resulting in stty + # getting stopped with a SIGTTOU. See zsh-workers thread 31660 and upstream + # commit f75904a38 + stty -onlcr -ocrnl -F /dev/tty + fi + + # The completion has been added, print the buffer as the suggestion + echo -nE - $'\0'$BUFFER$'\0' +} + +zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget + +_zsh_autosuggest_capture_setup() { + # There is a bug in zpty module in older zsh versions by which a + # zpty that exits will kill all zpty processes that were forked + # before it. Here we set up a zsh exit hook to SIGKILL the zpty + # process immediately, before it has a chance to kill any other + # zpty processes. + if ! is-at-least 5.4; then + zshexit() { + # The zsh builtin `kill` fails sometimes in older versions + # https://unix.stackexchange.com/a/477647/156673 + kill -KILL $$ 2>&- || command kill -KILL $$ + + # Block for long enough for the signal to come through + sleep 1 + } + fi + + # Try to avoid any suggestions that wouldn't match the prefix + zstyle ':completion:*' matcher-list '' + zstyle ':completion:*' path-completion false + zstyle ':completion:*' max-errors 0 not-numeric + + bindkey '^I' autosuggest-capture-completion +} + +_zsh_autosuggest_capture_completion_sync() { + _zsh_autosuggest_capture_setup + + zle autosuggest-capture-completion +} + +_zsh_autosuggest_capture_completion_async() { + _zsh_autosuggest_capture_setup + + zmodload zsh/parameter 2>/dev/null || return # For `$functions` + + # Make vared completion work as if for a normal command line + # https://stackoverflow.com/a/7057118/154703 + autoload +X _complete + functions[_original_complete]=$functions[_complete] + function _complete() { + unset 'compstate[vared]' + _original_complete "$@" + } + + # Open zle with buffer set so we can capture completions for it + vared 1 +} + +_zsh_autosuggest_strategy_completion() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable extended glob for completion ignore pattern + setopt EXTENDED_GLOB + + typeset -g suggestion + local line REPLY + + # Exit if we don't have completions + whence compdef >/dev/null || return + + # Exit if we don't have zpty + zmodload zsh/zpty 2>/dev/null || return + + # Exit if our search string matches the ignore pattern + [[ -n "$ZSH_AUTOSUGGEST_COMPLETION_IGNORE" ]] && [[ "$1" == $~ZSH_AUTOSUGGEST_COMPLETION_IGNORE ]] && return + + # Zle will be inactive if we are in async mode + if zle; then + zpty $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME _zsh_autosuggest_capture_completion_sync + else + zpty $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME _zsh_autosuggest_capture_completion_async "\$1" + zpty -w $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME $'\t' + fi + + { + # The completion result is surrounded by null bytes, so read the + # content between the first two null bytes. + zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0' + + # Extract the suggestion from between the null bytes. On older + # versions of zsh (older than 5.3), we sometimes get extra bytes after + # the second null byte, so trim those off the end. + # See http://www.zsh.org/mla/workers/2015/msg03290.html + suggestion="${${(@0)line}[2]}" + } always { + # Destroy the pty + zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME + } +} + +#--------------------------------------------------------------------# +# History Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix. +# + +_zsh_autosuggest_strategy_history() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) and (x~y) glob operator + setopt EXTENDED_GLOB + + # Escape backslashes and all of the glob operators so we can use + # this string as a pattern to search the $history associative array. + # - (#m) globbing flag enables setting references for match data + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get the history items that match the prefix, excluding those that match + # the ignore pattern + local pattern="$prefix*" + if [[ -n $ZSH_AUTOSUGGEST_HISTORY_IGNORE ]]; then + pattern="($pattern)~($ZSH_AUTOSUGGEST_HISTORY_IGNORE)" + fi + + # Give the first history item matching the pattern as the suggestion + # - (r) subscript flag makes the pattern match on values + typeset -g suggestion="${history[(r)$pattern]}" +} + +#--------------------------------------------------------------------# +# Match Previous Command Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix and whose preceding history item also matches the most +# recently executed command. +# +# For example, suppose your history has the following entries: +# - pwd +# - ls foo +# - ls bar +# - pwd +# +# Given the history list above, when you type 'ls', the suggestion +# will be 'ls foo' rather than 'ls bar' because your most recently +# executed command (pwd) was previously followed by 'ls foo'. +# +# Note that this strategy won't work as expected with ZSH options that don't +# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or +# `HIST_EXPIRE_DUPS_FIRST`. + +_zsh_autosuggest_strategy_match_prev_cmd() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) and (x~y) glob operator + setopt EXTENDED_GLOB + + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get the history items that match the prefix, excluding those that match + # the ignore pattern + local pattern="$prefix*" + if [[ -n $ZSH_AUTOSUGGEST_HISTORY_IGNORE ]]; then + pattern="($pattern)~($ZSH_AUTOSUGGEST_HISTORY_IGNORE)" + fi + + # Get all history event numbers that correspond to history + # entries that match the pattern + local history_match_keys + history_match_keys=(${(k)history[(R)$~pattern]}) + + # By default we use the first history number (most recent history entry) + local histkey="${history_match_keys[1]}" + + # Get the previously executed command + local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")" + + # Iterate up to the first 200 history event numbers that match $prefix + for key in "${(@)history_match_keys[1,200]}"; do + # Stop if we ran out of history + [[ $key -gt 1 ]] || break + + # See if the history entry preceding the suggestion matches the + # previous command, and use it if it does + if [[ "${history[$((key - 1))]}" == "$prev_cmd" ]]; then + histkey="$key" + break + fi + done + + # Give back the matched history entry + typeset -g suggestion="$history[$histkey]" +} + +#--------------------------------------------------------------------# +# Fetch Suggestion # +#--------------------------------------------------------------------# +# Loops through all specified strategies and returns a suggestion +# from the first strategy to provide one. +# + +_zsh_autosuggest_fetch_suggestion() { + typeset -g suggestion + local -a strategies + local strategy + + # Ensure we are working with an array + strategies=(${=ZSH_AUTOSUGGEST_STRATEGY}) + + for strategy in $strategies; do + # Try to get a suggestion from this strategy + _zsh_autosuggest_strategy_$strategy "$1" + + # Ensure the suggestion matches the prefix + [[ "$suggestion" != "$1"* ]] && unset suggestion + + # Break once we've found a valid suggestion + [[ -n "$suggestion" ]] && break + done +} + +#--------------------------------------------------------------------# +# Async # +#--------------------------------------------------------------------# + +_zsh_autosuggest_async_request() { + zmodload zsh/system 2>/dev/null # For `$sysparams` + + typeset -g _ZSH_AUTOSUGGEST_ASYNC_FD _ZSH_AUTOSUGGEST_CHILD_PID + + # If we've got a pending request, cancel it + if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then + # Close the file descriptor and remove the handler + exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&- + zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD + + # We won't know the pid unless the user has zsh/system module installed + if [[ -n "$_ZSH_AUTOSUGGEST_CHILD_PID" ]]; then + # Zsh will make a new process group for the child process only if job + # control is enabled (MONITOR option) + if [[ -o MONITOR ]]; then + # Send the signal to the process group to kill any processes that may + # have been forked by the suggestion strategy + kill -TERM -$_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null + else + # Kill just the child process since it wasn't placed in a new process + # group. If the suggestion strategy forked any child processes they may + # be orphaned and left behind. + kill -TERM $_ZSH_AUTOSUGGEST_CHILD_PID 2>/dev/null + fi + fi + fi + + # Fork a process to fetch a suggestion and open a pipe to read from it + exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <( + # Tell parent process our pid + echo $sysparams[pid] + + # Fetch and print the suggestion + local suggestion + _zsh_autosuggest_fetch_suggestion "$1" + echo -nE "$suggestion" + ) + + # There's a weird bug here where ^C stops working unless we force a fork + # See https://github.com/zsh-users/zsh-autosuggestions/issues/364 + autoload -Uz is-at-least + is-at-least 5.8 || command true + + # Read the pid from the child process + read _ZSH_AUTOSUGGEST_CHILD_PID <&$_ZSH_AUTOSUGGEST_ASYNC_FD + + # When the fd is readable, call the response handler + zle -F "$_ZSH_AUTOSUGGEST_ASYNC_FD" _zsh_autosuggest_async_response +} + +# Called when new data is ready to be read from the pipe +# First arg will be fd ready for reading +# Second arg will be passed in case of error +_zsh_autosuggest_async_response() { + emulate -L zsh + + local suggestion + + if [[ -z "$2" || "$2" == "hup" ]]; then + # Read everything from the fd and give it as a suggestion + IFS='' read -rd '' -u $1 suggestion + zle autosuggest-suggest -- "$suggestion" + + # Close the fd + exec {1}<&- + fi + + # Always remove the handler + zle -F "$1" +} + +#--------------------------------------------------------------------# +# Start # +#--------------------------------------------------------------------# + +# Start the autosuggestion widgets +_zsh_autosuggest_start() { + # By default we re-bind widgets on every precmd to ensure we wrap other + # wrappers. Specifically, highlighting breaks if our widgets are wrapped by + # zsh-syntax-highlighting widgets. This also allows modifications to the + # widget list variables to take effect on the next precmd. However this has + # a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND + # to disable the automatic re-binding. + if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then + add-zsh-hook -d precmd _zsh_autosuggest_start + fi + + _zsh_autosuggest_bind_widgets +} + +# Mark for auto-loading the functions that we use +autoload -Uz add-zsh-hook is-at-least + +# Automatically enable asynchronous mode in newer versions of zsh. Disable for +# older versions because there is a bug when using async mode where ^C does not +# work immediately after fetching a suggestion. +# See https://github.com/zsh-users/zsh-autosuggestions/issues/364 +if is-at-least 5.0.8; then + typeset -g ZSH_AUTOSUGGEST_USE_ASYNC= +fi + +# Start the autosuggestion widgets on the next precmd +add-zsh-hook precmd _zsh_autosuggest_start diff --git a/home/.zsh-server/plugins/zsh-completions/.editorconfig b/home/.zsh-server/plugins/zsh-completions/.editorconfig new file mode 100644 index 0000000..e762a90 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/.editorconfig @@ -0,0 +1,10 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://EditorConfig.org + +root = true + +[_*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = LF diff --git a/home/.zsh-server/plugins/zsh-completions/.github/ISSUE_TEMPLATE.md b/home/.zsh-server/plugins/zsh-completions/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/.github/ISSUE_TEMPLATE.md @@ -0,0 +1 @@ + diff --git a/home/.zsh-server/plugins/zsh-completions/.github/PULL_REQUEST_TEMPLATE.md b/home/.zsh-server/plugins/zsh-completions/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..085d8ea --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ + + + + +- [ ] This compdef is not already available in zsh. +- [ ] This compdef is not already available in their original project. +- [ ] I am the original author, or I have authorization to submit this work. +- [ ] This is a finished work. +- [ ] It has a header containing authors, status and origin of the script. +- [ ] It has a license header or I accept that it will be licensed under the terms of the Zsh license. diff --git a/home/.zsh-server/plugins/zsh-completions/.gitignore b/home/.zsh-server/plugins/zsh-completions/.gitignore new file mode 100644 index 0000000..c29589f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/.gitignore @@ -0,0 +1,6 @@ +# zsh word code files +*.zwc + +# IDE files +.vscode/ +.idea/ diff --git a/home/.zsh-server/plugins/zsh-completions/CONTRIBUTING.md b/home/.zsh-server/plugins/zsh-completions/CONTRIBUTING.md new file mode 100644 index 0000000..3d588e6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing + +## How to Contribute to zsh-completions + +Contributions are welcome, just make sure you follow the guidelines: + + * Completions are not accepted when already available in zsh. + * Completions are not accepted when already available in their original project. + * Please do not just copy/paste someone else's completion, ask before. + * Partially implemented completions are not accepted. + * Please add a header containing authors, status and origin of the script and license header if you do not wish to use the Zsh license (example [here](src/_tox)). + * Any reasonable open source license is acceptable but note that we recommend the use of the Zsh license and that you should use it if you hope for the function to migrate to zsh itself. + * Please try to follow the [Zsh completion style guide](https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide). + * Please send one separate pull request per file. + * Send a pull request or ask for committer access. + +## Contributing Completion Functions to Zsh + +The zsh project itself welcomes completion function contributions via +[github pull requests](https://github.com/zsh-users/zsh/), +[gitlab merge requests](https://gitlab.com/zsh-org/zsh/) or via patch +files sent to its mailing list, `zsh-workers@zsh.org`. + +Contributing to zsh has the advantage of reaching the most users. + +## Including Completion Functions in Upstream Projects + +Many upstream projects include zsh completions. + +If well maintained, this has the advantage that users get a completion +function that matches the installed version of their software. + +If you are the upstream maintainer this is a good choice. If the project +already includes completions for bash, fish, tcsh, etc then they are +likely open to including zsh's too. It can also be a good option for +completions handling commands that are system or distribution specific. + +Ideally, arrange for the project's build system to install the +completion function in `$prefix/share/zsh/site-functions`. diff --git a/home/.zsh-server/plugins/zsh-completions/LICENSE b/home/.zsh-server/plugins/zsh-completions/LICENSE new file mode 100644 index 0000000..d275ca9 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/LICENSE @@ -0,0 +1,25 @@ +The Z Shell is copyright (c) 1992-2017 Paul Falstad, Richard Coleman, +Zoltán Hidvégi, Andrew Main, Peter Stephenson, Sven Wischnowsky, and +others. All rights reserved. Individual authors, whether or not +specifically named, retain copyright in all changes; in what follows, they +are referred to as `the Zsh Development Group'. This is for convenience +only and this body has no legal status. The Z shell is distributed under +the following licence; any provisions made in individual files take +precedence. + +Permission is hereby granted, without written agreement and without +licence or royalty fees, to use, copy, modify, and distribute this +software and to distribute modified versions of this software for any +purpose, provided that the above copyright notice and the following +two paragraphs appear in all copies of this software. + +In no event shall the Zsh Development Group be liable to any party for +direct, indirect, special, incidental, or consequential damages arising out +of the use of this software and its documentation, even if the Zsh +Development Group have been advised of the possibility of such damage. + +The Zsh Development Group specifically disclaim any warranties, including, +but not limited to, the implied warranties of merchantability and fitness +for a particular purpose. The software provided hereunder is on an "as is" +basis, and the Zsh Development Group have no obligation to provide +maintenance, support, updates, enhancements, or modifications. diff --git a/home/.zsh-server/plugins/zsh-completions/README.md b/home/.zsh-server/plugins/zsh-completions/README.md new file mode 100644 index 0000000..ba030cc --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/README.md @@ -0,0 +1,71 @@ +zsh-completions ![GitHub release](https://img.shields.io/github/release/zsh-users/zsh-completions.svg) ![GitHub contributors](https://img.shields.io/github/contributors/zsh-users/zsh-completions.svg) [![IRC](https://img.shields.io/badge/IRC-%23zsh--completions-yellow.svg)](irc://irc.freenode.net/#zsh-completions) [![Gitter](https://badges.gitter.im/zsh-users/zsh-completions.svg)](https://gitter.im/zsh-users/zsh-completions?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +============= + +**Additional completion definitions for [Zsh](http://www.zsh.org).** + +*This projects aims at gathering/developing new completion scripts that are not available in Zsh yet. The scripts may be contributed to the Zsh project when stable enough.* + + +## Usage + +### Using packages + +| System | Package | +| ------------- | ------------- | +| Debian / Ubuntu | [zsh-completions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions) | +| Fedora / CentOS / RHEL / Scientific Linux | [zsh-completions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions) | +| OpenSUSE / SLE | [zsh-completions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions) | +| Arch Linux / Manjaro / Antergos / Hyperbola | [zsh-completions](https://www.archlinux.org/packages/zsh-completions), [zsh-completions-git](https://aur.archlinux.org/packages/zsh-completions-git) | +| Gentoo / Funtoo | [app-shells/zsh-completions](http://packages.gentoo.org/package/app-shells/zsh-completions) | +| NixOS | [zsh-completions](https://github.com/NixOS/nixpkgs/blob/master/pkgs/shells/zsh/zsh-completions/default.nix) | +| Void Linux | [zsh-completions](https://github.com/void-linux/void-packages/blob/master/srcpkgs/zsh-completions/template) | +| Slackware | [Slackbuilds](https://slackbuilds.org/repository/14.2/system/zsh-completions/) | +| macOS | [homebrew](https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-completions.rb), [MacPorts](https://github.com/macports/macports-ports/blob/master/sysutils/zsh-completions/Portfile) | +| NetBSD | [pkgsrc](http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/shells/zsh-completions/README.html) | +| FreeBSD | [shells/zsh-completions](https://www.freshports.org/shells/zsh-completions) | + + +### Using zsh frameworks + +#### [antigen](https://github.com/zsh-users/antigen) + +Add `antigen bundle zsh-users/zsh-completions` to your `~/.zshrc`. + +#### [oh-my-zsh](http://github.com/robbyrussell/oh-my-zsh) + +* Clone the repository inside your oh-my-zsh repo: + + git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions + +* Add it to `FPATH` in your `.zshrc` by adding the following line before `source "$ZSH/oh-my-zsh.sh"`: + + fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src + +Note: adding it as a regular Oh My ZSH! plugin will not work properly (see [#603](https://github.com/zsh-users/zsh-completions/issues/603)). + +#### [zinit](https://github.com/zdharma-continuum/zinit) + +Add `zinit light zsh-users/zsh-completions` to your `~/.zshrc`. + +### Manual installation + +* Clone the repository: + + git clone https://github.com/zsh-users/zsh-completions.git + +* Include the directory in your `$fpath`, for example by adding in `~/.zshrc`: + + fpath=(path/to/zsh-completions/src $fpath) + +* You may have to force rebuild `zcompdump`: + + rm -f ~/.zcompdump; compinit + +### Contributing + +Contributions are welcome, see [CONTRIBUTING](https://github.com/zsh-users/zsh-completions/blob/master/CONTRIBUTING.md). + + +## License +Completions use the Zsh license, unless explicitly mentioned in the file header. +See [LICENSE](https://github.com/zsh-users/zsh-completions/blob/master/LICENSE) for more information. diff --git a/home/.zsh-server/plugins/zsh-completions/src/_afew b/home/.zsh-server/plugins/zsh-completions/src/_afew new file mode 100644 index 0000000..140ca5b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_afew @@ -0,0 +1,65 @@ +#compdef afew +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for afew(version 3.0.1) an initial tagging script for notmuch mail. +# (https://github.com/teythoon/afew) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +_arguments \ + '(- 1 *)'{-h,--help}'[display usage information]' \ + '(- 1 *)'{-V,--version}"[show program's version number and exit]" \ + "(-t --tag -m --move-mails)"{-w,--watch}"[continuously monitor the mailbox for new messages matching the given query]" \ + "(-m --move-mails -w --watch)"{-t,--tag}"[run the tag filters]" \ + "(-w --watch -m --move-mails)"{-m,--move-mails}"[move mail files between maildir folders]" \ + "(-n --all)"{-a,--all}"[operate on all email]" \ + "(-a --new)"{-n,--new}"[operate on all new email]" \ + {-C,--notmuch-config=}"[specify path to notmuch configuration file]:files:_files" \ + {-e,--enable-filters=}"[specify filter classes to use]:filter" \ + {-d,--dry-run}"[don't change the DB]" \ + {-R,--reference-set-size=}"[specify size of the reference set]:size [1000]" \ + {-T,--reference-set-timeframe-days=}"[don't use emails older than specified age]:age (days) [30]" \ + {-N,--notmuch-args=}"[arguments for nutmuch new(in move mode)]:notmuch arg" \ + {-v,--verbose}"[be more verbose]" \ + '*: :_guard "^-*" query' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_android b/home/.zsh-server/plugins/zsh-completions/src/_android new file mode 100644 index 0000000..c26e2f8 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_android @@ -0,0 +1,308 @@ +#compdef android +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for the android command (Revision 12) +# (http://developer.android.com/guide/developing/tools/android.html). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_android() { + typeset -A opt_args + local context state line curcontext="$curcontext" + + local ret=1 + + _arguments -C -A "-*" \ + '(- : *)'{-h,--help}'[get help on a specific command]:command:_android_cmds' \ + '(-s --silent -v --verbose)'{-v,--verbose}'[verbose mode: errors, warnings and informational messages are printed]' \ + '(-v --verbose -s --silent)'{-s,--silent}'[silent mode: only errors are printed out]' \ + '1: :_android_cmds' \ + '*::arg:->args' \ + && ret=0 + + case "$state" in + (args) + curcontext="${curcontext%:*:*}:android-cmd-$words[1]:" + case $words[1] in + (list) + _arguments -C \ + '1: :_android_list_entities' \ + '*::list-arg:->list-args' \ + && ret=0 + case "$state" in + (list-args) + case $words[1] in + (avd|target) + _arguments \ + '(-0 --null)'{-0,--null}'[terminate lines with \0 instead of \n (e.g. for xargs -0)]' \ + '(-c --compact)'{-c,--compact}'[compact output (suitable for scripts)]' \ + && ret=0 + ;; + (sdk) + _arguments \ + '(-o --obsolete)'{-o,--obsolete}'[install obsolete packages]' \ + '--proxy-host[HTTP/HTTPS proxy host (overrides settings if defined)]:proxy host:_hosts' \ + '--proxy-port[HTTP/HTTPS proxy port (overrides settings if defined)]:proxy port number' \ + '(-s --no-https)'{-s,--no-https}'[use HTTP instead of HTTPS (the default) for downloads]' \ + '(-u --no-ui)'{-u,--no-ui}'[display list result on console (no GUI)]' \ + && ret=0 + ;; + esac + ;; + esac + ;; + (create) + _arguments -C \ + '1: :_android_create_entities' \ + '*::create-arg:->create-args' \ + && ret=0 + case "$state" in + (create-args) + case $words[1] in + (avd) + _arguments \ + '(-c --sdcard)'{-c,--sdcard}'[path to a shared SD card image, or size of a new sdcard for the new AVD]:SD card image or size:_files -g "*.img"' \ + '(-n --name)'{-n,--name}'[name of the new AVD]:name' \ + '(-a --snapshot)'{-a,--snapshot}'[place a snapshots file in the AVD, to enable persistence]' \ + '(-p --path)'{-p,--path}'[directory where the new AVD will be created]: :_files -/' \ + '(-f --force)'{-f,--force}'[forces creation (overwrites an existing AVD)]' \ + '(-s --skin)'{-s,--skin}'[skin for the new AVD]:skin' \ + '(-t --target)'{-t,--target}'[target ID of the new AVD]: :_android_targets' \ + && ret=0 + ;; + (project) + _arguments \ + '(-n --name)'{-n,--name}'[project name]:project name' \ + '(-p --path)'{-p,--path}'[the new project'\''s directory]: :_files -/' \ + '(-k --package)'{-k,--package}'[Android package name for the application]:package name' \ + '(-a --activity)'{-a,--activity}'[name of the default Activity that is created]:activity name' \ + '(-t --target)'{-t,--target}'[target ID of the new project]: :_android_targets' \ + && ret=0 + ;; + (test-project) + _arguments \ + '(-n --name)'{-n,--name}'[project name]:project name' \ + '(-p --path)'{-p,--path}'[the new project'\''s directory]: :_files -/' \ + '(-m --main)'{-m,--main}'[path to directory of the app under test, relative to the test project directory]:path' \ + && ret=0 + ;; + (lib-project) + _arguments \ + '(-n --name)'{-n,--name}'[project name]:project name' \ + '(-p --path)'{-p,--path}'[the new project'\''s directory]: :_files -/' \ + '(-k --package)'{-k,--package}'[Android package name for the application]:package name' \ + '(-t --target)'{-t,--target}'[target ID of the new project]: :_android_targets' \ + && ret=0 + ;; + esac + ;; + esac + ;; + (update) + _arguments -C \ + '1: :_android_update_entities' \ + '*::update-arg:->update-args' \ + && ret=0 + case "$state" in + (update-args) + case $words[1] in + (avd) + _arguments \ + '(-n --name)'{-n,--name}'[name of the AVD to update]: :_android_avd_names' \ + && ret=0 + ;; + (project) + _arguments \ + '(-l --library)'{-l,--library}'[directory of an Android library to add, relative to this project'\''s directory]: :_files -/' \ + '(-p --path)'{-p,--path}'[the project'\''s directory]: :_files -/' \ + '(-n --name)'{-n,--name}'[project name]:name' \ + '(-t --target)'{-t,--target}'[target ID to set for the project]: :_android_targets' \ + '(-s --subprojects)'{-s,--subprojects}'[also updates any projects in sub-folders, such as test projects]' \ + && ret=0 + ;; + (test-project) + _arguments \ + '(-p --path)'{-p,--path}'[the project'\''s directory]: :_files -/' \ + '(-m --main)'{-m,--main}'[directory of the app under test, relative to the test project directory]:path' \ + && ret=0 + ;; + (lib-project) + _arguments \ + '(-p --path)'{-p,--path}'[the project'\''s directory]: :_files -/' \ + '(-t --target)'{-t,--target}'[target ID to set for the project]: :_android_targets' \ + && ret=0 + ;; + (sdk) + _arguments \ + '(-o --obsolete)'{-o,--obsolete}'[install obsolete packages]' \ + '--proxy-host[HTTP/HTTPS proxy host (overrides settings if defined)]:proxy host:_hosts' \ + '--proxy-port[HTTP/HTTPS proxy port (overrides settings if defined)]:proxy port number' \ + '(-s --no-https)'{-s,--no-https}'[use HTTP instead of HTTPS (the default) for downloads]' \ + '(-u --no-ui)'{-u,--no-ui}'[update from command-line (no GUI)]' \ + '(-f --force)'{-f,--force}'[force replacement of a package or its parts, even if something has been modified]' \ + '(-t --filter)'{-t,--filter}'[a filter that limits the update to the specified types of packages]: :_android_sdk_update_filters -s ,' \ + '(-n --dry-mode)'{-n,--dry-mode}'[simulate the update but does not download or install anything]' \ + && ret=0 + ;; + esac + ;; + esac + ;; + (move) + _arguments -C \ + '1: :_android_move_entities' \ + '*::move-arg:->move-args' \ + && ret=0 + case "$state" in + (move-args) + case $words[1] in + (avd) + _arguments \ + '(-n --name)'{-n,--name}'[name of the AVD to move or rename]: :_android_avd_names' \ + '(-p --path)'{-p,--path}'[path to the AVD'\''s new directory]: :_files -/' \ + '(-r --rename)'{-r,--rename}'[new name of the AVD]:name' \ + && ret=0 + ;; + esac + ;; + esac + ;; + (delete) + _arguments -C \ + '1: :_android_delete_entities' \ + '*::delete-arg:->delete-args' \ + && ret=0 + case "$state" in + (delete-args) + case $words[1] in + (avd) + _arguments \ + '(-n --name)'{-n,--name}'[name of the AVD to delete]: :_android_avd_names' \ + && ret=0 + ;; + esac + ;; + esac + ;; + (display) + _arguments \ + '1: :_android_display_entities' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + +(( $+functions[_android_cmds] )) || +_android_cmds() { + local commands; commands=( + 'list:list existing targets or virtual devices' + 'create:create new virtual devices or projects' + 'update:update a virtual device, project, SDK or adb' + 'move:move a virtual device' + 'delete:delete a virtual device' + 'avd:displays the AVD Manager window' + 'sdk:displays the SDK Manager window' + 'display:display manager windows' + ) + _describe -t commands 'command' commands "$@" +} + +(( $+functions[_android_list_entities] )) || +_android_list_entities() { + local entities; entities=( + 'avd:list existing Android Virtual Devices' + 'target:list existing targets' + 'sdk:list remote SDK repository' + ) + _describe -t entities 'entity' entities "$@" +} + +(( $+functions[_android_create_entities] )) || +_android_create_entities() { + local entities; entities=( + 'avd:create a new Android Virtual Device' + 'project:create a new Android project' + 'test-project:create a new Android project for a test package' + 'lib-project:create a new Android library project' + ) + _describe -t entities 'entity' entities "$@" +} + +(( $+functions[_android_update_entities] )) || +_android_update_entities() { + local entities; entities=( + 'avd:update an Android Virtual Device to match the folders of a new SDK' + 'project:update an Android project' + 'test-project:update the Android project for a test package' + 'lib-project:update an Android library project' + 'adb:update adb to support the USB devices declared in the SDK add-ons' + 'sdk:update the SDK by suggesting new platforms to install if available' + ) + _describe -t entities 'entity' entities "$@" +} + +(( $+functions[_android_move_entities] )) || +_android_move_entities() { + local entities; entities=( + 'avd:move or rename an Android Virtual Device' + ) + _describe -t entities 'entity' commands "$@" +} + +(( $+functions[_android_delete_entities] )) || +_android_delete_entities() { + local entities; entities=( + 'avd:delete an Android Virtual Device' + ) + _describe -t entities 'entity' entities "$@" +} + +(( $+functions[_android_display_entities] )) || +_android_display_entities() { + local entities; entities=( + 'sdk:display the SDK Manager window' + 'avd:display the AVD Manager window' + ) + _describe -t entities 'entity' entities "$@" +} + +(( $+functions[_android_targets] )) || +_android_targets() { + local targets; targets=(${(f)"$(_call_program targets $service list target --compact)"//:/\\:}) + _describe -t targets 'target' targets "$@" +} + +(( $+functions[_android_avd_names] )) || +_android_avd_names() { + local avd_names; avd_names=(${(f)"$(_call_program targets $service list avd --compact)"//:/\\:}) + _describe -t avd-names 'AVD name' avd_names "$@" +} + +(( $+functions[_android_sdk_update_filters] )) || +_android_sdk_update_filters() { + local filters; filters=(platform tool platform-tool doc sample extra) + _values $@ 'filter' "${filters[@]}" +} + +_android "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_archlinux-java b/home/.zsh-server/plugins/zsh-completions/src/_archlinux-java new file mode 100644 index 0000000..a497f76 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_archlinux-java @@ -0,0 +1,85 @@ +#compdef archlinux-java +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for archlinux-java a tool for selecting default Java runtime (https://wiki.archlinux.org/index.php/java). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_archlinux-java_command_arguments() { + case $words[1] in + (set) + local java_versions=("${(@f)$(archlinux-java status | tail -n +2 | tr -s ' ' | cut -d ' ' -f2)}") + _describe -t output 'Downloads to delete' java_versions + ;; + esac +} + +_archlinux-java() { + local -a commands + + commands=( + "status:List installed Java environments and enabled one" + "get:Return the short name of the Java environment set as default" + "set:Force as default" + "unset:Unset current default Java environment" + "fix:Fix an invalid/broken default Java environment configuration" + "help:Show help" + ) + + _arguments -C \ + '1:cmd:->cmds' \ + '*:: :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + _archlinux-java_command_arguments + ;; + esac +} + +_archlinux-java + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_artisan b/home/.zsh-server/plugins/zsh-completions/src/_artisan new file mode 100644 index 0000000..1104a20 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_artisan @@ -0,0 +1,63 @@ +#compdef artisan +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for artisan (http://laravel.com/docs/artisan). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * loranger (https://github.com/loranger) +# * Yohan Tambè (https://github.com/Cronos87) +# +# ------------------------------------------------------------------------------ + + +_artisan_get_command_list () { + IFS=" " + php artisan --no-ansi | \ + sed "1,/Available commands/d" | \ + awk '/ [a-z]+/ { print $1 }' | \ + sed -E 's/^[ ]+//g' | \ + sed -E 's/[:]+/\\:/g' | \ + sed -E 's/[ ]{2,}/\:/g' +} + +_artisan () { + if [ -f artisan ]; then + local -a commands + IFS=$'\n' + commands=(`_artisan_get_command_list`) + _describe 'commands' commands + fi +} + +compdef _artisan php artisan +compdef _artisan artisan diff --git a/home/.zsh-server/plugins/zsh-completions/src/_atach b/home/.zsh-server/plugins/zsh-completions/src/_atach new file mode 100644 index 0000000..5da9633 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_atach @@ -0,0 +1,71 @@ +#compdef atach +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for atach (https://github.com/sorin-ionescu/atach). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sorin Ionescu +# +# ------------------------------------------------------------------------------ + +local state mode_values existing_sessions ret=1 + +mode_values=( + "none:disable redrawing" + "ctrl_l:use ctrl + l to redraw" + "winch:use sigwinch to redraw" +) + +existing_sessions=($(_call_program session atach)) + +_arguments -C -s -S \ + '(--list -l)'{--list,-l}'[list sessions]' \ + '(--sockets -L)'{--sockets,-L}'[list sockets]' \ + '(--session -s)'{--session=,-s+}'[set the session name]:session' \ + '(--char -c)'{--char=,-c+}'[set the detach character (default: ^\\)]:char' \ + '(--redraw -r)'{--redraw=,-r+}'[set the redraw method (none, ctrl_l, or winch)]:mode:->mode' \ + '(--detached -d)'{--detached,-d}'[start the session detached]' \ + '(--no-detach -D)'{--no-detach,-D}'[disable detaching]' \ + '(--no-suspend -Z)'{--no-suspend,-Z}'[disable suspending]' \ + '(--version -v)'{--version,-v}'[display version and copyright]' \ + '(--help -h)'{--help,-h}'[display help]' \ + '(-)::args:->session-or-command' && ret=0 + +case "$state" in + (mode) + _describe -t mode 'redraw mode' mode_values && ret=0 + ;; + (session-or-command) + _describe -t 'session' 'sessions' existing_sessions && ret=0 + _path_commands && ret=0 + ;; +esac + +return $ret + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_bitcoin-cli b/home/.zsh-server/plugins/zsh-completions/src/_bitcoin-cli new file mode 100644 index 0000000..f953eb4 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_bitcoin-cli @@ -0,0 +1,211 @@ +#compdef bitcoin-cli +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for bitcoin-cli (https://bitcoin.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Ian Ker-Seymer (https://github.com/ianks) +# +# ------------------------------------------------------------------------------ + +_bitcoin-cli() { + local context state line curcontext="$curcontext" + + _arguments -C \ + -?'[This help message]' \ + -conf='[Specify configuration file. Relative paths will be prefixed by datadir location. (default: bitcoin.conf)]:PATH:_files' \ + -datadir='[Specify data directory]:PATH:_directories' \ + -getinfo='[Get general information from the remote server.]' \ + -testnet'[Use the test chain]' \ + -regtest'[Enter regression test mode, which uses a special chain in which blocks can be solved instantly. This is intended for regression testing tools and app development.]' \ + -named'[Pass named instead of positional arguments (default: false)]' \ + -stdin'[Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases)]' \ + -rpcport='[Connect to JSON-RPC on (default: 8332, testnet: 18332, regtest: 18443)]: :_guard "[[\:digit\:]]#" "PORT"' \ + -rpcwait'[Wait for RPC server to start]' \ + -rpcuser='[Username for JSON-RPC connections]:RPCUSER:()' \ + -rpcpassword='[Password for JSON-RPC connections]:RPCPASSWORD:()' \ + -rpcconnect='[Send commands to node running on (default: 127.0.0.1)]:RPCCONNECT:_hosts' \ + -rpcclienttimeout='[Timeout during HTTP requests, or 0 for no timeout. (default: 900)]: :_guard "[[\:digit\:]]#" "RPCCLIENTTIMEOUT"' \ + ':subcommand:->subcommand' && ret=0 + + case $state in + subcommand) + subcommands=( + 'getbestblockhash' + 'getblock' + 'getblockchaininfo' + 'getblockcount' + 'getblockfilter' + 'getblockhash' + 'getblockheader' + 'getblockstats' + 'getchaintips' + 'getchaintxstats' + 'getdifficulty' + 'getmempoolancestors' + 'getmempooldescendants' + 'getmempoolentry' + 'getmempoolinfo' + 'getrawmempool' + 'gettxout' + 'gettxoutproof' + 'gettxoutsetinfo' + 'preciousblock' + 'pruneblockchain' + 'savemempool' + 'scantxoutset' + 'verifychain' + 'verifytxoutproof' + 'getmemoryinfo' + 'getrpcinfo' + 'help' + 'logging' + 'stop' + 'uptime' + 'generatetoaddress' + 'getblocktemplate' + 'getmininginfo' + 'getnetworkhashps' + 'prioritisetransaction' + 'submitblock' + 'submitheader' + 'addnode' + 'clearbanned' + 'disconnectnode' + 'getaddednodeinfo' + 'getconnectioncount' + 'getnettotals' + 'getnetworkinfo' + 'getnodeaddresses' + 'getpeerinfo' + 'listbanned' + 'ping' + 'setban' + 'setnetworkactive' + 'analyzepsbt' + 'combinepsbt' + 'combinerawtransaction' + 'converttopsbt' + 'createpsbt' + 'createrawtransaction' + 'decodepsbt' + 'decoderawtransaction' + 'decodescript' + 'finalizepsbt' + 'fundrawtransaction' + 'getrawtransaction' + 'joinpsbts' + 'sendrawtransaction' + 'signrawtransactionwithkey' + 'testmempoolaccept' + 'utxoupdatepsbt' + 'createmultisig' + 'deriveaddresses' + 'estimatesmartfee' + 'getdescriptorinfo' + 'signmessagewithprivkey' + 'validateaddress' + 'verifymessage' + 'abandontransaction' + 'abortrescan' + 'addmultisigaddress' + 'backupwallet' + 'bumpfee' + 'createwallet' + 'dumpprivkey' + 'dumpwallet' + 'encryptwallet' + 'getaddressesbylabel' + 'getaddressinfo' + 'getbalance' + 'getbalances' + 'getnewaddress' + 'getrawchangeaddress' + 'getreceivedbyaddress' + 'getreceivedbylabel' + 'gettransaction' + 'getunconfirmedbalance' + 'getwalletinfo' + 'importaddress' + 'importmulti' + 'importprivkey' + 'importprunedfunds' + 'importpubkey' + 'importwallet' + 'keypoolrefill' + 'listaddressgroupings' + 'listlabels' + 'listlockunspent' + 'listreceivedbyaddress' + 'listreceivedbylabel' + 'listsinceblock' + 'listtransactions' + 'listunspent' + 'listwalletdir' + 'listwallets' + 'loadwallet' + 'lockunspent' + 'removeprunedfunds' + 'rescanblockchain' + 'sendmany' + 'sendtoaddress' + 'sethdseed' + 'setlabel' + 'settxfee' + 'setwalletflag' + 'signmessage' + 'signrawtransactionwithwallet' + 'unloadwallet' + 'walletcreatefundedpsbt' + 'walletlock' + 'walletpassphrase' + 'walletpassphrasechange' + 'walletprocesspsbt' + 'getzmqnotifications' + ) + + _describe -t subcommands 'bitcoin-cli subcommands' subcommands && ret=0 + esac + + return ret +} + +_bitcoin-cli "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_bower b/home/.zsh-server/plugins/zsh-completions/src/_bower new file mode 100644 index 0000000..69197ea --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_bower @@ -0,0 +1,163 @@ +#compdef bower +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Bower (http://bower.io). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Joe Lencioni (https://github.com/lencioni) +# +# ------------------------------------------------------------------------------ + + +local curcontext="$curcontext" state line _opts ret=1 + +_arguments -C \ + '(- 1 *)'{-v,--version}'[display version information]' \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + +case $state in + cmds) + _values "bower command" \ + "cache[manage bower cache]" \ + "help[display help information about Bower]" \ + "home[opens a package homepage into your favorite browser]" \ + "info[info of a particular package]" \ + "init[interactively create a bower.json file]" \ + "install[install a package locally]" \ + "link[symlink a package folder]" \ + "list[list local packages - and possible updates]" \ + "login[authenticate with GitHub and store credentials]" \ + "lookup[look up a package URL by name]" \ + "prune[removes local extraneous packages]" \ + "register[register a package]" \ + "search[search for a package by name]" \ + "update[update a local package]" \ + "uninstall[remove a local package]" \ + "unregister[remove a package from the registry]" \ + "version[bump a package version]" && ret=0 + _arguments \ + '(--force)--force[make various commands more forceful]' \ + '(--json)--json[output consumable JSON]' \ + '(--log-level)--log-level[what level of logs to report]' \ + "(--offline)--offline[don't hit the network]" \ + '(--quiet)--quiet[only output important information]' \ + "(--silent)--silent[don't output anything, besides errors]" \ + '(--verbose)--verbose[make output more verbose]' \ + '(--allow-root)--allow-root[allow running commands as root]' \ + '(--version)--version[output Bower version]' \ + '(--no-color)--no-color[disable colors]' && ret=0 + ;; + args) + case $line[1] in + help) + _values 'commands' \ + 'cache' \ + 'home' \ + 'info' \ + 'init' \ + 'install' \ + 'link' \ + 'list' \ + 'login' \ + 'lookup' \ + 'prune' \ + 'register' \ + 'search' \ + 'update' \ + 'uninstall' \ + 'unregister' \ + 'version' && ret=0 + ;; + (home|info|init|link|lookup|prune|register|search|unregister) + _arguments \ + '(--help)--help[show help message]' && ret=0 + ;; + install) + _arguments \ + '(--force-latest)--force-latest[force latest version on conflict]' \ + '(--help)--help[show help message]' \ + "(--production)--production[don't install project devDependencies]" \ + "(--save)--save[save installed packages into the project's bower.json dependencies]" \ + "(--save-dev)--save-dev[save installed packages into the project's bower.json devDependencies]" && ret=0 + ;; + list) + _arguments \ + '(--help)--help[show help message]' \ + '(--paths)--paths[generate a simple JSON source mapping]' \ + '(--relative)--relative[make paths relative to the directory config property, which defaults to bower_components]' && ret=0 + ;; + login) + _arguments \ + '(--help)--help[show help message]' \ + '(-t --token)'{-t,--token}'[Pass GitHub auth token (will not prompt for username/password)]' && ret=0 + ;; + uninstall) + _arguments \ + '(--help)--help[show help message]' \ + "(--save)--save[save installed packages into the project's bower.json dependencies]" \ + "(--save-dev)--save-dev[save installed packages into the project's bower.json devDependencies]" && ret=0 + ;; + update) + _arguments \ + '(--force-latest)--force-latest[force latest version on conflict]' \ + '(--help)--help[show help message]' \ + "(--production)--production[don't install project devDependencies]" && ret=0 + ;; + version) + _arguments \ + '(--message)--message[custom git commit and tag message]' && ret=0 + ;; + exec) + _normal && ret=0 + ;; + *) + _opts=( $(bower help $line[1] | sed -e '/^ \[-/!d; s/^ \[\(-[^=]*\)=.*/\1/') ) + _opts+=( $(bower help $line[1] | sed -e '/^ -/!d; s/^ \(-.\), \[\(-[^=]*\)=.*/\1 \2/') ) + if [[ $_opts != "" ]]; then + _values 'option' $_opts && ret=0 + fi + ;; + esac + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_bundle b/home/.zsh-server/plugins/zsh-completions/src/_bundle new file mode 100644 index 0000000..0231f15 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_bundle @@ -0,0 +1,353 @@ +#compdef bundle +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Bundler 2.3.14 (https://bundler.io/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Bruno Michel (https://github.com/nono) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line ret=1 + +_bundle_commands() { + local -a commands=( + "install:Install the gems specified by the Gemfile or Gemfile.lock" + "update:Update dependencies to their latest versions" + "cache:Package the .gem files required by your application" + "exec:Execute a script in the context of the current bundle" + "config:Specify and read configuration options for bundler" + "help:Describe available tasks or one specific task" + "add:Add the named gem to the Gemfile and run bundle install" + "binstubs:Generate binstubs for executables in a gem" + "check:Determine whether the requirements for your application are installed" + "show:Show the source location of a particular gem in the bundle" + "outdated:Show all of the outdated gems in the current bundle" + "console:Start an IRB session in the context of the current bundle" + "open:Open an installed gem in the editor" + "list:Show all of the gems in the current bundle" + "lock:Generate a lockfile for your dependencies" + "viz:Generate a visual representation of your dependencies" + "init:Generate a simple Gemfile, placed in the current directory" + "gem:Create a simple gem, suitable for development with bundler" + "platform:Displays platform compatibility information" + "clean:Clean up unused gems in your Bundler directory" + "doctor:Display warnings about common problems" + "remove:Removes gems from the Gemfile" + ) + + _describe -t commands 'command' commands "$@" +} + +_bundle_gems() { + local -a gems=($(bundle show | awk '/^ / { print $2 }')) + if [[ $? == 0 ]]; then + _values 'gems' $gems + fi +} + +_bundle_groups() { + if [[ -e Gemfile ]]; then + local -a groups=(${(@f)"$(awk '/^ *group *:/{sub(/^ *group *:/, ""); print $1}' Gemfile)"}) + _values 'groups' $groups + fi +} + +_bundle_config_subcommands() { + local subcommands; + subcommands=( + "list:print a list of all bundler configuration" + "get:print the value of that configuration setting" + "set:set defaults to setting configuration" + "unset:delete the configuration" + ) + _describe -t subcommands 'subcommand' subcommands "$@" +} + +_arguments -C -A "-v" -A "--version" \ + '(- 1 *)'{-v,--version}'[display version information]' \ + '(-r --retry)'{-r,--retry}'[specify the number of times you with to attempt network commands]:number:' \ + '(-v --verbose)'{-V,--verbose}'[print out additional logging information]' \ + '--no-color[print all output without color]' \ + '1: :_bundle_commands' \ + '*:: :->args' && ret=0 + +case $state in + args) + case $words[1] in + help) + local -a commands=('install' 'update' 'cache' 'exec' 'config' 'help' 'add' 'binstubs' + 'check' 'show' 'outdated' 'console' 'open' 'list' 'lock' 'lock' 'viz' 'init' + 'gem' 'platform' 'clean' 'doctor' 'remove') + _arguments -C \ + '1: :($commands)' \ + && ret=0 + ;; + install) + local -a policies=('HighSecurity' 'MediumSecurity' 'LowSecurity' 'AlmostNoSecurity' 'NoSecurity') + _arguments \ + '--binstubs=-[generate bin stubs for bundled gems to ./bin]:directory:_files -/' \ + '--clean[remove any gems not present in the current Gemfile]' \ + '--deployment[install using defaults tuned for deployment environments]' \ + '--redownload[force download every gem, even if the required versions are already available locally]' \ + '--frozen[do not allow the Gemfile.lock to be updated after this install]' \ + '--full-index[download and cache the index file of all gems]' \ + '--gemfile=-[use the specified gemfile instead of Gemfile]:gemfile:_files' \ + '(-j --jobs)'{-j,--jobs}'[the maximum number of parallel download and install jobs]:number' \ + '--local[do not attempt to connect to rubygems.org]' \ + '--no-cache[do not update the cache in vendor/cache with newly installed gems]' \ + '--no-prune[do not remove stale gem from cache after installation]' \ + '--path=-[specify a different path than the system default]:path:_files' \ + '--quiet[only output warnings and errors]' \ + '--shebang=-[specify ruby executable to execute scripts]:ruby:_files' \ + '--standalone=-[create standalone bundles]:groups:_bundle_groups' \ + '--system[install to the system location]' \ + "--trust-policy=-[apply the Rubygems security policy]:arg:($policies)" \ + '--with=-[include gems that are part of the specified named group]:groups:_bundle_groups' \ + '--without=-[exclude gems that are part of the specified named group]:groups:_bundle_groups' \ + && ret=0 + ;; + update) + _arguments \ + '--all[update all gems specified in Gemfile]' \ + \*{--group,-g}=-'[only update the gems in the specified group]' \ + '--source=-[the name of a source used in the Gemfile]:url' \ + '--local[do not attempt to fetch gems remotely and use the gem cached instead]' \ + '--ruby[update the locked version of Ruby to the current version of Ruby]' \ + '--bundler[update the locked version of bundler to invoked bundler version]' \ + '--full-index[fall back to using the single-file index of all gems]' \ + '(-j --jobs)'{-j,--jobs}'[specify the number of jobs to run in parallel]:number' \ + '--retry=-[retry failed network or git requests for number times]:number' \ + '--quiet[only output warnings and errors]' \ + '--redownload[force download every gem, even if the required versions are already available locally]' \ + '--patch[prefer updating only to next patch version]' \ + '--minor[prefer updating only to next minor version]' \ + '--major[prefer updating only to next major version (default)]' \ + '--strict[do not allow any gem to be updated past latest --patch | --minor | --major]' \ + '--conservative[use bundle install conservative update behavior]' \ + '*:: :_bundle_gems' \ + && ret=0 + ;; + cache) + _arguments \ + '--all[include all sources]' \ + '--all-platforms[include gems for all platforms present in the lockfile, not only the current one]' \ + '--cache-path=-[specify a different cache path than the default(vendor/cache)]: :_files -/' \ + '--gemfile=-[use the specified gemfile instead of Gemfile]:gemfile:_files' \ + "--no-install[don't install the gems, only update the cache]" \ + "--no-prune[don't remove stale gems from the cache]" \ + '--path=-[specify a different path than the system default($BUNDLE_PATH or $GAM_HOME)]: :_files' \ + '--quite[only output warnings and errors]' \ + '--frozen[do not allow the Gemfile.lock to be updated after this bundle cache operation]' \ + '--no-color[disable colorization in output]' \ + '(-r --retry)'{-r,--retry}=-'[specify the number of times you with to attempt network commands]:nums' \ + '(-V --verbose)'{-v,--verbose}'[enable verbose output mode]' \ + && ret=0 + ;; + exec) + _arguments \ + '--keep-file-descriptors[exec will revert to the 1.9 behavior of passing all file descriptors to the new process]' \ + '*:: :_normal' \ + && ret=0 + ;; + config) + _arguments -C \ + '1: :_bundle_config_subcommands' \ + '--local[use local configuration]' \ + '--global[use global configuration]' \ + && ret=0 + ;; + add) + _arguments \ + '(-v --version)'{-v,--version}=-'[specify version requirements for the added gem]:version' \ + '(-g --group)'{-g,--group}=-'[specify the group for the added gem]:group:_bundle_groups' \ + '(-s --source)'{-s,--source}=-'[specify the source for the added gem]: :_files' \ + '(-r --require)'{-r,--require}=-'[adds require path to gem]: :_files' \ + '--path=-[specify the file path for the added gem]: :_files -/' \ + '--git=-[specify the git source for the added gem]:git' \ + '--github=-[specify the github source for the added gem]:github' \ + '--branch=-[specify the git branch for the added gem]:branch' \ + '--ref=-[specify the git ref for the added gem]' \ + '--skip-install[adds the gem to the Gemfile but does not install it]' \ + '--optimistic[adds optimistic declaration of version]' \ + '--strict[adds strict declaration of version]' \ + '1::gem:' \ + && ret=0 + ;; + binstubs) + _arguments \ + '--force[overwrite existing binstubs if they exist]' \ + '--path=-[the location to install the specified binstubs to]: :_files -/' \ + '--standalone[makes binstubs that can work without depending on Rubygems or Bundler at runtime]' \ + '--shebang=-[specify a different shebang executable name than the default(default: ruby)]: :_files' \ + '--all[create binstubs for all gems in the bundle]' \ + '1::gem:' \ + && ret=0 + ;; + check) + _arguments \ + '--dry-run[locks the Gemfile before running the command]' \ + '--gemfile=-[use the specified gemfile instead of the Gemfile]: :_files' \ + '--path=-[specify a different path than the system default($BUNDLE_PATH or $GEM_HOME)]: :_files -/' \ + && ret=0 + ;; + show) + _arguments \ + '--paths[list the paths of all gems that are required by your Gemfile]' \ + '1:: :_bundle_gems' \ + && ret=0 + ;; + outdated) + _arguments \ + '--local[do not attempt to fetch gems remotely and use the gem cache instead]' \ + '--pre[check for newer pre-release gems]' \ + '--source[check against a specific source]' \ + '--strict[only list newer versions allowed by your Gemfile requirements]' \ + {--parseable,--porcelain}'[use minimal formatting for more parsable output]' \ + '--group=-[list gems from a specific group]:group:_bundle_groups' \ + '--groups[list gems organized by groups]' \ + '--major[prefer updating to next major version(default)]' \ + '--minor[prefer updating only to next minor version]' \ + '--patch[prefer updating only to next patch version]' \ + '--filter-major[only list major new versions]' \ + '--filter-minor[only list minor new versions]' \ + '--filter-patch[only list patch new versions]' \ + '--only-explicit[only list gems specified in your Gemfile, not their dependencies]' \ + '*:: :_bundle_gems' \ + && ret=0 + ;; + console) + _arguments \ + '--no-color[disable colorization in output]' \ + '(-r --retry)'{-r,--retry}=-'[specify the number of times you with to attempt network commands]:num' \ + '(-v --verbose)'{-v,--verbose}=-'[enable verbose output mode]' \ + '1:: :_bundle_groups' \ + && ret=0 + ;; + open) + _arguments \ + '1:: :_bundle_gems' \ + && ret=0 + ;; + list) + _arguments \ + '--name-only[print only the name of each gem]' \ + '--paths[print the path to each gem in the bundle]' \ + '--without-group=-[a space-separated list of groups of gems to skip during printing]: :_bundle_groups' \ + '--only-group=-[a space-separated list of groups of gems to print]: :_bundle_groups' \ + && ret=0 + ;; + lock) + _arguments \ + '--update=-[ignores the existing lockfile]' \ + '--local[do not attempt to connect to rubygems.org]' \ + '--print[prints the lockfile to STDOUT instead of writing to the file system]' \ + '--lockfile=-[the path where the lick file should be written to]: :_files' \ + '--full-index[fall back to using the single file index of all gems]' \ + '--add-platform=-[add a new platform to the lockfile, re-resolving for the addition of that platform]' \ + '--remove-platform=-[remove a platform from the lockfile]' \ + '--patch[if updating, prefer updating only to next patch version]' \ + '--minor[if updating, prefer updating only to next minor version]' \ + '--major[if updating, prefer updating to next major version(default)]' \ + '--strict[if updating, do not allow any gem to be updated past latest --patch | --minor | --major]' \ + '--conservative[if updating, use bundle install conservative update behavior]' \ + && ret=0 + ;; + viz) + _arguments \ + '(-f --file)'{-f,--file}=-'[the name to use for the generated file]: :_files' \ + '(-F --format)'{-F,--format}=-'[output format option]: :(png jpg svg dot)' \ + '(-R --requirements)'{-r,--requirements}'[set to show the version of each required dependency]' \ + '(-v --version)'{-v,--version}'[set to show each version]' \ + '(-W --without)'{-W,--without}'[exclude gems that are part of the specified named group]' \ + && ret=0 + ;; + init) + _arguments \ + '--gemspec=-[use the specified .gemspec to create the Gemfile]: :_files' \ + && ret=0 + ;; + gem) + _arguments \ + '(--exe -b --bin --no-exe)'{--exe,-b,--bin}'[specify that bundler should create a binary executable in the generated rubygem project]' \ + '(--exe -b --bin --no-exe)--no-exe[do not create a binary]' \ + '(--no-coc)--coc[add a CODE_OF_CONDUCT.md to the root of the generated project]' \ + '(--coc)--no-coc[do not create a CODE_OF_CONDUCT.md]' \ + '(--no-ext)--ext[add boilerplate for C extension code to the generated project]' \ + '(--ext)--no-ext[do not add C extension code]' \ + '(--no-mit)--mit[add an MIT license to a LICENSE.txt file in the root of the generated project]' \ + '(--mit)--no-mit[do not create a LICENSE.txt]' \ + '(-t --test)'{-t,--test}=-'[specify the test framework]: :(minitest rspec test-unit)' \ + '--ci=-[specify the continuous integration service]: :(github travis gitlab circle)' \ + '--linter=-[specify the linter and code formatter]: :(rubocop standard)' \ + '(-e --edit)'{-e,--edit}=-'[open the resulting GEM_NAME.gemspec in EDITOR]' \ + '1::gem_name:' \ + && ret=0 + ;; + platform) + _arguments \ + '--ruby[it will display the ruby directive information]' \ + && ret=0 + ;; + clean) + _arguments \ + '--dry-run[print the changes, but do not clean the unused gems]' \ + '--force[forces cleaning up unused gems even if Bundler is configured to use globally installed gems]' \ + && ret=0 + ;; + doctor) + _arguments \ + '--quiet[only output warnings and errors]' \ + '--gemfile=-[the location of the Gemfile which Bundler should use]: :_files' \ + && ret=0 + ;; + remove) + _arguments \ + '--install[runs bundle install after the given gem have been removed from the Gemfile]' \ + '*:: :_bundle_gems' \ + && ret=0 + ;; + esac + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_caffeinate b/home/.zsh-server/plugins/zsh-completions/src/_caffeinate new file mode 100644 index 0000000..afcd569 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_caffeinate @@ -0,0 +1,50 @@ +#compdef caffeinate +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------- +# Description +# ----------- +# +# Completion script for the macOS 'caffeinate' tool (man 8 caffeinate). +# +# ------------------------------------------------------------------------- +# Authors +# ------- +# +# * Nicolas Despres (initial version) +# +# ------------------------------------------------------------------------- + +_arguments -s \ + '-d[prevent the display from sleeping]' \ + '-i[prevent the system from idle sleeping]' \ + '-m[prevent the disk from idle sleeping]' \ + '-s[prevent the system from sleeping but only when running on AC power]' \ + '-u[declare that user is active]' \ + '-t+[assertion timeout value]:delay in seconds' \ + '-w+[waits for process to exit]:pid:_pids' \ + '(-):command: _command_names -e' \ + '*::args: _normal' diff --git a/home/.zsh-server/plugins/zsh-completions/src/_cap b/home/.zsh-server/plugins/zsh-completions/src/_cap new file mode 100644 index 0000000..ef2abee --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_cap @@ -0,0 +1,93 @@ +#compdef cap +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Capistrano 3.17.1 (https://capistranorb.com/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Bruno Michel (https://github.com/nono) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + + +local curcontext="$curcontext" state line cmds ret=1 + +_arguments -C \ + '--backtrace=[Enable full backtrace]: :(stderr stdout)' \ + '--comments[Show commented tasks only]' \ + '--job-stats[Display job statistics]:level' \ + '--suppress-backtrace[Suppress backtrace lines matching regexp PATTERN]:pattern' \ + '(-A --all)'{-A,--all}'[Show all tasks, even uncommented ones]' \ + '(-B --build-all)'{-B,--build-all}'[Build all prerequisites, including those which are up-to-date]' \ + '(-C --directory)'{-C,--directory}'[Change to DIRECTORY before doing anything]: :_files -/' \ + '(-D --describe)'{-D,--describe}'[Describe the tasks, then exit]:pattern' \ + '(-E --execute-continue)'{-E,--execute-continue}'[Execute Ruby code and exit]:code' \ + '(-f --rakefile)'{-f,--rakefile}'[Use FILENAME as the rakefile to search for]: :_files' \ + '(-G --no-system --nosystem)'{-G,--no-system,--nosystem}'[Use standard project Rakefile search paths, ignore system wide rakefiles]' \ + '(-g --system)'{-g,--system}'[Using system wide rakefiles]' \ + '(-I --libdir)'\*{-I,--libdir}'[Include LIBDIR in the search path for required modules]: :_files -/' \ + '(-j --jobs)'{-j,--jobs}'[Specifies the maximum number of tasks to execute in parallel]:num' \ + '(-m --multitask)'{-m,--multitask}'[Treat all tasks as multitasks]' \ + '(-N --no-search --nosearch)'{-N,--no-search,--nosearch}'[Do not search parent directories for the Rakefile]' \ + '(-P --prereqs)'{-P,--prereqs}'[Display the tasks and dependencies, then exit]' \ + '--execute-print[Execute some Ruby code, print the result, then exit]:code' \ + '--require[Require MODULE before executing rakefile]:module' \ + '(-R --rakelibdir --rakelib)'{-R,--rakelibdir,--rakelib}'[Auto-import any .rake files in RAKELIBDIR]: :_files -/' \ + '(-t --trace)'{-t,--trace}'[Turn on invoke/execute tracing, enable full backtrace]: :(stderr stdout)' \ + '(-T --tasks)'{-T,--tasks}'[Display the tasks with descriptions]::pattern' \ + '(-W --where)'{-W,--where}'[Describe the tasks then exit]::pattern' \ + '(-X --no-deprecation-warnings)'{-X,--no-deprecation-warnings}'[Disable the deprecation warnings]' \ + '(- *)'{-V,--version}'[Display the program version]' \ + '(-n --dry-run)'{-n,--dry-run}'[Do a dry run without executing actions]' \ + '(-r --roles)'{-r,--roles}'[Run SSH commands only on hosts matching these roles]:roles' \ + '(-z --hosts)'{-z,--hosts}'[Run SSH commands only on matching hosts]:hosts' \ + '(-p --print-config-variables)'{-p,--print-config-variables}'[Display the defined config variables before starting the deployment tasks]' \ + '(- *)'{-h,-H,--help}'[Display help message]' \ + '*: :->cmds' && ret=0 + +case $state in + cmds) + cmds=( ${(f)"$(_call_program commands cap -T 2>/dev/null | sed -e '/ # /!d; s/:/\\:/g; s/cap \([A-Za-z0-9\\:_-]*\) .*# /\1:/')"} ) + _describe -t commands 'cap command' cmds && ret=0 + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_cask b/home/.zsh-server/plugins/zsh-completions/src/_cask new file mode 100644 index 0000000..b2ba82a --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_cask @@ -0,0 +1,89 @@ +#compdef cask +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for cask (http://cask.readthedocs.org) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * ptrv +# * Johan Andersson +# * Sebastien Duthil +# +# ------------------------------------------------------------------------------ + +function _cask() { + local ret=1 state + _arguments \ + ':subcommand:->subcommand' \ + '*:: :->subcmds' && ret=0 + + case $state in + subcommand) + subcommands=( + "build:build all Elisp files in the files directive" + "clean-elc:remove all byte compiled Elisp files in the files directive" + "exec:execute command with correct 'exec-path' and 'load-path'" + "exec-path:print 'exec-path' for all packages and dependencies" + "files:print list of files specified in the files directive" + "help:display usage information or documentation for specified command" + "info:show info about the current package" + "init:initialize the current directory with a Cask-file" + "install:install all packages specified in the Cask-file" + "link:manage links" + "list:list dependencies" + "load-path:print 'load-path' for all packages and dependencies" + "outdated:print list of outdated packages" + "package:build package and put in specified directory (default: dist)" + "package-directory:print current package installation directory" + "path:print 'exec-path' for all packages and dependencies" + "pkg-file:write a 'define-package' file" + "update:update package version" + "upgrade-cask:upgrade Cask itself and its dependencies" + "upgrade:upgrade Cask itself and its dependencies" + "version:print program version" + ) + _describe -t subcommands 'cask subcommands' subcommands && ret=0 + esac + + case "$words[1]" in + init) + _arguments \ + '(--dev)--dev[Run in dev mode]' && ret=0 ;; + exec) + _generic + ;; + esac + + return ret +} + +_cask "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ccache b/home/.zsh-server/plugins/zsh-completions/src/_ccache new file mode 100644 index 0000000..b4b35cc --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ccache @@ -0,0 +1,325 @@ +#compdef ccache -P -value-,CCACHE_*,-default- + +# zsh completion script for ccache + +# Copyright 2018 CERN for the benefit of the LHCb Collaboration. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# In applying this licence, CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +# allow users to define their better compilers +# inspired by _cmake_compilers +# users could override with +# +# _ccache_compilers() { +# local -a _ccache_compilers +# _ccache_compilers=(gcc g++ clang clang++) +# _wanted compilers expl "compiler" compadd -- $_ccache_compilers +# } +(( $+functions[_ccache_compilers] )) || +_ccache_compilers() { + _command_names -e +} + +_ccache_booleans() { + _message 'There are no "false" values, unset variable to disable' + local description; description=${1:-boolean} + local booleans; booleans=( + 'true' + 'yes' + ) + _describe -t booeans "$description" booleans +} + +(( $+functions[_ccache_compressionlevels] )) || +_ccache_compressionlevels() { + local -a one_nine + one_nine=(1 2 3 4 5 6 7 8 9) + _describe -t onetonine "compression level (if using compression)" one_nine +} + +(( $+functions[_ccache_sloppiness] )) || +_ccache_sloppiness() { + _values -s ',' \ + "file_macro[ignore __FILE__]" \ + "file_stat_matches[rely on mtimes and ctimes]" \ + "include_file_ctime[ignore headers' ctime too new]" \ + "include_file_mtime[ignore headers' mtime too new]" \ + "no_system_headers[exclude system headers from cache]" \ + "pch_defines[be sloppy about #defines in pch]" \ + "time_macros[ignore __date__ and __time__]" +} + +(( $+functions[_ccache_compilerchecks] )) || +_ccache_compilerchecks() { + local -a compiler_check_values + compiler_check_values=( + 'content: the actual compiler binary' + 'mtime: mtime and size of the compiler' + 'none: ignore compiler for hashing' + 'string\:: any hard coded string (pre-computed version)' + '%compiler%\ -v:any compiler invocation output' + ) + _describe -t compilerchecks "compiler information included in the hash" compiler_check_values +} + +(( $+functions[_ccache_dirlevels] )) || +_ccache_dirlevels() { + local -a one_eight + one_eight=(1 2 3 4 5 6 7 8) + _describe -t onetoeight "directory levels in the cache directory" one_eight +} + +if [[ "$service" = -value-* ]]; then + case $service in + *CCACHE_*DIR*) + # CCACHE_BASEDIR: relative to which top level paths are hashed + # CCACHE_DIR: where the cache and config are kept + # CCACHE_TEMPDIR: where temporary files are kept + # all: a single path + _path_files -/ + ;; + *CCACHE_NLEVELS*) + _ccache_dirlevels + ;; + *CCACHE_CC*) + _ccache_compilers + ;; + *CCACHE_COMPILERCHECK*) + _ccache_compilerchecks + ;; + *CCACHE_*COMPRESS*) + _ccache_booleans "write compressed cache" + ;; + *CCACHE_COMPRESSLEVEL*) + _ccache_compressionlevels + ;; + *CCACHE_EXTENSION*) + _alternative ':set extension for intermediate files: ' + ;; + *CCACHE_*DIRECT*) + _ccache_booleans "use direct mode" + ;; + *CCACHE_*DISABLE*) + _ccache_booleans "disable cache usage" + ;; + *CCACHE_EXTRAFILES*) + local sep=: + compset -P "*${sep}" + compset -S "${sep}*" || suf="$sep" + + _files "" -r "${sep}"' /\t\t\-' "$@" + ;; + *CCACHE_*HARDLINK*) + _ccache_booleans "create hard links rather than copies" + ;; + *CCACHE_*HASHDIR*) + _ccache_booleans "include the cwd in the hash" + ;; + *CCACHE_IGNOREHEADERS*) + _dir_list + ;; + *CCACHE_*COMMENTS*) + _ccache_booleans "consider comments in hashing" + ;; + *CCACHE_LIMIT_MULTIPLE*) + _alternative ":clean up down to level (e.g. 0.8): " + ;; + *CCACHE_LOGFILE*) + _path_files -g "*(/) *.log" + ;; + *CCACHE_MAXFILES*) + _alternative ":maximum number of files in the cache (0= no limit): " + ;; + *CCACHE_MAXSIZE*) + _alternative ':maximum cache size (0= no limit) with suffix k,M,G,T or Ki,Mi,Gi,Ti: ' + ;; + *CCACHE_PATH*) + _alternative ':PATH for compiler lookup (instead of $PATH):_dir_list' + ;; + *CCACHE_PREFIX*) + _alternative ':prefixes for compiler invocation: ' + ;; + *CCACHE_PREFIX_CPP*) + _alternative ':prefixes for preprocessor invocation: ' + ;; + *CCACHE_*READONLY*) + _ccache_booleans "treat cache as read-only" + ;; + *CCACHE_*READONLY_DIRECT*) + _ccache_booleans "retrieve from read-only cache in direct mode" + ;; + *CCACHE_*RECACHE*) + _ccache_booleans "use cache in write-only mode" + ;; + *CCACHE_*CPP2*) + _ccache_booleans "pass original rather than preprocessed source code to compiler" + ;; + *CCACHE_SLOPPINESS*) + _ccache_sloppiness + ;; + *CCACHE_*STATS*) + _ccache_booleans "update statistics counters" + ;; + *CCACHE_UMASK*) + _alternative ":umask value (octal): " + ;; + *CCACHE_*UNIFY*) + _ccache_booleans "normalise sources prior to processing" + ;; + esac + + return +fi + +__ccache_config_keys() { + local -a keys + keys=( + 'compression:write compressed cache' + 'direct_mode:use direct mode' + 'disable:disable cache usage' + 'hard_link:create hard links rather than copies' + 'hash_dir:include the cwd in the hash' + 'keep_comments_cpp:consider comments in hashing' + 'read_only:treat cache as read-only' + 'read_only_direct:retrieve from read-only cache in direct mode' + 'recache:use cache in write-only mode' + 'run_second_cpp:pass original rather than preprocessed source code to compiler' + 'stats:update statistics counters' + 'unify:normalise sources prior to processing' + 'base_dir:specify relative to which top level paths are hashed' + 'temporary_dir:specify where temporary files are kept' + 'cache_dir:specify where the cache is kept' + 'compiler:specify compiler' + 'cache_dir_levels:directory levels in the cache directory' + 'compiler_check:compiler information included in the hash' + 'compression_level:cache compression level' + 'cpp_extension:set extensions for intermediate files' + 'extra_files_to_hash:additional files to consider in hashing' + 'ignore_headers_in_manifest:set paths to headers to ignore in hashing' + 'limit_multiple:cleanup level' + 'log_file:specify a log file' + 'max_files:maximum number of files in the cache' + 'max_size:maximum size of the cache' + 'path:PATH for compiler lookup (instead of $PATH)' + 'prefix_command:prefixes for compiler invocation' + 'prefix_command_cpp:prefixes for preprocessor invocation' + 'sloppiness:hash files sloppy' + 'umask:set umask for ccache and child processes (e.g. for sharing cache)' + ) + _describe -t configkeys "configuration keys" keys -S '=' +} + +if compset -P '--set-config=*='; then + case $IPREFIX in + *=compression= | *=direct_mode= | *=disable= | *=hard_link= | *=hash_dir= | *=keep_comments_cpp= | *=read_only= | *=read_only_direct= | *=recache= | *=run_second_cpp= | *=stats= | *=unify= ) + local booleans; booleans=( + 'true' + 'false' + ) + _describe -t booleans 'boolean' booleans + ;; + *=base_dir= | *=temporary_dir= | *=cache_dir=) + _path_files -/ + ;; + *=compiler=) + _ccache_compilers + ;; + *=cache_dir_levels=) + _ccache_dirlevels + ;; + *=compiler_check=) + _ccache_compilerchecks + ;; + *=compression_level=) + _ccache_compressionlevels + ;; + *=cpp_extension=) + _alternative ':set extension for intermediate files: ' + ;; + *=extra_files_to_hash=) + local sep=: + compset -P "*${sep}" + compset -S "${sep}*" || suf="$sep" + + _files "" -r "${sep}"' /\t\t\-' "$@" + ;; + *=ignore_headers_in_manifest=) + _dir_list + ;; + *=limit_multiple=) + _alternative ":clean up down to level (e.g. 0.8): " + ;; + *=log_file=) + _path_files -g "*(/) *.log" + ;; + *=max_files=) + _alternative ":maximum number of files in the cache (0= no limit): " + ;; + *=max_size=) + _alternative ':maximum cache size (0= no limit) with suffix k,M,G,T or Ki,Mi,Gi,Ti: ' + ;; + *=path=) + _alternative ':PATH for compiler lookup (instead of $PATH):_dir_list' + ;; + *=prefix_command=) + _alternative ':prefixes for compiler invocation: ' + ;; + *=prefix_command_cpp=) + _alternative ':prefixes for preprocessor invocation: ' + ;; + *=sloppiness=) + _ccache_sloppiness + ;; + *=umask=) + _alternative ":umask value (octal): " + ;; + esac +elif [[ $words[2] == -* ]]; then + # if the first argument starts with -, we are in configure-ccache mode + _arguments \ + '*'{-o,--set-config=}"[set configuration key]:keys:__ccache_config_keys" \ + '(: -)'{-h,--help}'[show help message]' \ + '(: -)'{-V,--version}'[print version and copyright information]' \ + '(-z --zero-stats)'{-z,--zero-stats}'[zero statistics counters]' \ + '(-c --cleanup)'{-c,--cleanup}'[delete old files and recalculate size counters]' \ + '(-C --clear)'{-C,--clear}'[clear the cache completely (except configuration)]' \ + '(-p --show-config)'{-p,--show-config}'[show current configuration options]' \ + '(-s --show-stats)'{-s,--show-stats}'[show statistics summary]' \ + '(-F --max-files=)'{-F,--max-files=}'[set maximum number of files in cache]:number of files in cache: ' \ + '(-M --max-size=)'{-M,--max-size=}'[set maximum size of cache]:cache size: ' +elif [[ $CURRENT -eq 2 ]]; then + _ccache_compilers +else + # the command line already looks like 'ccache ...' + # forward to the completion function of the compiler + (( CURRENT-- )) + shift words + _normal +fi diff --git a/home/.zsh-server/plugins/zsh-completions/src/_cf b/home/.zsh-server/plugins/zsh-completions/src/_cf new file mode 100644 index 0000000..398a912 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_cf @@ -0,0 +1,994 @@ +#compdef cf +# ------------------------------------------------------------------------------ +# +# Copyright 2015 Ferran Rodenas & Danny Rosen +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ +# +# Description +# ----------- +# +# Completion script for Cloud Foundry CLI (https://github.com/cloudfoundry/cli#downloads) +# +# ------------------------------------------------------------------------------ +# +# Authors +# ------- +# +# * Ferran Rodenas (https://github.com/frodenas) +# * Danny Rosen (https://github.com/dannyzen) +# +# ------------------------------------------------------------------------------ + +# ---------------------- +# ----- Helper functions +# ---------------------- + +# Output a selectable list of organizations +__cf_orgs() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf orgs | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'ORG' cont_cmd +} + +# Output a selectable list of spaces +__cf_spaces() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf spaces | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SPACE' cont_cmd +} + +# Output a selectable list of applications +__cf_apps() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf apps | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'APP' cont_cmd +} + +# Output a selectable list of stacks +__cf_stacks() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf stacks | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'STACK' cont_cmd +} + +# Output a selectable list of services +__cf_marketplace_services() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf marketplace | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SERVICE' cont_cmd +} + +# Output a selectable list of services +__cf_services() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf services | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SERVICE' cont_cmd +} + +# Output a selectable list of domains +__cf_domains() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v shared | awk 'NR>2{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'DOMAIN' cont_cmd +} + +# Output a selectable list of shared domains +__cf_shared_domains() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v owned | awk 'NR>2{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SHARED-DOMAIN' cont_cmd +} + +# Output a selectable list of hostnames +__cf_hostnames() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf routes | awk 'NR>3{print $2}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'ROUTE' cont_cmd +} + +# Output a selectable list of buildpacks +__cf_buildpacks() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf buildpacks | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'BUILDPACK' cont_cmd +} + +# Output a selectable list of feature flags +__cf_feature_flags() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf feature-flags | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'FEATURE-FLAG' cont_cmd +} + +# Output a selectable list of plugin repos +__cf_repo_plugins() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf list-plugin-repos | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'REPO-PLUGIN' cont_cmd +} + +# Output a selectable list of plugins +__cf_plugins() { + declare -a cont_cmd + cont_cmd=($(cf plugins | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'PLUGIN' cont_cmd +} + +# Output a selectable list of targets (requires cf-targets plugin) +__cf_targets() { + declare -a cont_cmd + cont_cmd=($(cf targets | awk '{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'TARGET' cont_cmd +} + + +# -------------------------- +# ----- end Helper functions +# -------------------------- + +# -------------- +# ----- Commands +# -------------- + +__login() { + _arguments \ + '-a=[API endpoint (e.g. https://api.example.com)]:api endpoint:' \ + '-u=[Username]:username:' \ + '-p=[Password]:password:' \ + '-o=[Organization]:organization name:__cf_orgs' \ + '-s=[Space]:space name:__cf_spaces' \ + '--sso[Use a one-time password to login]' \ + '--skip-ssl-validation[Skip SSL validation]' +} + +__logout() { + # no arguments +} + +__passwd() { + _arguments \ + '1:password:' +} + +__target() { + _arguments \ + '-o=[Organization]:organization name:__cf_orgs' \ + '-s=[Space]:space name:__cf_spaces' +} + +__api() { + _arguments \ + '1:API url:' \ + '--unset[Remove all api endpoint targeting]' \ + '--skip-ssl-validation[Skip SSL validation]' +} + +__auth() { + # no arguments +} + +__apps() { + # no arguments +} + +__app() { + _arguments \ + '1:application name:__cf_apps' \ + '--guid[Retrieve and display the given app guid. All other health and status output for the app is suppressed]' +} + +__push() { + _arguments \ + '1:application name:__cf_apps' \ + '-b=[Custom buildpack by name (e.g. my-buildpack) or GIT URL or GIT BRANCH URL]:buildpack name:__cf_buildpacks' \ + '-c=[Startup command, set to null to reset to default start command]:startup command:' \ + '-d=[Domain (e.g. example.com)]:domain (e.g. example.com):__cf_domains' \ + '-f=[Path to manifest]:file:_files:' \ + '-i=[Number of instances]:number of instances:' \ + '-k=[Disk limit (e.g. 256M, 1024M, 1G)]:disk limit (e.g. 256M, 1024M, 1G):' \ + '-m=[Memory limit (e.g. 256M, 1024M, 1G)]:memory limit (e.g. 256M, 1024M, 1G):' \ + '-n=[Hostname (e.g. my-subdomain)]:hostname (e.g. my-subdomain):' \ + '-p=[Path to app directory or to a zip file of the contents of the app directory]:file:_files' \ + '-s=[Stack to use (a stack is a pre-built file system, including an operating system, that can run apps)]:stack name:__cf_stacks:' \ + '-t=[Maximum time (in seconds) for CLI to wait for application start, other server side timeouts may apply]:maximum time (in seconds):' \ + '--no-hostname[Map the root domain to this app]' \ + '--no-manifest[Ignore manifest file]' \ + '--no-route[Do not map a route to this app and remove routes from previous pushes of this app]' \ + '--no-start[Do not start an app after pushing]' \ + '--random-route[Create a random route for this app]' +} + +__scale() { + _arguments \ + '1:application name:__cf_apps' \ + '-i=[Number of instances]:number of instances:' \ + '-k=[Disk limit (e.g. 256M, 1024M, 1G)]:disk limit (e.g. 256M, 1024M, 1G):' \ + '-m=[Memory limit (e.g. 256M, 1024M, 1G)]:memory limit (e.g. 256M, 1024M, 1G):' \ + '-f[Force restart of app without prompt]' +} + +__delete() { + _arguments \ + '1:application name:__cf_apps' \ + '--f[Force deletion without confirmation]' \ + '--r[Also delete any mapped routes]' +} + +__rename() { + _arguments \ + '1:application name:__cf_apps' \ + '2:application name:' +} + +__start() { + _arguments \ + '1:application name:__cf_apps' +} + +__stop() { + _arguments \ + '1:application name:__cf_apps' +} + +__restart() { + _arguments \ + '1:application name:__cf_apps' +} + +__restage() { + _arguments \ + '1:application name:__cf_apps' +} + +__restart-app-instance() { + _arguments \ + '1:application name:__cf_apps' \ + '2:application index:' +} + +__events() { + _arguments \ + '1:application name:__cf_apps' +} + +__files() { + _arguments \ + '1:application name:__cf_apps' \ + '2::path:' \ + '-i=[instance]' +} + +__logs() { + _arguments \ + '1:application name:__cf_apps' \ + '--recent[Dump recent logs instead of tailing]' +} + +__env() { + _arguments \ + '1:application name:__cf_apps' +} + +__set-env() { + _arguments \ + '1:application name:__cf_apps' \ + '2:env var name:' \ + '3:env var value:' +} + +__unset-env() { + _arguments \ + '1:application name:__cf_apps' \ + '2:env var name:' +} + +__stacks() { + # no arguments +} + +__stack() { + _arguments \ + '1:stack name:__cf_stacks' \ + '--guid[Retrieve and display the given stack guid. All other output for the stack is suppressed]' +} + +__copy-source() { + _arguments \ + '1:source application name:__cf_apps' \ + '2:target application name:' \ + '-o=[Org that contains the target application]:organization name:__cf_orgs' \ + '-s=[Space that contains the target application]:space name:__cf_spaces' \ + '--no-restart[Override restart of the application in target environment after copy-source completes]' +} + +__create-app-manifest() { + _arguments \ + '1:application name:__cf_apps' \ + '-p=[Specify a path for file creation. If path not specified, manifest file is created in current working directory]:path:_files' +} + +__marketplace() { + _arguments \ + '-s=[Show plan details for a particular service offering]' +} + +__services() { + # no arguments +} + +__service() { + _arguments \ + '1:service name:__cf_services' \ + '--guid[Retrieve and display the given service guid. All other output for the service is suppressed]' +} + +__create-service() { + _arguments \ + '1:service:__cf_marketplace_services' \ + '2:plan:' \ + '3:service name:' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' \ + '-t=[User provided tags]' +} + +__update-service() { + _arguments \ + '1:service name:__cf_services' \ + '-p=[Change service plan for a service instance]' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' \ + '-t=[User provided tags]' +} + +__rename-service() { + _arguments \ + '1:service name:__cf_services' \ + '2:service name:' +} + +__delete-service() { + _arguments \ + '1:service name:__cf_services' \ + '-f[Force deletion without confirmation]' +} + +__create-service-key() { + _arguments \ + '1:service name:__cf_services' \ + '2:service key:' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' +} + +__service-keys() { + _arguments \ + '1:service name:__cf_services' +} + +__service-key() { + _arguments \ + '1:service name:__cf_services' \ + '2:service key:' +} + +__delete-service-key() { + _arguments \ + '1:service name:__cf_services' \ + '2:service key:' \ + '-f[Force deletion without confirmation]' +} + +__bind-service() { + _arguments \ + '1:application name:__cf_apps' \ + '2:service name:__cf_services' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' +} + +__unbind-service() { + _arguments \ + '1:application name:__cf_apps' \ + '2:service name:__cf_services' +} + +__create-user-provided-service() { + _arguments \ + '1:service name:' \ + '-p=[Credentials]' \ + '-l=[Syslog Drain Url]' +} + +__update-user-provided-service() { + _arguments \ + '1:service name:__cf_services' \ + '-p=[Credentials]' \ + '-l=[Syslog Drain Url]' +} + +__orgs() { + # no arguments +} + +__org() { + _arguments \ + '1:organization name:__cf_orgs' \ + '--guid[Retrieve and display the given org guid. All other output for the org is suppressed]' +} + +__create-org() { + _arguments \ + '1:organization name:' \ + '-q=[Quota to assign to the newly created org (excluding this option results in assignment of default quota)]' +} + +__delete-org() { + _arguments \ + '1:organization name:__cf_orgs' \ + '-f[Force deletion without confirmation]' +} + +__spaces() { + # no arguments +} + +__space() { + _arguments \ + '1:space name:__cf_spaces' \ + '--guid[Retrieve and display the given space guid. All other output for the space is suppressed]' \ + '--security-group-rules[Retrieve the rules for all the security groups associated with the space]' +} + +__create-space() { + _arguments \ + '1:space name:' \ + '-o=[Org that contains the target application]:organization name:__cf_orgs' \ + '-q=[Quota to assign to the newly created space (excluding this option results in assignment of default quota)]' +} + +__delete-space() { + _arguments \ + '1:space name:__cf_spaces' \ + '-f[Force deletion without confirmation]' +} + +__domains() { + # no arguments +} + +__create-domain() { + _arguments \ + '1:organization name:__cf_orgs' \ + '2:domain:' +} + +__delete-domain() { + _arguments \ + '1:domain:__cf_domains' \ + '-f[Force deletion without confirmation]' +} + +__create-shared-domain() { + _arguments \ + '1:domain:' +} + +__delete-shared-domain() { + _arguments \ + '1:domain:__cf_shared_domains' \ + '-f[Force deletion without confirmation]' +} + +__routes() { + _arguments \ + '--orglevel[List all the routes for all spaces of current organization]' +} + +__create-route() { + _arguments \ + '1:space name:__cf_spaces' \ + '2:domain:__cf_domains' \ + '-n=[Hostname]' +} + +__check-route() { + _arguments \ + '1:hostname:__cf_hostnames' \ + '2:domain:__cf_domains' +} + +__map-route() { + _arguments \ + '1:application name:__cf_apps' \ + '2:domain:__cf_domains' \ + '-n=[Hostname]:hostname:__cf_hostnames:' +} + +__unmap-route() { + _arguments \ + '1:application name:__cf_apps' \ + '2:domain:__cf_domains' \ + '-n=[Hostname]:hostname:__cf_hostnames:' +} + +__delete-route() { + _arguments \ + '1:domain:__cf_domains' \ + '-n=[Hostname]:hostname:__cf_hostnames:' \ + '-f[Force deletion without confirmation]' +} + +__delete-orphaned-routes() { + _arguments \ + '-f[Force deletion without confirmation]' +} + +__buildpacks() { + # no arguments +} + +__create-buildpack() { + _arguments \ + '1:buildpack name:' \ + '2:path:_files' \ + '3:position:' \ + '--enable[Enable the buildpack to be used for staging]' \ + '--disable[Disable the buildpack from being used for staging]' +} + +__update-buildpack() { + _arguments \ + '1:buildpack name:__cf_buildpacks' \ + '-p=[Path to directory or zip file]:file:_files' \ + '-i=[The order in which the buildpacks are checked during buildpack auto-detection]' \ + '--enable[Enable the buildpack to be used for staging]' \ + '--disable[Disable the buildpack from being used for staging]' \ + '--lock[Lock the buildpack to prevent updates]' \ + '--unlock[Unlock the buildpack to enable updates]' +} + +__rename-buildpack() { + _arguments \ + '1:buildpack name:__cf_buildpacks' \ + '2:new buildpack name:' +} + +__delete-buildpack() { + _arguments \ + '1:buildpack name:__cf_buildpacks' \ + '-f[Force deletion without confirmation]' +} + +__running-environment-variable-group() { + # no arguments +} + +__staging-environment-variable-group() { + # no arguments +} + +__set-staging-environment-variable-group() { + # no arguments +} + +__set-running-environment-variable-group() { + # no arguments +} + +__feature-flags() { + # no arguments +} + +__feature-flag() { + _arguments \ + '1:feature name:__cf_feature_flags' +} + +__enable-feature-flag() { + _arguments \ + '1:feature name:__cf_feature_flags' +} + +__disable-feature-flag() { + _arguments \ + '1:feature name:__cf_feature_flags' +} + +__curl() { + _arguments \ + '1:path:' \ + '-i[Include response headers in the output]' \ + '-v[Enable CF_TRACE output for all requests and responses]' \ + '-X=[HTTP method]:http method:(GET POST PUT DELETE)' \ + '-h=[Custom headers to include in the request, flag can be specified multiple times]' \ + '-d=[HTTP data to include in the request body]' \ + '--output[Write curl body to FILE instead of stdout]' +} + +__config() { + _arguments \ + '--async-timeout=[Timeout for async HTTP requests]' \ + '--trace=[Trace HTTP requests]:trace:(true false)' \ + '--color=[Enable or disable color]:color:(true false)' \ + '--locale=[Set default locale. If LOCALE is CLEAR, previous locale is deleted]' +} + +__oauth-token() { + # no arguments +} + +__add-plugin-repo() { + _arguments \ + '1:repo name:' \ + '2:url:' +} + +__remove-plugin-repo() { + _arguments \ + '1:repo name:__cf_repo_plugins' \ + '2:url:' +} + +__list-plugin-repos() { + # no arguments +} + +__repo-plugins() { + _arguments \ + '-r=[Repo Name]:repo name:__cf_repo_plugins' +} + +__plugins() { + _arguments \ + '-checksum[Compute and show the sha1 value of the plugin binary file]' +} + +__install-plugin() { + _arguments \ + '1:plugin URL or path:_files' \ + '-r=[repo name where the plugin binary is located]:repo name:__cf_repo_plugins' +} + +__uninstall-plugin() { + _arguments \ + '1:plugin name:__cf_plugins' +} + +__save-target() { + _arguments \ + '1:target-name:' \ + '-f[Force save even if current target is already saved under another name]' +} + +__set-target() { + _arguments \ + '1:target-name:__cf_targets' \ + '-f[Force target change even if current target is unsaved]' +} + +__delete-target() { + _arguments \ + '1:target-name:__cf_targets' +} + +# ------------------ +# ----- end Commands +# ------------------ + +# ------------------- +# ----- 1st Arguments +# ------------------- + +local -a _1st_arguments +_1st_arguments=( + "login":"Log user in" + "logout":"Log user out" + "passwd":"Change user password" + "target":"Set or view the targeted org or space" + "api":"Set or view target api url" + "auth":"Authenticate user non-interactively" + "apps":"List all apps in the target space" + "app":"Display health and status for app" + "push":"Push a new app or sync changes to an existing app" + "scale":"Change or view the instance count, disk space limit, and memory limit for an app" + "delete":"Delete an app" + "rename":"Rename an app" + "start":"Start an app" + "stop":"Stop an app" + "restart":"Restart an app" + "restage":"Restage an app" + "restart-app-instance":"Terminate the running application Instance at the given index and instantiate a new instance of the application with the same index" + "events":"Show recent app events" + "files":"Print out a list of files in a directory or the contents of a specific file" + "logs":"Tail or show recent logs for an app" + "env":"Show all env variables for an app" + "set-env":"Set an env variable for an app" + "unset-env":"Remove an env variable" + "stacks":"List all stacks" + "stack":"Show information for a stack" + "copy-source":"Make a copy of app source code from one application to another. Unless overridden, the copy-source command will restart the application" + "create-app-manifest":"Create an app manifest for an app that has been pushed successfully" + "marketplace":"List available offerings in the marketplace" + "services":"List all service instances in the target space" + "service":"Show service instance info" + "create-service":"Create a service instance" + "update-service":"Update a service instance" + "delete-service":"Delete a service instance" + "rename-service":"Rename a service instance" + "create-service-key":"Create key for a service instance" + "service-keys":"List keys for a service instance" + "service-key":"Show service key info" + "delete-service-key":"Delete a service key" + "bind-service":"Bind a service instance to an app" + "unbind-service":"Unbind a service instance from an app" + "create-user-provided-service":"Make a user-provided service instance available to cf apps" + "update-user-provided-service":"Update user-provided service instance name value pairs" + "orgs":"List all orgs" + "org":"Show org info" + "create-org":"Create an org" + "delete-org":"Delete an org" + "rename-org":"Rename an org" + "spaces":"List all spaces in an org" + "space":"Show space info" + "create-space":"Create a space" + "delete-space":"Delete a space" + "rename-space":"Rename a space" + "domains":"List domains in the target org" + "create-domain":"Create a domain in an org for later use" + "delete-domain":"Delete a domain" + "create-shared-domain":"Create a domain that can be used by all orgs (admin-only)" + "delete-shared-domain":"Delete a shared domain" + "routes":"List all routes in the current space or the current organization" + "create-route":"Create a url route in a space for later use" + "check-route":"Perform a simple check to determine whether a route currently exists or not" + "map-route":"Add a url route to an app" + "unmap-route":"Remove a url route from an app" + "delete-route":"Delete a route" + "delete-orphaned-routes":"Delete all orphaned routes (e.g.: those that are not mapped to an app)" + "buildpacks":"List all buildpacks" + "create-buildpack":"Create a buildpack" + "update-buildpack":"Update a buildpack" + "rename-buildpack":"Rename a buildpack" + "delete-buildpack":"Delete a buildpack" + "running-environment-variable-group":"Retrieve the contents of the running environment variable group" + "staging-environment-variable-group":"Retrieve the contents of the staging environment variable group" + "set-staging-environment-variable-group":"Pass parameters as JSON to create a staging environment variable group" + "set-running-environment-variable-group":"Pass parameters as JSON to create a running environment variable group" + "feature-flags":"Retrieve list of feature flags with status of each flag-able feature" + "feature-flag":"Retrieve an individual feature flag with status" + "enable-feature-flag":"Enable the use of a feature so that users have access to and can use the feature" + "disable-feature-flag":"Disable the use of a feature so that users have access to and can use the feature" + "curl":"Executes a raw request, content-type set to application/json by default" + "config":"write default values to the config" + "oauth-token":"Retrieve and display the OAuth token for the current session" + "add-plugin-repo":"Add a new plugin repository" + "remove-plugin-repo":"Remove a plugin repository" + "list-plugin-repos":"list all the added plugin repository" + "repo-plugins":"List all available plugins in all added repositories" + "plugins":"list all available plugin commands" + "install-plugin":"Install the plugin defined in command argument" + "uninstall-plugin":"Uninstall the plugin defined in command argument" + "targets":"List all saved targets (requires cf-targets plugin)" + "save-target":"Save the current target under a given name (requires cf-targets plugin)" + "set-target":"Restore a previously saved target (requires cf-targets plugin)" + "delete-target":"Delete a saved target (requires cf-targets plugin)" +) + +# ----------------------- +# ----- end 1st Arguments +# ----------------------- + +# ---------- +# ----- Main +# ---------- + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "cf command" _1st_arguments + return +fi + +local -a _command_args +case "$words[1]" in + login) + __login ;; + logout) + __logout ;; + passwd) + __passwd ;; + target) + __target ;; + api) + __api ;; + auth) + __auth ;; + apps) + __apps ;; + app) + __app ;; + push) + __push ;; + scale) + __scale ;; + delete) + __delete ;; + rename) + __rename ;; + start) + __start ;; + stop) + __stop ;; + restart) + __restart ;; + restage) + __restage ;; + restart-app-instance) + __restart-app-instance ;; + events) + __events ;; + files) + __files ;; + logs) + __logs ;; + env) + __env ;; + set-env) + __set-env ;; + unset-env) + __unset-env ;; + stacks) + __stacks ;; + stack) + __stack ;; + copy-source) + __copy-source ;; + create-app-manifest) + __create-app-manifest ;; + marketplace) + __marketplace ;; + services) + __services ;; + service) + __service ;; + create-service) + __create-service ;; + update-service) + __update-service ;; + rename-service) + __rename-service ;; + delete-service) + __delete-service ;; + create-service-key) + __create-service-key ;; + service-keys) + __service-keys ;; + service-key) + __service-key ;; + delete-service-key) + __delete-service-key ;; + bind-service) + __bind-service ;; + unbind-service) + __unbind-service ;; + create-user-provided-service) + __create-user-provided-service ;; + update-user-provided-service) + __update-user-provided-service ;; + orgs) + __orgs ;; + org) + __org ;; + create-org) + __create-org ;; + delete-org) + __delete-org ;; + spaces) + __spaces ;; + space) + __space ;; + create-space) + __create-space ;; + delete-space) + __delete-space ;; + domains) + __domains ;; + create-domain) + __create-domain ;; + delete-domain) + __delete-domain ;; + create-shared-domain) + __create-shared-domain ;; + delete-shared-domain) + __delete-shared-domain ;; + routes) + __routes ;; + create-route) + __create-route ;; + check-route) + __check-route ;; + map-route) + __map-route ;; + unmap-route) + __unmap-route ;; + delete-route) + __delete-route ;; + delete-orphaned-routes) + __delete-orphaned-routes ;; + buildpacks) + __buildpacks ;; + create-buildpack) + __create-buildpack ;; + update-buildpack) + __update-buildpack ;; + rename-buildpack) + __rename-buildpack ;; + delete-buildpack) + __delete-buildpack ;; + running-environment-variable-group) + __running-environment-variable-group ;; + staging-environment-variable-group) + __staging-environment-variable-group ;; + set-staging-environment-variable-group) + __set-staging-environment-variable-group ;; + set-running-environment-variable-group) + __set-running-environment-variable-group ;; + feature-flags) + __feature-flags ;; + feature-flag) + __feature-flag ;; + enable-feature-flag) + __enable-feature-flag ;; + disable-feature-flag) + __disable-feature-flag ;; + curl) + __curl ;; + config) + __config ;; + oauth-token) + __oauth-token ;; + add-plugin-repo) + __add-plugin-repo ;; + remove-plugin-repo) + __remove-plugin-repo ;; + list-plugin-repos) + __list-plugin-repos ;; + repo-plugins) + __repo-plugins ;; + plugins) + __plugins ;; + install-plugin) + __install-plugin ;; + uninstall-plugin) + __uninstall-plugin ;; + save-target) + __save-target ;; + set-target) + __set-target ;; + delete-target) + __delete-target ;; +esac diff --git a/home/.zsh-server/plugins/zsh-completions/src/_choc b/home/.zsh-server/plugins/zsh-completions/src/_choc new file mode 100644 index 0000000..3ac8c59 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_choc @@ -0,0 +1,60 @@ +#compdef choc +# ------------------------------------------------------------------------------ +# Copyright (c) 2012 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for choc (http://chocolatapp.com) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Nicholas Penree (https://github.com/drudge) +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_arguments -C \ + '(-a --async)'{-a,--async}'[do not wait for the user to close the file in Chocolat]' \ + '(-w --wait)'{-w,--wait}'[wait for file to be closed by Chocolat]' \ + '(-n --no-reactivation)'{-n,--no-reactivation}'[after editing with -w, do not reactivate the calling app]' \ + '(-h --help)'{-h,--help}'[show help information]' \ + '(-v --version)'{-v,--version}'[print version information]' \ + '*:script or directory:_files' && ret=0 + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_chromium b/home/.zsh-server/plugins/zsh-completions/src/_chromium new file mode 100644 index 0000000..917739b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_chromium @@ -0,0 +1,211 @@ +#compdef chromium + +# Copyright 2018 CERN for the benefit of the LHCb Collaboration + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of CERN nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# In applying this licence, CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +_arguments \ + "--user-data-dir=[Specify the directory that user data is kept in]:directory:_path_files -/" \ + "--app=[Runs URL in app mode]:url:_urls" \ + "--incognito[Open in incognito mode]" \ + "--new-window[open in new window]" \ + "(--no-proxy-server --proxy-auto-detect --proxy-pac-url --password-store)--proxy-server=[specify proxy server]:[\://][\:]:_chromium_proxyurls" \ + "--no-proxy-server[Disables the proxy server]" \ + "--proxy-auto-detect[Autodetect proxy configuration]" \ + "--proxy-pac-url=[Specify proxy autoconfiguration URL]:proxy autoconfiguration url:_urls" \ + "--password-store=[Set the password store to use]:password store: _wanted arguments expl 'wallet store' compadd -- basic gnome kwallet" \ + "--version[print version]" \ + "*:: :{ _alternative _urls _files }" + +# excerpt from the chromium help message: +# +# Specify the HTTP/SOCKS4/SOCKS5 proxy server to use for requests. This overrides any environment variables or settings picked via the options dialog. An individual proxy server is specified +# using the format: +# +# +# +# Where is the protocol of the proxy server, and is one of: +# +# "http", "socks", "socks4", "socks5". +# +# If the is omitted, it defaults to "http". Also note that "socks" is equivalent to "socks5". +# +# Examples: +# +# --proxy-server="foopy:99" +# Use the HTTP proxy "foopy:99" to load all URLs. +# +# --proxy-server="socks://foobar:1080" +# Use the SOCKS v5 proxy "foobar:1080" to load all URLs. +# +# --proxy-server="socks4://foobar:1080" +# Use the SOCKS v4 proxy "foobar:1080" to load all URLs. +# +# --proxy-server="socks5://foobar:66" +# Use the SOCKS v5 proxy "foobar:66" to load all URLs. +# +# It is also possible to specify a separate proxy server for different URL types, by prefixing the proxy server specifier with a URL specifier: +# +# Example: +# +# --proxy-server="https=proxy1:80;http=socks4://baz:1080" +# Load https://* URLs using the HTTP proxy "proxy1:80". And load http://* +# URLs using the SOCKS v4 proxy "baz:1080". +# + +_chromium_proxyurls () { + #TODO: semicolon separated urls not yet implemented + # mostly copied from _urls + local ipre scheme host user uhosts ret=1 expl match glob suf + local localhttp + zstyle -a ":completion:${curcontext}:urls" local localhttp + local localhttp_servername="$localhttp[1]" + local localhttp_documentroot="$localhttp[2]" + local localhttp_userdir="$localhttp[3]" + zstyle -a ":completion:${curcontext}:urls" urls urls + if [[ $#urls -gt 1 || ( $#urls -eq 1 && ! -d $urls[1] ) ]] + then + [[ $#urls -eq 1 && -f $urls[1] ]] && urls=($(< $urls[1])) + _wanted urls expl 'URL' compadd "$@" -a urls && return 0 + urls=() + fi + urls="$urls[1]" + glob=(-g '*(^/)') + zparseopts -D -K -E 'g:=glob' + ipre="$IPREFIX" + if ! compset -P '(#b)([-+.a-z0-9]#):' + then + _tags -C argument prefixes + while _tags + do + while _next_label prefixes expl 'URL prefix' -S '' "$@" + do + compset -S '[^:/]*' && compstate[to_end]='' + compadd "$expl[@]" http:// socks:// socks4:// socks5:// && ret=0 + done + (( ret )) || return 0 + done + return 1 + fi + scheme="$match[1]" + case "$scheme" in + (http(|s)|socks(|4|5)) if ! compset -P // + then + _wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" // + return + fi ;; + (file) [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P '//(127.0.0.1|localhost)' + [[ -prefix /// ]] && compset -P // + if ! compset -P // + then + _tags -C file files + while _tags + do + while _next_label files expl 'local file' + do + if [[ -prefix / ]] + then + _path_files "$expl[@]" -S '' "${glob[@]}" && ret=0 + _path_files "$expl[@]" -S/ -r '/' -/ && ret=0 + elif [[ -z "$PREFIX" ]] + then + compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0 + fi + done + (( ret )) || return 0 + done + return 1 + fi ;; + esac + if ! compset -P '(#b)([^:/]#)([:/])' + then + uhosts=($urls/$scheme/$PREFIX*$SUFFIX(/:t)) + _tags hosts + while _tags + do + while _next_label hosts expl host + do + compset -S '[:/]*' || suf="/" + (( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0 + [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername) + compadd -S "$suf" -r '/:' "$expl[@]" -a uhosts && ret=0 + done + (( ret )) || return 0 + done + return 1 + fi + host="$match[1]" + [[ $match[2] = ':' ]] && ! compset -P '<->/' && _message -e ports 'port number' && return 0 + _tags remote-files files || return 1 + if [[ "$localhttp_servername" = "$host" ]] + then + if compset -P \~ + then + if ! compset -P '(#b)([^/]#)/' + then + _users -S/ "$@" + return + fi + user="$match[1]" + while _tags + do + while _next_label files expl 'local file' + do + _path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0 + _path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0 + done + (( ret )) || return 0 + done + else + while _tags + do + while _next_label files expl 'local file' + do + _path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0 + _path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0 + done + (( ret )) || return 0 + done + fi + else + while _tags + do + (( $#urls )) && while _next_label files expl 'local file' + do + _path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0 + _path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0 + done + [[ $scheme = (scp|sftp) ]] && _requested remote-files && _remote_files -h $host -- ssh && ret=0 + (( ret )) || return 0 + done + fi + return $ret +} diff --git a/home/.zsh-server/plugins/zsh-completions/src/_cmake b/home/.zsh-server/plugins/zsh-completions/src/_cmake new file mode 100644 index 0000000..b97921f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_cmake @@ -0,0 +1,592 @@ +#compdef cmake -value-,CMAKE_GENERATOR,-default- +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------- +# Description +# ----------- +# +# Completion script for CMake 3.25.0 (https://cmake.org). +# +# ------------------------------------------------------------------------- +# Authors +# ------- +# +# * Scott M. Kroll (initial version) +# * Paul Seyfert (handling of --build and updates) +# * Norbert Lange (presets, command mode, updates) +# +# ------------------------------------------------------------------------- +# Notes +# ----- +# +# * By default only C and C++ languages are supported for compiler flag +# variables. To define your own list of languages: +# +# cmake_langs=('C' 'C' +# 'CXX' 'C++') +# zstyle ':completion:*:cmake:*' languages $cmake_langs +# +# ------------------------------------------------------------------------- + +local context state line curcontext="$curcontext" cmake_args + +local -a cmake_build_options=( + '-S[Explicitly specify a source directory]:source directory:_path_files -/' + '-B[Explicitly specify a build directory]:build directory:_path_files -/' + '-C[Pre-load a script to populate the cache]:initial cache:_files' + '*-D-[Create a cmake cache entry]:property:_cmake_define_property' + '*-U[Remove matching entries from CMake cache]:globbing expression' + '-G[Specify a makefile generator]:generator:_cmake_generators' + '-T[Specify toolset name if supported by generator]:toolset name' + '-A[Specify platform name if supported by generator]:platform name' + '--toolchain[Specify toolchain file]: :_files' + '--install-prefix[Specify install directory]: :_path_files -/' + + # Warnings + '(-Wdev)-Wno-dev[Suppress/Enable developer warnings]' + '(-Wno-dev)-Wdev[Suppress/Enable developer warnings]' + '(-Wdeprecated)-Wno-deprecated[Suppress/Enable deprecation warnings]' + '(-Wno-deprecated)-Wdeprecated[Suppress/Enable deprecation warnings]' + '(-Werror=dev)-Wno-error=dev[Make developer warnings (not) errors]' + '(-Wno-error=dev)-Werror=dev[Make developer warnings (not) errors]' + '(-Wno-error=deprecated)-Werror=deprecated[Make deprecated macro and function warnings (not) errors]' + '(-Werror=deprecated)-Wno-error=deprecated[Make deprecated macro and function warnings (not) errors]' + + '--preset=[Specify a configure preset]:preset:_cmake_presets' + '--list-presets[List available presets]' + + '-E[CMake command mode]:command:_cmake_command_help' + + '-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"' + '--fresh[Configure a fresh build tree, removing any existing cache file]' + + '--build[Build a CMake-generated project binary tree]:project directory:_path_files -/' + '--install[Install a CMake-generated project binary tree]:project directory:_path_files -/' + '--open[Open generated project in the associated application]:project directory:_path_files -/' + + '-N[View mode only]' + '-P[Process script mode]:script:_files' + + '--find-package[Legacy pkg-config like mode. Do not use]' + + '--graphviz=[Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more]:graphviz output:_files' + '--system-information[Dump information about this system]::system information output:_files' + + '--log-level=[Set the verbosity of messages from CMake files]:log level:(ERROR WARNING NOTICE STATUS VERBOSE DEBUG TRACE)' + '--log-context[Prepend log messages with context, if given]' + + '--debug-trycompile[Do not delete the try_compile build tree. Only useful on one try_compile at a time]' + '--debug-output[Put cmake in a debug mode]' + '--debug-find[Put cmake find in a debug mode]' + + '(--trace-expand)--trace[Put cmake in trace mode]' + '(--trace)--trace-expand[Put cmake in trace mode with variable expansion]' + '--trace-format=[Set the output format of the trace]:trace format:(human json-v1)' + '*--trace-source[Trace only this CMake file/module. Multiple options allowed]:filename:_files' + '--trace-redirect[Redirect trace output to a file instead of stderr]:trace output:_files' + + '--warn-uninitialized[Warn about uninitialized values]' + '--no-warn-unused-cli[Do not warn about command line options]' + '--warn-unused-vars[Warn about unused variables]' + '--check-system-vars[Find problems with variable usage in system files]' + '--compile-no-warning-as-error[Ignore COMPILE_WARNING_AS_ERROR property and CMAKE_COMPILE_WARNING_AS_ERROR variable]' + + '--profiling-format[Output data for profiling CMake scripts]:profiling format:(google-trace)' + '--profiling-output[Select an output path for the profiling data]:filename:_files' + + ':cmake project:_path_files -/' +) + +# ------------------------ +# _cmake_generator_options +# +# arguments are $1: build working directory (top level Makefile or build.ninja file) +# $2: position of "--" in the command line +# ------------------------ +(( $+functions[_cmake_generator_options] )) || +_cmake_generator_options() { + # pass only the part of the command line starting at "--" to the completion + shift (( $2 - 1 )) words + (( CURRENT = $CURRENT + 1 - $2 )) + if [ -f $1/Makefile ] + then + $_comps[make] + elif [ -f $1/build.ninja ] + then + $_comps[ninja] + fi +} + +# -------------- +# _cmake_presets +# -------------- +(( $+functions[_cmake_presets] )) || +_cmake_presets() { + local invoke; invoke=(${(Q)words}) + invoke[$CURRENT]=() + # TODO: remove all arguments -* except -S + + local list_presets; list_presets=(${(f)"$(${invoke} --list-presets 2>/dev/null | + sed -n -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' \ + -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*$,\1,p')"}) + + _describe 'presets' list_presets +} + +# -------------- +# _cmake_targets +# -------------- +(( $+functions[_cmake_targets] )) || +_cmake_targets() { + local -a targets + if [ -f $1/Makefile ] + then + # `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does. + i=1 + for target in $(make -f $1/Makefile help | \grep -e "\.\.\." | sed "s/\.\.\. //" | sed "s/ (the default.*//") ; do + targets[$i]=$target + (( i = $i + 1 )) + done + elif [ -f $1/build.ninja ] + then + # `ninja help` doesn't seem to be the list of targets we're interested in + i=1 + for target in $(ninja -C $1 -t targets all 2&>/dev/null | awk -F: '{print $1}') ; do + targets[$i]="$target" + (( i++ )) + done + fi + _describe 'build targets' targets +} + +_cmake_suggest_builddirs() { + _alternative ':current directory:(.)' 'directory::_directories' && return 0 +} + +_cmake_suggest_installdirs() { + _alternative ':current directory:(.)' 'directory::_directories' && return 0 +} + +_cmake_on_build() { + local build_extras;build_extras=( + '--[Native build tool options]' + '--target[specify build target]' + '--clean-first[build target clean first]' + '--config[For multi-configuration tools]' + '--parallel[maximum number of build processes]' + '--use-stderr') + local -a undescribed_build_extras + i=1 + for be in $build_extras ; do + undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") + (( i++ )) + done + inbuild=false + dashdashposition=-1 + for ((i = (($CURRENT - 1)); i > 1 ; i--)); do + if [[ $words[$i] == --build ]] ; then + inbuild=true + buildat=$i + (( difference = $CURRENT - $i )) + elif [[ $words[$i] == -- ]] ; then + dashdashposition=$i + fi + done + # check if build mode has been left + outofbuild=false + for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do + # don't check the word after --build (should be a directory) + if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --target ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi + outofbuild=true + done + if (( $dashdashposition > 0 )) ; then + _cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 + fi + if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then + # either there is no --build or completing the directory after --build + _arguments -C -s \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_build[@]" && return 0 + elif [[ $words[(($CURRENT - 1))] == --target ]] ; then + # after --build --target, suggest targets + _cmake_targets $words[(($buildat + 1))] && return 0 + elif [[ $words[(($CURRENT - 1))] == --config ]] ; then + # after --build --config, no idea + return 0 + elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then + # after --build --parallel + return 0 + elif [ "$outofbuild" = true ] ; then + # after --build --, suggest other cmake_build_options (like -Wno-dev) + _arguments "$cmake_build_options[@]" && return 0 + else + # after --build , suggest other cmake_build_options (like -Wno-dev) or --build options (like --clean-first) + _arguments "$build_extras[@]" "$cmake_build_options[@]" && return 0 + fi +} + +_cmake_on_install() { + local build_extras;build_extras=( + '--[Native build tool options]' + '--prefix[Override the installation prefix, CMAKE_INSTALL_PREFIX]' + '--config[For multi-configuration generators(e.g. Visual Studio)]' + '--component[Component-based install]' + '--strip[Strip before installing.]' + ) + local -a undescribed_build_extras + i=1 + for be in $build_extras ; do + undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") + (( i++ )) + done + inbuild=false + dashdashposition=-1 + for ((i = (($CURRENT - 1)); i > 1 ; i--)); do + if [[ $words[$i] == --install ]] ; then + inbuild=true + buildat=$i + (( difference = $CURRENT - $i )) + elif [[ $words[$i] == -- ]] ; then + dashdashposition=$i + fi + done + outofbuild=false + for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do + # don't check the word after --install (should be a directory) + if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --prefix ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --component ]] ; then continue ; fi + outofbuild=true + done + if (( $dashdashposition > 0 )) ; then + _cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 + fi + if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then + # either there is no --install or completing the directory after --install + _arguments -C -s \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_install[@]" && return 0 + elif [[ $words[(($CURRENT - 1))] == --prefix ]] ; then + # after --install --prefix, no idea + return 0 + elif [[ $words[(($CURRENT - 1))] == --config ]] ; then + # after --install --config, no idea + return 0 + elif [[ $words[(($CURRENT - 1))] == --component ]] ; then + # after --build --component, no idea + return 0 + elif [ "$outofbuild" = true ] ; then + # after --build --, suggest other cmake_build_options (like -Wno-dev) + _arguments "$cmake_build_options[@]" && return 0 + else + # after --build , suggest other cmake_build_options (like -Wno-dev) or --build options (like --clean-first) + _arguments "$build_extras[@]" "$cmake_build_options[@]" && return 0 + fi +} + +local -a cmake_help_actions=( + '(- 1)'{--help,-help,-usage,-h,-H}'[Print usage information and exit]' + '(- 1)'{--version,-version}'[Print version number and exit]' + '(- 1)--help-full[Print all help manuals and exit]' + '(- 1)--help-manual[Print one help manual and exit]:module-name: _cmake_list_names --help-manual-list "manual name"' + '(- 1)--help-manual-list[List help manuals available and exit]' + '(- 1)--help-command[Print help for one command and exit]:command-name: _cmake_list_names --help-command-list "command name"' + '(- 1)--help-command-list[List commands with help available and exit]' + '(- 1)--help-commands[Print cmake-commands manual and exit]' + '(- 1)--help-module[Print help for one module and exit]:module-name: _cmake_list_names --help-module-list "module name"' + '(- 1)--help-module-list[List modules with help available and exit]' + '(- 1)--help-modules[Print cmake-modules manual and exit]' + '(- 1)--help-policy[Print help for one policy and exit]:policy-name: _cmake_list_names --help-policy-list "policy name"' + '(- 1)--help-policy-list[List policies with help available and exit]' + '(- 1)--help-policies[Print cmake-policies manual and exit]' + '(- 1)--help-property[Print help for one property and exit]:property-name: _cmake_list_names --help-property-list "property name" brakremove' + '(- 1)--help-property-list[List properties with help available and exit]' + '(- 1)--help-properties[Print cmake-properties manual and exit]' + '(- 1)--help-variable[Print help for one variable and exit]:variable-name: _cmake_list_names --help-variable-list "variable name" brakremove' + '(- 1)--help-variable-list[List variables with help available and exit]' + '(- 1)--help-variables[Print cmake-variables manual and exit]' +) +_cmake_help() { + _arguments -C -s - help "$cmake_help_actions[@]" +} + +# ----------------- +# _cmake_list_names +# ----------------- +(( $+functions[_cmake_list_names] )) || +_cmake_list_names() { + local command; command="$@[1]" + local desc; desc="$@[2]" + local opts; opts=($@[3]) + local list_names; list_names=(${(f)"$($service $command 2> /dev/null)"}) + # Older CMake (< 3.0) writes out the version + list_names=(${^list_names##cmake version*}) + + if [[ ${opts[(i)brakremove]} -le ${#opts} ]]; then + list_names=(${^list_names//\[/\\\[}) + list_names=(${^list_names//\]/\\\]}) + fi + + _values ${desc} ${list_names[@]:-1} && return 0 +} + +# ---------------------- +# _cmake_define_property +# ---------------------- +(( $+functions[_cmake_define_property] )) || +_cmake_define_property() { + if compset -P '*='; then + _wanted property-values expl 'property value' _cmake_define_property_values ${${IPREFIX%=}#-D} && return 0 + else + _wanted property-names expl 'property name' _cmake_define_property_names -qS= && return 0 + fi +} + +# ---------------------------- +# _cmake_define_property_names +# ---------------------------- +(( $+functions[_cmake_define_property_names] )) || +_cmake_define_property_names() { + local alternatives; alternatives=( + 'common-property-names:common property name:_cmake_define_common_property_names -qS=' + ) + local -A cmake_langs + zstyle -a ":completion:${curcontext}:" languages cmake_langs + [[ $#cmake_langs -eq 0 ]] && cmake_langs=('C' 'C' 'CXX' 'C++') + + for cmake_lang in ${(k)cmake_langs}; do + cmake_lang_desc="${cmake_langs[$cmake_lang]}" + alternatives+=("${cmake_lang//:/-}-property-names:${cmake_lang_desc} language property name:_cmake_define_lang_property_names -qS= ${cmake_lang} ${cmake_lang_desc}") + done + + _alternative "${alternatives[@]}" +} + +# --------------------------------- +# _cmake_define_lang_property_names +# --------------------------------- +(( $+functions[_cmake_define_lang_property_names] )) || +_cmake_define_lang_property_names() { + local cmake_lang="$@[-2]" cmake_lang_desc="$@[-1]" + local properties; properties=( + "CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler" + "CMAKE_${cmake_lang}_COMPILER_LAUNCHER:${cmake_lang_desc} compiler launcher (e.g. ccache)" + "CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds" + "CMAKE_${cmake_lang}_FLAGS_DEBUG:${cmake_lang_desc} compiler flags for all Debug build" + "CMAKE_${cmake_lang}_FLAGS_RELEASE:${cmake_lang_desc} compiler flags for all Release build" + "CMAKE_${cmake_lang}_FLAGS_MINSIZREL:${cmake_lang_desc} compiler flags for all MinSizRel build" + "CMAKE_${cmake_lang}_FLAGS_RELWITHDEBINFO:${cmake_lang_desc} compiler flags for all RelWithDebInfo build" + "CMAKE_${cmake_lang}_STANDARD:${cmake_lang_desc} language standard" + "CMAKE_${cmake_lang}_STANDARD_REQUIRED:${cmake_lang_desc} language standard is required" + "CMAKE_${cmake_lang}_EXTENSIONS:${cmake_lang_desc} enable compiler specific extensions" + ) + + _describe -t "${cmake_lang//:/-}-property-names" "${cmake_lang_desc} property name" properties $@[0,-3] && return 0 +} + +# ----------------------------------- +# _cmake_define_common_property_names +# ----------------------------------- +(( $+functions[_cmake_define_common_property_names] )) || +_cmake_define_common_property_names() { + local properties; properties=( + 'CMAKE_MODULE_PATH:Search path for CMake modules (FindPROJECT.cmake)' + 'CMAKE_PREFIX_PATH:Search path for installations (PROJECTConfig.cmake)' + 'CMAKE_BUILD_TYPE:Specifies the build type for make based generators' + 'CMAKE_TOOLCHAIN_FILE:Absolute or relative path to a CMake script which sets up toolchain related variables' + 'CMAKE_COLOR_MAKEFILE:Enables/disables color output when using the Makefile generator' + 'CMAKE_INSTALL_PREFIX:Install directory used by install' + 'CMAKE_EXPORT_COMPILE_COMMANDS:Enable/disable output of compilation database during generation' + 'CMAKE_RULE_MESSAGES:Specify whether to report a message for each make rule' + 'CMAKE_VERBOSE_MAKEFILE:Enable verbose output from Makefile builds' + 'CMAKE_UNITY_BUILD:Batch include source files' + ) + + _describe -t 'common-property-names' 'common property name' properties $@ +} + +local _cmake_build_types=('Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel') +local _cmake_c_standards=(90 99 11) +local _cmake_cxx_standards=(98 11 14 17 20) + +# ---------------------------- +# _cmake_define_property_values +# ---------------------------- +(( $+functions[_cmake_define_property_values] )) || +_cmake_define_property_values() { + local ret=1 + setopt localoptions extendedglob + case $@[-1] in + (CMAKE_BUILD_TYPE) _wanted build-types expl 'build type' _values 'build type' ${_cmake_build_types[@]} && ret=0;; + (CMAKE_CXX_STANDARD) _wanted cxx-standards expl 'cxx standard' _values 'cxx standard' ${_cmake_cxx_standards[@]} && ret=0;; + (CMAKE_C_STANDARD) _wanted c-standards expl 'c standard' _values 'c standard' ${_cmake_c_standards[@]} && ret=0;; + (CMAKE_TOOLCHAIN_FILE) _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0;; + (CMAKE_COLOR_MAKEFILE) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_RULE_MESSAGES) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_VERBOSE_MAKEFILE) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_UNITY_BUILD) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_INSTALL_PREFIX) _files -/ && ret=0;; + (CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_*_COMPILER) _wanted compilers expl 'compiler' _cmake_compilers && ret=0;; + (CMAKE_*_COMPILER_LAUNCHER) _wanted compilers expl 'compiler launcher' _cmake_launchers && ret=0;; + (CMAKE_*_FLAGS(|_?*)) _message -e compiler-flags 'compiler flags' && _dispatch $service -value-,CPPFLAGS,-default- && ret=0;; + (CMAKE_*_STANDARD_REQUIRED) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_*_EXTENSIONS) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (*) _files && ret=0;; + esac + + return ret +} + +local -a _cmake_generator_list=(${(f)"$(cmake --help | awk '/^Generators/{flag=1} flag && /^[* ] [^ ]/ {sub(/^[* ] /, ""); sub(/=.*$/, ""); sub(/\[arch\]/, ""); sub(/ *$/, ""); print}')"}) + +# ----------------- +# _cmake_generators +# ----------------- +(( $+functions[_cmake_generators] )) || +_cmake_generators() { + _describe -t generators 'generator' _cmake_generator_list +} + +# ---------------------- +# _cmake_toolchain_files +# ---------------------- +(( $+functions[_cmake_toolchain_files] )) || +_cmake_toolchain_files() { + _files -g '*\.cmake*' +} + +local _cmake_booleans=(_describe -t booleans 'boolean' 'YES' 'NO') + +# --------------- +# _cmake_compilers +# +# by default just executable commands, but can be overridden by users. +# --------------- +(( $+functions[_cmake_compilers] )) || +_cmake_compilers() { + _command_names -e +} + +# --------------- +# _cmake_launchers +# +# by default just executable commands, but can be overridden by users. +# useful commands might be ccache, distcc, ... +# --------------- +(( $+functions[_cmake_launchers] )) || +_cmake_launchers() { + _command_names -e +} + +local -a _cmake_commands=( + 'capabilities:Report capabilities built into cmake in JSON format' \ + 'cat:concat the files and print them to the standard output' \ + 'chdir:run command in a given directory' \ + 'compare_files:check if file1 is same as file2' \ + 'copy:copy files to destination (either file or directory)' \ + 'copy_directory:copy content of ... directories to destination directory' \ + 'copy_if_different:copy files if it has changed' \ + 'echo:displays arguments as text' \ + 'echo_append:displays arguments as text but no new line' \ + 'env:run command in a modified environment' \ + 'environment:display the current environment' \ + 'make_directory:create parent and directories' \ + 'md5sum:create MD5 checksum of files' \ + 'sha1sum:create SHA1 checksum of files' \ + 'sha224sum:create SHA224 checksum of files' \ + 'sha256sum:create SHA256 checksum of files' \ + 'sha384sum:create SHA384 checksum of files' \ + 'sha512sum:create SHA512 checksum of files' \ + 'remove:remove the file(s), use -f to force it' \ + 'remove_directory:remove directories and their contents' \ + 'rename:rename a file or directory (on one volume)' \ + 'rm:remove files or directories' \ + 'server:start cmake in server mode' \ + 'sleep:sleep for given number of seconds' \ + 'tar:create or extract a tar or zip archive' \ + 'time:run command and display elapsed time' \ + 'touch:touch a ' \ + 'touch_nocreate:touch a but do not create it' \ + 'create_symlink:create a symbolic link new -> old' \ + 'create_hardlink:create a hard link new -> old' \ + 'true:do nothing with an exit code of 0' \ + 'false:do nothing with an exit code of 1' +) +_cmake_command() { + _arguments -C \ + '-E[CMake command mode]:command:(("${_cmake_commands[@]}"))' + +} +local cmake_suggest_build;cmake_suggest_build=( + '--build[build]:build dir:_cmake_suggest_builddirs' +) + +local cmake_suggest_install;cmake_suggest_install=( + '--install[install]:install dir:_cmake_suggest_installdirs' +) + +if [[ "$service" = -value-*CMAKE_GENERATOR* ]]; then + _cmake_generators +elif [ $CURRENT -eq 2 ] ; then + _arguments -C -s \ + - help \ + "$cmake_help_actions[@]" \ + - command \ + '-E[CMake command mode]:command:( )' \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_build[@]" \ + - install_cmds \ + "$cmake_suggest_install[@]" && return 0 +elif [[ $words[2] = --help* ]] ; then + _cmake_help +elif [[ $words[2] == --build ]] ; then + _cmake_on_build +elif [[ $words[2] == --install ]] ; then + _cmake_on_install +elif [[ $words[2] == -E ]]; then + _cmake_command +else + _arguments "$cmake_build_options[@]" +fi + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_coffee b/home/.zsh-server/plugins/zsh-completions/src/_coffee new file mode 100644 index 0000000..ebe36e6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_coffee @@ -0,0 +1,76 @@ +#compdef coffee +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Coffee.js v2.7.0 (https://coffeescript.org/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Mario Fernandez (https://github.com/sirech) +# * Dong Weiming (https://github.com/dongweiming) +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_arguments -s -S \ + '--ast[generate an abstract syntax tree of nodes]' \ + '(-b --bare)'{-b,--bare}'[compile without a top-level function wrapper]' \ + '(-c --compile)'{-c,--compile}'[compile to JavaScript and save as .js files]' \ + '(-e --eval)'{-e,--eval}'[pass a string from the command line as input]:Inline Script' \ + '(- *)'{-h,--help}'[display this help message]' \ + '(-i --interactive)'{-i,--interactive}'[run an interactive CoffeeScript REPL]' \ + '(-j --join)'{-j,--join}'[concatenate the source CoffeeScript before compiling]: :_files -g "*.coffee"' \ + '(-l --literate)'{-l,--literate}'[treat stdio as literate style coffeescript]' \ + '(-m --map)'{-m,--map}'[generate source map and save as .js.map files]' \ + '(-M --inline-map)'{-M,--inline-map}'[generate source map and include it directly in output]' \ + '(-n --nodes)'{-n,--nodes}'[print out the parse tree that the parser produces]' \ + '--nodejs[pass options directly to the "node" binary]' \ + '(-o --output)'{-o,--output}'[set the output directory for compiled JavaScript]: :_files' \ + '(-p --print --tokens)'{-p,--print}'[print out the compiled JavaScript]' \ + '(-r --require)'\*{-r,--require}'[require the given module before eval or REPL]:module' \ + '(-s --stdio)'{-s,--stdio}'[listen for and compile scripts over stdio]' \ + '(-t --transpile)'{-t,--transpile}'[pipe generated JavaScript through Babel]' \ + '(-p --print --tokens)--tokens[print out the tokens that the lexer/rewriter produce]' \ + '(- *)'{-v,--version}'[display the version number]' \ + '(-w --watch)'{-w,--watch}'[watch scripts for changes and rerun commands]' \ + '*:script or directory:_files' && ret=0 + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_conan b/home/.zsh-server/plugins/zsh-completions/src/_conan new file mode 100644 index 0000000..aa29915 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_conan @@ -0,0 +1,626 @@ +#compdef conan +# ------------------------------------------------------------------------------ +# Copyright (c) 2010-2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for conan 0.28.1 (https://www.conan.io). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_conan() { + + local context state state_descr line + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)'{-v,--version}'[display version information]' \ + '(-h --help)1: :_conan_commands' \ + '(-h --help)*:: :->command_args' + + case $state in + command_args) + (( $+functions[_conan_${words[1]}_args] )) && _conan_${words[1]}_args + ;; + esac +} + +(( $+functions[_conan_commands] )) || +_conan_commands() { + local consumer_commands creator_commands package_development_commands misc_commands deprecated_commands + consumer_commands=( + 'install:installs the requirements specified in a "conanfile.py" or "conanfile.txt"' + 'config:manages conan configuration information' + 'get:gets a file or list a directory of a given reference or package' + 'info:prints information about a package recipe'\''s dependency graph' + 'search:search package recipes and binaries in the local cache or in a remote server' + ) + creator_commands=( + 'new:creates a new package recipe template with a '\''conanfile.py'\''' + 'create:export, build package and test it with a consumer project' + 'upload:uploads a package recipe and the generated binary packages to a specified remote' + 'export:copies the package recipe (conanfile.py and associated files) to your local cache' + 'export-pkg:exports a recipe & creates a package with given files calling '\''package'\''' + 'test:runs a test-folder/conanfile.py to test an existing package' + ) + package_development_commands=( + 'source:calls your conanfile.py "source()" method to configure the source directory' + 'build:utility command to run your current project "conanfile.py" build() method' + 'package:calls your conanfile.py "package" method for a specific package recipe' + ) + misc_commands=( + 'profile:list profiles in the ".conan/profiles" folder, or show profile details' + 'remote:handles the remote list and the package recipes associated to a remote' + 'user:update your cached user name (and auth token) to avoid it being requested later' + 'imports:execute the "imports" stage of a conanfile.txt or a conanfile.py' + 'copy:copy conan recipes and packages to another user/channel.' + 'remove:remove any package recipe or binary matching a pattern' + 'alias:creates and export an alias recipe' + ) + _describe -t 'consumer-commands' "consumer commands" consumer_commands + _describe -t 'creator-commands' "creator commands" creator_commands + _describe -t 'package-development-commands' "package development commands" package_development_commands + _describe -t 'misc-commands' "misc commands" misc_commands +} + +(( $+functions[_conan_alias_args] )) || +_conan_alias_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1:alias reference:_conan_package_references' \ + '(-h --help)2:target reference:_conan_package_references' +} + +(( $+functions[_conan_build_args] )) || +_conan_build_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + "(-h --help -f --file)"{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \ + "(-h --help -sf --source-folder)"{-sf,--source-folder}'[local folder containing the sources. Defaulted to the directory of the conanfile. A relative path can also be specified (relative to the current directory)]: :_files -/' \ + "(-h --help -bf --build-folder)"{-bf,--build-folder}'[build folder, working directory of the build process. Defaulted to the current directory. A relative path can also be specified (relative to the current directory)]: :_files -/' \ + "(-h --help -pf --package-folder)"{-pf,--package-folder}'[folder to install the package (when the build system or build() method does it). Defaulted to the '\''{build_folder}/package'\'' folder. A relative path can be specified, relative to the current folder. Also an absolute path is allowed.]: :_files -/' \ + "(-h --help -if --install-folder)"{-if,--install-folder}'[local folder containing the conaninfo.txt and conanbuildinfo.txt files (from a previous conan install execution). Defaulted to --build-folder]: :_files -/' \ + '(-h --help)1: :_conan_conanfiles' +} + +(( $+functions[_conan_config_args] )) || +_conan_config_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_config_commands' \ + '(-h --help)*:: :->command_args' + + case $state in + command_args) + (( $+functions[_conan_config_${words[1]}_args] )) && _conan_config_${words[1]}_args + ;; + esac +} + +(( $+functions[_conan_config_commands] )) || +_conan_config_commands() { + local commands + commands=( + 'rm:rm an existing config element' + 'set:set/add value' + 'get:get the value of existing element' + 'install:install a full configuration from a zip file, local or remote' + ) + _describe -t 'commands' "command" commands +} + +(( $+functions[_conan_config_rm_args] )) || +_conan_config_rm_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_config_keys' +} + +(( $+functions[_conan_config_get_args] )) || +_conan_config_get_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_config_keys' +} + +(( $+functions[_conan_config_set_args] )) || +_conan_config_set_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_config_set_key_values' +} + +(( $+functions[_conan_config_set_key_values] )) || +_conan_config_set_key_values() { + local ret=1 + if compset -P '*='; then + _wanted property-values expl 'config value' _conan_config_values ${IPREFIX%=} && ret=0 + else + _wanted property-names expl 'config key' _conan_config_keys -qS= && ret=0 + fi + return ret +} + +(( $+functions[_conan_config_install_args] )) || +_conan_config_install_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1:config file:_files' +} + +(( $+functions[_conan_copy_args] )) || +_conan_copy_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + "(-h --help --all -p --package)"{-p,--package}'[copy specified package ID]:package reference:_conan_package_references' \ + '(-h --help --all -p --package)--all[copy all packages from the specified package recipe]' \ + '(-h --help --force)--force[override destination packages and the package recipe]' \ + '(-h --help)1: :_conan_package_references' \ + '(-h --help)2: :_conan_user_channels' +} + +(( $+functions[_conan_export_args] )) || +_conan_export_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help -p --path)'{-p,--path}'[folder with a conanfile.py (default current directory)]: :_files -/' \ + '(-h --help -k --keep-source)'{-k,--keep-source}'[do not remove the source folder in the local cache]' \ + '(-h --help -f --file)'{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \ + '(-h --help)1: :_conan_channel_or_package_references' +} + +(( $+functions[_conan_get_args] )) || +_conan_get_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + "(-h --help -p --package)"{-p,--package}'[package ID]: :_conan_package_references' \ + '(-h --help -r --remote)'{-r,--remote}'[get from this specific remote]: :_conan_remotes' \ + '(-h --help -raw --raw)'{-raw,--raw}'[do not decorate the text]' \ + '(-h --help)1: :_conan_package_references' \ + '(-h --help)2:file or directory path:_files' +} + +(( $+functions[_conan_imports_args] )) || +_conan_imports_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help -f --file)'{-f,--file}'[use another filename]: :_conan_conanfiles' \ + '(-h --help -imf --import-folder)'{-imf,--import-folder}'[directory to copy the artifacts to. By default it will be the current directory]: :_files -/' \ + '(-h --help -if --install-folder)'{-if,--install-folder}'[local folder containing the conaninfo.txt and conanbuildinfo.txt files (from a previous conan install execution)]: :_files -/' \ + '(-h --help -u --undo)'{-u,--undo}'[undo imports (remove imported files)]' \ + '(-h --help)1: :_conan_directory_or_package_references' +} + +(( $+functions[_conan_info_args] )) || +_conan_info_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help -f --file)'{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \ + '(-h --help -n --only)'{-n,--only}'[filter fields]: :_conan_info_only_values' \ + '(-h --help --paths)--paths[show package paths in local cache]' \ + '(-h --help --package-filter)--package-filter[print information only for packages that match the filtere.g., MyPackage/1.2@user/channel or MyPackage*]: :_conan_package_references' \ + '(-h --help -bo --build_order)'{-bo,--build_order}'[given a modified reference, return an ordered list to build (CI)]' \ + '(-h --help -j --json)'{-j,--json}'[only with --build_order option, return the information in a json]: :_files -g "*.json"' \ + '(-h --help -g --graph)'{-g,--graph}'[creates file with project dependencies graph]: :_files -g "*.(dot|html)"' \ + '(-h --help -u --update)'{-u,--update}'[check updates exist from upstream remotes]' \ + '(-h --help -sc --scope)'{-sc,--scope}'[use the specified scope in the install command]: :_conan_scopes' \ + '(-h --help -pr --profile)'{-pr,--profile}'[apply the specified profile to the install command]: :_conan_profiles' \ + '(-h --help -r --remote)'{-r,--remote}'[look in the specified remote server]: :_conan_remotes' \ + '(-h --help)'{-o,--options}'[options to build the package, overwriting the defaults. e.g., -o with_qt=true]: :_conan_options' \ + '(-h --help)'{-s,--settings}'[settings to build the package, overwriting the defaults. e.g., -s compiler=gcc]: :_conan_settings' \ + '(-h --help)'{-e,--env}'[environment variables that will be set during the package build, -e CXX=/usr/bin/clang++]: :_conan_environment_variables' \ + '(-h --help -b --build)'{-b,--build}'[given a build policy (same install command "build" parameter), return an ordered list of packages that would be built from sources in install command (simulation)]: :_conan_build_policies' \ + '(-h --help)1: :_conan_conanfiles_or_package_references' +} + +(( $+functions[_conan_info_only_values] )) || +_conan_info_only_values() { + local values + values=( + 'id:show only "id"' + 'build_id:show only "build_id"' + 'remote:show only "remote"' + 'url:show only "url"' + 'license:show only "license"' + 'requires:show only "requires"' + 'update:show only "update"' + 'required:show only "required"' + 'date:show only "date"' + 'author:show only "author"' + 'export_folder:use with --paths' + 'build_folder:use with --paths' + 'package_folder:use with --paths' + 'source_folder:use with --paths' + 'None:show only references' + ) + _describe -t 'values' "value" values +} + +(( $+functions[_conan_install_args] )) || +_conan_install_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help -f --file)'{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \ + '(-h --help -g --generator)'{-g,--generator}'[generators to use]: :_conan_generators' \ + '(-h --help --werror)--werror[error instead of warnings for graph inconsistencies]' \ + '(-h --help -if --install-folder)'{-if,--install-folder}'[Use this directory as the directory where to put the generatorfiles, conaninfo/conanbuildinfo.txt etc.]: :_files -/' \ + '(-h --help -m --manifests)'{-m,--manifests}'[install dependencies manifests in folder for later verify]: :_files -/' \ + '(-h --help -mi --manifests-interactive)'{-mi,--manifests-interactive}'[install dependencies manifests in folder for later verify]: :_files -/' \ + '(-h --help -v --verify)'{-v,--verify}'[verify dependencies manifests against stored ones]: :_files -/' \ + '(-h --help --no-imports)--no-imports[install specified packages but avoid running imports]' \ + '(-h --help -u --update)'{-u,--update}'[check updates exist from upstream remotes]' \ + '(-h --help -sc --scope)'{-sc,--scope}'[use the specified scope in the install command]: :_conan_scopes' \ + '(-h --help -pr --profile)'{-pr,--profile}'[apply the specified profile to the install command]: :_conan_profiles' \ + '(-h --help -r --remote)'{-r,--remote}'[look in the specified remote server]: :_conan_remotes' \ + '(-h --help)'{-o,--options}'[options to build the package, overwriting the defaults. e.g., -o with_qt=true]: :_conan_options' \ + '(-h --help)'{-s,--settings}'[settings to build the package, overwriting the defaults. e.g., -s compiler=gcc]: :_conan_settings' \ + '(-h --help)'{-e,--env}'[environment variables that will be set during the package build, -e CXX=/usr/bin/clang++]: :_conan_environment_variables' \ + '(-h --help -b --build)'{-b,--build}'[given a build policy (same install command "build" parameter), return an ordered list of packages that would be built from sources in install command (simulation)]: :_conan_build_policies' \ + '(-h --help)1: :_conan_conanfiles' +} + +(( $+functions[_conan_new_args] )) || +_conan_new_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help -t --test)'{-t,--test}'[create test_package skeleton to test package]' \ + '(-h --help -i --header)'{-i,--header}'[create a headers only package template]' \ + '(-h --help -c --pure_c)'{-c,--pure_c}'[create a C language package only package, deleting "self.settings.compiler.libcxx" setting in the configure method]' \ + '(-h --help -s --sources)'{-s,--sources}'[create a package with embedded sources in "src" folder, using "exports_sources" instead of retrieving external code with the "source()" method]' \ + '(-h --help -b --bare)'{-b,--bare}'[create the minimum package recipe, without build() or package() methods. Useful in combination with "package_files" command]' \ + '(-h --help -cis --ci_shared)'{-cis,--ci_shared}'[package will have a "shared" option to be used in CI]' \ + '(-h --help -cilg --ci_travis_gcc)'{-cilg,--ci_travis_gcc}'[generate travis-ci files for linux gcc]' \ + '(-h --help -cilc --ci_travis_clang)'{-cilc,--ci_travis_clang}'[generate travis-ci files for linux clang]' \ + '(-h --help -cilg --ci_travis_gcc)'{-cilg,--ci_travis_gcc}'[generate travis-ci files for linux gcc]' \ + '(-h --help -cio --ci_travis_osx)'{-cio,--ci_travis_osx}'[generate travis-ci files for OSX apple-clang]' \ + '(-h --help -ciw --ci_appveyor_win)'{-ciw,--ci_appveyor_win}'[generate appveyor files for Appveyor Visual Studio]' \ + '(-h --help -ciglg --ci_gitlab_gcc)'{-ciglg,--ci_gitlab_gcc}'[generate GitLab files for linux gcc]' \ + '(-h --help -ciglc --ci_gitlab_clang)'{-ciglc,--ci_gitlab_clang}'[generate GitLab files for linux clang]' \ + '(-h --help -cilg --ci_travis_gcc)'{-cilg,--ci_travis_gcc}'[generate travis-ci files for linux gcc]' \ + '(-h --help -gi --gitignore)'{-gi,--gitignore}'[generate a .gitignore with the known patterns to excluded]' \ + '(-h --help -ciu --ci_upload_url)'{-ciu,--ci_upload_url}'[define URL of the repository to upload]: :_urls' \ + '(-h --help)1: :_conan_package_references' +} + +(( $+functions[_conan_package_args] )) || +_conan_package_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + "(-h --help -sf --source-folder)"{-sf,--source-folder}'[local folder containing the sources. Defaulted to the directory of the conanfile. A relative path can also be specified (relative to the current directory)]: :_files -/' \ + "(-h --help -bf --build-folder)"{-bf,--build-folder}'[build folder, working directory of the build process. Defaulted to the current directory. A relative path can also be specified (relative to the current directory)]: :_files -/' \ + "(-h --help -pf --package-folder)"{-pf,--package-folder}'[folder to install the package (when the build system or build() method does it). Defaulted to the '\''{build_folder}/package'\'' folder. A relative path can be specified, relative to the current folder. Also an absolute path is allowed.]: :_files -/' \ + "(-h --help -if --install-folder)"{-if,--install-folder}'[local folder containing the conaninfo.txt and conanbuildinfo.txt files (from a previous conan install execution). Defaulted to --build-folder]: :_files -/' \ + '(-h --help)1: :_conan_package_references' \ + '(-h --help)2:package ID:' +} + +(( $+functions[_conan_profile_args] )) || +_conan_profile_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_profile_commands' \ + '(-h --help)*:: :->command_args' + + case $state in + command_args) + (( $+functions[_conan_profile_${words[1]}_args] )) && _conan_profile_${words[1]}_args + ;; + esac +} + +(( $+functions[_conan_profile_commands] )) || +_conan_profile_commands() { + local commands + commands=( + 'list:list current profiles' + 'show:show the values defined for a profile' + 'new:creates a new empty profile' + 'update:update a profile' + 'get:get a profile key' + 'remove:remove a profile key' + ) + _describe -t 'commands' "command" commands +} + +(( $+functions[_conan_profile_list_args] )) || +_conan_profile_list_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' +} + +(( $+functions[_conan_profile_show_args] )) || +_conan_profile_show_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_profiles' +} + +(( $+functions[_conan_profile_new_args] )) || +_conan_profile_new_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)--detect[autodetect settings and fill \[settings\] section]' \ + '(-h --help)1:profile name:' +} + +(( $+functions[_conan_profile_update_args] )) || +_conan_profile_update_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_settings' \ + '(-h --help)2: :_conan_profiles' +} + +(( $+functions[_conan_profile_get_args] )) || +_conan_profile_get_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_setting_keys' \ + '(-h --help)2: :_conan_profiles' +} + +(( $+functions[_conan_profile_remove_args] )) || +_conan_profile_remove_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_setting_keys' \ + '(-h --help)2: :_conan_profiles' +} + +(( $+functions[_conan_remote_args] )) || +_conan_remote_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_remote_commands' \ + '(-h --help)*:: :->command_args' + + case $state in + command_args) + (( $+functions[_conan_remote_${words[1]}_args] )) && _conan_remote_${words[1]}_args + ;; + esac +} + +(( $+functions[_conan_remote_commands] )) || +_conan_remote_commands() { + local commands + commands=( + 'list:list current remotes' + 'add:add a remote' + 'remove:remove a remote' + 'update:update the remote url' + 'list_ref:list the package recipes and its associated remotes' + 'add_ref:associate a recipe'\''s reference to a remote' + 'remove_ref:dissociate a recipe'\''s reference and its remote' + 'update_ref:update the remote associated with a package recipe' + ) + _describe -t 'commands' "command" commands +} + +(( $+functions[_conan_remote_list_args] )) || +_conan_remote_list_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' +} + +(( $+functions[_conan_remote_add_args] )) || +_conan_remote_add_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1:name of the remote:' \ + '(-h --help)2:url of the remote:_urls' \ + '(-h --help)3:verify SSL certificated:(True False)' +} + +(( $+functions[_conan_remote_remove_args] )) || +_conan_remote_remove_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_remotes' +} + +(( $+functions[_conan_remote_update_args] )) || +_conan_remote_update_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-h --help)1: :_conan_remotes' \ + '(-h --help)2:url of the remote:_urls' \ + '(-h --help)3:verify SSL certificated:(True False)' +} + +(( $+functions[_conan_remote_list_ref_args] )) || +_conan_remote_list_ref_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' +} + +# TODO complete conan remote add_ref +# TODO complete conan remote remove_ref +# TODO complete conan remote update_ref +# TODO complete conan remove +# TODO complete conan search +# TODO complete conan source +# TODO complete conan upload +# TODO complete conan user +# TODO complete conan export-pkg +# TODO complete conan test + + +(( $+functions[_conan_conanfiles] )) || +_conan_conanfiles() { + _files -g '*.py' +} + +(( $+functions[_conan_conanfiles_or_package_references] )) || +_conan_conanfiles_or_package_references() { + _alternative \ + 'conanfile: :_conan_conanfiles' \ + 'package-references: :_conan_package_references' +} + +(( $+functions[_conan_directory_or_package_references] )) || +_conan_directory_or_package_references() { + _alternative \ + 'directory: :_files -/' \ + 'package-references: :_conan_package_references' +} + +(( $+functions[_conan_channel_or_package_references] )) || +_conan_channel_or_package_references() { + _alternative \ + 'package-references: :_conan_package_references' \ + 'user-channels: :_conan_user_channels' +} + +(( $+functions[_conan_package_references] )) || +_conan_package_references() { + _guard '[^\-]#' 'package reference' # TODO complete package references +} + +(( $+functions[_conan_user_channels] )) || +_conan_user_channels() { + _guard '[^\-]#' 'user channel' # TODO complete user channels +} + +(( $+functions[_conan_remotes] )) || +_conan_remotes() { + local remotes; remotes=(${(f)"$(_call_program remotes $service remote list)"}) + _describe -t remotes 'remote' remotes "$@" +} + +(( $+functions[_conan_scopes] )) || +_conan_scopes() { + _guard '[^\-]#' 'scope' # TODO complete scopes +} + +(( $+functions[_conan_build_policies] )) || +_conan_build_policies() { + _guard '[^\-]#' 'build policy' # TODO complete build policies +} + +(( $+functions[_conan_generators] )) || +_conan_generators() { + _guard '[^\-]#' 'generator' # TODO complete generators +} + +(( $+functions[_conan_profiles] )) || +_conan_profiles() { + local profiles; profiles=(${(f)"$(_call_program profiles $service profile list)"}) + _describe -t profiles 'profile' profiles "$@" +} + +(( $+functions[_conan_config_keys] )) || +_conan_config_keys() { + _guard '[^\-]#' 'config key' # TODO complete config keys +} + +(( $+functions[_conan_config_values] )) || +_conan_config_values() { + _guard '[^\-]#' 'config value' # TODO complete config values +} + +(( $+functions[_conan_options] )) || +_conan_options() { + local ret=1 + if compset -P '*='; then + _wanted option-values expl 'option value' _conan_option_values ${IPREFIX%=} && ret=0 + else + _wanted option-names expl 'option key' _conan_option_keys -qS= && ret=0 + fi + return ret +} + +(( $+functions[_conan_option_keys] )) || +_conan_option_keys() { + _guard '[^\-]#' 'option key' # TODO complete option keys +} + +(( $+functions[_conan_option_values] )) || +_conan_option_values() { + _guard '[^\-]#' 'option value' # TODO complete option values +} + +(( $+functions[_conan_settings] )) || +_conan_settings() { + local ret=1 + if compset -P '*='; then + _wanted setting-values expl 'setting value' _conan_setting_values ${IPREFIX%=} && ret=0 + else + _wanted setting-names expl 'setting key' _conan_setting_keys -qS= && ret=0 + fi + return ret +} + +(( $+functions[_conan_setting_keys] )) || +_conan_setting_keys() { + _guard '[^\-]#' 'setting key' # TODO complete setting keys +} + +(( $+functions[_conan_setting_values] )) || +_conan_setting_values() { + _guard '[^\-]#' 'setting value' # TODO complete setting values +} + +(( $+functions[_conan_environment_variables] )) || +_conan_environment_variables() { + local ret=1 + if compset -P '*='; then + _wanted environment_variable-values expl 'environment variable value' _conan_environment_variable_values ${IPREFIX%=} && ret=0 + else + _wanted environment_variable-names expl 'environment variable' _conan_environment_variable_keys -qS= && ret=0 + fi + return ret +} + +(( $+functions[_conan_environment_variable_keys] )) || +_conan_environment_variable_keys() { + _parameters -g "*export*" +} + +(( $+functions[_conan_environment_variable_values] )) || +_conan_environment_variable_values() { + _guard '[^\-]#' 'environment variable value' # TODO complete environment variable values +} + + +_conan "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_concourse b/home/.zsh-server/plugins/zsh-completions/src/_concourse new file mode 100644 index 0000000..3635344 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_concourse @@ -0,0 +1,1517 @@ +#compdef concourse fly +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for concourse 5.2.0 (https://concourse-ci.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + +local _concourse_fly_target \ + _concourse_fly_pipeline \ + _concourse_fly_pipeline_config \ + _concourse_fly_job \ + _concourse_fly_resource \ + _concourse_fly_resource_type + +(( $+functions[_concourse_fly] )) || +_concourse_fly() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)'{-v,--version}'[print the version of Fly and exit]' \ + {-t,--target=}'[concourse target name]: :_concourse_fly_targets' \ + --verbose'[print API requests and responses]' \ + --print-table-headers'[print table headers even for redirected output]' \ + '(-): :->command' \ + '(-)*:: :->arguments' \ + && ret=0 + + case $state in + (command) + _concourse_fly_commands + ;; + (arguments) + curcontext=${curcontext%:*:*}:concourse-fly-$words[1]: + if (( $+functions[_concourse_fly_${words[1]}_args] )); then + _concourse_fly_target=${(v)opt_args[(i)-t|--target]} + _concourse_fly_${words[1]}_args && ret=0 + else + _message "unknown command ${words[1]}" && ret=1 + fi + ;; + esac + + return ret +} + +(( $+functions[_concourse_fly_commands] )) || +_concourse_fly_commands() { + local commands=( + {ab,abort-build}":abort a build" + {bs,builds}":list builds data" + {cr,check-resource}":check a resource" + {crt,check-resource-type}":check a resource-type" + {cl,checklist}":print a Checkfile of the given pipeline" + {ctc,clear-task-cache}":clears cache from a task container" + {cs,containers}":print the active containers" + {c,curl}":curl the api" + {dtg,delete-target}":delete target" + {dp,destroy-pipeline}":destroy a pipeline" + {dt,destroy-team}":destroy a team and delete all of its data" + {etg,edit-target}":edit a target" + {e,execute}":execute a one-off build using local bits" + {ep,expose-pipeline}":make a pipeline publicly viewable" + {fp,format-pipeline}":format a pipeline config" + {gp,get-pipeline}":get a pipeline's current configuration" + {gt,get-team}":show team configuration" + "help:print help message" + {hp,hide-pipeline}":hide a pipeline from the public" + {i,intercept,hijack}":execute a command in a container" + {js,jobs}":list the jobs in the pipelines" + {lw,land-worker}":land a worker" + {l,login}":authenticate with the target" + {o,logout}":release authentication with the target" + {op,order-pipelines}":orders pipelines" + {pj,pause-job}":pause a job" + {pp,pause-pipeline}":pause a pipeline" + {ps,pipelines}":list the configured pipelines" + {pw,prune-worker}":prune a stalled, landing, landed, or retiring worker" + {rp,rename-pipeline}":rename a pipeline" + {rt,rename-team}":rename a team" + {rvs,resource-versions}":list the versions of a resource" + {rs,resources}":list the resources in the pipeline" + {sp,set-pipeline}":create or update a pipeline's configuration" + {st,set-team}":create or modify a team to have the given credentials" + "status:login status" + {s,sync}":download and replace the current fly from the target" + {ts,targets}":list saved targets" + {t,teams}":list the configured teams" + {tj,trigger-job}":start a job in a pipeline" + {uj,unpause-job}":unpause a job" + {up,unpause-pipeline}":un-pause a pipeline" + "userinfo:user information" + {vp,validate-pipeline}":validate a pipeline config" + {vs,volumes}":list the active volumes" + {w,watch}":stream a build's output" + {ws,workers}":list the registered workers" + ) + _describe -t commands commands commands +} + +(( $+functions[_concourse_fly_ab_args] )) || +_concourse_fly_ab_args() { + _concourse_fly_abort-build_args +} + +(( $+functions[_concourse_fly_bs_args] )) || +_concourse_fly_bs_args() { + _concourse_fly_builds_args +} + +(( $+functions[_concourse_fly_cl_args] )) || +_concourse_fly_cl_args() { + _concourse_fly_checklist_args +} + +(( $+functions[_concourse_fly_cr_args] )) || +_concourse_fly_cr_args() { + _concourse_fly_check-resource_args +} + +(( $+functions[_concourse_fly_crt_args] )) || +_concourse_fly_crt_args() { + _concourse_fly_check-resource-type_args +} + +(( $+functions[_concourse_fly_ctc_args] )) || +_concourse_fly_ctc_args() { + _concourse_fly_clear-task-cache_args +} + +(( $+functions[_concourse_fly_cs_args] )) || +_concourse_fly_cs_args() { + _concourse_fly_containers_args +} + +(( $+functions[_concourse_fly_c_args] )) || +_concourse_fly_c_args() { + _concourse_fly_curl_args +} + +(( $+functions[_concourse_fly_dtg_args] )) || +_concourse_fly_dtg_args() { + _concourse_fly_delete-target_args +} + +(( $+functions[_concourse_fly_dp_args] )) || +_concourse_fly_dp_args() { + _concourse_fly_destroy-pipeline_args +} + +(( $+functions[_concourse_fly_dt_args] )) || +_concourse_fly_dt_args() { + _concourse_fly_destroy-team_args +} + +(( $+functions[_concourse_fly_etg_args] )) || +_concourse_fly_etg_args() { + _concourse_fly_edit-target_args +} + +(( $+functions[_concourse_fly_e_args] )) || +_concourse_fly_e_args() { + _concourse_fly_execute_args +} + +(( $+functions[_concourse_fly_ep_args] )) || +_concourse_fly_ep_args() { + _concourse_fly_expose-pipeline_args +} + +(( $+functions[_concourse_fly_fp_args] )) || +_concourse_fly_fp_args() { + _concourse_fly_format-pipeline_args +} + +(( $+functions[_concourse_fly_gp_args] )) || +_concourse_fly_gp_args() { + _concourse_fly_get-pipeline_args +} + +(( $+functions[_concourse_fly_gt_args] )) || +_concourse_fly_gt_args() { + _concourse_fly_get-team_args +} + +(( $+functions[_concourse_fly_hp_args] )) || +_concourse_fly_hp_args() { + _concourse_fly_hide-pipeline_args +} + +(( $+functions[_concourse_fly_hijack_args] )) || +_concourse_fly_hijack_args() { + _concourse_fly_intercept_args +} + +(( $+functions[_concourse_fly_i_args] )) || +_concourse_fly_i_args() { + _concourse_fly_intercept_args +} + +(( $+functions[_concourse_fly_js_args] )) || +_concourse_fly_js_args() { + _concourse_fly_jobs_args +} + +(( $+functions[_concourse_fly_lw_args] )) || +_concourse_fly_lw_args() { + _concourse_fly_land-worker_args +} + +(( $+functions[_concourse_fly_l_args] )) || +_concourse_fly_l_args() { + _concourse_fly_login_args +} + +(( $+functions[_concourse_fly_o_args] )) || +_concourse_fly_o_args() { + _concourse_fly_logout_args +} + +(( $+functions[_concourse_fly_op_args] )) || +_concourse_fly_op_args() { + _concourse_fly_order-pipelines_args +} + +(( $+functions[_concourse_fly_pj_args] )) || +_concourse_fly_pj_args() { + _concourse_fly_pause-job_args +} + +(( $+functions[_concourse_fly_pp_args] )) || +_concourse_fly_pp_args() { + _concourse_fly_pause-pipeline_args +} + +(( $+functions[_concourse_fly_ps_args] )) || +_concourse_fly_ps_args() { + _concourse_fly_pipelines_args +} + +(( $+functions[_concourse_fly_pw_args] )) || +_concourse_fly_pw_args() { + _concourse_fly_prune-worker_args +} + +(( $+functions[_concourse_fly_rp_args] )) || +_concourse_fly_rp_args() { + _concourse_fly_rename-pipeline_args +} + +(( $+functions[_concourse_fly_rt_args] )) || +_concourse_fly_rt_args() { + _concourse_fly_rename-team_args +} + +(( $+functions[_concourse_fly_rs_args] )) || +_concourse_fly_rs_args() { + _concourse_fly_resources_args +} + +(( $+functions[_concourse_fly_rvs_args] )) || +_concourse_fly_rvs_args() { + _concourse_fly_resource-versions_args +} + +(( $+functions[_concourse_fly_sp_args] )) || +_concourse_fly_sp_args() { + _concourse_fly_set-pipeline_args +} + +(( $+functions[_concourse_fly_st_args] )) || +_concourse_fly_st_args() { + _concourse_fly_set-team_args +} + +(( $+functions[_concourse_fly_s_args] )) || +_concourse_fly_s_args() { + _concourse_fly_sync_args +} + +(( $+functions[_concourse_fly_ts_args] )) || +_concourse_fly_ts_args() { + _concourse_fly_targets_args +} + +(( $+functions[_concourse_fly_t_args] )) || +_concourse_fly_t_args() { + _concourse_fly_teams_args +} + +(( $+functions[_concourse_fly_tj_args] )) || +_concourse_fly_tj_args() { + _concourse_fly_trigger-job_args +} + +(( $+functions[_concourse_fly_uj_args] )) || +_concourse_fly_uj_args() { + _concourse_fly_unpause-job_args +} + +(( $+functions[_concourse_fly_up_args] )) || +_concourse_fly_up_args() { + _concourse_fly_unpause-pipeline_args +} + +(( $+functions[_concourse_fly_vp_args] )) || +_concourse_fly_vp_args() { + _concourse_fly_validate-pipeline_args +} + +(( $+functions[_concourse_fly_vs_args] )) || +_concourse_fly_vs_args() { + _concourse_fly_volumes_args +} + +(( $+functions[_concourse_fly_w_args] )) || +_concourse_fly_w_args() { + _concourse_fly_watch_args +} + +(( $+functions[_concourse_fly_ws_args] )) || +_concourse_fly_ws_args() { + _concourse_fly_workers_args +} + +(( $+functions[_concourse_fly_help_args] )) || +_concourse_fly_help_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' +} + +(( $+functions[_concourse_fly_status_args] )) || +_concourse_fly_status_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' +} + +(( $+functions[_concourse_fly_userinfo_args] )) || +_concourse_fly_userinfo_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_abort-build_args] )) || +_concourse_fly_abort-build_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job)'{-j,--job=}'[name of a job to cancel]: :_concourse_fly_pipeline_slash_jobs' \ + '(-b --build)'{-b,--build=}'[job build number to cancel, or build id]: :_concourse_fly_builds' +} + +(( $+functions[_concourse_fly_builds_args] )) || +_concourse_fly_builds_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-a --all-teams)'{-a,--all-teams}'[show builds for the all teams that user has access to]' \ + '(-c --count)'{-c,--count=}'[number of builds you want to limit the return to]: :number' \ + '--current-team[show builds for the currently targeted team]' \ + '(-j --job -p --pipeline)'{-j,--job=}'[name of a job to get builds for]: :_concourse_fly_pipeline_slash_jobs' \ + '--json[print command result as JSON]' \ + '(-j --job -p --pipeline)'{-p,--pipeline=}'[name of a pipeline to get builds for]: :_concourse_fly_pipelines' \ + '--since=[start of the range to filter builds]: :_concourse_fly_dates' \ + '--until=[end of the range to filter builds]: :_concourse_fly_dates' +} + +(( $+functions[_concourse_fly_checklist_args] )) || +_concourse_fly_checklist_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[the pipeline from which to generate the Checkfile]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_check-resource_args] )) || +_concourse_fly_check-resource_args() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-r --resource)'{-r,--resource=}'[name of a resource to check]: :_concourse_fly_pipeline_slash_resources' \ + '(-f --from)'{-f,--from=}'[version of the resource to check from]: :->version' \ + && ret=0 + + case $state in + (version) + _concourse_fly_resource=${(v)opt_args[(i)-r|--resource]} + _concourse_fly_pipeline_resource_versions && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_concourse_fly_check-resource-type_args] )) || +_concourse_fly_check-resource-type_args() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-r --resource-type)'{-r,--resource-type=}'[name of a resource type to check]: :_concourse_fly_pipeline_slash_resource_types' \ + '(-f --from)'{-f,--from=}'[version of the resource type to check from]: :->version' \ + && ret=0 + + case $state in + (version) + _concourse_fly_resource_type=${(v)opt_args[(i)-r|--resource-type]} + _concourse_fly_pipeline_resource_type_versions && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_concourse_fly_clear-task-cache_args] )) || +_concourse_fly_clear-task-cache_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job)'{-j,--job=}'[name of a job to cancel]: :_concourse_fly_pipeline_slash_jobs' \ + '(-s --step)'{-s,--step=}'[step name to clear cache from]:task step' \ + '(-c --cache-path)'{-c,--cache-path=}'[cache directory to clear out]: :_files -/' \ + '(-n --non-interactive)'{-n,--non-interactive=}'[destroy the task cache(s) without confirmation]' +} + +(( $+functions[_concourse_fly_containers_args] )) || +_concourse_fly_containers_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_curl_args] )) || +_concourse_fly_curl_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--print-and-exit[print curl command and exit]' +} + +(( $+functions[_concourse_fly_delete-target_args] )) || +_concourse_fly_delete-target_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-a --all)'{-a,--all}'[delete all targets]' +} + +(( $+functions[_concourse_fly_destroy-pipeline_args] )) || +_concourse_fly_destroy-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[the pipeline to destroy]: :_concourse_fly_pipelines' \ + '(-n --non-interactive)'{-n,--non-interactive}'[destroy the pipeline without confirmation]' +} + +(( $+functions[_concourse_fly_destroy-team_args] )) || +_concourse_fly_destroy-team_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-n --team-name)'{-n,--team-name=}'[the team to delete]: :_concourse_fly_teams' \ + '(-n --non-interactive)'{-n,--non-interactive}'[force apply configuration]' +} + +(( $+functions[_concourse_fly_edit-target_args] )) || +_concourse_fly_edit-target_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--target-name=[update target name]: :_concourse_fly_targets' \ + '(-u --concourse-url)'{-u,--concourse-url=}'[update concourse URL]: :_urls' \ + '(-n --team-name)'{-n,--team-name=}'[update concourse URL]: :_concourse_fly_teams' +} + +(( $+functions[_concourse_fly_execute_args] )) || +_concourse_fly_execute_args() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-c --config)'{-c,--config=}'[the task config to execute]: :_concourse_config_files' \ + '(-p --privileged)'{-p,--privileged}'[run the task with full privileges]' \ + '--include-ignored[disregard .gitignore entries and uploads everything]' \ + '*'{-i,--input=}'[an input to provide to the task]: :->input' \ + '*'{-m,--input-mapping=}'[map a resource to a different name as task input]: :->input-mapping' \ + '(-j --inputs-from)'{-j,--inputs-from=}'[a job to base the inputs on]: :_concourse_fly_pipeline_slash_jobs' \ + '*'{-o,--output=}'[an output to fetch from the task]: :->output' \ + '--image=[image resource for the one-off build]: :_concourse_fly_images' \ + '*--tag=[a tag for a specific environment]: :_concourse_fly_tags' \ + '*'{-v,--var=}'[specify a string value to set for a variable in the pipeline]: :->var' \ + '*'{-y,--yaml-var=}'[specify a YAML value to set for a variable in the pipeline]: :->var' \ + '(-l --load-vars-from)'{-l,--load-vars-from=}'[variable flag that can be used for filling in template values in configuration from a YAML file]: :_files' \ + && ret=0 + + _concourse_fly_pipeline_config=${(v)opt_args[(i)-c|--config]} + + case $state in + (input-mapping) + # TODO complete --input-mapping + _message 'input mapping' + ;; + (input) + _concourse_fly_input_equal_paths && ret=0 + ;; + (output) + _concourse_fly_output_equal_paths && ret=0 + ;; + (var) + _concourse_fly_var_equal_values && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_concourse_fly_expose-pipeline_args] )) || +_concourse_fly_expose-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[pipeline to expose]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_format-pipeline_args] )) || +_concourse_fly_format-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-c --config)'{-c,--config=}'[pipeline configuration file]: :_concourse_config_files' \ + '(-w --write)'{-w,--write}'[do not print to stdout, overwrite the file in place]' +} + +(( $+functions[_concourse_fly_get-pipeline_args] )) || +_concourse_fly_get-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[get configuration of this pipeline]: :_concourse_fly_pipelines' \ + '(-j --json)'{-j,--json}'[print config as json instead of yaml]' +} + +(( $+functions[_concourse_fly_get-team_args] )) || +_concourse_fly_get-team_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-n --team)'{-n,--team=}'[get configuration of this team]: :_concourse_fly_teams' \ + '(-j --json)'{-j,--json}'[print config as json instead of yaml]' +} + +(( $+functions[_concourse_fly_hide-pipeline_args] )) || +_concourse_fly_hide-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[pipeline to hide]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_intercept_args] )) || +_concourse_fly_intercept_args() { + # TODO complete --handle + # TODO complete --check + # TODO complete --step + # TODO complete --step-type + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job --handle -c --check -u --url)'{-j,--job=}'[name of a job to hijack]: :_concourse_fly_pipeline_slash_jobs' \ + '(-j --job --handle -c --check -u --url)--handle=[handle id of a job to hijack]:job handle' \ + '(-j --job --handle -c --check -u --url)'{-c,--check=}'[name of a resource'\''s checking container to hijack]:name' \ + '(-j --job --handle -c --check -u --url)'{-u,--url=}'[URL for the build, job, or check container to hijack]: :_urls' \ + '(-b --build)'{-b,--build=}'[build number within the job, or global build ID]: :_concourse_fly_builds' \ + '(-s --step)'{-s,--step=}'[name of step to hijack]:step' \ + '--step-type=[type of step to hijack]:step type' \ + '(-a --attempt)'{-a,--attempt=}'[attempt number of step to hijack]: :_values -s, "number" 1 2 3 4 5 6 7 8 9' \ + '(-):command name: _command_names -e' \ + '*::arguments:_normal' +} + +(( $+functions[_concourse_fly_jobs_args] )) || +_concourse_fly_jobs_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[get jobs in this pipeline]: :_concourse_fly_pipelines' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_land-worker_args] )) || +_concourse_fly_land-worker_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-w --worker)'{-w,--worker=}'[worker to land]: :_concourse_fly_workers' +} + +(( $+functions[_concourse_fly_login_args] )) || +_concourse_fly_login_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-c --concourse-url)'{-c,--concourse-url=}'[concourse URL to authenticate with]: :_urls' \ + '(-k --insecure)'{-k,--insecure}'[skip verification of the endpoint'\''s SSL certificate]' \ + '(-u --username)'{-u,--username=}'[username for basic auth]: :_users' \ + '(-p --password)'{-p,--password=}'[password for basic auth]:password' \ + '(-n --team-name)'{-n,--team-name=}'[team to authenticate with]: :_concourse_fly_teams' \ + '--ca-cert=[path to Concourse PEM-encoded CA certificate file]: :_files -g "*.pem"' \ + '(-b --open-browser)'{-b,--open-browser}'[open browser to the auth endpoint]' +} + +(( $+functions[_concourse_fly_logout_args] )) || +_concourse_fly_logout_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-a --all)'{-a,--all}'[logout of all targets]' +} + +(( $+functions[_concourse_fly_order-pipelines_args] )) || +_concourse_fly_order-pipelines_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[name of pipeline to order]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_pause-job_args] )) || +_concourse_fly_pause-job_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job)'{-j,--job=}'[name of a job to pause]: :_concourse_fly_pipeline_slash_jobs' +} + +(( $+functions[_concourse_fly_pause-pipeline_args] )) || +_concourse_fly_pause-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[pipeline to pause]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_pipelines_args] )) || +_concourse_fly_pipelines_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-a --all)'{-a,--all}'[show all pipelines]' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_prune-worker_args] )) || +_concourse_fly_prune-worker_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-w --worker)'{-w,--worker=}'[worker to prune]: :_concourse_fly_workers' \ + '(-a --all-stalled)'{-a,--all-stalled}'[prune all stalled workers]' +} + +(( $+functions[_concourse_fly_rename-pipeline_args] )) || +_concourse_fly_rename-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-o --old-name)'{-o,--old-name=}'[pipeline to rename]: :_concourse_fly_pipelines' \ + '(-n --new-name)'{-n,--new-name=}'[name to set as pipeline name]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_rename-team_args] )) || +_concourse_fly_rename-team_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-o --old-name)'{-o,--old-name=}'[current team name]: :_concourse_fly_teams' \ + '(-n --new-name)'{-n,--new-name=}'[new team name]: :_concourse_fly_teams' +} + +(( $+functions[_concourse_fly_resources_args] )) || +_concourse_fly_resources_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[get resources in this pipeline]: :_concourse_fly_pipelines' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_resource-versions_args] )) || +_concourse_fly_resource-versions_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-c --count)'{-c,--count=}'[number of builds you want to limit the return to]:number' \ + '(-r --resource)'{-r,--resource=}'[name of a resource to get versions for]: :_concourse_fly_pipeline_slash_resources' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_set-pipeline_args] )) || +_concourse_fly_set-pipeline_args() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-n --non-interactive)'{-n,--non-interactive}'[skips interactions, uses default values]' \ + '--no-color[disable color output]' \ + '--check-creds[validate credential variables against credential manager]' \ + '(-p --pipeline)'{-p,--pipeline=}'[pipeline to configure]: :_concourse_fly_pipelines' \ + '(-c --config)'{-c,--config=}'[pipeline configuration file]: :_concourse_config_files' \ + '*'{-v,--var=}'[specify a string value to set for a variable in the pipeline]: :->var' \ + '*'{-y,--yaml-var=}'[specify a YAML value to set for a variable in the pipeline]: :->var' \ + '(-l --load-vars-from)'{-l,--load-vars-from=}'[variable flag that can be used for filling in template values in configuration from a YAML file]: :_files' \ + && ret=0 + + _concourse_fly_pipeline_config=${(v)opt_args[(i)-c|--config]} + + case $state in + (var) + _concourse_fly_var_equal_values && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_concourse_fly_set-team_args] )) || +_concourse_fly_set-team_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-n --team-name)'{-n,--team-name=}'[the team to create or modify]: :_concourse_fly_teams' \ + '--non-interactive[force apply configuration]' \ + '*--local-user=[list of whitelisted local concourse users]: :_users' \ + '(-c --config)'{-c,--config=}'[configuration file for specifying team params]: :_concourse_config_files' \ + '*--bitbucket-cloud-user=[list of whitelisted Bitbucket Cloud users]:user name' \ + '*--bitbucket-cloud-team=[list of whitelisted Bitbucket Cloud teams]:team name' \ + '*--cf-user=[list of whitelisted CloudFoundry users]:user name' \ + '*--cf-org=[list of whitelisted CloudFoundry orgs]:org name' \ + '*--cf-space=[list of whitelisted CloudFoundry spaces]:space name' \ + '*--github-user=[list of whitelisted GitHub users]:user name' \ + '*--github-org=[list of whitelisted GitHub orgs]:org name' \ + '*--github-team=[list of whitelisted GitHub teams]:team name' \ + '*--gitlab-user=[list of whitelisted GitLab users]:user name' \ + '*--gitlab-group=[list of whitelisted GitLab groups]:group name' \ + '*--ldap-user=[list of whitelisted LDAP users]:user name' \ + '*--ldap-group=[list of whitelisted LDAP groups]:group name' \ + '*--oauth-user=[list of whitelisted OAuth2 users]:user name' \ + '*--oauth-group=[list of whitelisted OAuth2 groups]:group name' \ + '*--oidc-user=[list of whitelisted OIDC users]:user name' \ + '*--oidc-group=[list of whitelisted OIDC groups]:group name' +} + +(( $+functions[_concourse_fly_sync_args] )) || +_concourse_fly_sync_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-f --force)'{-f,--force}'[sync even if versions already match]' +} + +(( $+functions[_concourse_fly_targets_args] )) || +_concourse_fly_targets_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' +} + +(( $+functions[_concourse_fly_teams_args] )) || +_concourse_fly_teams_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-d --details)'{-d,--details}'[print authentication configuration]' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_trigger-job_args] )) || +_concourse_fly_trigger-job_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job)'{-j,--job=}'[name of a job to trigger]: :_concourse_fly_pipeline_slash_jobs' \ + '(-w --watch)'{-w,--watch}'[start watching the build output]' +} + +(( $+functions[_concourse_fly_unpause-job_args] )) || +_concourse_fly_unpause-job_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job)'{-j,--job=}'[name of a job to unpause]: :_concourse_fly_pipeline_slash_jobs' +} + +(( $+functions[_concourse_fly_unpause-pipeline_args] )) || +_concourse_fly_unpause-pipeline_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-p --pipeline)'{-p,--pipeline=}'[pipeline to unpause]: :_concourse_fly_pipelines' +} + +(( $+functions[_concourse_fly_validate-pipeline_args] )) || +_concourse_fly_validate-pipeline_args() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-c --config)'{-c,--config=}'[pipeline configuration file]: :_concourse_config_files' \ + '(-s --strict)'{-s,--strict}'[fail on warnings]' \ + '(-o --output)'{-o,--output}'[output templated pipeline to stdout]' \ + '*'{-v,--var=}'[specify a string value to set for a variable in the pipeline]: :->var' \ + '*'{-y,--yaml-var=}'[specify a YAML value to set for a variable in the pipeline]: :->var' \ + '(-l --load-vars-from)'{-l,--load-vars-from=}'[variable flag that can be used for filling in template values in configuration from a YAML file]: :_files' \ + && ret=0 + + _concourse_fly_pipeline_config=${(v)opt_args[(i)-c|--config]} + + case $state in + (var) + _concourse_fly_var_equal_values && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_concourse_fly_volumes_args] )) || +_concourse_fly_volumes_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-d --details)'{-d,--details}'[print additional information for each volume]' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_watch_args] )) || +_concourse_fly_watch_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-j --job)'{-j,--job=}'[watches builds of the given job]: :_concourse_fly_pipeline_slash_jobs' \ + '(-b --build)'{-b,--build=}'[watches a specific build]: :_concourse_fly_builds' \ + '(-t --timestamps)'{-t,--timestamps}'[print with local timestamp]' +} + +(( $+functions[_concourse_fly_workers_args] )) || +_concourse_fly_workers_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-d --details)'{-d,--details}'[print additional information for each worker]' \ + '--json[print command result as JSON]' +} + +(( $+functions[_concourse_fly_targets] )) || +_concourse_fly_targets() { + local targets=($(_call_program targets $service targets | awk '{print $1}')) + _describe -t targets 'target' targets $@ || _message 'no target found' +} + +(( $+functions[_concourse_fly_teams] )) || +_concourse_fly_teams() { + if [[ -n ${_concourse_fly_target} ]]; then + local teams=($(_call_program teams $service -t ${_concourse_fly_target} teams | awk '{print $1}')) + _describe -t teams 'team' teams $@ || _message 'no team found' + else + _message 'team' + fi +} + +(( $+functions[_concourse_fly_pipelines] )) || +_concourse_fly_pipelines() { + if [[ -n ${_concourse_fly_target} ]]; then + local pipelines=($(_call_program pipelines $service -t ${_concourse_fly_target} pipelines | awk '{print $1}')) + _describe -t pipelines 'pipeline' pipelines $@ || _message 'no pipeline found' + else + _message 'pipeline' + fi +} + +(( $+functions[_concourse_fly_pipeline_jobs] )) || +_concourse_fly_pipeline_jobs() { + if [[ -n ${_concourse_fly_target} ]] && [[ -n ${_concourse_fly_pipeline} ]]; then + local jobs=($(_call_program jobs $service -t ${_concourse_fly_target} jobs -p ${_concourse_fly_pipeline} 2>&1 | awk '{print $1}')) + _describe -t jobs "${_concourse_fly_pipeline} job" jobs $@ || _message 'no job found' + else + _message 'job' + fi +} + +(( $+functions[_concourse_fly_pipeline_resources] )) || +_concourse_fly_pipeline_resources() { + if [[ -n ${_concourse_fly_target} ]] && [[ -n ${_concourse_fly_pipeline} ]]; then + local resources=($(_call_program resources $service -t ${_concourse_fly_target} resources -p ${_concourse_fly_pipeline} | awk '{print $1}')) + _describe -t resources 'resource' resources $@ || _message 'no resource found' + else + _message 'resource' + fi +} + +(( $+functions[_concourse_fly_pipeline_resource_types] )) || +_concourse_fly_pipeline_resource_types() { + if [[ -n ${_concourse_fly_target} ]] && [[ -n ${_concourse_fly_pipeline} ]]; then + local resource_types=($(_call_program resource-types $service -t ${_concourse_fly_target} resources -p ${_concourse_fly_pipeline} | awk '{print $2}')) + _describe -t resource-types 'resource type' resource_types $@ || _message 'no resource type found' + else + _message 'resource type' + fi +} + +(( $+functions[_concourse_fly_workers] )) || +_concourse_fly_workers() { + if [[ -n ${_concourse_fly_target} ]]; then + local workers=($(_call_program workers $service -t ${_concourse_fly_target} workers | awk '{print $1}')) + _describe -t workers 'worker' workers $@ || _message 'no worker found' + else + _message 'worker' + fi +} + +(( $+functions[_concourse_fly_builds] )) || +_concourse_fly_builds() { + if [[ -n ${_concourse_fly_target} ]]; then + local builds=($(_call_program builds $service -t ${_concourse_fly_target} builds | awk '{print $1}')) + _describe -t builds 'build' builds $@ || _message 'no build found' + else + _message 'build' + fi +} + +(( $+functions[_concourse_fly_pipeline_resource_versions] )) || +_concourse_fly_pipeline_resource_versions() { + if [[ -n ${_concourse_fly_target} ]] && [[ -n ${_concourse_fly_resource} ]]; then + local resource_versions=($(_call_program resource-versions $service -t ${_concourse_fly_target} resource-versions -r ${_concourse_fly_resource} | awk '{print $2}')) + _describe -t resource-versions 'resource version' resource_versions $@ || _message 'no version found' + else + _message 'resource version' + fi +} + +(( $+functions[_concourse_fly_pipeline_config_vars] )) || +_concourse_fly_pipeline_config_vars() { + if [[ -n ${_concourse_fly_pipeline_config} ]]; then + local variables=($(grep -Po '(?<=\(\()[^\)]+' ${_concourse_fly_pipeline_config})) + _describe -t variables 'variables' variables $@ || _message 'no variable found' + else + _message 'variable' + fi +} + +(( $+functions[_concourse_fly_pipeline_config_inputs] )) || +_concourse_fly_pipeline_config_inputs() { + if [[ -n ${_concourse_fly_pipeline_config} ]]; then + if (( $+commands[yq] )); then + local inputs=($(yq -r '.. | .inputs? | arrays | .[].name' ${_concourse_fly_pipeline_config} 2>&1)) + _describe -t inputs 'input' inputs $@ || _message 'no input found' + else + _message 'install yq (https://github.com/kislyuk/yq) to get completion of inputs' + fi + else + _message 'input' + fi +} + +(( $+functions[_concourse_fly_pipeline_config_outputs] )) || +_concourse_fly_pipeline_config_outputs() { + if [[ -n ${_concourse_fly_pipeline_config} ]]; then + if (( $+commands[yq] )); then + local outputs=($(yq -r '.. | .outputs? | arrays | .[].name' ${_concourse_fly_pipeline_config})) + _describe -t outputs 'output' outputs $@ || _message 'no output found' + else + _message 'install yq (https://github.com/kislyuk/yq) to get completion of outputs' + fi + else + _message 'output' + fi +} + +(( $+functions[_concourse_fly_pipeline_resource_type_versions] )) || +_concourse_fly_pipeline_resource_type_versions() { + # seems like there is no command for listing resource type versions... + _message 'resource type version' +} + +(( $+functions[_concourse_fly_tags] )) || +_concourse_fly_tags() { + # seems like there is no command for listing tags... + _message 'tag' +} + +(( $+functions[_concourse_fly_dates] )) || +_concourse_fly_dates() { + # _dates completer does not seem to work on zsh 5.7.1 + _dates -f '%Y-%m-%d %H:%M:%S' +} + +(( $+functions[_concourse_fly_pipeline_slash_jobs] )) || +_concourse_fly_pipeline_slash_jobs() { + local ret=1 + if compset -P '*/'; then + _concourse_fly_pipeline="${${IPREFIX%/}##*=}" + _concourse_fly_pipeline_jobs && ret=0 + else + _concourse_fly_pipelines -qS/ && ret=0 + fi + return ret +} + +(( $+functions[_concourse_fly_pipeline_slash_resources] )) || +_concourse_fly_pipeline_slash_resources() { + local ret=1 + if compset -P '*/'; then + _concourse_fly_pipeline="${${IPREFIX%/}##*=}" + _concourse_fly_pipeline_resources && ret=0 + else + _concourse_fly_pipelines -qS/ && ret=0 + fi + return ret +} + +(( $+functions[_concourse_fly_pipeline_slash_resource_types] )) || +_concourse_fly_pipeline_slash_resource_types() { + local ret=1 + if compset -P '*/'; then + _concourse_fly_pipeline="${${IPREFIX%/}##*=}" + _concourse_fly_pipeline_resource_types && ret=0 + else + _concourse_fly_pipelines -qS/ && ret=0 + fi + return ret +} + +(( $+functions[_concourse_fly_var_equal_values] )) || +_concourse_fly_var_equal_values() { + local ret=1 + if compset -P '*='; then + _message 'value' && ret=0 + else + _concourse_fly_pipeline_config_vars -qS= && ret=0 + fi + return ret +} + +(( $+functions[_concourse_fly_input_equal_paths] )) || +_concourse_fly_input_equal_paths() { + local ret=1 + if compset -P '*='; then + _files && ret=0 + else + _concourse_fly_pipeline_config_inputs -qS= && ret=0 + fi + return ret +} + +(( $+functions[_concourse_fly_output_equal_paths] )) || +_concourse_fly_output_equal_paths() { + local ret=1 + if compset -P '*='; then + _files && ret=0 + else + _concourse_fly_pipeline_config_outputs -qS= && ret=0 + fi + return ret +} + +(( $+functions[_concourse_server] )) || +_concourse_server() { + + local context state state_descr line ret=1 + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)'{-v,--version}'[print the version of Concourse and exit]' \ + '(-): :->command' \ + '(-)*:: :->arguments' \ + && ret=0 + + case $state in + (command) + _concourse_commands && ret=0 + ;; + (arguments) + curcontext=${curcontext%:*:*}:concourse-$words[1]: + if (( $+functions[_concourse_${words[1]}_args] )); then + _concourse_${words[1]}_args && ret=0 + else + _message "unknown command ${words[1]}" && ret=1 + fi + ;; + esac + + return ret +} + +(( $+functions[_concourse_commands] )) || +_concourse_commands() { + local commands=( + "generate-key:generate RSA key for use with Concourse components" + "land-worker:safely drain a worker's assignments for temporary downtime" + "migrate:run database migrations" + "quickstart:run both 'web' and 'worker' together, auto-wired" + "retire-worker:safely remove a worker from the cluster permanently" + "web:run the web UI and build scheduler" + "worker:run and register a worker" + ) + _describe -t commands commands commands +} + +(( $+functions[_concourse_generate-key_args] )) || +_concourse_generate-key_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(-t --type)'{-t,--type=}'[the type of key to generate]:key type:(rsa ssh)' \ + '(-f --filename)'{-f,--filename=}'[file path where the key shall be created. When generating ssh keys, the public key will be stored in a file with the same name but with .pub appended]: :_files' \ + '(-b --bits)'{-b,--bits=}'[the number of bits in the key to create]:integer' +} + +(( $+functions[_concourse_land-worker_args] )) || +_concourse_land-worker_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--name=[the name of the worker you wish to land]:worker name' \ + '*--tsa-host=[TSA host to forward the worker through]: :_concourse_host_colon_ports' \ + '--tsa-public-key=[file containing a public key to expect from the TSA]: :_files' \ + '--tsa-worker-private-key=[file containing a public key to expect from the TSA]: :_files' +} + +(( $+functions[_concourse_migrate_args] )) || +_concourse_migrate_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)--current-db-version[print the current database version and exit]' \ + '(- : *)--supported-db-version[print the max supported database version and exit]' \ + '(- : *)--migrate-db-to-version=[migrate to the specified database version and exit]:database version' \ + '--encryption-key=[a 16 or 32 length key used to encrypt sensitive information before storing it in the database]:encryption key' \ + '--postgres-host=[the host to connect to]: :_hosts' \ + '--postgres-port=[the port to connect to]: :_concourse_ports' \ + '--postgres-socket=[path to a UNIX domain socket to connect to]: :_files' \ + '--postgres-user=[the user to sign in as]: :_users' \ + '--postgres-password=[the user'\''s password]:password' \ + '--postgres-sslmode=[whether or not to use SSL]:SSL mode:((disable require verify-ca verify-full))' \ + '--postgres-ca-cert=[CA cert file location, to verify when connecting with SSL]: :_files' \ + '--postgres-client-cert=[client cert file location]: :_files' \ + '--postgres-client-key=[client key file location]: :_files' \ + '--postgres-connect-timeout=[dialing timeout]:duration' \ + '--postgres-database=[the name of the database to use]:database name' +} + +(( $+functions[_concourse_retire-worker_args] )) || +_concourse_retire-worker_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--name=[the name of the worker you wish to retire]:worker name' \ + '*--tsa-host=[TSA host to forward the worker through]: :_concourse_host_colon_ports' \ + '--tsa-public-key=[file containing a public key to expect from the TSA]: :_files' \ + '--tsa-worker-private-key=[file containing a public key to expect from the TSA]: :_files' +} + +(( $+functions[_concourse_web_args] )) || +_concourse_web_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--peer-address=[network address of this web node, reachable by other web nodes]: :_concourse_host_colon_ports' \ + '--log-level=[minimum level of logs to see]: :_concourse_log_levels' \ + '--bind-ip=[IP address on which to listen for web traffic]: :_concourse_ip_addresses' \ + '--bind-port=[port on which to listen for HTTP traffic]: :_concourse_ports' \ + '--tls-bind-port=[port on which to listen for HTTPS traffic]: :_concourse_ports' \ + '--tls-cert=[file containing an SSL certificate]: :_files' \ + '--tls-key=[file containing an RSA private key, used to encrypt HTTPS traffic]: :_files' \ + '--external-url=[URL used to reach any ATC from the outside world]: :_urls' \ + '--encryption-key=[a 16 or 32 length key used to encrypt sensitive information before storing it in the database]:encryption key' \ + '--old-encryption-key=[encryption key previously used for encrypting sensitive information]:encryption key' \ + '--debug-bind-ip=[IP address on which to listen for the pprof debugger endpoints]: :_concourse_ip_addresses' \ + '--debug-bind-port=[port on which to listen for the pprof debugger endpoints]: :_concourse_ports' \ + '--intercept-idle-timeout=[length of time for a intercepted session to be idle before terminating]: :_concourse_durations' \ + '--enable-global-resources[enable equivalent resources across pipelines and teams to share a single version history]' \ + '--global-resource-check-timeout=[time limit on checking for new versions of resources]: :_concourse_durations' \ + '--resource-checking-interval=[interval on which to check for new versions of resources]: :_concourse_durations' \ + '--resource-type-checking-interval=[interval on which to check for new versions of resource types]: :_concourse_durations' \ + '--container-placement-strategy=[method by which a worker is selected during container placement]:strategy:((volume-locality random fewest-build-containers))' \ + '--baggageclaim-response-header-timeout=[how long to wait for Baggageclaim to send the response header]: :_concourse_durations' \ + '--cli-artifacts-dir=[directory containing downloadable CLI binaries]: :_files -/' \ + '--log-db-queries[log database queries]' \ + '--build-tracker-interval=[interval on which to run build tracking]: :_concourse_durations' \ + '--default-build-logs-to-retain=[default build logs to retain, 0 means all]:number' \ + '--max-build-logs-to-retain=[maximum build logs to retain, 0 means not specified]:number' \ + '--default-days-to-retain-build-logs=[default days to retain build logs. 0 means unlimited]:number' \ + '--max-days-to-retain-build-logs=[maximum days to retain build logs, 0 means not specified]:number' \ + '--default-task-cpu-limit=[default max number of cpu shares per task, 0 means unlimited]:number' \ + '--default-task-memory-limit=[default maximum memory per task, 0 means unlimited]:number' \ + '--enable-build-auditing[enable auditing for all api requests connected to builds]' \ + '--enable-container-auditing[enable auditing for all api requests connected to containers]' \ + '--enable-job-auditing[enable auditing for all api requests connected to jobs]' \ + '--enable-pipeline-auditing[enable auditing for all api requests connected to pipelines]' \ + '--enable-resource-auditing[enable auditing for all api requests connected to resources]' \ + '--enable-system-auditing[enable auditing for all api requests connected to system transactions]' \ + '--enable-team-auditing[enable auditing for all api requests connected to teams]' \ + '--enable-worker-auditing[enable auditing for all api requests connected to workers]' \ + '--enable-volume-auditing[enable auditing for all api requests connected to volumes]' \ + '--postgres-host=[the host to connect to]: :_hosts' \ + '--postgres-port=[the port to connect to]: :_concourse_ports' \ + '--postgres-socket=[path to a UNIX domain socket to connect to]: :_files' \ + '--postgres-user=[the user to sign in as]: :_users' \ + '--postgres-password=[the user'\''s password]:password' \ + '--postgres-sslmode=[whether or not to use SSL]:SSL mode:((disable require verify-ca verify-full))' \ + '--postgres-ca-cert=[CA cert file location, to verify when connecting with SSL]: :_files' \ + '--postgres-client-cert=[client cert file location]: :_files' \ + '--postgres-client-key=[client key file location]: :_files' \ + '--postgres-connect-timeout=[dialing timeout]: :_concourse_durations' \ + '--postgres-database=[the name of the database to use]:database name' \ + '--secret-retry-attempts=[the number of attempts secret will be retried to be fetched, in case a retriable error happens]:number' \ + '--secret-retry-interval=[the interval between secret retry retrieval attempts]: :_concourse_durations' \ + '--secret-cache-enabled[enable in-memory cache for secrets]' \ + '--secret-cache-duration=[if the cache is enabled, secret values will be cached for not longer than this duration]: :_concourse_durations' \ + '--secret-cache-purge-interval=[if the cache is enabled, expired items will be removed on this internal]: :_concourse_durations' \ + '--credhub-url=[CredHub server address used to access secrets]: :_urls' \ + '--credhub-path-prefix=[path under which to namespace credential lookup]:path' \ + '--credhub-ca-cert=[path to PEM-encoded CA cert files to use to verify the CredHub server SSL cert]: :_files' \ + '--credhub-client-cert=[path to the client certificate for mutual TLS authorization]: :_files' \ + '--credhub-client-key=[path to the client private key for mutual TLS authorization]: :_files' \ + '--credhub-insecure-skip-verify[enable insecure SSL verification]' \ + '--credhub-client-id=[client ID for CredHub authorization]:client ID' \ + '--credhub-client-secret=[client secret for CredHub authorization]:client secret' \ + '--kubernetes-in-cluster[enables the in-cluster client]' \ + '--kubernetes-config-path=[path to Kubernetes config when running ATC outside Kubernetes]: :_files' \ + '--kubernetes-namespace-prefix=[prefix to use for Kubernetes namespaces under which secrets will be looked up]:prefex' \ + '--aws-secretsmanager-access-key=[AWS Access key ID]:access key' \ + '--aws-secretsmanager-secret-key=[AWS Secret Access Key]:secret key' \ + '--aws-secretsmanager-session-token=[AWS Session Token]:session token' \ + '--aws-secretsmanager-region=[AWS region to send requests to]:region' \ + '--aws-secretsmanager-pipeline-secret-template=[AWS Secrets Manager secret identifier template used for pipeline specific parameter]:template' \ + '--aws-secretsmanager-team-secret-template=[AWS Secrets Manager secret identifier template used for team specific parameter]:template' \ + '--aws-ssm-access-key=[AWS Access key ID]:access key' \ + '--aws-ssm-secret-key=[AWS Secret Access Key]:secret key' \ + '--aws-ssm-session-token=[AWS Session Token]:session token' \ + '--aws-ssm-region=[AWS region to send requests to]:region' \ + '--aws-ssm-pipeline-secret-template=[AWS SSM parameter name template used for pipeline specific parameter]:template' \ + '--aws-ssm-team-secret-template=[AWS SSM parameter name template used for team specific parameter]:template' \ + '--vault-url=[vault server address used to access secrets]: :_urls' \ + '--vault-path-prefix=[path under which to namespace credential lookup]:prefix' \ + '--vault-shared-path=[path under which to lookup shared credentials]:path' \ + '--vault-ca-cert=[path to a PEM-encoded CA cert file to use to verify the vault server SSL cert]: :_files' \ + '--vault-ca-path=[path to a directory of PEM-encoded CA cert files to verify the vault server SSL cert]: :_files -/' \ + '--vault-client-cert=[path to the client certificate for Vault authorization]: :_files' \ + '--vault-client-key=[path to the client private key for Vault authorization]: :_files' \ + '--vault-server-name=[if set, is used to set the SNI host when connecting via TLS]:server name' \ + '--vault-insecure-skip-verify[enable insecure SSL verification]' \ + '--vault-client-token=[client token for accessing secrets within the Vault server]:client token' \ + '--vault-auth-backend=[auth backend to use for logging in to Vault]:auth backend' \ + '--vault-auth-backend-max-ttl=[time after which to force a re-login]: :_concourse_durations' \ + '--vault-retry-max=[the maximum time between retries when logging in or re-authing a secret]: :_concourse_durations' \ + '--vault-retry-initial=[the initial time between retries when logging in or re-authing a secret]: :_concourse_durations' \ + '*--vault-auth-param=[parameter to pass when logging in via the backend]: :_concourse_name_colon_values' \ + {-n,--noop}'[don'\''t actually do any automatic scheduling or checking]' \ + '--worker-garden-url=[a Garden API endpoint to register as a worker]: :_urls' \ + '--worker-baggageclaim-url=[a Baggageclaim API endpoint to register with the worker]: :_urls' \ + '*--worker-resource=[a resource type to advertise for the worker]: :_concourse_type_colon_images' \ + '--metrics-host-name=[host string to attach to emitted metrics]: :_hosts' \ + '*--metrics-attribute=[a key-value attribute to attach to emitted metrics]: :_concourse_name_colon_values' \ + '--capture-error-metrics[enable capturing of error log metrics]' \ + '--datadog-agent-host=[datadog agent host to expose dogstatsd metrics]: :_hosts' \ + '--datadog-agent-port=[datadog agent port to expose dogstatsd metrics]: :_concourse_ports' \ + '--datadog-prefix=[prefix for all metrics to easily find them in Datadog]:prefix' \ + '--influxdb-url=[influxDB server address to emit points to]: :_urls' \ + '--influxdb-database=[influxDB database to write points to]:database name' \ + '--influxdb-username=[influxDB server username]: :_users' \ + '--influxdb-password=[influxDB server password]:password' \ + '--influxdb-insecure-skip-verify[skip SSL verification when emitting to InfluxDB]' \ + '--emit-to-logs[emit metrics to logs]' \ + '--newrelic-account-id=[new Relic Account ID]:account ID' \ + '--newrelic-api-key=[new Relic Insights API Key]:API key' \ + '--newrelic-service-prefix=[an optional prefix for emitted New Relic events]:prefix' \ + '--prometheus-bind-ip=[IP to listen on to expose Prometheus metrics]: :_concourse_ip_addresses' \ + '--prometheus-bind-port=[port to listen on to expose Prometheus metrics]: :_concourse_ports' \ + '--riemann-host=[riemann server address to emit metrics to]: :_hosts' \ + '--riemann-port=[port of the Riemann server to emit metrics to]: :_concourse_ports' \ + '--riemann-service-prefix=[an optional prefix for emitted Riemann services]:prefix' \ + '*--riemann-tag=[tag to attach to emitted metrics]:tag' \ + '--x-frame-options=[the value to set for X-Frame-Options]:options' \ + '--cluster-name=[a name for this Concourse cluster, to be displayed on the dashboard page]:name' \ + '--gc-interval=[interval on which to perform garbage collection]: :_concourse_durations' \ + '--gc-one-off-grace-period=[period after which one-off build containers will be garbage-collected]: :_concourse_durations' \ + '--gc-missing-grace-period=[period after which to reap containers and volumes that were created but went missing from the worker]: :_concourse_durations' \ + '--syslog-hostname=[client hostname with which the build logs will be sent to the syslog server]: :_hosts' \ + '--syslog-address=[remote syslog server address with port]: :_concourse_host_colon_ports' \ + '--syslog-transport=[transport protocol for syslog messages]:protocol:((tcp udp tls))' \ + '--syslog-drain-interval=[interval over which checking is done for new build logs to send to syslog server]: :_concourse_durations' \ + '--syslog-ca-cert=[paths to PEM-encoded CA cert files to use to verify the Syslog server SSL cert]: :_files' \ + '--cookie-secure[force sending secure flag on http cookies]' \ + '--auth-duration=[length of time for which tokens are valid]: :_concourse_durations' \ + '--session-signing-key=[file containing an RSA private key, used to sign auth tokens]: :_files' \ + '*--add-local-user=[list of username:password combinations for all your local users]: :_concourse_username_colon_passwords' \ + '*--main-team-local-user=[list of whitelisted local concourse users]: :_users' \ + {-c,--main-team-config=}'[configuration file for specifying team params]: :_concourse_config_files' \ + '*--main-team-bitbucket-cloud-user=[list of whitelisted Bitbucket Cloud users]: :_users' \ + '*--main-team-bitbucket-cloud-team=[list of whitelisted Bitbucket Cloud teams]:team' \ + '*--main-team-cf-user=[list of whitelisted CloudFoundry users]: :_users' \ + '*--main-team-cf-org=[list of whitelisted CloudFoundry orgs]:org name' \ + '*--main-team-cf-space=[list of whitelisted CloudFoundry spaces]:space name' \ + '*--main-team-github-user=[list of whitelisted GitHub users]: :_users' \ + '*--main-team-github-org=[list of whitelisted GitHub orgs]:org name' \ + '*--main-team-github-team=[list of whitelisted GitHub teams]:team name' \ + '*--main-team-gitlab-user=[list of whitelisted GitLab users]: :_users' \ + '*--main-team-gitlab-group=[list of whitelisted GitLab groups]:group name' \ + '*--main-team-ldap-user=[list of whitelisted LDAP users]: :_users' \ + '*--main-team-ldap-group=[list of whitelisted LDAP groups]:group name' \ + '*--main-team-oauth-user=[list of whitelisted OAuth2 users]: :_users' \ + '*--main-team-oauth-group=[list of whitelisted OAuth2 groups]:group name' \ + '*--main-team-oidc-user=[list of whitelisted OIDC users]: :_users' \ + '*--main-team-oidc-group=[list of whitelisted OIDC groups]:group name' \ + '--bitbucket-cloud-client-id=[client id]:client ID' \ + '--bitbucket-cloud-client-secret=[client secret]:client secret' \ + '--cf-client-id=[client id]:client ID' \ + '--cf-client-secret=[client secret]:client secret' \ + '--cf-api-url=[the base API URL of your CF deployment]: :_urls' \ + '--cf-ca-cert=[CA Certificate]: :_files' \ + '--cf-skip-ssl-validation[skip SSL validation]' \ + '--github-client-id=[client id]:client ID' \ + '--github-client-secret=[client secret]:client secret' \ + '--github-host=[hostname of GitHub Enterprise deployment]: :_hosts' \ + '--github-ca-cert=[CA certificate of GitHub Enterprise deployment]: :_files' \ + '--gitlab-client-id=[client id]:client ID' \ + '--gitlab-client-secret=[client secret]:client secret' \ + '--gitlab-host=[hostname of Gitlab Enterprise deployment]: :_hosts' \ + '--ldap-display-name=[the auth provider name displayed to users on the login page]:display name' \ + '--ldap-host=[the host and optional port of the LDAP server]: :_hosts' \ + '--ldap-bind-dn=[bind DN for searching LDAP users and groups]:bind DN' \ + '--ldap-bind-pw=[bind Password for the user specified by bind-dn]:bind password' \ + '--ldap-insecure-no-ssl[required if LDAP host does not use TLS]' \ + '--ldap-insecure-skip-verify[skip certificate verification]' \ + '--ldap-start-tls[start on insecure port, then negotiate TLS]' \ + '--ldap-ca-cert=[CA certificate]: :_files' \ + '--ldap-user-search-base-dn= [baseDN to start the search from]:baseDN' \ + '--ldap-user-search-filter=[optional filter to apply when searching the directory]:filter' \ + '--ldap-user-search-username=[attribute to match against the inputted username]:attribute' \ + '--ldap-user-search-scope=[can either be: '\''sub'\'' - search the whole sub tree or '\''one'\'' - only search one level]:scope:((sub one))' \ + '--ldap-user-search-id-attr=[a mapping of attributes on the user entry to claims]:attribute mapping' \ + '--ldap-user-search-email-attr=[a mapping of attributes on the user entry to claims]:attribute mapping' \ + '--ldap-user-search-name-attr=[a mapping of attributes on the user entry to claims]:attribute mapping' \ + '--ldap-group-search-base-dn=[baseDN to start the search from]:baseDN' \ + '--ldap-group-search-filter=[optional filter to apply when searching the directory]:filter' \ + '--ldap-group-search-scope=[can either be: '\''sub'\'' - search the whole sub tree or '\''one'\'' - only search one level]:scope:((sub one))' \ + '--ldap-group-search-user-attr=[adds an additional requirement to the filter that an attribute in the group match the user'\''s attribute value]:attribute' \ + '--ldap-group-search-group-attr=[adds an additional requirement to the filter that an attribute in the group match the user'\''s attribute value]:attribute' \ + '--ldap-group-search-name-attr=[the attribute of the group that represents its name]:attribute' \ + '--oauth-display-name=[the auth provider name displayed to users on the login page]:display name' \ + '--oauth-client-id=[client id]:client ID' \ + '--oauth-client-secret=[client secret]:client secret' \ + '--oauth-auth-url=[Authorization URL]: :_urls' \ + '--oauth-token-url=[Token URL]: :_urls' \ + '--oauth-userinfo-url=[UserInfo URL]: :_urls' \ + '*--oauth-scope=[any additional scopes that need to be requested during authorization]:scope' \ + '--oauth-groups-key=[the groups key indicates which claim to use to map external groups to Concourse teams]:group key' \ + '--oauth-user-id-key=[the user id key indicates which claim to use to map an external user id to a Concourse user id]:id key' \ + '--oauth-user-name-key=[the user name key indicates which claim to use to map an external user name to a Concourse user name]:name key' \ + '--oauth-ca-cert=[CA Certificate]: :_files' \ + '--oauth-skip-ssl-validation[skip SSL validation]' \ + '--oidc-display-name=[the auth provider name displayed to users on the login page]:display name' \ + '--oidc-issuer=[An OIDC issuer URL that will be used to discover provider configuration]: :_urls' \ + '--oidc-client-id=[client id]:client ID' \ + '--oidc-client-secret=[client secret]:client secret' \ + '*--oidc-scope=[any additional scopes that need to be requested during authorization]:scope' \ + '--oidc-groups-key=[the groups key indicates which claim to use to map external groups to Concourse teams]:group key' \ + '--oidc-user-name-key=[the user name key indicates which claim to use to map an external user name to a Concourse user name]:user name key' \ + '*--oidc-hosted-domains=[list of whitelisted domains when using Google, only users from a listed domain will be allowed to log in]:domain' \ + '--oidc-ca-cert=[CA Certificate]: :_files' \ + '--oidc-skip-ssl-validation[skip SSL validation]' \ + '--tsa-log-level=[minimum level of logs to see]: :_concourse_log_levels' \ + '--tsa-bind-ip=[IP address on which to listen for SSH]: :_concourse_ip_addresses' \ + '--tsa-peer-address=[network address of this web node, reachable by other web nodes]: :_urls' \ + '--tsa-bind-port=[port on which to listen for SSH]: :_concourse_ports' \ + '--tsa-debug-bind-ip=[IP address on which to listen for the pprof debugger endpoints]: :_concourse_ip_addresses' \ + '--tsa-debug-bind-port=[port on which to listen for the pprof debugger endpoints]: :_concourse_ports' \ + '--tsa-host-key=[path to private key to use for the SSH server]: :_files' \ + '--tsa-authorized-keys=[path to file containing keys to authorize, in SSH authorized_keys format]: :_files' \ + '--tsa-team-authorized-keys=[path to file containing keys to authorize, in SSH authorized_keys format]: :_concourse_name_colon_paths' \ + '--tsa-atc-url=[ATC API endpoints to which workers will be registered]: :_urls' \ + '--tsa-session-signing-key=[path to private key to use when signing tokens in requests to the ATC during registration]: :_files' \ + '--tsa-heartbeat-interval=[interval on which to heartbeat workers to the ATC]: :_concourse_durations' \ +} + +(( $+functions[_concourse_worker_args] )) || +_concourse_worker_args() { + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '--name=[the name to set for the worker during registration]:name' \ + '*--tag=[a tag to set during registration]:tag' \ + '--team=[the name of the team that this worker will be assigned to]:team name' \ + '--http-proxy=[HTTP proxy endpoint to use for containers]: :_urls' \ + '--https-proxy=[HTTPS proxy endpoint to use for containers]: :_urls' \ + '*--no-proxy=[blacklist of addresses to skip the proxy when reaching]: :_urls' \ + '--ephemeral[if set, the worker will be immediately removed upon stalling]' \ + '--certs-dir=[directory to use when creating the resource certificates volume]: :_files -/' \ + '--work-dir=[directory in which to place container data]: :_files -/' \ + '--bind-ip=[IP address on which to listen for the Garden server]: :_concourse_ip_addresses' \ + '--bind-port=[port on which to listen for the Garden server]: :_concourse_ports' \ + '--debug-bind-ip=[IP address on which to listen for the pprof debugger endpoints]: :_concourse_ip_addresses' \ + '--debug-bind-port=[port on which to listen for the pprof debugger endpoints]: :_concourse_ports' \ + '--healthcheck-bind-ip=[IP address on which to listen for health checking requests]: :_concourse_ip_addresses' \ + '--healthcheck-bind-port=[port on which to listen for health checking requests]: :_concourse_ports' \ + '--healthcheck-timeout=[HTTP timeout for the full duration of health checking]: :_concourse_durations' \ + '--sweep-interval=[interval on which containers and volumes will be garbage collected from the worker]: :_concourse_durations' \ + '--volume-sweeper-max-in-flight=[maximum number of volumes which can be swept in parallel]:number' \ + '--container-sweeper-max-in-flight=[maximum number of containers which can be swept in parallel]:number' \ + '--rebalance-interval=[duration after which the registration should be swapped to another random SSH gateway]: :_concourse_durations' \ + '--connection-drain-timeout=[duration after which a worker should give up draining forwarded connections on shutdown]: :_concourse_durations' \ + '--external-garden-url=[API endpoint of an externally managed Garden server to use instead of running the embedded Garden server]: :_urls' \ + '--resource-types=[path to directory containing resource types the worker should advertise]: :_files -/' \ + '--log-level=[minimum level of logs to see]: :_concourse_log_levels' \ + '*--tsa-host=[TSA host to forward the worker through]: :_hosts' \ + '--tsa-public-key=[file containing a public key to expect from the TSA]: :_files' \ + '--tsa-worker-private-key=[file containing the private key to use when authenticating to the TSA]: :_files' \ + '--garden-use-houdini[use the insecure Houdini Garden backend]' \ + '--garden-bin=[path to gdn executable (or leave as gdn to find it in $PATH)]: :_files' \ + '--garden-config=[path to a config file to use for Garden]: :_files' \ + '--garden-dns-proxy-enable[enable proxy DNS server]' \ + '--baggageclaim-log-level=[minimum level of logs to see]: :_concourse_log_levels' \ + '--baggageclaim-bind-ip=[IP address on which to listen for API traffic]: :_concourse_ip_addresses' \ + '--baggageclaim-bind-port=[port on which to listen for API traffic]: :_concourse_ports' \ + '--baggageclaim-debug-bind-ip=[IP address on which to listen for the pprof debugger endpoints]: :_concourse_ip_addresses' \ + '--baggageclaim-debug-bind-port=[port on which to listen for the pprof debugger endpoints]: :_concourse_ports' \ + '--baggageclaim-volumes=[directory in which to place volume data]: :_files -/' \ + '--baggageclaim-driver=[driver to use for managing volumes]:driver:((detect naive btrfs overlay))' \ + '--baggageclaim-btrfs-bin=[path to btrfs binary]: :_files' \ + '--baggageclaim-mkfs-bin=[path to mkfs.btrfs binary]: :_files' \ + '--baggageclaim-overlays-dir=[path to directory in which to store overlay data]: :_files -/' \ + '--baggageclaim-disable-user-namespaces[disable remapping of user/group IDs in unprivileged volumes]' +} + +(( $+functions[_concourse_config_files] )) || +_concourse_config_files() { + _files -g "*.(yml|yaml)" +} + +(( $+functions[_concourse_ip_addresses] )) || +_concourse_ip_addresses() { + _message 'IP address' +} + +(( $+functions[_concourse_ports] )) || +_concourse_ports() { + _message 'port number' +} + +(( $+functions[_concourse_host_colon_ports] )) || +_concourse_host_colon_ports() { + local ret=1 + if compset -P '*:'; then + _concourse_ports && ret=0 + else + _alternative \ + 'hosts: :_hosts -qS:' \ + 'ip-addresses: :_guard "[[:digit:]]*" "IP address"' \ + && ret=0 + fi + return ret +} + +(( $+functions[_concourse_type_colon_images] )) || +_concourse_type_colon_images() { + local ret=1 + if compset -P '*:'; then + _message 'type' && ret=0 + else + _message 'image' && ret=0 + fi + return ret +} + +(( $+functions[_concourse_name_colon_values] )) || +_concourse_name_colon_values() { + local ret=1 + if compset -P '*:'; then + _message 'name' && ret=0 + else + _message 'value' && ret=0 + fi + return ret +} + +(( $+functions[_concourse_username_colon_passwords] )) || +_concourse_username_colon_passwords() { + local ret=1 + if compset -P '*:'; then + _message 'username' && ret=0 + else + _message 'password' && ret=0 + fi + return ret +} + +(( $+functions[_concourse_name_colon_paths] )) || +_concourse_name_colon_paths() { + local ret=1 + if compset -P '*:'; then + _message 'name' && ret=0 + else + _files && ret=0 + fi + return ret +} + +(( $+functions[_concourse_durations] )) || +_concourse_durations() { + _message 'duration, eg: "5s", "5m", "5h", "5d"' +} + +(( $+functions[_concourse_log_levels] )) || +_concourse_log_levels() { + local levels=( + 'debug:debug traces' + 'info:normal log level' + 'error:log only errors' + 'fatal:log only fatal errors' + ) + _describe -t log-levels 'log level' levels +} + +case $service in + concourse) _concourse_server "$@" ;; + fly) _concourse_fly "$@" ;; + *) _message "unknown command ${service}" && ret=1 ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_console b/home/.zsh-server/plugins/zsh-completions/src/_console new file mode 100644 index 0000000..7e5b454 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_console @@ -0,0 +1,64 @@ +#compdef console +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for symfony console (https://github.com/symfony/Console). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * loranger (https://github.com/loranger) +# * Yohan Tambè (https://github.com/Cronos87) +# +# ------------------------------------------------------------------------------ + +_find_console () { + echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' -type f | head -n 1)" +} + +_console_get_command_list () { + IFS=" " + `_find_console` --no-ansi | \ + sed "1,/Available commands/d" | \ + awk '/ [a-z]+/ { print $0 }' | \ + sed -E 's/^[ ]+//g' | \ + sed -E 's/[:]+/\\:/g' | \ + sed -E 's/[ ]{2,}/\:/g' +} + +_console () { + local -a commands + IFS=$'\n' + commands=(`_console_get_command_list`) + _describe 'commands' commands +} + +compdef _console php console +compdef _console console diff --git a/home/.zsh-server/plugins/zsh-completions/src/_cppcheck b/home/.zsh-server/plugins/zsh-completions/src/_cppcheck new file mode 100644 index 0000000..2006828 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_cppcheck @@ -0,0 +1,116 @@ +#compdef cppcheck +# ------------------------------------------------------------------------------ +# Copyright (c) 2019 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for cppcheck -- a tool for static C/C++ code analysis (http://cppcheck.sourceforge.net) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Georgy Komarov (https://github.com/jubnzv) +# +# ------------------------------------------------------------------------------ +# Notes +# ----- +# +# Created for Cppcheck version 2.9 +# +# ------------------------------------------------------------------------------ + +_cppcheck_files() { + _path_files -/ -g "*.(c|cpp|cxx|h|hpp|C)" +} + +_cppcheck() { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + "--addon=[Execute addon]" \ + "--addon-python=[Specify the python interpreter]: :_files" \ + "--cppcheck-build-dir=[Analysis output directory]:directory:_files -/" \ + "--check-config[Check cppcheck configuration]" \ + "--check-library[Show information when library files have incomplete info]" \ + "--clang=[Use clang parser instead of the builtin Cppcheck parser]: :_files" \ + "--config-exclude=[Path to be excluded from configuration checking]:directory:_files -/" \ + "--config-exclude-files=[A file that contains a list of config-excludes]:file:_files" \ + "--doc[Print a list of all available checks]" \ + "--dump[Dump xml data for each translation unit]" \ + "-D[Define preprocessor symbol]" \ + "-U[Undefine preprocessor symbol]" \ + "-E[Print preprocessor output on stdout and don't do any further processing]" \ + "--enable[Enable additional checks]:id:(all warning style performance portability information unusedFunction missingInclude)" \ + "--error-exitcode=[Integer to return if errors are found]" \ + "--errorlist[Print a list of all the error messages in XML format]" \ + "--exitcode-suppressions=[Used when certain messages should be displayed but should not cause a non-zero exitcode]:_files" \ + "*--file-filter=[Analyze only those files matching the given filter str]:filter" \ + "--file-list=[Specify the files to check in a text file]:_files" \ + '(-f --force)'{-f,--force}"[Force checking of all configurations in files]" \ + '(- 1 *)'{-h,--help}"[Print this help]" \ + "-I[A file that contains a list of config-excludes]:directory:_files -/" \ + "--include-file=[Specify directory paths to search for included header files in a text file]:file:_files" \ + "--include=[Force inclusion of a file before the checked file]:file:_files" \ + "-i[Give a source file or source file directory to exclude from the check]:directory or file:_files" \ + "--inconclusive[Report even though the analysis is inconclusive]" \ + "--inline-suppr[Enable inline suppressions]" \ + "-j[Number of threads to do the checking simultaneously]::num" \ + "-l[No new threads should be started if the load average is exceeds this value]::load_avg" \ + {-x,--language=}"[Forces cppcheck to check all files as the given language]:language:(c c++)" \ + "--max-configs=[Maximum number of configurations to check in a file]" \ + "--max-ctu-depth=[Maximum depth in whole program analysis]:num" \ + "--output-file=[File to save results]:file:_files" \ + "--plist-output=[Generate Clang-plist output files in folder]:_files" \ + "--project=[Run Cppcheck on project]:file:_files" \ + "--project-configuration=[Limit the configuration cppcheck should check]:configuration" \ + "--platform=[Set platform specific types and sizes]:platforms:(unix32 unix64 win32A win32W win64 avr8 elbrus-e1cp pic8 pic8-enhanced pic16 mips32 native unspecified)" \ + '(-q --quiet)'{-q,--quiet}"[Do not show progress reports]" \ + {-rp,--relative-paths}"=[Use relative paths in output (separated with ;)]:_files" \ + "--report-progress[Report progress messages while checking a file]" \ + "--std=[Set standard]:std:(c89 c99 c11 c++03 c++11 c++14 c++17 c++20)" \ + "--suppress=[Suppress warnings (format: \[error id\]:\[filename\]:\[line\])]" \ + "--suppressions-list=[Suppress warnings listed in the file]:_files" \ + "--suppress-xml=[Suppress warnings listed in a xml file]:_files" \ + "--template=[Format the error messages]" \ + "--template-location=[Format the error message location]" \ + "(-v --verbose)"{-v,--verbose}"[Output more detailed error information]" \ + "--version[Print out version number]" \ + "--xml[Write results in xml format to stderr]" \ + '*: :_cppcheck_files' +} + +_cppcheck "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_dad b/home/.zsh-server/plugins/zsh-completions/src/_dad new file mode 100644 index 0000000..9ceee06 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_dad @@ -0,0 +1,68 @@ +#compdef dad +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for dad a command line manager of aria2 daemon. (https://github.com/baskerville/diana). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +_dad() { + local -a commands + + commands=( + "start:Start aria2c daemon" + "stop:Stop aria2c daemon" + ) + + _arguments -C \ + '(- 1 *)'-h"[Show help and exit]" \ + "-d[Set download dir]:download_dir:->val" \ + "-s[Set secret token]:secret_token:->val" \ + "-u[Set aria2c username]:username:->val" \ + "-p[Set aria2c password]:password:->val" \ + '1:cmd:->cmds' \ + '*: : :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + ;; + esac +} + +_dad + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_debuild b/home/.zsh-server/plugins/zsh-completions/src/_debuild new file mode 100644 index 0000000..20c676e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_debuild @@ -0,0 +1,40 @@ +#compdef debuild +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for debuild 2.10. +# +# Status: incomplete. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +# FIXME --noconf is only allowed in first position +_arguments \ + '(- 1 *)'{-h,--help}'[show help]' \ + '(- 1 *)--version[show version and copyright information]' \ + {--no-conf,--noconf}'[don'\''t read devscripts config files]' \ + {-r-,--rootcmd=}'[command used to become root if debuild not setuid root (default: fakeroot)]: :_command_names' \ + '*'{-e-,--preserve-envvar=}'[preserve environment variable]: :_vars' \ + '(-e --preserve-envvar)--preserve-env[preserve all environment vars (except PATH)]' \ + '*'{-e-,--set-envvar=}'[preserve environment variable]: :_vars -qS=' \ + '--prepend-path=[prepend to the sanitised PATH]: :_files -/' \ + '(-D)-d[skip checking of build dependencies]' \ + '(-d)-D[force checking of build dependencies]' \ + '--check-dirname-level[how much to check directory names]:level:((0\:never 1\:only\ if\ program\ changes\ directory\ \(default\) 2\:always))' \ + '--check-dirname-regex[Perl regex defining matching directory names, the string PACKAGE will be replaced by the package name (default: '\''PACKAGE(-.+)?'\'')]:regex' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_dget b/home/.zsh-server/plugins/zsh-completions/src/_dget new file mode 100644 index 0000000..d540121 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_dget @@ -0,0 +1,70 @@ +#compdef dget +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for dget +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Kris Shannon +# * Shohei YOSHIDA +# +# ------------------------------------------------------------------------------ + +_dget() { + local context state line expl + local -A opt_args + + _arguments -A "-*" \ + '(--no-conf -h --help)'{-h,--help}'[Show help message]' \ + '(--no-conf -V --version)'{-v,--version}'[Print license, copyright, and version information and exit]' \ + '(--no-conf -b --backup)'{-b,--backup}'[Move files that would be overwritten to ./backup]' \ + '(--no-conf -q --quiet)'{-q,--quiet}'[Suppress wget/curl output]' \ + '(--no-conf -x --extract -d --download-only --build)'{-d,--download-only}'[Do not extract downloaded source]' \ + '(--no-conf -x --extract -d --download-only --build)'{-x,--extract}'[Unpack downloaded source]' \ + '(--no-conf -x --extract -d --download-only --build)--build[Build package with dpkg-buildpackage after download]' \ + '(--no-conf -u --allow-unauthenticated)'{-u,--allow-unauthenticated}'[Make no attempt to verify source package signature]' \ + '(--no-conf)--path[Check this directory in addition to the apt archive]:DIR:_files -/' \ + '(--no-conf --insecure)--insecure[Do not check SSL certificates when downloading]' \ + '(--no-conf --no-cache)--no-cache[Disable server-side HTTP cache]' \ + "(--no-conf)--no-conf[Don't read devscripts config files]" \ + '(-)*:debian package or URL: _alternative "_deb_packages available" "_urls"' +} + +_dget "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_dhcpcd b/home/.zsh-server/plugins/zsh-completions/src/_dhcpcd new file mode 100644 index 0000000..82b821f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_dhcpcd @@ -0,0 +1,53 @@ +#compdef dhcpcd +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for dhcpcd 2.3.2. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_arguments \ + '1:network interface:_net_interfaces' \ + - release \ + '(-k --release)'{-k,--release}'[causes an existing dhcpcd process running on the interface to release it'\''s lease, deconfigure the interface and then exit]' \ + - exit \ + '(-x --exit)'{-x,--exit}'[causes an existing dhcpcd process running on the interface to exit]' \ + - main \ + '(-d --debug)'{-d,--debug}'[echo debug and informational messages to the console]' \ + '(-h --hostname)'{-h,--hostname}'[specify the hostname sent, or an empty string to stop any hostname from being sent]:hostname:_hosts' \ + '(-i --classid)'{-i,--classid}'[override the DHCP vendor classid field we send]:classid' \ + '(-l --leasetime)'{-l,--leasetime}'[request a specific lease time in seconds]:lease time \(seconds\)' \ + '(-m --metric)'{-m,--metric}'[added routes will use the metric on systems where this is supported]:metric' \ + '(-n --renew)'{-n,--renew}'[notifies an existing dhcpcd process running on the interface to renew it'\''s lease]' \ + '(-p --persistent)'{-p,--persistent}'[don'\''t deconfigure the interface and configuration at exit]' \ + '(-r --request)'{-r,--request}'[skip the broadcast request step and just request an address]:address' \ + '(-s --inform)'{-s,--inform}'[behaves exactly like -r, but sends a DHCP inform instead of a request]:address' \ + '(-t --timeout)'{-t,--timeout}'[timeout after seconds, instead of the default 20]:timeout \(seconds\)' \ + '(-u --userclass)'{-u,--userclass}'[tags the DHCP message with the userclass class]:class' \ + '*'{-H,--sethostname}'[forces dhcpcd to set the hostname as supplied by the DHCP server]' \ + '({-I --clientid)'{-I,--clientid}'[send clientid as a client identifier string]:clientid' \ + '*'{-S,--mscsr}'[request Microsoft specific Classless Static Routes (RFC 3442) code as well]' \ + '(-A --noarp)'{-A,--noarp}'[don'\''t request or claim the address by ARP]' \ + '(-G --nogateway)'{-G,--nogateway}'[don'\''t set any default routes]' \ + '(-L --noipv4ll)'{-L,--noipv4ll}'[don'\''t use IPv4LL at all]' \ + '(-M --nomtu)'{-M,--nomtu}'[don'\''t set the MTU of the interface]' \ + '(-N --nontp)'{-N,--nontp}'[don'\''t touch /etc/ntpd.conf or restart the ntp service]' \ + '(-R --nodns)'{-R,--nodns}'[don'\''t send DNS information to resolvconf or touch /etc/resolv.conf]' \ + '(-T --test)'{-T,--test}'[on receipt of discover messages, simply print the contents of the DHCP message to the console]' \ + '(-Y --nonis)'{-Y,--nonis}'[don'\''t touch /etc/yp.conf or restart the ypbind service]' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_diana b/home/.zsh-server/plugins/zsh-completions/src/_diana new file mode 100644 index 0000000..ef51a0d --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_diana @@ -0,0 +1,150 @@ +#compdef diana +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Diana a command line interface to the aria2 daemon. (https://github.com/baskerville/diana). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +local GIDs PGIDs + +_diana_load_gids() { + GIDs=() + local downloads hashArr fileName + + downloads=$(diana list | cut -d' ' -f1) + + if [ ${#downloads} -eq "0" ]; then + return + fi + + hashArr=("${(f)$(echo "$downloads")}") + for ((i=1; i<=${#hashArr[@]}; i++)); do + fileName=$(diana files $hashArr[i] | grep "[X]" | rev | cut -d'/' -f1 | rev); + GIDs+=("$hashArr[i]:$fileName"); + done +} + +_diana_load_paused_gids() { + PGIDs=() + local downloads hashArr fileName + + downloads=$(diana paused | cut -d' ' -f1) + + if [ ${#downloads} -eq "0" ]; then + return + fi + + hashArr=("${(f)$(echo "$downloads")}") + for ((i=1; i<=${#hashArr[@]}; i++)); do + fileName=$(diana files $hashArr[i] | grep "[X]" | rev | cut -d'/' -f1 | rev); + PGIDs+=("$hashArr[i]:$fileName"); + done +} + +_diana_command_arguments() { + case $words[1] in + (remove) + _diana_load_gids + _describe -t output 'Downloads to delete' GIDs + ;; + (info) + _diana_load_gids + _describe -t output 'Downloads to get info' GIDs + ;; + (files) + _diana_load_gids + _describe -t output 'Get files for downloads' GIDs + ;; + (forcerm) + _diana_load_gids + _describe -t output 'Downloads to delete' GIDs + ;; + (pause) + _diana_load_gids + _describe -t output 'Downloads to pause' GIDs + ;; + (resume) + _diana_load_paused_gids + _describe -t output 'Downloads to resume' PGIDs + ;; + (preview) + _diana_load_gids + _describe -t output 'Downloads to preview' GIDs + ;; + esac + + +} + +_diana() { + local -a commands + + commands=( + "list:Output the list of active downloads." + "paused:Output the list of paused downloads." + "stopped:Output the list of stopped downloads." + "info:Output information regarding the given GIDs." + "files:Output the files owned by the downloads corresponding to the given GIDs." + "errors:Output the list of errors." + "stats:Output download bandwidth statistics." + "add:Download the given items (local or remote URLs to torrents, etc.)." + "remove:Remove the downloads corresponding to the given GIDs." + "forcerm:Forcibly remove the downloads corresponding to the given GIDs." + "pause:Pause the downloads corresponding to the given GIDs." + "resume:Resume the downloads corresponding to the given GIDs." + "preview:Preview all the files from all the downloads corresponding to the given GIDs." + "sleep:Pause all the active downloads." + "wake:Resume all the paused downloads." + "purge:Clear the list of stopped downloads and errors." + "clean:Stop seeding completed downloads." + ) + +_arguments -C \ + '1:cmd:->cmds' \ + '*:: :->args' \ + +case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + _diana_command_arguments + ;; +esac +} + +_diana + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_direnv b/home/.zsh-server/plugins/zsh-completions/src/_direnv new file mode 100644 index 0000000..3d2a742 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_direnv @@ -0,0 +1,125 @@ +#compdef direnv +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS OR THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for direnv (https://direnv.net/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Nitai J. Perez +# +# ------------------------------------------------------------------------------ + +_commands=( + 'allow:Grants direnv permission to load the given .envrc or .env file.' + 'permit:Grants direnv permission to load the given .envrc or .env file.' + 'grant:Grants direnv permission to load the given .envrc or .env file.' + 'block:Revokes the authorization of a given .envrc or .env file.' + 'deny:Revokes the authorization of a given .envrc or .env file.' + 'revoke:Revokes the authorization of a given .envrc or .env file.' + 'edit:Opens PATH_TO_RC or the current .envrc or .env into an $EDITOR and allow the file to be loaded afterwards.' + 'exec:Executes a command after loading the first .envrc or .env found in DIR' + 'fetchurl:Fetches a given URL into direnv''s CAS' + 'help:shows this help' + 'hook:Used to setup the shell hook' + 'prune:removes old allowed files' + 'reload:triggers an env reload' + 'status:prints some debug status information' + 'stdlib:Displays the stdlib available in the .envrc execution context' + 'version:prints the version or checks that direnv is older than VERSION_AT_LEAST.' +) + +_direnv_commands() { + _describe 'command' _commands +} + +_direnv() { + local state + + _arguments \ + '1: :_direnv_commands' \ + '*:: :->command_args' + + case $state in + command_args) + case $words[1] in + allow|permit|grant|block|deny|revoke|edit) + _arguments \ + '1:PATH TO RC FILE:_files' \ + ;; + + exec) + _arguments \ + '1:DIRECTORY:_files -/' \ + '2:COMMAND:_command_names' + + ;; + + hook) + _arguments \ + '1:SHELL:(bash zsh fish tcsh elvish)' + ;; + + fetchurl) + _arguments \ + '1:URL:' \ + '2:INTEGRITY HASH:' + ;; + + + prune|reload|status|stdlib) + _arguments + ;; + + version) + _arguments \ + '1:VERSION:' + ;; + + help) + _arguments \ + '1:SHOW PRIVATE:' + ;; + + *) + _default + ;; + esac + ;; + esac +} + +_direnv "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_docpad b/home/.zsh-server/plugins/zsh-completions/src/_docpad new file mode 100644 index 0000000..5b6a481 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_docpad @@ -0,0 +1,90 @@ +#compdef docpad +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for docpad v6.38.2 (https://github.com/bevry/docpad). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Changwoo Park (https://github.com/pismute) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +_docpad_subcommands() { + local -a commands=( + "run:run docpad on your project" + "init:initialize your project" + "generate:(re)generates your project" + "render:render the file at and output its results to stdout" + "watch:watches your project for changes, and (re)generates whenever a change is made" + "clean:ensure everything is cleaned correctly (will remove your out directory)" + "update:update your local DocPad and plugin installations to their latest compatible version" + "upgrade:update your local DocPad and plugin installations to their latest compatible version" + "install:install plugins" + "uninstall:uninstall a plugin" + "info:display the information about your docpad instance" + ) + + _describe -t commands 'command' commands "$@" +} + +_docpad() { + local ret=1 + + _arguments \ + '--outpath[a custom directory to place the rendered project]: :_files -/' \ + '--config[a custom configuration file to load in]: :_files' \ + '--env[the environment name to use for this instance, multiple names can be separated with a comma]' \ + '--log[the rfc log level to display]:level' \ + '(-v --verbose)'{-v,--verbose}'[set log level to 7]' \ + '(-d --debug)'{-d,--debug}'[output a log file]' \ + '--global[whether or not we should just fire global installation of docpad]' \ + '(--color --colour)'{--color,--colour}'[use color terminal output(default: true)]' \ + '--silent[do not write anything that is not essential]' \ + '--progress[output the progress as it occurs(default: true)]' \ + '--version[show version]' \ + '(- *)'{-h,--help}'[output usage information]'\ + '1: :_docpad_subcommands'\ + '*:: :_files' && ret=0 + + return ret +} + +_docpad "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_drush b/home/.zsh-server/plugins/zsh-completions/src/_drush new file mode 100644 index 0000000..83c0b04 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_drush @@ -0,0 +1,191 @@ +#compdef drush +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Drush (http://drush.ws). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Vasily Kraev (https://github.com/vasilykraev) +# +# ------------------------------------------------------------------------------ + +_drush() { + local curcontext='$curcontext' state line cmds ret=1 + integer NORMARG + typeset -A opt_args + + global_args=('--debug' '--verbose' '--yes' '--no' '--simulate' '--root=' '--uri=') + + _arguments -C \ + '(--*)'{--version,--version}'[Show drush version.]' \ + '(- *)'{-d,--debug}'[Display even more information, including internal messages.]' \ + '(- *)'{-v,--verbose}'[Display extra information about the command.]' \ + '(- *)'{-y,--yes}'[Assume "yes" as answer to all prompts.]' \ + '(- *)'{-n,--no}'[Assume "no" as answer to all prompts.]' \ + '(- *)'{-s,--simulate}'[Simulate all relevant actions (don'\''t actually change the system).]' \ + '(- *)'{-r,--root=}'[Drupal root directory to use (default: current directory).]' \ + '(- *)'{-l,--uri=}'[URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).]' \ + '1: :->cmds' \ + '*::arg:->args' \ + && ret=0 + +case $state in + cmds) + _values 'drush command' \ + '(archive-dump)'{archive-dump,ard,arb}'[Backup your code, files, and database into a single file.]' \ + '(archive-restore)'{archive-restore,arr}'[Expand a site archive into a Drupal web site.]' \ + '(cache-clear)'{cache-clear,cc}'[Clear a specific cache, or all drupal caches.]' \ + '(core-status)'{core-status,status,st}'[Provides a birds-eye view of the current Drupal installation, if any.]' \ + '(core-cron)'{core-cron,cron}'[Run all cron hooks in all active modules for specified site.]' \ + '(core-execute)'{core-execute,exec}'[Execute a shell command. Usually used with a site alias.]' \ + '(drupal-directory)'{drupal-directory,dd}'[Return the filesystem path for modules/themes and other key folders.]' \ + 'help[Print this help message.]' \ + 'image-flush[Flush all derived images for a given style.]' \ + '(site-alias)'{site-alias,sa}'[Print an alias record.]' \ + '(site-install)'{site-install,si}'[Install Drupal along with modules/themes/configuration using the specified install profile.]' \ + 'test-clean[Clean temporary tables and files.]' \ + 'test-run[Run tests. Note that you must use the --uri option.]' \ + '(updatedb)'{updatedb,updb}'[Apply any database updates required (as with running update.php).]' \ + '(variable-delete)'{variable-delete,vdel}'[Delete a variable.]' \ + '(variable-get)'{variable-get,vget}'[Get a list of some or all site variables and values.]' \ + '(variable-set)'{variable-set,vset}'[Set a variable.]' \ + '(pm-list)'{pm-list,pml}'[Show a list of available extensions (modules and themes).]' \ + '(pm-disable)'{pm-disable,dis}'[Disable one or more extensions (modules or themes). Disable dependent extensions as well.]' \ + '(pm-download)'{pm-download,dl}'[Download projects from drupal.org or other sources.]' \ + '(pm-enable)'{pm-enable,en}'[Enable one or more extensions (modules or themes). Enable dependent extensions as well.]' \ + 'pm-uninstall[Uninstall one or more modules.]' \ + 'pm-update[Update Drupal core and contrib projects and apply any pending database updates (Same as pm-updatecode + updatedb).]' \ + '(sql-cli)'{sql-cli,sqlc}'[Open a SQL command-line interface using Drupals credentials.]' \ + 'sql-drop[Drop all tables in a given database.]' \ + 'sql-dump[Exports the Drupal DB as SQL using mysqldump or equivalent.]' \ + '(sql-query)'{sql-query,sqlq}'[Execute a query against the site database.]' \ + 'sql-sync[Copy and import source database to target database. Transfers via rsync.]' \ + '(user-login)'{user-login,uli}'[Display a one time login link for the given user account (defaults to uid 1).]' \ + '(user-password)'{user-password,upwd}'[(Re)Set the password for the user account with the specified name.]' \ + '(devel-reinstall)'{devel-reinstall,dre}'[Disable, Uninstall, and Install a list of projects. (devel)]' \ + '(devel-token)'{devel-token,token}'[List available tokens (devel)]' \ + '(generate-content)'{generate-content,genc}'[Create content. (devel_generate)]' \ + '(generate-menus)'{generate-menus,genm}'[Create menus and menu items. (devel_generate)]' \ + '(generate-terms)'{generate-terms,gent}'[Create terms in specified vocabulary. (devel_generate)]' \ + '(generate-users)'{generate-users,genu}'[Create users. (devel_generate)]' \ + '(generate-vocabs)'{generate-vocabs,genv}'[Create vocabularies. (devel_generate)]' \ + '(features-diff)'{features-diff,fd}'[Show the difference between the default and overridden state of a feature.]' \ + '(features-export)'{features-export,fe}'[Export a feature from your site into a module.]' \ + '(features-list)'{features-list,fl}'[List all the available features for your site.]' \ + '(features-revert)'{features-revert,fr}'[Revert a feature module on your site.]' \ + '(features-revert-all)'{features-revert-all,fra}'[Revert all enabled feature module on your site.]' \ + '(features-update)'{features-update,fu}'[Update a feature module on your site.]' \ + '(features-update-all)'{features-update-all,fua}'[Update all feature modules on your site.]' \ + && ret=0 + ;; + args) + case $line[1] in + (archive-dump|ard) + _arguments \ + '(--description)--description=[Filter out extensions that are provided by drupal core.]' \ + '(--destination)--destination=[The full path and filename in which the archive should be stored. If omitted, it will be saved to the drush-backups directory.]' \ + '(--no-core)--no-core[Exclude Drupal core, so the backup only contains the site specific stuff.]' \ + '(--pipe)--pipe[Only print the destination of the archive. Useful for scripts that don'\''t pass --destination.]' \ + '(--tar-options)--tar-options=[Options passed thru to the tar command.]' \ + && ret=0 + compadd -a global_args + ;; + (archive-restore|arr) + _arguments \ + '(--db-prefix)--db-prefix[An optional table prefix to use during restore.]' \ + '(--db-su)--db-su[Account to use when creating the new database. Optional.]' \ + '(--db-su-pw)--db-su-pw[Password for the "db-su" account. Optional.]' \ + '(--db-url)--db-url=[A Drupal 6 style database URL indicating the target for database restore. If not provided, the archived settings.php is used. ]' \ + '(--destination)--destination[Specify where the Drupal site should be expanded, including the docroot. Defaults to the current working directory.]' \ + '(--overwrite)--overwrite[Allow drush to overwrite any files in the destination.]' \ + && ret=0 + compadd -a global_args + ;; + (user-password|upwd) + _arguments \ + '--password=:Set the password for the username someuser.' \ + && ret=0 + ;; + (help) + _values 'commands' 'arb' 'archive-dump' 'archive-restore' 'ard' 'arr' 'cache-clear' 'cc' 'core-cron' 'core-execute' 'core-status' 'cron' 'dd' 'devel-reinstall' 'devel-token' 'dis' 'dl' 'dre' 'drupal-directory' 'en' 'exec' 'fd' 'fe' 'features-diff' 'features-export' 'features-list' 'features-revert' 'features-revert-all' 'features-update' 'features-update-all' 'fl' 'fr' 'fra' 'fu' 'fua' 'genc' 'generate-content' 'generate-menus' 'generate-terms' 'generate-users' 'generate-vocabs' 'genm' 'gent' 'genu' 'genv' 'help' 'image-flush' 'pm-disable' 'pm-download' 'pm-enable' 'pm-list' 'pm-uninstall' 'pm-update' 'pml' 'sa' 'si' 'site-alias' 'site-install' 'sql-cli' 'sql-drop' 'sql-dump' 'sql-query' 'sql-sync' 'sqlc' 'sqlq' 'st' 'status' 'test-clean' 'test-run' 'token' 'uli' 'updatedb' 'updb' 'upwd' 'user-login' 'user-password' 'variable-delete' 'variable-get' 'variable-set' 'vdel' 'vget' 'vset' + ;; + (cc) + _values 'options' 'all' 'drush' 'theme-registry' 'menu' 'css-js' 'block' + ;; + (pm-list|pml) + _arguments \ + '(--core)--core[Filter out extensions that are not in drupal core.]' \ + '(--no-core)--no-core[Filter out extensions that are provided by drupal core.]' \ + '(--pipe)--pipe[Returns a whitespace delimited list of the names of the resulting extensions.]' \ + '(--status)--status=-[Filter by extension status. Choices: enabled, disabled and/or "not installed".]:status:(enabled disabled)' \ + '(--type)--type=-[Filter by extension type. Choices: module, theme.]:type:(module theme)' \ + && ret=0 + ;; + (pm-disable|dis) + _modules=( $(drush pml --status=enabled --pipe) ) + if [[ $_modules != "" ]]; then + _values 'enabled modules' $_modules + fi + ;; + (pm-enable|en) + _arguments -C \ + '--resolve-dependencies[Attempt to download any missing dependencies. At the moment, only works when the module name is the same as the project name.]' \ + '--skip[Skip automatic downloading of libraries (c.f. devel).]' && ret=0 + _modules=( $(drush pml --status="disabled,not installed" --pipe) ) + if [[ $_modules != "" ]]; then + _values -s 'not yet enabled modules' $_modules && ret=0 + fi + ;; + (*) + _values 'Global options' \ + {-d,--debug}'[Display even more information, including internal messages.]' \ + {-v,--verbose}'[Display extra information about the command.]' \ + {-y,--yes}'[Assume "yes" as answer to all prompts.]' \ + {-n,--no}'[Assume "no" as answer to all prompts.]' \ + {-s,--simulate}'[Simulate all relevant actions (don'\''t actually change the system).]' \ + {-r,--root=}'[Drupal root directory to use (default: current directory).]' \ + {-l,--uri=}'[URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).]' + ;; + esac + ;; +esac +} + +_drush '$@' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ecdsautil b/home/.zsh-server/plugins/zsh-completions/src/_ecdsautil new file mode 100644 index 0000000..5d0a6f3 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ecdsautil @@ -0,0 +1,53 @@ +#compdef ecdsautil +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ecdsaultils v0.4.0 (https://github.com/tcatm/ecdsautils) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Robinhuett +# +# ------------------------------------------------------------------------------ + +_ecdsautil_args() { + case $words[1] in + (sign) + _arguments '1:somefile:_files' + ;; + (verify) + _arguments '-s[signature]:secret:_files' '-p[publickey]:pubkey:_files' +'-n[signaturecount]:signaturecount:""' ':file:_files' + ;; + esac +} + +_ecdsautil() { + local -a commands + + commands=( + "help:Show help" + "generate-key:generate a new secret on stdout" + "show-key:output public key of secret read from stdin" + "sign:sign file" + "verify:verify signature of file" + ) + + _arguments -C \ + '1:cmd:->cmds' \ + '*:: :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + _ecdsautil_args + ;; + esac +} + +_ecdsautil "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_emulator b/home/.zsh-server/plugins/zsh-completions/src/_emulator new file mode 100644 index 0000000..265dccd --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_emulator @@ -0,0 +1,137 @@ +#compdef emulator +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for emulator (Android Emulator) 12.0 +# (http://developer.android.com/guide/developing/tools/emulator.html). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +typeset -A opt_args +local context state line curcontext="$curcontext" + +_list_avds() { + local -a _avds=($HOME/.android/avd/*.ini(N.:t:r)) + echo "${_avds[@]}" +} + +# TODO All image options are contextual to -sysdir value +# TODO All skin options are contextual to -skindir value +# TODO snapshot options are mutually exclusive +# TODO Use '-snapshot-list' output for snapshot names +# TODO -logcat: use completer from _adb +# TODO Complete options with device values +# TODO Complete -prop +_arguments \ + '(- : *)-version[display emulator version number]' \ + '(- : *)-help[display help information]' \ + '(- : *)-help-disk-images[about disk images]' \ + '(- : *)-help-keys[supported key bindings]' \ + '(- : *)-help-debug-tags[debug tags for -debug ]' \ + '(- : *)-help-char-devices[character specification]' \ + '(- : *)-help-environment[environment variables]' \ + '(- : *)-help-keyset-file[key bindings configuration file]' \ + '(- : *)-help-virtual-device[virtual device management]' \ + '(- : *)-help-sdk-images[about disk images when using the SDK]' \ + '(- : *)-help-build-images[about disk images when building Android]' \ + '(- : *)-help-all[prints all help content]' \ + '(- : *)-help-'{version,list-avds,sysdir,system,writable-system,image,datadir,kernel,ramdisk,initdata,data,partition-size,cache,no-cache,nocache,sdcard,snapstorage,no-snapstorage,snapshot,no-snapshot,no-snapshot-save,no-snapshot-load,snapshot-list,no-snapshot-update-time,wipe-data,avd,skindir,skin,noskin,no-skin,memory,cores,accel,no-accel,netspeed,netdelay,netfast,trace,show-kernel,shell,no-jni,nojni,logcat,noaudio,no-audio,audio,raw-keys,radio,port,ports,onion,onion-alpha,onion-rotation,scale,dpi-device,http-proxy,timezone,dns-server,cpu-delay,no-boot-anim,no-window,report-console,gps,keyset,shell-serial,tcpdump,bootchart,charmap,prop,shared-net-id,nand-limits,memcheck,qemu,verbose}'[print option-specific help]' \ + '-list-avds[list available AVDs]' \ + '-sysdir[search for system disk images in the directory]: :_files -/' \ + '(-system -image)'{-system,-image}'[read initial system image from the file]: :_files -g "*.img"' \ + '-writable-system[make system image writable after '\''adb remount'\'']' \ + '-datadir[write user data into the directory]: :_files -/' \ + '-kernel[use specific emulated kernel]: :_files' \ + '-ramdisk[ramdisk image (default /ramdisk.img]: :_files -g "*.img"' \ + '-initdata[same as '\''-init-data '\'']: :_files' \ + '-data[data image (default /userdata-qemu.img]: :_files -g "*.img"' \ + '-partition-size[system/data partition size]:size (in MBs)' \ + '(-no-cache -nocache)-cache[cache partition image (default is temporary file)]: :_files -g "*.img"' \ + '(-cache -no-cache -nocache)'{-no-cache,-nocache}'[disable the cache partition]' \ + '-sdcard[SD card image (default /sdcard.img]: :_files -g "*.img"' \ + '(-no-snapstorage)-snapstorage[file that contains all state snapshots (default /snapshots.img)]: :_files -g "*.img"' \ + '(-snapstorage)-no-snapstorage[do not mount a snapshot storage file (this disables all snapshot functionality)]' \ + '-snapshot[name of snapshot within storage file for auto-start and auto-save (default '\''default-boot'\'')]:snapshot name' \ + '-no-snapshot[perform a full boot and do not do not auto-save, but qemu vmload and vmsave operate on snapstorage]' \ + '-no-snapshot-save[do not auto-save to snapshot on exit: abandon changed state]' \ + '-no-snapshot-load[do not auto-start from snapshot: perform a full boot]' \ + '-snapshot-list[show a list of available snapshots]' \ + '-no-snapshot-update-time[do not do try to correct snapshot time on restore]' \ + '-wipe-data[reset the user data image (copy it from initdata)]' \ + '-avd[use a specific android virtual device]:android virtual device name:($(_list_avds))' \ + '-skindir[search skins in (default /skins)]: :_files -/' \ + '-skin[select a given skin]' \ + '(-noskin -no-skin)'{-noskin,-no-skin}'[don'\''t use any emulator skin]' \ + '-memory[physical RAM size in MBs]:size (in MBs)' \ + '-cores[Set number of CPU cores to emulator]:number' \ + '(-no-accel)-accel[Configure emulation acceleration]:mode' \ + '(-accel)-no-accel[Same as '\''-accel off'\'']' \ + '-netspeed[maximum network download/upload speeds]:speed' \ + '-netdelay[network latency emulation]:delay' \ + '-netfast[disable network shaping]' \ + '-trace[enable code profiling (F9 to start)]:trace name' \ + '-show-kernel[display kernel messages]' \ + '-shell[enable root shell on current terminal]' \ + {-no-jni,-nojni}'[disable JNI checks in the Dalvik runtime]' \ + '-logcat[enable logcat output with given tags]:logcat tags' \ + '(-audio -noaudio -no-audio)'{-noaudio,-no-audio}'[disable audio support]' \ + '(-noaudio -no-audio)-audio[use specific audio backend]:audio backend' \ + '-raw-keys[disable Unicode keyboard reverse-mapping]' \ + '-radio[redirect radio modem interface to character device]:device' \ + '-port[TCP port that will be used for the console]:port number' \ + '-ports[TCP ports used for the console and adb bridge]:console port,adb port' \ + '-onion[use overlay PNG image over screen]: :_files -g "*.(png|PNG)"' \ + '-onion-alpha[specify onion-skin translucency]:percentage' \ + '-onion-rotation[specify onion-skin rotation]:rotation:((1 2 3 4))' \ + '-scale[scale emulator window]:scale' \ + '-dpi-device[specify device'\''s resolution in dpi (default 165)]:dpi' \ + '-http-proxy[make TCP connections through a HTTP/HTTPS proxy]:proxy' \ + '-timezone[use this timezone instead of the host'\''s default]:timezone' \ + '-dns-server[use this DNS server(s) in the emulated system]:DNS servers' \ + '-cpu-delay[throttle CPU emulation]:CPU delay' \ + '-no-boot-anim[disable animation for faster boot]' \ + '-no-window[disable graphical window display]' \ + '-report-console[report console port to remote socket]: :_socket' \ + '-gps[redirect NMEA GPS to character device]:device' \ + '-keyset[specify keyset file name]: :_files' \ + '-shell-serial[specific character device for root shell]:device' \ + '-tcpdump[capture network packets to file]: :_files' \ + '-bootchart[enable bootcharting]:timeout' \ + '-charmap[use specific key character map]: :_files' \ + '*-prop[set system property on boot]:name=value' \ + '-shared-net-id[join the shared network, using IP address 10.1.2.]:number' \ + '-nand-limits[enforce NAND/Flash read/write thresholds]:limits' \ + '-memcheck[enable memory access checking]:flags' \ + '-qemu[pass arguments to qemu]:arguments' \ + '-verbose[same as '\''-debug-init'\'']' \ + '*'{-debug,-debug-,-debug-no-}'[enable/disable specific debug messages]:tag' \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + +case $state in + cmds) + local -a _avds=($(_list_avds)) + for ((i=1; i<=${#_avds[@]}; i++)); do + _avds[i]="@${_avds[i]}" + done + _values 'avds' "${_avds[@]}" + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_envdir b/home/.zsh-server/plugins/zsh-completions/src/_envdir new file mode 100644 index 0000000..6437993 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_envdir @@ -0,0 +1,49 @@ +#compdef envdir +# ------------------------------------------------------------------------------ +# Copyright (c) 2016, Github zsh-users (https://github.com/zsh-users) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for envdir (https://github.com/jezdez/envdir). +# It completes its few options and then a directory and command. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Daniel Hahler +# +# ------------------------------------------------------------------------------ + +args=( + '(-h --help)'{-h+,--help}'[show this help message and exit]' + '(-)'--version'[display version information and exit]' + '(-)1:directory: _path_files -/' + '(-)2:command: _command_names -e' + '*::arguments: _precommand' +) +_arguments -S $args diff --git a/home/.zsh-server/plugins/zsh-completions/src/_exportfs b/home/.zsh-server/plugins/zsh-completions/src/_exportfs new file mode 100644 index 0000000..4a6cdb6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_exportfs @@ -0,0 +1,51 @@ +#compdef exportfs +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for nfs's exportfs - maintain table of exported NFS file systems. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Timofey Titovets +# +# ------------------------------------------------------------------------------ +_exportfs() { + _values -w 'option' \ + '(-i)-a[Export or unexport all directories]' \ + '(-a -r -u)-i[Ignore the /etc/exports file and files under /etc/exports.d directory]' \ + '(-i)-r[Reexport all directories]' \ + '(-i)-u[Unexport one or more directories]' \ + '-f[Flush everything out of export table]' \ + '-o[option1,option2.. Specify a list of export options]' \ + '-s[Display the current export list suitable for /etc/exports]' \ + '-v[Be verbose]' +} +_exportfs "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_fab b/home/.zsh-server/plugins/zsh-completions/src/_fab new file mode 100644 index 0000000..ba60bb6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_fab @@ -0,0 +1,109 @@ +#compdef fab +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Fabric (http://fabfile.org) +# +# Source: https://github.com/vhbit/fabric-zsh-autocomplete +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Valerii Hiora (https://github.com/vhbit) +# +# ------------------------------------------------------------------------------ + + +local curcontext=$curcontext state line +declare -A opt_args + +declare target_list +target_list=(`fab --shortlist 2>/dev/null`) + +_targets() { + _describe -t commands "fabric targets" target_list +} + +output_levels=( + 'status: Status messages, i.e. noting when Fabric is done running, if the user used a keyboard interrupt, or when servers are disconnected from. These messages are almost always relevant and rarely verbose.' + 'aborts: Abort messages. Like status messages, these should really only be turned off when using Fabric as a library, and possibly not even then. Note that even if this output group is turned off, aborts will still occur – there just won’t be any output about why Fabric aborted!' + 'warnings: Warning messages. These are often turned off when one expects a given operation to fail, such as when using grep to test existence of text in a file. If paired with setting env.warn_only to True, this can result in fully silent warnings when remote programs fail. As with aborts, this setting does not control actual warning behavior, only whether warning messages are printed or hidden.' + 'running: Printouts of commands being executed or files transferred, e.g. [myserver] run: ls /var/www. Also controls printing of tasks being run, e.g. [myserver] Executing task ''foo''.' + 'stdout: Local, or remote, stdout, i.e. non-error output from commands.' + 'stderr: Local, or remote, stderr, i.e. error-related output from commands.' + 'user: User-generated output, i.e. local output printed by fabfile code via use of the fastprint or puts functions.' +) + +_arguments -w -S -C \ + '(-)'{-h,--help}'[show this help message and exit]: :->noargs' \ + '(-)'{-V,--version}'[show program'\''s version number and exit]: :->noargs' \ + '(-)--list[print list of possible commands and exit]: :->noargs' \ + '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \ + '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \ + '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \ + "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \ + '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \ + '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \ + '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \ + '(-p+ --password=-)'{-p+,--password=-}'[password for use with authentication and/or sudo]: :' \ + '(-H+ --hosts=-)'{-H+,--hosts=-}'[comma separated list of hosts to operate on]: :' \ + '(-R+ --roles=-)'{-R+,--roles=-}'[comma separated list of roles to operate on]: :' \ + '(-a --no-agent)'{-a,--no-agent}'[don'\''t use the running SSH agent]' \ + '(-k --no-keys)'{-k,--no-keys}'[don'\''t load private key files from ~/.ssh/]' \ + '(-w --warn-only)'{-w,--warn-only}'[warn instead of abort, when commands fail]' \ + '-i+[path to SSH private key file. May be repeated]: :_files' \ + "(-f+ --fabfile=)"{-f+,--fabfile=}"[Python module file to import]: :_files -g *.py" \ + '(-c+ --config=-)'{-c+,--config=-}'[specify location of config file to use]: :_files' \ + '(-s+ --shell=-)'{-s+,--shell=-}'[specify a new shell, defaults to ''/bin/bash -l -c'']: :' \ + '(--ssh-config-path=)--ssh-config-path=[ssh config path]: :_files' \ + '(--hide=-)--hide=-[comma-separated list of output levels to hide]: :->levels' \ + '(--show=-)--show=-[comma-separated list of output levels to show]: :->levels' \ + '*::: :->subcmds' && return 0 + +if [[ CURRENT -ge 1 ]]; then + case $state in + noargs) + _message "nothing to complete";; + levels) + _describe -t commands "output levels" output_levels;; + *) + _targets;; + esac + + return +fi + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_fail2ban-client b/home/.zsh-server/plugins/zsh-completions/src/_fail2ban-client new file mode 100644 index 0000000..1cebd19 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_fail2ban-client @@ -0,0 +1,339 @@ +#compdef fail2ban-client +# ------------------------------------------------------------------------------ +# Copyright (c) 2020 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for fail2ban-client (https://www.fail2ban.org/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Felix Neumärker +# +# ------------------------------------------------------------------------------ + +_f2bc_jails() { + LANG=C fail2ban-client status 2> /dev/null | sed -n -e 's/.*Jail list:\s\+//' -e 'T' -e 's/,\s\+/\'$'\n/g' -e 'p' +} + +_complete_f2bc_cmds() { + local cmds=( + 'unban:unbans all IP addresses' + 'set:set property' + 'get:get property' + 'status:gets the current status of the server' + 'reload:reloads the configuration/jails' + 'restart:restarts the server' + 'start:starts the server and the jails' + 'stop:stops all jails and terminate the server' + 'ping:tests if the server is alive' + 'flushlogs:flushes the logtarget if a file and reopens it' + 'help:return this output' + 'version:return the server version' + ) + + _describe -V "fail2ban commands" cmds +} + +_complete_f2bc_cmdargs() { + local f2barg="$words[$NORMARG]" + case "$f2barg" in + unban) + local jail + if (( $words[(I)(--all)] == 0 )) ; then + for jail in $(_f2bc_jails) ; do + _complete_f2bc_ips $jail + done + local unban_opts=(--all) + _describe -o "unban options" unban_opts + else + _nothing + fi + ;; + (set|get)) + if (( $NORMARG + 1 == $CURRENT )) ; then + _complete_f2bc_jails + _complete_f2bc_settings + else + _complete_f2bc_jail${f2barg} + fi + ;; + status) + if (( $NORMARG + 1 == $CURRENT )) ; then + _complete_f2bc_jails + elif (( $NORMARG + 2 == $CURRENT )) ; then + _values "flavor" basic cymru + else + _nothing + fi + ;; + esac +} + +_complete_f2bc_jails() { + local jails=($(_f2bc_jails)) + _describe -V "jails" jails +} + +_complete_f2bc_ips() { + local ips=("${(@f)$(LANG=C fail2ban-client status $1 2> /dev/null | sed -n -e 's/^.*Banned IP list:\s\+//' -e 'T' -e 's/\s\+/\'$'\n/g' -e 'p')}") + if [[ -n "${ips[@]}" ]] ; then + _describe -t "f2b_jail_$1" -V "banned ips of jail $1" ips + else + _nothing + fi +} + +_complete_f2bc_jailset() { + if (( $NORMARG + 2 == $CURRENT )) ; then + case $words[$NORMARG+1] in + loglevel) + local loglevel=(CRITICAL ERROR WARNING NOTICE INFO DEBUG TRACEDEBUG HEAVYDEBUG) + _describe -V "loglevel" loglevel ;; + logtarget) + local logtarget=(STDOUT STDERR SYSLOG) + _describe -V "logtarget" logtarget + _files ;; + syslogsocket) + local syslogsocket=(auto) + _describe -V "logtarget" syslogsocket + _files ;; + dbfile) + _files ;; + dbpurgeage) + _message "sets the max age in that history of bans will be kept" ;; + *) + # jail + local jailsettings=( + unbanip + banip + action + addaction + addfailregex + addignoreip + addignoreregex + addjournalmatch + addlogpath + bantime + datepattern + delaction + delfailregex + delignoreip + delignorerexgex + deljournalmatch + dellogpath + findtime + idle + ignorecache + ignorecommand + ignoreself + logencoding + maxlines + maxretry + usedns + ) + _describe -t "f2b_jail_setting" -V "jail setting" jailsettings ;; + esac + else + local jail="$words[$NORMARG+1]" + + if (( $NORMARG + 3 == $CURRENT )) ; then + case $words[$NORMARG+2] in + unbanip) + _complete_f2bc_ips "$jail" ;; + delfailregex) + _complete_f2bc_regex fail "$jail" ;; + delignorerexgex) + _complete_f2bc_regex ignore "$jail" ;; + dellogpath) + local filelist=("${(@f)$(LANG=C fail2ban-client status $jail 2> /dev/null | sed -n -e 's/^.*File list:\s\+//' -e 'T' -e 's/\s\+/\'$'\n/g' -e 'p')}") + + if [[ -n "${filelist[@]}" ]] ; then + _describe -t "f2b_filelist" -V "filelist of jail $1" filelist + else + _nothing + fi ;; + idle) + _values 'fail2ban idle' on off ;; + ignoreself) + _values 'fail2ban ignoreself' true false ;; + delignoreip) + local ignoreips=("${(@f)$(fail2ban-client get "$jail" ignoreip 2> /dev/null | sed -e 's/^[|`]-\s\+//p')}") + if [[ -n "${ignoreips[@]}" ]] ; then + _describe -t "f2b_ignoreip" -V "fail2ban ignored ips" ignoreips + else + _nothing + fi ;; + delaction|action) + _complete_f2bc_action "$jail" ;; + addlogpath) + _files ;; + *) + _message "No completion for ${words[NORMARG+2]}" ;; + esac + elif (( $NORMARG + 4 == $CURRENT )) ; then + case $words[$NORMARG+2] in + action) + _complete_f2bc_actionproperties "$jail" $words[$NORMARG+3] ;; + addaction) + _files ;; + *) + _nothing ;; + esac + else + _nothing + fi + fi +} + +_complete_f2bc_jailget() { + if (( $NORMARG + 2 == $CURRENT )) ; then + case $words[$NORMARG+1] in + (loglevel|logtarget|syslogsocket|dbfile|dbpurgeage)) + _nothing ;; + *) + # jail + local jailprops=( + logpath + logencoding + journalmatch + ignoreself + ignoreip + ignorecommand + failregex + ignoreregex + findtime + bantime + datepattern + usedns + maxretry + maxlines + actions + action + actionproperties + actionmethods + ) + _describe -t "f2b_jail_props" -V "jail properties" jailprops ;; + esac + else + local jail="$words[$NORMARG+1]" + + if (( $NORMARG + 3 == $CURRENT )) ; then + case $words[$NORMARG+2] in + (action|actionproperties|actionmethods)) + _complete_f2bc_action "$jail" ;; + *) + _nothing ;; + esac + elif (( $NORMARG + 4 == $CURRENT )) ; then + case $words[$NORMARG+2] in + (action|actionproperties|actionmethods)) + _complete_f2bc_actionproperties "$jail" $words[$NORMARG+3] ;; + *) + _nothing ;; + esac + else + _nothing + fi + fi +} + +_complete_f2bc_action() { + local jailactions=("${(@f)$(fail2ban-client get $1 actions 2>/dev/null | sed -e '1d' -e 's/,\s\+/\'$'\n/g')}") + + if [[ -n "${jailactions[@]}" ]] ; then + _describe -t "f2b_jail_actions" -V "jail actions" jailactions + else + _nothing + fi +} + +_complete_f2bc_actionproperties() { + local default_actionproperties=( + actionstart + actionstop + actioncheck + actionban + actionunban + timeout + ) + local all_actionproperties=("${(@f)$(fail2ban-client get $1 actionproperties $2 2>/dev/null | sed -e '1d' -e 's/,\s\+/\'$'\n/g')}") + local add_actionproperties=("${(@)all_actionproperties:|default_actionproperties}") + + _describe -t "f2b_actions_defprops" -V "default action properties" default_actionproperties + + if [[ -n "${add_actionproperties[@]}" ]] ; then + _describe -t "f2b_actions_remprops" -V "additional action properties" add_actionproperties + else + _nothing + fi +} + +_complete_f2bc_regex() { + local regex=("${(@f)$(fail2ban-client get $2 ${1}regex 2> /dev/null | sed -n -e 's/[|`]- \[\([0-9]\+\)\]:\s\+/\1:/p')}") + if [[ -n "${regex[@]}" ]] ; then + _describe -t "f2b_regex" -V "jail $2 ${1}regex" regex + else + _nothing + fi +} + +_complete_f2bc_settings() { + local setargs=(loglevel logtarget syslogsocket dbfile dbpurgeage) + _describe -t "f2b_settings" -V "fail2ban-client settings" setargs +} + +integer NORMARG + +_arguments -A "-*" -n \ + '-c[configuration directory]:_files -/' \ + '-s[socket path]:_files' \ + '-p[pidfile path]:_files' \ + '--loglevel[logging level]:(CRITICAL ERROR WARNING, NOTICE INFO, DEBUG, TRACEDEBUG HEAVYDEBUG)' \ + '--logtarget[logging target]:(stdout stderr syslog sysout)' \ + '--syslogsocket:_files' \ + '-d[dump configuration]' \ + '(--dp --dump-pretty)'{--dp,--dump-pretty}'[dump the configuration using more human readable representation]' \ + '(-t --test)'{-t,--test}'[test configuration]' \ + '-i[interactive mode]' \ + '-v[increase verbosity]' \ + '-q[decrease verbosity]' \ + '-x[force execution of the server (remove socket file)]' \ + '-b[start server in background]' \ + '-f[start server in foreground]' \ + '--str2sec[convert time abbreviation format to seconds]:_message str2sec' \ + '(-h --help)'{-h,--help}'[display this help message]' \ + '(-V --version)'{-V,--version}'[print the version]' \ + '1:fail2ban command:_complete_f2bc_cmds' \ + '*:fail2ban command argument:_complete_f2bc_cmdargs' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: set et sw=2 ts=2 ft=zsh: diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ffind b/home/.zsh-server/plugins/zsh-completions/src/_ffind new file mode 100644 index 0000000..92cb30b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ffind @@ -0,0 +1,62 @@ +#compdef ffind +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ffind (https://github.com/jaimebuelta/ffind). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sergei Eremenko (https://github.com/SmartFinn) +# +# ------------------------------------------------------------------------------ + +_arguments -C \ + '(-h --help)'{-h,--help}'[show help message and exit]' \ + '--version[show version number and exit]' \ + '-p[match whole path, not only name of files]' \ + '--nocolor[do not display color]' \ + '--nosymlinks[do not follow symlinks]' \ + '--hidden[do not ignore hidden directories]' \ + '-c[force case sensitive]' \ + '-i[force case insensitive]' \ + '--delete[delete files found]' \ + '--exec[execute the given command with the file found]:command:_command_names' \ + '--module[execute the given module with the file found]:module_name args:' \ + '--command[execute the given python program with the file found]:program:_files' \ + '--ignore-vcs[ignore version control system files and directories]' \ + '-f[experimental fuzzy search]' \ + '--return-results[for testing purposes only]' \ + '1:directory to search:_path_files -/' \ + '*:filepattern:' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_fleetctl b/home/.zsh-server/plugins/zsh-completions/src/_fleetctl new file mode 100644 index 0000000..a754e3c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_fleetctl @@ -0,0 +1,123 @@ +#compdef fleetctl +# ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for fleetctl (https://github.com/coreos/fleet). +# +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Remi Paulmier (https://github.com/shtouff) +# +# ------------------------------------------------------------------------------ + +# fleetctl zsh completion + +local -a _1st_arguments +_1st_arguments=( + 'cat:Output the contents of a submitted unit' + 'destroy:Destroy one or more units in the cluster' + 'fd-forward:Proxy stdin and stdout to a unix domain socket' + 'help:Show a list of commands or help for one command' + 'journal:Print the journal of a unit in the cluster to stdout' + 'list-machines:Enumerate the current hosts in the cluster' + 'list-unit-files:List the units that exist in the cluster.' + 'list-units:List the current state of units in the cluster' + 'load:Schedule one or more units in the cluster, first submitting them if necessary.' + 'ssh:Open interactive shell on a machine in the cluster' + 'start:Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary.' + 'status:Output the status of one or more units in the cluster' + 'stop:Instruct systemd to stop one or more units in the cluster.' + 'submit:Upload one or more units to the cluster without starting them' + 'unload:Unschedule one or more units in the cluster.' + 'version:Print the version and exit' +) + +__task_list () +{ + local expl + declare -a tasks + + tasks=(cat destroy fd-forward help journal list-machines list-unit-files \ + list-units load ssh start status stop submit unload version) + + _wanted tasks expl 'help' compadd $tasks +} + +__unit_list () +{ + _wanted application expl 'command' compadd $(command fleetctl list-units | \ + tail -n +2 | awk '{print $1}') +} + +local expl + +local curcontext="$curcontext" state line +local -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "gem subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _arguments ':feature:__task_list' + ;; + + (destroy|journal|start|status|stop|unload|cat) + _arguments '*:feature:__unit_list' + ;; + + (load|submit) + _arguments '*:file:_files -g *.service' + ;; + + (ssh) + _arguments '*:host:_hosts' + ;; + + (*) + _arguments '*:file:_files' + ;; + esac + ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_flutter b/home/.zsh-server/plugins/zsh-completions/src/_flutter new file mode 100644 index 0000000..7305a5a --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_flutter @@ -0,0 +1,633 @@ +#compdef flutter +# ------------------------------------------------------------------------------ +# MIT License +# +# Copyright (c) 2018 Nickolay Simonov +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for the Flutter.io sdk's cli tool 3.3.8 (https://flutter.dev) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Nikolai Simonov (https://github.com/NiKoTron) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ +_flutter() { + typeset -A opt_args + local context state line + + local curcontext="$curcontext" + + local ret=1 + + _arguments -C -A "-*" \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-v --verbose)'{-v,--verbose}'[Noisy logging, including all shell commands executed]' \ + '--prefixed-errors[Causes lines sent to stderr to be prefixed with "ERROR:"]' \ + '--quiet[Reduce the amount of output from some commands]' \ + '(--no-wrap --wrap)--wrap[Whether to use output word wrapping]' \ + '(--wrap --no-wrap)--no-wrap[Whether to use output word wrapping]' \ + '--wrap-column=[Set the output wrap column]:number:' \ + '(-d --device-id)'{-d,--device-id}'[Target device id or name (prefixes allowed)]' \ + '--version[Reports the version of this tool]' \ + '--machine[When used with the "--version" flag, outputs the information using JSON]' \ + '(--no-color --color)--color[Whether to use terminal colors]' \ + '(--color --no-color)--no-color[Whether to use terminal colors]' \ + '(--no-version-check --version-check)--version-check[Allow Flutter to check for updates when this command runs]' \ + '(--version-check --no-version-check)--no-version-check[Not allow Flutter to check for updates when this command runs]' \ + '--suppress-analytics[Suppress analytics reporting when this command runs]' \ + '--packages[Path to your ".packages" file. (required, since the current directory does not contain a ".packages" file)]' \ + '--local-engine-src-path=[Path to your engine src directory]: :_path_files -/' \ + '--local-engine=[Name of a build output within the engine out directory]' \ + '--show-test-device=[List the special "flutter-tester" device in device listings]' \ + '--show-web-server-device=[List the special "web-server" device in device listings]' \ + '1: :_flutter_root_commands' \ + '*::arg:->args' \ + && ret=0 + + case "$state" in + (args) + case $words[1] in + (help) + _arguments \ + '1: :_flutter_root_commands' \ + && ret=0 + ;; + (analyze) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--current-package[Include the lib/main.dart file from the current directory, if any. (defaults to on)]' \ + '--no-current-package[Include the lib/main.dart file from the current directory, if any. (defaults to on)]' \ + '--watch[Run analysis continuously, watching the filesystem for changes]' \ + '--write=[Also output the results to a file]: :_files ' \ + '--pub[Whether to run "flutter packages get" before executing this command. (defaults to on)]' \ + '--no-pub[Whether to run "flutter packages get" before executing this command. (defaults to on)]' \ + '--congratulate[When analyzing, show output even when there are no errors/warnings/hints/lints (defaults to on)]' \ + '--no-congratulate[When analyzing, show output even when there are no errors/warnings/hints/lints(defaults to on)]' \ + '--preamble[When analyzing, display the number of files that will be analyzed. (defaults to on)]' \ + '--no-preamble[When analyzing, display the number of files that will be analyzed. (defaults to on)]' \ + '(--no-fatal-infos --fatal-infos)--fatal-infos[Treat info level issues as fatal]' \ + '(--no-fatal-infos --fatal-infos)--no-fatal-infos[Not treat info level issues as fatal]' \ + '(--no-fatal-warnings --fatal-warnings)--fatal-warnings[Treat warning level issues as fatal]' \ + '(--no-fatal-warnings --fatal-warnings)--no-fatal-warnings[Not treat warning level issues as fatal]' \ + && ret=0 + ;; + (assemble) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + {-d,--define=}'[Allows passing configuration to a target]: :' \ + '--performance-measurement-file[Output individual target performance to a JSON file]' \ + {-i,--input=}'[Allows passing additional input]: :' \ + '--depfile=[A file path where a depfile will be written]: :_path_files' \ + '--build-inputs=[A file path where a newline-separated file containing all inputs used will be written after a build]: :_path_files' \ + '(-o --output)'{-o,--output=}'[A directory where output files will be written]: :_path_files -/' \ + '*--dart-define=[Additional key-value pairs that will be available as constants]:' \ + '--resource-pool-size=[The maximum number of concurrent tasks the build system will run]:number:' \ + && ret=0 + ;; + (attach) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--debug[Build a debug version of your app (default mode)]' \ + '--profile[Build a version of your app specialized for performance profiling]' \ + '(-t --target)'{-t,--target=}'[The main entry-point file of the application, as run on the device.(defaults to "lib/main.dart")]::_files -g "*.dart"' \ + '--device-vmservice-port=[Look for vmservice connections only from the specified port]:port:' \ + '--host-vmservice-port=[When a device-side vmservice port is forwarded to a host-side port]:port:' \ + '*--dart-define=[Additional key-value pairs that will be available as constants]: :' \ + '--device-user=[Identifier number for a user or work profile on Android only]:id:' \ + '--null-assertions[Perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--no-null-assertions[Not perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--debug-url=[The URL at which the observatory is listening]:url:' \ + '--app-id=[The package name (Android) or bundle identifier (iOS) for the app]:app_id:' \ + '--pid-file=[Specify a file to write the process id to]::_files' \ + '--track-widget-creation[Track widget creation locations. (defaults to on)]' \ + '--no-track-widget-creation[Not rack widget creation locations. (defaults to on)]' \ + '--dds-port=[When this value is provided, the Dart Development Service (DDS) will be bound to the provided port]:port:' \ + '--device-timeout=[Time in seconds to wait for devices to attach]:seconds:' \ + && ret=0 + ;; + (bash-completion) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(--no-overwrite --overwrite)--overwrite[Overwritten completion setup if it already exists]' \ + '(--overwrite --no-overwrite)--no-overwrite[Not overwritten completion setup if it already exists]' \ + && ret=0 + ;; + (build) + _arguments \ + '1: :_flutter_build_entities' \ + '(- *)'{-h,--help}'[Print this usage information]' \ + && ret=0 + ;; + (config) + _arguments \ + '(-h --help)'{-h,--help}'[Print this usage information]' \ + '--analytics[Enable or disable reporting anonymously tool usage statistics and crash reports]' \ + '--no-analytics[Enable or disable reporting anonymously tool usage statistics and crash reports]' \ + '--clear-ios-signing-cert[Clear the saved development certificate choice used to sign apps for iOS device deployment]' \ + '--android-sdk=[The Android SDK directory]: :_path_files -/' \ + '--android-studio-dir=[The Android Studio install directory]: :_path_files -/' \ + '--build-dir=[The relative path to override a projects build directory]: :_path_files -/' \ + '(--no-enable-web --enable-web)--enable-web[Enable Flutter for web]' \ + '(--no-enable-web --enable-web)--no-enable-web[Disable Flutter for web]' \ + '(--no-enable-linux-desktop --enable-linux-desktop)--enable-linux-desktop[Enable support for desktop on Linux]' \ + '(--no-enable-linux-desktop --enable-linux-desktop)--no-enable-linux-desktop[Disable support for desktop on Linux]' \ + '(--no-enable-macos-desktop --enable-macos-desktop)--enable-macos-desktop[Enable support for desktop on macOS]' \ + '(--no-enable-macos-desktop --enable-macos-desktop)--no-enable-macos-desktop[Disable support for desktop on macOS]' \ + '(--no-enable-windows-desktop --enable-windows-desktop)--enable-windows-desktop[Enable support for desktop on Windows]' \ + '(--no-enable-windows-desktop --enable-windows-desktop)--no-enable-windows-desktop[Disable support for desktop on Windows]' \ + '(--no-enable-windows-uwp-desktop --enable-windows-uwp-desktop)--enable-windows-uwp-desktop[Enable support for desktop on Windows UWP]' \ + '(--no-enable-windows-uwp-desktop --enable-windows-uwp-desktop)--no-enable-windows-uwp-desktop[Disable support for desktop on Windows UWP]' \ + '(--no-single-widget-reload-optimization --single-widget-reload-optimization)--single-widget-reload-optimization[Enable Hot reload optimization for a single widget]' \ + '(--no-single-widget-reload-optimization --single-widget-reload-optimization)--no-single-widget-reload-optimization[Disable Hot reload optimization for a single widget]' \ + '(--no-enable-android --enable-android)--enable-android[Enable Flutter for Android]' \ + '(--no-enable-android --enable-android)--no-enable-android[Disable Flutter for Android]' \ + '(--no-enable-ios --enable-ios)--enable-ios[Enable Flutter for iOS]' \ + '(--no-enable-ios --enable-ios)--no-enable-ios[Disable Flutter for iOS]' \ + '(--no-enable-fuchsia --enable-fuchsia)--enable-fuchsia[Enable Flutter for Fuchsia]' \ + '(--no-enable-fuchsia --enable-fuchsia)--no-enable-fuchsia[Disable Flutter for Fuchsia]' \ + '(--no-enable-custom-devices --enable-custom-devices)--enable-custom-devices[Enable Early support for custom device types]' \ + '(--no-enable-custom-devices --enable-custom-devices)--no-custom-devices[Disable Early support for custom device types]' \ + '--clear-features[Remove all configured features and restore them to the default values]' \ + && ret=0 + ;; + + (create) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--pub[Whether to run "flutter packages get" after the project has been created. (defaults to on)]' \ + '--no-pub[Whether to run "flutter packages get" after the project has been created. (defaults to on)]' \ + '--offline[Offline mode when "flutter packages get" is run]' \ + '--no-offline[Offline mode when "flutter packages get" is run]' \ + '--overwrite[When performing operations, overwrite existing files]' \ + '--no-overwrite[When performing operations, not overwrite existing files]' \ + "--description=[The description to use for your new Flutter project. (defaults to 'A new Flutter project.')]::" \ + "--org=[The organization responsible for new Flutter project, in reverse domain name notation.(defaults to 'com.example')]::" \ + '--project-name=[The project name for this new Flutter project]:name:' \ + '(-i --ios-language)'{-i,--ios-language=}'[iOS project language]: :_flutter_ios_languages' \ + '(-a --android-language)'{-a,--android-language=}'[Android project language]: :_flutter_android_languages' \ + '--platforms[The platforms supported by this project]' \ + '(-t --template=)'{-t,--template=}'[Specify the type of project to create]: :_flutter_project_templates' \ + '(-s --sample=)'{-s,--sample=}'[Specifies the Flutter code sample to use as the "main.dart" for an application]:id:' \ + '--list-samples=[Specifies a JSON output file for a listing of Flutter code samples that can be created with "--sample"]::_path_files' \ + && ret=0 + ;; + (custom-devices) + _arguments \ + '1: :_flutter_custom_devices_subcommands' \ + '(- *)'{-h,--help}'[Print this usage information]' \ + && ret=0 + ;; + (daemon) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--listen-on-tcp-port=[If specified, the daemon will be listening for commands on the specified port instead of stdio]:port:' \ + && ret=0 + ;; + (debug-adapter) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--dds-port=[When this value is provided, the Dart Development Service (DDS) will be bound to the provided port]:port:' \ + '(--no-test --test)--test[use the "flutter test" debug adapter to run tests]' \ + '(--no-test --test)--no-test[not use the "flutter test" debug adapter to run tests]' \ + && ret=0 + ;; + (devices) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--machine[Output device information in machine readable structured JSON format]' \ + "--device-timeout=[Time in seconds to wait for devices to attach]:seconds:" \ + && ret=0 + ;; + (doctor) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + "--android-licenses[Run the Android SDK manager tool to accept the SDK's licenses]" \ + && ret=0 + ;; + (drive) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--debug[Build a debug version of your app (default mode)]' \ + '--profile[Build a version of your app specialized for performance profiling]' \ + '--release[Build a release version of your app]' \ + '*--dart-define=[Additional key-value pairs that will be available as constants]: :' \ + '--flavor[Build a custom app flavor as defined by platform-specific build setup]' \ + '--web-renderer[The renderer implementation to use when building for the web]: :(auto canvaskit html)' \ + '--trace-startup[Start tracing during startup]' \ + '(--cache-startup-profile --no-cache-startup-profile)--cache-startup-profile[Caches the CPU profile collected before the first frame for startup analysis]' \ + '(--cache-startup-profile --no-cache-startup-profile)--no-cache-startup-profile[Not caches the CPU profile collected before the first frame for startup analysis]' \ + '--verbose-system-logs[Include verbose logging from the Flutter engine]' \ + '--cache-sksl[Cache the shader in the SkSL format instead of in binary or GLSL formats]' \ + '--dump-skp-on-shader-compilation[Cache the shader in the SkSL format instead of in binary or GLSL formats]' \ + '--purge-persistent-cache[Removes all existing persistent caches]' \ + '--route[Which route to load when running the app]' \ + '--use-application-binary=[Specify a pre-built application binary to use when running]::_files -g "*.apk"' \ + '(--no-start-paused --start-paused)--start-paused[Start in a paused mode and wait for a debugger to connect]' \ + '(--no-start-paused --start-paused)--no-start-paused[Not tart in a paused mode and wait for a debugger to connect]' \ + '--endless-trace-buffer[Enable tracing to an infinite buffer, instead of a ring buffer]' \ + '--trace-systrace[Enable tracing to the system tracer]' \ + '--trace-skia[Enable tracing of Skia code]' \ + *{-a,--dart-entrypoint-args=}'[Pass a list of arguments to the Dart entrypoint at application startup]: :' \ + '--web-launch-url=[The URL to provide to the browser]: :' \ + '(-t --target=)'{-t,--target=}'[The main entry-point file of the application, as run on the device.(defaults to "lib/main.dart")]: :_files -g "*.dart"' \ + '--device-vmservice-port=[Look for vmservice connections only from the specified port]:port:' \ + '--host-vmservice-port=[When a device-side vmservice port is forwarded to a host-side port]:port:' \ + '--pub[Whether to run "flutter packages get" before executing this command. (defaults to on)]' \ + '--no-pub[Whether to run "flutter packages get" before executing this command. (defaults to on)]' \ + '--track-widget-creation[Track widget creation locations. (defaults to on)]' \ + '--no-track-widget-creation[Not rack widget creation locations. (defaults to on)]' \ + '--null-assertions[Perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--no-null-assertions[Not perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--device-user=[Identifier number for a user or work profile on Android only]:id:' \ + '--device-timeout=[Time in seconds to wait for devices to attach]:seconds:' \ + '--dds-port=[the Dart Development Service (DDS) will be bound to the provided port]:port:' \ + *{-P,--android-project-arg=}'[Additional arguments specified as key=value that are passed directly to the gradle project]: :' \ + '--multidex[indicates that the app should be built with multidex support(defaults to on)]' \ + '--no-multidex[indicates that the app should not be built with multidex support(defaults to on)]' \ + '--no-keep-app-running[Will not keep the Flutter application running when done testing]' \ + '--keep-app-running[Will keep the Flutter application running when done testing]' \ + '--use-existing-app=[Connect to an already running instance via the given observatory URL]' \ + '--driver=[The test file to run on the host]: :_files' \ + '--build[If necessary, build the app before running. (defaults to on)]' \ + '--no-build[If necessary, not build the app before running]' \ + '--screenshot=[Directory location to write screenshots on test failure]::_path_files -/' \ + '--driver-port=[The port where Webdriver server is launched at(default to "4444")]:port:' \ + '(--no-headless --headless)--headless[Launch driver browser in headless mode(defaults to on)]' \ + '(--no-headless --headless)--no-headless[Not launch driver browser in headless mode]' \ + '--browser-name=[Name of the browser where tests will be executed]: :(android-chrome chrome edge firefox ios-safari safari)' \ + '--browser-dimension=[The dimension of the browser when running a Flutter Web test(defaults to "1600,1024")]: :' \ + '(--no-android-emulator --android-emulator)--android-emulator[Perform Flutter Driver testing using an Android Emulator]' \ + '(--no-android-emulator --android-emulator)--no-android-emulator[Not perform Flutter Driver testing using an Android Emulator]' \ + '--chrome-binary=[Location of the Chrome binary]::_files' \ + '--write-sksl-on-exit[Attempts to write an SkSL file when the drive process is finished to the provided file, overwriting it if necessary]' \ + '*--test-arguments=[Additional arguments to pass to the Dart VM running The test script]: :' \ + '--profile-memory=[Launch devtools and profile application memory, writing the output data as JSON]::_files -g "*.json"' \ + && ret=0 + ;; + (emulators) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--launch[The full or partial ID of the emulator to launch]' \ + '--cold[Used with the "--launch" flag to cold boot the emulator instance (Android only)]' \ + '--create[Creates a new Android emulator based on a Pixel device]' \ + '--name[Used with the "--create" flag. Specifies a name for the emulator being created]' \ + && ret=0 + ;; + (format) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-v --verbose)'{-v,--verbose}'[Show all options and flags with --help]' \ + '(-o --output)'{-o,--output=}'[Set where to write formatted output]: :(json none show write)' \ + '--set-exit-if-changed[Return exit code 1 if there are any formatting changes]' \ + '--fix[Apply all style fixes]' \ + '(-l --line-length)'{-l,--line-length=}'[Wrap lines longer than this(defaults to 80)]:lines:' \ + '*: :_files' \ + && ret=0 + ;; + (gen-l10n) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--arb-dir=[The directory where template arb files are located]::_path_files -/' \ + '--output-dir=[The directory where the generated localization classes will be written]::_path_files -/' \ + '--template-arb-file=[The path of template arb file]::_files' \ + '--output-localization-file=[The filename for the output localization and localizations delegate classes]::_files -g "*.dart"' \ + '--untranslated-messages-file=[The file that describes the localization messages have not been translated yet]::_files' \ + '--output-class=[The Dart class name to use for the output localization and localizations delegate classes]:class:' \ + '--preferred-supported-locales=[The list of preferred supported locales for the application]::' \ + '--header=[The header to prepend to the generated Dart localizations files]:header:' \ + '--header-file=[The header to prepend to the generated Dart localizations files]::_files' \ + '(--no-use-deferred-loading --use-deferred-loading)--use-deferred-loading[Generate the Dart localization file as deferred]' \ + '(--no-use-deferred-loading --use-deferred-loading)--no-use-deferred-loading[Not generate the Dart localization file as deferred]' \ + '--gen-inputs-and-outputs-list=[the tool generates a JSON file containing the tools inputs and outputs]::_path_files -/' \ + '(--no-synthetic-package --synthetic-package)--synthetic-package[Generate files as a synthetic package]' \ + '(--no-synthetic-package --synthetic-package)--no-synthetic-package[Not generate files as a synthetic package]' \ + '--project-dir=[the directory of the root Flutter project]::_path_files -/' \ + '(--no-required-resource-attributes --required-resource-attributes)--required-resource-attributes[Requires all resource ids to contain a corresponding resource attribute]' \ + '(--no-required-resource-attributes --required-resource-attributes)--no-required-resource-attributes[Requires all resource ids to contain a corresponding resource attribute]' \ + '(--no-nullable-getter --nullable-getter)--nullable-getter[The localizations class getter is nullable]' \ + '(--no-nullable-getter --nullable-getter)--no-nullable-getter[The localizations class getter is not nullable]' \ + && ret=0 + ;; + (install) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--device-user=[Identifier number for a user or work profile on Android only]:id:' \ + '--device-timeout=[Time in seconds to wait for devices to attach]:seconds:' \ + '(--no-uninstall-only --uninstall-only)--uninstall-only[Uninstall the app if already on the device. Skip install]' \ + '(--no-uninstall-only --uninstall-only)--no-uninstall-only[Uninstall the app if already on the device. Skip install]' \ + && ret=0 + ;; + (logs) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-c --clear)'{-c,--clear}'[Clear log history before reading from logs]' \ + '--device-timeout=[Time in seconds to wait for devices to attach]:seconds:' \ + && ret=0 + ;; + (precache) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-a --all-platforms)'{-a,--all-platforms}'[Precache artifacts for all platforms]' \ + '(-f --force)'{-f,--force}'[Force re-downloading of artifacts]' \ + '(--no-ios --ios)--ios[Precache artifacts for iOS development]' \ + '(--no-ios --ios)--no-ios[Not precache artifacts for iOS development]' \ + '(--no-web --web)--web[Precache artifacts for web development]' \ + '(--no-web --web)--no-web[Not precache artifacts for web development]' \ + '(--no-linux --linux)--linux[Precache artifacts for Linux desktop development]' \ + '(--no-linux --linux)--no-linux[Not recache artifacts for Linux desktop development]' \ + '(--no-windows --windows)--windows[Precache artifacts for Windows desktop development]' \ + '(--no-windows --windows)--no-windows[Not precache artifacts for Windows desktop development]' \ + '(--no-winuwp --winuwp)--winuwp[Precache artifacts for Windows UWP desktop development]' \ + '(--no-winuwp --winuwp)--no-winuwp[Not recache artifacts for Windows UWP desktop development]' \ + '(--no-macos --macos)--macos[Precache artifacts for macOS desktop development]' \ + '(--no-macos --macos)--no-macos[Not precache artifacts for macOS desktop development]' \ + '(--no-fuchsia --fuchsia)--fuchsia[Precache artifacts for Fuchsia development]' \ + '(--no-fuchsia --fuchsia)--no-fuchsia[Not precache artifacts for Fuchsia development]' \ + '(--no-universal --universal)--universal[Precache artifacts required for any development platform]' \ + '(--no-universal --universal)--no-universal[Not precache artifacts required for any development platform]' \ + && ret=0 + ;; + (pub) + _arguments \ + '1: :_flutter_pub_subcommands' \ + '(- *)'{-h,--help}'[Print this usage information]' \ + && ret=0 + ;; + (run) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--debug[Build a debug version of your app (default mode)]' \ + '--profile[Build a version of your app specialized for performance profiling]' \ + '--release[Build a release version of your app]' \ + '*--dart-define=[Additional key-value pairs that will be available as constants]: :' \ + '--flavor[Build a custom app flavor as defined by platform-specific build setup]' \ + '--web-renderer[The renderer implementation to use when building for the web]: :(auto canvaskit html)' \ + '--trace-startup[Start tracing during startup]' \ + '(--cache-startup-profile --no-cache-startup-profile)--cache-startup-profile[Caches the CPU profile collected before the first frame for startup analysis]' \ + '(--cache-startup-profile --no-cache-startup-profile)--no-cache-startup-profile[Not caches the CPU profile collected before the first frame for startup analysis]' \ + '--verbose-system-logs[Include verbose logging from the Flutter engine]' \ + '--cache-sksl[Cache the shader in the SkSL format instead of in binary or GLSL formats]' \ + '--dump-skp-on-shader-compilation[Cache the shader in the SkSL format instead of in binary or GLSL formats]' \ + '--purge-persistent-cache[Removes all existing persistent caches]' \ + '--route[Which route to load when running the app]' \ + '--use-application-binary=[Specify a pre-built application binary to use when running]::_files -g "*.apk"' \ + '(--no-start-paused --start-paused)--start-paused[Start in a paused mode and wait for a debugger to connect]' \ + '(--no-start-paused --start-paused)--no-start-paused[Not start in a paused mode and wait for a debugger to connect]' \ + '--endless-trace-buffer[Enable tracing to an infinite buffer, instead of a ring buffer]' \ + '--trace-systrace[Enable tracing to the system tracer]' \ + '--trace-skia[Enable tracing of Skia code]' \ + *{-a,--dart-entrypoint-args=}'[Pass a list of arguments to the Dart entrypoint at application startup]: :' \ + '--web-launch-url=[The URL to provide to the browser]: :' \ + '(-t= --target=)'{-t=,--target=}'[The main entry-point file of the application, as run on the device.(defaults to "lib/main.dart")]: :_files -g "*.dart"' \ + '--device-vmservice-port=[Look for vmservice connections only from the specified port]:port:' \ + '--host-vmservice-port=[When a device-side vmservice port is forwarded to a host-side port]:port:' \ + '--pub[Whether to run "flutter packages get" before executing this command. (defaults to on)]' \ + '--no-pub[Whether to run "flutter packages get" before executing this command. (defaults to on)]' \ + '--track-widget-creation[Track widget creation locations. (defaults to on)]' \ + '--no-track-widget-creation[Not rack widget creation locations. (defaults to on)]' \ + '--null-assertions[Perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--no-null-assertions[Not perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--device-user=[Identifier number for a user or work profile on Android only]:id:' \ + '--device-timeout=[Time in seconds to wait for devices to attach]:seconds:' \ + '--dds-port=[When this value is provided, the Dart Development Service (DDS) will be bound to the provided port]:port:' \ + *{-P,--android-project-arg=}'[Additional arguments specified as key=value that are passed directly to the gradle project via the -P flag]: :' \ + '--multidex[indicates that the app should be built with multidex support(defaults to on)]' \ + '--no-multidex[indicates that the app should not be built with multidex support(defaults to on)]' \ + '--ignore-deprecation[Indicates that the app should ignore deprecation warnings and continue to build using deprecated APIs]' \ + '--enable-software-rendering[Enable rendering using the Skia software backend]' \ + '--skia-deterministic-rendering[When combined with --enable-software-rendering, provides 100% deterministic Skia rendering]' \ + '--await-first-frame-when-tracing[Wait for the first frame when tracing startup ("--trace-startup")(defaults to on)]' \ + '--no-await-first-frame-when-trasing[Just dump the trace as soon as the application is running]' \ + '--use-test-fonts[Enable (and default to) the "Ahem" font]' \ + '--no-use-test-fonts[Not enable (and default to) the "Ahem" font]' \ + '--build[If necessary, build the app before running. (defaults to on)]' \ + '--no-build[If necessary, build the app before running. (defaults to on)]' \ + '--hot[Run with support for hot reloading. (defaults to on)]' \ + '--no-hot[Run with support for hot reloading. (defaults to on)]' \ + '--pid-file=[Specify a file to write the process id to]::_files' \ + && ret=0 + ;; + (screenshot) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-o --out)'{-o,--out=}'[Location to write the screenshot]: :_files' \ + '--observatory-url=[The Observatory URL to which to connect]:uri:' \ + '--type=[The type of screenshot to retrieve]: :(device rasterizer skia)' \ + '--device-timeout=[Time in seconds to wait for devices to attach]:seconds:' \ + && ret=0 + ;; + (symbolize) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-d --debug-info)'{-d,--debug-info=}'[A path to the symbols file generated with "--split-debug-info"]: :_files' \ + '(-i --input)'{-i,--input=}'[A file path containing a Dart stack trace]: :_files' \ + '(-o --output)'{-o,--output=}'[A file path for a symbolized stack trace to be written to]: :_files' \ + && ret=0 + ;; + (test) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--pub[Run "flutter packages get" before executing this command(defaults to on)]' \ + '--no-pub[Not to run "flutter packages get" before executing this command]' \ + '--null-assertions[Perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--no-null-assertions[Not perform additional null assertions on the boundaries of migrated and un-migrated code]' \ + '--track-widget-creation[Track widget creation locations]' \ + '--no-track-widget-creation[Not track widget creation locations]' \ + '*--dart-define=[Additional key-value pairs that will be available as constants]: :' \ + '--web-renderer[The renderer implementation to use when building for the web]: :(auto canvaskit html)' \ + '--device-user=[Identifier number for a user or work profile on Android only]:id:' \ + '--flavor[Build a custom app flavor as defined by platform-specific build setup]' \ + '--name=[A regular expression matching substrings of the names of tests to run]' \ + '--plain-name=[A plain-text substring of the names of tests to run]' \ + *{-t,--tags=}'[Run only tests associated with the specified tags]:tag:' \ + *{-x,--exclude-tags=}'[Run only tests that do not have the specified tags]:tag:' \ + '--start-paused[Start in a paused mode and wait for a debugger to connect]' \ + '--run-skipped[Run skipped tests instead of skipping them]' \ + '--no-run-skipped[Not run skipped tests instead of skipping them]' \ + '--coverage[Whether to collect coverage information]' \ + '--merge-coverage[Whether to merge coverage data with "coverage/lcov.base.info" (Requires lcov)]' \ + '--coverage-path=[Where to store coverage information (if coverage is enabled). (defaults to "coverage/lcov.info")]::_files' \ + '--update-goldens[Whether "matchesGoldenFile()" calls within your test methods should update the golden files]' \ + {-j,--concurrency=}'[The number of concurrent test processes to run]:nums:' \ + '--test-assets[Build the assets bundle for testing]' \ + '--no-test-assets[Not build the assets bundle for testing]' \ + '--test-randomize-ordering-seed[The seed to randomize the execution order of test cases within test files]' \ + '--total-shards[Tests can be sharded with the "--total-shards" and "--shard-index" arguments]' \ + '--shard-index[Tests can be sharded with the "--total-shards" and "--shard-index" arguments]' \ + {-r,--reporter=}'[Set how to print test results]: :(compact expanded json)' \ + '--timeout=[The default test timeout, specified either in seconds (e.g. "60s"). Defaults to "30s"]:seconds:' \ + '--dds-port=[the Dart Development Service (DDS) will be bound to the provided port]:port:' \ + && ret=0 + ;; + (upgrade) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-f --force)'{-f,--force}'[Force upgrade the flutter branch, potentially discarding local changes]' \ + '--verify-only[Checks for any new Flutter updates, without actually fetching them]' \ + && ret=0 + ;; + (*) + _arguments \ + '(- *)'{-h,--help}'[Print this usage information]' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + +(( $+functions[_flutter_root_commands] )) || +_flutter_root_commands() { + local -a commands=( + "analyze:Analyze the project's Dart code." + 'assemble:Assemble and build flutter resources.' + 'attach:Attach to a running application.' + 'bash-completion:Output command line shell completion setup scripts.' + 'build:Flutter build commands.' + 'channel:List or switch flutter channels.' + 'clean:Delete the build/ directory.' + 'config:Configure Flutter settings.' + 'create:Create a new Flutter project.' + 'custom-devices:List, reset, add and delete custom devices' + 'daemon:Run a persistent, JSON-RPC based server to communicate with devices.' + 'debug-adapter:Run a Debug Adapter Protocol server to communicate with the Flutter tool' + 'downgrade:Downgrade Flutter to the last active version for the current channel' + 'devices:List all connected devices.' + 'doctor:Show information about the installed tooling.' + 'drive:Runs Flutter Driver tests for the current project.' + 'emulators:List, launch and create emulators.' + 'format:Format one or more dart files.' + 'gen-l10n:Generate localizations for the current project.' + 'help:Display help information for flutter.' + 'install:Install a Flutter app on an attached device.' + 'logs:Show log output for running Flutter apps.' + "precache:Populates the Flutter tool's cache of binary artifacts." + 'pub:Commands for managing Flutter packages.' + 'run:Run your Flutter app on an attached device.' + 'screenshot:Take a screenshot from a connected device.' + 'symbolize:Symbolize a stack trace from an AOT-compiled Flutter app.' + 'test:Run Flutter unit tests for the current project.' + 'upgrade:Upgrade your copy of Flutter.' + ) + _describe -t commands 'command' commands "$@" +} + +(( $+functions[_flutter_build_entities] )) || +_flutter_build_entities() { + local -a entities=( + "aar:Build a repository containing an AAR and a POM file." + "apk:Build an Android APK file from your app." + "appbundle:Build an Android App Bundle file from your app." + "bundle:Build the Flutter assets directory from your app." + "fuchsia:Build the Fuchsia target." + "ios:Build an iOS application bundle (Mac OS X host only)." + "linux:Build a Linux desktop application." + "macos:Build a macOS desktop application." + "windows:Build a Windows desktop application." + "winuwp:Build a Windows UWP desktop application." + ) + _describe -t entities 'entity' entities "$@" +} + +(( $+functions[_flutter_custom_devices_subcommands] )) || +_flutter_custom_devices_subcommands() { + local -a subcmds=( + "add:Add a new device the custom devices config file" + "delete:Delete a device from the config file" + "list:List the currently configured custom devices, both enabled and disabled, reachable or not" + "reset:Reset the config file to the default" + ) + _describe -t subcmds 'subcommands' subcmds "$@" +} + +(( $+functions[_flutter_project_templates] )) || +_flutter_project_templates() { + local -a templates=( + "app:(default) Generate a Flutter application" + "module:Generate a shareable Flutter project containing modular Dart code" + "package:Generate a shareable Flutter project containing modular Dart code" + "plugin:Generate a shareable Flutter project containing an API in Dart code with a platform-specific implementation for Android, for iOS code, or for both" + "plugin_ffi:Generate a shareable Flutter project containing an API in Dart code with a platform-specific implementation through dart:ffi for Android, iOS, Linux, macOS, Windows, or any combination of these" + "skeleton:Generate a List View / Detail View Flutter application that follows community best practices" + ) + _describe -t templates 'template' templates "$@" +} + +(( $+functions[_flutter_ios_languages] )) || +_flutter_ios_languages() { + local -a languages=( + "objc:Objective-C" + "swift:(default) Swift" + ) + _describe -t languages 'language' languages "$@" +} + +(( $+functions[_flutter_android_languages] )) || +_flutter_android_languages() { + local -a languages=( + "java:Java" + "kotlin:(default) Kotlin" + ) + _describe -t languages 'language' languages "$@" +} + +(( $+functions[_flutter_pub_subcommands] )) || +_flutter_pub_subcommands() { + local -a subcommands=( + "add:Add a dependency to pubspec.yaml" + "cache:Work with the Pub system cache" + "deps:Print package dependencies" + "downgrade:Downgrade packages in a Flutter project" + "get:Get packages in a Flutter project" + "global:Work with Pub global packages" + "login:Log into pub.dev" + "logout:Log out of pub.dev" + "outdated:Analyze dependencies to find which ones can be upgraded" + "pub:Pass the remaining arguments to Dart's 'pub' tool" + "publish:Publish the current package to pub.dartlang.org" + "remove:Removes a dependency from the current package" + "run:Run an executable from a package" + "test:Run the 'test' package" + "token:Manage authentication tokens for hosted pub repositories" + "upgrade:Upgrade the current package's dependencies to latest versions" + "uploader:Manage uploaders for a package on pub.dev" + "version:Print Pub version" + ) + _describe -t subcommands 'subcommand' subcommands "$@" +} + +_flutter "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_fvm b/home/.zsh-server/plugins/zsh-completions/src/_fvm new file mode 100644 index 0000000..8053d34 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_fvm @@ -0,0 +1,183 @@ +#compdef fvm +# ------------------------------------------------------------------------------ +# Copyright (c) 2022 Github zsh-users - https://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for fvm. (https://github.com/fluttertools/fvm) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +_fvm_versions() { + local -a versions + versions=($(fvm releases | awk '/[0-9]+\.[0-9]+\.[0-9]+/{ sub(/^[^│]*│ /, ""); print $1}')) + versions=(master beta stable $versions) + _describe 'versions' versions +} + +_fvm_installed_versions() { + local -a versions + versions=($(fvm list | sed -e '1,2d')) + _describe 'installed_versions' versions +} + +_fvm_run_flutter() { + local begin=$(($CURRENT - 1)) + if (( $+functions[_flutter] )); then + compset -n $begin + _flutter "$@" + fi +} + +_fvm() { + typeset -A opt_args + local context state line + local curcontext="$curcontext" + local ret=1 + + _arguments -C -A "-*" \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--verbose[Print verbose output]' \ + '(- *)--version[current version]' \ + '1: :_fvm_subcommands' \ + '*::arg:->args' \ + && ret=0 + + case "$state" in + (args) + case $words[1] in + (help) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '1: :_fvm_subcommands' \ + && ret=0 + ;; + (config) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-c --cache-path)'{-c,--cache-path}'[Set the path which FVM will cache the version.Priority over FVM_HOME]::_path_files -/' \ + '(-s --skip-setup --no-skip-setup)'{-s,--skip-setup}'[Skip setup after a version install]' \ + '(-s --skip-setup --no-skip-setup)--no-skip-setup[No skip setup after a version install]' \ + '(-g --git-cache --no-git-cache)'{-g,--git-cache}'[Will cache a local version of Flutter repo for faster version install]' \ + '(-g --git-cache --no-git-cache)--no-git-cache[Will not cache a local version of Flutter repo for faster version install]' \ + && ret=0 + ;; + (destroy|doctor|flavor|list|releases) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + && ret=0 + ;; + (exec) + _arguments -C \ + '*::args:_normal' \ + && ret=0 + ;; + (flutter) + _arguments -C \ + '1: :_fvm_run_flutter' \ + '*: :_normal' \ + && ret=0 + ;; + (global) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '*::args:_fvm_installed_versions' \ + && ret=0 + ;; + (install) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-s --skip-setup)'{-s,--skip-setup}'[Skips Flutter setup after install]' \ + '1: :_fvm_versions' \ + && ret=0 + ;; + (remove) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '--force[Skips version global check]' \ + '1: :_fvm_installed_versions' \ + && ret=0 + ;; + (spawn) + _arguments -C \ + '1: :_fvm_installed_versions' \ + '2: :_fvm_run_flutter' \ + '*: :_normal' \ + && ret=0 + ;; + (use) + _arguments -C \ + '(- *)'{-h,--help}'[Print this usage information]' \ + '(-f --force)'{-f,--force}'[Skips command guards that does Flutter project checks]' \ + '(-p --pin)'{-p,--pin}'[If version provided is a channel. Will pin the latest release of the channel]' \ + '--flavor[Sets version for a project flavor]' \ + '(-s --skip-setup)'{-s,--skip-setup}'[Skips Flutter setup after install]' \ + '1: :_fvm_installed_versions' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + + +(( $+functions[_fvm_subcommands] )) || +_fvm_subcommands() { + local commands; + commands=( + 'config:Set configuration for FVM' + 'dart:Proxies Dart Commands' + 'destroy:Destroy FVM cache by deleting FVM directory' + 'doctor:Shows information about environment, and project configuration' + 'exec:Executes scripts with the configured Flutter SDK' + 'flavor:Switches between different project flavors' + 'flutter:Proxies Flutter Commands' + 'global:Sets Flutter SDK Version as a global' + 'install:Installs Flutter SDK version' + 'list:Lists installed Flutter SDK Versions' + 'releases:View all Flutter SDK releases available for install' + 'remove:Removes Flutter SDK Version' + 'spawn:Spawns a command on a Flutter version' + 'use:Sets Flutter SDK Version you would like to use in a project' + ) + _describe -t commands 'command' commands "$@" +} + + +_fvm "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_fwupdmgr b/home/.zsh-server/plugins/zsh-completions/src/_fwupdmgr new file mode 100644 index 0000000..5edcbf7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_fwupdmgr @@ -0,0 +1,293 @@ +#compdef fwupdmgr +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for fwupdmgr 1.2.9 (https://github.com/hughsie/fwupd). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_fwupdmgr() { + + local context state state_descr line + typeset -A opt_args + + _arguments -C \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)'{-v,--version}'[display version information]' \ + {-v,--verbose}'[show extra debugging information]' \ + --offline'[schedule installation for next reboot when possible]' \ + --allow-reinstall'[allow re-installing existing firmware versions]' \ + --allow-older'[allow downgrading firmware versions]' \ + --force'[override warnings and force the action]' \ + '(-y, --assume-yes)'{-y,--assume-yes}'[answer yes to all questions]' \ + --sign'[sign the uploaded data with the client certificate]' \ + --no-unreported-check'[do not check for unreported history]' \ + --no-metadata-check'[do not check for old metadata]' \ + --no-reboot-check'[do not check for reboot after update]' \ + --no-history'[do not write to the history database]' \ + --show-all-devices'[show devices that are not updatable]' \ + '(-): :->command' \ + '(-)*:: :->arguments' \ + && ret=0 + + case $state in + (command) + _fwupdmgr_commands + ;; + (arguments) + curcontext=${curcontext%:*:*}:fwupdmgr-$words[1]: + if (( $+functions[_fwupdmgr_${words[1]}_args] )); then + _fwupdmgr_${words[1]}_args + else + _message "unknown command ${words[1]}" && ret=1 + fi + ;; + (*) + _message "unknown state $state" && ret=1 + ;; + esac +} + +(( $+functions[_fwupdmgr_commands] )) || +_fwupdmgr_commands() { + local commands=( + 'activate:activate devices' + 'clear-history:erase all firmware update history' + 'clear-offline:clears any updates scheduled to be updated offline' + 'clear-results:clears the results from the last update' + 'disable-remote:disables a given remote' + 'downgrade:downgrades the firmware on a device' + 'enable-remote:enables a given remote' + 'get-approved-firmware:gets the list of approved firmware' + 'get-details:gets details about a firmware file' + 'get-devices:get all devices that support firmware updates' + 'get-history:show history of firmware updates' + 'get-releases:gets the releases for a device' + 'get-remotes:gets the configured remotes' + 'get-results:gets the results from the last update' + 'get-topology:get all devices according to the system topology' + 'get-updates:gets the list of updates for connected hardware' + 'install:install a firmware file on this hardware' + 'modify-config:modifies a daemon configuration value' + 'modify-remote:modifies a given remote' + 'refresh:refresh metadata from remote server' + 'report-history:share firmware history with the developers' + 'set-approved-firmware:sets the list of approved firmware' + 'unlock:unlocks the device for firmware access' + 'update:updates all firmware to latest versions available' + 'verify:gets the cryptographic hash of the dumped firmware' + 'verify-update:update the stored metadata with current ROM contents' + ) + _describe -t commands commands commands +} + +(( $+functions[_fwupdmgr_activate_args] )) || +_fwupdmgr_activate_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_clear-history_args] )) || +_fwupdmgr_clear-history_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_clear-results_args] )) || +_fwupdmgr_clear-results_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_disable-remote_args] )) || +_fwupdmgr_disable-remote_args() { + _arguments -C \ + '1: :_fwupdmgr_remote_ids' +} + +(( $+functions[_fwupdmgr_downgrade_args] )) || +_fwupdmgr_downgrade_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_enable-remote_args] )) || +_fwupdmgr_enable-remote_args() { + _arguments -C \ + '1: :_fwupdmgr_remote_ids' +} + +(( $+functions[_fwupdmgr_get-approved-firmware_args] )) || +_fwupdmgr_get-approved-firmware_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_get-details_args] )) || +_fwupdmgr_get-details_args() { + _files +} + +(( $+functions[_fwupdmgr_get-devices_args] )) || +_fwupdmgr_get-devices_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_get-history_args] )) || +_fwupdmgr_get-history_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_get-releases_args] )) || +_fwupdmgr_get-releases_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_get-remotes_args] )) || +_fwupdmgr_get-remotes_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_get-results_args] )) || +_fwupdmgr_get-results_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_get-topology_args] )) || +_fwupdmgr_get-topology_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_get-updates_args] )) || +_fwupdmgr_get-updates_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_install_args] )) || +_fwupdmgr_install_args() { + _arguments -C \ + '1: :_files' \ + '2: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_TODO_args] )) || +_fwupdmgr_TODO_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_modify-config_args] )) || +_fwupdmgr_modify-config_args() { + local ret=1 + if compset -P '*,'; then + _wanted config-value expl 'config value' _fwupdmgr_config_values ${IPREFIX%=} && ret=0 + else + _wanted config-key expl 'config key' _fwupdmgr_config_keys -qS, && ret=0 + fi + return ret +} + +(( $+functions[_fwupdmgr_modify-remote_args] )) || +_fwupdmgr_modify-remote_args() { + _arguments -C \ + '1: :_fwupdmgr_remote_ids' \ + '2: :_fwupdmgr_remote_keys' \ + '3: :_fwupdmgr_remote_values' +} + +(( $+functions[_fwupdmgr_refresh_args] )) || +_fwupdmgr_refresh_args() { + _arguments -C \ + '1: :_files' \ + '2:file signature:' \ + '3: :_fwupdmgr_remote_ids' +} + +(( $+functions[_fwupdmgr_report-history_args] )) || +_fwupdmgr_report-history_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_set-approved-firmware_args] )) || +_fwupdmgr_set-approved-firmware_args() { + _message 'checksum' && ret=0 +} + +(( $+functions[_fwupdmgr_unlock_args] )) || +_fwupdmgr_unlock_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_update_args] )) || +_fwupdmgr_update_args() { + _message 'no more arguments' && ret=0 +} + +(( $+functions[_fwupdmgr_verify_args] )) || +_fwupdmgr_verify_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_verify-update_args] )) || +_fwupdmgr_verify-update_args() { + _arguments -C \ + '1: :_fwupdmgr_device_ids' +} + +(( $+functions[_fwupdmgr_device_ids] )) || +_fwupdmgr_device_ids() { + # TODO add device name as description + local devices=($(_call_program devices fwupdmgr get-devices | grep -Po 'DeviceId:\s+\K(.*)')) + _describe -t devices 'device ID' devices +} + +(( $+functions[_fwupdmgr_remote_ids] )) || +_fwupdmgr_remote_ids() { + # TODO add remote description + local remotes=($(_call_program remotes fwupdmgr get-remotes | grep -Po 'Remote ID:\s+\K(.*)')) + _describe -t remotes 'remote ID' remotes +} + +(( $+functions[_fwupdmgr_checksums] )) || +_fwupdmgr_checksums() { + _guard '[^\-]#' 'checksum' +} + +(( $+functions[_fwupdmgr_config_keys] )) || +_fwupdmgr_config_keys() { + _guard '[^\-]#' 'config key' +} + +(( $+functions[_fwupdmgr_config_values] )) || +_fwupdmgr_config_values() { + _guard '[^\-]#' 'config value' +} + +(( $+functions[_fwupdmgr_remote_keys] )) || +_fwupdmgr_remote_keys() { + _guard '[^\-]#' 'remote key' +} + +(( $+functions[_fwupdmgr_remote_values] )) || +_fwupdmgr_remote_values() { + _guard '[^\-]#' 'remote value' +} + +_fwupdmgr "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_gas b/home/.zsh-server/plugins/zsh-completions/src/_gas new file mode 100644 index 0000000..c173507 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_gas @@ -0,0 +1,69 @@ +#compdef gas +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for gas (https://github.com/walle/gas). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Fredrik Wallgren +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line cmds ret=1 + +_arguments -C \ + '(- 1 *)'{-v,--version}'[display version information]' \ + '(-h|--help)'{-h,--help}'[show help information]' \ + '1: :->cmds' \ + '*: :->args' && ret=0 + +case "$state" in + (cmds) + cmds=( + "version:Prints Gas's version" + "use:Uses author" + "show:Shows your current user" + "list:Lists your authors" + "import:Imports current user to gasconfig" + "help:Describe available tasks or one specific task" + "delete:Deletes author" + "add:Adds author to gasconfig" + ) + _describe -t commands 'gas command' cmds && ret=0 + ;; + (args) + case "$line[1]" in + (use|delete) + _values -S , 'authors' $(cat ~/.gas | sed -n -e 's/^\[\(.*\)\]/\1/p') && ret=0 + ;; + esac + ;; +esac + +return ret + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ghc b/home/.zsh-server/plugins/zsh-completions/src/_ghc new file mode 100644 index 0000000..455658f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ghc @@ -0,0 +1,618 @@ +#compdef ghc ghci ghc-pkg +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ghc (http://www.haskell.org/ghc/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Gérard Milmeister +# * Philip Dexter +# +# ------------------------------------------------------------------------------ + +local state +local WORDS + +# +# ghci +# + +_ghc_ghci () { _ghc_compiler } + +# +# ghc +# + +_ghc_compiler () +{ + _arguments \ + "-no-hs-main[Don't assume this program contains main]" \ + "-no-user-package-conf[Don't load the user's package config file]" \ + '(- *)'{--help,-\?}'[Show help information]' \ + '*-I-[Add directory to path for #include files]:directory:_files -/' \ + '*-X-[Language flags]:flag:_ghc_language_flags' \ + '*-d-[Debugging options]:flag:_ghc_debugging_options' \ + '*-f-[Compiler options]:flag:_ghc_compiler_flags' \ + '*-hide-package[Hide package]:Package:_ghc_pkg_list_packages' \ + '*-trust[Expose package and set it to be trusted]:Package:_ghc_pkg_list_packages' \ + '*-distrust[Expose package and set it to be distrusted]:Package:_ghc_pkg_list_packages' \ + '*-distrust-all[Distrust all packages by default]' \ + '*-i-[Add directory to import path]:directory:->ghc_include_directory' \ + '*-package[Expose package]:Package:_ghc_pkg_list_packages' \ + '*:file:_files -g \*.\{lhs,hs,hc,c,s\}' \ + '--info[Display information about the compiler]' \ + '--show-options[Display the supported command line options]' \ + '--interactive[Interactive mode]' \ + '--make[Compile and link a complete Haskell program]:file:_files -g "*.{lhs,hs,hc,c,s}"' \ + '--numeric-version[Display GHC version (numeric only)]' \ + '--print-libdir[Display GHC library directory]' \ + '--show-iface[Show interface]:file:_files -g "*.hi"' \ + {--supported-languages,--supported-extensions}'[Display the supported language extensions]' \ + '-C[Stop after generating C]' \ + '-E[Stop after generating preprocessed, de-litted Haskell]' \ + '-H[Minimum heap size]:size:' \ + '-M[Output Makefile rules]' \ + '-O-[Enable optimization]:level:(0 1 2)' \ + '-Rghc-timing[Summarise timing stats for GHC]' \ + '-S[Stop after generating assembler]' \ + '-V[Display GHC version]' \ + '-W[Enable normal warnings]' \ + '-Wall[Enable almost all warnings]' \ + '-Werror[Make warnings fatal]' \ + '-Wwarn[Make warnings non-fatal]' \ + '-c[Stop after generating object files]' \ + '-eventlog[Enable runtime event tracing]' \ + '-debug[Use the debugging runtime]' \ + "-dylib-install-name[On Darwin/macOS only, set the install name]" \ + '-dynamic[Use dynamic Haskell libraries]' \ + '-dynamic-too[Build dynamic object files as well as static object files during compilation]' \ + '-dynosuf[Set the output suffix for dynamic object files]' \ + '-dynload[Select one of a number of modes for finding shared libraries at runtime]' \ + '--mk-dll[DLL-creation mode (Windows only)]' \ + '-framework-path[On Darwin/macOS/iOS only, add dir to the list of directories searched for frameworks]' \ + '-shared[Generate a shared library (as opposed to an executable)]' \ + '-staticlib[On Darwin/macOS/iOS only, generate a standalone static library (as opposed to an executable)]' \ + '-e[Evaluate expression]' \ + '-hide-all-packages[Hide all packages by default]' \ + '-hpcdir[Directory to deposit .mix files during compilation (default is .hpc)]' \ + '-n[Do a dry run]' \ + '-o[Set output filename]:file:_files' \ + '-outputdir[Set output directory]:directory:_files -/' \ + '-package-name[Compile to be part of package]' \ + '-hide-all-packages[Hide all packages by default]' \ + '-package-db[Add file to the package db stack]:file:_files' \ + '-clear-package-db[Clear the package db stack]' \ + '-msse2[(x86 only) Use SSE2 for floating point]' \ + '-monly-\[432\]-regs[(x86 only) give some registers back to the C compiler]' \ + '-no-global-package-db[Remove the global package db from the stack]' \ + '-global-package-db[Add the global package db to the stack]' \ + "-no-user-package-db[Remove the user's package db from the stack]" \ + "-user-package-db[Add the user's package db to the stack]" \ + "-no-auto-link-packages[Don't automatically link in the base and rts packages]" \ + '-optL[pass option to the literate pre-processor]' \ + '-optP[pass option to cpp (with -cpp only)]' \ + '-optF[pass option to the custom pre-processor]' \ + '-optc[pass option to the C compiler]' \ + '-optlo[pass option to the LLVM optimiser]' \ + '-optlc[pass option to the LLVM compiler]' \ + '-optm[pass option to the mangler]' \ + '-opta[pass option to the assembler]' \ + '-optl[pass option to the linker]' \ + '-optdll[pass option to the DLL generator]' \ + '-optwindres[pass option to windres.]' \ + '-prof[Turn on profiling]' \ + '-pgmL[Use cmd as the literate pre-processor]' \ + '-pgmP[Use cmd as the C pre-processor (with -cpp only)]' \ + '-pgmc[Use cmd as the C compiler]' \ + '-pgms[Use cmd as the splitter]' \ + '-pgml[Use cmd as the linker]' \ + '-pgmdll[Use cmd as the DLL generator]' \ + '-pgmF[Use cmd as the pre-processor (with -F only)]' \ + '-pgmwindres[Use cmd as the program for embedding manifests on Windows]' \ + '-pgmlibtool[Use cmd as the command for libtool (with -staticlib only)]' \ + '-rtsopts[Only a minimum of safe options can be given to RTS]' \ + '-rtsopts=[Control whether the RTS behavior can be tweaked via command-line flags and the GHCRTS environment variable (none, some, or all)]' \ + '-with-rtsopts=[Set the default RTS options]' \ + '-threaded[Use the threaded runtime]' \ + '-ticky[Turn on ticky-ticky profiling]' \ + '-tmpdir[Set the directory for temporary files]:directory:_files -/' \ + '-v-[Control verbosity]:level:(0 1 2 3 4 5)' \ + '-w[Disable all warnings]' \ + '-x[Override default behaviour for source files]:suffix:(hs lhs hc c s o hspp)' \ + '-hcsuf[Set the suffix to use for intermediate]:suffix:' \ + '-hidir[Set directory for interface files]:directory:_files -/' \ + '-hisuf[Set the suffix to use for interface files]:suffix:' \ + '-odir[Set directory for object files]:directory:_files -/' \ + '-ohi[Set the filename in which to put the interface]:filename:_files -/' \ + '-osuf[Set the output file suffix]:suffix:' \ + '-stubdir[Redirect FFi stub files]:directory:_files -/' \ + '-dumpdir[Redirect dump files]:directory:_files -/' \ + '-outputdir[Set output directory]:directory:_files -/' \ + '-keep-hc-files[Retain intermediate .hc files]' \ + '-keep-llvm-files[Retain intermediate LLVM .ll files]' \ + '-keep-s-files[Retain intermediate .s files]' \ + '-keep-raw-s-files[Retain intermediate .raw_s files]' \ + '-keep-tmp-files[Retain all intermediate temporary files]' \ + '-static[Use static Haskell libraries]' \ + '-split-objs[Split objects (for libraries)]' \ + '-no-link[Omit linking]' \ + '-main-is[Set main module and function]:function:' \ + '*-L-[Add dir to the list of directories searched for libraries]:directory:_files -/' \ + '*-l-[Link in library]:library:->library' + + [[ -n "$state" ]] && + case "$state" in + ghc_include_directory) _ghc_include_directory ;; + library) + _wanted libraries expl library \ + compadd - \ + ${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(:t:fr:s/lib//) \ + && ret=0 + esac +} + + +_ghc_include_directory () +{ + compset -P '*:' + compset -S ':*' + _path_files -r': ' -/ +} + +_ghc_compiler_flags () +{ + local _ghc_compiler_flags_list + _ghc_compiler_flags_list=( + 'ghci-hist-size:Set the number of entries GHCi keeps for \:history' + 'print-explicit-foralls:Print explicit forall quantification in types' + 'print-explicit-kinds:Print explicit kind foralls and kind arguments in types' + {no-,}'break-on-error:Break on uncaught exceptions and errors' + {no-,}'break-on-exception:Break on any exception thrown' + {no-,}'case-merge:Enable case-merging' + {no-,}'defer-type-errors:Defer as many type errors as possible until runtime' + {no-,}'dicts-strict:Make dictionaries strict' + {no-,}'do-eta-reduction:Enable eta-reduction' + {no-,}'do-lambda-eta-expansion:Enable lambda eta-reduction' + 'eager-blackholing:Turn on eager blackholing' + {no-,}'enable-rewrite-rules:Switch on all rewrite rules (including rules generated by automatic specialisation of overloaded functions)' + 'error-spans:Output full span in error messages' + 'ext-core:Generate .hcr external Core file' + 'force-recomp:Turn off recompilation checking' + {no-,}'float-in:Turn on the float-in transformation' + {no-,}'full-laziness:Turn on full laziness (floating bindings outwards)' + {no-,}'fun-to-thunk:Allow worker-wrapper to convert a function closure into a thunk if the function does not use any of its arguments. Off by default.' + {no-,}'glasgow-exts:Enable most language extensions' + {no-,}'helpful-errors:Make suggestions for mis-spelled names' + 'history-size:Set simplification history size' + {no-,}'ignore-asserts:Ignore assertions in the source' + {no-,}'ignore-interface-pragmas:Ignore pragmas in interface files' + {no-,}'loopification:Turn saturated self-recursive tail-calls into local jumps in the generated assembly' + {no-,}'late-dmd-anal:Run demand analysis again, at the end of the simplification pipeline' + {no-,}'liberate-case:Turn on the liberate-case transformation' + 'liberate-case-threshold=:Set the size threshold for the liberate-case transformation (default 200)' + 'no-liberate-case-threshold:Set the size threshold for the liberate-case transformation (default 200)' + {no-,}'max-relevant-bindings=N:Set the maximum number of bindings to display in type error messages (default 6).' + 'max-worker-args=:If a worker has that many arguments, none will be unpacked anymore (default 10)' + 'max-simplifier-iterations=:Set the max iterations for the simplifier' + 'no-asm-mangling:Turn off assembly mangling' + 'no-black-holing:Turn off black holing' + "no-hi-version-check:Don't complain about .hi file mismatches" + 'no-implicit-import-qualified:Turn off implicit qualified import of everything in GHCi' + 'no-print-bind-contents:Turn off printing of binding contents in GHCi' + 'no-opt-coercion:Turn off the coercion optimiser' + 'no-ghci-history:Do not use the load/store the GHCi command history from/to ghci_history' + 'no-ghci-sandbox:Turn off the GHCi sandbox. Means computations are run in the main thread, rather than a forked thread' + 'no-gen-manifest:Do not generate a manifest file (Windows only)' + 'no-embed-manifest:Do not embed the manifest in the executable (Windows only)' + "no-shared-implib:Don't generate an import library for a DLL (Windows only)" + 'no-pre-inlining:Turn off pre-inlining' + 'no-state-hack:Turn off the "state hack" whereby any lambda with a real-world state token as argument is considered to be single-entry' + {no-,}'print-bind-result:Turn on printing of binding results in GHCi' + {no-,}'print-evld-with-show:Enable usage of Show instances in \:print' + 'unregisterised:Unregisterised compilation' + 'asm:Use the native code generator' + 'via-C:Compile via C' + 'no-code:Omit code generation' + 'byte-code:Generate byte-code' + 'object-code:Generate object code' + 'hpc:Turn on Haskell program coverage instrumentation' + 'PIC:Generate position-independent code' + 'plugin=:Load a plugin exported by a given module' + 'plugin-opt=:Give arguments to a plugin module' + 'context-stack=:Set the limit for context reduction (default is 20)' + 'type-function-depth=:Set the limit for type function reductions (default is 200)' + 'force-recomp:Turn off recompilation checking' + {no-,}"omit-interface-pragmas:Don't generate interface pragmas" + 'package-trust:Enable Safe Haskell trusted package requirement for trustworthy modules' + {no-,}'pedantic-bottoms:Make GHC be more precise about its treatment of bottom' + {no-,}'disambiguate-record-fields:Enable record field disambiguation' + {no-,}'irrefutable-tuples:Make tuple pattern matching irrefutable' + {no-,}'vectorise:Enable vectorisation of nested data parallelism' + {no-,}'avoid-vect:Enable vectorisation avoidance' + {no-,}'excess-precision:Enable excess intermediate precision' + {no-,}'prof-auto:Auto-add SCCs to all bindings not marked INLINE' + {no-,}'prof-auto-top:Auto-add SCCs to all top-level bindings not marked INLINE' + {no-,}'prof-auto-exported:Auto-add SCCs to all exported bindings not marked INLINE' + {no-,}'prof-cafs:Auto-add SCCs to all CAFs' + {no-,}'prof-count-entries:Collect entry counts' + 'simplifier-phases:Set the number of phases for the simplifier (default 2)' + 'simpl-tick-factor=:Set the percentage factor for simplifier ticks (default 100)' + {no-,}'spec-constr:Turn on the SpecConstr transformation' + {no-,}'spec-constr-threshold=:Set the size threshold for the SpecConstr transformation (default 200)' + {no-,}'spec-constr-count=:Set the maximum number of specialisations that will be created for any one function by the SpecConstr transformation (default 3)' + 'strictness=before=:Run an additional strictness analysis before a simplifier phase' + {no-,}'static-argument-transformation:Turn on the static argument transformation' + {no-,}'unbox-strict-fields:Flatten strict constructor fields' + {no-,}'unbox-small-strict-fields:Flatten strict constructor fields with a pointer-sized representation' + {no-,}'unfolding-creation-threshold:Tweak unfolding settings' + {no-,}'unfolding-fun-discount:Tweak unfolding settings' + {no-,}'unfolding-keeness-factor:Tweak unfolding settings' + {no-,}'unfolding-use-threshold:Tweak unfolding settings' + {no-,}'warn-warnings-deprecations:Warn about uses of functions & types that have warnings or deprecated pragmas' + {no-,}'warn-deprecated-flags:Warn about uses of commandline flags that are deprecated' + {no-,}'warn-duplicate-exports:Warn when an entity is exported multiple times' + {no-,}'warn-hi-shadowing:Warn when a .hi file in the current directory shadows a library' + {no-,}'warn-implicit-prelude:Warn when the Prelude is implicitly imported' + {no-,}'warn-incomplete-patterns:Warn when a pattern match could fail' + {no-,}'warn-incomplete-record-updates:Warn when a record update could fail' + {no-,}'warn-missing-fields:Warn when fields of a record are uninitialised' + {no-,}'warn-missing-methods:Warn when class methods are undefined' + {no-,}'warn-missing-signatures:Warn about top-level functions without signatures' + {no-,}'warn-duplicate-constraints:Warn when a constraint appears duplicated in a type signature' + {no-,}'warn-identities:Warn about uses of Prelude numeric conversions that are probably the identity (and hence could be omitted)' + {no-,}'warn-incomplete-uni-patterns:Warn when a pattern match in a lambda expression or pattern binding could fail' + {no-,}'warn-lazy-unlifted-bindings:(Deprecated) warn when a pattern binding looks lazy but must be strict' + {no-,}'warn-missing-import-lists:Warn when an import declaration does not explicitly list all the names brought into scope' + {no-,}'warn-missing-local-sigs:Warn about polymorphic local bindings without signatures' + {no-,}'warn-monomorphism-restriction:Warn when the Monomorphism Restriction is applied' + {no-,}'warn-name-shadowing:Warn when names are shadowed' + {warn-orphans,warn-auto-orphans}':Warn when the module contains orphan instance declarations or rewrite rules' + {no-,}'warn-overlapping-patterns:Warn about overlapping patterns' + {no-,}'warn-tabs:Warn if there are tabs in the source file' + {no-,}'warn-type-defaults:Warn when defaulting happens' + {no-,}"warn-unrecognised-pragmas:Warn about uses of pragmas that GHC doesn't recognise" + {no-,}'warn-unused-binds:Warn about bindings that are unused' + {no-,}'warn-unused-imports:Warn about unnecessary imports' + {no-,}"warn-unused-matches:Warn about variables in patterns that aren't used" + {no-,}'warn-unused-do-bind:Warn about do bindings that appear to throw away values of types other than ()' + {no-,}'warn-wrong-do-bind:Warn about do bindings that appear to throw away monadic values that you should have bound instead' + {no-,}'warn-unsafe:Warn if the module being compiled is regarded to be unsafe' + {no-,}'warn-safe:Warn if the module being compiled is regarded to be safe' + {no-,}'warn-amp:Warn on definitions conflicting with the Applicative-Monad Proposal (AMP)' + {no-,}'warn-typed-holes:Enable holes in expressions' + ) + _describe -t flags 'ghc' _ghc_compiler_flags_list || compadd "$@" +} + +_ghc_debugging_options () +{ + local _ghc_debugging_options_list + _ghc_debugging_options_list=( + "dump-hi:Dump the new interface to stdout" + "dump-hi-diffs:Show the differences vs. the old interface" + "dump-minimal-imports:Dump a minimal set of imports" + "core-lint:Turn on internal sanity checking" + "dump-asm:Dump assembly" + "dump-bcos:Dump interpreter byte code" + "dump-cmm:Dump C-- output" + "dump-cpranal:Dump output from CPR analysis" + "dump-cse:Dump CSE output" + "dump-deriv:Dump deriving output" + "dump-ds:Dump desugarer output" + 'dump-flatC:Dump "flat" C' + "dump-foreign:Dump foreign export stubs" + "dump-hpc:Dump after instrumentation for program coverage" + "dump-inlinings:Dump inlining info" + "dump-occur-anal:Dump occurrence analysis output" + "dump-opt-cmm:Dump the results of C-- to C-- optimising passes" + "dump-parsed:Dump parse tree" + "dump-prep:Dump prepared core" + "dump-rn:Dump renamer output" + "dump-rules:Dump rules" + "dump-simpl:Dump final simplifier output" + "dump-simpl-phases:Dump output from each simplifier phase" + "dump-simpl-iterations:Dump output from each simplifier iteration" + "dump-spec:Dump specialiser output" + "dump-splices:Dump TH spliced expressions" + "dump-stg:Dump final STG" + "dump-stranal:Dump strictness analyser output" + "dump-tc:Dump typechecker output" + "dump-types:Dump type signatures" + "dump-worker-wrapper:Dump worker-wrapper output" + "dump-if-trace:Trace interface files" + "dump-tc-trace:Trace typechecker" + "dump-to-file:Dump to files instead of stdout" + "dump-core-stats:Print a one-line summary of the size of the Core program at the end of the optimisation pipeline" + "dump-llvm:Dump LLVM intermediate code" + "dump-rule-firings:Dump rule firing info" + "dump-rule-rewrites:Dump detailed rule firing info" + "dump-vect:Dump vectoriser input and output" + "dump-strsigs:Dump strictness signatures" + "dump-vt-trace:Trace vectoriser" + "dump-rn-trace:Trace renamer" + "dump-rn-stats:Renamer stats" + "dump-simpl-stats:Dump simplifier stats" + "suppress-all:In core dumps, suppress everything (except for uniques) that is suppressible" + "suppress-uniques:Suppress the printing of uniques in debug output (easier to use diff)" + "suppress-idinfo:Suppress extended information about identifiers where they are bound" + "suppress-module-prefixes:Suppress the printing of module qualification prefixes" + "suppress-type-signatures:Suppress type signatures" + "suppress-type-applications:Suppress type applications" + "suppress-coercions:Suppress the printing of coercions in Core dumps to make them shorter" + "no-debug-output:Suppress unsolicited debugging output" + "ppr-debug:Turn on debug printing (more verbose)" + "ppr-noprags:Don't output pragma info in dumps" + "ppr-user-length:Set the depth for printing expressions in error msgs" + "ppr-colsNNN:Set the width of debugging output. For example -dppr-cols200" + "ppr-case-as-let:Print single alternative case expressions as strict lets" + "source-stats:Dump haskell source stats" + "cmm-lint:C-- pass sanity checking" + "stg-lint:STG pass sanity checking" + "stg-stats:Dump STG stats" + "verbose-core2core:Show output from each core-to-core pass" + "verbose-stg2stg:Show output from each STG-to-STG pass" + "show-passes:Print out each pass name as it happens" + "faststring-stats:Show statistics for fast string usage when finished" + ) + _describe -t flags 'ghc' _ghc_debugging_options_list || compadd "$@" +} + + +_ghc_language_flags () +{ + local _ghc_language_flags_list + _ghc_language_flags_list=( + "AllowAmbiguousTypes:Allow the user to write ambiguous types, and the type inference engine to infer them" + "Arrows:Enable arrow notation extension" + "AutoDeriveTypeable:Automatically derive Typeable instances for every datatype and type class declaration" + "BangPatterns:Enable bang patterns" + "ConstraintKinds:Enable a kind of constraints" + "CPP:Enable the C preprocessor" + "ConstrainedClassMethods:Enable constrained class methods" + "DataKinds:Enable datatype promotion" + "DefaultSignatures:Enable default signatures" + "DeriveDataTypeable:Enable deriving for the Data and Typeable classes" + "DeriveGeneric:Enable deriving for the Generic class" + "DisambiguateRecordFields:Enable record field disambiguation" + "EmptyCase:Allow empty case alternatives" + "EmptyDataDecls:Enable empty data declarations" + "ExistentialQuantification:Enable existential quantification" + "ExplicitForAll:Enable explicit universal quantification" + "ExplicitNamespaces:Enable using the keyword type to specify the namespace of entries in imports and exports" + "ExtendedDefaultRules:Use GHCi's extended default rules in a normal module" + "FlexibleContexts:Enable flexible contexts" + "FlexibleInstances:Enable flexible instances" + "ForeignFunctionInterface:Enable foreign function interface" + "FunctionalDependencies:Enable functional dependencies" + "GADTs:Enable generalised algebraic data types" + "GADTSyntax:Enable generalised algebraic data type syntax" + "GeneralizedNewtypeDeriving:Enable newtype deriving" + "Generics:Enable generic classes" + "ImplicitParams:Enable Implicit Parameters" + "ImpredicativeTypes:Enable impredicative types" + "IncoherentInstances:Enable incoherent instances" + "InterruptibleFFI:Enable interruptible FFI" + "KindSignatures:Enable kind signatures" + "LambdaCase:Enable lambda-case expressions" + "LiberalTypeSynonyms:Enable liberalised type synonyms" + "MonadComprehensions:Enable monad comprehensions" + "MonoLocalBinds:Enable do not generalise local bindings" + "MultiParamTypeClasses:Enable multi parameter type classes" + "MultiWayIf:Enable multi-way if-expressions" + "NamedFieldPuns:Enable record puns" + "NegativeLiterals:Enable support for negative literals" + "NewQualifiedOperators:Enable new qualified operator syntax" + "NoImplicitPrelude:Don't implicitly import Prelude" + "NoMonoPatBinds:Make pattern bindings polymorphic" + "NoMonomorphismRestriction:Disable the monomorphism" + "NoNPlusKPatterns:Disable support for n+k patterns" + "NoTraditionalRecordSyntax:Disable support for traditional record syntax (as supported by Haskell 98) C {f = x}" + "NullaryTypeClasses:Enable nullary (no parameter) type classes" + "NumDecimals:Enable support for 'fractional' integer literals" + "OverlappingInstances:Enable overlapping instances" + "OverloadedLists:Enable overloaded lists" + "OverloadedStrings:Enable overloaded string literals" + "PArr:Enable parallel arrays" + "PackageImports:Enable package-qualified imports" + "ParallelArrays:Enable parallel arrays" + "ParallelListComp:Enable parallel list comprehensions" + "PatternGuards:Enable pattern guards" + "PolyKinds:Enable kind polymorphism" + "PolymorphicComponents:Enable polymorphic components for data constructors" + "QuasiQuotes:Enable quasiquotation" + "Rank2Types:Enable rank-2 types" + "RankNTypes:Enable rank-N types" + "RebindableSyntax:Employ rebindable syntax" + "RecordWildCards:Enable record wildcards" + "RecursiveDo:Enable recursive do (mdo) notation" + "RelaxedPolyRec:Relaxed checking for mutually-recursive polymorphic functions" + "Safe:Enable the Safe Haskell Safe mode" + "ScopedTypeVariables:Enable lexically-scoped type variables" + "StandaloneDeriving:Enable standalone deriving" + "TemplateHaskell:Enable Template Haskell" + "TransformListComp:Enable transform list comprehensions" + "TypeFamilies:Enable type families" + "TypeOperators:Enable type operators" + "TypeSynonymInstances:Enable type synonyms" + "Trustworthy:Enable the Safe Haskell Trustworthy mode" + "UnboxedTuples:Enable unboxed tuples" + "UndecidableInstances:Enable undecidable instances" + "UnicodeSyntax:Enable unicode syntax" + "UnliftedFFITypes:Enable unlifted FFI types" + "Unsafe:Enable Safe Haskell Unsafe mode" + "ViewPatterns:Enable view patterns" + 'MagicHash:Allow "#" as a postfix modifier on identifiers' + ) + _describe -t flags 'ghc' _ghc_language_flags_list || compadd "$@" +} + +# +# ghc-pkg +# + +_ghc_pkg () +{ + WORDS=() + for w in $words[1,(($CURRENT - 1))]; do + if [[ $w != --* ]]; then WORDS+=$w; fi + done + _arguments '*:command:_ghc_pkg_command' +} + +_ghc_pkg_command() +{ + local -a _ghc_pkg_cmds + _ghc_pkg_cmds=( + "register:Register the package using package description" + "update:Register the package (overwriting existing package)" + "unregister:Unregister the specified package" + "expose:Expose the specified package" + "hide:Hide the specified package" + "list:List registered packages" + "find-module:List registered packages exposing module" + "latest:Prints the highest registered version of a package" + "check:Check the consistency of package dependencies and list broken packages" + "describe:Give the registered description for the specified package" + "field:Extract the specified field of the package description" + "dump:Dump the registered description for every package" + ) + + if (( $#WORDS == 1 )); then + _describe -t commands 'command' _ghc_pkg_cmds || compadd "$@" + else + local curcontext="$curcontext" + cmd="${${_ghc_pkg_cmds[(r)$WORDS[2]:*]%%:*}}" + if (( $#cmd )); then + _arguments \ + "--user[Use current user's package database]" \ + '--global[User the global package database]' \ + {-f,--package-conf=}'[Use the specified package config file]:Package config file:_files' \ + '--no-user-package-conf[Never reader the user package config]' \ + {-V,--version}'[Output version information and exit]' \ + '--force[Ignore missing directories and libraries only]' \ + {-g,--auto-ghci-libs}'[Automatically build libs for GHCi]' \ + {-?,--help}'[Display this help and exit]' \ + '--simple-output[Print output in easy-to-parse format for some commands]' \ + '--names-only[Only print package names, not versions]' \ + '--ignore-case[Ignore case for substring matching]' \ + '*:argument:_ghc_pkg_'$cmd + else + _message "unknown ghc-pkg command: $WORDS[2]" + fi + fi +} + +_ghc_pkg_unregister () { _ghc_pkg_list_packages } + +_ghc_pkg_expose () { _ghc_pkg_list_packages } + +_ghc_pkg_hide () { _ghc_pkg_list_packages } + +_ghc_pkg_latest () { _ghc_pkg_list_packages } + +_ghc_pkg_describe () { _ghc_pkg_list_packages } + +_ghc_pkg_field () +{ + _ghc_pkg_available_packages + if (( $#WORDS == 2 )); then + compadd "$@" -a -- _ghc_pkg_packages + elif (( $#WORDS == 3 )); then + compset -P '*,' + compset -S ',*' + compadd "$@" -S ',' -q -- \ + name version license copyright maintainer \ + stability homepage package-url description \ + category author exposed exposed-modules \ + hidden-modules import-dirs hs-libraries \ + extra-libraries extra-ghci-libraries include-dirs \ + includes depends hugs-options cc-options ld-options \ + framework-dirs frameworks haddock-interfaces \ + haddock-html + fi +} + +_ghc_pkg_register () { _files } + +_ghc_pkg_update () { _files } + +_ghc_pkg_list () { _ghc_pkg_list_packages } + +_ghc_pkg_find-module () +{ + if (( $#WORDS == 2)); then + if ( [[ ${+_ghc_modules} -eq 0 ]] || _cache_invalid GHC_MODULES ) && + ! _retrieve_cache GHC_MODULES; + then + _ghc_modules=( $(ghc-pkg dump | sed -n '/^exposed-modules:/{s/^exposed-modules:[ ]\+\(.*\)$/\1/;s/ /\n/;p;be};b;:e;n;/^ /{s/^[ ]\+\(.*\)$/\1/;s/ /\n/;p;be}') ) + _store_cache GHC_MODULES _ghc_modules + fi + compadd "$@" -a -- _ghc_modules + fi +} + +_ghc_pkg_dump () {} + +_ghc_pkg_check () {} + +_ghc_pkg_available_packages () +{ + if ( [[ ${+_ghc_pkg_packages_pkgs} -eq 0 ]] || _cache_invalid GHC_PACKAGES ) && + ! _retrieve_cache GHC_PACKAGES; + then + _ghc_pkg_packages=( $(ghc-pkg list --simple-output --names-only) ) + _store_cache GHC_PACKAGES _ghc_pkg_packages + fi +} + +_ghc_pkg_list_packages () +{ + _ghc_pkg_available_packages + compadd "$@" -a -- _ghc_pkg_packages +} + + +# +# dispatcher +# + +case $service in + ghc) + _ghc_compiler + ;; + ghci) + _ghc_ghci + ;; + ghc-pkg) + _ghc_pkg + ;; +esac diff --git a/home/.zsh-server/plugins/zsh-completions/src/_gist b/home/.zsh-server/plugins/zsh-completions/src/_gist new file mode 100644 index 0000000..1db566e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_gist @@ -0,0 +1,126 @@ +#compdef gist +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for gist (https://github.com/defunkt/gist) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Akira Maeda +# * Patrick Ziegler +# * Shivam Mehta +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_arguments -C \ + '(--login)--login[Authenticate gist on this computer.]' \ + '(-f --filename)'{-f,--filename}'[Sets the filename and syntax type.]:NAME' \ + '(-t --type)'{-t,--type}'[Sets the file extension and syntax type.]:EXT' \ + '(-p --private --no-private)'{-p,--private}'[Makes your gist private.]' \ + '(--no-private -p --private)'--no-private'[Makes your gist no private.]' \ + '(-d --description)'{-d,--description}'[Adds a description to your gist.]:DESCRIPTION' \ + '(-s --shorten)'{-s,--shorten}'[Shorten the gist URL using git.io.]' \ + '(-u --update)'{-u,--update}'[Update an existing gist.]:URL ID:user_gists' \ + '(-c --copy)'{-c,--copy}'[Copy the resulting URL to the clipboard]' \ + '(-e --embed)'{-e,--embed}'[Copy the embed code for the gist to the clipboard]' \ + '(-o --open --no-open)'{-o,--open}'[Open the resulting URL in a browser]' \ + '(--no-open -o --open)'--no-open'[No open the resulting URL in a browser]' \ + '(-P --paste)'{-P,--paste}'[Paste from the clipboard to gist]' \ + '(-R --raw)'{-R,--raw}'[Display raw URL of the new gist]' \ + '(-l --list)'{-l,--list}'[List all gists for user ]::user' \ + '(-h --help)'{-h,--help}'[print options help]' \ + '(-v --version)'{-v,--version}'[print version]' \ + '(-r --read)'{-r,--read}'[Read a gist and print out the contents]:user gists:user_gists' \ + '*: :_files' && ret=0 + +_user_gists_cache_policy() { + # rebuild if cache is more than a day old + local -a oldp + oldp=( "$1"(mh+1) ) + (( $#oldp )) +} + +user_gists() { + local update_policy ret=1 + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _user_gists_cache_policy + fi + + # stores the gists of the logged in user in the format ID[Description] + _list=() + _cached_gists="user_gists" + + # retrieve/Write gists from/to cache + if _cache_invalid $_cached_gists || ! _retrieve_cache $_cached_gists; then + _gists=$(gist -l) + + if [ $? -eq 0 ]; then + _store_cache $_cached_gists _gists + else + # some error occurred, the user is probably not logged in + # set _gists to an empty string so that no completion is attempted + _gists="" + fi + else + _retrieve_cache $_cached_gists + fi + + if [ -n "$_gists" ]; then + echo "$_gists" | while read -r line; do + # Splitting the gist -l output + url="$(echo "$line" | cut -d " " -f 1 | cut -d "/" -f 4)" + # gists w/o descriptions can have only one column in the output, those + # have their description set to an empty string + description="$(echo "$line" | awk '{if(NF > 1){$1=""; print $0}}')" + + _list+=( "${url}[${description}]" ) + done + + _values "gists" $_list + ret=0 + fi + + return ret +} + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_git-flow b/home/.zsh-server/plugins/zsh-completions/src/_git-flow new file mode 100644 index 0000000..427b9b2 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_git-flow @@ -0,0 +1,444 @@ +#compdef git-flow +#description Git Flow branching model +# ------------------------------------------------------------------------------ +# Copyright (c) 2010-2015 Justin Hileman +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for git-flow (http://github.com/nvie/gitflow). +# +# Source: https://github.com/bobthecow/git-flow-completion +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Justin Hileman (https://github.com/bobthecow) +# * Yusuke Muraoka (https://github.com/jbking) +# * Vincent Driessen (https://github.com/nvie) +# * Zifei Tong (https://github.com/chevalun) +# * Ben O'Hara (https://github.com/benohara) +# +# ------------------------------------------------------------------------------ + + +_git-flow () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'init:Initialize a new git repo with support for the branching model.' + 'feature:Manage your feature branches.' + 'release:Manage your release branches.' + 'hotfix:Manage your hotfix branches.' + 'support:Manage your support branches.' + 'version:Shows version information.' + ) + _describe -t commands 'git flow' subcommands + ;; + + (options) + case $line[1] in + + (init) + _arguments \ + -f'[Force setting of gitflow branches, even if already configured]' \ + -d'[Use default branch naming conventions and prefixes]' + ;; + + (version) + ;; + + (hotfix) + __git-flow-hotfix + ;; + + (release) + __git-flow-release + ;; + + (feature) + __git-flow-feature + ;; + + (support) + __git-flow-support + ;; + + esac + ;; + esac +} + +__git-flow-release () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'start:Start a new release branch.' + 'finish:Finish a release branch.' + 'list:List all your release branches. (Alias to `git flow release`)' + 'publish:Publish this release branch to origin.`)' + 'track:Track a release branch from origin.`)' + ) + _describe -t commands 'git flow release' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; + + (options) + case $line[1] in + + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':version:__git_flow_version_list' + ;; + + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -s'[Sign the release tag cryptographically]'\ + -u'[Use the given GPG-key for the digital signature (implies -s)]'\ + -m'[Use the given tag message]'\ + -n'[Don'\''t tag this release]'\ + -p'[Push to $ORIGIN after performing finish]'\ + -k'[Keep branch after performing finish]'\ + ':version:__git_flow_version_list' + ;; + + (publish) + _arguments \ + ':version:__git_flow_version_list' + ;; + + (track) + _arguments \ + ':version:__git_flow_version_list' + ;; + + + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac +} + +__git-flow-hotfix () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'start:Start a new hotfix branch.' + 'finish:Finish a hotfix branch.' + 'list:List all your hotfix branches. (Alias to `git flow hotfix`)' + 'publish:Publish this hotfix branch to origin`)' + ) + _describe -t commands 'git flow hotfix' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; + + (options) + case $line[1] in + + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':hotfix:__git_flow_version_list'\ + ':branch-name:__git_branch_names' + ;; + + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -s'[Sign the release tag cryptographically]'\ + -u'[Use the given GPG-key for the digital signature (implies -s)]'\ + -m'[Use the given tag message]'\ + -p'[Push to $ORIGIN after performing finish]'\ + ':hotfix:__git_flow_hotfix_list' + ;; + + (publish) + _arguments \ + ':hotfix:__git_flow_hotfix_list' + ;; + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac +} + +__git-flow-feature () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'start:Start a new feature branch.' + 'finish:Finish a feature branch.' + 'list:List all your feature branches. (Alias to `git flow feature`)' + 'publish:Publish this feature branch to origin.' + 'track:Track a feature branch from origin.' + 'diff:Show a diff of changes since this feature branched off.' + 'rebase:Rebase a feature branch on top of develop.' + 'checkout:Check out (switch to) the given feature branch.' + 'pull:Pull a feature branch from a remote peer.' + ) + _describe -t commands 'git flow feature' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; + + (options) + case $line[1] in + + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':feature:__git_flow_feature_list'\ + ':branch-name:__git_branch_names' + ;; + + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -r'[Finish branch by rebasing first]'\ + -k'[Keep branch after performing finish]'\ + -D'[Force delete feature branch after finish]'\ + ':feature:__git_flow_feature_list' + ;; + + (publish) + _arguments \ + ':feature:__git_flow_feature_list'\ + ;; + + (track) + _arguments \ + ':feature:__git_flow_feature_list'\ + ;; + + (diff) + _arguments \ + ':branch:__git_branch_names'\ + ;; + + (rebase) + _arguments \ + -i'[Do an interactive rebase]' \ + ':branch:__git_branch_names' + ;; + + (checkout) + _arguments \ + ':branch:__git_flow_feature_list'\ + ;; + + (pull) + _arguments \ + ':remote:__git_remotes'\ + ':branch:__git_branch_names' + ;; + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac +} + +__git-flow-support () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'start:Start a new support branch.' + 'list:List all your support branches. (Alias to `git flow support`)' + ) + _describe -t commands 'git flow support' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; + + (options) + case $line[1] in + + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':feature:__git_flow_support_list'\ + ':branch-name:__git_branch_names' + ;; + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac +} + +__git_flow_version_list () +{ + local expl + declare -a versions + + versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return + + _wanted versions expl 'version' compadd $versions +} + +__git_flow_feature_list () +{ + local expl + declare -a features + + features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return + + _wanted features expl 'feature' compadd $features +} + +__git_remotes () { + local expl gitdir remotes + + gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) + __git_command_successful || return + + remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) + __git_command_successful || return + + # TODO: Should combine the two instead of either or. + if (( $#remotes > 0 )); then + _wanted remotes expl remote compadd $* - $remotes + else + _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" + fi +} + +__git_flow_hotfix_list () +{ + local expl + declare -a hotfixes + + hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return + + _wanted hotfixes expl 'hotfix' compadd $hotfixes +} + +__git_flow_support_list () +{ + local expl + declare -a support + + support=(${${(f)"$(_call_program support git flow support list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return + + _wanted hotfixes expl 'support' compadd $support +} + + +__git_branch_names () { + local expl + declare -a branch_names + + branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) + __git_command_successful || return + + _wanted branch-names expl branch-name compadd $* - $branch_names +} + +__git_command_successful () { + if (( ${#pipestatus:#0} > 0 )); then + _message 'not a git repository' + return 1 + fi + return 0 +} + +_git-flow "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_git-pulls b/home/.zsh-server/plugins/zsh-completions/src/_git-pulls new file mode 100644 index 0000000..8dfc117 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_git-pulls @@ -0,0 +1,83 @@ +#compdef git-pulls +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for git-pulls 0.3.1 (https://git-pulls.com/schacon/git-pulls). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud (https://github.com/nicoulaj) +# +# ------------------------------------------------------------------------------ + + +_git-pulls() { + typeset -A opt_args + local context state line curcontext="$curcontext" + + local ret=1 + + _arguments -C \ + '(- 1 *)--help[show usage]' \ + '1:cmd:->cmds' \ + '*::arg:->args' \ + && ret=0 + + case "$state" in + (cmds) + local commands; commands=( + 'update:update pull requests list' + 'list:list pull requests' + 'show:show pull request' + 'browse:open pull request in a web browser' + 'merge:merge pull request' + ) + _describe -t commands 'command' commands && ret=0 + ;; + (args) + curcontext="${curcontext%:*:*}:git-pulls-cmd-$words[1]:" + case $words[1] in + (update) + _message 'no more arguments' && ret=0 + ;; + (list) + _arguments \ + '--reverse[list in reverse order]' \ + && ret=0 + ;; + (show) + _arguments \ + '1: :_git-pulls_pull_requests_numbers' \ + '--full[use verbose output]' \ + && ret=0 + ;; + (browse|merge) + _arguments \ + '1: :_git-pulls_pull_requests_numbers' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + +(( $+functions[_git-pulls_pull_requests_numbers] )) || +_git-pulls_pull_requests_numbers() { + local pull_requests; pull_requests=(${${${(M)${(f)"$(_call_program users $service list)"}:#[[:digit:]]##[[:space:]]*}//:/\\:}/[[:space:]]##/:}) + _describe -t pull-request-numbers 'pull request number' pull_requests "$@" +} + +_git-pulls "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_git-revise b/home/.zsh-server/plugins/zsh-completions/src/_git-revise new file mode 100644 index 0000000..1090826 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_git-revise @@ -0,0 +1,71 @@ +#compdef git-revise +#description update, split and rearrange commits +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for git-revise 0.7.0 +# (https://github.com/mystor/git-revise/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hannu Hartikainen (https://github.com/dancek) +# +# ------------------------------------------------------------------------------ + +__git-revise_commits() { + local -a commits + if git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null; then + commits=(${(f)"$(git log -20 --pretty=format:'%h:%d %s' | sed 's/: /:/')"}) + _describe -V 'commit' commits + else + _message 'not a git repository' + fi +} + +__git-revise_branches() { + local -a branches + if git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null; then + branches=(${(f)"$(git for-each-ref --format='%(refname:short)' refs/heads/)"}) + _describe 'branch' branches + else + _message 'not a git repository' + fi +} + +_git-revise() { + local curcontext="$curcontext" ret=1 + + _arguments -s \ + '(- :)'{-h,--help}'[show help message and exit]' \ + '--root[revise starting at the root commit]' \ + '--ref=[reference to update]: :__git-revise_branches' \ + '--reauthor[reset the author of the targeted commit]' \ + '(- :)--version[show version number and exit]' \ + '(--edit -e)'{--edit,-e}'[edit commit message of targeted commit(s)]' \ + '(--no-autosquash)--autosquash[automatically apply fixup! and squash! commits to their targets]' \ + '(--autosquash)--no-autosquash[force disable revise.autoSquash behaviour]' \ + '(--all -a)--no-index[ignore the index while rewriting history]' \ + '(--no-index --all -a)'{--all,-a}'[stage all tracked files before running]' \ + '(--interactive -i --message -m --cut -c --patch -p)'{--patch,-p}'[interactively stage hunks before running]' \ + '(--interactive -i --message -m --cut -c --patch -p)'{--interactive,-i}'[interactively edit commit stack]' \ + '(--interactive -i --message -m --cut -c --patch -p)'{--message,-m}'[specify commit message on command line]:MESSAGE:()' \ + '(--interactive -i --message -m --cut -c --patch -p)'{--cut,-c}'[interactively cut a commit into two smaller commits]' \ + '(--gpg-sign -S --no-gpg-sign)'{--gpg-sign,-S}'[GPG sign commits]' \ + '(--gpg-sign -S --no-gpg-sign)--no-gpg-sign[do not GPG sign commits]' \ + '1: :__git-revise_commits' && ret=0 + + return $ret +} + +_git-revise "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_git-wtf b/home/.zsh-server/plugins/zsh-completions/src/_git-wtf new file mode 100644 index 0000000..f3f15db --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_git-wtf @@ -0,0 +1,65 @@ +#compdef git-wtf +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for git-wtf, authored by +# William Morgan (http://git-wt-commit.rubyforge.org/git-wtf) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Mario Fernandez (https://github.com/sirech) +# * Shohei YOSHIDA (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +__git_wtf_branches() { + local -a branches + branches=(${(f)"$(git for-each-ref --format='%(refname:short)' refs/heads/)"}) + _describe 'branch' branches +} + +_arguments -w -C -s \ + '(--long --short)'{-l,--long}'[include author info and date for each commit]' \ + '(--long --short)'{-s,--short}'[do not show commits]' \ + '(--all)'{-a,--all}'[show all branches across all remote repos, not just those from origin]' \ + '(--all-commits)'{-A,--all-commits}'[show all commits, not just the first 5]' \ + '(--key)'{-k,--key}'[show key]' \ + '(--relations)'{-r,--relations}'[show relation to features / integration branches]' \ + '(--dump-config)--dump-config[print out current configuration and exit]' \ + '*: :__git_wtf_branches' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_glances b/home/.zsh-server/plugins/zsh-completions/src/_glances new file mode 100644 index 0000000..043bd69 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_glances @@ -0,0 +1,125 @@ +#compdef glances +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for glances (https://nicolargo.github.io/glances/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * loranger (https://github.com/loranger) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +_glances() { + _arguments \ + '(- *)'{-h,--help}'[show this help message and exit]' \ + '(- *)'{-V,--version}"[show program's version number and exit]" \ + '(-C,--config)'{-C,--config}'[path to the configuration file]: :_files' \ + '(--modules-list --module-list)'{--modules-list,--module-list}'[display modules list and exit]' \ + '(--disable-plugin --disable-plugins)'{--disable-plugin,--disable-plugins}'[disable plugin(comma separated list or all)]:plugin' \ + '(--enable-plugin --enable-plugins)'{--enable-plugin,--enable-plugins}'[enable plugin(comma separated list)]:plugin' \ + '--disable-process[disable process module]' \ + '--disable-webui[disable the Web Interface]' \ + '(--light --enable-light)'{--light,--enable-light}'[light mode for Curses UI]' \ + '(-0 --disable-irix)'{-0,--disable-irix}"[task's cpu usage will be divided by the total number of CPUs]" \ + '(-1 --percpu)'{-1,--percpu}'[start Clances in per CPU mode]' \ + '(-2 --disable-left-sidebar)'{-2,--disable-left-sidebar}'[disable network, disk I/O, FS and sensors modules]' \ + '(-3 --disable-quicklook)'{-3,--disable-quicklook}'[disable quick look module]' \ + '(-4 --full-quicklook)'{-4,--full-quicklook}'[disable all but quick look and load]' \ + '(-5 --disable-top)'{-5,--disable-top}'[disable top menu(QL, CPU, MEM, SWAP and LOAD)]' \ + '(-6 --menugpu)'{-6,--menugpu}'[start Glances in mean GPU mode]' \ + '--disable-history[disable stats history]' \ + '--disable-bold[disable bold mode in the terminal]' \ + '--disable-bg[disable background colors in the terminal]' \ + '--enable-irq[enable IRQ mode]' \ + '--enable-process-extended[enable extended stats on top process]' \ + '(--separator --enable-separator)'{--separator,--enable-separator}'[enable separator in the UI]' \ + '--sort-process[sort processes]: :(cpu_percent memory_percent username cpu_times io_counters name)' \ + '(--programs --program)'{--programs,--program}'[Accumulate processes by program]' \ + '--export[enable export module]:module' \ + '--export-csv-file[file path for CSV exporter]: :_files' \ + '--export-csv-overwrite[overwrite existing CSV file]' \ + '--export-json-file[file path for JSON exporter]: :_files' \ + '--export-graph-path[Folder for Graph exporter]: :_files -/' \ + '(-c --client)'{-c,--client}'[connect to a Glances server]:host:_hosts' \ + '(-s --server)'{-s,--server}'[run Glances in server mode]' \ + '--browser[start the client browser]' \ + '--disable-autodiscover[disable autodiscover feature]' \ + '(-p --port)'{-p,--port}'[define the client/server TCP port]' \ + '(-B --bind)'{-B,--bind}'[bind server to the given IPv4/IPv6 address or hostname]:host:_hosts' \ + '--username[define a client/server username]' \ + '--password[define a client/server password]' \ + '-u[use the given client/server username]:user_name' \ + '--snmp-community[SNMP community]:community' \ + '--snmp-port[SNMP community]:port' \ + '--snmp-version[SNMP version]:version:(1 2c 3)' \ + '--snmp-user[SNMP user]:user' \ + '--snmp-auth[SNMP auth]:auth' \ + '--snmp-force[force SNMP mode]' \ + '(-t --time)'{-t,--time}'[set minimum refresh rate in seconds(default: 2 sec)]:seconds' \ + '(-w --webserver)'{-w,--webserver}'[run Glances in web server mode]' \ + '--cached-time[set the server cache time(default: 1 sec)]:seconds' \ + '--stop-after[stop Glances after n fresh]:' \ + '--open-web-browser[try to open the Web UI in the default browser]' \ + '(-q --quiet)'{-q,--quiet}'[do not display the curses interface]' \ + '(-f --process-filter)'{-f,--process-filter}'[set the process filter pattern]:regexp' \ + '--process-short-name[force short name for processes name]' \ + '--process-long-name[force long name for processes name]' \ + '--stdout[display stats to stdout one stat per line]:stats' \ + '--stdout-json[display stats to stdout, JSON format]:stats' \ + '--stdout-csv[display stats to CSV, JSON format]:stats' \ + '--issue[test all plugins and exit]' \ + '--trace-malloc[trace memory allocation and display it at the end of the process]' \ + '--memory-leak[test memory leak]' \ + '--api-doc[display fields descriptions]'\ + '--hide-kernel-threads[hide kernel threads in process list]' \ + '(-b --byte)'{-b,--byte}'[display network rate in byte per second]' \ + '--diskio-show-ramfs[show RAM Fs in the DiskIO plugin]' \ + '--diskio-iops[show IO per second in the DiskIO plugin]' \ + '--fahrenheit[display temperature in Fahrenheit]' \ + '--fs-free-space[display FS free space instead of used]' \ + '--sparkline[display sparklines instead of bar in the curses interface]' \ + '--disable-unicode[disable unicode characters in the curses interface]' \ + '--theme-white[optimize display colors for white background ]' \ + '--disable-check-update[disable online Glances version check]' \ + '--strftime[strftime format string for displaying current date in standalone mode]' \ +} + +_glances "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_golang b/home/.zsh-server/plugins/zsh-completions/src/_golang new file mode 100644 index 0000000..abc42bb --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_golang @@ -0,0 +1,1132 @@ +#compdef go -P -value-,GO*,-default- -P -value-,CGO*,-default- +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2013-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# Copyright (c) 2010-2014 Go authors +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for go 1.19 (http://golang.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Mikkel Oscar Lyderik Larsen +# * Paul Seyfert +# * oh-my-zsh authors: +# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/golang/golang.plugin.zsh +# * Go authors +# +# ------------------------------------------------------------------------------ + +__go_buildmodes() { + local -a buildmodes + buildmodes=( + 'archive[non-main packages into .a files]' + 'c-archive[main package, plus all packages it imports, into a C archive file]' + 'c-shared[main package, plus all packages it imports, into a C shared library]' + 'default[main packages are built into executables and listed non-main packages are built into .a files]' + 'shared[non-main packages into a single shared library that will be used when building with the -linkshared option]' + 'exe[main packages into executables]' + 'pie[main packages and everything they import into position independent executables (PIE)]' + 'plugin[main packages, plus all packages that they import, into a Go plugin]' + ) + + _values 'mode' $buildmodes +} + + +__go_runtimedebug() { + local -a vars + vars=( + 'allocfreetrace[profile allocations]:boolean:(1 0)' + 'clobberfree[clobber memory after free]:boolean:(1 0)' + 'cgocheck[check passing go pointers to non-go]: :((0\:"no checks" 1\:"check checks" 2\:"expensive checks"))' + 'efence[allocate on unique pages]:boolean:(1 0)' + "gccheckmark[verify garbage collector's concurrent mark phase]:boolean:(1 0)" + 'gcpacertrace[print state of the concurrent pacer from garbage collector]:boolean:(1 0)' + 'gcshrinkstackoff[disable moving goroutines to smaller stacks]:boolean:(1 0)' + 'gcstoptheworld[disable concurrent garbage collection]: :((0\:default 1\:"disable concurrent garbage collection" 2\:"disable concurrent gc and sweeping"))' + 'gctrace[emit memory collection and pause information from the garbage collector]:boolean:(1 0)' + 'madvdontneed[use MADV_DONTNEED instead of MADV_FREE]:boolean:(1 0)' + 'memprofilerate[every N-th allocation should be profiled]:int:' + 'invalidptr[crash on invalid integers in pointer-type variables]:boolean:(1 0)' + 'sbrk[replace memory allocator and garbage collector by trivial allocator]:boolean:(1 0)' + 'scavenge[enable debugging mode of heap scavenger]:boolean:(1 0)' + 'scavtrace[emit scavenger work information (memory returned and memory utilization)]:boolean:(1 0)' + 'scheddetail[emit detailed states of scheduler, processors, threads, goroutines]:boolean:(1 0)' + 'schedtrace[emit scheduler state every N ms to stderr]:int' + 'tracebackancestors[set ancestor goroutines to be printed in goroutine creation stacks]:int' + 'asyncpreemptoff[disable signal-based asynchronous goroutine preemption.]:boolean:(1 0)' + ) + _values -s ',' -S '=' "runtime debug behaviour" $vars[@] +} + +__go_gcdebugflags() { + _values -s , -S = 'debug flag' \ + 'append[print information about append compilation]' \ + 'checkptr[instrument unsafe pointer conversions]:pointer conversion checks:((0\:"instrumentation disabled" 1\:"conversions involving unsafe.Pointer are instrumented" 2\:"conversions to unsafe.Pointer force heap allocation"))' \ + 'closure[print information about closure compilation]' \ + 'compilelater[compile functions as late as possible]' \ + 'disablenil[disable nil checks]' \ + 'dclstack[run internal dclstack check]' \ + 'gcprog[print dump of GC programs]' \ + 'libfuzzer[coverage instrumentation for libfuzzer]' \ + 'nil[print information about nil checks]' \ + 'panic[do not hide any compiler panic]' \ + 'slice[print information about slice compilation]' \ + 'typeassert[print information about type assertion inlining]' \ + 'wb[print information about write barriers]' \ + 'export[print export data]' \ + 'pctab[print named pc-value table]:pc-value:(pctospadj pctofile pctoline pctoinline pctopcdata)' \ + 'locationlists[print information about DWARF location list creation]' \ + 'typecheckinl[eager typechecking of inline function bodies]' \ + 'dwarfinl[print information about DWARF inlined function creation]' \ + 'softfloat[force compiler to emit soft-float code]' \ + 'defer[print information about defer compilation]' \ + 'ssa/help[print help about SSA debugging]' +} + +__go_gcflags() { + _arguments \ + '-%[debug non-static initializers]' \ + '-c=[concurrency during compilation]:int' \ + '-+[compiling runtime]' \ + '-B[disable bounds checking]' \ + '-C[disable printing of columns in error messages]' \ + '-D=[set relative path for local imports]:path: _path_files -/' \ + '-E[debug symbol export]' \ + '-I=[add directory to import search path]:directory: _path_files -/' \ + '-K[debug missing line numbers]' \ + '-L[show full file names in error messages]' \ + '-N[disable optimizations]' \ + '-S[print assembly listing]' \ + '-V[print version and exit]' \ + '-W[debug parse tree after type checking]' \ + '-asmhdr=[write assembly header to file]:file' \ + '-bench=[append benchmark times to file]:file' \ + '-blockprofile=[write block profile to file]:file' \ + '-buildid=[record id as the build id in the export metadata]:id' \ + '-complete[compiling complete package (no C or assembly)]' \ + '-cpuprofile=[write cpu profile to file]:file' \ + '-d=[print debug information about items in list; try -d help]:list: __go_gcdebugflags' \ + '-dwarf[generate DWARF symbols (default true)]' \ + '-dwarfbasentries[use base address selection entries in DWARF (default true)]' \ + '-dwarflocationlists[add location lists to DWARF in optimized mode (default true)]' \ + '-dynlink[support references to Go symbols defined in other shared libraries]' \ + '-e[no limit on number of errors reported]' \ + '-gendwarfinl=[generate DWARF inline info records (default 2)]:int' \ + '-goversion=[required version of the runtime]:string' \ + '-h[halt on error]' \ + '-importcfg=[read import configuration from file]:file' \ + '-installsuffix=[set pkg directory suffix]:suffix' \ + '-j[debug runtime-initialized variables]' \ + '-json=[version,destination for JSON compiler/optimizer logging]:string' \ + '-l[disable inlining]' \ + '-lang=[release to compile for]:string' \ + '-linkobj=[write linker-specific object to file]:file' \ + '-linkshared[generate code that will be linked against Go shared libraries]' \ + '-live[debug liveness analysis]' \ + '-m[print optimization decisions]' \ + '-memprofile=[write memory profile to file]:file' \ + '-memprofilerate=[set runtime.MemProfileRate to rate]:rate' \ + '-msan[build code compatible with C/C++ memory sanitizer]' \ + '-mutexprofile=[write mutex profile to file]:file' \ + '-newobj[use new object file format]' \ + '-nolocalimports[reject local (relative) imports]' \ + '-o=[write output to file]:file' \ + '-p=[set expected package import path]:path: _path_files -/' \ + '-pack[write to file.a instead of file.o]' \ + '-r[debug generated wrappers]' \ + '-race[enable race detector]' \ + '-shared[generate code that can be linked into a shared library]' \ + '-smallframes[reduce the size limit for stack allocated objects]' \ + '-spectre=[enable spectre mitigations]:mitigations:(all index ret)' \ + '-std[compiling standard library]' \ + '-symabis=[read symbol ABIs from file]:file' \ + '-traceprofile=[write an execution trace to file]:file' \ + '-trimpath=[remove prefix from recorded source file paths]:prefix' \ + '-v[increase debug verbosity]' \ + '-w[debug type checking]' \ + '-wb[enable write barrier (default true)]' \ +} + + +local -a commands build_flags +commands=( +'bug:start a bug report' +'build:compile packages and dependencies' +'clean:remove object files and cached files' +'doc:show documentation for package or symbol' +'env:print Go environment information' +'fix:update packages to use new APIs' +'fmt:gofmt (reformat) package sources' +'generate:generate Go files by processing source' +'get:download and install packages and dependencies' +'install:compile and install packages and dependencies' +'list:list packages or modules' +'mod:module maintenance' +'work:workspace maintenance' +'run:compile and run Go program' +'test:test packages' +'tool:run specified go tool' +'version:print Go version' +'vet:report likely mistakes in packages' +'help:get more information about a command' +) + +__go_envvarvals() { + # if __go_envvarvals is called for -value-, I use the function argument to + # decide which variable to go to. if $1 is not set, then __go_envvarvals is + # called from the `go env` completion and the current word (with all after + # the first '=' removed) is the current variable. + local variable + variable=${1-${words[$CURRENT]%%=*}} + case $variable in + # commands + AR) + ;& + CC) + ;& + CXX) + ;& + FC) + ;& + GCCGO) + _command_names -e + ;; + # directories (using fallthrough) + GOBIN) + ;& + GOCACHE) + ;& + GOTMPDIR) + ;& + GOTOOLDIR) + ;& + GOROOT) + ;& + GOROOT_FINAL) + ;& + GCCGOTOOLDIR) + ;& + GOPATH) + ;& + GOMODCACHE) + _files -/ + ;; + # regular files (using fallthrough) + GOMOD) + ;& + PKG_CONFIG) + ;& + GOENV) + _files + ;; + # special + GOHOSTOS) + ;& + GOOS) + # from https://golang.org/doc/install/source#environment + _values 'operating system' aix android darwin dragonfly freebsd illumos ios js linux netbsd openbsd plan9 solaris windows + ;; + GOHOSTARCH) + ;& + GOARCH) + _values 'architecture' amd64 386 arm64 arm ppc64 ppc64le mips mipsle mips64 mips64le riscv64 s390x wasm + ;; + CGO_ENABLED) + _values 'enable/disable cgo' 0 1 + ;; + GO_EXTLINK_ENABLED) + _values 'enable/disable external linkage' 0 1 + ;; + GOARM) + _values 'target arm architecture' 5 6 7 + ;; + GO386) + _values 'x86 floating point instruction set' 387 sse2 + ;; + GOAMD64) + _values 'amd64 instruction set' v1 v2 v3 v4 + ;; + GOMIPS*) + _values 'mips floating point instructions' hardfloat softfloat + ;; + GOPPC64) + _values 'powerpc64 instruction set' power8 power9 + ;; + GOWASM) + _values 'web assembly features' -s ',' satconv signext + ;; + GOPROXY) + _urls + ;; + GOEXE) + _message "suffix for executables" + ;; + CGO_*FLAGS_*ALLOW) + _message "regexp" + ;; + CGO_*FLAGS) + _dispatch $service -value-,${variable#CGO_},-default- + ;; + GODEBUG) + __go_runtimedebug + ;; + GOFLAGS) + # not implemented, sorry + ;; + GOINSECURE) + ;& + GOPRIVATE) + ;& + GONOPROXY) + ;& + GONOSUMDB) + # comma separated glob patterns (in the syntax of Go's path.Match) + _message "comma separated glob pattern" + ;; + GOSUMDB) + _message "e.g. sum.golang.org+ https://sum.golang.org" + ;; + esac +} + +if [[ "$service" = -value-* ]]; then + variable=${${service%,-default-}#-value-,} + # some special variables are not read from the environment + local -a blacklist + blacklist=('GOEXE' 'GOGCCFLAGS' 'GOHOSTARCH' 'GOHOSTOS' 'GOMOD' 'GOTOOLDIR') + if (($blacklist[(I)$variable])); then + return + fi + __go_envvarvals $variable + return +fi + +_arguments \ + "1: :{_describe 'command' commands}" \ + '*:: :->args' + +case $state in + args) + build_flags=( + '-a[force rebuilding of packages that are already up-to-date]' + '-n[print the commands but do not run them]' + '-p[number of builds that can be run in parallel]:number' + '-race[enable data race detection]' + '-msan[enable interoperation with memory sanitizer]' + '-asan[enable interoperation with address sanitizer]' + '-v[print the names of packages as they are compiled]' + '-work[print temporary work directory and keep it]' + '-x[print the commands]' + '-asmflags[arguments for each go tool asm invocation]:flags' + '-buildmode[build mode to use]:mode:__go_buildmodes' + '-buildvcs[stamp binaries with version control information]:mode:(internal external auto)' + '-compiler[name of compiler to use]:name' + '-gccgoflags[arguments for gccgo]:args' + '*-gcflags=[arguments for each go tool compile invocation]:args:__go_gcflags' + '-installsuffix[suffix to add to package directory]:suffix' + '-ldflags[arguments to pass on each go tool link invocation.]:flags' + '-linkshared[link against shared libraries]' + '-overlay[read a JSON config file that provides an overlay for build operations]:file:_files -g "*.json"' + '-pkgdir[install and load all packages from dir]:dir' + '-tags[list of build tags to consider satisfied]:tags' + '-trimpath[remove all file system paths from the resulting executable]' + '-toolexec[program to use to invoke toolchain programs]:args' + ) + mod_flags=( + '-mod=[module download mode to use]:download mode:(readonly vendor mod)' + '-modcacherw[leave newly-created directories in the module cache read-write]' + '-modfile=[read an alternate go.mod file]:modfile: _files -g "*.mod"' + ) + + edit_flags=( + '-fmt[reformats the go.mod/work file without making other changes]' \ + '*-require=[add a requirement on the given module path and version]:require' \ + '*-droprequire=[drop a requirement on the given module path and version]:droprequire' \ + '-go[sets the expected Go language version]:goversion' \ + '*-replace=[add a replacement of the given module path and version]:replace' \ + '*-dropreplace=[drop a replacement of the given module path and version]:dropreplace' \ + '-json[prints the final go.mod/work file in JSON format]' \ + '-print[prints the final go.mod/work in its text format]' \ + ) + + __go_packages() { + local gopaths + declare -a gopaths + gopaths=("${(s/:/)$(go env GOPATH)}") + gopaths+=("$(go env GOROOT)") + for p in $gopaths; do + _path_files $@ -W "$p/src" -/ + done + # no special treatment for + # - relative paths starting with .. + # - absolute path starting with / + # - variables, substitutions, subshells + if [[ $words[$CURRENT] = ..* || $words[$CURRENT] = \$* || $words[$CURRENT] = /* ]]; then + _path_files $@ -/ -g '*.go' + else + # go build accepts paths relative to the cwd but they must start with './', so prefix them + _path_files $@ -P './' -/ -g '*.go' + fi + } + + case $words[1] in + build) + _arguments \ + '-o[force build to write to named output file or directory]:file or directory:_files' \ + '-i[installs the packages that are dependencies of the target]' \ + ${build_flags[@]} \ + ${mod_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + clean) + _arguments \ + '-i[remove corresponding installed archive or binary]' \ + '-r[apply clean recursively on all dependencies]' \ + '-cache[remove the entire go build cache]' \ + '-testcache[expire all test results in the go build cache]' \ + '-modcache[clean to remove the entire module download cache]' \ + '-fuzzcache[remove files stored in the Go build cache for fuzz testing]' \ + ${build_flags[@]} \ + ${mod_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + doc) + _arguments \ + '-all[show all the documentation for the package]' \ + '-c[respect case when matching symbols]' \ + '-cmd[treat a command (package main) like a regular package]' \ + '-short[one-line representation for each symbol]' \ + '-src[show the full source code for the symbol]' \ + '-u[show docs for unexported and exported symbols and methods]' + ;; + + env) + local -a goenvvars + goenvvars=( + "GOARCH[architecture, or processor, for which to compile code.]:architecture" + "GCCGO[gccgo command to run.]:gccgo command" + "GOBIN[directory where 'go install' installs to]:go install target dir" + "GOCACHE[directory to store cached information]:go build cache dir" + "GODEBUG[enable runtime debug facilities]:runtime debug settings" + "GOENV[location of the go environment configuration file]:configuration file" + "GOFLAGS[default go command line flags]:space separated default command line flags" + "GOINSECURE[module prefixes that are fetched insecurely]:comma separated module prefixes" + "GOOS[target operating system]:operating system" + "GOPATH[path to resolve import statements]:import path" + "GOPROXY[URL of go module proxy]:proxy url" + "GOROOT[root of the go tree]:go root directory" + "GOTMPDIR[directory for temporary sources, packages, and binaries]:tmp directory" + "GOPRIVATE[modules that should always be fetched directly]:comma separated glob patterns" + "GONOPROXY[modules that should always be fetched directly]:comma separated glob patterns" + "GONOSUMDB[modules that should not be compared against the checksum db]:comma separated glob patterns" + "GOMODCACHE[module cache directory]:path" + "GOSUMDB[checksum database]:name(+publickey( url))" + "AR[command for manipulating library archives (for gccgo)]:archive manipulation program" + "CC[command to compile C code]:C compiler" + "CGO_ENABLED[enable/disable cgo]:boolean" + "CGO_CFLAGS[flags passed to the compiler for C code]:C compilation flags" + "CGO_CFLAGS_ALLOW[additional flags to allow to appear in #cgo CFLAGS]:regular expression" + "CGO_CFLAGS_DISALLOW[flags that must be disallowed from appearing in #cgo CFLAGS]" + "CGO_CPPFLAGS[flags passed to the C preprocessor]:C preprocessor flags" + "CGO_CPPFLAGS_ALLOW[additional flags to allow to appear in #cgo CPPFLAGS]:regular expression" + "CGO_CPPFLAGS_DISALLOW[flags that must be disallowed from appearing in #cgo CPPFLAGS]" + "CGO_CXXFLAGS[flags passed to the compiler for C++ code]:C++ compilation flags" + "CGO_CXXFLAGS_ALLOW[additional flags to allow to appear in #cgo CXXFLAGS]:regular expression" + "CGO_CXXFLAGS_DISALLOW[flags that must be disallowed from appearing in #cgo CXXFLAGS]" + "CGO_FFLAGS[flags passed to the compiler for Fortran code]:Fortran compilation flags" + "CGO_FFLAGS_ALLOW[additional flags to allow to appear in #cgo FFLAGS]:regular expression" + "CGO_FFLAGS_DISALLOW[flags that must be disallowed from appearing in #cgo FFLAGS]" + "CGO_LDFLAGS[flags passed to the compiler for linker]:linker flags" + "CGO_LDFLAGS_ALLOW[additional flags to allow to appear in #cgo LDFLAGS]:regular expression" + "CGO_LDFLAGS_DISALLOW[flags that must be disallowed from appearing in #cgo LDFLAGS]" + "CXX[command to compile C++]:C++ compiler" + "FC[command to compile Fortran]:Fortran compiler" + "PKG_CONFIG[Path to pkg-config tool.]:path to pkg-config" + "GOARM[arm architecture]:arm architecture" + "GO386[x86 instruction set]:x86 instruction set" + "GOAMD64[amd64 instruction set]:amd64 instruction set" + "GOMIPS[mips instruction set]:mips instruction set" + "GOMIPS64[mips64 instruction set]:mips64 instruction set" + "GOPPC64[powerpc64 instruction set]:powerpc64 instruction set" + "GOWASM[web assembly features]:comma separated web assembly features" + "GCCGOTOOLDIR[directory of gccgo tools]:gccgo tool directory" + "GOROOT_FINAL[root of the go tree]:go root" + "GO_EXTLINK_ENABLED[enable external linking mode]:boolean" + "GIT_ALLOW_PROTOCOL[schemes allowed to fetch]:colon separated git schemes" + "GOEXE[suffix for executables]:executable suffix" + "GOGCCFLAGS[arguments supplied to CC]:space separated arguments to CC" + "GOHOSTARCH[architecture of the toolchain binaries]:host os architecture" + "GOHOSTOS[operating system of the toolchain binaries]:host os" + "GOMOD[absolute path the the main go.mod]:abs path to main go.mod" + "GOTOOLDIR[installation directory of go tools]:tool installation directory" + ) + local -a exclude_from_w + exclude_from_w=(GOENV) + + __list_env_vars() { + # the parameter expansion strops off everything after the first [ + _values -s ' ' -w 'environment variable' ${goenvvars[@]%%\[*} + } + + # the ^ parameter expansion appends ": __go_envvarvals" to every element of goenvvars + # the :# parameter expansion removes all elements matching GOENV* + [[ $words[2] != '-w' ]] && _arguments \ + '-json[print the environment in JSON format]' \ + '-u[unset environment variables]' \ + '-w[change the default setting of environment variables]' \ + '*:[show environment variable]: __list_env_vars' || _values \ + -s ' ' -S "=" -w 'environment variable' ${^goenvvars:#GOENV*}": __go_envvarvals" + ;; + + fix) + _arguments '*:importpaths:__go_packages' + ;; + + fmt) + _arguments \ + '-n[prints commands that would be executed]' \ + '-x[prints commands as they are executed]' \ + '*:importpaths:__go_packages' + ;; + + generate) + _arguments \ + '-run=[specifies a regular expression to select directives]:regex' \ + '-x[print the commands]' \ + '-n[print the commands but do not run them]' \ + '-v[print the names of packages as they are compiled]' \ + "*:args:{ _alternative ':importpaths:__go_packages' _files }" + ;; + + get) + # no mod_flags for get + _arguments \ + '-d[instructs get to stop after downloading the packages]' \ + '-f[force get -u not to verify that each package has been checked from vcs]' \ + '-fix[run the fix tool on the downloaded packages]' \ + '-insecure[permit fetching/resolving custom domains]' \ + '-t[also download the packages required to build tests]' \ + '-u[use the network to update the named packages]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + install) + _arguments ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + list) + local -a list_args + list_args=( + '-e[changes the handling of erroneous packages]' + '-f[specifies an alternate format for the list]:format' + '-json[causes package data to be printed in JSON format]' + '-compiled[set CompiledGoFiles to the Go source files presented to the compiler]' + '-deps[iterate over named packages and their dependencies]' + '-m[list modules instead of packages]' + ${build_flags[@]} + ${mod_flags[@]} + '*:importpaths:__go_packages' + ) + # -u and -versions are only available if -m is present on the commandline + if (($words[(I)-m])); then + list_args+=( + '-u[adds information about available upgrades]' + '-versions[list all known versions of modules]' + ) + fi + _arguments ${list_args[@]} + ;; + + mod) + local -a mod_commands + mod_commands=( + 'download:download modules to local cache' + 'edit:edit go.mod from tools or scripts' + 'graph:print module requirement graph' + 'init:initialize new module in current directory' + 'tidy:add missing and remove unused modules' + 'vendor:make vendored copy of dependencies' + 'verify:verify dependencies have expected content' + 'why:explain why packages or modules are needed' + 'help:get more information about a command' + ) + + _arguments \ + "1: :{_describe 'command' mod_commands}" \ + '*:: :->args' + + case $state in + args) + case $words[1] in + download) + _arguments \ + '-json[print a sequence of JSON objects to standard output]' \ + '-x[print the commands download executes]' + ;; + + edit) + _arguments \ + ${edit_flags[@]} \ + "-module[change the module's path]" \ + '*-exclude=[add an exclusion for the given module path and version]:exclude' \ + '*-dropexclude=[drop an exclusion for the given module path and version]:dropexclude' \ + ':go.mod:_path_files -g "go.mod"' + ;; + graph) + _arguments \ + '-go[report the module graph as loaded by the given Go version]:goversion' + ;; + init) + # Use go packages as module name suggestion + _arguments \ + '*:module:__go_packages' + ;; + tidy) + _arguments \ + '-v[print information about removed modules to standard error]' \ + '-e[attempt to proceed despite errors encountered while loading packages]' \ + '-go[update the go directive in the go.mod file to the given version]:goversion' \ + '-compat[preserves additional checksums needed for the indicated Go version]' + ;; + vendor) + _arguments \ + '-v[print the names of vendored modules and packages to standard error]' \ + '-e[attempt to proceed despite errors encountered while loading packages]' \ + '-o[create the vendor directory at the given path instead of "vendor"]:directory:_path_files -/' + ;; + verify) + ;; + why) + _arguments \ + '-m[treats the arguments as a list of modules]' \ + '-vendor[exclude tests of dependencies]' \ + '*:module:__go_packages' + ;; + esac + ;; + esac + ;; + + run) + _arguments \ + ${build_flags[@]} \ + '-exec[invoke the binary using xprog]:xporg' \ + '*:importpaths:__go_packages' + ;; + + test) + if [[ $words[$CURRENT] = -test.* ]]; then + _arguments \ + '-test.bench[run only benchmarks matching regexp]:regexp' \ + '-test.benchmem[print memory allocations for benchmarks]' \ + '-test.benchtime[run each benchmark for duration d (default 1s)]:d' \ + '-test.blockprofile[write a goroutine blocking profile to file]:file:_files' \ + '-test.blockprofilerate[set blocking profile rate (see runtime.SetBlockProfileRate) (default 1)]:rate' \ + '-test.count[run tests and benchmarks n times (default 1)]:n' \ + '-test.coverprofile[write a coverage profile to file]:file:_files' \ + '-test.cpu[comma-separated list of cpu counts to run each test with]:comma-separated list' \ + '-test.cpuprofile[write a cpu profile to file]:file:_files' \ + '-test.failfast[do not start new tests after the first test failure]' \ + '-test.list[list tests, examples, and benchmarks matching regexp then exit]:regexp' \ + '-test.fuzz[run the fuzz test matching regexp]:regexp' \ + '-test.fuzzcachedir[directory where interesting fuzzing inputs are stored]:dir:_path_files -/' \ + '-test.fuzzminimizetime[time to spend minimizing a value after finding a failing input (default 1m0s)]:t' \ + '-test.fuzztime[time to spend fuzzing; default is to run indefinitely]:t' \ + '-test.fuzzworker[coordinate with the parent process to fuzz random values (for use only by cmd/go)]' \ + '-test.list[list tests, examples, and benchmarks matching regexp then exit]:regexp' \ + '-test.memprofile[write an allocation profile to file]:file:_files' \ + '-test.memprofilerate[set memory allocation profiling rate (see runtime.MemProfileRate)]:rate' \ + '-test.mutexprofile[write a mutex contention profile to the named file after execution]:string' \ + '-test.mutexprofilefraction[if >= 0, calls runtime.SetMutexProfileFraction() (default 1)]:int' \ + '-test.outputdir[write profiles to dir]:dir:_path_files -/' \ + '-test.paniconexit0[panic on call to os.Exit(0)]' \ + '-test.parallel[run at most n tests in parallel (default 4)]:n' \ + '-test.run[run only tests and examples matching regexp]:regexp' \ + '-test.short[run smaller test suite to save time]' \ + '-test.shuffle[randomize the execution order of tests and benchmarks (default "off")]:string' \ + '-test.testlogfile[write test action log to file (for use only by cmd/go)]:file' \ + '-test.timeout[panic test binary after duration d (default 0, timeout disabled)]:d' \ + '-test.trace[write an execution trace to file]:file' \ + '-test.v[verbose: print additional output]' + else + _arguments \ + "-c[compile but don't run test]" \ + '-i[install dependencies of the test]' \ + '-bench[run benchmarks matching the regular expression]:regexp' \ + '-benchmem[print memory allocation statistics for benchmarks]' \ + '-benchtime[run benchmarks for t rime]:t' \ + '-blockprofile[write a goroutine blocking profile to the specified file]:block' \ + '-blockprofilerate[control goroutine blocking profiles]:n' \ + '-count[run each test and benchmark n times]:n' \ + '-cover[enable coverage analysis]' \ + '-covermode[set the mode for coverage analysis]:mode:(set count atomic)' \ + '-coverpkg[apply coverage analysis in each test of listed packages]:list' \ + '-coverprofile[write a coverage profile to file]:cover' \ + '-cpu[specify a list of GOMAXPROCS values]:cpus' \ + '-cpuprofile[write a CPU profile to the specified file]:profile' \ + '-failtest[do not start new tests after the first test failure]' \ + '-fuzz[run the fuzz test matching the regular expression]:regexp' \ + '-fuzztime[run enough iterations of the fuzz target during fuzzing]:t' \ + '-fuzzminimizetime[run enough iterations of the fuzz target during each minimization attempt]:t' \ + '-json[log verbose output and test results in JSON]' \ + '-list[list tests, benchmarks, fuzz tests, or examples matching the regular expression]:regexp' \ + '-memprofile[write a memory profile to file]:mem' \ + '-memprofilerate[enable more precise memory profiles]:n' \ + '-mutexprofile[write a mutex contention profile to the specified file]:file:_files' \ + '-outputdir[place output files from profiling in output dir]:dir' \ + '-parallel[allow parallel execution of test functions]:n' \ + '-run[run tests and examples matching the regular expression]:regexp' \ + '-short[tell long-running tests to shorten their run time]' \ + '-shuffle[randomize the execution order of tests and benchmarks]:type:(off on)' \ + '-test.-[specify options for test running]:test running options:' \ + '-timeout[timeout long running tests]:t' \ + '-trace[write an execution trace to the specified file]:trace' \ + '-v[verbose output]' \ + '-vet[configure the invocation of "go vet" during "go test" to use the comma-separated list of vet checks]:list' \ + ${build_flags[@]} \ + '-exec[run test binary using xprog]:xprog' \ + '-o[compile test binary to named file]:file:_files' \ + '*:importpaths:__go_packages' + fi + ;; + + tool) + local -a tools + tools=($(go tool)) + + _arguments \ + '-n[print command that would be executed]' \ + "1: :{_describe 'tool' tools}" \ + '*:: :->args' + + case $state in + args) + case $words[1] in + addr2line) + _files + ;; + + asm) + _arguments \ + '-D[predefined symbol with optional simple value]:value' \ + '-I[include directory]:value' \ + '-S[print assembly and machine code]' \ + '-debug[dump instructions as they are parsed]' \ + '-dynlink[support references to Go symbols]' \ + '-o[output file]:string' \ + '-shared[generate code that can be linked into a shared lib]' \ + '-trimpath[remove prefix from recorded source file paths]:string' + ;; + + callgraph) + local -a algos graphs + algos=( + 'static:static calls only' + 'cha:Class Hierarchy Analysis' + 'rta:Rapid Type Analysis' + 'pta:inclusion-based Points-To Analysis' + ) + graphs=( + 'digraph:output in digraph format' + 'graphviz:output in AT&T GraphViz (.dot) format' + ) + + _arguments \ + '-algo=[call-graph construction algorithm]:algos:{ _describe "algos" algos }' \ + "-test[include the package's tests in the analysis]" \ + '-format=[format in which each call graph edge is displayed]:graphs:{ _describe "graphs" graphs }' + ;; + + cgo) + _arguments \ + '-debug-define[print relevant #defines]' \ + '-debug-gcc[print gcc invocations]' \ + '-dynimport[if non-empty, print dynamic import data]:string' \ + '-dynlinker[record dynamic linker information]' \ + '-dynout[write -dynimport output to file]:file' \ + '-dynpackage[set Go package for -dynimport output]:string' \ + '-exportheader[where to write export header]:string' \ + '-gccgo[generate files for use with gccgo]' \ + '-gccgopkgpath[-fgo-pkgpath option used with gccgo]:string' \ + '-gccgoprefix[-fgo-prefix option used with gccgo]:string' \ + '-godefs[write Go definitions for C file to stdout]' \ + '-import_runtime_cgo[import runtime/cgo in generated code]' \ + '-import_syscall[import syscall in generated code]' \ + '-importpath[import path of package being built]:path' \ + '-objdir[object directory]:dir' + ;; + + compile) + _arguments \ + '-%[debug non-static initializers]' \ + '-+[compiling runtime]' \ + "-A[for bootstrapping, allow 'any' type]" \ + '-B[disable bounds checking]' \ + '-D[set relative path for local imports]:path' \ + '-E[debug symbol export]' \ + '-I[add directory to import search path]:directory' \ + '-K[debug missing line numbers]' \ + '-L[use full (long) path in error messages]' \ + '-M[debug move generation]' \ + '-N[disable optimizations]' \ + '-P[debug peephole optimizer]' \ + '-R[debug register optimizer]' \ + '-S[print assembly listing]' \ + '-V[print compiler version]' \ + '-W[debug parse tree after type checking]' \ + '-asmhdr[write assembly header to file]:file' \ + '-buildid[record id as the build id in the export metadata]:id' \ + '-complete[compiling complete package (no C or assembly)]' \ + '-cpuprofile[write cpu profile to file]:file' \ + '-d[print debug information about items in list]:list' \ + '-dynlink[support references to Go symbols]' \ + '-e[no limit on number of errors reported]' \ + '-f[debug stack frames]' \ + '-g[debug code generation]' \ + '-h[halt on error]' \ + '-i[debug line number stack]' \ + '-installsuffix[set pkg directory suffix]:suffix' \ + '-j[debug runtime-initialized variables]' \ + '-l[disable inlining]' \ + '-largemodel[generate code that assumes a large memory model]' \ + '-live[debug liveness analysis]' \ + '-m[print optimization decisions]' \ + '-memprofile[write memory profile to file]:file' \ + '-memprofilerate[set runtime.MemProfileRate to rate]:rate' \ + '-nolocalimports[reject local (relative) imports]' \ + '-o[write output to file]:file' \ + '-p[set expected package import path]:path' \ + '-pack[write package file instead of object file]' \ + '-r[debug generated wrappers]' \ + '-race[enable race detector]' \ + '-s[warn about composite literals that can be simplified]' \ + '-shared[generate code that can be linked into a shared library]' \ + '-trimpath[remove prefix from recorded source file paths]:prefix' \ + '-u[reject unsafe code]' \ + '-v[increase debug verbosity]' \ + '-w[debug type checking]' \ + '-wb[enable write barrier (default 1)]' \ + '-x[debug lexer]' \ + '-y[debug declarations in canned imports (with -d)]' \ + '*:file:_files -g "*.go(-.)"' + ;; + + cover) + if (( CURRENT == 2 )); then + _arguments \ + '-func=[output coverage profile information for each function]:string' \ + '-html=[generate HTML representation of coverage profile]:file:_files' \ + '-mode=[coverage mode]:mode:(set count atomic)' + return + fi + + _arguments \ + '-o[file for output]:file' \ + '-var=[name of coverage variable to generate]:var' \ + '*:file:_files -g "*.go(-.)"' + ;; + + doc) + _arguments \ + '-c[respect case when matching symbols]' \ + '-cmd[treat a command (package main) like a regular package]' \ + '-u[show docs for unexported and exported symbols and methods]' \ + ;; + + fix) + _arguments \ + '-diff[display diffs instead of rewriting files]' \ + '-force[force fixes to run even if the code looks updated]:string' \ + '-r[restrict the rewrites]:string' \ + '*:files:_files' + ;; + + link) + _arguments \ + '-B[add an ELF NT_GNU_BUILD_ID note when using ELF]:note' \ + '-C[check Go calls to C code]' \ + '-D[set data segment address (default -1)]:address' \ + '-E[set entry symbol name]:entry' \ + '-H[set header type]:type' \ + '-I[use linker as ELF dynamic linker]:linker' \ + '-L[add specified directory to library path]:directory' \ + '-R[set address rounding quantum (default -1)]:quantum' \ + '-T[set text segment address (default -1)]:address' \ + '-V[print version and exit]' \ + '-W[disassemble input]' \ + '-X[add string value definition]:definition' \ + '-a[disassemble output]' \ + '-buildid[record id as Go toolchain build id]:id' \ + '-buildmode[set build mode]:mode' \ + '-c[dump call graph]' \ + '-cpuprofile[write cpu profile to file]:file' \ + '-d[disable dynamic executable]' \ + '-extld[use linker when linking in external mode]:linker' \ + '-extldflags[pass flags to external linker]:flags' \ + '-f[ignore version mismatch]' \ + '-g[disable go package data checks]' \ + '-h[halt on error]' \ + '-installsuffix[set package directory suffix]:suffix' \ + '-k[set field tracking symbol]:symbol' \ + '-linkmode[set link mode]:mode:(internal external auto)' \ + '-linkshared[link against installed Go shared libraries]' \ + '-memprofile[write memory profile to file]:file' \ + '-memprofilerate[set runtime.MemProfileRate to rate]:rate' \ + '-n[dump symbol table]' \ + '-o[write output to file]:file' \ + '-r[set the ELF dynamic linker search path to dir1:dir2:...]:path' \ + '-race[enable race detector]' \ + '-s[disable symbol table]' \ + '-shared[generate shared object (implies -linkmode external)]' \ + '-tmpdir[use directory for temporary files]:directory' \ + '-u[reject unsafe packages]' \ + '-v[print link trace]' \ + '-w[disable DWARF generation]' \ + '*:files:_files' + ;; + + objdump) + _arguments \ + '-s[only dump symbols matching this regexp]:regexp' \ + '*:files:_files' + ;; + + pack) + _arguments '1:ops:(c p r t x)' '::verbose:(v)' ':files:_files' + ;; + + pprof) + _arguments \ + '-callgrind[outputs a graph in callgrind format]' \ + '-disasm=[output annotated assembly]:p' \ + '-dot[outputs a graph in DOT format]' \ + '-eog[visualize graph through eog]' \ + '-evince[visualize graph through evince]' \ + '-gif[outputs a graph image in GIF format]' \ + '-gv[visualize graph through gv]' \ + '-list=[output annotated source for functions matching regexp]:p' \ + '-pdf[outputs a graph in PDF format]' \ + '-peek=[output callers/callees of functions matching regexp]:p' \ + '-png[outputs a graph image in PNG format]' \ + '-proto[outputs the profile in compressed protobuf format]' \ + '-ps[outputs a graph in PS format]' \ + '-raw[outputs a text representation of the raw profile]' \ + '-svg[outputs a graph in SVG format]' \ + '-tags[outputs all tags in the profile]' \ + '-text[outputs top entries in text form]' \ + '-top[outputs top entries in text form]' \ + '-tree[outputs a text rendering of call graph]' \ + '-web[visualize graph through web browser]' \ + '-weblist=[output annotated source in HTML]:p' \ + '-output=[generate output on file f (stdout by default)]:f' \ + '-functions[report at function level (default)]' \ + '-files[report at source file level]' \ + '-lines[report at source line level]' \ + '-addresses[report at address level]' \ + '-base[show delta from this profile]:profile' \ + '-drop_negative[ignore negative differences]' \ + '-cum[sort by cumulative data]' \ + '-seconds=[length of time for dynamic profiles]:n' \ + '-nodecount=[max number of nodes to show]:n' \ + '-nodefraction=[hide nodes below *total]:f' \ + '-edgefraction=[hide edges below *total]:f' \ + '-sample_index[index of sample value to display]' \ + '-mean[average sample value over first value]' \ + '-inuse_space[display in-use memory size]' \ + '-inuse_objects[display in-use object counts]' \ + '-alloc_space[display allocated memory size]' \ + '-alloc_objects[display allocated object counts]' \ + '-total_delay[display total delay at each region]' \ + '-contentions[display number of delays at each region]' \ + '-mean_delay[display mean delay at each region]' \ + '-runtime[show runtime call frames in memory profiles]' \ + '-focus=[restricts to paths going through a node matching regexp]:r' \ + '-ignore=[skips paths going through any nodes matching regexp]:r' \ + '-tagfocus=[restrict to samples tagged with key:value matching regexp]:r' \ + '-tagignore=[discard samples tagged with key:value matching regexp]' \ + '-call_tree[generate a context-sensitive call tree]' \ + '-unit=[convert all samples to unit u for display]:u' \ + '-divide_by=[scale all samples by dividing them by f]:f' \ + '-buildid=[override build id for main binary in profile]:id' \ + '-tools=[search path for object-level tools]:path' \ + '-help[help message]' \ + '*:files:_files' + ;; + + trace) + _arguments \ + '-http=[HTTP service address]:addr' \ + '*:files:_files' + ;; + + vet) + _arguments \ + '-all[check everything]' \ + '-asmdecl[check assembly against Go declarations]' \ + '-assign[check for useless assignments]' \ + '-atomic[check for common mistaken usages of the sync/atomic]' \ + '-bool[check for mistakes involving boolean operators]' \ + '-buildtags[check that +build tags are valid]' \ + '-composites[check that composite literals used field-keyed elements]' \ + '-compositewhitelist[use composite white list]' \ + '-copylocks[check that locks are not passed by value]' \ + '-methods[check that canonically named methods are canonically defined]' \ + '-nilfunc[check for comparisons between functions and nil]' \ + '-printf[check printf-like invocations]' \ + '-printfuncs[print function names to check]:string' \ + '-rangeloops[check that range loop variables are used correctly]' \ + '-shadow[check for shadowed variables]' \ + '-shadowstrict[whether to be strict about shadowing]' \ + '-shift[check for useless shifts]' \ + '-structtags[check that struct field tags have canonical format]' \ + '-tags[list of build tags to apply when parsing]:list' \ + '-test[for testing only: sets -all and -shadow]' \ + '-unreachable[check for unreachable code]' \ + '-unsafeptr[check for misuse of unsafe.Pointer]' \ + '-unusedfuncs[list of functions whose results must be used]:string' \ + '-unusedresult[check for unused result of calls to functions in -unusedfuncs]' \ + '-unusedstringmethods[list of methods whose results must be used]:string' \ + '-v[verbose]' \ + '*:files:_files' + ;; + + yacc) + _arguments \ + '-o[output]:output' \ + '-v[parsetable]:parsetable' \ + '*:files:_files' + ;; + esac + ;; + esac + ;; + + version) + _arguments \ + '-m[print each executable embedded module version information]' \ + '-v[report unrecognized files]' \ + '*:files:_files' + ;; + + + vet) + _arguments \ + '-n[print commands that would be executed]' \ + '-x[prints commands as they are executed]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + work) + local -a work_commands + work_commands=( + 'edit:edit go.work from tools or scripts' + 'init:initialize workspace file' + 'sync:sync workspace build list to modules' + 'use:add modules to workspace file' + ) + + _arguments \ + "1: :{_describe 'command' work_commands}" \ + '*:: :->args' + + case $state in + args) + case $words[1] in + edit) + _arguments \ + ${edit_flags[@]} \ + '*-use[add use directive from the go.work set of module directories]' \ + '*-dropuse[drop use directive from the go.work set of module directories]' \ + ':go.work:_path_files -g "go.work"' + ;; + + init) + _arguments \ + '*:directory: _path_files -/' + ;; + + sync) + ;; + + use) + _arguments \ + '-r[searches recursively for modules in the argumentdirectories]' \ + '*:directory: _path_files -/' + ;; + esac + ;; + esac + ;; + + + help) + local -a topics + topics=( + 'buildconstraint:build constraints' + 'buildmode:build modes' + 'c:calling between Go and C' + 'cache:build and test caching' + 'environment:environment variables' + 'filetype:file types' + 'go.mod:the go.mod file' + 'gopath:GOPATH environment variable' + 'gopath-get:legacy GOPATH go get' + 'goproxy:module proxy protocol' + 'importpath:import path syntax' + 'modules:modules, module versions, and more' + 'module-get:module-aware go get' + 'module-auth:module authentication using go.sum' + 'packages:package lists and patterns' + 'private:configuration for downloading non-public code' + 'testflag:testing flags' + 'testfunc:testing functions' + 'vcs:controlling version control with GOVCS' + ) + + _arguments "1: :{_describe 'command' commands -- topics}" + ;; + esac + ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_google b/home/.zsh-server/plugins/zsh-completions/src/_google new file mode 100644 index 0000000..8cd6a1b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_google @@ -0,0 +1,94 @@ +#compdef google +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for googlecl (https://code.google.com/p/googlecl/) +# +# Source: https://raw.github.com/dadrc/zsh-cfg/master/completions/_google +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * dadrc (https://github.com/dadrc) +# * Ben O'Hara (https://github.com/benohara) +# +# ------------------------------------------------------------------------------ + +_google() { + # init variables + local curcontext="$curcontext" state line + typeset -A opt_args + + # init state + _arguments \ + '1: :->service'\ + '2: :->task' + + case $state in + service) + _arguments '1:service:(picasa blogger youtube docs contacts calendar finance)' + ;; + *) + case $words[2] in + picasa) + compadd "$@" get create list list-albums tag post delete + ;; + blogger) + compadd "$@" post tag list delete + ;; + youtube) + compadd "$@" post tag list delete + ;; + docs) + compadd "$@" edit delete list upload get + ;; + contacts) + compadd "$@" list list-groups add add-groups delete-groups delete + ;; + calendar) + compadd "$@" add list today delete + ;; + finance) + compadd "$@" list-txn delete-pos create-pos delete-txn create create-txn list list-pos delete + ;; + *) + esac + esac +} + +_google "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_gpgconf b/home/.zsh-server/plugins/zsh-completions/src/_gpgconf new file mode 100644 index 0000000..7cee03e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_gpgconf @@ -0,0 +1,69 @@ +#compdef gpgconf +# Copyright (c) 2021 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Description: +# Completions for gpgconf (configuration utility provided with GnuPG +# ) +# +# Authors: +# * "score" https://keybase.io/score_under + +_gpgconf_component() { + local values=( + "${(@f)$(gpgconf --list-components | perl -F: -ale 'print "${F[0]}[$F[1]]"')}" + ) + if [ "${action[2]}" = all ]; then + values+=('all[All daemon components]') + fi + + _values 'component' "${(o)values[@]}" +} + +_arguments \ + '--help[print help text]' \ + '--list-components[list all components]' \ + '--check-programs[check all programs]' \ + '--apply-defaults[apply global default values]' \ + '--list-dirs[get the configuration directories for gpgconf]' \ + '--list-config[list global configuration file]' \ + '--check-config[check global configuration file]' \ + '--query-swdb[query the software version database]' \ + '--reload[reload all or a given component]:component:_gpgconf_component all' \ + '--launch[launch a given component]:component:_gpgconf_component all' \ + '--kill[kill a given component]:component:_gpgconf_component all' \ + '--create-socketdir[create a directory for sockets below /run/user or /var/run/user]' \ + '--remove-socketdir[remove a directory created with command --create-socketdir]' \ + '--list-options[list options]:component:_gpgconf_component' \ + '--change-options[change options]:component:_gpgconf_component' \ + '--check-options[check options]:component:_gpgconf_component' \ + '--apply-profile[update configuration files using the specified file]:configuration file:_path_files' \ + '--status-fd[write status info to the specified file descriptor]:file descriptor' \ + '--homedir[specify an alternative gnupg configuration home directory]:directory:_directories' \ + '(-o --output)'{-o,--output}'[write output to the specified file]:output file:_path_files' \ + '(-v --verbose)'{-v,--verbose}'[verbose]' \ + '(-q --quiet)'{-q,--quiet}'[quiet]' \ + '(-n --dry-run)'{-n,--dry-run}'[do not make any changes]' \ + '(-r --runtime)'{-r,--runtime}'[activate changes at runtime, if possible]' diff --git a/home/.zsh-server/plugins/zsh-completions/src/_gtk-launch b/home/.zsh-server/plugins/zsh-completions/src/_gtk-launch new file mode 100644 index 0000000..a2bede4 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_gtk-launch @@ -0,0 +1,87 @@ +#compdef gtk-launch +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for gtk-launch on gtk+-3.14.8 (http://www.gtk.org/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * ncaq (version 3.14.8) +# +# ------------------------------------------------------------------------------ + +_gtk-launch() { + _arguments \ + {-h,--help}'[Show help options]' \ + --help-all'[Show all help options]' \ + --help-gtk'[Show GTK+ Options]' \ + --display='[X display to use]' \ + '1: :_applications' +} + +_applications() { + local -a applications + + for file in /usr/share/applications/*.desktop; do + applications+=`_format_entry $file` + done + + _values -w \ + 'applications' \ + $applications +} + +_format_entry() { + echo "`_remove_path_extension $1`[`_get_description $1`]" +} + +_remove_path_extension() { + # echo arg + # remove path string + # remove extension string + echo $1 | \ + sed 's/.*\///' | \ + sed 's/\.desktop//' +} + +_get_description() { + # grep --no-messages option is handling of not UTF-8 text + grep --no-messages '^Comment=\|^Exec=' $1 | \ + tr '\n' ' ' +} + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_hello b/home/.zsh-server/plugins/zsh-completions/src/_hello new file mode 100644 index 0000000..e8dafdf --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_hello @@ -0,0 +1,19 @@ +#compdef hello +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for GNU hello (https://www.gnu.org/software/hello/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Wu Zhenyu +# +# ------------------------------------------------------------------------------ + +_arguments -s '(- *)'{-h,--help}'[display this help and exit]' \ + '(- *)'{-v,--version}'[display version information and exit]' \ + {-t,--traditional}'[use traditional greeting]' \ + {-g,--greeting=}'[use TEXT as the greeting message]:TEXT' diff --git a/home/.zsh-server/plugins/zsh-completions/src/_hledger b/home/.zsh-server/plugins/zsh-completions/src/_hledger new file mode 100644 index 0000000..d6e92a7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_hledger @@ -0,0 +1,286 @@ +#compdef hledger + +# ------------------------------------------------------------------------------ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for hledger 1.10 ( http://hledger.org/ ) +# Last updated: 07.08.2018 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Valodim ( https://github.com/Valodim ) +# * fdw ( https://github.com/fdw ) +# +# ------------------------------------------------------------------------------ +# Notes +# ----- +# +# account completion depends on availability of a ~/.hledger.journal file +# +# ------------------------------------------------------------------------------ + + +local curcontext="$curcontext" curstate state line expl grp cmd ret=1 +typeset -a args +typeset -A opt_args + +args=( + '(- *)'{-h,--help}'[print help information]' + '(-f --file)'{-f,--file}'=[use a different input file]:input file:_files' + '--rules-file=[CSV conversion rules file]:rules file:_files' + '--alias=[display accounts named OLD as NEW]:alias specification' + '--anon=[anonymize accounts and payees]' + '(-b --begin)'{-b,--begin}'=[include postings/txns on or after this date]:date' + '(-e --end)'{-e,--end}'=[include postings/txns before this date]:date' + '(-D --daily)'{-D,--daily}'[multiperiod/multicolumn report by day]' + '(-W --weekly)'{-W,--weekly}'[multiperiod/multicolumn report by week]' + '(-M --monthly)'{-M,--monthly}'[multiperiod/multicolumn report by month]' + '(-Q --quarterly)'{-Q,--quarterly}'[multiperiod/multicolumn report by quarter]' + '(-Y --yearly)'{-Y,--yearly}'[multiperiod/multicolumn report by year]' + '(-p --period)'{-p,--period}'=[set start date, end date, and/or reporting interval all at once]' + '(-C --cleared)'{-C,--cleared}'[include only cleared postings/txns]' + '(-U --uncleared)'{-U,--uncleared}'[include only uncleared postings/txns]' + '(-R --real)'{-R,--real}'[include only non-virtual postings]' + '(--depth)--depth=[hide accounts/postings deeper than N]:depth' + '(-E --empty)'{-E,--empty}'[show empty/zero things which are normally omitted]' + '(-B --cost)'{-B,--cost}'[show amounts in their cost price'\''s commodity]' + '(-V --value)'{-V,--value}'[converts reported amounts to the current market value]' + '(-I --ignore-assertions)'{-I,--ignore-assertions}'[ignore any failing balance assertions]' + '--forecast=[apply periodic transaction rules to generate future transactions]' +) + +_arguments -C "$args[@]" -A "-*" \ + '(- *)--version[print version information]' \ + '--debug[show debug output]' \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + +while (( $#state )); do + curstate=$state + shift state + case $curstate in + cmds) + typeset -a cmds + cmds=( + 'accounts:show account names (a)' + 'activity:show an ascii barchart of posting counts per interval' + 'add:prompt for transactions and add them to the journal' + 'balance:show accounts and balances (b, bal)' + 'balancesheet:show a balance sheet (bs)' + 'balancesheetequity:like balancesheet, but also reports equity' + 'cashflow:show a cashflow statement (cf)' + 'check-dates:check that transactions are sorted by increasing date' + 'check-dupes:report account names having the same leaf but different prefixes' + 'close:print closing/opening transactions that bring some or all account balances to zero and back' + 'help:show any of the hledger manuals' + 'import:read new transactions added to each file since last run, and add them to the main journal file' + 'incomestatement:show an income statement (is)' + 'prices:print market price directives from the journal' + 'print:show transaction entries (p, txns)' + 'print-unique:print transactions which do not reuse an already-seen description' + 'register:show postings and running total (r, reg)' + 'register-patch:print the one posting whose transaction description is closest to the description' + 'rewrite:print all transactions, adding custom postings to the matched ones' + 'stats:show some journal statistics' + 'tags:list all the tag names used in the journal' + 'test:run built-in unit tests' + ) + _describe 'subcommands' cmds && ret=0 + ;; + args) + : $words + local cmd=$words[1] + (( $+cmd )) || return 1 + # curcontext="${curcontext%:*:*}:$service-$cmd:" + case $cmd in + accounts) + args=( + '(--declared)--declared[show account names declared with account directives]' + '(--used)--used[show account names posted to by transactions]' + '(--tree)--tree[show accounts as a tree (default in simple reports)]' + '(--flat)--flat[show accounts as a list (default in multicolumn)]' + '(--drop)--drop=[flat mode, omit N leading account name parts]:drop n' + ) + ;; + activity) + ;; + add) + args=( + '(--no-new-accounts)--no-new-accounts=[do not allow creating new accounts]' + ) + ;; + bal|balance) + args+=( + '(--change)--change[show balance change in each period (default)]' + '(--cumulative)--cumulative[show balance change accumulated across periods]' + '(-H --historical)'{-H,--historical}'[show historical ending balance in each period]' + '(--tree)--tree[show accounts as a tree (default in simple reports)]' + '(--flat)--flat[show accounts as a list (default in multicolumn)]' + '(-A --average)'{-A,--average}'[show a row average column (in multicolumn mode)]' + '(-T --row-total)'{-T,--row-total}'[show a row total column]' + '(-N --no-total)'{-N,--no-total}'[do not show the final total row]' + '(--drop)--drop=[in flat mode, omit N leading account name parts]:drop n' + '(--no-elide)--no-elide[tree mode, do not squash boring parent accounts]' + '(--format)--format=[in tree mode, use this custom line format]:custom line format' + '(-O --output-format)'{-O,--output-format}='[select the output format from txt, csv, html]:format' + '(-o --output-file)'{-o,--output-file}'=[write output to file]:file' + '(--pretty-tables)--pretty-tables[use unicode to display prettier tables]' + '(--sort-amount)--sort-amount[sort by amount instead of account code/name]' + '(--invert)--invert[display all amounts with reversed sign]' + '(--budget)--budget[show performance compared to budget goals]' + '(--show-unbudgeted)--show-unbudgeted[with --budget, show unbudgeted accounts also]' + ) + ;; + bl|balancesheet|balancesheetequity) + args+=( + '(--change)--change[show balance change in each period (default)]' + '(--cumulative)--cumulative[show balance change accumulated across periods]' + '(-H --historical)'{-H,--historical}'[show historical ending balance in each period]' + '(--tree)--tree[show accounts as a tree (default in simple reports)]' + '(--flat)--flat[show accounts as a list (default in multicolumn)]' + '(-A --average)'{-A,--average}'[show a row average column (in multicolumn mode)]' + '(-T --row-total)'{-T,--row-total}'[show a row total column]' + '(-N --no-total)'{-N,--no-total}'[do not show the final total row]' + '(--drop)--drop=[in flat mode, omit N leading account name parts]:drop n' + '(--no-elide)--no-elide[tree mode, do not squash boring parent accounts]' + '(--format)--format=[in tree mode, use this custom line format]:custom line format' + '(--sort-amount)--sort-amount[sort by amount instead of account code/name]' + ) + ;; + cashflow|cf|balancesheet|bs|incomestatement|is) + args+=( + '(--change)--change[show balance change in each period (default)]' + '(--cumulative)--cumulative[show balance change accumulated across periods]' + '(-H --historical)'{-H,--historical}'[show historical ending balance in each period]' + '(--tree)--tree[show accounts as a tree (default in simple reports)]' + '(--flat)--flat[show accounts as a list (default in multicolumn)]' + '(-A --average)'{-A,--average}'[show a row average column (in multicolumn mode)]' + '(-T --row-total)'{-T,--row-total}'[show a row total column]' + '(-N --no-total)'{-N,--no-total}'[do not show the final total row]' + '(--drop)--drop=[in flat mode, omit N leading account name parts]:drop n' + '(--no-elide)--no-elide[tree mode, do not squash boring parent accounts]' + '(--format)--format=[in tree mode, use this custom line format]:custom line format' + '(--sort-amount)--sort-amount[sort by amount instead of account code/name]' + ) + ;; + import) + args=( + '(--dry-run)--dry-run[just show the transactions to be imported]' + ) + ;; + is|incomestatement) + args+=( + '(--change)--change[show balance change in each period (default)]' + '(--cumulative)--cumulative[show balance change accumulated across periods]' + '(-H --historical)'{-H,--historical}'[show historical ending balance in each period]' + '(--tree)--tree[show accounts as a tree (default in simple reports)]' + '(--flat)--flat[show accounts as a list (default in multicolumn)]' + '(-A --average)'{-A,--average}'[show a row average column (in multicolumn mode)]' + '(-T --row-total)'{-T,--row-total}'[show a row total column]' + '(-N --no-total)'{-N,--no-total}'[do not show the final total row]' + '(--drop)--drop=[in flat mode, omit N leading account name parts]:drop n' + '(--no-elide)--no-elide[tree mode, do not squash boring parent accounts]' + '(--format)--format=[in tree mode, use this custom line format]:custom line format' + '(--sort-amount)--sort-amount[sort by amount instead of account code/name]' + ) + ;; + print) + args=( + '(-m --match)'{-m,--match}'[show the transaction whose description is most similar]:string' + '(--new)--new[show only newer-dated transactions added in each file since last run]' + '(-x --explicit)'{-x,--explicit}'[show all amounts explicitly]' + '(-O --output-format)'{-O,--output-format}='[select the output format from txt, csv, html]:format' + '(-o --output-file)'{-o,--output-file}'=[write output to file]:file' + ) + ;; + register|reg) + args+=( + '(--cumulative)--cumulative[show balance change accumulated across periods]' + '(-H --historical)'{-H,--historical}'[show historical ending balance in each period]' + '(-A --average)'{-A,--average}'[show a row average column (in multicolumn mode)]' + '(-r --related)'{-r,--related}'[show postings'\'' siblings instead]' + '(-w --width)'{-w,--width}'=[set output width to 120, or N]:width (default 80)' + '(-O --output-format)'{-O,--output-format}='[select the output format from txt, csv, html]:format' + '(-o --output-file)'{-o,--output-file}'=[write output to file]:file' + ) + ;; + stats) + args=( + '(-o --output-file)'{-o,--output-file}'=[write output to file]:file' + ) + ;; + # fallback to _default + *) _arguments -C -A "-*" "$args[@]" \ + '*: :_default' && ret=0 + continue + esac + _arguments -C -A "-*" "$args[@]" \ + '*:query patterns:->query' && ret=0 + ;; + query) + + local -a accs keywords + keywords=( + 'acct\::match account names' + 'code\::match by transaction code' + 'desc\::match transaction descriptions' + 'tag\::match by tag name' + 'depth\::match at or above depth' + 'status\::match cleared/uncleared transactions' + 'real\::match real/virtual transactions' + 'empty\::match if amount is/is not zero' + 'amt\::match transaction amount' + 'cur\::match by currency' + ) + if compset -P 'amt:'; then + _message 'match amount (<, <=, >, >=, add sign for non-absolute match)' && ret=0 + continue + fi + if compset -P '(#b)(code|desc|tag|depth|status|real|empty):'; then + _message "'$match[1]' parameter" && ret=0 + continue + fi + + accs=( ${(f)"$(_call_program hledger hledger accounts $PREFIX 2>/dev/null)"} ) + if (( $? )); then + _message "error fetching accounts from hledger" + fi + + # decided against partial matching here. these lines can + # be uncommented to complete subaccounts hierarchically + # (add -S '' -q to the compadd below, too) + # if compset -P '(#b)(*):'; then + # accs=( ${(M)accs:#$match[1]:*} ) + # accs=( ${accs#$IPREFIX} ) + # fi + # accs=( ${accs%%:*} ) + + _wanted accounts expl "accounts" compadd -a accs && ret=0 + _describe "matcher keywords" keywords -S '' && ret=0 + + # not is special, it doesn't need the -S '' + keywords=( + 'not:negate expression' + ) + _describe "matcher keywords" keywords && ret=0 + + ;; + esac +done + +return ret diff --git a/home/.zsh-server/plugins/zsh-completions/src/_homestead b/home/.zsh-server/plugins/zsh-completions/src/_homestead new file mode 100644 index 0000000..9dc1c41 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_homestead @@ -0,0 +1,53 @@ +#compdef homestead +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for homestead (http://laravel.com/docs/homestead). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * loranger (https://github.com/loranger) +# +# ------------------------------------------------------------------------------ + + +_homestead_get_command_list () { + homestead --no-ansi | sed "1,/Available commands/d" | awk '/ [a-z]+/ { print $1 }' +} + +_homestead () { + if [ -f homestead ]; then + compadd `_homestead_get_command_list` + fi +} + +compdef _homestead php homestead +compdef _homestead homestead diff --git a/home/.zsh-server/plugins/zsh-completions/src/_httpie b/home/.zsh-server/plugins/zsh-completions/src/_httpie new file mode 100644 index 0000000..015e5c0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_httpie @@ -0,0 +1,218 @@ +#compdef http https=http +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for httpie 3.2.1 (https://httpie.io/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Akira Maeda +# * Valodim +# * Claus Klingberg +# * Shohei YOSHIDA +# +# ------------------------------------------------------------------------------ + +_httpie_params() { + local ret=1 expl + + # or a url + if (( CURRENT <= NORMARG+1 )) && [[ $words[NORMARG] != *:* ]] ; then + _httpie_urls && ret=0 + + # regular param, if we already have a url + elif (( CURRENT > NORMARG )); then + + # if the suffix is precisely : this is shorthand for a header + if [[ -prefix ':' ]]; then + PREFIX= + SUFFIX=: + fi + + # if we are in front of a : (possibly due to the PREFIX move before) + if [[ -suffix ':' ]]; then + # this is rather buggy with normal tab behavior : + compstate[insert]=menu + _wanted http_header expl 'HTTP Header' \ + compadd -s ':' -S '' -- Content-Type Cookie && return 0 + fi + + # ignore all prefix stuff + compset -P '(#b)([^:@=]#)' + local name=$match[1] + + if compset -P '='; then + _message "$name data field value" + elif compset -P '@'; then + _files + elif compset -P ':=@'; then + _files + elif compset -P ':='; then + _message "$name raw json data" + elif compset -P '=='; then + _message "$name url parameter value" + elif compset -P ':'; then + _message "$name header content" + else + typeset -a ops + ops=( + '=:data field' + '\::header' + '==:request parameter' + '@:data file field' + '\:=:raw json field' + '\:=@:raw json field file path' + ) + _describe -t httpparams "parameter types" ops -Q -S '' + fi + + ret=0 + + fi + + # first arg may be a request method + (( CURRENT == NORMARG )) && + _wanted http_method expl 'Request Method' \ + compadd GET POST PUT DELETE HEAD OPTIONS TRACE CONNECT PATCH LINK UNLINK && ret=0 + + return $ret +} + +_httpie_urls() { + local ret=1 + + if ! [[ -prefix [-+.a-z0-9]#:// ]]; then + local expl + compset -S '[^:/]*' && compstate[to_end]='' + _wanted url-schemas expl 'URL schema' compadd -S '' http:// https:// && ret=0 + else + _urls && ret=0 + fi + + return $ret + +} + +_httpie_printflags() { + local ret=1 + + # not sure why this is necessary, but it will complete "-pH" style without it + [[ $IPREFIX == "-p" ]] && IPREFIX+=" " + + compset -P '(#b)([a-zA-Z]#)' + + local -a flags + [[ $match[1] != *H* ]] && flags+=( "H:request headers" ) + [[ $match[1] != *B* ]] && flags+=( "B:request body" ) + [[ $match[1] != *h* ]] && flags+=( "h:response headers" ) + [[ $match[1] != *b* ]] && flags+=( "b:response body" ) + + _describe -t printflags "print flags" flags -S '' && ret=0 + + return $ret +} + +_httpie_styles() { + local -a styles=(abap algol algol_nu arduino auto autumn borland bw + colorful default dracula emacs friendly + friendly_grayscale fruity gruvbox-dark gruvbox-light + igor inkpot lilypond lovelace manni material monokai + murphy native one-dark paraiso-dark paraiso-light + pastie perldoc pie pie-dark pie-light rainbow_dash + rrt sas solarized solarized-dark solarized-light stata + stata-dark stata-light tango trac vim vs xcode zenburn) + + _describe -t styles 'style' styles +} + +integer NORMARG + +_arguments -n -C -s \ + '(-j --json -f)'{-j,--json}'[Data items from the command line are serialized as a JSON object.]' \ + '(-f --form -j)'{-f,--form}'[Data items from the command line are serialized as form fields.]' \ + '--multipart[Similar to --form, but always sends a multipart/form-data request]' \ + '--boundary=[Specify a custom boundary string for multipart/form-data requests]' \ + '--raw=[This option allows you to pass raw request data without extra processing]' \ + '(-x --compress)'{-x,--compress}'[Content compressed with Deflate algorithm]' \ + '--pretty=[Controls output processing.]:output format:(all colors format none)' \ + '(-s --style)'{-s,--style}'=[Output coloring style]:STYLE:_httpie_styles' \ + '--unsorted[Disables all sorting while formatting output]' \ + '--sorted[Re-enables all sorting options while formatting output]' \ + '--response-charset=[Override the response encoding for terminal display purposes]' \ + '--response-mime=[Override the response mime type for coloring and formatting for the terminal]' \ + '--format-options=[Controls output formatting]' \ + '(-p --print)'{-p,--print}'=[String specifying what the output should contain]:print flags:_httpie_printflags' \ + '(-v --verbose)'{-v,--verbose}'[Print the whole request as well as the response.]' \ + '(-p -h --headers)'{-h,--headers}'[Print only the response headers.]' \ + '(-p -m --meta)'{-m,--meta}'[Print only the response metadata]' \ + '(-p -b --body)'{-b,--body}'[Print only the response body.]' \ + '--all[By default, only the final request/response is shown]' \ + '(-S --stream)'{-S,--stream}'[Always stream the output by line, i.e., behave like `tail -f`.]' \ + '(-o --output)'{-o,--output}'=[Save output to FILE.]:output file:_files' \ + '(-d --download)'{-d,--download}'=[Do not print the response body to stdout.]' \ + '(-c --continue)'{-c,--continue}'[Resume an interrupted download.]' \ + '(-q --quiet)'{-q,--quiet}'[Do not print to stdout or stderr, except for errors and warnings when provided once]' \ + '(--session-read-only)--session=[Create, or reuse and update a session.]:session name (or path)' \ + '(--session)--session-read-only=[Create or read a session without updating it form the request/response exchange.]:session name (or path)' \ + '(-a --auth)'{-a,--auth}'=[If only the username is provided (-a username)]:USER\:PASS' \ + '--auth-type=[The authentication mechanism to be used. Defaults to "basic".]:AUTH-TYPE:(basic digest bearer)' \ + '--ignore-netrc[Ignore credentials from .netrc]' \ + '--offline[Build the request and print it but do not actually send it]' \ + '--proxy=[String mapping protocol to the URL of the proxy.]:PROXY' \ + '(-F --follow)'{-F,--follow}'[Allow full redirects.]' \ + '--max-redirects=[A limit of redirects]:number:' \ + '--max-headers=[The maximum number of response headers to be read]:number:' \ + "--verify=[Enable or disable verification of ssl certificates.]:verify certificate:(yes no)" \ + '--ssl=[The desired protocol version to use]:ssl version:(ssl2.3 tls1 tls1.1 tls1.2)' \ + '--ciphers=[A string in the OpenSSL cipher list format]' \ + '--cert=[Specify a local cert to use as client side SSL certificate]:cert:_files' \ + '--cert-key=[Specify the private to key to use with SSL]:cert key:_files' \ + '--cert-key-pass=[The passphrase to be used to with the given private key]' \ + '--timeout=[Float describes the timeout of the request (Use socket.setdefaulttimeout() as fallback).]:timeout (seconds)' \ + '--check-status[This flag instructs HTTPie to also check the HTTP status code and exit with an error if the status indicates one.]' \ + '--path-as-is[Bypass dot segment URL squashing]' \ + '--chunked[Enable streaming via chunked transfer encoding]' \ + '(-I --ignore-stdin)'{-I,--ignore-stdin}'[Do not attempt to read stdin.]' \ + '(- *)--help[show help message.]' \ + '(- *)--manual[show the full manual]' \ + "(- *)--version[show program's version number and exit.]" \ + '--traceback[Prints exception traceback should one occur.]' \ + '--default-scheme=[The default scheme to use if not specified in the URL]:scheme:' \ + '--debug[Prints exception traceback should one occur and other information useful for debugging HTTPie itself.]' \ + '*:args:_httpie_params' && return 0 + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ibus b/home/.zsh-server/plugins/zsh-completions/src/_ibus new file mode 100644 index 0000000..28ae67e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ibus @@ -0,0 +1,109 @@ +#compdef ibus +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ibus 1.5.27 (https://github.com/ibus/ibus). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Tomo Kazahaya +# +# ------------------------------------------------------------------------------ + +# The completion of "ibus emoji --lang=" depends on _language_codes from +# https://github.com/zsh-users/zsh-completions. + +local context state state_descr line +typeset -A opt_args +local curcontext=$curcontext + +_arguments -C \ + ":command:(($(ibus help|sed -ne 's/^ \(\S\+\) \+\(.*\)/"\1\\:\2"/p')))" \ + '*:: :->args' \ + && return + +case $state in + args) + case $line[1] in + (engine) + _arguments \ + ":engine:(($(ibus list-engine|sed -ne 's/:/\\\\:/g' -e 's/^ \(\S\+\) - \(.*\)$/"\1:\2"/p')))" \ + && return + ;; + (start|restart) + _arguments \ + '--type=[start or restart daemon type with direct or systemd type]: :(direct systemd)' \ + '--file=[start or restart daemon with SYSTEMD_SERVICE file]: :_files' \ + '--verbose[Show debug message]' \ + '(- *)--help[Show help message]' \ + && return + ;; + (read-cache) + _arguments \ + '--system[show the content of the system registry cache]' \ + '--file=[custom registry cache to show]:registry cache:_files' \ + '(- *)--help[Show help message]' \ + && return + ;; + (write-cache) + _arguments \ + '--system[save the system registry cache]' \ + '--file=[custom registry cache to save]:registry cache:_files' \ + '(- *)--help[Show help message]' \ + && return + ;; + (emoji) + _arguments \ + '--font=[emoji font]:emoji font: ' \ + '--lang=[language of emoji annotations]:language:_language_codes ISO-639-1' \ + '--partial-match[match annotations with a partial string]' \ + '(- *)--help[Show help message]' \ + && return + ;; + (im-module) + _arguments \ + '--type=[Set im-module TYPE]: :(gtk2 gtk3 gtk4)' \ + '(- *)--help[Show help message]' \ + && return + ;; + esac + ;; +esac + +return 1 + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_include-what-you-use b/home/.zsh-server/plugins/zsh-completions/src/_include-what-you-use new file mode 100644 index 0000000..bb9902c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_include-what-you-use @@ -0,0 +1,65 @@ +#compdef include-what-you-use + +# Copyright 2018 CERN for the benefit of the LHCb Collaboration. +# All rights reserved. +# +# Developed by: +# +# CERN LBC group +# +# CERN +# +# http://cern.ch +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# with 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: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimers. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimers in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the names of the LBC group, CERN, nor the names of its +# contributors may be used to endorse or promote products derived from +# this Software without specific prior written permission. +# +# 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 +# CONTRIBUTORS 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 WITH +# THE SOFTWARE. +# +# In applying this licence, CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization or +# submit itself to any jurisdiction. + +# TODO: +# - prevent _iwyu_opts from running once the first clang option got passed + +_iwyu_opts() { + _arguments '--check_also=[print iwyu-violation info for files matching the given glob pattern]:glob pattern:' \ + '--cwd=[specify the current working directory]:current working directory:_path_files -/' \ + '--howtodebug[print instructions on how to run iwyu under gdb]' \ + '--howtodebug=[print instructions on how to run iwyu under gdb if file matches argument]:file for debug run:_path_files' \ + '*'"--mapping_file=[iwyu mapping file]:iwyu mapping file:_path_files -g '*(/) *.imp'" \ + "--no_default_mappings[do not add iwyu's default mappings]" \ + '--pch_in_code[mark the first include in a translation unit as a precompiled header]' \ + '--prefix_header_includes=[what to do with command line includes]:command line include treatment:(add keep remove)' \ + "--transitive_includes_only[do not suggest that a file add headers that aren't already visible]" \ + '--max_line_length=[maximum line length for includes]:a number:' \ + '--no_comments[do not add "why" comments]' \ + '--no_fwd_decls[do not use forward declarations]' \ + '--verbose=[the higher the level, the more output]:a number:' +} + +_arguments "*-Xiwyu[include-what-you-use options]:include-what-you-use options:_iwyu_opts" +# gcc will also provide --version and --help. Not ideal. +_gcc diff --git a/home/.zsh-server/plugins/zsh-completions/src/_inxi b/home/.zsh-server/plugins/zsh-completions/src/_inxi new file mode 100644 index 0000000..2089b8f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_inxi @@ -0,0 +1,146 @@ +#compdef inxi +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script of inxi - a full featured CLI system information tool +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Oleksii Filonenko +# +# ------------------------------------------------------------------------------ + +local colors=($(seq 0 42)) +local verbosity_levels=( + '0:Short output, same as: inxi' + '1:Basic verbose, -S + basic CPU' + '2:Adds -N, -M, -B, same as: inxi -b' + '3:Adds -C, -n, -x' + '4:Adds -P, -D' + '5:Adds -A, -m, -s, -l, -u' + '6:Adds -p, -o, -d, --usb, -xx' + '7:Adds -i, -xxx' + '8:Adds -r, --slots, -tcm, --admin' +) +local alt_downloaders=( + '40:Perl' + '41:Curl' + '42:Fetch' + '43:Wget' + '44:Curl, Fetch, and Wget' +) +local partition_sort_orders=( + 'dev-base:/dev partition identifier' + 'fs:partition filesystem' + 'id:mount point of partition (default)' + 'label:label of partition' + 'percent-used:percentage of partition size used' + 'size:KiB size of partition' + 'uuid:UUID of the partition' + 'used:KiB used of partition' +) + +_arguments -s \ + {-A,--audio}"[Show Audio/sound card(s) information]" \ + {-b,--basic}"[Show basic output, short form]" \ + {-B,--battery}"[Show system Battery information]" \ + {-c+,--color=}"[Set color scheme]:color:(${colors[*]})" \ + {-C,--cpu}"[Show full CPU output]" \ + {-d,--disk-full,--optical}"[Show hard + optical drive info]" \ + {-D,--disk}"[Show hard Disk info]" \ + {-f,--flags}"[Show all CPU flags used]" \ + {-F,--full}"[Show Full output]" \ + {-G,--graphics}"[Show Graphic card(s) information]" \ + "(- *)"{-h,--help}"[Show list of command-line options]" \ + {-i,--ip}"[Show WAN IP address and local interfaces]" \ + {-I,--info}"[Show Information: processes, uptime, etc.]" \ + {-l,--label}"[Show partition labels]" \ + {-m,--memory}"[Memory (RAM) data]" \ + {-M,--machine}"[Show Machine data]" \ + {-n,--network-advanced}"[Show Advanced Network card information]" \ + {-N,--network}"[Show Network card(s) information]" \ + {-o,--unmounted}"[Show unmounted partition information]" \ + {-p,--partitions-full}"[Show full Partition information]" \ + {-P,--partitions}"[Show basic Partition information]" \ + {-r,--repos}"[Show distro repository data]" \ + {-R,--raid}"[Show RAID data]" \ + "(- *)"--recommends"[Check inxi dependencies + recommends]" \ + {-s,--sensors}"[Show output from configured sensors]" \ + --slots"[Show PCI slots]" \ + {-S,--system}"[Show System information]" \ + {-t+,--processes=}"[Show processes]:processes:((c\:'CPU only' m\:'Memory only' cm\:'CPU+memory'))" \ + --usb"[Show USB data for attached Hubs and Devices]" \ + {-u,--uuid}"[Show partition UUIDs]" \ + "(- *)"{-U,--update}"[Auto-update inxi]" \ + "(- *)"{-V,--version}"[Show version of inxi]" \ + {-v+,--verbosity=}"[Script verbosity levels]:verbosity:->verbosity" \ + {-w,--weather}"[Adds weather line]" \ + {-W+,--weather-location=}"[Get weather/time for an alternate location]:weather location: " \ + --weather-unit="[Set weather unit]:weather unit:((m\:metric i\:imperial mi\:'metric (imperial)' im\:'imperial (metric)'))" \ + {-y+,--width=}"[Set width override]:columns (80 minimum): " \ + {-z,--filter}"[Adds security filters]" \ + {-Z,--filter-override}"[Absolute override for output filters]" \ + \*{-x,--extra}"[Extra data options]" \ + {-a,--admin}"[Admin extra data options]:admin option:->admin" \ + --alt"[Bypass a downloader option]:downloader:->alt" \ + --display"[Get display data out of X]:\:: " \ + --dmidecode"[Force use of dmidecode]" \ + --downloader"[Force inxi to use a specific downloader]:downloader:(curl fetch perl wget)" \ + --host"[Turns on hostname in System line]" \ + --indent-min"[Overrides default indent minimum value]:integer: " \ + --limit"[Limit max IP addresses for -i]:limit (-1 removes the limit): " \ + --man"[Updates / install man page with -U]" \ + --no-host"[Turns off hostname in System line]" \ + --no-man"[Disables man page install with -U]" \ + --no-ssl"[Skip SSL certificate checks]" \ + --output"[Change data output type]:type:(json screen xml)" \ + --output-file"[Path to output file]:output file:->output_file" \ + --partition-sort"[Change default sort order of partition output]:order:->partition_sort" \ + --sleep"[Change CPU sleep time]:sleep time (usually in decimals): " \ + --tty"[Forces internal IRC flag to off]" \ + --usb-sys"[Forces the USB data generator to use /sys as data source]" \ + --usb-tool"[Forces the USB data generator to use lsusb as data source]" \ + --wan-ip-url"[Force -i to use supplied URL as WAN ip source]:URL: " \ + --wm"[Force System item wm to use wmctrl as data source]" \ + --dbg"[Debug downloader failures]:level:(1)" \ + --debug"[On screen debugger output]:level:(1 2 3 10 11 20 21 22)" \ + --ftp"[Set alternate ftp upload location]:FTP URL: " \ + --debug-proc"[Force debugger to parse /proc directory data when run as root]" \ + --debug-proc-print"[Use this to locate file that /proc debugger hangs on]" \ + --debug-no-exit"[Skip exit on error when running debugger]" \ + --debug-no-proc"[Skip /proc debugging in case of a hang]" \ + --debug-no-sys"[Skip /sys debugging in case of a hang]" \ + --debug-sys"[Force PowerPC debugger parsing of /sys as sudo/root]" \ + --debug-proc"[Force debugger to parse /proc directory data when run as root]" \ + --debug-sys-print"[Use this to locate file that /sys debugger hangs on]" + +case "$state" in + admin) + _arguments -s \ + -C"[Adds CPU family, model-id, and stepping]" \ + -d"[Adds logical and physical block size in bytes]" \ + {-p,-P}"[Adds raw partition / filesystem block size]" + ;; + alt) + _describe 'downloader' alt_downloaders + ;; + output_file) + _alternative \ + "outputs:output file:((print\:'Print to stdout'))" \ + "outputs:output file:_files" + ;; + partition_sort) + _describe 'sort order' partition_sort_orders + ;; + verbosity) + _describe 'script verbosity level' verbosity_levels + ;; +esac + +# Local Variables: +# mode: shell-script +# sh-shell: zsh +# End: diff --git a/home/.zsh-server/plugins/zsh-completions/src/_jmeter b/home/.zsh-server/plugins/zsh-completions/src/_jmeter new file mode 100644 index 0000000..27a6086 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_jmeter @@ -0,0 +1,58 @@ +#compdef jmeter +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for JMeter (http://jakarta.apache.org/jmeter). +# +# Status: incomplete +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_arguments \ + '(- 1 *)--?[print command line options and exit]' \ + '(- 1 *)'{-h,--help}'[print usage information and exit]' \ + '(- 1 *)'{-v,--version}'[print the version information and exit]' \ + {-p,--propfile}'[the jmeter property file to use]:properties file:_files -g "*.properties"' \ + '*'{-q,--addprop}'[additional property file(s)]:properties file:_files -g "*.properties"' \ + {-t,--testfile}'[the jmeter test plan file to run]:JMeter test plan file:_files -g "*.jmx"' \ + {-j,--jmeterlogfile}'[the jmeter log file]: :_files -g "*.log"' \ + {-l,--logfile}'[the file to log samples to]: :_files -g "*.jtl"' \ + {-i,--jmeterlogconf}'[jmeter logging configuration file]: :_files -g "*.xml"' \ + {-j,--jmeterlogfile}'[jmeter run file]: :_files -g "*.log"' \ + {-n,--nongui}'[run JMeter in nongui mode]' \ + {-s,--server}'[run the JMeter server]' \ + {-E,--proxyScheme}'[set a proxy scheme to use for the proxy server]:scheme' \ + {-H,--proxyHost}'[set a proxy server for JMeter to use]: :_hosts' \ + {-P,--proxyPort}'[set proxy server port for JMeter to use]:number' \ + {-N,--nonProxyHosts}'[set non proxy host list]:host' \ + {-u,--username}'[set username for proxy server that JMeter is to use]:username:_users' \ + {-a,--password}'[set password for proxy server that JMeter is to use]:password' \ + {-J-,--jmeterproperty}'[define additional JMeter properties]:argument=value' \ + {-G-,--globalproperty}'[define Global properties (sent to servers)]:argument=value' \ + {-D-,--systemproperty}'[define additional System properties]:argument=value' \ + {-S,--systemPropertyFile}'[a property file to be added as System properties]:properties file:_files -g "*.properties"' \ + {-f,--forceDeleteResultFile}'[force delete existing results files and web report folder]' \ + {-L,--loglevel}'[define loglevel]:[category=]level' \ + {-r,--runremote}'[start remote servers (as defined by the jmeter property remote_hosts)]' \ + {-R,--remotestart}'[start these remote servers (overrides remote_hosts)]:remote servers list' \ + {-d,--homedir}'[the JMeter home directory to use]: :_files -/' \ + {-X,--remoteexit}'[exit the remote servers at end of test (non-GUI)]' \ + {-g,--removeonly}'[generate report dashboard only, from a test results file]: :_files' \ + {-e,--reportatendofloadtests}'[generate report dashboard after load test]' \ + {-o,--reportoutputfolder}'[output folder for report dashboard]: :_files -/' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_jmeter-plugins b/home/.zsh-server/plugins/zsh-completions/src/_jmeter-plugins new file mode 100644 index 0000000..3253896 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_jmeter-plugins @@ -0,0 +1,42 @@ +#compdef jmeter-plugins +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for jmeter-plugins command line tool 0.4.2 +# (http://code.google.com/p/jmeter-plugins). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_arguments \ + '(- 1 *)--help[show help options]' \ + '--generate-png[generate PNG file containing graph]:PNG file name:_files -g "*.png"' \ + '--generate-csv[generate CSV file containing graph data]:CSV file name:_files -g "*.csv"' \ + '--input-jtl[load data from specified JTL file]:JTL file:_files -g "*.jtl"' \ + '--plugin-type[type of graph to use for results generation]:class:((AggregateReport ThreadsStateOverTime BytesThroughputOverTime HitsPerSecond LatenciesOverTime PerfMon ResponseCodesPerSecond ResponseTimesDistribution ResponseTimesOverTime ResponseTimesPercentiles ThroughputOverTime ThroughputVsThreads TimesVsThreads TransactionsPerSecond))' \ + '--width[set graph width]:graph width (pixels)' \ + '--height[set graph height]::graph height (pixels)' \ + '--granulation[granulation time for samples]:time (ms)' \ + '--relative-times[use relative X axis times, no will set absolute times]: :((yes no))' \ + '--aggregate-rows[aggregate all rows into one]: :((yes no))' \ + '--paint-gradient[paint gradient background]: :((yes no))' \ + '--paint-zeroing[paint zeroing lines]: :((yes no))' \ + '--prevent-outliers[prevent outliers on distribution graph]: :((yes no))' \ + '--limit-rows[limit number of points in row]:number of points' \ + '--force-y[force Y axis limit]:limit' \ + '--hide-low-counts[hide points with sample count below limit]:limit' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_jonas b/home/.zsh-server/plugins/zsh-completions/src/_jonas new file mode 100644 index 0000000..2a72b3d --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_jonas @@ -0,0 +1,100 @@ +#compdef jonas +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for JOnAS 5.2 (http://jonas.ow2.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +typeset -A opt_args +local context state line curcontext="$curcontext" ret=1 + +_arguments -C \ + '1:cmd:->cmds' \ + '*::arg:->args' \ +&& ret=0 + +case "$state" in + (cmds) + local commands; commands=( + 'version:show version information' + 'check:check that the JOnAS environment is correctly set' + 'start:start a server instance' + 'stop:stop a server instance' + 'admin:administrate a server instance' + ) + _describe -t commands 'command' commands && ret=0 + ;; + (args) + curcontext="${curcontext%:*:*}:jonas-cmd-$words[1]:" + case $words[1] in + (version|check) + _message 'no more arguments' && ret=0 + ;; + (start) + _arguments \ + '-standby[start a minimal JOnAS server with only mandatory services]' \ + '(-bg)-fg[start the server in foreground mode]' \ + '(-fg)-bg[start the server in background mode]' \ + '-win[start the server in a new window]' \ + '(-bg)-tui[start the Apache Felix TUI (force foreground mode)]' \ + '-gui[start the Apache Felix GUI]' \ + '-dev[start a JOnAS server by using bundles present in the default maven repository instead of bundles under $JONAS_ROOT/lib/bundles]' \ + '-clean[clean the Apache Felix cache before starting a JOnAS server]' \ + '-n[set the server name, must be unique in the domain (default: jonas)]:name' \ + '-target[start another server or cluster (group of servers) in the domain]:server' \ + '-Ddomain.name=[set the name of the management domain to which the server belongs]:domain' \ + && ret=0 + ;; + (stop) + _arguments \ + '-standby[stop all services except the mandatory ones]' \ + '-n[set the name of the server to stop (default: jonas)]:name' \ + '-target[stop another server or cluster (group of servers) in the domain]:server' \ + '-Ddomain.name=[set the name of the management domain to which the server belongs]:domain' \ + && ret=0 + ;; + (admin) + _arguments \ + '(- : *)-?[print the help message]' \ + '-win[administer the server in a new window]' \ + '-n[set the name of the server to administer (default: jonas)]:name' \ + '-username[set the username when authentication is required]: :_users' \ + '-password[set the password when authentication is required]:password' \ + '-registry[set the registry URL]: :_urls' \ + '-protocol[set the protocol name]:protocol:((jrmp\:JRE\ implementation\ of\ RMI\ on\ the\ JRMP\ protocol\ \(default\) iiop\:JacORB\ implementation\ of\ RMI\ over\ the\ IIOP\ protocol irmi\:Oracle\ JRE\ independent\ implementation\ of\ RMI))' \ + '-a[deploy an application from a given filepath on the current server, or on another target in the domain if the current server is a master]:Java application archive:_files -g "*.(j|w|r|e)ar"' \ + '-r[undeploy a previously deployed application from the current server or from the specified target if the current server is a master]:Java application archive:_files -g "*.(j|w|r|e)ar"' \ + '-gc[run the garbage collector on the current JOnAS server]' \ + '-passivate[passivate all entity bean instances]' \ + '-e[list the properties of the current JOnAS server]' \ + '-j[list the registered JNDI names, as seen by the current JOnAS server]' \ + '-l[list the beans currently loaded by the current JOnAS server]' \ + '-synch[synchronize the entity bean instances on the current JOnAS server]' \ + '-debug[set the logging level for the given topic to DEBUG]:topic' \ + '-tt[change the default timeout for transactions]:timeout (seconds)' \ + '-ping[wait until the JOnAS server is available]' \ + '-timeout[maximum time to wait when -ping is used]:timeout (seconds)' \ + && ret=0 + ;; + esac + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_jrnl b/home/.zsh-server/plugins/zsh-completions/src/_jrnl new file mode 100644 index 0000000..e1bc185 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_jrnl @@ -0,0 +1,66 @@ +#compdef jrnl +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for jrnl a simple journal application for your command line. (https://maebert.github.io/jrnl/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_jrnl() { + + _arguments -C \ + '(- 1 *)'-h"[Show help and exit]" \ + '(- 1 *)'-v"[Prints version information and exits]" \ + '(- 1 *)'-ls"[Displays accessible journals]" \ + '(- 1 *)'-d"[Execute in debug mode]" \ + '(- 1 *)'--tags"[Returns a list of all tags and number of occurrences]" \ + "--short[Show only titles or line containing the search]" \ + "-from[View entries after this date]:date:" \ + "-until[View entries before this date]:date:" \ + "-to[View entries before this date]:date:" \ + "-on[View entries on this date]:date:" \ + "-and[Filter by tags using AND (default: OR)]" \ + "-starred[Show only starred entries]" \ + "-n[Shows the last n entries matching the filter. And '-3' have the same effect.]":number: \ + "--export[Export your journal. TYPE can be json, markdown text.]:format:(json markdown text)" \ + "-o[Optionally specifies output file when using --export If OUTPUT is a directory, exports each entry in individual file instead.]:output file:" \ + "--encrypt[Encrypts your existing journal with a new pass]" \ + "--decrypt[Decrypts your journal and stores it in plain text]" \ + "--edit[Opens your editor to edit the selected entries.]" \ +} + +_jrnl + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_kak b/home/.zsh-server/plugins/zsh-completions/src/_kak new file mode 100644 index 0000000..19faeee --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_kak @@ -0,0 +1,78 @@ +#compdef kak +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for kak 2022.10.31 (https://github.com/mawww/kakoune) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Frank LENORMAND +# +# ------------------------------------------------------------------------------ + +_kak_sessions() { + local -a session_ids expl + session_ids=($(_call_program session_names kak -l)) + _description session-ids expl "session name" + compadd "$expl[@]" -a session_ids +} + +_kak() { + _arguments \ + '-c[connect to given session]:session_id:_kak_sessions' \ + '-e[execute argument on client initialization phase]:keys' \ + '-E[execute argument on server initialization]:keys' \ + "-n[do not load the system's kakrc]" \ + '-s[set the current session name]:session_id' \ + '-d[run as a headless session (requires -s)]' \ + '-p[just send stdin as commands to the given session]:session_id:_kak_sessions' \ + "-f[enter in 'filter mode':select the whole file, then execute keys]:keys" \ + '-i[backup the files on which a filter is applied using the given suffix]:suffix' \ + '-q[in filter mode, do not print any errors]' \ + '-ui[set the type of user interface to use (ncurses, dummy, or json)]:ui_type:(ncurses dummy json)' \ + '-l[list existing sessions]:session_id:_kak_sessions' \ + '-clear[clear dead sessions]' \ + '-debug[initial debug option value]:arg' \ + '(- *)-version[display Kakoune version and quit]' \ + '-ro[readonly mode]' \ + '(- *)-help[display a help message and quit]' \ + '*::files:_files' +} + +_kak "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_kitchen b/home/.zsh-server/plugins/zsh-completions/src/_kitchen new file mode 100644 index 0000000..55f59f6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_kitchen @@ -0,0 +1,86 @@ +#compdef kitchen +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Test Kitchen (http://kitchen.ci/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Peter Eisentraut (https://github.com/petere) +# * Shohei YOSHIDA (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + + +_kitchen() { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments '1: :->cmds'\ + '2: :->args' + + case $state in + cmds) + _kitchen_commands + ;; + args) + case $line[1] in + converge|create|destroy|diagnose|list|setup|test|verify) + compadd 'all' + _kitchen_instances + ;; + login) + _kitchen_instances + ;; + esac + ;; + esac +} + +_kitchen_commands() { + local commands + + commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) .*# \(.*\)$/\1:\2/p')}") + _describe -t commands 'kitchen commands' commands +} + +_kitchen_instances() { + if [[ $_kitchen_instances_cache_dir != $PWD ]]; then + unset _kitchen_instances_cache + fi + if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then + _kitchen_instances_cache=(${(f)"$(_call_program instances $service list -b 2>/dev/null)"}) + _kitchen_instances_cache_dir=$PWD + fi + _wanted instances expl 'instance' compadd -a _kitchen_instances_cache +} + +_kitchen "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_knife b/home/.zsh-server/plugins/zsh-completions/src/_knife new file mode 100644 index 0000000..dc839ef --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_knife @@ -0,0 +1,324 @@ +#compdef knife +# ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Chef's knife (http://www.opscode.com/chef). +# +# Source: https://github.com/ohmyzsh/ohmyzsh/blob/22fed4f/plugins/knife/_knife +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Frank Louwers (https://github.com/franklouwers) +# * Mark Cornick (https://github.com/markcornick) +# +# ------------------------------------------------------------------------------ + + +# You can override the path to knife.rb and your cookbooks by setting +# KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb +# KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks +# If you want your local cookbooks path to be calculated relative to where you are then +# set the below option +# KNIFE_RELATIVE_PATH=true +# Read around where these are used for more detail. + +# knife has a very special syntax, some example calls are: +# knife status +# knife cookbook list +# knife role show ROLENAME +# knife data bag show DATABAGNAME +# knife role show ROLENAME --attribute ATTRIBUTENAME +# knife cookbook show COOKBOOKNAME COOKBOOKVERSION recipes + +# The -Q switch in compadd allow for completions of things like "data bag" without having to go through two rounds of completion and avoids zsh inserting a \ for escaping spaces +_knife() { + # These flags should be available everywhere according to man knife + local -a knife_general_flags; knife_general_flags=(--help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes) + + local curcontext="$curcontext" state line + typeset -A opt_args + local -a cloudproviders; cloudproviders=(bluebox ec2 rackspace slicehost terremark) + _arguments \ + '1: :->knifecmd' \ + '2: :->knifesubcmd' \ + '3: :->knifesubcmd2' \ + '4: :->knifesubcmd3' \ + '5: :->knifesubcmd4' \ + '6: :->knifesubcmd5' + + case $state in + knifecmd) + compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment user index node recipe role search solo ssh status upload vault windows "$cloudproviders[@]" + ;; + knifesubcmd) + case $words[2] in + bluebox|ec2|rackspace|slicehost|terremark) + compadd "$@" server images + ;; + client) + compadd -Q "$@" "bulk delete" list create show delete edit reregister + ;; + configure) + compadd "$@" client + ;; + cookbook) + compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload + ;; + diff) + _arguments '*:file or directory:_files -g "*"' + ;; + environment) + compadd -Q "$@" list create delete edit show "from file" + ;; + user) + compadd -Q "$@" create delete edit list reregister show + ;; + node) + compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete" + ;; + recipe) + compadd "$@" list + ;; + role) + compadd -Q "$@" "bulk delete" create delete edit "from file" list show + ;; + solo) + compadd "$@" bootstrap clean cook init prepare + ;; + upload) + _arguments '*:file or directory:_files -g "*"' + ;; + vault) + compadd -Q "$@" create decrypt delete edit remove "rotate all keys" "rotate keys" show update + ;; + windows) + compadd "$@" bootstrap + ;; + *) + _arguments '2:Subsubcommands:($(_knife_options1))' + ;; + esac + ;; + knifesubcmd2) + case $words[3] in + server) + compadd "$@" list create delete + ;; + images) + compadd "$@" list + ;; + site) + compadd "$@" vendor show share search download list unshare + ;; + show|delete|edit|update) + _arguments '3:Subsubcommands:($(_knife_list_remote "$words[2]"))' + ;; + upload|test) + _arguments '3:Subsubcommands:($(_call_function - "_knife_list_local_$words[2]s") --all)' + ;; + list) + compadd -a "$@" knife_general_flags + ;; + bag) + compadd -Q "$@" show edit list "from file" create delete + ;; + bootstrap|clean|cook|prepare) + compadd "$@" nodes/*.json(N:t:r) + ;; + init) + compadd "$@" ./*(/N:t) + ;; + *) + _arguments '3:Subsubcommands:($(_knife_options2))' + ;; + esac + ;; + knifesubcmd3) + case "$words[3]" in + show) + case "$words[2]" in + cookbook) + versioncomp=1 + _arguments '4:Cookbookversions:($(_knife_cookbook_versions) latest)' + ;; + node|client|role) + compadd "$@" --attribute + ;; + vault) + _arguments '4:Keys:($(_knife_list_remote "$words[2]" "$words[4]"))' + ;; + esac + ;; + update) + case "$words[2]" in + vault) + _arguments '4:Keys:($(_knife_list_remote "$words[2]" "$words[4]"))' + ;; + esac + ;; + esac + case "$words[4]" in + show|edit) + _arguments '4:Subsubsubcommands:($(_knife_list_remote "$words[2]" "$words[3]"))' + ;; + file) + case "$words[2]" in + environment) + _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_knife_root)/environments"' + ;; + node) + _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_knife_root)/nodes"' + ;; + role) + _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_knife_root)/roles"' + ;; + *) + _arguments '*:Subsubcommands:($(_knife_options3))' + ;; + esac + ;; + list) + compadd -a "$@" knife_general_flags + ;; + *) + _arguments '*:Subsubcommands:($(_knife_options3))' + ;; + esac + ;; + knifesubcmd4) + if ((versioncomp > 0)); then + compadd "$@" attributes definitions files libraries providers recipes resources templates + else + case "$words[5]" in + file) + _arguments '*:directory:_path_files -/ -W "$(_knife_root)/data_bags" -qS \ ' + ;; + *) _arguments '*:Subsubcommands:($(_knife_options2))' ;; + esac + fi + ;; + knifesubcmd5) + case "$words[5]" in + file) + _arguments '*:files:_path_files -g "*.json" -W "$(_knife_root)/data_bags/$words[6]"' + ;; + *) + _arguments '*:Subsubcommands:($(_knife_options3))' + ;; + esac + ;; + esac +} + +# Helper functions to provide the argument completion for several depths of commands +_knife_options1() { + local line + for line in $(_call_program commands knife "$words[2]" --help | grep -v "^knife"); do + echo $line | grep "\-\-" + done +} + +_knife_options2() { + local line + for line in $(_call_program commands knife "$words[2]" "$words[3]" --help | grep -v "^knife"); do + echo $line | grep "\-\-" + done +} + +_knife_options3() { + local line + for line in $(_call_program commands knife "$words[2]" "$words[3]" "$words[4]" --help | grep -v "^knife"); do + echo $line | grep "\-\-" + done +} + +# get a list of objects of type x on the server +_knife_list_remote() { + case "$*" in + role|client|node|cookbook|"cookbook site"|"data bag"|environment|user|vault) + _call_program commands knife "$@" list --format json \ + | grep \" \ + | awk '{print $1}' \ + | awk -F"," '{print $1}' \ + | awk -F"\"" '{print $2}' + ;; + "vault "*) + _call_program commands knife vault show "$2" --format json \ + | grep \" \ + | awk '{print $1}' \ + | awk -F"," '{print $1}' \ + | awk -F"\"" '{print $2}' + ;; + esac +} + +# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server +_knife_list_local_cookbooks() { + if [ $KNIFE_RELATIVE_PATH ]; then + local cookbook_path="$(_knife_root)/cookbooks" + else + local knife_rb="${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}" + if [ -f ./.chef/knife.rb ]; then + knife_rb="./.chef/knife.rb" + fi + local cookbook_path="${KNIFE_COOKBOOK_PATH:-$(grep -s cookbook_path "$knife_rb" | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' | cut -d '"' -f2)}" + fi + + local i + for i in $cookbook_path; do + ls $i + done +} + +# This function extracts the available cookbook versions on the chef server +_knife_cookbook_versions() { + _call_program commands knife cookbook show "$words[4]" \ + | grep -v "$words[4]" \ + | grep -v -E '\]|\[|\{|\}' \ + | sed 's/ //g' \ + | sed 's/"//g' +} + +# Searches up from current directory to find the closest folder that has a .chef folder +# Useful for the knife upload/from file commands +_knife_root() { + local directory="$PWD" + while [ $directory != '/' ]; do + test -e "$directory/.chef" && echo "$directory" && return + directory="${directory:h}" + done +} + +_knife "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_language_codes b/home/.zsh-server/plugins/zsh-completions/src/_language_codes new file mode 100644 index 0000000..ef9d25a --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_language_codes @@ -0,0 +1,250 @@ +#autoload +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completer for language codes. +# +# Usage: _language_codes ISO-639-1 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +(( $+functions[_language_codes_iso_639_1] )) || +_language_codes_iso_639_1() { + local codes; codes=( + 'aa:Afar' + 'ab:Abkhazian' + 'af:Afrikaans' + 'ak:Akan' + 'sq:Albanian' + 'am:Amharic' + 'ar:Arabic' + 'an:Aragonese' + 'hy:Armenian' + 'as:Assamese' + 'av:Avaric' + 'ae:Avestan' + 'ay:Aymara' + 'az:Azerbaijani' + 'ba:Bashkir' + 'bm:Bambara' + 'eu:Basque' + 'be:Belarusian' + 'bn:Bengali' + 'bh:Bihari languages' + 'bi:Bislama' + 'bo:Tibetan' + 'bs:Bosnian' + 'br:Breton' + 'bg:Bulgarian' + 'my:Burmese' + 'ca:Catalan' + 'cs:Czech' + 'ch:Chamorro' + 'ce:Chechen' + 'zh:Chinese' + 'cu:Church Slavic' + 'cv:Chuvash' + 'kw:Cornish' + 'co:Corsican' + 'cr:Cree' + 'cy:Welsh' + 'cs:Czech' + 'da:Danish' + 'de:German' + 'dv:Divehi' + 'nl:Dutch' + 'dz:Dzongkha' + 'el:Greek, Modern (1453-)' + 'en:English' + 'eo:Esperanto' + 'et:Estonian' + 'eu:Basque' + 'ee:Ewe' + 'fo:Faroese' + 'fa:Persian' + 'fj:Fijian' + 'fi:Finnish' + 'fr:French' + 'fy:Western Frisian' + 'ff:Fulah' + 'ka:Georgian' + 'de:German' + 'gd:Gaelic' + 'ga:Irish' + 'gl:Galician' + 'gv:Manx' + 'gn:Guarani' + 'gu:Gujarati' + 'ht:Haitian' + 'ha:Hausa' + 'he:Hebrew' + 'hz:Herero' + 'hi:Hindi' + 'ho:Hiri Motu' + 'hr:Croatian' + 'hu:Hungarian' + 'hy:Armenian' + 'ig:Igbo' + 'is:Icelandic' + 'io:Ido' + 'ii:Sichuan Yi' + 'iu:Inuktitut' + 'ie:Interlingue' + 'ia:Interlingua (International Auxiliary Language Association)' + 'id:Indonesian' + 'ik:Inupiaq' + 'is:Icelandic' + 'it:Italian' + 'jv:Javanese' + 'ja:Japanese' + 'kl:Kalaallisut' + 'kn:Kannada' + 'ks:Kashmiri' + 'ka:Georgian' + 'kr:Kanuri' + 'kk:Kazakh' + 'km:Central Khmer' + 'ki:Kikuyu' + 'rw:Kinyarwanda' + 'ky:Kirghiz' + 'kv:Komi' + 'kg:Kongo' + 'ko:Korean' + 'kj:Kuanyama' + 'ku:Kurdish' + 'lo:Lao' + 'la:Latin' + 'lv:Latvian' + 'li:Limburgan' + 'ln:Lingala' + 'lt:Lithuanian' + 'lb:Luxembourgish' + 'lu:Luba-Katanga' + 'lg:Ganda' + 'mk:Macedonian' + 'mh:Marshallese' + 'ml:Malayalam' + 'mi:Maori' + 'mr:Marathi' + 'ms:Malay' + 'mk:Macedonian' + 'mg:Malagasy' + 'mt:Maltese' + 'mn:Mongolian' + 'mi:Maori' + 'ms:Malay' + 'my:Burmese' + 'na:Nauru' + 'nv:Navajo' + 'nr:Ndebele, South' + 'nd:Ndebele, North' + 'ng:Ndonga' + 'ne:Nepali' + 'nl:Dutch' + 'nn:Norwegian Nynorsk' + 'nb:Bokmål, Norwegian' + 'no:Norwegian' + 'ny:Chichewa' + 'oc:Occitan (post 1500)' + 'oj:Ojibwa' + 'or:Oriya' + 'om:Oromo' + 'os:Ossetian' + 'pa:Panjabi' + 'fa:Persian' + 'pi:Pali' + 'pl:Polish' + 'pt:Portuguese' + 'ps:Pushto' + 'qu:Quechua' + 'rm:Romansh' + 'ro:Romanian' + 'ro:Romanian' + 'rn:Rundi' + 'ru:Russian' + 'sg:Sango' + 'sa:Sanskrit' + 'si:Sinhala' + 'sk:Slovak' + 'sk:Slovak' + 'sl:Slovenian' + 'se:Northern Sami' + 'sm:Samoan' + 'sn:Shona' + 'sd:Sindhi' + 'so:Somali' + 'st:Sotho, Southern' + 'es:Spanish' + 'sq:Albanian' + 'sc:Sardinian' + 'sr:Serbian' + 'ss:Swati' + 'su:Sundanese' + 'sw:Swahili' + 'sv:Swedish' + 'ty:Tahitian' + 'ta:Tamil' + 'tt:Tatar' + 'te:Telugu' + 'tg:Tajik' + 'tl:Tagalog' + 'th:Thai' + 'bo:Tibetan' + 'ti:Tigrinya' + 'to:Tonga (Tonga Islands)' + 'tn:Tswana' + 'ts:Tsonga' + 'tk:Turkmen' + 'tr:Turkish' + 'tw:Twi' + 'ug:Uighur' + 'uk:Ukrainian' + 'ur:Urdu' + 'uz:Uzbek' + 've:Venda' + 'vi:Vietnamese' + 'vietnamien' + 'vo:Volapük' + 'cy:Welsh' + 'wa:Walloon' + 'wo:Wolof' + 'xh:Xhosa' + 'yi:Yiddish' + 'yo:Yoruba' + 'za:Zhuang' + 'zh:Chinese' + 'zu:Zulu' + ) + _describe -t language-codes 'ISO 639-1 language code' codes "$@" +} + +_language_codes() { + local command="$argv[$#]" ret=1 + + case $command in + ISO-639-1) + _language_codes_${${command//-/_}:l} "${@[1,-2]}" && ret=0 + ;; + *) + _message "unknown command: $command" + ;; + esac + + return ret +} + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_lilypond b/home/.zsh-server/plugins/zsh-completions/src/_lilypond new file mode 100644 index 0000000..920f075 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_lilypond @@ -0,0 +1,134 @@ +#compdef lilypond +# ------------------------------------------------------------------------------ +# Copyright (c) 2021 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for lilypond 2.22.2 (https://lilypond.org/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Andre Kugland (https://github.com/kugland) +# +# ------------------------------------------------------------------------------ + +_arguments -C -S -A "-*" \ + '(- 1 *)-dhelp[show help for scheme options]' \ + '(- 1 *)'{-h,--help}'[show usage information]' \ + '(- 1 *)'{-v,--version}'[show version number]' \ + '(- 1 *)'{-w,--warranty}'[show warranty and copyright]' \ + '(-f --formats)'{-f,--formats=}'[select format(s) to generate]:format(s) to generate:_sequence compadd - pdf svg png ps eps' \ + '--pdf[generate .pdf files]' \ + '--svg[generate .svg files]' \ + '--png[generate .png files]' \ + '--ps[generate .ps files]' \ + '(-E --eps)'{-E,--eps}'[generate .eps files]' \ + '(-O --pspdfopt)'{-O,--pspdfopt=}'[set .ps/.pdf optimization]:.ps/.pdf optimization:(size TeX TeX-GS)' \ + '*'{-d,--define-default=}'[set scheme option]:scheme option:->scheme_opt' \ + '(-e --evaluate)'{-e,--evaluate=}'[evaluate scheme code]:scheme code' \ + '(-H --header)'{-H,--header=}'[dump header field to file]:field' \ + '*'{-I,--include=}'[append directory to include search path]:directory:_files -/' \ + '(-i --init)'{-i,--init=}'[use file as init file]:file:_files -g "*.(#i)ly(-.)"' \ + '(-j --jail)'{-j,--jail=}'[chroot to jail, become user:group and cd into dir]:jail arg (user,group,jail,dir)' \ + '(-o --output)'{-o,--output=}'[set output base filename or folder]:output base filename or folder:_files' \ + '(-l --loglevel -s --silent -V --verbose)'{-l,--loglevel=}'[set level of the log]:log level [INFO]:(NONE ERROR WARNING BASIC PROGRESS INFO DEBUG)' \ + '(-l --loglevel -s --silent -V --verbose)'{-s,--silent}'[no progress, only error messages (same as --loglevel=ERROR)]' \ + '(-l --loglevel -s --silent -V --verbose)'{-V,--verbose}'[be verbose (same as --loglevel=DEBUG)]' \ + '*:input file:_files -g "*.(#i)ly(-.)"' + +case $state in + scheme_opt) + _values 'scheme option' \ + 'anti-alias-factor[set anti-alias factor]:anti-alias-factor (1-8)' \ + 'aux-files[create .tex, .texi, .count files in the EPS backend]:aux-files:(\#t \#f)' \ + 'backend[select backend]:backend:(eps null ps scm svg)' \ + 'check-internal-types[check every property assignment for types]:check-internal-types:(\#t \#f)' \ + 'clip-systems[generate cut-out snippets of a score]:clip-systems:(\#t \#f)' \ + 'crop[match the size of the normal output to the typeset image]:crop:(\#t \#f)' \ + 'datadir[LilyPond prefix for data files]: :_files -/' \ + 'debug-gc-assert-parsed-dead[ensure that all references to parsed objects are dead]:debug-gc-assert-parsed-dead:(\#t \#f)' \ + 'debug-gc[dump memory debugging statistics]:debug-gc:(\#t \#f)' \ + 'debug-lexer[debug the flex lexer]:debug-lexer:(\#t \#f)' \ + 'debug-page-breaking-scoring[dump scores for many different page breaking configurations]:debug-page-breaking-scoring:(\#t \#f)' \ + 'debug-parser[debug the bison parser]:debug-parser:(\#t \#f)' \ + 'debug-property-callbacks[debug cyclic callback chains]:debug-property-callbacks:(\#t \#f)' \ + 'debug-skylines[debug skylines]:debug-skylines:(\#t \#f)' \ + 'delete-intermediate-files[delete unusable, intermediate PostScript files]:delete-intermediate-files:(\#t \#f)' \ + 'dump-signatures[dump output signatures of each system]:dump-signatures:(\#t \#f)' \ + 'embed-source-code[embed the source files inside the generated PDF document]:embed-source-code:(\#t \#f)' \ + 'eps-box-padding[pad left edge of the output EPS bounding box by given amount]:eps-box-padding (mm)' \ + 'font-export-dir[directory for exporting fonts as PostScript files]:font-export-dir:_files -/' \ + 'font-ps-resdir[build a subset of PostScript resource directory for embedding fonts]:font-ps-resdir' \ + 'gs-api[whether to use the Ghostscript API (read-only if not available)]:gs-api:(\#t \#f)' \ + 'gs-load-fonts[load fonts via Ghostscript]:gs-load-fonts:(\#t \#f)' \ + 'gs-load-lily-fonts[load only LilyPond fonts via Ghostscript]:gs-load-lily-fonts:(\#t \#f)' \ + 'gs-never-embed-fonts[make Ghostscript embed only TrueType fonts and no other font format]:gs-never-embed-fonts:(\#t \#f)' \ + 'gui[run LilyPond from a GUI and redirect stderr to a log file]:gui:(\#t \#f)' \ + 'help[show this help]:help:(\#t \#f)' \ + 'include-book-title-preview[include book titles in preview images]:include-book-title-preview:(\#t \#f)' \ + 'include-eps-fonts[include fonts in separate-system EPS files]:include-eps-fonts:(\#t \#f)' \ + 'include-settings[included file before the score is processed]:include-settings:_files -g "*.(#i)ly(-.)"' \ + 'job-count[process in parallel, using the given number of jobs]:job-count' \ + 'log-file[output log to file (.log will be appended)]:log-file' \ + 'max-markup-depth[maximum depth for the markup tree]:max-markup-depth' \ + 'midi-extension[set the default file extension for MIDI output]:midi-extension:(mid midi)' \ + 'music-font-encodings[use font encodings and the PostScript "show" operator with music fonts]:music-font-encodings:(\#t \#f)' \ + 'music-strings-to-paths[convert text strings to paths when glyphs belong to a music font]:music-strings-to-paths:(\#t \#f)' \ + 'outline-bookmarks[use bookmarks in table of contents metadata]:outline-bookmarks:(\#t \#f)' \ + 'paper-size[set default paper size]:paper-size:(\"a1\" \"a2\" \"a3\" \"a4\" \"a5\" \"a6\" \"b1\" \"b2\" \"b3\" \"b4\" \"b5\" \"b6\" \"c1\" \"c2\" \"c3\" \"c4\" \"c5\" \"c6\" \"f4\" \"government-legal\" \"government-letter\" \"imperial\" \"junior-legal\" \"ledger\" \"legal\" \"letter\" \"folio\" \"octavo\" \"quarto\" \"tabloid\")' \ + 'pixmap-format[set GhostScript'\''s output format for pixel images]:pixmap-format:(fpng jpeg jpegcmyk jpeggray png16m pngalpha pnggray pngmonod)' \ + 'png-height[image height for PNG output]:png-height (pixels)' \ + 'png-width[image width for PNG output]:png-width (pixels)' \ + 'point-and-click[add point & click links to PDF and SVG output]:point-and-click:(\#t \#f)' \ + 'preview[create preview images also]:preview:(\#t \#f)' \ + 'print-pages[print pages in the normal way]:print-pages:(\#t \#f)' \ + 'profile-property-accesses[keep statistics of get_property() calls]:profile-property-accesses:(\#t \#f)' \ + 'protected-scheme-parsing[continue when errors in inline Scheme are caught in the parser]:protected-scheme-parsing:(\#t \#f)' \ + 'read-file-list[specify file which contains a list of input files]:read-file-list:(\#t \#f)' \ + 'relative-includes[look for the included file relative to the current file]:relative-includes:(\#t \#f)' \ + 'resolution[set resolution for generating PNG pixmaps to given value]:resolution (dpi)' \ + 'safe[run in safer mode]:safe:(\#t \#f)' \ + 'separate-log-files[use separate log files for each input]:separate-log-files:(\#t \#f)' \ + 'show-available-fonts[list available font names]:show-available-fonts:(\#t \#f)' \ + 'strict-infinity-checking[force a crash on encountering Inf and NaN floating point exceptions]:strict-infinity-checking:(\#t \#f)' \ + 'strip-output-dir[don'\''t use directories from input files while constructing output file names]:strip-output-dir:(\#t \#f)' \ + 'strokeadjust[set the PostScript '\''strokeadjust'\'' operator explicitly]:strokeadjust:(\#t \#f)' \ + 'svg-woff[use woff font files in SVG backend]:svg-woff:(\#t \#f)' \ + 'verbose[verbose output]:verbose:(\#t \#f)' \ + 'warning-as-error[change all warning and programming_error messages into errors]:warning-as-error:(\#t \#f)' + ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_lunchy b/home/.zsh-server/plugins/zsh-completions/src/_lunchy new file mode 100644 index 0000000..4c327b7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_lunchy @@ -0,0 +1,138 @@ +#compdef lunchy +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for lunchy 0.10.4 (https://github.com/mperham/lunchy). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Blake Walters (https://github.com/markupboy) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +_lunchy() { + local state line cmds ret=1 + + _arguments -C \ + '1: :->cmds' \ + '*::arg:->args' && ret=0 + + case $state in + cmds) + local -a cmds + cmds=( + 'ls:Show the list of installed agents, with optional filter' + 'list:Show the list of installed agents, with optional filter' + 'start:Start the first agent matching pattern' + 'stop:Stop the first agent matching pattern' + 'restart:Stop and start the first agent matching pattern' + 'status:Show the PID and label for all agents, with optional filter' + 'install:Install an agents plist file to ~/Library/LaunchAgents or /Library/LaunchAgents' + 'uninstall:Uninstall name from ~/Library/LaunchAgents or /Library/LaunchAgents' + 'show:Show the contents of the launchctl daemon file' + 'edit:Open the launchctl daemon file in the default editor(EDITOR environment variable)' + ) + _describe -t commands 'lunchy command' cmds && ret=0 + ;; + args) + local -a cmd_args + case $line[1] in + (ls|list) + cmd_args=( + '-l[display absolute paths of the launchctl daemon files when showing list of installed agents]' + '1:: :_lunchy_installed_agents' + ) + ;; + (start) + cmd_args=( + '-w[persist the start command, the agent will load on startup]' + '-F[force start agents]' + '1: :_lunchy_installed_agents' + ) + ;; + (stop) + cmd_args=( + '-w[persist the stop command, the agent will never load]' + '1: :_lunchy_agents' + ) + ;; + (restart) + cmd_args=( + '1: :_lunchy_agents' + ) + ;; + (install) + cmd_args=( + '-s[use a symlink for installation]' + '1: :_files' + ) + ;; + (uninstall) + cmd_args=( + '1: :_lunchy_agents' + ) + ;; + (*) + cmd_args=( + '1: :_lunchy_installed_agents' + ) + ;; + esac + + _arguments -s -S "$cmd_args[@]" && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_lunchy_agents] )) || +_lunchy_agents() { + local -a agents=(${(@f)"$(lunchy status | awk 'NR>=2{print $3}')"}) + _values 'agents' $agents +} + +(( $+functions[_lunchy_installed_agents] )) || +_lunchy_installed_agents() { + local -a agents=(${(@f)"$(lunchy ls)"}) + _values 'agents' $agents +} + +_lunchy "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_mc b/home/.zsh-server/plugins/zsh-completions/src/_mc new file mode 100644 index 0000000..64eaf00 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_mc @@ -0,0 +1,82 @@ +#compdef mc +# ------------------------------------------------------------------------------ +# Copyright (c) 2019 Sebastian Gniazdowski +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Midnight Commander 4.8.28 (https://midnight-commander.org/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sebastian Gniazdowski (https://github.com/psprint) +# ------------------------------------------------------------------------------ + +setopt localoptions warncreateglobal typesetsilent + +local -a opts +opts=( + {-h,--help}'[show help on options]' + --help-all'[show help on all options]' + --help-terminal'[terminal options help]' + --help-color'[color options help]' + {-a,--stickchars}'[use stickchars to draw]' + '(-c --color -b --nocolor)'{-b,--nocolor}'[requests to run in black and white]' + '(-b --nocolor -c --color)'{-c,--color}'[request to run in color mode]' + {-C,--colors=}'[specifies a color configuration]:arg:' + --configure-options'[print configure options]' + {-d,--nomouse}'[disable mouse support in text version]' + {-d,--debuglevel=}'[save the debug level for SMB VFS]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' + {-e,--edit=}'[edit files]:file:_files' + {-f,--datadir}'[print data directory]' + {-F,--datadir-info}'[print extended info about used data directories]' + {-g,--oldmouse}'[tries to use an old highlight mouse tracking]' + {-k,--resetsoft}'[resets soft keys on HP terminals]' + {-K,--keymap=}'[load definitions of key bindings from specified file]:file:_files' + {-l,--ftplog=}'[log ftp dialog to specified file]:file:_files' + --nokeymap"[don't load key bindings from any file, use default hardcoded keys]" + {-P,--printwd=}'[print last working directory to specified file]:file:_files' + {-s,--slow}'[to run on slow terminals]' + {-S,--skin=}'[show mc with specified skin]:skin:' + {-t,--termcap}'[tries to use termcap instead of terminfo]' + '(-U --subshell -u --nosubshell)'{-u,--nosubshell}'[disables subshell support]' + '(-u --nosubshell -U --subshell)'{-U,--subshell}'[enables subshell support (default)]' + {-v,--view=}'[launches the file viewer on a file]:file:_files' + {-V,--version}'[displays the current version]' + {-x,--xterm}'[forces xterm features]' + {-X,--no-x11}'[disable X11 support]' + '*:pane directory:_directories' +) + +_arguments -s $opts + +# Return value passes through + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_middleman b/home/.zsh-server/plugins/zsh-completions/src/_middleman new file mode 100644 index 0000000..278da39 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_middleman @@ -0,0 +1,156 @@ +#compdef middleman +# ------------------------------------------------------------------------------ +# Copyright (c) 2013 Jozef Izso, MIT License +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for middleman (http://middlemanapp.com/) +# Includes commands from middleman-blog and middleman-deploy extensions. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jozef Izso (https://github.com/jozefizso) +# +# ------------------------------------------------------------------------------ + +local ret=1 state + +local -a common_ops +common_ops=( + "--help[Display help]" +) + +typeset -A opt_args +_arguments \ + ':subcommand:->subcommand' \ + $common_ops \ + '*::options:->options' && ret=0 + +case $state in + subcommand) + local -a subcommands + subcommands=( + "article:Create a new blog article" + "build:Builds the static site for deployment" + "console:Start an interactive console in the context of your Middleman application" + "deploy:Deploy a middleman built site over rsync, ftp, sftp, or git (e.g. gh-pages on github)." + "extension:Create Middleman extension scaffold" + "init:Create new project" + "server:Start the preview server" + "upgrade:Upgrade installed bundle" + "version:Show version" + ) + + _describe -t subcommands 'middleman subcommand' subcommands && ret=0 + ;; + + options) + local -a args + args=( + $common_ops + ) + + local -a help + help=( + "--help[Display help information]" + ) + + case $words[1] in + article) + args=( + {-d,--date}"[The date to create the post with (defaults to now)]:date" + ) + ;; + + build) + args=( + "--clean[Remove orphaned files from build (Default: true)]" + "--no-clean[Disable removing orphaned files from build]" + {-g,--glob}"[Build a subset of the project]:glob" + "--verbose[Print debug messages]" + "--instrument[Print instrument messages]:instrument" + "--profile[Generate profiling report for the build]" + ) + ;; + + console) + args=( + {-e,--environment}"[The environment Middleman will run under (Default: development)]:environment" + "--verbose[Print debug messages]" + ) + ;; + + deploy) + args=( + {-b,--build-before}"[Run \`middleman build\` before the deploy step]" + ) + ;; + + extension) + args=( + "--git[Default: true]" + ) + ;; + + init) + args=( + {-T,--template}"[Use a project template: default, html5, mobile, smacss, empty. (Default: default)]:template" + "--css-dir [The path to the css files]:css_dir" + "--js-dir [The path to the javascript files]:js_dir" + "--images-dir [The path to the image files]:images_dir" + "--rack [Include a config.ru file]" + "--skip-gemfile [Don't create a Gemfile]" + "--skip-bundle [Don't run bundle install]" + "--skip-git [Skip Git ignores and keeps]" + ) + ;; + + server) + args=( + {-e,--environment}"[The environment Middleman will run under (Default: development)]:environment" + {-h,--host}"[Bind to HOST address (Default: 0.0.0.0)]:host" + {-p,--port}"[The port Middleman will listen on (Default: 4567)]:port" + "--verbose [Print debug messages]" + "--instrument [Print instrument messages]:instrument" + "--disable-watcher [Disable the file change and delete watcher process]" + "--profile [Generate profiling report for server startup]" + "--reload-paths [Additional paths to auto-reload when files change]:reload_paths" + "--force-polling [Force file watcher into polling mode]" + ) + ;; + + upgrade) + args=() + ;; + + version) + args=() + ;; + esac + + _arguments $args && ret=0 + ;; +esac + +return ret diff --git a/home/.zsh-server/plugins/zsh-completions/src/_mina b/home/.zsh-server/plugins/zsh-completions/src/_mina new file mode 100644 index 0000000..01b06f2 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_mina @@ -0,0 +1,68 @@ +#compdef mina +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Mina (http://nadarei.co/mina/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Kazuya Takeshima (https://github.com/mitukiii) +# +# ------------------------------------------------------------------------------ + + +local curcontext="$curcontext" state line cmds ret=1 + +_arguments -C \ + {-h,--help}'[Show help]' \ + {-V,--version}'[Show program version]' \ + {-v,--verbose}'[Show commands as they happen]' \ + {-s,--simulate}'[Run in simulation mode]' \ + {-t,--trace}'[Show backtraces when errors occur]' \ + -f'[Use FILE as the deploy configuration]:file:_files' \ + '*: :->cmds' && ret=0 + +case $state in + cmds) + cmds=( ${(f)"$(_call_program commands mina -T 2> /dev/null | sed -e 's/:/\\:/g; s/\[/\\[/g; s/\]/\\]/g; s/mina \([^ ]*\) .*# /\1:/g')"} ) + _describe -t commands 'mina command' cmds && ret=0 + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_mix b/home/.zsh-server/plugins/zsh-completions/src/_mix new file mode 100644 index 0000000..989adef --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_mix @@ -0,0 +1,236 @@ +#compdef mix +#autoload + +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Elixir Mix +# +# Last updated: 18.04.2017 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Han Ngo (https://github.com/tieubao) +# * Teja Sophista (https://github.com/tejanium) +# +# ------------------------------------------------------------------------------ + +local -a _1st_arguments +_1st_arguments=( + 'app.start:Starts all registered apps' + 'app.tree:Prints the application tree' + 'archive:Lists installed archives' + 'archive.build:Archives this project into a .ez file' + 'archive.install:Installs an archive locally' + 'archive.uninstall:Uninstalls archives' + 'clean:Deletes generated application files' + 'cmd:Executes the given command' + 'compile:Compiles source files' + 'deps:Lists dependencies and their status' + "deps.clean:Deletes the given dependencies' files" + 'deps.compile:Compiles dependencies' + 'deps.get:Gets all out of date dependencies' + 'deps.tree:Prints the dependency tree' + 'deps.unlock:Unlocks the given dependencies' + 'deps.update:Updates the given dependencies' + 'do:Executes the tasks separated by comma' + 'ecto:Prints Ecto help information' + 'ecto.create:Creates the repository storage' + 'ecto.drop:Drops the repository storage' + 'ecto.dump:Dumps the repository database structure' + 'ecto.gen.migration:Generates a new migration for the repo' + 'ecto.gen.repo:Generates a new repository' + 'ecto.load:Loads previously dumped database structure' + 'ecto.migrate:Runs the repository migrations' + 'ecto.migrations:Displays the repository migration status' + 'ecto.rollback:Rolls back the repository migrations' + 'escript:Lists installed escripts' + 'escript.build:Builds an escript for the project' + 'escript.install:Installs an escript locally' + 'escript.uninstall:Uninstalls escripts' + 'gettext.extract:Extracts translations from source code' + 'gettext.merge:Merge template files into translation files' + 'help:Prints help information for tasks' + 'hex:Prints Hex help information' + 'hex.build:Builds a new package version locally' + 'hex.config:Reads, updates or deletes Hex config' + 'hex.docs:Fetch or open documentation of a package' + 'hex.info:Prints Hex information' + 'hex.key:Manages Hex API key' + 'hex.outdated:Shows outdated Hex deps for the current project' + 'hex.owner:Manages Hex package ownership' + 'hex.public_keys:Manages Hex public keys' + 'hex.publish:Publishes a new package version' + 'hex.retire:Retires a package version' + 'hex.search:Searches for package names' + 'hex.user:Registers or manages Hex user' + 'loadconfig:Loads and persists the given configuration' + 'local:Lists local tasks' + 'local.hex:Installs Hex locally' + 'local.phoenix:Updates Phoenix locally' + 'local.phx:Updates the Phoenix project generator locally' + 'local.public_keys:Manages public keys' + 'local.rebar:Installs Rebar locally' + 'new:Creates a new Elixir project' + 'phoenix.gen.html:Generates controller, model and views for an HTML based resource' + 'phoenix.server:Starts applications and their servers' + 'phx.digest:Digests and compresses static files' + 'phx.digest.clean:Removes old versions of static assets.' + 'phx.gen.channel:Generates a Phoenix channel' + 'phx.gen.context:Generates a context with functions around an Ecto schema' + 'phx.gen.html:Generates controller, views, and context for an HTML resource' + 'phx.gen.json:Generates controller, views, and context for a JSON resource' + 'phx.gen.presence:Generates a Presence tracker' + 'phx.gen.schema:Generates an Ecto schema and migration file' + 'phx.gen.secret:Generates a secret' + 'phx.new:Creates a new Phoenix application' + 'phx.new.ecto:Creates a new Ecto project within an umbrella project' + 'phx.new.web:Creates a new Phoenix web project within an umbrella project' + 'phx.routes:Prints all routes' + 'phx.server:Starts applications and their servers' + 'profile.fprof:Profiles the given file or expression with fprof' + 'run:Runs the given file or expression' + "test:Runs a project's tests" + 'xref:Performs cross reference checks' + '--help:Describe available tasks' + '--version:Prints the Elixir version information' +) + +__task_list () +{ + local expl + declare -a tasks + + tasks=( + 'app.start' + 'app.tree' + 'archive' + 'archive.build' + 'archive.install' + 'archive.uninstall' + 'clean' + 'cmd' + 'compile' + 'deps' + 'deps.clean' + 'deps.compile' + 'deps.get' + 'deps.tree' + 'deps.unlock' + 'deps.update' + 'do' + 'ecto' + 'ecto.create' + 'ecto.drop' + 'ecto.dump' + 'ecto.gen.migration' + 'ecto.gen.repo' + 'ecto.load' + 'ecto.migrate' + 'ecto.migrations' + 'ecto.rollback' + 'escript' + 'escript.build' + 'escript.install' + 'escript.uninstall' + 'gettext.extract' + 'gettext.merge' + 'format' + 'help' + 'hex' + 'hex.build' + 'hex.config' + 'hex.docs' + 'hex.info' + 'hex.key' + 'hex.outdated' + 'hex.owner' + 'hex.public_keys' + 'hex.publish' + 'hex.retire' + 'hex.search' + 'hex.user' + 'loadconfig' + 'local' + 'local.hex' + 'local.public_keys' + 'local.rebar' + 'new' + 'phoenix.gen.html' + 'phoenix.server' + 'phx.digest' + 'phx.digest.clean' + 'phx.gen.channel' + 'phx.gen.context' + 'phx.gen.html' + 'phx.gen.json' + 'phx.gen.presence' + 'phx.gen.schema' + 'phx.gen.secret' + 'phx.routes' + 'phx.server' + 'profile.fprof' + 'run' + 'test' + 'xref' + ) + + _wanted tasks expl 'help' compadd $tasks +} + +local expl + +local curcontext="$curcontext" state line +typeset -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "mix subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _arguments ':feature:__task_list' + return + ;; + (test|format|run) + _arguments ':PATH:_files' + return + ;; + esac + ;; +esac diff --git a/home/.zsh-server/plugins/zsh-completions/src/_mssh b/home/.zsh-server/plugins/zsh-completions/src/_mssh new file mode 100644 index 0000000..c47a305 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_mssh @@ -0,0 +1,108 @@ +#compdef mssh +# ------------------------------------------------------------------------------ +# Copyright (c) 2020 Hyeon Kim +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# mssh is a Python client for accessing EC2 instances via AWS EC2 Instance +# Connect. +# +# References: +# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-methods.html#ec2-instance-connect-connecting-ec2-cli +# https://github.com/aws/aws-ec2-instance-connect-cli +# https://pypi.org/project/ec2instanceconnectcli/ +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hyeon Kim (https://hyeon.me/) +# +# ------------------------------------------------------------------------------ + +# Do nothing if there's no AWS CLI +if (( ! $+commands[aws] )); then + return +fi + +# Define function only when it doesn't exist +(( $+functions[_mssh_cache_policy] )) || _mssh_cache_policy() { + # Cache invalidates after 30 seconds + # + # Reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#index-globbing_002c-qualifiers + local -a oldp + oldp=( "$1"(ms+30) ) + (( $#oldp )) +} + +# Unless user explicitly turned off caching, enable caching just for this context +local existing_setting +zstyle -s ":completion:${curcontext}:" use-cache existing_setting +if [[ -z "${existing_setting}" ]]; then + zstyle ":completion:${curcontext}:" use-cache on +fi + +# Update cache policy only when there was no existing policy +local existing_policy +zstyle -s ":completion:${curcontext}:" cache-policy existing_policy +if [[ -z "${existing_policy}" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _mssh_cache_policy +fi + +local -a instances +if _cache_invalid mssh_instances || ! _retrieve_cache mssh_instances; then + # Cache is invalid or caching retrieval failed (usually due to disabled cache) + + # Store the output of the AWS CLI separately + # + # Reference: + # https://unix.stackexchange.com/a/430182 + local stderr + local -i exit_code + () { + aws ec2 describe-instances \ + --query 'Reservations[].Instances[] | [?State.Name == `running`].join(`:`, [InstanceId, Tags[?Key == `Name`].Value | [0]])' \ + --output text \ + >${1} 2>${2} + exit_code=${?} + IFS=$'\n\t' instances=($(<${1})) + stderr=$(<${2}) + } =(:) =(:) + + if (( $exit_code == 0 )); then + # AWS CLI successfully executed + _store_cache mssh_instances instances + else + # AWS CLI failed, abort autocompletion + _message -r "\ +Failed autocomplete due to following reason: +${stderr}" + return + fi +fi + +_describe 'command' instances + +# Reference: +# http://zsh.sourceforge.net/Doc/Release/Completion-System.html +# https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org diff --git a/home/.zsh-server/plugins/zsh-completions/src/_mussh b/home/.zsh-server/plugins/zsh-completions/src/_mussh new file mode 100644 index 0000000..ff2e96e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_mussh @@ -0,0 +1,86 @@ +#compdef mussh +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for MUltihost SSH Wrapper (http://mussh.sourceforge.net/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Mario Fernandez (https://github.com/sirech) +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +# TODO: +# -i: admit more than one use +# -d, -v, -t: control input +# -m: Accept number (but also empty) +# -h: Accept multiple hosts, also more than one use +# -H: Accept multiple files, also more than one use + +_arguments -C \ + '--help[display this help message]' \ + '-V[print version info and exit]' \ + '-d[Verbose debug]:level (from 0 to 2)' \ + '-v[SSH debug level]:level (from 0 to 3)' \ + '-m[Run concurrently]' \ + '(-b -B)-b[Print each hosts output in a block without mingling with other hosts output]' \ + '(-b -B)-B[Allow hosts output to mingle. (default)]' \ + '(-a -A)-a[Force loading ssh-agent]' \ + '(-a -A)-A[Do NOT load ssh-agent]' \ + '(-u -U)-u[Unique. Eliminate duplicate hosts. (default)]' \ + '(-u -U)-U[Do NOT make host list unique]' \ + '-P[Do NOT fall back to passwords on any host. This will skip hosts where keys fail]' \ + '-i[Load an identity file. May be used more than once]:identity' \ + '-o[Args to pass to ssh with -o option]:ssh-args' \ + '(-l -L)-l[Use _login_ when no other is specified with the hostname]:login' \ + '(-l -L)-L[Force use of _login_ on all hosts]:login' \ + '-s[Path to shell on remote host]:shell' \ + '-t[Timeout setting for each session]:timeout' \ + '-p[Host to use as proxy]:[user@]host' \ + '-po[Args to pass to ssh on proxy with -o option]:ssh-args' \ + '(-h -H)-h[Add a host to list of hosts]:[user@]host' \ + '(-h -H)-H[Add contents of file to list of hosts]:host file:_files' \ + '(-c -C)-c[Add a command or quoted list of commands to list of commands to be executed on each host]:command' \ + '(-c -C)-C[Add file contents to list of commands to be executed on each host]:commands file:_files' \ + '(-q)-q[No output unless necessary]' && ret=0 + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_mvn b/home/.zsh-server/plugins/zsh-completions/src/_mvn new file mode 100644 index 0000000..6f4b31c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_mvn @@ -0,0 +1,613 @@ +#compdef mvn mvnDebug +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Maven (http://maven.apache.org). +# +# Status: See FIXME and TODO tags. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ +# Notes +# ----- +# +# * By default advanced phases are displayed only if you start typing them. To have +# them always displayed: +# +# zstyle ':completion:*:mvn:*' show-all-phases true +# +# * By default full form plugins (groupId:artifactId[:version]) are only shown if you +# start typing them. To have them always displayed: +# +# zstyle ':completion:*:mvn:*' show-full-form-plugins true +# +# * By default only the plugins for which the completion has already been +# called ("mvn plugin:") are shown. To define your own list of plugins: +# +# maven_plugins=(jboss tomcat gwt android) +# zstyle ':completion:*:mvn:*' plugins $maven_plugins +# +# * To have a better presentation of completions: +# +# zstyle ':completion:*:*:mvn:*:matches' group 'yes' +# zstyle ':completion:*:*:mvn:*:options' description 'yes' +# zstyle ':completion:*:*:mvn:*:options' auto-description '%d' +# zstyle ':completion:*:*:mvn:*:descriptions' format $'\e[1m -- %d --\e[22m' +# zstyle ':completion:*:*:mvn:*:messages' format $'\e[1m -- %d --\e[22m' +# zstyle ':completion:*:*:mvn:*:warnings' format $'\e[1m -- No matches found --\e[22m' +# +# ------------------------------------------------------------------------------ + + +_mvn() { + typeset -A opt_args + local context state line + + local curcontext="$curcontext" maven_version excl_opts + + excl_opts=(-h --help -v --version -ep --encrypt-password -emp --encrypt-master-password) + + _pick_variant -r maven_version maven3='Maven 3' maven2='Maven 2' unknown --version + if [[ $maven_version == 'maven3' ]]; then + opts=( + "($excl_opts -T --threads)"{-T,--threads}'[thread count, for instance 2.0C where C is core multiplied]:thread count:_mvn_thread_counts' + "($excl_opts -t --toolchains)"{-t,--toolchains}'[alternate path for the user toolchains file]:toolchains file:_mvn_toolchains_files' + "($excl_opts -l --log-file)"{-l,--log-file}'[log file to where all build output will go]:log file:_mvn_log_files' + ) + elif [[ $maven_version == 'maven2' ]]; then + opts=( + "($excl_opts -cpu --check-plugin-updates -up --update-plugins -npu --no-plugin-updates -o --offline)"{-cpu,--check-plugin-updates,-up,--update-plugins}'[force upToDate check for any relevant registered plugins]' + "($excl_opts -npr --no-plugin-registry)"{-npr,--no-plugin-registry}'[don'\''t use plugin-registry.xml for plugin versions]' + "($excl_opts -npu --no-plugin-updates -cpu --check-plugin-updates -up --update-plugins)"{-npu,--no-plugin-updates}'[suppress upToDate check for any relevant registered plugins]' + "($excl_opts -r --reactor)"{-r,--reactor}'[dynamically build reactor from subdirectories]:reactor:_mvn_reactors' + ) + fi + + [[ -n ${(M)words:#"-pl"} || -n ${(M)words:#"--projects"} ]] && opts+=( + "($excl_opts -am --also-make)"{-am,--also-make}'[if project list is specified, also build projects required by the list]' + "($excl_opts -amd --also-make-dependents)"{-amd,--also-make-dependents}'[if project list is specified, also build projects that depend on projects on the list]' + ) + + _arguments -C \ + "(- : *)"{-h,--help}'[display help information]' \ + "(- : *)"{-v,--version}'[display version information]' \ + "(- : *)"{-emp,--encrypt-master-password}'[encrypt master security password]:master password:_mvn_passwords' \ + "(- : *)"{-ep,--encrypt-password}'[encrypt server password]:password:_mvn_passwords' \ + "($excl_opts -B --batch-mode)"{-B,--batch-mode}'[run in non-interactive (batch) mode]' \ + "($excl_opts -V --show-version)"{-V,--show-version}'[display version information without stopping build]' \ + "($excl_opts -q --quiet -X --debug)"{-q,--quiet}'[quiet output, only show errors]' \ + "($excl_opts -X --debug -q --quiet)"{-X,--debug}'[produce execution debug output]' \ + "($excl_opts -N --non-recursive)"{-N,--non-recursive}'[do not recurse into sub-projects]' \ + "($excl_opts -C --strict-checksums -c --lax-checksums)"{-C,--strict-checksums}'[fail the build if checksums don'\''t match]' \ + "($excl_opts -c --lax-checksums -C --strict-checksums)"{-c,--lax-checksums}'[warn if checksums don'\''t match]' \ + "($excl_opts -e --errors)"{-e,--errors}'[produce execution error messages]' \ + "($excl_opts -f --file)"{-f,--file}'[force the use of an alternate POM file]:POM file:_mvn_pom_files' \ + "($excl_opts -s --settings)"{-s,--settings}'[alternate path for the user settings file]:settings file:_mvn_settings_files' \ + "($excl_opts -gs --global-settings)"{-gs,--global-settings}'[alternate path for the global settings file]:global settings file:_mvn_settings_files' \ + "($excl_opts -fae --fail-at-end -ff --fail-fast -fn --fail-never)"{-fae,--fail-at-end}'[only fail the build afterwards, allow all non-impacted builds to continue]' \ + "($excl_opts -ff --fail-fast -fae --fail-at-end -fn --fail-never)"{-ff,--fail-fast}'[stop at first failure in reactorized builds]' \ + "($excl_opts -fn --fail-never -fae --fail-at-end -ff --fail-fast)"{-fn,--fail-never}'[never fail the build, regardless of project result]' \ + "($excl_opts)*"{-P,--activate-profiles}'[comma-delimited list of profiles to activate]:profile:_mvn_profiles -s ,' \ + "($excl_opts -pl --projects)"{-pl,--projects}'[build specified reactor projects instead of all projects]:project list:_mvn_projects -s ,' \ + "($excl_opts -rf --resume-from)"{-rf,--resume-from}'[resume reactor from specified project]:project:_mvn_projects' \ + "($excl_opts -o --offline -U --update-snapshots -cpu --check-plugin-updates -up --update-plugins)"{-o,--offline}'[work offline]' \ + "($excl_opts -U --update-snapshots -nsu --no-snapshot-updates -o --offline)"{-U,--update-snapshots}'[force a check for updated releases and snapshots on remote repositories]' \ + "($excl_opts -nsu --no-snapshot-updates -U --update-snapshots -o --offline)"{-nsu,--no-snapshot-updates}'[Suppress SNAPSHOT updates]' \ + "*"{-D-,--define}'[define a system property]:property:_mvn_properties' \ + "${opts[@]}" \ + "($excl_opts)*: :_mvn_args" +} + +(( $+functions[_mvn_args] )) || +_mvn_args() { + _alternative \ + 'phases:phase:_mvn_phases' \ + 'plugin-colon-goals:plugin colon goal:_mvn_plugin_colon_goals' +} + +(( $+functions[_mvn_phases] )) || +_mvn_phases() { + local phases + phases=( + 'clean:remove all files generated by the previous build' + 'compile:compile the source code of the project' + 'test:run tests using a suitable unit testing framework' + 'package:take the compiled code and package it in its distributable format, such as a JAR' + 'integration-test:process and deploy the package if necessary into an environment where integration tests can be run' + 'verify:run any checks to verify the package is valid and meets quality criteria' + 'install:install the package into the local repository, for use as a dependency in other projects locally' + 'deploy:done in an integration or release environment, copies the final package to the remote repository' + 'site:generates the projects site documentation' + 'site-deploy:deploys the generated site documentation to the specified web server' + ) + if [[ $#PREFIX -gt 0 ]] || zstyle -t ":completion:${curcontext}:" show-all-phases; then + phases+=( + 'pre-clean:executes processes needed prior to the actual project cleaning' + 'post-clean:executes processes needed to finalize the project cleaning' + 'validate:validate the project is correct and all necessary information is available' + 'initialize:initialize build state, e.g. set properties or create directories' + 'generate-sources:generate any source code for inclusion in compilation' + 'process-sources:process the source code, for example to filter any values' + 'generate-resources:generate resources for inclusion in the package' + 'process-resources:copy and process the resources into the destination directory, ready for packaging' + 'process-classes:post-process the generated files from compilation' + 'generate-test-sources:generate any test source code for inclusion in compilation' + 'process-test-sources:process the test source code, for example to filter any values' + 'generate-test-resources:create resources for testing' + 'process-test-resources:copy and process the resources into the test destination directory' + 'test-compile:compile the test source code into the test destination directory' + 'process-test-classes:post-process the generated files from test compilation' + 'prepare-package:perform any operations necessary to prepare a package before the actual packaging' + 'pre-integration-test:perform actions required before integration tests are executed' + 'post-integration-test:perform actions required after integration tests have been executed' + 'pre-site:executes processes needed prior to the actual project site generation.' + 'post-site:executes processes needed to finalize the site generation, and to prepare for site deployment' + ) + fi + _describe -t 'phases' "phase" phases +} + +(( $+functions[_mvn_plugins] )) || +_mvn_plugins() { + local ret=1 + if [[ $words[CURRENT] == *.* ]] || zstyle -t ":completion:${curcontext}:" show-full-form-plugins; then + _wanted full-form-plugins expl 'full form plugin' _mvn_full_form_plugins && ret=0 + else + _wanted plugin-prefixes expl 'plugin prefix' _mvn_plugin_prefixes && ret=0 + fi + return ret +} + +(( $+functions[_mvn_plugin_colon_goals] )) || +_mvn_plugin_colon_goals() { + local ret=1 + if [[ $words[CURRENT] == *.* ]] || zstyle -t ":completion:${curcontext}:" show-full-form-plugins; then + _wanted full-form-plugin-colon-goals expl 'full form plugin colon goal' _mvn_full_form_plugin_colon_goals && ret=0 + else + _wanted plugin-prefix-colon-goals expl 'plugin prefix colon goal' _mvn_plugin_prefix_colon_goals && ret=0 + fi + return ret +} + +(( $+functions[_mvn_plugin_prefix_colon_goals] )) || +_mvn_plugin_prefix_colon_goals() { + local ret=1 + if compset -P '*:'; then + local plugin="${IPREFIX%:}" + _wanted goals expl "${plugin} plugin goal" _mvn_plugin_goals $plugin && ret=0 + else + _wanted plugin-prefixes expl 'plugin prefix' _mvn_plugin_prefixes -qS: && ret=0 + fi + return ret +} + +(( $+functions[_mvn_plugin_prefixes] )) || +_mvn_plugin_prefixes() { + local plugins + zstyle -a ":completion:${curcontext}:" plugins plugins + [[ $#plugins -eq 0 ]] && plugins=($(__mvn_get_plugin_prefix $(__mvn_get_cache_dir)/mvn/plugins/*(:t))) + _describe -t plugin-prefixes 'plugin prefix' plugins $@ +} + +(( $+functions[_mvn_full_form_plugin_colon_goals] )) || +_mvn_full_form_plugin_colon_goals() { + local ret=1 + # FIXME Duplicates _mvn_full_form_plugins + if compset -P 1 '*:'; then + local groupId="${${IPREFIX%:}##*:}" + if compset -P 1 '*:'; then + local artifactId="${${IPREFIX%:}##*:}" + if compset -P 1 '*:'; then + local version="${${IPREFIX%:}##*:}" + _wanted goals expl "${artifactId}:${version} goal" _mvn_plugin_goals "${groupId}:${artifactId}:${version}" && ret=0 + else + _alternative \ + "versions:${artifactId} version:_mvn_artifact_versions -qS: ${groupId}:${artifactId}" \ + "goals:${artifactId} goal:_mvn_plugin_goals ${groupId}:${artifactId}" \ + && ret=0 + fi + else + _wanted artifactIds expl "${groupId} artifactId" _mvn_groupId_artifactIds -qS: $groupId && ret=0 + fi + else + _wanted groupIds expl "groupId" _mvn_groupIds -qS: && ret=0 + fi + return ret +} + +(( $+functions[_mvn_full_form_plugins] )) || +_mvn_full_form_plugins() { + local ret=1 chunk="${PREFIX%%:*}" + if compset -P 1 '*:'; then + local groupId="$chunk" + chunk="${PREFIX%%:*}" + if compset -P 1 '*:'; then + _wanted versions expl "${current} version" _mvn_artifact_versions $@ "${groupId}:${chunk}" && ret=0 + else + _wanted artifactIds expl "${groupId} artifactId" _mvn_groupId_artifactIds -qS: "${groupId}" && ret=0 + fi + else + _wanted groupIds expl "groupId" _mvn_groupIds -qS: && ret=0 + fi + return ret +} + +(( $+functions[_mvn_groupIds] )) || +_mvn_groupIds() { + local repository_location=$(__mvn_get_repository_location) update_policy ret=1 + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + [[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mvn_groupIds_caching_policy + + if [[ -d $repository_location ]]; then + unset _groupIds + if ( [[ ${+_groupIds} -eq 0 ]] || _cache_invalid "mvn/repositories/${repository_location}/groupIds" ) && ! _retrieve_cache "mvn/repositories/${repository_location}/groupIds"; then + _groupIds=($repository_location/**/) + _groupIds=(${${${(u)_groupIds:h:h}#"$repository_location/"}//\//.}) + [[ $#_groupIds -gt 0 ]] && _store_cache "mvn/repositories/${repository_location}/groupIds" _groupIds + fi + + [[ $#_groupIds -gt 0 ]] && _multi_parts $@ . _groupIds && ret=0 + fi + + return ret +} + +(( $+functions[_mvn_groupId_artifactIds] )) || +_mvn_groupId_artifactIds() { + local groupId_repository_location="${$(__mvn_get_repository_location)}/${${@[-1]}//\.//}" ret=1 + + if [[ -d $groupId_repository_location ]]; then + local artifactIds; artifactIds=($groupId_repository_location/*/*/*.pom(:h:h:t)) + _describe -t artifactIds "artifactId" artifactIds $@[0,-2] && ret=0 + fi + + return ret +} + +(( $+functions[_mvn_artifact_versions] )) || +_mvn_artifact_versions() { + local artifact_repository_location="${$(__mvn_get_repository_location)}/${${@[-1]}//[\.:]//}" ret=1 + + if [[ -d $artifact_repository_location ]]; then + local versions; versions=($artifact_repository_location/*/*.pom(:h:t)) + _describe -t versions "version" versions $@[0,-2] + fi + + return ret +} + +(( $+functions[_mvn_plugin_goals] )) || +_mvn_plugin_goals() { + local ret=1 plugin="$@[-1]" update_policy + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + [[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mvn_goals_caching_policy + + unset _goals + if ( [[ ${+_goals} -eq 0 ]] || _cache_invalid "mvn/plugins/${plugin}" ) && ! _retrieve_cache "mvn/plugins/${plugin}"; then + setopt localoptions extendedglob + _goals=(${(s:,,,:)${${${(f)${${${(f)${${${${(F)${(S)${(f)"$(_call_program goals $words[1] -N org.apache.maven.plugins:maven-help-plugin:2.1.1:describe -Dplugin=$plugin)"}//#$(__mvn_get_plugin_prefix $plugin):/,,,}}:#*BUILD FAILURE*}#*This plugin has*goals#:}%For more information, run \'mvn help:describe*}}//:/\\:}}}// ##/ }// Description\\: /:}}) + [[ $#_goals -gt 0 ]] && _store_cache "mvn/plugins/${plugin}" _goals + fi + + [[ $#_goals -gt 0 ]] && _describe -t "goals" "${plugin} goal" _goals $@[0,-2] && ret=0 + + return ret +} + +(( $+functions[_mvn_profiles] )) || +_mvn_profiles() { + + # FIXME Use "mvn help:all-profiles" output instead of parsing settings and pom files... + # Blocked on http://jira.codehaus.org/browse/MPH-82 and http://jira.codehaus.org/browse/MPH-83 + local profs update_policy settings_file=$(__mvn_get_settings_file) parent_pom_file=$(__mvn_get_parent_pom_file) cache_name profiles_section ret=1 + + # TODO Should be split into _mvn_profiles/mvn_profiles_lists + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + [[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mvn_profiles_caching_policy + + profs=() + + # Resolve profiles from settings.xml + if [[ -f $settings_file ]]; then + unset _profiles + cache_name="mvn/profiles${settings_file:A}" # FIXME Don't use A modifier, it is only available on Zsh >= 4.3.10 + if ( [[ ${+_profiles} -eq 0 ]] || _cache_invalid "$cache_name" ) && ! _retrieve_cache "$cache_name"; then + _profiles=() + profiles_section="${(M)${(f)$(<$settings_file)}:#**}" + if [[ -n "$profiles_section" ]]; then + for profile in ${(s:,,,:)${${${(S)${(S)${(S)${(S)${${profiles_section#*}%*}//*<\/repositories>}//*<\/pluginRepositories>}//*<\/build>}//<\/id>*/,,,}##*}%%*}}; do + [[ -z ${(M)profiles:#"$profile"*} ]] && _profiles+=("$profile"'['"in settings file"']') + done + fi + [[ $#_profiles -gt 0 ]] && _store_cache "$cache_name" _profiles + fi + profs+=($_profiles) + fi + + # Resolve project profiles + if [[ -f $parent_pom_file ]]; then + unset _profiles + cache_name="mvn/profiles${parent_pom_file:A}" # FIXME Don't use A modifier, it is only available on Zsh >= 4.3.10 + if ( [[ ${+_profiles} -eq 0 ]] || _cache_invalid "$cache_name" ) && ! _retrieve_cache "$cache_name"; then + _profiles=() + setopt localoptions extendedglob + for file in ${parent_pom_file:h}/**/pom.xml~*target\/*; do # FIXME project.build.directory is not always target/ + profiles_section="${(M)${(f)$(<$file)}:#**}" + if [[ -n "$profiles_section" ]]; then + for profile in ${(s:,,,:)${${${(S)${(S)${(S)${(S)${${profiles_section#*}%*}//*<\/repositories>}//*<\/pluginRepositories>}//*<\/build>}//<\/id>*/,,,}##*}%%*}}; do + [[ -z ${(M)profiles:#"$profile"*} ]] && _profiles+=("$profile"'['"in ${file#${parent_pom_file:h}\/}"']') + done + fi + done + [[ $#_profiles -gt 0 ]] && _store_cache "$cache_name" _profiles + fi + profs+=($_profiles) + fi + + compset -P '-'; compset -P '+'; compset -P '!' # FIXME Only works for the first profile + + [[ $#profs -gt 0 ]] && _values $@ 'profile' "${profs[@]}" && ret=0 + + return ret +} + +(( $+functions[_mvn_projects] )) || +_mvn_projects() { + # TODO Projects can also be given in the form [groupId:]artifactId. + # TODO Should be split into _mvn_projects/mvn_projects_lists + local pom_file=$(__mvn_get_parent_pom_file) ret=1 + + if [[ -f $pom_file ]]; then + setopt localoptions extendedglob + local projects; projects=(${pom_file:h}/*/**/pom.xml~*target\/*) # FIXME project.build.directory is not always target/ + projects=(${${projects#.\/}:h}) + [[ $#projects -gt 0 ]] && _values "$@" 'project' "${projects[@]}" && ret=0 + fi + + return ret +} + +(( $+functions[_mvn_properties] )) || +_mvn_properties() { + local ret=1 + if compset -P '*='; then + _wanted property-values expl 'property value' _mvn_property_values ${${IPREFIX%=}#-D} && ret=0 + else + _wanted property-names expl 'property name' _mvn_property_names -qS= && ret=0 + fi + return ret +} + +(( $+functions[_mvn_property_names] )) || +_mvn_property_names() { + # FIXME "-qS=" should be inherited from _mvn_properties + local alternatives; alternatives=( + "common-property-names:common property name:_mvn_common_property_names -qS=" + ) + for plugin_colon_goal in ${(M)words:#[^-]*:*}; do + alternatives+=("plugin-property-names:plugin property name:_mvn_plugin_goal_property_names -qS= ${plugin_colon_goal}") + done + _alternative "${alternatives[@]}" +} + +(( $+functions[_mvn_common_property_names] )) || +_mvn_common_property_names() { + local properties; properties=( + 'skipTests:skip tests execution' + 'maven.test.skip:skip tests compilation and execution' + 'gpg.passphrase:gpg passphrase' + 'tycho.mode:enable maven mode for Tycho projects to disable p2 resolution' + ) + _describe -t 'common-property-names' 'common property name' properties $@ +} + +(( $+functions[_mvn_plugin_goal_property_names] )) || +_mvn_plugin_goal_property_names() { + local plugin_colon_goal="$@[-1]" update_policy ret=1 + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + [[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mvn_properties_caching_policy + + unset _properties + if ( [[ ${+_properties} -eq 0 ]] || _cache_invalid "mvn/plugins/${plugin_colon_goal}" ) && ! _retrieve_cache "mvn/plugins/${plugin_colon_goal}"; then + # FIXME Does not work for: + # android:apk (new line before expression) + # ear:ear (unknown cause) + _properties=(${(M)${(ps:,,,:)${${${${(pj: :)${${${(f)${"$(_call_program properties $words[1] -N org.apache.maven.plugins:maven-help-plugin:2.1.1:describe -Dplugin=${plugin_colon_goal%:*} -Dgoal=${plugin_colon_goal##*:} -Ddetail)"#*Available parameters:}%%\[INFO\]*}//# [a-z]*/,,,}##*Expression: \$\{}}//\}[[:space:]]##/:}//[[:space:]]##/ }//[[:space:]]#,,,[[:space:]]#/,,,}}:#[a-zA-Z]##:*}) + [[ $#_properties -gt 0 ]] && _store_cache "mvn/plugins/${plugin_colon_goal}" _properties + fi + + [[ $#_properties -gt 0 ]] && _describe -t "${plugin_colon_goal//:/-}-property-names" "${plugin_colon_goal} property name" _properties $@[0,-2] && ret=0 + + return ret +} + +(( $+functions[_mvn_property_values] )) || +_mvn_property_values() { + local ret=1 + setopt localoptions extendedglob + case $@[-1] in + ((#i)*pomFile*) _wanted pom-files expl 'POM file' _mvn_pom_files && ret=0;; + ((#i)*file*) _wanted files expl 'file' _files && ret=0;; + ((#i)*groupId*) _wanted groupIds expl 'groupId' _mvn_groupIds && ret=0;; + ((#i)*artifactId*) _wanted artifactIds expl 'artifactId' _mvn_groupId_artifactIds ${${(M)${(ps.:.)opt_args[(K)-D]}:#groupId=*}#groupId=} && ret=0;; + ((#i)*version*) _wanted versions expl 'version' _mvn_artifact_versions ${${(M)${(ps.:.)opt_args[(K)-D]}:#groupId=*}#groupId=}:${${(M)${(ps.:.)opt_args[(K)-D]}:#artifactId=*}#artifactId=} && ret=0;; + ((#i)*repositoryId*) _message -e repositoryIds 'repositoryId' && ret=0;; # TODO Not implemented + ((#i)*classifier*) _message -e classifiers 'classifier' && ret=0;; + ((#i)*scope*) _wanted scopes expl 'scope' _mvn_scopes && ret=0;; + ((#i)*url*) _wanted urls expl 'url' _urls && ret=0;; # TODO Use _alternative and add repository urls from settings + projects + ((#i)*(password|passphrase)*) _wanted passwords expl password _mvn_passwords && ret=0;; + ((#i)*(createChecksum|generatePom|maven.test.skip)*) _wanted booleans expl 'boolean' _mvn_booleans && ret=0;; + ((#i)*user*) _wanted users expl 'user' _users && ret=0;; # TODO Use _alternative and add repository usernames from settings + projects + ((#i)*plugin*) _wanted plugin expl 'plugin' _mvn_plugins && ret=0;; + ((#i)*tycho.mode*) _wanted tychomodes expl 'tychomode' _mvn_tycho_modes && ret=0;; + (*) _default && ret=0;; + esac + return ret +} + +(( $+functions[_mvn_scopes] )) || +_mvn_scopes() { + local scopes; scopes=( + 'compile:default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.' + 'provided:much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.' + 'runtime:indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.' + 'test:indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.' + 'system:similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.' + 'import:only used on a dependency of type pom in the section. It indicates that the specified POM should be replaced with the dependencies in that POM'\''s section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.' + ) + _describe -t scopes 'scope' scopes +} + +(( $+functions[_mvn_thread_counts] )) || +_mvn_thread_counts() { + local thread_counts; thread_counts=( + '1:build with 1 thread' '1C:build with 1 thread per CPU core' + '2:build with 2 threads' '2C:build with 2 threads per CPU core' + '3:build with 3 threads' '3C:build with 3 threads per CPU core' + '4:build with 4 threads' '4C:build with 4 threads per CPU core' + '5:build with 5 threads' '5C:build with 5 threads per CPU core' + '6:build with 6 threads' '6C:build with 6 threads per CPU core' + '7:build with 7 threads' '7C:build with 7 threads per CPU core' + '8:build with 8 threads' '8C:build with 8 threads per CPU core' + ) + _describe -t thread-counts 'thread count' thread_counts +} + +(( $+functions[_mvn_reactors] )) || +_mvn_reactors() { + _message -e reactors 'reactor' # FIXME No idea what kind of value the "--reactor" option is supposed to take +} + +(( $+functions[_mvn_passwords] )) || +_mvn_passwords() { + _message -e passwords 'password' +} + +(( $+functions[_mvn_pom_files] )) || +_mvn_pom_files() { + _files -g '*pom*\.xml*' +} + +(( $+functions[_mvn_toolchains_files] )) || +_mvn_toolchains_files() { + _files -g '*toolchains*\.xml*' +} + +(( $+functions[_mvn_settings_files] )) || +_mvn_settings_files() { + _files -g '*settings*\.xml*' +} + +(( $+functions[_mvn_log_files] )) || +_mvn_log_files() { + _files +} + +(( $+functions[_mvn_booleans] )) || +_mvn_booleans() { + local booleans; booleans=( + 'true:"true" boolean value' + 'false:"false" boolean value' + ) + _describe -t booleans 'boolean' booleans +} + + +(( $+functions[_mvn_tycho_modes] )) || +_mvn_tycho_modes() { + local tychomodes; tychomodes=( + 'maven:maven mode, Tycho will not do any p2 dependency resolution' + ) + _describe -t tychomodes 'boolean' tychomodes +} + +# ------------------------------------------------------------------------------ +# Helper functions +# ------------------------------------------------------------------------------ + +__mvn_get_pom_file() { + print ${~opt_args[-f]:-${opt_args[--file]:-pom.xml}} +} + +__mvn_get_parent_pom_file() { + local pom_file=$(__mvn_get_pom_file) + while [[ -f ${pom_file:a:h:h}/pom.xml ]]; do + pom_file=${pom_file:a:h:h}/pom.xml; + done + print $pom_file +} + +__mvn_get_settings_file() { + print ${~opt_args[-s]:-${opt_args[--settings]:-$HOME/.m2/settings.xml}} +} + +__mvn_get_repository_location() { + print ${${${${(M)"$(<$(__mvn_get_settings_file))":#**}:-$HOME/.m2/repository}##*}%%<\/localRepository>*} +} + +__mvn_get_plugin_prefix() { + print ${${${${@#*.*:}%%:*}%-plugin}/-#maven-#} +} + +__mvn_get_cache_dir() { + local cache_dir + zstyle -s ":completion:${curcontext}:" cache-path cache_dir + print ${cache_dir:-${ZDOTDIR:-$HOME}/.zcompcache} +} + + +# ------------------------------------------------------------------------------ +# Caching policies +# ------------------------------------------------------------------------------ + +(( $+functions[_mvn_goals_caching_policy] )) || +_mvn_goals_caching_policy() { + # Rebuild if cache is older than one month. + local -a oldp + oldp=( "$1"(NmM+1) ) + (( $#oldp )) +} + +(( $+functions[_mvn_properties_caching_policy] )) || +_mvn_properties_caching_policy() { + _mvn_goals_caching_policy +} + +(( $+functions[_mvn_groupIds_caching_policy] )) || +_mvn_groupIds_caching_policy() { + _mvn_goals_caching_policy +} + +(( $+functions[_mvn_profiles_caching_policy] )) || +_mvn_profiles_caching_policy() { + # Rebuild if cached file more recent than cache. + local cached_file="${1#$(__mvn_get_cache_dir)}" + [[ -f $cached_file && $cached_file -nt "$1" ]] && return 0 + + # Rebuild if cache is older than one week. + local -a oldp + oldp=( "$1"(Nmw+1) ) + (( $#oldp )) && return 0 + + return 1 +} + +_mvn "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_nano b/home/.zsh-server/plugins/zsh-completions/src/_nano new file mode 100644 index 0000000..602443b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_nano @@ -0,0 +1,74 @@ +#compdef nano + +local curcontext="$curcontext" state line +local -i ret=1 + +_arguments -s -S -C \ + '(-)'{-A,--smarthome}'[enable smart home key]' \ + '(-B --backup)'{-B,--backup}'[save backups of existing files]' \ + '(-C --backupdir)'{-C+,--backupdir=}'[specify directory for saving unique backup files]:directory:_directories' \ + '(-D --boldtext)'{-D,--boldtext}'[use bold instead of reverse video text]' \ + '(-E --tabstospaces)'{-E,--tabstospaces}'[convert typed tabs to spaces]' \ + '(-F --multibuffer)'{-F,--multibuffer}'[read a file into a new buffer by default]' \ + '(-G --locking)'{-G,--locking}'[use vim-style lock files]' \ + '(-H --historylog)'{-H,--historylog}'[log & read search replace string history]' \ + '(-I --ignorercfiles)'{-I,--ignorercfiles}"[don't look at nanorc files]" \ + '(-J --guidestripe)'{-J+,--guidestripe=}'[show a guide bar at specified column]:number' \ + '(-K --rawsequences)'{-K,--rawsequences}'[fix numeric keypad key confusion problem]' \ + '(-L --nonewlines)'{-L,--nonewlines}"[don't add an automatic newline]" \ + '(-M --trimblanks)'{-M,--trimblanks}'[trim trailing spaces when hard-wrapping]' \ + '(-N --noconvert -u --unix)'{-N,--noconvert}"[don't convert files from DOS/Mac format]" \ + '(-O --bookstyle)'{-O,--bookstyle}'[leading whitespace means new paragraph]' \ + '(-P --positionlog)'{-P,--positionlog}'[log & read location of cursor position]' \ + '(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoted parts of lines]:regex [^([ \t]*([!#%\:;>|}]|//))+]' \ + '(-R --restricted)'{-R,--restricted}'[restricted mode]' \ + '(-S --softwrap)'{-S,--softwrap}'[display overly long lines on multiple rows]' \ + '(-T --tabsize)'{-T+,--tabsize=}'[set width of a tab]:columns [8]' \ + '(-U --quickblank -c --constantshow -_ --minibar)'{-U,--quickblank}'[do quick statusbar blanking]' \ + '(- *)'{-V,--version}'[print version information and exit]' \ + '(-W --wordbounds -X --wordchars)'{-W,--wordbounds}'[detect word boundaries more accurately]' \ + '(-X --wordchars -W --wordbounds)'{-X+,--wordchars=}'[specify which other characters are word parts]:string' \ + '(-Y --syntax=)'{-Y+,--syntax=}'[syntax definition to use for coloring]:value' \ + '(-Z --zap)'{-Z,--zap}'[let backspace and delete erase a marked region]' \ + '(-a --atblanks)'{-a,--atblanks}'[when soft-wrapping, do it at whitespace]' \ + '(-b --breaklonglines -w --nowrap)'{-b,--breaklonglines}'[automatically hard-wrap overlong lines]' \ + '(-c --constantshow -U --quickblank)'{-c,--constantshow}'[show cursor position constantly]' \ + '(-d --rebinddelete)'{-d,--rebinddelete}'[fix Backspace/Delete confusion problem]' \ + '(-e --emptyline)'{-e,--emptyline}'[keep the line below the title bar empty]' \ + '(-f --rcfile)'{-f,--rcfile=}'[Use only specified file for configuring nano]:file:_files' \ + '(-g --showcursor)'{-g,--showcursor}'[show cursor in file browser & help text]' \ + '(- *)'{-h,--help}'[show help text and exit]' \ + '(-i --autoindent)'{-i,--autoindent}'[automatically indent new lines]' \ + '(-j --jumpyscrolling)'{-j,--jumpyscrolling}'[scroll by half-screen, not by line]' \ + '(-k --cutfromcursor)'{-k,--cutfromcursor}'[cut from cursor to end of line]' \ + '(-l --linenumbers)'{-l,--linenumbers}'[show line numbers in front of the text]' \ + '(-m --mouse)'{-m,--mouse}'[enable the use of the mouse]' \ + '(-n --noread)'{-n,--noread}"[don't read the file (only write it)]" \ + '(-o --operatingdir)'{-o+,--operatingdir=}'[set operating directory]:directory:_directories' \ + '(-p --preserve)'{-p,--preserve}'[preserve XON (^Q) and XOFF (^S) keys]' \ + '(-q --indicator)'{-q,--indicator}'[show a position+portion indicator]' \ + '(-r --fill)'{-r+,--fill=}'[set width for hard-wrap and justification]:width [-8]' \ + '(-s --speller)'{-s+,--speller=}'[enable alternate speller]:program:_command_names -e' \ + '(-t --tempfile)'{-t,--tempfile}'[auto save on exit, do not prompt]' \ + '(-u --unix -N --noconvert)'{-u,--unix}'[save a file by default in Unix format]' \ + '(-v --view)'{-v,--view}'[view mode (read-only)]' \ + '(-w --nowrap -b --breaklonglines)'{-w,--nowrap}"[don't hard-wrap long lines default]" \ + '(-x --nohelp)'{-x,--nohelp}"[don't show the two help lines]" \ + '(-y --afterends)'{-y,--afterends}'[make Ctrl+Right stop at word ends]' \ + '(-z --suspend)'{-z,--suspend}'[enable suspension]' \ + '(-% --stateflags)'{-%,--stateflags}'[show some states in the title bar]' \ + '(-_ --minibar -U --quickblank)'{-_,--minibar}'[suppress the title bar and show information at the bottom of the screen]' \ + '(-! --magic)'{-\!,--magic}'[try libmagic to determine applicable syntax]' \ + '(-0 --zero)'{-0,--zero}'[Hide all bars, use whole terminal]' \ + '(-t -q)*: :->args' && ret=0 + +if [[ -n $state ]]; then + case $PREFIX in + +) _message -e lines "start at a given line" ;; + +[crCR]#[/?]) _message -e 'search string' ;; + +<->,) _message -e 'column number' ;; + *) _files && ret=0 ;; + esac +fi + +return ret diff --git a/home/.zsh-server/plugins/zsh-completions/src/_nanoc b/home/.zsh-server/plugins/zsh-completions/src/_nanoc new file mode 100644 index 0000000..7a0fb1f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_nanoc @@ -0,0 +1,162 @@ +#compdef nanoc +# ------------------------------------------------------------------------------ +# Copyright (c) 2020 OKURA Masafumi, MIT License +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for nanoc (https://nanoc.ws/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * OKURA Masafumi (https://okuramasafumi.com) +# +# This works is heavily inspired by the middleman completion by +# Jozef Izso (https://github.com/jozefizso) +# +# ------------------------------------------------------------------------------ + +local ret=1 state + +local -a common_ops +common_ops=( + {-C,--no-color}"[disable color]" + {-V,--verbose}"[make output more detailed]" + {-d,--debug}"[enable debugging]" + {-e,--env=}"[set environment]" + {-h,--help}"[show the help message and quit]" + {-l,--color}"[enable color]" + {-v,--version}"[show version information and quit]" + {-w,--warn}"[enable warnings]" +) + +typeset -A opt_args +_arguments \ + ':subcommand:->subcommand' \ + $common_ops \ + '*::options:->options' && ret=0 + +case $state in + subcommand) + local -a subcommands + subcommands=( + "check:run issue checks" + "compile:compile items of this site" + "create-site:create a site" + "deploy:deploy the compiled site" + "help:show help" + "prune:remove files not managed by Nanoc from the output directory" + "shell:open a shell on the Nanoc environment" + "show-data:show data in this site" + "show-plugins:show all available plugins" + "show-rules:describe the rules for each item" + "view:start the web server that serves static files" + ) + + _describe -t subcommands 'nanoc subcommand' subcommands && ret=0 + ;; + + options) + local -a args + args=( + $common_ops + ) + + local -a help + help=( + "--help[Display help information]" + ) + + case $words[1] in + check) + args=( + {-L,--list}"[list all checks]" + {-a,--all}"[run all checks]" + ) + ;; + + compile) + args=( + "--diff[generate diff]" + ) + ;; + + create-site) + args=( + "--force[force creation of new site]" + ) + ;; + + deploy) + args=( + {-C,--no-check}"[do not run the issue checks marked for deployment]" + {-D,--list-deployers}"[list available deployers]" + {-L,--list}"[list available locations to deploy to]" + {-n,--dry-run}"[show what would be deployed]" + {-t,--target=}"[specify the location to deploy to (default:\`default\`)]" + ) + ;; + + prune) + args=( + {-n,--dry-run}"[print files to be deleted instead of actually deleting them]" + {-y,--yes}"[confirm deletion]" + ) + ;; + + shell) + args=( + {-p,--preprocess}"[run preprocessor]" + ) + ;; + + show-data) + args=( + ) + ;; + + show-plugins) + args=( + ) + ;; + + show-rules) + args=( + ) + ;; + + view) + args=( + {-H,--handler=}"[specify the handler to use(webrick/mongrel/...)]" + {-L,--live-reload}"[reload on changes]" + {-o,--host=}"[specify the host to listen on(default: 127.0.0.1)]" + {-p,--port=}"[specify the port to listen on(default: 3000)]" + ) + ;; + esac + + _arguments $args && ret=0 + ;; +esac + +return ret diff --git a/home/.zsh-server/plugins/zsh-completions/src/_nftables b/home/.zsh-server/plugins/zsh-completions/src/_nftables new file mode 100644 index 0000000..8e6cb9b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_nftables @@ -0,0 +1,500 @@ +#compdef nft +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for nft 0.9.0 (https://www.netfilter.org/projects/nftables/index.html). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Markus Richter ( https://github.com/mqus , ) +# +# ------------------------------------------------------------------------------ +_nft(){ +local -a rules states prev args families options descriptors +local state="start" line nextstate cmd_obj cmd_subcmd cmd_fam cmd_tab cmd_chain #curcontext="$curcontext" + +options=( + '(-)'{-h,--help}'[show help]' \ + '(-)'{-v,--version}'[print version information]' \ + "(-i --interactive)"{-i,--interactive}'[read input from interactive CLI]: :->end' \ + "(-f --file)"{-f,--file}'[read input from ]:nftables rule file:_files' \ + '(-c --check -n --numeric -N)'{-c,--check}"[check command's validity without actually applying the changes]" \ + '(-j --json)'{-j,--json}'[format output in json]' \ + '(-c --check -N)*'{-n,--numeric}'[can be specified up to 3 times, Shows 1:network addresses(default behaviour), 2:internet services (port numbers) and 3:protocols, user IDs, and group IDs numerically]' \ + '(-s --stateless)'{-s,--stateless}'[omit stateful information of ruleset]' \ + '(-N -n --numeric -c --check)'-N'[translate IP addresses to names]' \ + '(-a --handle)'{-a,--handle}'[output rule handle]' \ + '(-e --echo)'{-e,--echo}'[echo what has been added, inserted or replaced]' \ + {-I,--includepath}'[add specified directory to the paths searched for include files]:include directory [/usr/share]:include directory:_directories' +) + +# start a state machine. The state is modified by _arguments if the +# current argument (descriptors) cannot be completed. Each state has to define is successive state and the +# 'descriptors' for _arguments, which essentially tells _arguments how to complete +local _i=0 +while true;do + (( _i+=1 )) + #Guard for endless loops + [[ $_i -gt 100 ]] && return 1 + + descriptors=() + nextstate="end" + case $state in + (start) + ##if line is empty (at the start) or ends with semicolon, autocomplete subcommands, + # else if we are after a space,complete a semicolon (end the current nft command) and start anew + if [[ $line[1] = "" || $line[1] =~ ';$' ]] ; then + descriptors=( ":: :_nft_subcommands" ) + nextstate="category" + else + if [[ $words =~ ' $' ]]; then + descriptors=(':: :(\;)') + else + descriptors=(':argument: ') + fi + nextstate="start" + fi + ;; + (category) + case $line[1] in + (add | list | flush | delete | create | rename | insert | replace | reset) + descriptors=( ":: :_nft_${line[1]}" ) + nextstate=$line[1] + ;; + (monitor) + descriptors=( ":: : _nft_mon_filter" ) + nextstate="mon1" + ;; + (export) + descriptors=( ":: :(ruleset)" ":: :_nft_out_format" ) + nextstate="preend" + ;; + (describe) + descriptors=( ":expression: ") + nextstate="start" #x restart + ;; + (*) + return 1; + ;; + esac + + #descriptors=( "(ruleset)" ) + #nextstate="end" + ;; + (mon1) + case $line[1] in + (new | destroy) +# descriptors=( ":: :_nft_mon_keywords" ":: :_nft_out_format") + descriptors=( ":: : _nft_mon_keywords") + nextstate="mon1" + ;; + (tables | chains | sets | rules | elements | ruleset) + descriptors=( ":: : _nft_out_format") + nextstate="preend" + ;; + esac + ;; + #all completions for create and insert match with the completions of add + (create | insert) + state="add" + ;| + #all completions for reset and flush match with the completions of list + (reset | flush) + state="list" + ;| + #(add(^table)/create(^table)/delete/flush(^ruleset)/insert/list(^ruleset)/rename/replace)[family]table + (reset | delete | insert | rename | replace | add | create | flush | list) + if [[ $state = "add" && $line[1] = "table" ]]; then + descriptors=( ":: :_nft_families" ":table name:") + nextstate="start" #x restart + elif [[ $state = "list" && ( $line[1] = "ruleset" || $line[1] = "tables" ) ]]; then + descriptors=( ":: :_nft_families") + nextstate="start" #x restart + elif [[ $state = "delete" && $line[1] = "table" ]]; then + descriptors=(": : _nft_table all-handle") + nextstate="tcomplete-delete-table" + else + cmd_obj=$line[1] + cmd_subcmd=$state + descriptors=(": : _nft_table all") + nextstate="tcomplete" + fi + ;; + (tcomplete-delete-table) + # if only a family was completed, complete the table name. + case $line[1] in + (arp | bridge | inet | ip | ip6 | netdev) + descriptors=(": : _nft_table ${line[1]}-handle") + cmd_fam=$line[1] + ;; + # if 'handle' was completed, complete the handle number. + (handle) + descriptors=(": : _nft_table_handle_all " ) + ;; + # else, complete nothing and go to the next state. default family is 'ip' + (*) + descriptors=() + cmd_fam="ip" + ;; + esac + nextstate="delete-table" + ;; + (tcomplete) + # if only a family was completed, complete the table name. + case $line[1] in + (arp | bridge | inet | ip | ip6 | netdev) + descriptors=(": : _nft_table ${line[1]}") + cmd_fam=$line[1] + ;; + # else, complete nothing and go to the next state. default family is 'ip' + (*) + descriptors=() + cmd_fam="ip" + ;; + esac + nextstate="$cmd_subcmd-$cmd_obj" + ;; + (list-table) + descriptors=(":: :(\;)") + nextstate="start" + ;; + (delete-table) + #if family AND handle were input, complete handle number for given family. + if [[ $line[1] == "handle" ]]; then + descriptors=(":table handle: _nft_table_handle $cmd_fam" ) + else + descriptors=() + fi + nextstate="start" + ;; + (delete-chain | delete-set | delete-quota | delete-counter | delete-ct\\ helper) + cmd_tab=$line[1] + descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj true") + nextstate="delete-obj-handle" + ;; + (delete-obj-handle) + if [[ $line[1] == "handle" ]]; then + descriptors=(": : _nft_object_handle $cmd_fam $cmd_tab $cmd_obj") + else + descriptors=(": :(\;)") + fi + nextstate="start" + ;; + (add-chain) + descriptors=(":chain name:") + nextstate="start" + ;; + (rename-chain) + cmd_tab=$line[1] + descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false") + nextstate="add-chain" + ;; + (replace-rule | delete-rule) + cmd_tab=$line[1] + descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false") + nextstate="repdel-rule" + ;; + (repdel-rule) + cmd_chain=$line[1] + descriptors=(": :(handle)" ": : _nft_rule_handle $cmd_fam $cmd_tab ${line[1]}") + if [[ $cmd_subcmd = "replace" ]];then + nextstate="rule-stmt" + else + nextstate="start" + fi + ;; + (add-rule) + cmd_tab=$line[1] + descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false") + nextstate="add-rule-2" + ;; + (add-rule-2) + cmd_chain=$line[1] + descriptors=(": :(handle index position)") + nextstate="add-rule-3" + ;; + (add-rule-3) + case $line[1] in + (index | position) + descriptors=(":${line[1]}:") + ;; + (handle) + descriptors=(": : _nft_rule_handle $cmd_fam $cmd_tab $cmd_chain") + ;; + (*) + descriptors=() + ;; + esac + nextstate="rule-stmt" + ;; + (rule-stmt) + #TODO + # _nft_rule $cmd_fam $cmd_tab $cmd_chain\ + # && return 0; + descriptors=":expression: " + nextstate="start" + ;; + (list-set | list-map | delete-map | list-chain | list-flowtable | delete-flowtable | list-ct\\ helper | list-counter | list-quota | list-meter) + cmd_tab=$line[1] + descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj false") + nextstate="start" + ;; + #TODO: + #(add-element | delete-element) + #(add-set | add-map) + #(add-flowtable) + #("add-ct\ helper") + #(add-counter) + #(add-quota) + + (*) + return 1; + ;; + esac + _arguments -C -s \ + "${options[@]}" \ + "${descriptors[@]}" \ + "*:: :->$nextstate" \ + && return 0; + +done +} # end _nft + +_nft_subcommands(){ + local commands=( + 'add:add a table, chain, rule, set, map, or object' + 'list:list a ruleset, table, chain, set, map, or object' + 'flush:flush (delete everything from) a ruleset, table, chain, set, or map' + 'export:print the ruleset in a machine readable format (json or xml)' + 'delete:delete a table, chain, rule, set, element, map, or object' + 'create:similar to add but returns an error for existing chain' + 'rename:rename the specified chain' + 'insert:similar to the add command, but the rule is prepended to the beginning of the chain or before the rule at the given position' + 'replace:similar to the add command, but replaces the specified rule' + 'reset:list-and-reset stateful object' + 'monitor:listen to Netlink events' + 'describe:show information about the type of an expression and its data type' + ) + _describe -t commands 'nft subcommand' commands "$@" +} +_nft_mon_filter(){ + local monitor_filters=( + 'new:show only events of created objects' + 'destroy:show only events of deleted objects' + ) + _describe -t monitor_filters 'nft monitor' monitor_filters -J monitor_filters "$@" + _nft_mon_keywords +} + +_nft_mon_keywords(){ + local monitor_keywords=( + 'tables:show table events' + 'chains:show chain events' + 'sets:show set events' + 'rules:show rule events' + 'elements:show only events of element objects' + 'ruleset:show ruleset events, such as table, chain, rule, set, counters and quotas' + ) + _describe -t monitor_keywords 'nft monitor' monitor_keywords -J monitor_keywords "$@" + _nft_out_format +} + +_nft_out_format(){ + local monitor_format=( + 'json:format output to JSON' + 'xml:format output to XML' + ) + _describe -t monitor_format "output format" monitor_format -J monitor_format "$@" +} + +_nft_add(){ + local commands=( + 'table:add a new table' + 'flowtable:add a new flowtable' + 'chain:add a chain to a table' + 'rule:add a rule to an existing chain' + 'set:add a set to a table' + 'map:add a map to a table' + 'element:add one or multiple element(s) to a set or map' + 'ct\ helper:add a ct helper to a table' + 'counter:add a named counter to a table' + 'quota:add a named quota helper to a table' + ) + _describe -t commands 'nft add' commands "$@" +} + +_nft_create(){ + local commands=( + "table:add a table, but return an error if it already exists" + "chain:add a chain to a table, but return an error if it already exists" + "flowtable:add a flowtable, but return an error if it already exists" + ) + _describe -t commands 'nft create' commands "$@" +} + +_nft_delete(){ + local commands=( + "table:delete the specified table" + "chain:delete the specified chain, chain must be empty and mustn't be used as jump target" + "rule:delete the specified rule, rule must be referable to by a handle" + "set:delete the specified set" + "map:delete the specified map" + "element:delete element(s) from the specified set/map" + "flowtable:delete the specified flowtable" + "ct\ helper:delete the specified ct helper" + "counter:delete the specified counter" + "quota:delete the specified quota" + ) + _describe -t commands 'nft delete' commands "$@" +} + +_nft_flush(){ + local commands=( + "ruleset:clear the whole ruleset, including removing all tables and containing objects" + "table:flush all chains and rules of the specified table" + "chain:flush all rules of the specified chain" + "set:remove all elements from the specified set" + "map:remove all elements from the specified map" + ) + _describe -t commands 'nft flush' commands "$@" +} + +_nft_insert(){ + local commands=( + "rule:prepend a rule to the beginning of the chain or before the rule with the given handle" + ) + _describe -t commands 'nft insert' commands "$@" +} + +_nft_list(){ + local commands=( + "ruleset:print the ruleset in human-readable format" + "tables:list all tables (undocumented)" + "table:list all chains and rules of the specified table" + "chain:list all rules of the specified chain" + "set:display the elements in the specified set" + "map:display the elements in the specified map" + "flowtable:list all flowtables" + "ct\ helper:display stateful information the ct helper holds" + "counter:display stateful information the counter holds" + "quota:display stateful information the quota holds" + ) + _describe -t commands 'nft list' commands "$@" +} + +_nft_rename(){ + local commands=( + "chain:replace a chain" + ) + _describe -t commands 'nft rename' commands "$@" +} + +_nft_replace(){ + local commands=( + "rule:replace a rule" + ) + _describe -t commands 'nft replace' commands "$@" +} + +_nft_reset(){ + local commands=( + 'ct\ helper:reset and list a ct helper to a table' + 'counter:reset and list a counter from a table' + 'quota:reset and list a quota object a table' + ) + _describe -t commands 'nft reset' commands "$@" +} +_nft_families(){ + local families=( + "ip:IPv4 address family" + "ip6:IPv6 address family" + "inet:internet (IPv4+IPv6) address family" + "arp:ARP address family, handling IPv4 ARP packets" + "bridge:Bridge address family, handling packets which traverse a bridge device" + "netdev:Netdev address family, handling packets from ingress" + ) + _describe -t families 'nft families' families "$@" +} + +_nft_table(){ + # complete the names of tables and the families of existing tables + #$1 can be: all all-handle -handle + local tables=() + if [[ "$1" =~ "^all" ]]; then + local families=( ${(f)"$(_call_program -p tables nft list tables 2>/dev/null \ + | cut -d\ -f2 )"} ) + # ip is the default family, search also for table names there + 1="${1/all/ip}" + _describe -t families "family" families -J "family" + fi + if [[ "$1" =~ "-handle$" ]]; then + tables=("handle:adress the table by handle") + #remove -handle from $1 to be able to complete table names + 1="${1/-handle/}" + _describe -t tables "table" tables -V "handle" + fi + case $1 in + (arp | bridge | inet | ip | ip6 | netdev) + tables=( ${(f)"$(_call_program -p tables nft -a list ruleset 2>/dev/null \ + | grep '^table '"$1" | sed 's/table // ;s/{ # handle // ;s/\(\S*\) \(\S*\) \(\S*\)/\2:type \1, handle \3/' )"} ) + _describe -t tables "table" tables -V "table-name" + ;; + esac +} + +_nft_table_handle(){ + # complete the handles of tables with the specified family (with the table name in the description) + #$1:protocol family + local tables=( ${(f)"$(_call_program -p tables nft -a list ruleset 2>/dev/null \ + | grep '^table '"$1" | sed 's/table // ;s/{ # handle // ;s/\(\S*\) \(\S*\) \(\S*\)/\3:\2(type \1)/' )"} ) + echo $1 > /tmp/znfttab + _describe -t tables "table handle" tables +} + +_nft_table_handle_all(){ + # complete the handles of tables of all families (with the table name in the description) + local tables=( ${(f)"$(_call_program -p tables nft -a list ruleset 2>/dev/null \ + | grep '^table' | sed 's/table // ;s/{ # handle // ;s/\(\S*\) \(\S*\) \(\S*\)/\3:\2(type \1)/' )"} ) + _describe -t tables "table handle" tables +} + +_nft_object(){ + # complete the names of objects contained directly in a table (with the handle number in the description) + #$1:protocol family + #$2:table + #$3:object type (chain/set/map/flowtable/ct helper/counter/quota/meter) + #$4:include 'handle'? + local objects=( ${(f)"$(_call_program -p objects nft -a list table $1 $2 2>/dev/null\ + | grep ""\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # \(.*\)/:(\1)/' )"} ) + if $4 ;then + objects+=( "handle:adress $3 by handle") + fi + _describe -t objects "$3" objects +} + +_nft_object_handle(){ + # complete handles of objects contained directly in a table (with the name in the description) + #$1:protocol family + #$2:table + #$3:object type (chain/set/ct helper/counter/quota) + local handles=( ${(f)"$(_call_program -p handles nft -a list table $1 $2 2>/dev/null\ + | grep ""\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # handle// ;s/\(\S*\) \(\S*\)/\2:\1/' )"} ) + _describe -t handles "$3-handle" handles +} + +_nft_rule_handle(){ + # complete the handles of rules (and put the rule into the description) + #$1:protocol family + #$2:table + #$3:chain name + local rules=( ${(f)"$(_call_program -p nft-rule-handle nft -a list chain $1 $2 $3 2>/dev/null \ + |grep -v '^\s*\(table\|chain\|type\|\}\)'|sed 's/^\s*\(.*\) # handle \(\S*\)$/\2:\1/' )"} ) + # don't sort those entries alphabetically, so they get shown in the order they are executed in nftables + _describe -t rules "rule" rules -V "rules" +} + +#currently, only the `nft` command is covered by this script. +_nft "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_node b/home/.zsh-server/plugins/zsh-completions/src/_node new file mode 100644 index 0000000..6f5387c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_node @@ -0,0 +1,192 @@ +#compdef node +# ------------------------------------------------------------------------------ +# Copyright (c) 2018 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Node.js v19.0.0 (https://nodejs.org) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Mario Fernandez (https://github.com/sirech) +# * Nicholas Penree (https://github.com/drudge) +# * Masafumi Koba (https://github.com/ybiquitous) +# * Shohei YOSHIDA (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +_node_files() { + for (( i = 2; i < CURRENT; i++)); do + if [[ ${words[i]} == "--prof-process" ]]; then + _files -g "*.log" + return + fi + done + + _files -g "*.(js|mjs)" +} + +_node_args() { + if (( CURRENT == 2 )); then + _alternative "_node_files" "_values 'command' 'inspect[enable inspector for debugging]'" + return + fi + + _node_files +} + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_arguments -C \ + '-[script read from stdin (default; interactive mode if a tty)]' \ + '--[indicate the end of node options]' \ + '--abort-on-uncaught-exception[aborting instead of exiting causes a core file to be generated for analysis]' \ + '--build-snapshot[generate a snapshot blob when the process exits]' \ + '--completion-bash[print source-able bash completion script]' \ + '--cpu-prof[Start the V8 CPU profiler on start up]' \ + '--cpu-prof-dir=[directory where the V8 profiles generated by --cpu-prof]: :_files -/' \ + '--cpu-prof-name=[file name of the V8 profile generated with --cpu-prof]: :_files' \ + '--cpu-prof-interval=[sampling interval in microseconds for the V8 CPU profiler]:number' \ + '--disable-proto=[disable Object.prototype.__proto__]:mode:(delete throw)' \ + '--disallow-code-generation-from-strings[disallow eval and friends]' \ + '--dns-result-order=[set default value of verbatim in dns.lookup]: :(ipv4first verbatim)' \ + '--enable-fips[enable FIPS crypto at startup]' \ + '--enable-source-maps[source map support]' \ + '--es-module-specifier-resolution=[extension resolution algorithm for es modules]:resolution algorithm:(explicit none)' \ + '--experimental-import-meta-resolve[experimental ES Module import.meta.resolve() support]' \ + '(--loader --experimental-loader)'{--loader,--experimental-loader}'=[Specify the module of a custom ECMAScript Module loader]: :_files' \ + '--experimental-network-imports[experimental https support for the ES Module loader]' \ + '--experimental-policy=[security policy file]: :_files' \ + '--experimental-vm-modules[experimental ES Module support in vm module]' \ + '--experimental-wasi-unstable-preview1[experimental WASI support]' \ + '--experimental-wasm-modules[experimental ES module support for webassembly modules]' \ + '--force-context-aware[disable loading non-context-aware addons]' \ + '--force-fips[force FIPS crypto]' \ + '--frozen-intrinsics[experimental frozen intrinsics support]' \ + '--heap-prof[Start the V8 heap profiler on start up]' \ + '--heap-prof-dir=[Directory where the V8 profiles generated by --heap-prof]: :_files -/' \ + '--heap-prof-interval=[sampling interval in bytes for the V8 heap profile]: :number' \ + '--heap-prof-name=[file name of the V8 heap profile generated]: :_files' \ + '--heapsnapshot-signal=[Generate heap snapshot on specified signal]:signals:_signals -s' \ + '--huge-max-old-generation-size[increase default maximum heap size with 16GB or more]' \ + '--icu-data-dir=[set ICU data load path to dir (overrides NODE_ICU_DATA) note: linked-in ICU data is present]: :_directories' \ + '--input-type=[set module type for string input]:module type :(commonjs module)' \ + '--insecure-http-parser[Use an insecure HTTP parser that accepts invalid HTTP headers]' \ + '--inspect-brk=-[activate inspector on host:port and break at start of user script]:[host\:]port' \ + '(--debug-port --inspect-port)'{--debug-port,--inspect-port}'=[set host:port for inspector]:[host\:]port' \ + '--inspect=-[activate inspector on host:port (default: 127.0.0.1:9229)]:[host\:]port' \ + '--inspect-publish-uid=[comma separated list of destinations for inspector uid]' \ + '--interpreted-frames-native-stack[help system profilers to translate JavaScript interpreted frames]' \ + '--jitless[Disable runtime allocation of executable memory]' \ + '--max-http-header-size=[set the maximum size of HTTP headers]: :number' \ + '--napi-modules[load N-API modules (no-op - option kept for compatibility)]' \ + '--no-addons[disable loading native addons]' \ + '--no-deprecation[silence deprecation warnings]' \ + '--no-experimental-fetch[disable experimental Fetch API]' \ + '--no-experimental-global-customevent[expose experimental CustomEvent on the global scope]' \ + '--no-experimental-global-webscrypto[expose experimental Web Crypto API on the global scope]' \ + '--no-experimental-repl-await[disable experimental await keyword support in REPL]' \ + '--no-experimental-info-on-fatal-exception[hide extra information on fatal exception that causes exit]' \ + '--no-force-async-hooks-checks[disable checks for async_hooks]' \ + '--no-global-search-paths[disable global module search paths]' \ + '--no-warnings[silence all process warnings]' \ + '--node-memory-debug[run with extra debug checks for memory leaks in Node.js itself]' \ + '--openssl-config=[load OpenSSL configuration from the specified file (overrides OPENSSL_CONF)]:file:_files' \ + '--openssl-legacy-provider[enable OpenSSL 3.0 legacy provider]' \ + '--openssl-shared-config[enable OpenSSL shared configuration]' \ + '--pending-deprecation[emit pending deprecation warnings]' \ + '--policy-integrity=[ensure the security policy contents match the specified integrity]' \ + '--preserve-symlinks[preserve symbolic links when resolving]' \ + '--preserve-symlinks-main[preserve symbolic links when resolving the main module]' \ + '--prof[generate V8 profiler output]' \ + '--prof-process[process V8 profiler output generated using --prof]' \ + '--redirect-warnings=[write warnings to file instead of stderr]: :_files' \ + '--report-compact[output compact single-line JSON]' \ + '--report-directory=[custom report path]: :_files -/' \ + '--report-filename=[custom report file name]: :_files' \ + '--report-on-fatalerror[generate diagnostic report on fatal (internal) errors]' \ + '--report-on-signal=[generate diagnostic report upon receiving signals]' \ + '--report-signal=[causes diagnostic report to be produced on provided signal]:signals:_signals -s' \ + '--report-uncaught-exception[generate diagnostic report on uncaught exceptions]' \ + '--secure-heap=[total size of the OpenSSL secure heap]: :number' \ + '--secure-heap-min=[minimum allocation size from the OpenSSL secure heap]' \ + '--snapshot-blob=[path to the snapshot blob that is used to restore the application state]:snapshot:_files' \ + '--test[launch test runner on startup]' \ + '--test-name-pattern=[run tests whose name matches this regular expression]:pattern' \ + '--test-only[run tests with "only" option set]' \ + '--throw-deprecation[throw an exception on deprecations]' \ + '--title=[the process title to use on startup]:process title' \ + '--tls-cipher-list=[use an alternative default TLS cipher list]:cipher list string' \ + '--tls-keylog=[log TLS decryption keys to named file for traffic analysis]: :_files' \ + '(--tls-max-v1.3)--tls-max-v1.2[set default TLS maximum to TLSv1.2]' \ + '(--tls-max-v1.2)--tls-max-v1.3[set default TLS maximum to TLSv1.3]' \ + '(--tls-min-v1.1 --tls-min-v1.2 --tls-min-v1.3)--tls-min-v1.0[set default TLS minimum to TLSv1.0]' \ + '(--tls-min-v1.0 --tls-min-v1.2 --tls-min-v1.3)--tls-min-v1.1[set default TLS minimum to TLSv1.1]' \ + '(--tls-min-v1.0 --tls-min-v1.1 --tls-min-v1.3)--tls-min-v1.2[set default TLS minimum to TLSv1.2]' \ + '(--tls-max-v1.2 --tls-min-v1.0 --tls-min-v1.1 --tls-min-v1.2)--tls-min-v1.3[set default TLS minimum to TLSv1.3]' \ + '--trace-atomics-wait[trace Atomics.wait operations]' \ + '--trace-deprecation[show stack traces on deprecations]' \ + '--trace-event-categories[comma separated list of trace event categories to record]: :{_values -s , categories node node.async_hooks node.bootstrap node.perf node.perf.usertiming node.perf.timerify node.fs.sync node.vm.script v8}' \ + '--trace-event-file-pattern[Template string specifying the filepath for the trace-events data, it supports ${rotation} and ${pid} log-rotation id. %2$u is the pid.]:template string' \ + '--trace-exit[show stack trace when an environment exits]' \ + '--trace-sigint[prints a stack trace on SIGINT]' \ + '--trace-sync-io[show stack trace when use of sync IO is detected after the first tick]' \ + '--trace-tls[prints TLS packet trace information to stderr]' \ + '--trace-uncaught[show stack traces for the throw behind uncaught exceptions]' \ + '--trace-warnings[show stack traces on process warnings]' \ + '--track-heap-objects[track heap object allocations for heap snapshots]' \ + '--unhandled-rejections=[define unhandled rejections behavior]:rejection behavior:(strict warn none)' \ + '--update-assert-snapshot[update assert snapshot files]' \ + '--use-bundled-ca[use bundled CA store (default)]' \ + '--use-largepages=[re-map the Node.js static code to large memory pages at startup]:mode:(off on silent)' \ + "--use-openssl-ca[use OpenSSL's default CA store]" \ + '(- 1 *)--v8-options[print v8 command line options]' \ + "--v8-pool-size=[set v8's thread pool size]:number" \ + "--watch[run in watch mode]" \ + "--watch-path=[path to watch]: :_node_files" \ + '--zero-fill-buffers[automatically zero-fill all newly allocated Buffer and SlowBuffer instances]' \ + {-c,--check}'[syntax check script without executing]' \ + '(- 1 *)'{-e,--eval}'[evaluate script]:inline JavaScript' \ + '(- 1 *)'{-h,--help}'[print node command line options]' \ + {-i,--interactive}'[always enter the REPL even if stdin does not appear to be a terminal]' \ + '(- 1 *)'{-p,--print}'[evaluate script and print result]:inline JavaScript' \ + '*'{-r,--require}'[module to preload (option can be repeated)]: :_node_files' \ + '(- 1 *)'{-v,--version}'[print Node.js version]' \ + '*: :_node_args' && ret=0 + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_nvm b/home/.zsh-server/plugins/zsh-completions/src/_nvm new file mode 100644 index 0000000..4c820d2 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_nvm @@ -0,0 +1,235 @@ +#compdef nvm +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for nvm v0.39.2 (https://github.com/nvm-sh/nvm). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Changwoo Park (https://github.com/pismute) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +__nvm() { + typeset -A opt_args + local context state line + + local curcontext="$curcontext" + local ret=1 + + _arguments -C \ + '--help[show help message]' \ + '--no-color[suppress colored output]' \ + '--version[print out the installed version of nvm]' \ + '1: :__nvm_subcommands' \ + '*::arg:->args' && ret=0 + + case "$state" in + args) + case $words[1] in + (install) + _arguments -C \ + '-s[Skip binary download, install from source only]' \ + '-b[Skip source download, install from binary only]' \ + '--reinstall-packages-from=[When installing, reinstall packages installed in node]:version' \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '--skip-default-packages[When installing, skip the default-packages file if it exists]' \ + '--latest-npm[After installing, attempt to upgrade to the latest working npm on the given node version]' \ + '--no-progress[Disable the progress bar on any downloads]' \ + '--alias=[After installing, set the alias specified to the version specified]' \ + '--default[After installing, set default alias to the version specified]' \ + '1::version:__nvm_versions' \ + && ret=0 + ;; + (uninstall) + _arguments -C \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '1: :__nvm_installed_versions' \ + && ret=0 + ;; + (use) + _arguments -C \ + '--silent[Silences stdout/stderr output]' \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '1: :__nvm_installed_versions' \ + '*: :_normal' \ + && ret=0 + ;; + (exec) + _arguments -C \ + '--silent[Silences stdout/stderr output]' \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '1: :__nvm_installed_versions' \ + '*: :_normal' \ + && ret=0 + ;; + (run) + _arguments -C \ + '--silent[Silences stdout/stderr output]' \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '1: :__nvm_installed_versions' \ + '*: :_normal' \ + && ret=0 + ;; + (ls) + _arguments -C \ + '--no-colors[Suppress colored output]' \ + '--no-alias[Suppress `nvm alias` output]' \ + && ret=0 + ;; + (ls-remote) + _arguments -C \ + '--silent[Silences stdout/stderr output]' \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '--no-colors[Suppress colored output]' \ + && ret=0 + ;; + (version-remote) + _arguments -C \ + '--lts=[When installing, only select from LTS versions]::lts_name' \ + '1: :__nvm_versions' \ + && ret=0 + ;; + (deactivate) + _arguments -C \ + '--silent=[Silences stdout/stderr output]' \ + && ret=0 + ;; + (alias) + _arguments -C \ + '1:name' \ + '2:version:__nvm_installed_versions' \ + && ret=0 + ;; + (unalias) + _arguments -C \ + '1:version:__nvm_installed_versions' \ + && ret=0 + ;; + (reinstall-package) + _arguments -C \ + '--silent=[Silences stdout/stderr output]' \ + '1: :__nvm_installed_versions' \ + && ret=0 + ;; + (which) + _arguments -C \ + '1: : _alternative "version:version:__nvm_installed_versions" "current: :(current)"' \ + && ret=0 + ;; + (cache) + _arguments -C \ + '1: :__nvm_cache_subcommands' \ + && ret=0 + ;; + *) + (( ret )) && _message 'no more arguments' + ;; + esac + ;; + esac + + return ret +} + +__nvm_subcommands() { + local -a commands=( + 'help:Show this message' + 'install:Download and install a ' + 'uninstall:Uninstall a ' + 'use:Modify PATH to use ' + 'exec:Run on ' + 'run:Run with as arguments' + 'current:Display currently activated version of Node' + 'ls:List installed [versions]' + 'ls-remote:List remote versions available for install' + 'version:Show current node version' + 'version-remote:Resolve the given description to a single remote version' + 'deactivate:Undo effects of NVM on current shell' + 'alias:Set an alias named pointing to . Show all aliases beginning with [].' + 'unalias:Deletes the alias named ' + 'install-latest-npm:Attempt to upgrade to the latest working npm on the current node version' + 'reinstall-packages:Reinstall global npm packages contained in to current version' + 'unload:Unload `nvm` from shell' + 'which:Display path to installed node version' + 'cache:Show cache directory/Clear cache' + 'set-colors:Set five text colors using format "yMeBg"' + ) + + _describe -t commands 'command' commands "$@" +} + +__nvm_aliases() { + local aliases + if [[ -d $NVM_DIR/alias ]]; then + aliases=$(echo $NVM_DIR/alias/*(:t)) + fi + echo "$aliases" +} + +__nvm_versions() { + # nvm ls-remote is slow + if [[ ${#__nvm_node_version_cache[@]} == 0 ]]; then + __nvm_node_version_cache=(${(@f)"$(nvm ls-remote --no-colors | awk '{print $1}')"}) + fi + + _describe -t versions 'version' __nvm_node_version_cache "$@" +} + +__nvm_installed_versions() { + local -a versions + + if (( $+functions[nvm_ls] )); then + versions=(${(f)"$(nvm_ls)"}) + fi + + versions=($versions $(__nvm_aliases)) + _describe -t versions 'version' versions "$@" +} + +__nvm_cache_subcommands() { + local -a commands=( + 'dir:Display path to the cache directory for nvm' + 'clear:Empty cache directory for nvm' + ) + _describe -t commands 'command' commands "$@" +} + +__nvm "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_openssl b/home/.zsh-server/plugins/zsh-completions/src/_openssl new file mode 100644 index 0000000..bf3594f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_openssl @@ -0,0 +1,1687 @@ +#compdef openssl +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ + +# openssl command [ command_opts ] [ command_args ] + +_openssl() { + local openssl_commands cmd cmds + if [[ "$CURRENT" -lt 2 ]]; then + # I do not think this can happen... + return + elif [[ "$CURRENT" -eq 2 ]]; then + # first parameter, the command + openssl_commands=(${(z)${${(f)"$(openssl help 2>&1)"}:#([A-Z]|openssl:Error:)*}}) + _describe 'openssl commands' openssl_commands + else + # $CURRENT -gt 2 + cmd="${words[2]}" + # Note: we could use ${(k)functions} to get a list of all functions and + # filter those that start with _openssl_ + # but that would mean defining a new function *somewhere* might mess with + # the completion... + cmds=(asn1parse ca ciphers cms crl crl2pkcs7 dgst dh dhparam dsa dsaparam \ + ec ecparam enc engine errstr gendh gendsa genpkey genrsa nseq ocsp \ + passwd pkcs12 pkcs7 pkcs8 pkey pkeyparam pkeyutl prime rand req rsa \ + rsautl s_client s_server s_time sess_id smime speed spkac srp ts \ + verify version x509) + # check if $cmd is in $cmds, the list of supported commands + if [[ "${cmds[(r)$cmd]}" == "${cmd}" ]]; then + # we should be able to complete $cmd + # run _openssl_$cmd with the remaining words from the command line + shift words + (( CURRENT-- )) + _openssl_${cmd} + elif [[ ${${=${"$(openssl help 2>&1)"/*Cipher commands[^)]#)/}}[(re)$cmd]} == "$cmd" ]]; then + # $cmd is a cipher command, which is practically an alias to enc + shift words + (( CURRENT-- )) + _openssl_enc + elif [[ ${${=${${"$(openssl help 2>&1)"%%Cipher commands*}/*Message Digest commands[^)]#)/}}[(re)$cmd]} == "$cmd" ]]; then + # $cmd is a message digest command, which is practically an alias to dgst + shift words + (( CURRENT-- )) + _openssl_dgst + fi + fi +} + + +_openssl_asn1parse() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - one of DER PEM]:format:(DER PEM)' \ + '-in[input file]:file:_files' \ + '-out[output file (output format is always DER]:file:_files' \ + "-noout[don't produce any output]" \ + '-offset[offset into file]:number: ' \ + '-length[length of section in file]:number: ' \ + '-i[indent entries]' \ + '-dump[dump unknown data in hex form]' \ + '-dlimit[dump the first arg bytes of unknown data in hex form]:number: ' \ + '-oid[file of extra oid definitions]:file:_files' \ + "-strparse[a series of these can be used to 'dig' into multiple ASN1 blob wrappings]:offset:" \ + '-genstr[string to generate ASN1 structure from]:str:' \ + '-genconf[file to generate ASN1 structure from]:file:_files' +} + + +_openssl_ca() { + # written for openssl 1.0.1k + _arguments -C \ + '-verbose[talk alot while doing things]' \ + '-config[a config file]:file:_files' \ + '-name[the particular CA definition to use]:section: ' \ + '-gencrl[generate a new CRL]' \ + '-crldays[days is when the next CRL is due]:days: ' \ + '-crlhours[hours is when the next CRL is due]:hours: ' \ + '-startdate[certificate validity notBefore]:date: ' \ + '-enddate[certificate validity notAfter (overrides -days)]:date: ' \ + '-days[number of days to certify the certificate for]:days: ' \ + '-md[md to use, one of md2, md5, sha or sha1]:alg:(md2 md5 sha sha1)' \ + "-policy[the CA 'policy' to support]:policy: " \ + '-keyfile[private key file]:file:_files' \ + '-keyform[private key file format (PEM or ENGINE)]:format:(PEM ENGINE)' \ + '-key[key to decode the private key if it is encrypted]:password: ' \ + '-cert[the CA certificate]:file:_files' \ + '-selfsign[sign a certificate with the key associated with it]' \ + '-in[the input PEM encoded certificate request(s)]:file:_files' \ + '-out[where to put the output file(s)]:file:_files' \ + '-outdir[where to put output certificates]:dir:_files -/' \ + '-infiles[the last argument, requests to process]:*:files:_files' \ + '-spkac[file contains DN and signed public key and challenge]:file:_files' \ + '-ss_cert[file contains a self signed cert to sign]:file:_files' \ + "-preserveDN[don't re-order the DN]" \ + "-noemailDN[don't add the EMAIL field into certificate' subject]" \ + "-batch[don't ask questions]" \ + '-msie_hack[msie modifications to handle all those universal strings]' \ + '-revoke[revoke a certificate (given in file)]:file:_files' \ + "-subj[use arg instead of request's subject]:subject: " \ + '-utf8[input characters are UTF8 (default ASCII)]' \ + '-multivalue-rdn[enable support for multivalued RDNs]' \ + '-extensions[extension section (override value in config file)]:section: ' \ + '-extfile[configuration file with X509v3 extensions to add]:file:_files' \ + '-crlexts[CRL extension section (override value in config file)]:section: ' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-status[shows certificate status given the serial number]:serial: ' \ + '-updatedb[updates db for expired certificates]' +} + + +_openssl_ciphers() { + # written for openssl 1.0.1k + _arguments -C \ + '-v[verbose mode, a textual listing of the SSL/TLS ciphers in OpenSSL]' \ + '-V[even more verbose]' \ + '-ssl2[SSL2 mode]' \ + '-ssl3[SSL3 mode]' \ + '-tls1[TLS1 mode]' \ + ':cipher suite:_list_ciphers' +} + + +_openssl_cms() { + # written for openssl 1.0.1k + _arguments -C \ + '-encrypt[encrypt message]' \ + '-decrypt[decrypt encrypted message]' \ + '-sign[sign message]' \ + '-verify[verify signed message]' \ + '-cmsout[output CMS structure]' \ + '-des3[encrypt with triple DES]' \ + '-des[encrypt with DES]' \ + '-seed[encrypt with SEED]' \ + '-rc2-40[encrypt with RC2-40 (default)]' \ + '-rc2-64[encrypt with RC2-64]' \ + '-rc2-128[encrypt with RC2-128]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + "-nointern[don't search certificates in message for signer]" \ + "-nosigs[don't verify message signature]" \ + "-noverify[don't verify signers certificate]" \ + "-nocerts[don't include signers certificate when signing]" \ + '-nodetach[use opaque signing]' \ + "-noattr[don't include any signed attributes]" \ + "-binary[don't translate message to text]" \ + '-certfile[other certificates file]:file:_files' \ + '-certsout[certificate output file]:file:_files' \ + '-signer[signer certificate file]:file:_files' \ + '-recip[recipient certificate file for decryption]:file:_files' \ + '-keyid[use subject key identifier]' \ + '-in[input file]:file:_files' \ + '-inform[input format SMIME (default), PEM or DER]:format:(SMIME PEM DER)' \ + '-inkey[input private key (if not signer or recipient)]:file:_files' \ + '-keyform[input private key format (PEM or ENGINE)]:format:(PEM ENGINE)' \ + '-out[output file]:file:_files' \ + '-outform[output format SMIME (default), PEM or DER]:format:(SMIME PEM DER)' \ + '-content[supply or override content for detached signature]:file:_files' \ + '-to[to address mail head]:address: ' \ + '-from[from address mail head]:address: ' \ + '-subject[subject mail head]:subject: ' \ + '-text[include or delete text MIME headers]' \ + '-CApath[trusted certificates directory]:dir:_files -/' \ + '-CAfile[trusted certificates file]:file:_files' \ + "-crl_check[check revocation status of signer's certificate using CRLs]" \ + "-crl_check_all[check revocation status of signer's certificate chain using CRLs]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '*:certificate:_files' +} + + +_openssl_crl() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - default PEM (DER or PEM)]:format:(PEM DER)' \ + '-outform[output format - default PEM]:format:(PEM DER)' \ + '-text[print out a text format version]' \ + '-in[input file - default stdin]:file:_files' \ + '-out[output file - default stdout]:file:_files' \ + '-hash[print hash value]' \ + '-hash_old[print old-style (MD5) hash value]' \ + '-fingerprint[print the crl fingerprint]' \ + '-issuer[print issuer DN]' \ + '-lastupdate[print lastUpdate field]' \ + '-nextupdate[print nextUpdate field]' \ + '-crlnumber[print CRL number]' \ + '-noout[no CRL output]' \ + '-CAfile[verify CRL using certificates in the specified file]:file:_files' \ + '-CApath[verify CRL using certificates in the specified directory]:dir:_files -/' \ + '*-nameopt[various certificate name options]:options:_nameopts' +} + + +_openssl_crl2pkcs7() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - DER or PEM]:format:(PEM DER)' \ + '-outform[output format - DER or PEM]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-certfile[certificates file of chain to a trusted CA (can be used more than once)]:file:_files' \ + "-nocrl[no crl to load, just certs from '-certfile']" +} + + +_openssl_dgst() { + # written for openssl 1.0.1k + local digests + digests=(-dss1 -md4 -md5 -mdc2 -ripemd160 -sha -sha1 -sha224 -sha256 -sha384 -sha512 -whirlpool) + # -hmac is listed twice because it's documented twice by openssl + _arguments -C -A '-*' \ + '(-r -hex -binary)-c[to output the digest with separating colons]' \ + '(-c -hex -binary)-r[to output the digest in coreutils format]' \ + '-d[to output debug info]' \ + '(-c -r -binary)-hex[output as hex dump]' \ + '(-c -r -hex)-binary[output in binary form]' \ + '-hmac[set the HMAC key to arg]:key: ' \ + '-non-fips-allow[allow use of non FIPS digest]' \ + '-sign[sign digest using private key in the specified file]:file:_files' \ + '-verify[verify a signature using public key in the specified file]:file:_files' \ + '-prverify[verify a signature using private key in the specified file]:file:_files' \ + '-keyform[key file format (PEM or ENGINE)]:format:(PEM ENGINE)' \ + '-out[output to filename rather than stdout]:file:_files' \ + '-signature[signature to verify]:file:_files' \ + '-sigopt[signature parameter]:nm\:v: ' \ + '-hmac[create hashed MAC with key]:key: ' \ + '-mac[create MAC (not necessarily HMAC)]:algorithm: ' \ + '-macopt[MAC algorithm parameters or key]:nm\:v: ' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "($digests)-dss1[use the dss1 message digest algorithm]" \ + "($digests)-md4[to use the md4 message digest algorithm]" \ + "($digests)-md5[to use the md5 message digest algorithm]" \ + "($digests)-mdc2[to use the mdc2 message digest algorithm]" \ + "($digests)-ripemd160[to use the ripemd160 message digest algorithm]" \ + "($digests)-sha[to use the sha message digest algorithm]" \ + "($digests)-sha1[to use the sha1 message digest algorithm]" \ + "($digests)-sha224[to use the sha224 message digest algorithm]" \ + "($digests)-sha256[to use the sha256 message digest algorithm]" \ + "($digests)-sha384[to use the sha384 message digest algorithm]" \ + "($digests)-sha512[to use the sha512 message digest algorithm]" \ + "($digests)-whirlpool[to use the whirlpool message digest algorithm]" \ + '*:file:_files' +} + + +_openssl_dh() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-check[check the DH parameters]' \ + '-text[print a text form of the DH parameters]' \ + '-C[output C code]' \ + '-noout[no output]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_dhparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-dsaparam[read or generate DSA parameters, convert to DH]' \ + '-check[check the DH parameters]' \ + '-text[print a text form of the DH parameters]' \ + '-C[output C code]' \ + '-2[generate parameters using 2 as the generator value]' \ + '-5[generate parameters using 5 as the generator value]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-noout[no output]' \ + ':numbits: ' +} + + +_openssl_dsa() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-passin[input file pass phrase source]:file:_files' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:file:_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-des[encrypt PEM output with cbc des]' \ + '-des3[encrypt PEM output with ede cbc des using 168 bit key]' \ + '-idea[encrypt PEM output with cbc idea]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-text[print the key in text]' \ + "-noout[don't print key out]" \ + '-modulus[print the DSA public value]' +} + + +_openssl_dsaparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-text[print as text]' \ + '-C[output C code]' \ + '-noout[no output]' \ + '-genkey[generate a DSA key]' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + ':numbits: ' +} + + +_openssl_ec() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-passin[input file pass phrase source]:file:_files' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:file:_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "-des[encrypt PEM output, instead of 'des' every other cipher supported by OpenSSL can be used]" \ + '-text[print the key]' \ + "-noout[don't print key out]" \ + '-param_out[print the elliptic curve parameters]' \ + '-conv_form[specifies the point conversion form]:form:(compressed uncompressed hybrid)' \ + '-param_enc[specifies the way the ec parameters are encoded in the asn1 der encoding]:encoding:(named_curve explicit)' +} + + +_openssl_ecparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file - default stdin]:file:_files' \ + '-out[output file - default stdout]:file:_files' \ + '-noout[do not print the ec parameter]' \ + '-text[print the ec parameters in text form]' \ + '-check[validate the ec parameters]' \ + "-C[print a 'C' function creating the parameters]" \ + "-name[use the ec parameters with 'short name' name]:name: " \ + "-list_curves[prints a list of all currently available curve 'short names']" \ + '-conv_form[specifies the point conversion form]:form:(compressed uncompressed hybrid)' \ + '-param_enc[specifies the way the ec parameters are encoded in the asn1 der encoding]:encoding:(named_curve explicit)' \ + "-no_seed[if 'explicit' parameters are chosen do not use the seed]" \ + '-genkey[generate ec key]' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_enc() { + # written for openssl 1.0.1k + local ciphers + ciphers=(-aes-128-cbc -aes-128-cbc-hmac-sha1 -aes-128-cfb -aes-128-cfb1 \ + -aes-128-cfb8 -aes-128-ctr -aes-128-ecb -aes-128-gcm -aes-128-ofb \ + -aes-128-xts -aes-192-cbc -aes-192-cfb -aes-192-cfb1 -aes-192-cfb8 \ + -aes-192-ctr -aes-192-ecb -aes-192-gcm -aes-192-ofb -aes-256-cbc \ + -aes-256-cbc-hmac-sha1 -aes-256-cfb -aes-256-cfb1 -aes-256-cfb8 \ + -aes-256-ctr -aes-256-ecb -aes-256-gcm -aes-256-ofb -aes-256-xts \ + -aes128 -aes192 -aes256 -bf -bf-cbc -bf-cfb -bf-ecb -bf-ofb \ + -blowfish -camellia-128-cbc -camellia-128-cfb -camellia-128-cfb1 \ + -camellia-128-cfb8 -camellia-128-ecb -camellia-128-ofb \ + -camellia-192-cbc -camellia-192-cfb -camellia-192-cfb1 \ + -camellia-192-cfb8 -camellia-192-ecb -camellia-192-ofb \ + -camellia-256-cbc -camellia-256-cfb -camellia-256-cfb1 \ + -camellia-256-cfb8 -camellia-256-ecb -camellia-256-ofb \ + -camellia128 -camellia192 -camellia256 -cast -cast-cbc -cast5-cbc \ + -cast5-cfb -cast5-ecb -cast5-ofb -des -des-cbc -des-cfb -des-cfb1 \ + -des-cfb8 -des-ecb -des-ede -des-ede-cbc -des-ede-cfb -des-ede-ofb \ + -des-ede3 -des-ede3-cbc -des-ede3-cfb -des-ede3-cfb1 \ + -des-ede3-cfb8 -des-ede3-ofb -des-ofb -des3 -desx -desx-cbc \ + -id-aes128-GCM -id-aes192-GCM -id-aes256-GCM -idea -idea-cbc \ + -idea-cfb -idea-ecb -idea-ofb -rc2 -rc2-40-cbc -rc2-64-cbc \ + -rc2-cbc -rc2-cfb -rc2-ecb -rc2-ofb -rc4 -rc4-40 -rc4-hmac-md5 \ + -rc5 -rc5-cbc -rc5-cfb -rc5-ecb -rc5-ofb -seed -seed-cbc -seed-cfb \ + -seed-ecb -seed-ofb) + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-pass[pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-e[encrypt]' \ + '-d[decrypt]' \ + '(-a -base64)'{-a,-base64}'[base64 encode/decode, depending on encryption flag]' \ + '-k[the password to derive the key from]:password: ' \ + '-kfile[read the password to derive the key from the first line of the file]:file:_files' \ + '-md[the md to use to create a key from a passphrase]:alg:(md2 md5 sha sha1)' \ + '-S[the actual salt to use]:salt: ' \ + '-K[the actual key to use]:key: ' \ + '-iv[the actual IV to use]:IV: ' \ + '-p[print out the key and IV used]' \ + '-P[print out the key and IV used the exit]' \ + '-bufsize[set the buffer size for I/O]:size: ' \ + '-nopad[disable standard block padding]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "(${ciphers})-aes-128-cbc[cipher types]" \ + "(${ciphers})-aes-128-cbc-hmac-sha1[cipher types]" \ + "(${ciphers})-aes-128-cfb[cipher types]" \ + "(${ciphers})-aes-128-cfb1[cipher types]" \ + "(${ciphers})-aes-128-cfb8[cipher types]" \ + "(${ciphers})-aes-128-ctr[cipher types]" \ + "(${ciphers})-aes-128-ecb[cipher types]" \ + "(${ciphers})-aes-128-gcm[cipher types]" \ + "(${ciphers})-aes-128-ofb[cipher types]" \ + "(${ciphers})-aes-128-xts[cipher types]" \ + "(${ciphers})-aes-192-cbc[cipher types]" \ + "(${ciphers})-aes-192-cfb[cipher types]" \ + "(${ciphers})-aes-192-cfb1[cipher types]" \ + "(${ciphers})-aes-192-cfb8[cipher types]" \ + "(${ciphers})-aes-192-ctr[cipher types]" \ + "(${ciphers})-aes-192-ecb[cipher types]" \ + "(${ciphers})-aes-192-gcm[cipher types]" \ + "(${ciphers})-aes-192-ofb[cipher types]" \ + "(${ciphers})-aes-256-cbc[cipher types]" \ + "(${ciphers})-aes-256-cbc-hmac-sha1[cipher types]" \ + "(${ciphers})-aes-256-cfb[cipher types]" \ + "(${ciphers})-aes-256-cfb1[cipher types]" \ + "(${ciphers})-aes-256-cfb8[cipher types]" \ + "(${ciphers})-aes-256-ctr[cipher types]" \ + "(${ciphers})-aes-256-ecb[cipher types]" \ + "(${ciphers})-aes-256-gcm[cipher types]" \ + "(${ciphers})-aes-256-ofb[cipher types]" \ + "(${ciphers})-aes-256-xts[cipher types]" \ + "(${ciphers})-aes128[cipher types]" \ + "(${ciphers})-aes192[cipher types]" \ + "(${ciphers})-aes256[cipher types]" \ + "(${ciphers})-bf[cipher types]" \ + "(${ciphers})-bf-cbc[cipher types]" \ + "(${ciphers})-bf-cfb[cipher types]" \ + "(${ciphers})-bf-ecb[cipher types]" \ + "(${ciphers})-bf-ofb[cipher types]" \ + "(${ciphers})-blowfish[cipher types]" \ + "(${ciphers})-camellia-128-cbc[cipher types]" \ + "(${ciphers})-camellia-128-cfb[cipher types]" \ + "(${ciphers})-camellia-128-cfb1[cipher types]" \ + "(${ciphers})-camellia-128-cfb8[cipher types]" \ + "(${ciphers})-camellia-128-ecb[cipher types]" \ + "(${ciphers})-camellia-128-ofb[cipher types]" \ + "(${ciphers})-camellia-192-cbc[cipher types]" \ + "(${ciphers})-camellia-192-cfb[cipher types]" \ + "(${ciphers})-camellia-192-cfb1[cipher types]" \ + "(${ciphers})-camellia-192-cfb8[cipher types]" \ + "(${ciphers})-camellia-192-ecb[cipher types]" \ + "(${ciphers})-camellia-192-ofb[cipher types]" \ + "(${ciphers})-camellia-256-cbc[cipher types]" \ + "(${ciphers})-camellia-256-cfb[cipher types]" \ + "(${ciphers})-camellia-256-cfb1[cipher types]" \ + "(${ciphers})-camellia-256-cfb8[cipher types]" \ + "(${ciphers})-camellia-256-ecb[cipher types]" \ + "(${ciphers})-camellia-256-ofb[cipher types]" \ + "(${ciphers})-camellia128[cipher types]" \ + "(${ciphers})-camellia192[cipher types]" \ + "(${ciphers})-camellia256[cipher types]" \ + "(${ciphers})-cast[cipher types]" \ + "(${ciphers})-cast-cbc[cipher types]" \ + "(${ciphers})-cast5-cbc[cipher types]" \ + "(${ciphers})-cast5-cfb[cipher types]" \ + "(${ciphers})-cast5-ecb[cipher types]" \ + "(${ciphers})-cast5-ofb[cipher types]" \ + "(${ciphers})-des[cipher types]" \ + "(${ciphers})-des-cbc[cipher types]" \ + "(${ciphers})-des-cfb[cipher types]" \ + "(${ciphers})-des-cfb1[cipher types]" \ + "(${ciphers})-des-cfb8[cipher types]" \ + "(${ciphers})-des-ecb[cipher types]" \ + "(${ciphers})-des-ede[cipher types]" \ + "(${ciphers})-des-ede-cbc[cipher types]" \ + "(${ciphers})-des-ede-cfb[cipher types]" \ + "(${ciphers})-des-ede-ofb[cipher types]" \ + "(${ciphers})-des-ede3[cipher types]" \ + "(${ciphers})-des-ede3-cbc[cipher types]" \ + "(${ciphers})-des-ede3-cfb[cipher types]" \ + "(${ciphers})-des-ede3-cfb1[cipher types]" \ + "(${ciphers})-des-ede3-cfb8[cipher types]" \ + "(${ciphers})-des-ede3-ofb[cipher types]" \ + "(${ciphers})-des-ofb[cipher types]" \ + "(${ciphers})-des3[cipher types]" \ + "(${ciphers})-desx[cipher types]" \ + "(${ciphers})-desx-cbc[cipher types]" \ + "(${ciphers})-id-aes128-GCM[cipher types]" \ + "(${ciphers})-id-aes192-GCM[cipher types]" \ + "(${ciphers})-id-aes256-GCM[cipher types]" \ + "(${ciphers})-idea[cipher types]" \ + "(${ciphers})-idea-cbc[cipher types]" \ + "(${ciphers})-idea-cfb[cipher types]" \ + "(${ciphers})-idea-ecb[cipher types]" \ + "(${ciphers})-idea-ofb[cipher types]" \ + "(${ciphers})-rc2[cipher types]" \ + "(${ciphers})-rc2-40-cbc[cipher types]" \ + "(${ciphers})-rc2-64-cbc[cipher types]" \ + "(${ciphers})-rc2-cbc[cipher types]" \ + "(${ciphers})-rc2-cfb[cipher types]" \ + "(${ciphers})-rc2-ecb[cipher types]" \ + "(${ciphers})-rc2-ofb[cipher types]" \ + "(${ciphers})-rc4[cipher types]" \ + "(${ciphers})-rc4-40[cipher types]" \ + "(${ciphers})-rc4-hmac-md5[cipher types]" \ + "(${ciphers})-rc5[cipher types]" \ + "(${ciphers})-rc5-cbc[cipher types]" \ + "(${ciphers})-rc5-cfb[cipher types]" \ + "(${ciphers})-rc5-ecb[cipher types]" \ + "(${ciphers})-rc5-ofb[cipher types]" \ + "(${ciphers})-seed[cipher types]" \ + "(${ciphers})-seed-cbc[cipher types]" \ + "(${ciphers})-seed-cfb[cipher types]" \ + "(${ciphers})-seed-ecb[cipher types]" \ + "(${ciphers})-seed-ofb[cipher types]" +} + + +_openssl_engine() { + # written for openssl 1.0.1k + _arguments -C \ + '(-vv -vvv -vvvv)-v[verbose mode, for each engine, list its "control commands"]' \ + "(-v -vvv -vvvv)-vv[like -v, but additionally display each command's description]" \ + '(-v -vv -vvvv)-vvv[like -vv, but also add the input flags for each command]' \ + '(-v -vv -vvv)-vvvv[like -vvv, but also show internal input flags]' \ + '-c[for each engine, also list the capabilities]' \ + '(-tt)-t[for each engine, check that they are really available]' \ + '(-t)-tt[display error trace for unavailable engines]' \ + "-pre[runs command 'cmd' against the ENGINE before any attempts to load it (if -t is used)]:cmd: " \ + "-post[runs command 'cmd' against the ENGINE after loading it (only used if -t is also provided)]:cmd: " \ + '*:engine:_engines' + # TODO: can cmd (for -pre and -post) be completed? +} + + +_openssl_errstr() { + # written for openssl 1.0.1k + # written for openssl 1.0.2a + _arguments -C \ + '-stats' \ + ':errno: ' +} + + +_openssl_gendh() { + # written for openssl 1.0.1k + _arguments -C \ + "-out[output the key to 'file']:file:_files" \ + '-2[use 2 as the generator value]' \ + '-5[use 5 as the generator value]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':numbits: ' +} + + +_openssl_gendsa() { + # written for openssl 1.0.1k + _arguments -C \ + "-out[output the key to 'file']:file:_files" \ + '-des[encrypt the generated key with DES in cbc mode]' \ + '-des3[encrypt the generated key with DES in ede cbc mode (168 bit key)]' \ + '-idea[encrypt the generated key with IDEA in cbc mode]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':dsaparam-file:_files' +} + + +_openssl_genpkey() { + # written for openssl 1.0.1k + local ciphers cipher_opts + if ! ciphers=( ${$(openssl list-cipher-algorithms | cut -d' ' -f1)} ) 2>/dev/null ; then + ciphers=( ${$(openssl list -cipher-algorithms | cut -d' ' -f1)} ) + fi + cipher_opts=() + for alg in ${ciphers}; do + cipher_opts=(${cipher_opts} "(${${(l:32:: ::-:)ciphers[@]}// / })-${alg}[use this cipher to encrypt the key]") + done + _arguments -C \ + '-out[output file]:file:_files' \ + '-outform[output format]:format:(PEM DER)' \ + '-pass[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + $cipher_opts \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '(-algorithm)-paramfile[parameters file]:file:_files' \ + '(-paramfile)-algorithm[the public key algorithm]:algorithm:(EC RSA DSA DH)' \ + '-pkeyopt[public key options]:option\:value: ' \ + '-genparam[generate parameters, not key]' \ + '-text[print the in text]' + # NB: options order may be important! See the manual page. + # TODO: complete pkeyopts + # However: "The precise set of options supported depends on the public key + # algorithm used and its implementation." +} + + +_openssl_genrsa() { + # written for openssl 1.0.1k + _arguments -C \ + '-des[encrypt the generated key with DES in cbc mode]' \ + '-des3[encrypt the generated key with DES in ede cbc mode (168 bit key)]' \ + '-idea[encrypt the generated key with IDEA in cbc mode]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-out[output the key to file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-f4[use F4 (0x10001) for the E value]' \ + '-3[use 3 for the E value]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':numbits: ' +} + + +_openssl_nseq() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-toseq[output NS Sequence file]' +} + + +_openssl_ocsp() { + # written for openssl 1.0.1k + _arguments -C \ + '-out[output filename]:file:_files' \ + '-issuer[issuer certificate]:file:_files' \ + '-cert[certificate to check]:file:_files' \ + '-serial[serial number to check]:serial: ' \ + '-signer[certificate to sign OCSP request with]:file:_files' \ + '-signkey[private key to sign OCSP request with]:file:_files' \ + '-sign_other[additional certificates to include in signed request]:file:_files' \ + "-no_certs[don't include any certificates in signed request]" \ + '-req_text[print text form of request]' \ + '-resp_text[print text form of response]' \ + '-text[print text form of request and response]' \ + '-reqout[write DER encoded OCSP request to "file"]:file:_files' \ + '-respout[write DER encoded OCSP response to "file"]:file:_files' \ + '-reqin[read DER encoded OCSP request from "file"]:file:_files' \ + '-respin[read DER encoded OCSP response from "file"]:file:_files' \ + '-nonce[add OCSP nonce to request]' \ + "-no_nonce[don't add OCSP nonce to request]" \ + '-url[OCSP responder URL]:URL: ' \ + '-host[send OCSP request to given host on given port]:host\:port: ' \ + '-path[path to use in OCSP request]' \ + '-CApath[trusted certificates directory]:directory:_files -/' \ + '-CAfile[trusted certificates file]:file:_files' \ + '-VAfile[validator certificates file]:file:_files' \ + '-validity_period[maximum validity discrepancy in seconds]:seconds: ' \ + '-status_age[maximum status age in seconds]:seconds: ' \ + "-noverify[don't verify response at all]" \ + '-verify_other[additional certificates to search for signer]:file:_files' \ + "-trust_other[don't verify additional certificates]" \ + "-no_intern[don't search certificates contained in response for signer]" \ + "-no_signature_verify[don't check signature on response]" \ + "-no_cert_verify[don't check signing certificate]" \ + "-no_chain[don't chain verify response]" \ + "-no_cert_checks[don't do additional checks on signing certificate]" \ + '-port[port to run responder on]:port: ' \ + '-index[certificate status index file]:file:_files' \ + '-CA[CA certificate]:file:_files' \ + '-rsigner[responder certificate to sign responses with]:file:_files' \ + '-rkey[responder key to sign responses with]:file:_files' \ + '-rother[other certificates to include in response]:file:_files' \ + "-resp_no_certs[don't include any certificates in response]" \ + '-nmin[number of minutes before next update]:minutes: ' \ + '-ndays[number of days before next update]:days: ' \ + '-resp_key_id[identify response by signing certificate key ID]' \ + '-nrequest[number of requests to accept (default unlimited)]:limit: ' \ + '-dss1[use specified digest in the request]' \ + '-md4[use specified digest in the request]' \ + '-md5[use specified digest in the request]' \ + '-mdc2[use specified digest in the request]' \ + '-ripemd160[use specified digest in the request]' \ + '-ripemd[use specified digest in the request]' \ + '-rmd160[use specified digest in the request]' \ + '-sha1[use specified digest in the request]' \ + '-sha224[use specified digest in the request]' \ + '-sha256[use specified digest in the request]' \ + '-sha384[use specified digest in the request]' \ + '-sha512[use specified digest in the request]' \ + '-sha[use specified digest in the request]' \ + '-ssl2-md5[use specified digest in the request]' \ + '-ssl3-md5[use specified digest in the request]' \ + '-ssl3-sha1[use specified digest in the request]' \ + '-whirlpool[use specified digest in the request]' \ + '-timeout[timeout connection to OCSP responder after n seconds]:seconds: ' +} + + +_openssl_passwd() { + # written for openssl 1.0.1k + _arguments -C \ + '-crypt[standard Unix password algorithm (default)]' \ + '-1[MD5-based password algorithm]' \ + '-apr1[MD5-based password algorithm, Apache variant]' \ + '-salt[use provided salt]:salt: ' \ + '-in[read passwords from file]:file:_files' \ + '-stdin[read passwords from stdin]' \ + '-noverify[never verify when reading password from terminal]' \ + '-quiet[no warnings]' \ + '-table[format output as table]' \ + '-reverse[switch table columns]' \ + '*:password:' +} + + +_openssl_pkcs12() { + # written for openssl 1.0.2d + local algorithms + algorithms=(aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc \ + aes-256-ecb bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc \ + camellia-128-ecb camellia-192-cbc camellia-192-ecb \ + camellia-256-cbc camellia-256-ecb cast-cbc cast5-cbc cast5-cfb \ + cast5-ecb cast5-ofb des-cbc des-cfb des-ecb des-ede des-ede-cbc \ + des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb \ + des-ede3-ofb des-ofb idea-cbc idea-cfb idea-ecb idea-ofb \ + rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \ + rc4-40 rc5-cbc rc5-cfb rc5-ecb rc5-ofb seed-cbc seed-cfb \ + seed-ecb seed-ofb PBE-MD2-DES PBE-MD5-DES PBE-SHA1-RC2-64 \ + PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES PBE-SHA1-RC4-128 \ + PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 \ + PBE-SHA1-RC2-40) + _arguments -C \ + '-export[output PKCS12 file]' \ + '-chain[add certificate chain]' \ + '-inkey[private key if not infile]:file:_files' \ + '-certfile[add all certs in the specified file]:file:_files' \ + "-CApath[PEM format directory of CA's]:file:_files" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + '-name[use specified friendly name]:name: ' \ + '*-caname[use specified CA friendly name]:name: ' \ + '-in[input filename]:file:_files' \ + '-out[output filename]:file:_files' \ + "-noout[don't output anything, just verify]" \ + "-nomacver[don't verify MAC]" \ + "-nocerts[don't output certificates]" \ + '-clcerts[only output client certificates]' \ + '-cacerts[only output CA certificates]' \ + "-nokeys[don't output private keys]" \ + '-info[give info about PKCS#12 structure]' \ + '-des[encrypt private keys with DES]' \ + '-des3[encrypt private keys with triple DES (default)]' \ + '-idea[encrypt private keys with idea]' \ + '-seed[encrypt private keys with seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + "-nodes[don't encrypt private keys]" \ + "-noiter[don't use encryption iteration]" \ + "-nomaciter[don't use MAC iteration]" \ + '-maciter[use MAC iteration]' \ + "-nomac[don't generate MAC]" \ + '-twopass[separate MAC, encryption passwords]' \ + '-descert[encrypt PKCS#12 certificates with triple DES (default RC2-40)]' \ + "-certpbe[specify certificate PBE algorithm (default RC2-40)]:alg:(${algorithms})" \ + '-keypbe[specify private key PBE algorithm (default 3DES)]:alg:(${algorithms})' \ + '-macalg[digest algorithm used in MAC (default SHA1)]:alg:_list_message_digest_algorithms' \ + '-keyex[set MS key exchange type]' \ + '-keysig[set MS key signature type]' \ + '-password[set import/export password source]:pass phrase source:_pass_phrase_source' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-CSP[Microsoft CSP name]:name: ' \ + '-LMK[add local machine keyset attribute to private key]' +} + + +_openssl_pkcs7() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-print_certs[print any certs or crl in the input]' \ + '-text[print full details of certificates]' \ + "-noout[don't output encoded data]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkcs8() { + # written for openssl 1.0.2d + _arguments -C \ + '-in[input file]:file:_files' \ + '-inform[input format]:format:(PEM DER)' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-outform[output format]:format:(PEM DER)' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-topk8[output PKCS8 file]' \ + '-nooct[use (nonstandard) no octet format]' \ + '-embed[use (nonstandard) embedded DSA parameters format]' \ + '-nsdb[use (nonstandard) DSA Netscape DB format]' \ + '-noiter[use 1 as iteration count]' \ + '-nocrypt[use or expect unencrypted private key]' \ + '-v2[use PKCS#5 v2.0 and given cipher]:alg:(aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc aes-256-ecb bf bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc camellia-128-ecb camellia-192-cbc camellia-192-ecb camellia-256-cbc camellia-256-ecb cast cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx idea idea-cbc idea-cfb idea-ecb idea-ofb rc2 rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40 rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb seed seed-cbc seed-cfb seed-ecb seed-ofb)' \ + '-v2prf[set the PRF algorithm to use with PKCS#5 v2.0]:alg:(hmacWithMD5 hmacWithRMD160 hmacWithSHA1 hmacWithSHA224 hmacWithSHA256 hmacWithSHA384 hmacWithSHA512)' \ + '-v1[use PKCS#5 v1.5 and given cipher]:obj:(PBE-MD2-DES PBE-MD5-DES PBE-SHA1-RC2-64 PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES PBE-SHA1-RC4-128 PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 PBE-SHA1-RC2-40)' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkey() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-inform[input format]:format:(PEM DER)' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-outform[output format]:format:(PEM DER)' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkeyparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[the input filename to read parameters from]:file:_files' \ + '-out[the output filename to write parameters]:file:_files' \ + '-text[prints out the parameters in plain text in addition to the encoded version]' \ + '-noout[do not output the encoded version of the parameters]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkeyutl() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-sigfile[signature file (verify operation only)]:file:_files' \ + '-inkey[input key]:file:_files' \ + '-keyform[private key format]:format:(PEM DER)' \ + '-pubin[input is a public key]' \ + '-certin[input is a certificate carrying a public key]' \ + '-pkeyopt[public key options]:option\:value:_pkeyopts' \ + '-sign[sign with private key]' \ + '-verify[verify with public key]' \ + '-verifyrecover[verify with public key, recover original data]' \ + '-encrypt[encrypt with public key]' \ + '-decrypt[decrypt with private key]' \ + '-derive[derive shared secret]' \ + '-hexdump[hex dump output]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[pass phrase source]:pass phrase source:_pass_phrase_source' +} + + +_openssl_prime() { + # written for openssl 1.0.1k + _arguments -C \ + '-hex[hex]' \ + '-checks[number of checks]:checks: ' \ + ':number:' +} + + +_openssl_rand() { + # written for openssl 1.0.1k + _arguments -C \ + '-out[write to file]:file:_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-base64[base64 encode output]' \ + '-hex[hex encode output]' \ + ':num:' +} + + +_openssl_req() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-text[text form of request]' \ + '-pubkey[output public key]' \ + '-noout[do not output REQ]' \ + '-verify[verify signature on REQ]' \ + '-modulus[RSA modulus]' \ + "-nodes[don't encrypt the output key]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "-subject[output the request's subject]" \ + '-passin[private key pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-key[use the private key contained in the specified file]:file:_files' \ + '-keyform[key file format]:format:(PEM DER)' \ + '-keyout[file to send the key to]:file:_files' \ + '-rand[files to use for random number input]:file:_rand_files' \ + "-newkey rsa\:-[generate a new RSA key of the specified number of bits in size]:bits: " \ + "-newkey dsa\:[generate a new DSA key, parameters taken from CA in the specified file]:file:_files" \ + "-newkey ec\:[generate a new EC key, parameters taken from CA in the specified file]:file:_files" \ + '-md2[digest to sign with]' \ + '-md4[digest to sign with]' \ + '-md5[digest to sign with]' \ + '-mdc2[digest to sign with]' \ + '-sha1[digest to sign with]' \ + '-config[request template file]:file:_files' \ + '-subj[set or modify request subject]:subject: ' \ + '-multivalue-rdn[enable support for multivalued RDNs]' \ + '-new[new request]' \ + '-batch[do not ask anything during request generation]' \ + '-x509[output a x509 structure instead of a certificate request]' \ + '-days[number of days a certificate generated by -x509 is valid for]:days: ' \ + '-set_serial[serial number to use for a certificate generated by -x509]:serial: ' \ + '-newhdr[output "NEW" in the header lines]' \ + "-asn1-kludge[output the 'request' in a format that is wrong but some CA's have been reported as requiring]" \ + '-extensions[specify certificate extension section (override value in config file)]:section: ' \ + '-reqexts[specify request extension section (override value in config file)]:section: ' \ + '-utf8[input characters are UTF8 (default ASCII)]' \ + '*-nameopt[various certificate name options]:options:_nameopts' \ + '*-reqopt[- various request text options]:options:_certopts' + # TODO: complete -extensions and -reqexts +} + + +_openssl_rsa() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER NET)' \ + '-outform[output format]:format:(PEM DER NET)' \ + '-in[input file]:file:_files' \ + '-sgckey[use IIS SGC key format]' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-des[encrypt PEM output with cbc des]' \ + '-des3[encrypt PEM output with ede cbc des using 168 bit key]' \ + '-idea[encrypt PEM output with cbc idea]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-text[print the key in text]' \ + "-noout[don't print key out]" \ + '-modulus[print the RSA key modulus]' \ + '-check[verify key consistency]' \ + '-pubin[expect a public key in input file]' \ + '-pubout[output a public key]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_rsautl() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-inkey[input key]:file:_files' \ + '-keyform[private key format]:format:(PEM DER)' \ + '-pubin[input is an RSA public]' \ + '-certin[input is a certificate carrying an RSA public key]' \ + '-ssl[use SSL v2 padding]' \ + '-raw[use no padding]' \ + '-pkcs[use PKCS#1 v1.5 padding (default)]' \ + '-oaep[use PKCS#1 OAEP]' \ + '-sign[sign with private key]' \ + '-verify[verify with public key]' \ + '-encrypt[encrypt with public key]' \ + '-decrypt[decrypt with private key]' \ + '-hexdump[hex dump output]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[pass phrase source]:pass phrase source:_pass_phrase_source' +} + + +_openssl_s_client() { + # written for openssl 1.0.1k + _arguments -C \ + '(-6)-4[use IPv4 only]' \ + '(-4)-6[use IPv6 only]' \ + '(-connect)-host[use -connect instead]:host: ' \ + '(-connect)-port[use -connect instead]:port: ' \ + '(-host -port)-connect[who to connect to (default is localhost:4433)]:host\:port: ' \ + '-verify[turn on peer certificate verification]:depth: ' \ + '-verify_return_error[return verification errors]' \ + '-cert[certificate file to use, PEM format assumed]:file:_files' \ + '-certform[certificate format (PEM or DER) PEM default]:format:(PEM DER)' \ + '-key[private key file to use, in cert file if not specified but cert file is]:file:_files' \ + '-keyform[key format (PEM or DER) PEM default]:format:(PEM DER)' \ + '-pass[private key file pass phrase source]:pass phrase source:_pass_phrase_source' \ + "-CApath[PEM format directory of CA's]:directory:_files -/" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + '-reconnect[drop and re-make the connection with the same Session-ID]' \ + '-pause[sleep(1) after each read(2) and write(2) system call]' \ + '-prexit[print session information even on connection failure]' \ + '-showcerts[show all certificates in the chain]' \ + '-debug[extra output]' \ + '-msg[show protocol messages]' \ + '-nbio_test[more ssl protocol testing]' \ + "-state[print the 'ssl' states]" \ + '-nbio[run with non-blocking IO]' \ + '-crlf[convert LF from terminal into CRLF]' \ + '-quiet[no s_client output]' \ + '(-no_ign_eof)-ign_eof[ignore input eof (default when -quiet)]' \ + "(-ign_eof)-no_ign_eof[don't ignore input eof]" \ + '-psk_identity[PSK identity]:identity: ' \ + '-psk[PSK in hex (without 0x)]:key: ' \ + "-srpuser[SRP authentication for 'user']:user: " \ + "-srppass[password for 'user']:password: " \ + '-srp_lateuser[SRP username into second ClientHello message]' \ + '-srp_moregroups[tolerate other than the known g N values]' \ + '-srp_strength[minimal length in bits for N (default 1024)]:int: ' \ + '(-no_ssl2 -ssl3 -tls1 -tls1_1 -tls1_2 -dtls1)-ssl2[just use SSLv2]' \ + '(-no_ssl3 -ssl2 -tls1 -tls1_1 -tls1_2 -dtls1)-ssl3[just use SSLv3]' \ + '(-no_tls1_2 -ssl2 -ssl3 -tls1 -tls1_1 -dtls1)-tls1_2[just use TLSv1.2]' \ + '(-no_tls1_1 -ssl2 -ssl3 -tls1 -tls1_1 -dtls1)-tls1_1[just use TLSv1.1]' \ + '(-no_tls1 -ssl2 -ssl3 -tls1 -tls1_1 -dtls1)-tls1[just use TLSv1.0]' \ + '(-no_dtls1 -ssl2 -ssl3 -tls1 -tls1_1 -tls1_2)-dtls1[just use DTLSv1]' \ + '-fallback_scsv[send TLS_FALLBACK_SCSV]' \ + '-mtu[set the link layer MTU]' \ + '(-tls1_2)-no_tls1_2[turn off TLSv1.2]' \ + '(-tls1_1)-no_tls1_1[turn off TLSv1.1]' \ + '(-tls1)-no_tls1[turn off TLSv1.0]' \ + '(-ssl3)-no_ssl3[turn off SSLv3]' \ + '(-ssl2)-no_ssl2[turn off SSLv2]' \ + '-bugs[switch on all SSL implementation bug workarounds]' \ + "-serverpref[use server's cipher preferences (only SSLv2)]" \ + '-cipher[preferred cipher to use]:cipher suite:_list_ciphers' \ + "-starttls[use the STARTTLS command before starting TLS for those protocols that support it]:protocol:(smtp pop3 imap ftp xmpp)" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-sess_out[file to write SSL session to]:file:_files' \ + '-sess_in[file to read SSL session from]:file:_files' \ + '-servername[set TLS extension servername in ClientHello]:host: ' \ + '-tlsextdebug[hex dump of all TLS extensions received]' \ + '-status[request certificate status from server]' \ + '-no_ticket[disable use of RFC4507bis session tickets]' \ + '-nextprotoneg[enable NPN extension, considering named protocols supported (comma-separated list)]:protocols: ' \ + '-legacy_renegotiation[enable use of legacy renegotiation (dangerous)]' \ + '-use_srtp[offer SRTP key management with a colon-separated profile list]:profiles: ' \ + '-keymatexport[export keying material using label]:label: ' \ + '-keymatexportlen[export len bytes of keying material (default 20)]:len: ' +} + + +_openssl_s_server() { + # written for openssl 1.0.1k + _arguments -C \ + '-accept[port to accept on (default is 4433)]:port: ' \ + '-context[set session ID context]:id: ' \ + '-verify[turn on peer certificate verification]:depth: ' \ + '-Verify[turn on peer certificate verification, must have a cert]:depth: ' \ + '-verify_return_error[return verification errors]' \ + '-cert[certificate file to use (default is server.pem)]:file:_files' \ + '-crl_check[check the peer certificate has not been revoked by its CA]' \ + '-crl_check_all[check the peer certificate has not been revoked by its CA or any other CRL in the CA chain]' \ + '-certform[certificate format]:format:(PEM DER)' \ + '-key[Private Key file to use, in cert file if not specified (default is server.pem)]:file:_files' \ + '-keyform[key format]:format:(PEM DER ENGINE)' \ + '-pass[private key file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-dcert[second certificate file to use (usually for DSA)]:file:_files' \ + '-dcertform[second certificate format]:format:(PEM DER)' \ + '-dkey[second private key file to use (usually for DSA)]:file:_files' \ + '-dkeyform[second key format]:format:(PEM DER ENGINE)' \ + '-dpass[second private key file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-dhparam[DH parameter file to use, in cert file if not specified or a default set of parameters is used]:file:_files' \ + '-named_curve[elliptic curve name to use for ephemeral ECDH keys. (default is nistp256)]:named curve:_list_curves' \ + '-nbio[run with non-blocking IO]' \ + '-nbio_test[test with the non-blocking test bio]' \ + '-crlf[convert LF from terminal into CRLF]' \ + '-debug[print more output]' \ + '-msg[show protocol messages]' \ + '-state[print the SSL states]' \ + "-CApath[PEM format directory of CA's]:file:_files -/" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + "-nocert[don't use any certificates (Anon-DH)]" \ + '-cipher[preferred cipher to use]:cipher suite:_list_ciphers' \ + "-serverpref[use server's cipher preferences]" \ + '-quiet[no server output]' \ + '-no_tmp_rsa[do not generate a tmp RSA key]' \ + '-psk_hint[PSK identity hint to use]:hint: ' \ + '-psk[PSK in hex (without 0x)]:PSK: ' \ + '-srpvfile[the verifier file for SRP]:file:_files' \ + '-srpuserseed[a seed string for a default user salt]:seed: ' \ + '-ssl2[just talk SSLv2]' \ + '-ssl3[just talk SSLv3]' \ + '-tls1_2[just talk TLSv1.2]' \ + '-tls1_1[just talk TLSv1.1]' \ + '-tls1[just talk TLSv1]' \ + '-dtls1[just talk DTLSv1]' \ + '-timeout[enable timeouts]' \ + '-mtu[set link layer MTU]' \ + '-chain[read a certificate chain]' \ + '-no_ssl2[just disable SSLv2]' \ + '-no_ssl3[just disable SSLv3]' \ + '-no_tls1[just disable TLSv1]' \ + '-no_tls1_1[just disable TLSv1.1]' \ + '-no_tls1_2[just disable TLSv1.2]' \ + '-no_dhe[disable ephemeral DH]' \ + '-no_ecdhe[disable ephemeral ECDH]' \ + '-bugs[turn on SSL bug compatibility]' \ + '-hack[workaround for early Netscape code]' \ + "-www[respond to a 'GET /' with a status page]" \ + "-WWW[respond to a 'GET / HTTP/1.0' with file ./]" \ + "-HTTP[respond to a 'GET / HTTP/1.0' with file ./ with the assumption it contains a complete HTTP response]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-id_prefix[generate SSL/TLS session IDs prefixed by arg]:prefix: ' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-servername[servername for HostName TLS extension]:hostname: ' \ + '-servername_fatal[on mismatch send fatal alert (default warning alert)]' \ + '-cert2[certificate file to use for servername (default is server2.pem)]:file:_files' \ + '-key2[Private Key file to use for servername, in cert file if not specified (default is server2.pem)]:file:_files' \ + '-tlsextdebug[hex dump of all TLS extensions received]' \ + '-no_ticket[disable use of RFC4507bis session tickets]' \ + '-legacy_renegotiation[enable use of legacy renegotiation (dangerous)]' \ + '-nextprotoneg[set the advertised protocols for the NPN extension (comma-separated list)]:protocol:(http/1.0 http/1.1)' \ + '-use_srtp[offer SRTP key management with a colon-separated profile list]:profiles: ' \ + '-4[use IPv4 only]' \ + '-6[use IPv6 only]' \ + '-keymatexport[export keying material using label]:label: ' \ + '-keymatexportlen[export len bytes of keying material (default 20)]:length: ' \ + '-status[respond to certificate status requests]' \ + '-status_verbose[enable status request verbose printout]' \ + '-status_timeout[status request responder timeout]:seconds: ' \ + '-status_url[status request fallback URL]:URL: ' + # TODO: srtp profiles +} + + +_openssl_s_time() { + # written for openssl 1.0.1k + _arguments -C \ + '-connect[host:port to connect to (default is localhost:4433)]:host\:port: ' \ + '-nbio[run with non-blocking IO]' \ + '-ssl2[just use SSLv2]' \ + '-ssl3[just use SSLv3]' \ + '-bugs[turn on SSL bug compatibility]' \ + '-new[just time new connections]' \ + '-reuse[just time connection reuse]' \ + "-www[retrieve the specified page from the site]:page: " \ + '-time[max number of seconds to collect data, default 30]:seconds: ' \ + '-verify[turn on peer certificate verification]:depth: ' \ + '-cert[certificate file to use, PEM format assumed]:file:_files' \ + '-key[RSA file to use, PEM format assumed, key is in cert file]:file:_files' \ + "-CApath[PEM format directory of CA's]:file:_files -/" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + '-cipher[preferred cipher to use]:cipher suite:_list_ciphers' +} + + +_openssl_sess_id() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file (default stdin)]:file:_files' \ + '-out[output file (default stdout)]:file:_files' \ + '-text[print ssl session id details]' \ + '-cert[output certificate ]' \ + '-noout[no CRL output]' \ + '-context[set the session ID context]:id: ' +} + + +_openssl_smime() { + # written for openssl 1.0.1k + _arguments -C \ + '-encrypt[encrypt message]' \ + '-decrypt[decrypt encrypted message]' \ + '-sign[sign message]' \ + '-verify[verify signed message]' \ + '-pk7out[output PKCS#7 structure]' \ + '-des3[encrypt with triple DES]' \ + '-des[encrypt with DES]' \ + '-seed[encrypt with SEED]' \ + '-rc2-40[encrypt with RC2-40 (default)]' \ + '-rc2-64[encrypt with RC2-64]' \ + '-rc2-128[encrypt with RC2-128]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + "-nointern[don't search certificates in message for signer]" \ + "-nosigs[don't verify message signature]" \ + "-noverify[don't verify signers certificate]" \ + "-nocerts[don't include signers certificate when signing]" \ + '-nodetach[use opaque signing]' \ + "-noattr[don't include any signed attributes]" \ + "-binary[don't translate message to text]" \ + '-certfile[other certificates file]:file:_files' \ + '-signer[signer certificate file]:file:_files' \ + '-recip[recipient certificate file for decryption]:file:_files' \ + '-in[input file]:file:_files' \ + '-inform[input format]:format:(SMIME PEM DER)' \ + '-inkey[input private key (if not signer or recipient)]:file:_files' \ + '-keyform[input private key format]:format:(PEM ENGINE)' \ + '-out[output file]:file:_files' \ + '-outform[output format]:format:(SMIME PEM DER)' \ + '-content[supply or override content for detached signature]:file:_files' \ + '-to[to address]:address: ' \ + '-from[from address]:address: ' \ + '-subject[subject]:subject: ' \ + '-text[include or delete text MIME headers]' \ + '-CApath[trusted certificates directory]:directory:_files -/' \ + '-CAfile[trusted certificates file]:file:_files' \ + "-crl_check[check revocation status of signer's certificate using CRLs]" \ + "-crl_check_all[check revocation status of signer's certificate chain using CRLs]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':certificate:_files' +} + + +_openssl_speed() { + # written for openssl 1.0.1k + local algorithms + algorithms=(mdc2 md4 md5 hmac sha1 sha256 sha512 whirlpoolrmd160 idea-cbc \ + seed-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 aes-128-cbc \ + aes-192-cbc aes-256-cbc aes-128-ige aes-192-ige aes-256-ige \ + camellia-128-cbc camellia-192-cbc camellia-256-cbc rc4 rsa512 \ + rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 ecdsap160 \ + ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521 ecdsak163 \ + ecdsak233 ecdsak283 ecdsak409 ecdsak571 ecdsab163 ecdsab233 \ + ecdsab283 ecdsab409 ecdsab571 ecdsa ecdhp160 ecdhp192 ecdhp224 \ + ecdhp256 ecdhp384 ecdhp521 ecdhk163 ecdhk233 ecdhk283 ecdhk409 \ + ecdhk571 ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571 ecdh idea \ + seed rc2 des aes camellia rsa blowfish) + _arguments -C \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-evp[use the specified EVP]:EVP: ' \ + '-decrypt[time decryption instead of encryption (only EVP)]' \ + '-mr[produce machine readable output]' \ + '-multi[run n benchmarks in parallel]:benchmarks: ' \ + "*:algorithm:(${algorithms})" +} + + +_openssl_spkac() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-key[create SPKAC using private key]:file:_files' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-challenge[challenge string]:string: ' \ + '-spkac[alternative SPKAC name]:spkacname: ' \ + '-spksect[alternative section name]:section: ' \ + "-noout[don't print SPKAC]" \ + '-pubkey[output public key]' \ + '-verify[verify SPKAC signature]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_srp() { + # written for openssl 1.0.1k + _arguments -C \ + '-verbose[talk a lot while doing things]' \ + '-config[a config file]:file:_files' \ + '-name[the particular srp definition to use]:definition: ' \ + '-srpvfile[the srp verifier file name]:file:_files' \ + '(-modify -delete -list)-add[add an user and srp verifier]' \ + '(-add -delete -list)-modify[modify the srp verifier of an existing user]' \ + '(-add -modify -list)-delete[delete user from verifier file]' \ + '(-add -modify -delete)-list[list user]' \ + '-gn[g and N values to be used for new verifier]:g and N: ' \ + '-userinfo[additional info to be set for user]:userinfo: ' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':user:' +} + + +_openssl_ts() { + # written for openssl 1.0.1k + # written for openssl 1.0.2e + local action digests + digests=(-dss1 -md4 -md5 -mdc2 -ripemd160 -sha -sha1 -sha224 -sha256 \ + -sha384 -sha512 -whirlpool) + if [[ "${CURRENT}" -eq 2 ]]; then + # first parameter to ts + _values 'openssl time stamp action' '-query[time stamp request generation]' '-reply[time stamp response generation]' '-verify[time stamp response verification]' + else + action="${words[2]}" + case "${action}" in + -query) + _arguments -C \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-config[config file to use]:file:_files' \ + '(-digest)-data[data file for which the time stamp request needs to be created]:file:_files' \ + '(-data)-digest[digest of the data file]:bytes: ' \ + "($digests)-dss1[use the dss1 message digest algorithm]" \ + "($digests)-md4[to use the md4 message digest algorithm]" \ + "($digests)-md5[to use the md5 message digest algorithm]" \ + "($digests)-mdc2[to use the mdc2 message digest algorithm]" \ + "($digests)-ripemd160[to use the ripemd160 message digest algorithm]" \ + "($digests)-sha[to use the sha message digest algorithm]" \ + "($digests)-sha1[to use the sha1 message digest algorithm]" \ + "($digests)-sha224[to use the sha224 message digest algorithm]" \ + "($digests)-sha256[to use the sha256 message digest algorithm]" \ + "($digests)-sha384[to use the sha384 message digest algorithm]" \ + "($digests)-sha512[to use the sha512 message digest algorithm]" \ + "($digests)-whirlpool[to use the whirlpool message digest algorithm]" \ + '-policy[policy to use for creating the time stamp token]:policy ID: ' \ + '-no_nonce[do not include a nonce in the request]' \ + '-cert[request a signing certificate in the response]' \ + '-in[use the previously created time stamp request]:file:_files' \ + '-out[name of the output file to which the request will be written]:file:_files' \ + '-text[output in human-readable format instead of DER]' + ;; + -reply) + _arguments -C \ + '-config[config file to use]:file:_files' \ + '-section[config file section for response generation]:section: ' \ + '-queryfile[file containing a DER encoded time stamp request]:file:_files' \ + '-passin[private key password source]:pass phrase source:_pass_phrase_source' \ + '-signer[signer certificate of the TSA in PEM format]:file:_files' \ + '-inkey[signer private key in PEM format]:file:_files' \ + '-chain[signer certificate chain in PEM format]:file:_files' \ + '-policy[default policy to use for response]:policy ID: ' \ + '-in[use the previously created time stamp response in DER format]:file:_files' \ + '-token_in[the parameter to -in is a time stamp token in DER format]' \ + '-out[name of the output file to which the response will be written]:file:_files' \ + '-token_out[output a time stamp token instead of a time stamp response]' \ + '-text[output in human-readable format instead of DER]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' + ;; + -verify) + _arguments -C \ + '(-digest -queryfile)-data[verify response against the specified file]:file:_files' \ + '(-data -queryfile)-digest[verify the response against the specified message digest]:digest bytes: ' \ + '(-data -digest)-queryfile[the original time stamp request in DER format]:file:_files' \ + '-in[time stamp response that needs to be verified in DER format]:file:_files' \ + '-token_in[the parameter to -in is a time stamp token in DER format]' \ + '-CApath[directory containing the trusted CA certificates of the client]:directory:_files -/' \ + '-CAFile[file containing a set of trusted self-signed CA certificates in PEM format]:file:_files' \ + '-untrusted[set of additional untrusted certificates in PEM format which may be needed when building the certificate chain]:file:_files' + ;; + esac + fi +} + + +_openssl_verify() { + # written for openssl 1.0.1k + _arguments -C \ + '-CApath[a directory of trusted certificates]:directory:_files -/' \ + '-CAfile[file A file of trusted certificates]:file:_files' \ + '-purpose[the intended use for the certificate]:purpose:(sslclient sslserver nssslserver smimesign smimeencrypt crlsign any ocsphelper timestampsign)' \ + '*-policy[enable policy processing and add arg to the user-initial-policy-set]:object name or OID: ' \ + '-ignore_critical[ignore critical extensions]' \ + '-attime[perform validation checks using the given time]:timestamp: ' \ + '-check_ss_sig[verify the signature on the self-signed root CA]' \ + "-crlfile[file containing one or more CRL's (in PEM format) to load]:file:_files" \ + '-crl_check[check end entity certificate in CRL]' \ + '-crl_check_all[check all certificates in CRL]' \ + '-policy_check[enables certificate policy processing]' \ + '-explicit_policy[set policy variable require-explicit-policy]' \ + '-inhibit_any[set policy variable inhibit-any-policy]' \ + '-inhibit_map[set policy variable inhibit-policy-mapping]' \ + '-x509_strict[strict X.509-compliance]' \ + '-extended_crl[enable extended CRL features]' \ + '-use_deltas[enable support for delta CRLs]' \ + '-policy_print[print out diagnostics related to policy processing]' \ + '-untrusted[a file of untrusted certificates]:file:_files' \ + '(-*)-help[print out a usage message]' \ + '-issuer_checks[print out diagnostics relating to searches for the issuer certificate of the current certificate]' \ + '-verbose[print extra information about the operations being performed]' \ + '*:certificate:_files' + # TODO: - may be used to separate certificates from options + # TODO: Do not hardcode purposes +} + + +_openssl_version() { + # written for openssl 1.0.1k + _arguments -C \ + '-a[all information, this is the same as setting all the other flags]' \ + '-v[the current OpenSSL version]' \ + '-b[the date the current version of OpenSSL was built]' \ + '-o[option information: various options set when the library was built]' \ + '-f[compilation flags]' \ + '-p[platform setting]' \ + '-d[OPENSSLDIR setting]' +} + + +_openssl_x509() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - default PEM (one of DER, NET or PEM)]:format:(DER NET PEM)' \ + '-outform[output format - default PEM (one of DER, NET or PEM)]:arg:(DER NET PEM)' \ + '-keyform[private key format - default PEM]:arg:(DER PEM)' \ + '-CAform[CA format - default PEM]:arg:(DER PEM)' \ + '-CAkeyform[CA key format - default PEM]:arg:(DER PEM)' \ + '-in[input file - default stdin]:file:_files' \ + '-out[output file - default stdout]:file:_files' \ + '-passin[private key password source]:pass phrase source:_pass_phrase_source' \ + '-serial[print serial number value]' \ + '-subject_hash[print subject hash value]' \ + '-subject_hash_old[print old-style (MD5) subject hash value]' \ + '-issuer_hash[print issuer hash value]' \ + '-issuer_hash_old[print old-style (MD5) issuer hash value]' \ + '-hash[synonym for -subject_hash]' \ + '-subject[print subject DN]' \ + '-issuer[print issuer DN]' \ + '-email[print email address(es)]' \ + '-startdate[notBefore field]' \ + '-enddate[notAfter field]' \ + '-purpose[print out certificate purposes]' \ + '-dates[both Before and After dates]' \ + '-modulus[print the RSA key modulus]' \ + '-pubkey[output the public key]' \ + '-fingerprint[print the certificate fingerprint]' \ + '-alias[output certificate alias]' \ + '-noout[no certificate output]' \ + '-ocspid[print OCSP hash values for the subject name and public key]' \ + '-ocsp_uri[print OCSP Responder URL(s)]' \ + '-trustout[output a "trusted" certificate]' \ + '-clrtrust[clear all trusted purposes]' \ + '-clrreject[clear all rejected purposes]' \ + '-addtrust[trust certificate for a given purpose]:purpose:(clientAuth serverAuth emailProtection)' \ + '-addreject[reject certificate for a given purpose]:purpose:(clientAuth serverAuth emailProtection)' \ + '-setalias[set certificate alias]:alias: ' \ + '-days[how long till expiry of a signed certificate (default 30 days)]:days: ' \ + '-checkend[check whether the cert expires in the specified time]:seconds: ' \ + '-signkey[self sign cert with arg]:file:_files' \ + '-x509toreq[output a certification request object]' \ + '-req[input is a certificate request, sign and output]' \ + '-CA[set the CA certificate, must be PEM format]:file:_files' \ + '-CAkey[set the CA key, must be PEM format]:file:_files' \ + '-CAcreateserial[create serial number file if it does not exist]' \ + '-CAserial[serial file]:file:_files' \ + '-set_serial[serial number to use]' \ + '-text[print the certificate in text form]' \ + '-C[print out C code forms]' \ + '(-md5 -sha1 -mdc2)-md2[digest to use]' \ + '(-md2 -sha1 -mdc2)-md5[digest to use]' \ + '(-md2 -md5 -mdc2)-sha1[digest to use]' \ + '(-md2 -md5 -sha1)-mdc2[digest to use]' \ + '-extfile[configuration file with X509V3 extensions to add]' \ + '-extensions[section from config file with X509V3 extensions to add]' \ + '-clrext[delete extensions before signing and input certificate]' \ + '*-nameopt[various certificate name options]:options:_nameopts' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '*-certopt[various certificate text options]:options:_certopts' +} + + +_pass_phrase_source() { + # pass:password + # env:var + # file:pathname + # fd:number + # stdin + _values -S : 'pass phrase source' \ + 'pass[obtain the password from the command line]:password: ' \ + 'env[obtain the password from the environment variable var]:var:_parameters -g "*export*"' \ + 'file[obtain the password from a file]:file:_files' \ + 'fd[read the password from the file descriptor number]:number: ' \ + 'stdin[read the password from standard input]' +} + + +_rand_files() { + # FIXME: this does not allow using multiple files separated by : + # the following would probably work, but how to generate $files? + #_values -s : -S ' ' 'random source file or directory' ${files} + _files +} + + +_engines() { + # openssl engines + local engines + engines=(${${${(@f)"$(_call_program engines openssl engine)"}%)*}#\(}) + _values 'engines' ${engines} +} + + +_list_ciphers() { + # openssl ciphers + local ciphers + # add cipher suites + ciphers=(${(@s/:/)"$(_call_program ciphers openssl ciphers)"}) + # add static cipher strings + ciphers=(${ciphers} \ + 'DEFAULT[the default cipher list]' \ + 'COMPLEMENTOFDEFAULT[the ciphers included in ALL but not enabled by default]' \ + 'ALL[all cipher suites except the eNULL ciphers]' \ + 'COMPLEMENTOFALL[the cipher suites not enabled by ALL]' \ + 'HIGH["high" encryption cipher suites]' \ + 'MEDIUM["medium" encryption cipher suites]' \ + 'LOW["low" encryption cipher suites]' \ + {EXP,EXPORT}'[export encryption algorithms]' \ + 'EXPORT40[40 bit export encryption algorithms]' \ + 'EXPORT56[56 bit export encryption algorithms]' \ + {eNULL,NULL}'[ciphers offering no encryption]' \ + 'aNULL[ciphers offering no authentication]' \ + {kRSA,RSA}'[cipher suites using RSA key exchange]' \ + 'kDHr[cipher suites using DH key agreement signed by CAs with RSA keys]' \ + 'kDHd[cipher suites using DH key agreement signed by CAs with DSS keys]' \ + 'kDH[cipher suites using DH key agreement]' \ + {kDHE,kEDH}'[cipher suites using ephemeral DH key agreement, including anonymous cipher suites]' \ + {DHE,EDH}'[cipher suites using authenticated ephemeral DH key agreement]' \ + 'ADH[anonymous DH cipher suites, not including anonymous ECDH ciphers]' \ + 'DH[cipher suites using DH, including anonymous DH, ephemeral DH and fixed DH]' \ + 'kECDHr[cipher suites using fixed ECDH key agreement signed by CAs with RSA keys]' \ + 'kECDHe[cipher suites using fixed ECDH key agreement signed by CAs with ECDSA keys]' \ + 'kECDH[cipher suites using fixed ECDH key agreement]' \ + {kECDHE,kEECDH}'[cipher suites using ephemeral ECDH key agreement, including anonymous cipher suites]' \ + {ECDHE,kEECDH}'[cipher suites using authenticated ephemeral ECDH key agreement]' \ + 'AECDH[anonymous Elliptic Curve Diffie Hellman cipher suites]' \ + 'ECDH[cipher suites using ECDH key exchange, including anonymous, ephemeral and fixed ECDH]' \ + 'aRSA[cipher suites using RSA authentication]' \ + {aDSS,DSS}'[cipher suites using DSS authentication]' \ + 'aDH[cipher suites effectively using DH authentication]' \ + 'aECDH[cipher suites effectively using ECDH authentication]' \ + {aECDSA,ECDSA}'[cipher suites using ECDSA authentication]' \ + 'TLSv1.2[TLSv1.2 cipher suites]' \ + 'TLSv1[TLSv1.0 cipher suites]' \ + 'SSLv3[SSLv3.0 cipher suites]' \ + 'SSLv2[SSLv2.0 cipher suites]' \ + 'AES128[cipher suites using 128 bit AES]' \ + 'AES256[cipher suites using 256 bit AES]' \ + 'AES[cipher suites using AES]' \ + 'AESGCM[AES in Galois Counter Mode (GCM)]' \ + 'CAMELLIA128[cipher suites using 128 bit CAMELLIA]' \ + 'CAMELLIA256[cipher suites using 256 bit CAMELLIA]' \ + 'CAMELLIA[cipher suites using CAMELLIA]' \ + '3DES[cipher suites using triple DES]' \ + 'DES[cipher suites using DES (not triple DES)]' \ + 'RC4[cipher suites using RC4]' \ + 'RC2[cipher suites using RC2]' \ + 'IDEA[cipher suites using IDEA]' \ + 'SEED[cipher suites using SEED]' \ + 'MD5[cipher suites using MD5]' \ + {SHA1,SHA}'[cipher suites using SHA1]' \ + 'SHA256[cipher suites using SHA256]' \ + 'SHA384[cipher suites using SHA284]' \ + 'aGOST[cipher suites using GOST R 34.10 for authentication]' \ + 'aGOST01[cipher suites using GOST R 34.10-2001 authentication]' \ + 'aGOST94[cipher suites using GOST R 34.10-94 authentication]' \ + 'kGOST[cipher suites, using VKO 34.10 key exchange]' \ + 'GOST94[cipher suites, using HMAC based on GOST R 34.11-94]' \ + 'GOST89MAC[cipher suites using GOST 28147-89 MAC instead of HMAC]' \ + 'PSK[cipher suites using pre-shared keys (PSK)]' \ + 'SUITEB128[suite B mode operation using 128 or 192 bit level of security]' \ + 'SUITEB128ONLY[suite B mode operation using 128 bit level of security]' \ + 'SUITEB192[suite B mode operation using 192 bit level of security]' \ + ) + # FIXME: support !, + and - before each cipher suite + _values -s : 'cipher suite' ${ciphers} +} + + +_list_curves() { + # openssl ecparam -list_curves + local curves not_curves + curves="$(_call_program list_curves openssl ecparam -list_curves)" + # identify lines that do not contain curve names but only descriptions + not_curves=(${${(f)curves[@]}:#*:*}) + # remove non-curve lines, trailing descriptions and leading spaces + curves=(${${${${(f)curves[@]}:|not_curves}%:*}##* }) + _values 'named curves' ${curves} +} + + +_list_message_digest_algorithms() { + # openssl list-message-digest-algorithms + local algorithms + algorithms=(${${(@f)"$(_call_program message_digest_algorithms openssl list-message-digest-algorithms)"}%% *}) + _values 'message digest algorithms' ${algorithms} +} + + +_nameopts() { + _values -s ',' -w 'nameopts' \ + '(-compat compat)'{-compat,compat}'[use the old format. This is equivalent to specifying no name options at all]' \ + '(-RFC2253 RFC2253)'{-RFC2253,RFC2253}'[displays names compatible with RFC2253 equivalent to esc_2253, esc_ctrl, esc_msb, utf8, dump_nostr, dump_unknown, dump_der, sep_comma_plus, dn_rev and sname]' \ + '(-oneline oneline)'{-oneline,oneline}'[a oneline format which is more readable than RFC2253. Equivalent to esc_2253, esc_ctrl, esc_msb, utf8, dump_nostr, dump_der, use_quote, sep_comma_plus_space, space_eq and sname options]' \ + '(-multiline multiline)'{-multiline,multiline}'[a multiline format. Equivalent to esc_ctrl, esc_msb, sep_multiline, space_eq, lname and align]' \ + '(-esc_2253 esc_2253)'{-esc_2253,esc_2253}'[escape the "special" characters required by RFC2253 in a field]' \ + '(-esc_ctrl esc_ctrl)'{-esc_ctrl,esc_ctrl}'[escape control characters]' \ + '(-esc_msb esc_msb)'{-esc_msb,esc_msb}'[escape characters with the MSB set]' \ + '(-use_quote use_quote)'{-use_quote,use_quote}'[escapes some characters by surrounding the whole string with " characters]' \ + '(-utf8 utf8)'{-utf8,utf8}'[convert all strings to UTF8 format first]' \ + '(-ignore_type ignore_type)'{-ignore_type,ignore_type}'[this option does not attempt to interpret multibyte characters in any way]' \ + '(-show_type show_type)'{-show_type,show_type}'[show the type of the ASN1 character string]' \ + '(-dump_der dump_der)'{-dump_der,dump_der}'[use DER encoding when hexdumping fields]' \ + '(-dump_nostr dump_nostr)'{-dump_nostr,dump_nostr}'[dump non character string types]' \ + '(-dump_all dump_all)'{-dump_all,dump_all}'[dump all fields]' \ + '(-dump_unknown dump_unknown)'{-dump_unknown,dump_unknown}'[dump any field whose OID is not recognised by OpenSSL]' \ + '(-sep_comma_plus sep_comma_plus)'{-sep_comma_plus,sep_comma_plus}'[these options determine the field separators]' \ + '(-sep_comma_plus_space sep_comma_plus_space)'{-sep_comma_plus_space,sep_comma_plus_space}'[these options determine the field separators]' \ + '(-sep_semi_plus_space sep_semi_plus_space)'{-sep_semi_plus_space,sep_semi_plus_space}'[these options determine the field separators]' \ + '(-sep_multiline sep_multiline)'{-sep_multiline,sep_multiline}'[these options determine the field separators]' \ + '(-dn_rev dn_rev)'{-dn_rev,dn_rev}'[reverse the fields of the DN]' \ + '(-nofname nofname)'{-nofname,nofname}'[do not display field names]' \ + '(-sname sname)'{-sname,sname}'[display field names in short form]' \ + '(-lname lname)'{-lname,lname}'[display field names in long form]' \ + '(-oid oid)'{-oid,oid}'[display field names in numerical form]' \ + '(-align align)'{-align,align}'[align field values for a more readable output. Only usable with sep_multiline]' \ + '(-space_eq space_eq)'{-space_eq,space_eq}'[places spaces around the = character which follows the field name]' +} + + +_certopts() { + _values -s ',' -w 'certopts' \ + 'compatible[use the old format. This is equivalent to specifying no output options at all]' \ + "no_header[don't print header information: that is the lines saying \"Certificate\" and \"Data\"]" \ + "no_version[don't print out the version number]" \ + "no_serial[don't print out the serial number]" \ + "no_signame[don't print out the signature algorithm used]" \ + "no_validity[don't print the validity, that is the notBefore and notAfter fields]" \ + "no_subject[don't print out the subject name]" \ + "no_issuer[don't print out the issuer name]" \ + "no_pubkey[don't print out the public key]" \ + "no_sigdump[don't give a hexadecimal dump of the certificate signature]" \ + "no_aux[don't print out certificate trust information]" \ + "no_extensions[don't print out any X509V3 extensions]" \ + 'ext_default[retain default extension behaviour: attempt to print out unsupported certificate extensions]' \ + 'ext_error[print an error message for unsupported certificate extensions]' \ + 'ext_parse[ASN1 parse unsupported extensions]' \ + 'ext_dump[hex dump unsupported extensions]' \ + '(no_issuer no_pubkey no_header no_version no_sigdump no_signame)ca_default[the value used by the ca utility, equivalent to no_issuer, no_pubkey, no_header, no_version, no_sigdump and no_signame]' +} + + +_openssl "$@" + +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_openvpn3 b/home/.zsh-server/plugins/zsh-completions/src/_openvpn3 new file mode 100644 index 0000000..3f1ca1c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_openvpn3 @@ -0,0 +1,246 @@ +#compdef openvpn3 +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for openvpn 3 (https://github.com/openvpn/openvpn3) (https://openvpn.net/openvpn-client-for-linux/). +# version: 13_beta-1 (Jul 1 2021) +# openvpn 3/Linux git:makepkg:2031975261858750 (openvpn3) +# openvpn core 3.git:HEAD:ce0c9963 linux x86_64 64-bit +# +# ------------------------------------------------------------------------------ +# Author +# ------- +# +# * undg (https://github.com/undg) +# +# ------------------------------------------------------------------------------ + +local sessions_configs_names=$(openvpn3 sessions-list | grep 'Config name:' | awk '{print $3}' | xargs) +local sessions_paths=$(openvpn3 sessions-list | grep 'Path:' | awk '{print $2}' | xargs) +local sessions_interfaces=$(openvpn3 sessions-list | grep 'Device:' | awk '{print $4}' | xargs) +local sessions_users=$(openvpn3 sessions-list | grep 'Owner:' | awk '{print $2}' | xargs) +local sessions_names=$(openvpn3 sessions-list | grep 'Session name:' | awk '{print $2}' | xargs) +local configs_names=$(openvpn3 configs-list | awk 'count&&!--count; /\/net\/openvpn\//{count=2}' | awk '{print $1}' | xargs) +local configs_paths=$(openvpn3 configs-list | grep '/net/openvpn/v3/configuration/' | xargs) + +_openvpn3_config-acl(){ + _arguments \ + {-s,--show}"[Show the current access control lists]" \ + {-o,--path}"[OBJ-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \ + {-S,--seal}"[Make the configuration profile permanently read-only]" \ + {-R,--revoke}"[ Revoke this user access from this configuration profile]" \ + {-G,--grant}"[ Grant this user access to this configuration profile]" \ + "--public-access[ Set/unset the public access flag]" \ + "--lock-down[ Set/unset the lock-down flag.Will disable config retrieval for users]: :(true false)" \ + "--config-path[OBJ-PATH Alias for --path]: :($configs_paths)" \ +} + +_openvpn3_config-import(){ + _arguments \ + {-p,--persistent}"[Make the configuration profile persistent through service restarts]" \ + {-n,--name}"[NAME Provide a different name for the configuration (default: CFG-FILE)]" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CFG-FILE Configuration file to import]: :_files" \ +} + +_openvpn3_config-manage(){ + _arguments \ + {-s,--show}"[Show current configuration options]" \ + {-r,--rename}"[NEW-CONFIG-NAME Renames the configuration]" \ + {-o,--path}"[CONFIG-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \ + "--unset-override[ Removes the override]" \ + "--tls-version-min[ Sets the minimal TLS version for the control channel]: :(tls_1_0 tls_1_1 tls_1_2 tls_1_3)" \ + "--tls-cert-profile[ Sets the control channel tls profile]: :(legacy preferred suiteb)" \ + "--server-override[ Replace the remote, connecting to this server instead the server specified in the configuration]" \ + "--proxy-username[ HTTP Proxy username to authenticate as]" \ + "--proxy-port[ HTTP Proxy port to connect on]" \ + "--proxy-password[ HTTP Proxy password to use for authentication]" \ + "--proxy-host[ HTTP Proxy to connect via, overrides configuration file http-proxy]" \ + "--proxy-auth-cleartext[ Adds the boolean override proxy-auth-cleartext]: :(true false)" \ + "--proto-override[ Overrides the protocol being used]: :(tcp upd)" \ + "--port-override[ Replace the remote port, connecting to this port instead of the configuration value]" \ + "--persist-tun[ Adds the boolean override persist-tun]: :(true false)" \ + "--ipv6[ Sets the IPv6 policy of the client]: :(yes no default)" \ + "--force-cipher-aes-cbc[ Adds the boolean override force-cipher-aes-cbc]: :(true false)" \ + "--dns-sync-lookup[ Adds the boolean override dns-sync-lookup]: :(true false)" \ + "--dns-setup-disabled[ Adds the boolean override dns-setup-disabled]: :(true false)" \ + "--dns-fallback-google[ Adds the boolean override dns-fallback-google]: :(true false)" \ + "--config-path[CONFIG-PATH Alias for --path]: :($configs_paths)" \ + "--auth-fail-retry[ Adds the boolean override auth-fail-retry]: :(true false)" \ + "--allow-compression[ Set compression mode]: :(no asym yes)" \ +} + +_openvpn3_config-remove(){ + _arguments \ + {-o,--path}"[OBJ-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \ + "--force[Force the deletion process without asking for confirmation]" \ + "--config-path[OBJ-PATH Alias for --path]: :($configs_paths)" \ +} + +_openvpn3_config-show(){ + _arguments \ + {-o,--path}"[OBJ-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \ + {-j,--json}"[Dump the configuration in JSON format]" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \ + "--config-path[OBJ-PATH Alias for --path]: :($configs_paths)" \ +} + +_openvpn3_configs-list(){ + _arguments \ + {-h,--help}"[This help screen]" \ +} + +_openvpn3_help(){ + _arguments \ + {-h,--help}"[This help screen]" \ +} + +_openvpn3_log(){ + _arguments \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --session-path, where configuration profile name is used instead]: :($sessions_configs_names $configs_names)" \ + {-I,--interface}"[INTERFACE Alternative to --session-path, where tun interface name is used instead]: :($sessions_interfaces)" \ + "--session-path[SESSION-PATH Receive log events for a specific session]: :($sessions_paths)" \ + "--log-level[LOG-LEVEL Set the log verbosity level of messages to be shown (default: 4)]" \ + "--config-events[Receive log events issued by the configuration manager]" \ +} + +_openvpn3__session-acl(){ + _arguments \ + {-s,--show}"[Show the current access control lists]" \ + {-o,--path}"[SESSION-PATH Path to the session in the session manager]: :($sessions_paths)" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($sessions_configs_names)" \ + {-R,--revoke}"[ Revoke this user access from this session]" \ + {-I,--interface}"[INTERFACE Alternative to --path, where tun interface name is used instead]: :($sessions_interfaces)" \ + {-G,--grant}"[ Grant this user access to this session]" \ + "--session-path[SESSION-PATH Alias for --path]: :($sessions_paths)" \ + "--public-access[ Set/unset the public access flag]: :(true false)" \ + "--allow-log-access[ Can users granted access also access the session log?]: :(true false)" \ +} + +_openvpn3_session-manage(){ + _arguments \ + {-o,--path}"[SESSION-PATH Path to the session in the session manager]: :($sessions_paths)" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($sessions_configs_names)" \ + {-R,--resume}"[Resumes a paused VPN session]" \ + {-P,--pause}"[Pauses the VPN session]" \ + {-I,--interface}"[INTERFACE Alternative to --path, where tun interface name is used instead]: :($sessions_interfaces)" \ + {-D,--disconnect}"[Disconnects a VPN session]" \ + "--session-path[SESSION-PATH Alias for --path]: :($sessions_paths)" \ + "--restart[Disconnect and reconnect a running VPN session]" \ + "--cleanup[Clean up stale sessions]" \ +} + +_openvpn3_session-start(){ + _arguments \ + {-p,--config-path}"[CONFIG-PATH Configuration path to an already imported configuration]: :($configs_paths)" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-FILE Configuration file to start directly]: :_files" \ + "--persist-tun[Enforces persistent tun/seamless tunnel (requires --config)]" \ +} + +_openvpn3_session-stats(){ + _arguments \ + {-o,--path}"[SESSION-PATH Path to the configuration in the configuration manager]: :($sessions_paths)" \ + {-j,--json}"[Dump the configuration in JSON format]" \ + {-h,--help}"[This help screen]" \ + {-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($sessions_configs_names)" \ + {-I,--interface}"[INTERFACE Alternative to --path, where tun interface name is used instead]: :($sessions_interfaces)" \ + "--session-path[SESSION-PATH Alias for --path]: :($sessions_paths)" \ +} + +_openvpn3_sessions-list(){ + _arguments \ + {-h,--help}"[This help screen]" \ +} + +_openvpn3_shell-completion(){ + _arguments \ + {-h,--help}"[This help screen]" \ + "--list-commands[List all available commands]" \ + "--list-options[COMMAND List all available options for a specific command]: :($(openvpn3 shell-completion --list-commands))" \ + "--arg-helper[OPTION Used together with --list-options, lists value hint to an option]" +} + +_openvpn3_version(){ + _arguments \ + {-h,--help}"[This help screen]" \ +} + + +_openvpn3_command(){ + local -a _openvpn3_cmds + _openvpn3_cmds=( + "config-acl: Manage access control lists for configurations" \ + "config-import: Import configuration profiles" \ + "config-manage: Manage configuration properties" \ + "config-remove: Remove an available configuration profile" \ + "config-show: Show/dump a configuration profile" \ + "configs-list: List all available configuration profiles" \ + "help: This help screen" \ + "log: Receive log events as they occur" \ + "session-acl: Manage access control lists for sessions" \ + "session-manage: Manage VPN sessions" \ + "session-start: Start a new VPN session" \ + "session-stats: Show session statistics" \ + "sessions-list: List available VPN sessions" \ + "shell-completion: Helper function to provide shell completion data" \ + "version: Show program version information" \ + ) + + if ((CURRENT == 1)); then + _describe -t commands 'openvpn3 commands' _openvpn3_cmds + else + local curcontext="$curcontext" + cmd="${${_openvpn3_cmds[(r)$words[1]:*]%%:*}}" + if (($#cmd)); then + if (( $+functions[_openvpn3_$cmd] )); then + _openvpn3_$cmd + else + _message "no options for $cmd" + fi + else + _message "no more options" + fi + fi +} + +_arguments \ + {-h,--help}"[that This help screen]" \ + "*::openvpn3 commands:_openvpn3_command" \ + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_optirun b/home/.zsh-server/plugins/zsh-completions/src/_optirun new file mode 100644 index 0000000..ebc0e00 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_optirun @@ -0,0 +1,75 @@ +#compdef optirun +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for the optirun command from bumblebee +# (https://github.com/Bumblebee-Project/Bumblebee). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Christophe-Marie Duquesne +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line +typeset -A opt_args + +local -a arguments + +arguments=( + '--version[output version information]' + '(-h --help)'{-h,--help}'[show help]' + '(-c --vgl-compress)'{-c,--vgl-compress}'[image transport method]:method:(proxy jpeg rgb xb yuv)' + '--failsafe[run a program even if the nvidia card is unavailable]:boolean:(true false)' + '--no-failsafe[do not run a program if the nvidia card is unavailable]' + '--vgl-options[options to be passed to vglrun (example: +tr)]' + '(-q --quiet --silent)'{-q,--quiet,--silent}'[suppress all logging messages]' + '(-v --verbose)'{-v,--verbose}'[increase the verbosity level of log messages]' + '--debug[set the verbosity level to the maximum]' + '(-b --bridge)'{-b,--bridge}'[specify bridge library to use: VirtualGL, Primus or auto]:method:(auto primus virtualgl none)' + '(-d --display)'{-d,--display}'[the X display number to use]' + '(-C --config)'{-C,--config}'[retrieve settings for Bumblebee from FILE]:file:_files' + '(-l --ldpath)'{-l,--ldpath}'[PATH the libraries like libGL.so are searched in]:file:_files' + '--primus-ldpath[a colon-separated list of paths which are searched for the primus libGL.so.1]:file:_files' + '(-s --socket)'{-s,--socket}'[use FILE for communication with the daemon]:file:_files' + '--no-xorg[do not start secondary X server (implies -b none)]' + '*::arguments: _normal' +) + +_arguments $arguments + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_opustools b/home/.zsh-server/plugins/zsh-completions/src/_opustools new file mode 100644 index 0000000..db3873f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_opustools @@ -0,0 +1,113 @@ +#compdef opusenc opusdec opusinfo + +# ------------------------------------------------------------------------------ +# Copyright (c) 2021 Github zsh-users - http://github.com/zsh-users +# +# Permission is hereby granted, without written agreement and without +# licence or royalty fees, to use, copy, modify, and distribute this +# software and to distribute modified versions of this software for any +# purpose, provided that the above copyright notice and the following +# two paragraphs appear in all copies of this software. +# +# In no event shall the Zsh Development Group be liable to any party for +# direct, indirect, special, incidental, or consequential damages arising out +# of the use of this software and its documentation, even if the Zsh +# Development Group have been advised of the possibility of such damage. +# +# The Zsh Development Group specifically disclaim any warranties, including, +# but not limited to, the implied warranties of merchantability and fitness +# for a particular purpose. The software provided hereunder is on an "as is" +# basis, and the Zsh Development Group have no obligation to provide +# maintenance, support, updates, enhancements, or modifications. +# +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for opus-tools (https://opus-codec.org/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Andre Kugland (https://github.com/kugland) +# +# ------------------------------------------------------------------------------ + +case $service in + opusenc) + _arguments -S \ + '1:input file:_files -g "*.(#i)(wav|flac|ogg|aif(|f))(-.)"' \ + '2:output file:_files -g "*.(#i)opus(-.)"' \ + '(- 1 *)'{-h,--help}'[show usage information]' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '(- 1 *)--help-picture[show help on attaching album art]' \ + '--quiet[enable quiet mode]' \ + '--bitrate[set target bitrate per channel]:target bitrate per channel (kbps) (6-256)' \ + '--comp[set encoding complexity]:encoding complexity (1-10) [10]:(1 2 3 4 5 6 7 8 9 10)' \ + '--cvbr[use constrained variable bitrate encoding]' \ + '--downmix-mono[downmix to mono]' \ + '--downmix-stereo[downmix to stereo (if >2 channels)]' \ + '--expect-loss[set expected packet loss]:expected packet loss (percent) (0-100) [0]' \ + '--framesize[set maximum frame size]:maximum frame size (milliseconds) [20]:(2.5 5 10 20 40 60)' \ + '--hard-cbr[use hard constant bitrate encoding]' \ + '--max-delay[set maximum container delay]:maximum container delay (milliseconds) (0-1000) [1000]' \ + '--music[tune low bitrates for music (override automatic detection)]' \ + '--no-phase-inv[disable use of phase inversion for intensity stereo]' \ + '--speech[tune low bitrates for speech (override automatic detection)]' \ + '--vbr[use variable bitrate encoding (default)]' \ + '--album[set album or collection]:album or collection' \ + '--date[set date of track]:date of track (YYYY, YYYY-MM, or YYYY-MM-DD):_dates -f "%F"' \ + '--discard-comments[discard metadata when transcoding]' \ + '--discard-pictures[discard pictures when transcoding]' \ + '--padding[reserve extra bytes for metadata]:padding size (bytes) [512]' \ + '--title[set track title]:track title' \ + '--tracknumber[set track number]:track number' \ + '*--artist[add artist or author]:artist or author' \ + '*--comment[add an extra comment]:comment (tag=val)' \ + '*--genre[add genre]:genre' \ + '*--picture[attach album art]:album art:_files -g "*.(#i)(jp(|e)g|png|gif)(-.)"' \ + '--ignorelength[ignore the data length in RIFF wav headers]' \ + '--raw-bits[set bits per sample for raw input]:bits per sample [16]:(8 16 24)' \ + '--raw-chan[set number of channels for raw input]:number of channels (1-255) [2]' \ + '--raw-endianness[set endianness for raw input]:endianness:(("0"\:"big endian" "1"\:"little endian"))' \ + '--raw-rate[set sampling rate for raw input]:sample rate (Hz) (100-768000) [48000]' \ + '--raw[interpret input as raw PCM data without headers]' \ + '--serial[force use of a specific stream serial number]:stream serial number' \ + '--save-range[save check values for every frame to a file]:output for check values:_files' \ + '--set-ctl-int[pass encoder control]:encoder control' + ;; + opusdec) + _arguments -S \ + '1:input file:_files -g "*.(#i)opus(-.)"' \ + '2::output file:_files -g "*.(#i)wav(-.)"' \ + '(- 1 *)'{-h,--help}'[show usage information]' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '(- 1 *)--help-picture[show help on attaching album art]' \ + '--quiet[enable quiet mode]' \ + '--rate[force decoding at given sample rate]:sample rate (Hz) (8000-192000)' \ + '--force-stereo[force decoding to stereo]' \ + '--gain[adjust output volume]:gain (dB) (negative is quieter)' \ + '--no-dither[do not dither 16-bit output]' \ + '--float[output 32-bit floating-point samples]' \ + '--force-wav[force RIFF wav header on output]' \ + '--packet-loss[simulate random packet loss]:packet loss probability (percent) (0-100)' \ + '--save-range[save check values for every frame to a file]:output for check values:_files' + ;; + opusinfo) + _arguments -s -S \ + '(- 1 *)-h[show usage information]' \ + '(- 1 *)-V[show version information]' \ + '*-q[make the output quieter]' \ + '*-v[make the output more verbose]' \ + '*:opus file:_files -g "*.(#i)opus(-.)"' + ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_patool b/home/.zsh-server/plugins/zsh-completions/src/_patool new file mode 100644 index 0000000..d132a6c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_patool @@ -0,0 +1,95 @@ +#compdef patool +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for patool (https://github.com/wummel/patool). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sergei Eremenko (https://github.com/SmartFinn) +# +# ------------------------------------------------------------------------------ + +local state line ret=1 + +_arguments -C \ + '(-h --help)'{-h,--help}'[show help message and exit]' \ + '(--non-interactive)'--non-interactive'[do not query for user input]' \ + '(-v --verbose)'{-v,--verbose}'[verbose operation]' \ + '1:cmd:->cmds' \ + '*:arg:->args' && ret=0 + +case $state in + (cmds) + local -a cmds + + cmds=( + 'create:create an archive from given files' + 'diff:show differences between two archives' + 'extract:extract files from given archives' + 'formats:show all supported archive formats' + 'list:list files in archives' + 'repack:repackage archive to a different format' + 'recompress:recompress an archive to smaller size' + 'search:search in archive contents for given pattern' + 'test:test the given archives' + ) + + _describe -t commands 'patool commands' cmds && ret=0 + ;; + (args) + case $line[1] in + (extract) + _arguments \ + '--outdir[extract to the given output directory]:select directory:_files -/' \ + '*:files:_files' && ret=0 + ;; + (formats) + _message 'no more arguments' && ret=0 + ;; + (search) + _arguments \ + '2:search pattern:' \ + '*:files:_files' && ret=0 + ;; + (*) + _arguments \ + '*:files:_files' && ret=0 + ;; + esac + ;; +esac + +return $ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_periscope b/home/.zsh-server/plugins/zsh-completions/src/_periscope new file mode 100644 index 0000000..588c4ef --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_periscope @@ -0,0 +1,36 @@ +#compdef periscope +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Periscope (http://code.google.com/p/periscope). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_arguments \ + '(- : *)'{-h,--help}'[show help message and exit]' \ + '(- : *)--version[show version number and exit]' \ + '*'{-l,--language}'[wanted language]: :_language_codes ISO-639-1' \ + '(-f --force)'{-f,--force}'[replace existing subtitle file]' \ + '(-q --query)'{-q,--query}'[query to send to the subtitles website]:queries' \ + '--list-plugins[list all plugins supported by periscope]' \ + '--list-active-plugins[list all plugins used to search subtitles]' \ + '--cache-folder[cache/config directory to use]: :_files -/' \ + '--quiet[run in quiet mode (only show warn and error messages)]' \ + '--debug[set the logging level to debug]' \ + '*: :_files' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_pgsql_utils b/home/.zsh-server/plugins/zsh-completions/src/_pgsql_utils new file mode 100644 index 0000000..df0d096 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_pgsql_utils @@ -0,0 +1,590 @@ +#compdef psql pg_dump pg_dumpall pg_restore createdb dropdb vacuumdb createuser dropuser initdb +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users, Dominic Mitchell, Johann 'Myrkraverk' Oskarsson, Daniel Serodio, J Smith +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for PostgreSQL utils (http://postgresql.org). +# +# Source: http://www.zsh.org/mla/users/2004/msg01006.html +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Dominic Mitchell +# +# * Johann 'Myrkraverk' Oskarsson +# +# * Daniel Serodio pg_dumpall completion +# +# * J Smith various completion additions +# +# ------------------------------------------------------------------------------ + + +_pgsql_get_identity () { + _pgsql_user=${(v)opt_args[(i)-U|--username]} + _pgsql_port=${(v)opt_args[(i)-p|--port]} + _pgsql_host=${(v)opt_args[(i)-h|--host]} + + _pgsql_params=( + ${_pgsql_user:+"--username=$_pgsql_user"} + ${_pgsql_port:+"--port=$_pgsql_port"} + ${_pgsql_host:+"--host=$_pgsql_host"} + ) +} + +# Postgres Allows specifying the path to the directory containing the +# socket as well as a hostname. +_pgsql_host_or_dir() { + _alternative \ + 'hosts:host:_hosts' \ + 'directories:directory:_directories' +} + +# This creates a port completion list based on socket files on the +# local computer. Be default, Postgres puts them in /tmp/ but Debian +# changed that to /var/run/postgresql/ in their packages. +_pgsql_ports() { + compadd "$@" - /tmp/.s.PGSQL.<->(N:e) /var/run/postgresql/.s.PGSQL.<->(N:e) +} + +_pgsql_users () { + local _pgsql_user _pgsql_port _pgsql_host _pgsql_params + local _pgsql_user_sql + _pgsql_get_identity + + # We use _pgsql_port and _pgsql_host directly here instead of + # _pgsql_params so as to not pick up a partially completed + # username. + _pgsql_params=( + ${_pgsql_port:+"--port=$_pgsql_port"} + ${_pgsql_host:+"--host=$_pgsql_host"} + ) + + _pgsql_user_sql='select r.rolname from pg_catalog.pg_roles r where r.rolcanlogin = true' + + compadd "$@" - $( psql $_pgsql_params[@] -XAqt -c $_pgsql_user_sql template1 2>/dev/null ) + +} + +_pgsql_tables () { + local _pgsql_user _pgsql_port _pgsql_host _pgsql_params + _pgsql_get_identity + + # Need to pull out the database name from the existing arguments. + # This is going to vary between commands. Thankfully, it's only + # used by pg_dump, which always has the dbname in arg1. If it's + # not present it defaults to ${PGDATABASE:-$LOGNAME}, which + # matches (I think) the PostgreSQL behaviour. + + local db + db=${line[1]:-${PGDATABASE:-$LOGNAME}} + + ## Instead of parsing the output of the psql \ commands, we look + ## up the tables ourselves. The following query has been tested + ## with Postgres 8.2 - 9.2. + + local _pgsql_table_sql + _pgsql_table_sql="select n.nspname || '.' || c.relname \ + from pg_catalog.pg_class c \ + left join pg_catalog.pg_namespace n on n.oid = c.relnamespace \ + where c.relkind in ('r', '') \ + and n.nspname <> 'pg_catalog' \ + and n.nspname <> 'information_schema' \ + and n.nspname !~ '^pg_toast' \ + and pg_catalog.pg_table_is_visible( c.oid ) \ + order by 1" + + compadd "$@" - \ + $( psql $_pgsql_params[@] -AXqt -c $_pgsql_table_sql $db 2>/dev/null ) +} + +_pgsql_schemas () { + local _pgsql_user _pgsql_port _pgsql_host _pgsql_params + _pgsql_get_identity + + local db + db=${line[1]:-${PGDATABASE:-$LOGNAME}} + + local _pgsql_schema_sql="select n.nspname \ + from pg_catalog.pg_namespace n \ + where n.nspname !~ '^pg_' \ + and n.nspname <> 'information_schema' \ + order by 1;" + + compadd "$@" - \ + $( psql $_pgsql_params[@] -AXqt -c $_pgsql_schema_sql $db 2>/dev/null ) +} + +_pgsql_databases () { + local _pgsql_user _pgsql_port _pgsql_host _pgsql_params + _pgsql_get_identity + + local _pgsql_services _pgsql_service_files + _pgsql_service_files=(~/.pg_service.conf) + (( $+commands[pg_config] )) && _pgsql_service_files+=$(pg_config --sysconfdir)/pg_service.conf + + _pgsql_services=$( grep -h '^\[.*\]' $_pgsql_service_files 2>/dev/null \ + | sed -e 's/^\[/service=/' -e 's/\].*$//' ) + + local _pgsql_db_sql + _pgsql_db_sql="select d.datname from pg_catalog.pg_database d \ + where d.datname <> 'template0'" + + compadd "$@" - \ + ${(f)_pgsql_services} \ + $( psql $_pgsql_params[@] -AXtq -c $_pgsql_db_sql template1 2>/dev/null ) +} + +_pgsql_encodings () { + local _pgsql_user + _pgsql_get_identity + + local _pgsql_db_sql + _pgsql_db_sql="select pg_encoding_to_char(i) from generate_series(0,100) i;" + + compadd "$@" - $( psql $_pgsql_params[@] -AXtq -c $_pgsql_db_sql template1 ) +} + + +## +## The actual completion code for the commands +## + +_psql () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s "-*" \ + "$_pgsql_common_opts[@]" \ + {-c+,--command=}':execute SQL command:' \ + {-d+,--dbname=}':database to connect to:_pgsql_databases' \ + {-f+,--file=}':SQL file to read:_files' \ + {-l,--list}'[list databases]' \ + {-v+,--set=,--variable=}':set SQL variable:' \ + {-V,--version}'[output version information, then exit]' \ + {-X,--no-psqlrc}'[don'\''t read ~/.psqlrc]' \ + {-1,--single-transaction}'[restore as a single transaction]' \ + {-\?,--help=}':display help:' \ + \ + {-a,--echo-all}'[print commands read]' \ + {-b,--echo-errors}'[echo failed commands]' \ + {-e,--echo-queries}'[display queries submitted]' \ + {-E,--echo-hidden}'[display hidden queries]' \ + {-L,--log-file=}'[send session log to file]' \ + {-n,--no-readline}'[disable enhanced command line editing (readline)]' \ + {-o+,--output=}':query output:_files' \ + {-q,--quiet}'[non verbose mode]' \ + {-s,--single-step}'[prompt before each query]' \ + {-S,--single-line}'[newline sends query]' \ + \ + {-A,--no-align}'[unaligned output mode]' \ + --csv'[CSV (Comma-Separated Values) table output mode]' \ + {-F+,--field-separator=}':field separator char:' \ + {-H,--html}'[HTML output]' \ + {-P+,--pset=}':set psql variable:' \ + {-R+,--record-separator=}':record separator char:' \ + {-t,--tuples-only}'[don'\''t display header/footer]' \ + {-T+,--table-attr=}':HTML table options:' \ + {-x,--expanded}'[one column per line]' \ + {-z,--field-separator-zero}'[set field separator for unaligned output to zero byte]' \ + {-0,--record-separator-zero}'[set record separator for unaligned output to zero byte]' \ + -u'[prompt for username/password]' \ + ':PostgreSQL database:_pgsql_databases' \ + ':PostgreSQL user:_pgsql_users' +} + +_pg_dump () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-f+,--file=}':output file:_files' \ + {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \ + {-j,--jobs=}'[use this many parallel jobs to dump]' \ + {-v,--verbose}'[verbose mode]' \ + {-V,--version}'[output version information, then exit]' \ + {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \ + --lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \ + --no-sync'[do not wait for changes to be written safely to disk]' \ + {-\?,--help}'[display help]' \ + \ + {-a,--data-only}'[dump only data]' \ + {-b,--blobs}'[dump blobs as well]' \ + {-B,--no-blobs}'[exclude large objects in dump]' \ + {-c,--clean}'[include clean cmds in dump]' \ + {-C,--create}'[include createdb cmds in dump]' \ + {-e+,--extension=}'[dump the specified extension(s) only]' \ + {-E+,--encoding=}':database encoding:_pgsql_encodings' \ + {-n+,--schema=}':schema to dump:_pgsql_schemas' \ + {-N+,--exclude-schema=}':schema to NOT dump:_pgsql_schemas' \ + {-O,--no-owner}'[don'\''t recreate as same owner]' \ + {-s,--schema-only}'[no data, only schema]' \ + {-S+,--superuser=}':superuser name:_pgsql_users' \ + {-t+,--table=}':table to dump:_pgsql_tables' \ + {-T+,--exclude-table=}':table to NOT dump:_pgsql_tables' \ + {-x,--no-{acl,privileges}}'[don'\''t dump ACLs]' \ + --binary-upgrade'[for use by upgrade utilities only]' \ + {-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \ + --disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \ + --disable-triggers'[disable triggers during data-only restore]' \ + --enable-row-security'[enable row security (dump only content user has access to)]' \ + --exclude-table-data='[do NOT dump data for the named table(s)]' \ + --if-exists'[use IF EXISTS when dropping objects]' \ + --include-foreign-data='[include data of foreign servers]' \ + --inserts'[dump data as INSERT commands, rather than COPY]' \ + --load-via-partition-root'[load partitions via the root table]' \ + --no-comments'[do not dump comments]' \ + --no-publications'[do not dump publications]' \ + --no-security-labels'[do not dump security label assignments]' \ + --no-subscriptions'[do not dump subscriptions]' \ + --no-synchronized-snapshots'[do not use synchronized snapshots in parallel jobs]' \ + --no-tablespaces'[do not dump tablespace assignments]' \ + --no-toast-compression'[do not dump TOAST compression methods]' \ + --no-unlogged-table-data'[do not dump unlogged table data]' \ + --on-conflict-do-nothing'[add ON CONFLICT DO NOTHING to INSERT commands]' \ + --quote-all-identifiers'[quote all identifiers, even if not key words]' \ + --rows-per-insert=['number of rows per INSERT'] \ + --section=':dump named section:_values "section" pre-data data post-data' \ + --serializable-deferrable'[wait until the dump can run without anomalies]' \ + --snapshot='[use given snapshot for the dump]' \ + --strict-names'[require table and/or schema include patterns to match at least one entity each]' \ + --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]' \ + \ + {-i,--ignore-version}'[ignore version mismatch]' \ + {-o,--oids}'[dump objects identifiers for every table]' \ + {-R,--no-reconnect}'[don'\''t output connect]' \ + -X+':option:_values "option" use-set-session-authorization disable-triggers' \ + ':PostgreSQL database:_pgsql_databases' +} + +_pg_restore () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-d+,--dbname=}':database to connect to:_pgsql_databases' \ + {-f+,--file=}':output file:_files' \ + {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \ + {-l,--list}'[list databases]' \ + {-v,--verbose}'[verbose mode]' \ + {-V,--version}'[output version information, then exit]' \ + {-\?,--help}'[display help]' \ + \ + {-a,--data-only}'[dump only data]' \ + {-c,--clean}'[include clean (drop) cmds before recreating]' \ + {-C,--create}'[include createdb cmds in dump]' \ + {-e,--exit-on-error}'[exit on error, default is to continue]' \ + {-I,--index=}':index name:' \ + {-j,--jobs=}':use this many parallel jobs to restore:' \ + {-L,--use-list=}':use table of contents from this file for selecting/ordering output:' \ + {-n,--schema=}':restore only objects in this schema:' \ + {-O,--no-owner}'[skip restoration of object ownership]' \ + {-P,--function=}':restore named function:' \ + {-s,--schema-only}'[restore only the schema, no data]' \ + {-S,--superuser=}':superuser user name to use for disabling triggers:' \ + {-t,--table=}':restore named table:' \ + {-T,--trigger=}':restore named trigger:' \ + {-x,--no-privileges}'[skip restoration of access privileges (grant/revoke)]' \ + {-1,--single-transaction}'[restore as a single transaction]' \ + --disable-triggers'[disable triggers during data-only restore]' \ + --enable-row-security'[enable row security]' \ + --if-exists'[use IF EXISTS when dropping objects]' \ + --no-comments'[do not restore comments]' \ + --no-data-for-failed-tables'[do not restore data of tables that could not be created]' \ + --no-publications'[do not restore publications]' \ + --no-security-labels'[do not restore security labels]' \ + --no-subscriptions'[do not restore subscriptions]' \ + --no-tablespaces'[do not restore tablespace assignments]' \ + --section=':dump named section:_values "section" pre-data data post-data' \ + --strict-names'[require table and/or schema include patterns to match at least one entity each]' \ + --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership]' \ + \ + {-b,--blobs}'[include large objects in dump]' \ + {-B,--no-blobs}'[exclude large objects in dump]' \ + \ + "1: :_files" +} + +_pg_dumpall () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-f+,--file=}':output file:_files' \ + {-v,--verbose}'[verbose mode]' \ + {-V,--version}'[output version information, then exit]' \ + --lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \ + {-\?,--help}'[display help]' \ + \ + {-a,--data-only}'[dump only data]' \ + {-c,--clean}'[include clean (drop) cmds before recreating]' \ + {-E,--encoding=}'[dump the data in encoding]' \ + {-g,--globals-only}'[dump only global objects, no databases]' \ + {-O,--no-owner}'[don'\''t recreate as same owner]' \ + {-r,--roles-only}'[no databases or tablespaces, only roles]' \ + {-s,--schema-only}'[no data, only schema]' \ + {-S+,--superuser=}':superuser name:_pgsql_users' \ + {-t,--tablespaces-only}'[no databases or roles, only tablespaces]' \ + {-x,--no-privileges}'[don'\''t dump ACLs]' \ + --binary-upgrade'[for use by upgrade utilities only]' \ + --column-inserts'[use INSERT with column names not COPY]' \ + --disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \ + --disable-triggers'[disable triggers during data-only restore]' \ + --exclude-database=':exclude databases:_pgsql_databases' \ + --extra-float-digits='[override default setting for extra_float_digits]' \ + --if-exists'[use IF EXISTS when dropping objects]' \ + --inserts'[use INSERT not COPY]' \ + --load-via-partition-root'[pload partitions via the root table]' \ + --no-comments'[do not dump comments]' \ + --no-publications'[do not dump publications]' \ + --no-role-passwords'[do not dump passwords for roles]' \ + --no-security-labels'[do not dump security label assignments]' \ + --no-subscriptions'[do not dump subscriptions]' \ + --no-sync'[do not wait for changes to be written safely to disk]' \ + --no-tablespaces'[do not dump tablespace assignments]' \ + --no-toast-compression'[do not dump TOAST compression methods]' \ + --no-unlogged-table-data'[do not dump unlogged table data]' \ + --on-conflict-do-nothing'[add ON CONFLICT DO NOTHING to INSERT commands]' \ + --quote-all-identifiers'[quote all identifiers, even if not key words]' \ + --rows-per-insert='[number of rows per INSERT]' \ + --use-set-session-authorization'[use SET SESSION AUTHORIZATION cmds instead of ALTER OWNER]' \ + {-o,--oids}'[dump objects identifiers for every table]' \ +} + +_createdb () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-D+,--tablespace=}'[default tablespace for the database]' \ + {-e,--echo}'[display SQL queries]' \ + {-E+,--encoding=}':database encoding:_pgsql_encodings' \ + {-l+,--locale=}'[locale settings for the database]' \ + --lc-collate='[LC_COLLATE setting for the database]' \ + --lc-ctype='[LC_CTYPE setting for the database]' \ + {-O+,--owner=}':database user to own the new database:_pgsql_users' \ + {-T+,--template=}':database template:_pgsql_databases' \ + '--version[output version information, then exit]' \ + {-\?,--help}'[display help]' \ + \ + --maintenance-db=':alternate maintenance database:_pgsql_databases' \ + {-q,--quiet}'[non verbose mode]' \ + --location=':database location (unsupported since PostgrSQL 8.0):_directories' \ + ':PostgreSQL database:' \ + ':comment:' +} + +_dropdb () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-e,--echo}'[display SQL queries]' \ + {-f,--force}'[try to terminate other connections before dropping]' \ + {-i,--interactive}'[confirm before drop]' \ + {-V,--version}'[output version information, then exit]' \ + --if-exists'[don'\''t treport error if database does'\''t exist]' \ + --maintenance-db=':alternate maintenance database:_pgsql_databases' \ + {-q,--quiet}'[non verbose mode]' \ + ':PostgreSQL database:_pgsql_databases' +} + +_vacuumdb () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-a,--all}'[vacuum all databases]' \ + {-d+,--dbname=}':database to connect to:_pgsql_databases' \ + --disable-page-skipping'[disable all page-skipping behavior]' \ + {-e,--echo}'[show the commands being sent to the server]' \ + {-f,--full}'[do full vacuuming]' \ + {-F,--freeze}'[freeze row transaction information]' \ + --force-index-cleanup'[always remove index entries that point to dead tuples]' \ + {-j,--jobs=}'[use this many concurrent connections to vacuum]' \ + '--min-mxid-age=[minimum multixact ID age of tables to vacuum]' \ + '--min-xid-age=[minimum transaction ID age of tables to vacuum]' \ + --no-index-cleanup'[don'\''t remove index entries that point to dead tuples]' \ + --no-process-toast'[skip the TOAST table associated with the table to vacuum]' \ + --no-truncate'[don'\''t truncate empty pages at the end of the table]' \ + {-P+,--parallel=}'[use this many background workers for vacuum, if available]' \ + {-q,--quiet}'[do not write any messages]' \ + '--skip-locked[skip relations that cannot be immediately locked]' \ + {-t+,--table=}':table to dump:_pgsql_tables' \ + {-v,--verbose}'[write a lot of output]' \ + {-V,--version}'[output version information, then exit]' \ + {-z,--analyze}'[update optimizer hints]' \ + {-Z,--analyze-only}'[only update optimizer statistics; no vacuum]' \ + --analyze-in-stages'[only update optimizer statistics, in multiple stages for faster results; no vacuum]' \ + {-\?,--help}'[display help]' \ + --maintenance-db='[alternate maintenance database]' \ + '1:PostgreSQL database:_pgsql_databases' +} + +_createuser () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-c,--connection-limit=}'[connection limit for role (default: no limit)]' \ + {-d,--createdb}'[role can create new databases]' \ + {-D,--no-createdb}'[role cannot create databases]' \ + {-e,--echo}'[display SQL queries]' \ + {-g,--role=}'[new role will be a member of this role]' \ + {-i,--inherit}'[role inherits privileges of roles it is a member of (default)]' \ + {-I,--no-inherit}'[role does not inherit privileges]' \ + {-l,--login}'[role can login (default)]' \ + {-L,--no-login}'[role cannot login]' \ + {-P,--pwprompt}'[assign a password to new role]' \ + {-r,--createrole}'[role can create new roles]' \ + {-R,--no-createrole}'[role cannot create roles]' \ + {-s,--superuser}'[role will be superuser]' \ + {-S,--no-superuser}'[role will not be superuser]' \ + --interactive'[prompt for missing role name and attributes rather than using defaults]' \ + --replication'[role can initiate replication]' \ + --no-replication'[role cannot initiate replication]' \ + {-E,--encrypted}'[encrypt stored password]' \ + {-N,--unencrypted}'[do not encrypt stored password]' \ + {-\?,--help}'[display help]' +} + +_dropuser () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + "$_pgsql_common_opts[@]" \ + {-e,--echo}'[display SQL queries]' \ + {-q,--quiet}'[non verbose mode]' \ + {-i,--interactive}'[prompt before deleting anything, and prompt for role name if not specified]' \ + {-V,--version}'[output version information, then exit]' \ + --if-exists'[don'\''t report error if user doesn'\''t exist]' \ + ':PostgreSQL user:_pgsql_users' +} + +_initdb () { + local curcontext="$curcontext" state line expl + typeset -A opt_args + + _arguments -C -s \ + {--auth=,-A+}':default authentication method for local connections:_values "auth methods" $_pgsql_auth_methods[@]' \ + --auth-host=':default authentication method for local TCP/IP connections:_values "auth methods" $_pgsql_auth_methods[@]' \ + --auth-local=':default authentication method for local-socket connections:_values "auth methods" $_pgsql_auth_methods[@]' \ + {-D+,--pgdata=}':location for this database cluster:_files' \ + {-E+,--encoding=}':set default encoding for new databases:_pgsql_encodings' \ + {-g,--allow-group-access}'[allow group readexecute on data directory]' \ + {-k,--data-checksums}':use data page checksums:' \ + --locale=':set default locale for new databases:' \ + --lc-collate=':set the default locale for collate:' \ + --lc-ctype=':set the default locale for ctype:' \ + --lc-messages=':set the default locale for messages:' \ + --lc-monetary=':set the default locale for monetary:' \ + --lc-numeric=':set the default locale for numeric:' \ + --lc-time=':set the default local for time:' \ + --no-locale'[equivalent to --locale=C]' \ + --pwfile=':read password for the new superuser from file:_files' \ + {-T+,--text-search-config=}'[default text search configuration]' \ + {-U+,--username=NAME}':database superuser name:' \ + {-W,--pwprompt}'[prompt for a password for the new superuser]' \ + {-X+,--waldir=}':location for the write-ahead log directory:_files' \ + --xlogdir=':location for the transaction log directory (unsupported since PostgreSQL 10):_files' \ + --wal-segsize='[size of WAL segments, in megabytes]' \ + {-d,--debug}'[generate lots of debugging output]' \ + --discard-caches'[set debug_discard_caches=1]' \ + -L+':where to find the input files:_files' \ + {-n,--no-clean}'[do not clean up after errors]' \ + {-N,--no-sync}':do not wait for changes to be written safely to disk:' \ + --instructions'[do not print instructions for next steps]' \ + {-s,--show}'[show internal settings]' \ + {-S,--sync-only}'[only sync data directory]' \ + {-V,--version}'[output version information, then exit]' \ + {-\?,--help}'[display help]' \ + ':location for this database cluster:_files' +} + +_pgsql_utils () { + local _pgsql_common_opts _pgsql_auth_methods + + _pgsql_common_opts=( + {-\?,--help}'[display help]' + {-h+,--host=}':database host:_pgsql_host_or_dir' + {-p+,--port=}':database port number:_pgsql_ports' + {-U+,--username=}':connect as user:_pgsql_users' + {-W,--password}'[prompt for password]' + {-w,--no-password}'[never prompt for password]' + --role='[do SET ROLE before restore]' + ) + + _pgsql_auth_methods=( + trust + reject + md5 + password + gss + sspi + krb5 + ident + peer + ldap + radius + cert + pam + ) + + case "$service" in + psql) _psql "$@" ;; + pg_dump) _pg_dump "$@" ;; + pg_dumpall) _pg_dumpall "$@" ;; + pg_restore) _pg_restore "$@" ;; + createdb) _createdb "$@" ;; + dropdb) _dropdb "$@" ;; + vacuumdb) _vacuumdb "$@" ;; + createuser) _createuser "$@" ;; + dropuser) _dropuser "$@" ;; + initdb) _initdb "$@" ;; + esac +} + +_pgsql_utils "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_phing b/home/.zsh-server/plugins/zsh-completions/src/_phing new file mode 100644 index 0000000..afdaf3e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_phing @@ -0,0 +1,94 @@ +#compdef phing +# ------------------------------------------------------------------------------ +# Copyright (c) Igor M. Timoshenko +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Phing (http://phing.info). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Igor Timoshenko +# +# ------------------------------------------------------------------------------ + +_phing() { + local context curcontext="$curcontext" state line ret=1 + integer NORMARG + typeset -A opt_args + + # Follow http://phing.info/docs/stable/webhelp/sec.commandlineargs.html for more information + _arguments \ + '(-h -help)'{-h,-help}'[display the help screen]' \ + '(-v -version)'{-v,-version}'[print version information and exit]' \ + '(-l -list)'{-l,-list}'[list all available targets in buildfile (excluding targets that have their hidden attribute set to true)]' \ + '(-q -quiet)'{-q,-quiet}'[quiet operation, no output at all]' \ + '-verbose[verbose, give some more output]' \ + '-debug[output debug information]' \ + '-logfile [use given file for log]:file:_files' \ + '-D[set the property to the specified value to be used in the buildfile]' \ + '-find []:file:_files' \ + '-buildfile [specify an alternate buildfile name. Default is build.xml]:file:_files' \ + '-logger [specify an alternate logger. Default is phing.listener.DefaultLogger. Other options include phing.listener.NoBannerLogger, phing.listener.AnsiColorLogger, phing.listener.XmlLogger, phing.listener.TargetLogger and phing.listener.HtmlColorLogger]' \ + '-propertyfile [load properties from the specified file]:file:_files' \ + '(-v --version)'{-v,--version}'[show version]' \ + '1: :->targets' \ + '*:: :->args' \ + && ret=0 + + case $state in + targets) + local buildfile; buildfile=build.xml + if [[ ! -f $buildfile ]] + then + ret=0 + else + local targets; targets=($(sed -nE "/xzfiles" \ + '(- 1 *)'-x"[Extract one file very fast]:filepath:->filepath" \ + '(- 1 *)'-d"[Decompress]:file:->xzfiles" \ + "-i[Input]:file:->files" \ + "-o[Output]:output:->outputxz" \ + "-p[Use a maximum of NUM CPU-intensive threads]:cpu:->cpus" \ + "-t[Don't assume input is in tar format]" \ + "-k[Keep original input (do not remove it)]" \ + "-e[Use "extreme" compression, which is much slower]" \ + "-f[Set the size of each compression block, relative to the LZMA dictionary size (default is 2.0)]:num" \ + "-q[Set the number of blocks to allocate for the compression queue (default is 1.3 * cores + 2)]:num" \ + '1:inputfile:->files' \ + '2:outputfile' \ + '*: : :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (xzfiles) + _pixz_compressed_files + _describe -t files 'files' files + ;; + (files) + _files + ;; + (cpus) + local num_cpus cores + num_cpus=$(nproc) + cores=() + for i in {1..$num_cpus}; do + cores+=($i) + done + _describe -t cores 'cores' cores + ;; + (filepath) + ;; + (*) + ;; + esac +} + +_pixz + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_pkcon b/home/.zsh-server/plugins/zsh-completions/src/_pkcon new file mode 100644 index 0000000..440a7fe --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_pkcon @@ -0,0 +1,137 @@ +#compdef pkcon +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for pkcon (http://www.packagekit.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# +# ------------------------------------------------------------------------------ + + +local -a options +options=( + '--version[Show the program version and exit]' + '--filter[Set the filter, e.g. installed]' + "--root[Set the install root, e.g. '/' or '/mnt/ltsp']" + '(-n --nowait)'{-n,--nowait}'[Exit without waiting for actions to complete]' + '(-y --noninteractive)'{-g,--noninteractive}'[Install the packages without asking for confirmation]' + '--background[Run the command using idle network bandwidth and also using less power]' + '(-p --plain)'{-p,--plain}'[Print to screen a machine readable output, rather than using animated widgets]' + '(-c --cache-age)'{-c,--cache-age}"[The maximum metadata cache age. Use -1 for 'never'.]" + '(-h --help)'{-h,--help}'[Show help options.]' + '(-v --verbose)'{-v,--verbose}'[Show debugging information for all files]' +) + +local -a actions +actions=( + 'accept-eula' + 'get-roles' + 'get-distro-upgrades' + 'get-categories' + 'get-actions' + 'get-groups' + 'get-filters' + 'get-transactions' + 'get-time' + 'search' + 'install' + 'install-local' + 'download' + 'remove' + 'update' + 'refresh' + 'resolve' + 'get-updates' + 'get-depends' + 'get-requires' + 'get-details' + 'get-files' + 'get-update-detail' + 'get-packages' + 'repo-list' + 'repo-enable' + 'repo-disable' + 'repo-set-data' + 'what-provides' + 'upgrade-system' +) + +local context state line expl cmd +local -A opt_args + +integer i=2 +while (( i < $#words )); do + case "$words[$i]" in + -*) + # skip option + (( i++ )) + continue + ;; + esac + + if [[ -z "$cmd" ]]; then + cmd="$words[$i]" + words[$i]=() + (( CURRENT-- )) + fi + (( i++ )) +done + +if [[ -z "$cmd" ]] +then + _arguments -s -w : $options \ + ":action:($actions)" + return +fi + +case "$cmd" in + search) + _arguments : $options \ + ':type:(name details group file)' \ + ':data: :' + ;; + refresh) + _arguments -s -w : $options \ + '--force' + ;; + *) + _arguments -s -w : $options + ;; +esac +return 1 + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_play b/home/.zsh-server/plugins/zsh-completions/src/_play new file mode 100644 index 0000000..c135328 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_play @@ -0,0 +1,190 @@ +#compdef play +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Play! framework 1.2.2 (http://www.playframework.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# * Mario Fernandez (https://github.com/sirech) +# +# ------------------------------------------------------------------------------ + + +_play() { + local context curcontext="$curcontext" state line + typeset -A opt_args + + local ret=1 + + _arguments -C \ + '1: :_play_cmds' \ + '*::arg:->args' \ + && ret=0 + + case $state in + (args) + curcontext="${curcontext%:*:*}:play-cmd-$words[1]:" + case $line[1] in + (build-module|list-modules|lm|check|id) + _message 'no more arguments' && ret=0 + ;; + (dependencies|deps) + _arguments \ + '1:: :_play_apps' \ + '(--debug)--debug[Debug mode (even more information logged than in verbose mode)]' \ + '(--jpda)--jpda[Listen for JPDA connection. The process will be suspended until a client is plugged to the JPDA port.]' \ + '(--sync)--sync[Keep lib/ and modules/ directory synced. Delete unknown dependencies.]' \ + '(--verbose)--verbose[Verbose Mode]' \ + && ret=0 + ;; + (clean|javadoc|jd|out|pid|secret|stop) + _arguments '1:: :_play_apps' && ret=0 + ;; + (help) + _arguments '1: :_play_cmds -F "(cp deps ec idea jd st lm nb nm help antify evolutions evolutions:apply evolutions:markApplied evolutions:resolve)"' && ret=0 + ;; + (status|st) + _arguments \ + '1:: :_play_apps' \ + '(--url)--url[If you want to monitor an application running on a remote server, specify the application URL using this option]:URL:_urls' \ + '(--secret)--secret[You can provide your own secret key using this option]:Secret key' \ + && ret=0 + ;; + (new) + _arguments \ + '1: :_play_apps' \ + '(--with)--with[Automatically enable this set of module for the newly created application]:Modules list:_play_modules_list' \ + && ret=0 + ;; + (install) + _arguments '1:Play! module:_play_modules_dash_versions' && ret=0 + ;; + (new-module) + _arguments '1:Module directory:_files -/' && ret=0 + ;; + (test|precompile|run|start|war|auto-test|classpath|cp|eclipsify|ec|idealize|idea|modules|netbeansify|nb) + local cmd_args; cmd_args=( + '1:: :_play_apps' + '(--deps)--deps[Resolve and install dependencies before running the command]' + ) + case $line[1] in + (precompile|run|start|restart|war) + local app_dir="$line[2]" + [[ -d "$app_dir" ]] || app_dir=. + [[ -f "$app_dir/conf/application.conf" ]] && cmd_args+=('--'${(u)${(M)$(<$app_dir/conf/application.conf):#%*}%%.*}'[Use this ID to run the application (override the default framework ID)]') + ;| + (test|run) + cmd_args+=('(-f)-f[Disable the JPDA port checking and force the jpda.port value]') + ;| + (war) + cmd_args+=( + '(-o --output)'{-o,--output}'[The path where the WAR directory will be created. The contents of this directory will first be deleted]:output directory:_files -/' + '(--zip)--zip[By default, the script creates an exploded WAR. If you want a zipped archive, specify the --zip option]' + '(--exclude)--exclude[Excludes a list of colon separated directories]:excluded directories list:_play_colon_dirs_list' + ) + ;| + (test|run|start|restart|war) + cmd_args+=('*:Java option') + ;; + esac + _arguments "$cmd_args[@]" && ret=0 + ;; + *) + _call_function ret _play_cmd_$words[1] && ret=0 + (( ret )) && _message 'no more arguments' + ;; + esac + ;; + esac +} + +# FIXME Completes only core commands, some modules add commands too (eg Maven). Where do we get them ? +# FIXME Parse 'play help' and 'play help ' (for aliases) instead of hard-coding. +(( $+functions[_play_cmds] )) || +_play_cmds() { + local commands; commands=( + 'antify:Create a build.xml file for this project' + 'auto-test:Automatically run all application tests' + 'build-module:Build and package a module' + 'check:Check for a release newer than the current one' + {classpath,cp}':Display the computed classpath' + 'clean:Delete temporary files (including the bytecode cache)' + {dependencies,deps}':Resolve and retrieve project dependencies' + {eclipsify,ec}':Create all Eclipse configuration files' + 'evolutions:Run the evolution check' + 'evolutions\:apply:Automatically apply pending evolutions' + 'evolutions\:mark:AppliedMark pending evolutions as manually applied' + 'evolutions\:resolve:Resolve partially applied evolution' + 'help:Display help on a specific command' + 'id:Define the framework ID' + {idealize,idea}':Create all IntelliJ Idea configuration files' + 'install:Install a module' + {javadoc,jd}':Generate your application Javadoc' + {list-modules,lm}':List modules available from the central modules repository' + 'modules:Display the computed modules list' + {netbeansify,nb}':Create all NetBeans configuration files' + 'new:Create a new application' + {new-module,nm}':Create a module' + 'out:Follow logs/system.out file' + 'pid:Show the PID of the running application' + 'precompile:Precompile all Java sources and templates to speed up application start-up' + 'restart:Restart the running application' + 'run:Run the application in the current shell' + 'secret:Generate a new secret key' + 'start:Start the application in the background' + {status,st}':Display the running application status' + 'stop:Stop the running application' + 'test:Run the application in test mode in the current shell' + 'war:Export the application as a standalone WAR archive' + ) + _describe -t commands 'Play! command' commands "$@" +} + +(( $+functions[_play_apps] )) || +_play_apps() { + _wanted application expl 'Play! application directory' _files -/ +} + +(( $+functions[_play_modules] )) || +_play_modules() { + local modules; modules=(${(ps:,:)${${${(S)${(f)$(_call_program modules $service list-modules)}//\]*\[/,}%%\]*}##*\[}}) + _describe -t modules 'Play! module' modules "$@" +} + +(( $+functions[_play_modules_dash_versions] )) || +_play_modules_dash_versions() { + local ret=1 + if compset -P '*-'; then + local versions; versions=(${(ps:,:)${${${${${(f)$(_call_program versions $service list-modules)}##*${IPREFIX%-}\]}#*Versions:}%%"~"*}//[[:space:]]/}}) + _describe -t module-versions "${IPREFIX%-} module versions" versions && ret=0 + else + _wanted modules expl 'Play! module' _play_modules -qS- && ret=0 + fi +} + +(( $+functions[_play_modules_list] )) || +_play_modules_list() { + compset -P '*,'; compset -S ',*' + _wanted module-list expl 'Play! modules list' _play_modules -qS, +} + +(( $+functions[_play_colon_dirs_list] )) || +_play_colon_dirs_list() { + compset -P '*:'; compset -S ':*' + _wanted directories-list expl 'Directories list' _files -/ -qS: +} + +_play "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_pm2 b/home/.zsh-server/plugins/zsh-completions/src/_pm2 new file mode 100644 index 0000000..a750fb0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_pm2 @@ -0,0 +1,370 @@ +#compdef pm2 +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for pm2 5.2.2 (https://pm2.keymetrics.io/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Myoungdo Park +# * Shohei Yoshida +# +# ------------------------------------------------------------------------------ + +_pm2() { + typeset -A opt_args + local context state line + + local curcontext="$curcontext" + + local ret=1 + + _arguments -C \ + '(- *)'{-v,-V,--version}'[print pm2 version]' \ + '(-s --silent)'{-s,--silent}'[hide all messages]' \ + '--ext[watch only this file extension]:extension' \ + '(-n --name)'{-n,--name}'[set a name for the process in the process list]:name' \ + '(-m --mini-list)'{-m,--mini-list}'[display a compacted list without formatting]' \ + '--interpreter[set a specific interpreter to use for executing app(default: node)]:prog' \ + '(--interpreter-args --node-args)'{--interpreter-args,--node-args}'[set arguments to pass to the interpreter]:args' \ + '(-o --output)'{-o,--output}'[specify log file for stdout]: :_files' \ + '(-e --error)'{-e,--error}'[specify log file for stderr]: :_files' \ + '(-l --log)'{-l,--log}'[specify log file which gathers both stdout and stderr]' \ + '--filter-env[filter out outgoing global values that contain provided strings]:envs' \ + '--log-type[specify log output style]: :(raw json)' \ + '--log-date-format[specify log output style]:format' \ + '--time[enable time logging]' \ + '--disable-logs[disable all logs storage]' \ + '*--env[specify which set of environment variables from ecosystem file must be injected]:env' \ + '(-a --update-env)'{-a,--update-env}'[force and update of the environment with restart/reload]' \ + '(-f --force)'{-f,--force}'[force actions]' \ + '(-i --instances)'{-i,--instances}'[launch number instances]:num' \ + '--parallel[number of parallel actions]:num' \ + '--shutdown-with-message[shutdown an application with process.send("shutdown") instead of process.kill(pid, SIGINT)]' \ + '(-p --pid)'{-p,--pid}'[specify pid file]: :_files' \ + '(-k --kill-timeout)'{-k,--kill-timeout}'[delay before sending final SIGKILL signal to process]:delay' \ + '--listen-timeout[listen timeout an application reload]:delay' \ + '--max-memory-restart[restart the app if an amount of memory is exceeded (in bytes)]:bytes' \ + '--restart-delay[specify a delay between restarts(in milliseconds)]:delay' \ + '--exp-backoff-restart-delay[specify a delay between restarts(in milliseconds)]:delay' \ + '(-x --execute-command)'{-e,--execute-command}'[execute a program using fork system]' \ + '--max-restarts[only start the script COUNT times]:count' \ + '(-u --user)'{-u,--user}'[define user when generating startup script]:username' \ + '--uid[run target script with rights]:uid' \ + '--gid[run target script with rights]:gui' \ + '--namespace[start application within specified namespace]:namespace' \ + '--cwd[run target script from path ]:cwd:_paths -/' \ + '--hp[define home path when generating startup script]: :_paths -/' \ + '--wait-ip[override systemd script to wait for full internet connectivity to launch pm2]' \ + '--service-name[define service name when generating startup script]' \ + '(-c --cron --cron-restart)'{-c,--cron,--cron-restart}'[restart a running process based on a cron pattern]:pattern' \ + '(-w --write)'{-w,--write}'[write configuration in local folder]' \ + '--no-daemon[run pm2 daemon in the foreground if it does not exist already]' \ + '(--disable-source-map-support --source-map-support)--source-map-support[force source map support]' \ + '--only[with json declaration, allow to only act on one application]:app' \ + '(--disable-source-map-support --source-map-support)--disable-source-map-support[force disable source map support]' \ + '--wait-ready[ask pm2 to wait for ready event from your app]' \ + '--merge-logs[merge logs from different instances but keep error and out separated]' \ + '*--watch[watch application folder for changes]: :_files -/' \ + '*--ignore-watch[list of paths to ignore]: :_files' \ + '--no-color[skip colors]' \ + '--no-vizion[start an app without vizion feature]' \ + '--np-autorestart[start an app without automatic restart]' \ + '--no-treekill[Only kill the main process, not detached children]' \ + '--no-pmx[start an app without pmx]' \ + '--no-automation[start an app without automation]' \ + '(--disable-trace --trace)--trace[enable transaction tracing with km]' \ + '(--disable-trace --trace)--disable-trace[disable transaction tracing with km]' \ + "--sort[sort process according to field's]:field_name" \ + '--attach[attach logging after your start/restart/stop/reload]' \ + '--v8[enable v8 data collecting]' \ + '--event-loop-inspector[enable event-loop-inspector dump in pmx]' \ + '--deep-monitoring[enable all monitoring tools]' \ + '(- *)'{-h,--help}'[output usage information]' \ + '1: :_pm2_subcommands' \ + '*:: :->subcmds' && return 0 + + case "$state" in + (subcmds) + case $words[1] in + (start) + _arguments \ + '--watch[watch folder for changes]' \ + '--fresh[Rebuild Dockerfile]' \ + '--daemon[Run container in Daemon mode(debug purposes)]' \ + '--container[Start application in container mode]' \ + '--dist[--with-container; change local Dockerfile to containerize all files in current directory]' \ + '--image-name[with --dist; set the exported image name]:name' \ + '--node-version[with --container, set a specific major Node.js version]:version' \ + '--dockerdaemon[for debugging purpose]' \ + '(- *)'{-h,--help}'[output usage information]' \ + '*: :_pm2_id_namespace_file' \ + && ret=0 + ;; + (trigger) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '1: :_pm2_id_names' \ + && ret=0 + ;; + (deploy|startOrRestart|startOrReload|startOrGracefulReload) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '1: :_files -g "*.json"' \ + && ret=0 + ;; + (stop|restart) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--watch[Stop watching folder for changes]' \ + '*: :_pm2_id_namespace_all' \ + && ret=0 + ;; + (reload|delete|reset) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '*: :_pm2_id_namespace_all' \ + && ret=0 + ;; + (module:install) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--tarball[is local tarball]' \ + '--install[run yarn install before starting module]' \ + '--docker[is docker container]' \ + '--v1[install module in v1 manner(do not use it)]' \ + '--safe[keep module backup, if new module fail = restore with previous]:time' \ + && ret=0 + ;; + (publish|module:publish) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--npm[publish on npm]' \ + '*: :_files -/' \ + && ret=0 + ;; + (link) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--info-node[set url info node]:url' \ + && ret=0 + ;; + (plus) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--info-node[set url info node]:url' \ + '(-d --discrete)'{-d,--discrete}'[silent mode]' \ + '(-a --install-all)'{-a,--install-all}'[install all modules (force yes)]' \ + && ret=0 + ;; + (dump|save) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--force[force deletion of dump file even if empty]' \ + && ret=0 + ;; + (send|attach|describe|env) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '1: :_pm2_id_names' \ + && ret=0 + ;; + (slist|sysinfos) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--tree[show as tree]' \ + && ret=0 + ;; + (logs) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--json[json log output]' \ + '--format[formatted log output]' \ + '--raw[raw output]' \ + '--err[only shows error output]' \ + '--out[only shows standard output]' \ + '--line[output the last N lines, instead of the last 15 by default]:lines' \ + '--timestamp[add timestamps(default format YYYY-MM-DD-HH:mm:ss)]:format' \ + '--nostream[print logs without launching the log stream]' \ + '*--highlight[highlights the given value]' \ + '1: :_pm2_id_namespace' \ + && ret=0 + ;; + (serve) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '--port[specify port to listen to]:port' \ + '--spa[always serving index.html on inexistant sub path]' \ + '--basic-auth-username[set basic auth username]:username' \ + '--basic-auth-password[set basic auth password]:password' \ + '--monitor[frontend app monitoring]:app' \ + '*: :_files -/' \ + && ret=0 + ;; + (*) + _arguments \ + '(- *)'{-h,--help}'[output usage information]' \ + '*: :_files' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + +(( $+functions[_pm2_subcommands] )) || +_pm2_subcommands() { + local -a subcommands=( + "start:start and daemonize an app" + "trigger:trigger process action" + "deploy:deploy your json" + "startOrRestart:start or restart JSON file" + "startOrReload:start or gracefully reload JSON file" + "pid:return pid of [app_name] or all" + "create:return pid of [app_name] or all" + "startOrGracefulReload:start or gracefully reload JSON file" + "stop:stop a process" + "restart:restart a process" + "scale:scale up/down a process in cluster mode depending on total_number param" + "profile\:mem:Sample PM2 heap memory" + "profile\:cpu:Profile PM2 cpu" + "reload:reload processes (note that its for app using HTTP/HTTPS)" + "id:get process id by name" + "inspect:inspect a process" + "delete:stop and delete a process from pm2 process list" + "sendSignal:send a system signal to the target process" + "ping:ping pm2 daemon - if not up it will launch it" + "updatePM2:update in-memory PM2 with local PM2" + "update:update in-memory PM2 with local PM2" + "install:install or update a module and run it forever" + "module\:install:install or update a module and run it forever" + "module\:update:update a module and run it forever" + "module\:generate:Generate a sample module in current folder" + "uninstall:stop and uninstall a module" + "module\:uninstall:stop and uninstall a module" + "package:Check & Package TAR type module" + "publish:Publish the module you are currently on" + "module\:publish:Publish the module you are currently on" + "set:sets the specified config " + "multiset:multiset eg \"key1 val1 key2 val2\"" + "get:get value for " + "conf:get / set module config values" + "config:get / set module config values" + "unset:clears the specified config " + "report:give a full pm2 report for https://github.com/Unitech/pm2/issues" + "link:link with the pm2 monitoring dashboard" + "unlink:unlink with the pm2 monitoring dashboard" + "monitor:monitor target process" + "unmonitor:unmonitor target process" + "open:open the pm2 monitoring dashboard" + "plus:enable pm2 plus" + "login:Login to pm2 plus" + "logout:Logout from pm2 plus" + "dump:dump all processes for resurrecting them later" + "save:dump all processes for resurrecting them later" + "cleardump:Create empty dump file" + "send:send stdin to " + "attach:attach stdin/stdout to application identified by " + "resurrect:resurrect previously dumped processes" + "unstartup:disable the pm2 startup hook" + "startup:enable the pm2 startup hook" + "logrotate:copy default logrotate configuration" + "ecosystem:generate a process conf file" + "init:generate a process conf file" + "reset:reset counters for process" + "describe:describe all parameters of a process" + "desc:describe all parameters of a process" + "info:describe all parameters of a process" + "show:describe all parameters of a process" + "env:list all environment variables of a process id" + "list:list all processes" + "l:list all processes" + "ps:list all processes" + "status:list all processes" + "jlist:list all processes in JSON format" + "sysmonit:start system monitoring daemon" + "slist:list system infos in JSON" + "sysinfos:list system infos in JSON" + "prettylist:print json in a prettified JSON" + "monit:launch termcaps monitoring" + "imonit:launch legacy termcaps monitoring" + "dashboard:launch dashboard with monitoring and logs" + "dash:launch dashboard with monitoring and logs" + "flush:flush logs" + "reloadLogs:reload all logs" + "logs:stream logs file. Default stream all logs" + "kill:kill daemon" + "pull:updates repository for a given app" + "forward:updates repository to the next commit for a given app" + "backward:downgrades repository to the previous commit for a given app" + "deepUpdate:performs a deep update of PM2" + "serve:serve a directory over http via port" + "autoinstall:auto install" + "examples:display pm2 usage examples" + ) + + _describe -t subcommands 'subcommand' subcommands "$@" +} + +(( $+functions[_pm2_id_names] )) || +_pm2_id_names() { + local app_list=$(pm2 list -m) + local -a names=(${(@f)"$(echo $app_list | awk '/^\+---/{sub("+--- ", ""); print}')"}) + local -a ids=(${(@f)"$(echo $app_list | awk '/^pm2 id/{sub("pm2 id :", ""); print}')"}) + + if (( ${#ids} > 0 )); then + local -a id_names + for i in {1..${#ids}}; do + id_names+=( "${ids[i]}:${names[i]}" ) + done + + _describe 'id' id_names + fi +} + +(( $+functions[_pm2_namespaces] )) || +_pm2_namespaces() { + local -a namespaces=(${(@f)"$(pm2 list -m | awk '/^namespace :/{ print $3 }')"}) + if (( ${#namespaces} > 0 )); then + _values 'namespace' $namespaces + fi +} + +(( $+functions[_pm2_id_namespace] )) || +_pm2_id_namespace() { + _alternative \ + 'ids:id:_pm2_id_names' \ + 'namespaces:namespace:_pm2_namespaces' +} + +(( $+functions[_pm2_id_namespace_all] )) || +_pm2_id_namespace_all() { + _alternative \ + 'ids:id:_pm2_id_names' \ + 'namespaces:namespace:_pm2_namespaces' \ + 'all:all:(all)' +} + +(( $+functions[_pm2_id_namespace_file] )) || +_pm2_id_namespace_file() { + _alternative \ + 'ids:id:_pm2_id_names' \ + 'namespaces:namespace:_pm2_namespaces' \ + 'files:file:_files' +} + +_pm2 "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: + +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_port b/home/.zsh-server/plugins/zsh-completions/src/_port new file mode 100644 index 0000000..260d37a --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_port @@ -0,0 +1,278 @@ +#compdef port +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for MacPorts (http://www.macports.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Matt Cable +# * Sorin Ionescu +# * Aljaž Srebrnič +# ----------------------------------------------------------------------------- +# License +# ------- +# +# Copyright (c) 2016, Matt Cable, Sorin Ionescu, Aljaž Srebrnič +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ------------------------------------------------------------------------------ + +_port() { + local -a upgrade_options revupgrade_options select_options \ + actions pseudo_common pseudo_advanced port_prefix + + port_prefix=$(which port | sed 's|/bin/port||') + + actions=( + 'activate\:Activate\ the\ given\ ports' + 'archive\:Archive\ the\ given\ ports,\ i.e.\ install\ the\ port\ image\ but\ do\ not\ activate' + 'archivefetch\:Fetch\ archive\ for\ the\ given\ ports' + 'build\:Build\ the\ given\ ports' + 'bump\:Update\ the\ outdated\ checksums\ of\ a\ Portfile' + 'cat\:Writes\ the\ Portfiles\ of\ the\ given\ ports\ to\ stdout' + 'checksum\:Compares\ the\ checksums\ for\ the\ downloaded\ files\ of\ the\ given\ ports' + 'clean\:Removes\ files\ associated\ with\ the\ given\ ports' + 'configure\:Configure\ the\ given\ ports' + 'contents\:\Returns\ a\ list\ of\ files\ installed\ by\ given\ ports' + 'deactivate\:Deactivates\ the\ given\ ports' + 'dependents\:Returns\ a\ list\ of\ installed\ dependents\ for\ each\ of\ the\ given\ ports' + 'deps\:Display\ a\ dependency\ listing\ for\ the\ given\ ports' + 'destroot\:Destroot\ the\ given\ ports' + 'diagnose\:Detects\ common\ issues' + 'dir\:Returns\ the\ directories\ of\ the\ given\ ports' + 'distcheck\:Checks\ if\ the\ given\ ports\ can\ be\ fetched\ from\ all\ of\ its\ master_sites' + 'distfiles\:Returns\ a\ list\ of\ distfiles\ for\ the\ given\ port' + 'dmg\:Creates\ a\ dmg\ for\ each\ of\ the\ given\ ports' + 'dpkg\:Creates\ a\ dpkg\ for\ each\ of\ the\ given\ ports' + 'echo\:Returns\ the\ list\ of\ ports\ the\ argument\ expands\ to' + 'edit\:Edit\ given\ ports' + 'extract\:Extract\ the\ downloaded\ files\ of\ the\ given\ ports' + 'fetch\:Downloaded\ distfiles\ for\ the\ given\ ports' + 'file\:Returns\ the\ path\ to\ the\ Portfile\ for\ each\ of\ the\ given\ ports' + 'gohome\:Opens\ the\ homepages\ of\ the\ given\ ports\ in\ your\ browser' + 'help\:Displays\ short\ help\ texts\ for\ the\ given\ actions' + 'info\:Returns\ information\ about\ the\ given\ ports ' + 'install\:Installs\ the\ given\ ports' + 'installed\:List\ installed\ versions\ of\ the\ given\ port,\ or\ all\ installed\ ports\ if\ no\ port\ is\ given' + 'lint\:Checks\ if\ the\ Portfile\ is\ lint-free\ for\ each\ of\ the\ given\ ports' + 'list\:List\ the\ available\ version\ for\ each\ of\ the\ given\ ports' + 'livecheck\:Checks\ if\ a\ new\ version\ of\ the\ software\ is\ available' + 'load\:Interface\ to\ launchctl(1)\ for\ ports\ providing\ startup\ items' + 'location\:Returns\ the\ install\ location\ for\ each\ of\ the\ given\ ports' + 'log\:Shows\ main\ log\ for\ given\ ports' + 'logfile\:Returns\ the\ log\ file\ path\ for\ each\ of\ the\ given\ ports' + 'mdmg\:Creates\ a\ dmg\ containing\ an\ mpkg\ for\ each\ of\ the\ given\ ports\ and\ their\ dependencies' + 'mirror\:Fetches\ distfiles\ for\ the\ given\ ports' + 'mpkg\:Creates\ an\ mpkg\ for\ each\ of\ the\ given\ ports\ and\ their\ dependencies' + 'notes\:Displays\ informational\ notes\ for\ each\ of\ the\ given\ ports' + 'outdated\:Returns\ a\ list\ of\ outdated\ ports' + 'patch\:Applies\ patches\ to\ each\ of\ the\ given\ ports' + 'pkg\:Creates\ a\ pkg\ for\ each\ of\ the\ given\ ports' + 'platform\:Returns\ the\ current\ platform\ that\ port\ is\ running\ on' + 'provides\:Return\ which\ port\ provides\ each\ of\ the\ files\ given' + 'rdependents\:Recursive\ version\ of\ dependents' + 'rdeps\:Display\ a\ recursive\ dependency\ listing\ for\ the\ given\ ports' + 'reclaim\:Reclaims\ disk\ space' + 'rev-upgrade\:Scan\ for\ broken\ binaries\ in\ the\ installed\ ports\ and\ rebuild\ them\ as\ needed' + 'rpm\:Creates\ a\ rpm\ for\ each\ of\ the\ given\ ports' + 'search\:Search\ for\ a\ port' + 'select\:Select\ between\ multiple\ versions\ of\ a\ versioned\ port' + 'selfupdate\:Upgrade\ MacPorts\ itself\ and\ run\ the\ sync\ target' + 'setrequested\:Marks\ each\ of\ the\ given\ ports\ as\ requested' + 'space\:Show\ the\ disk\ space\ used\ by\ the\ given\ ports' + 'srpm\:Creates\ a\ srpm\ for\ each\ of\ the\ given\ ports' + 'sync\:Synchronize\ the\ set\ of\ Portfiles' + 'test\:Run\ tests\ on\ each\ of\ the\ given\ ports' + 'unarchive\:Unarchive\ the\ destroot\ of\ the\ given\ ports\ from\ installed\ images' + 'uninstall\:Uninstall\ the\ given\ ports' + 'unload\:Interface\ to\ launchctl(1)\ for\ ports\ providing\ startup\ items' + 'unsetrequested\:Marks\ each\ of\ the\ given\ ports\ as\ unrequested' + 'upgrade\:Upgrades\ the\ given\ ports\ to\ the\ latest\ version' + 'url\:Returns\ the\ URL\ for\ each\ of\ the\ given\ ports' + 'usage\:Returns\ basic\ usage\ of\ the\ port\ command' + 'variants\:Returns\ a\ list\ of\ variants\ provided\ by\ the\ given\ ports,\ with\ descriptions\ if\ present' + 'version\:Returns\ the\ version\ of\ MacPorts' + 'work\:Returns\ the\ path\ to\ the\ work\ directory\ for\ each\ of\ the\ given\ ports' + ) + + pseudo_common=(all current active inactive actinact installed uninstalled outdated + obsolete requested unrequested leaves rleaves) + + pseudo_advanced=('variants:' 'variant:' 'description:' 'depends:' + 'depends_lib:' 'depends_run:' 'depends_build:' 'depends_fetch:' 'depends_extract:' + 'portdir:' 'homepage:' 'epoch:' 'platforms:' 'platform:' 'name:' 'long_description:' + 'maintainers:' 'maintainer:' 'categories:' 'category:' 'version:' 'revision:' 'license:') + + select_options=( + '--summary:Display summary of selected options' + '--list:List available versions for the group' + '--set:Select the given version for the group' + '--show:Show which version is currently selected for the group (default if none given)' + ) + + revupgrade_options=('--id-loadcmd-check:Run more checks against a special loadcommand in Mach-O binaries') + + upgrade_options=( + '--force\:Ignore\ circumstances\ that\ would\ normally\ cause\ ports\ to\ be\ skipped\ \(e.g.\ not\ outdated\).' \ + '--enforce-variants\:If\ the\ installed\ variants\ do\ not\ match\ those\ requested,\ upgrade\ even\ if\ the\ port\ is\ not\ outdated.' \ + '--no-replace\:Do\ not\ replace\ one\ port\ with\ another\ according\ to\ the\ replaced_by\ field.' \ + ) + + _arguments -s -C \ + '-v[Verbose mode (generate verbose messages)]' \ + '-d[Debug mode (generate debugging messages, implies -v)]' \ + '-q[Quiet mode (suppress messages)]' \ + "-n[Don't upgrade dependencies (affects upgrade and install)]" \ + "-R[Also upgrade dependents (only affects upgrade) - note that this does not upgrade dependents' dependencies]" \ + '-u[Uninstall non-active ports when upgrading and uninstalling]' \ + '-f[Force mode (ignore state file)]' \ + '-o[Honor state files even if the Portfile has been modified since (called -o because it used to mean "older")]' \ + '-s[Source-only mode (build and install from source, do not attempt to fetch binary archives)]' \ + '-b[Binary-only mode (build and install from binary archives, ignore source, abort if no archive available)]' \ + '-c[Autoclean mode (execute clean after install)]' \ + "-k[Keep mode (don't autoclean after install)]" \ + '-D[Specify portdir]' \ + '-F[Read and process the file of commands specified by the argument.]' \ + '-p[Despite any errors encountered, proceed to process multiple ports and commands.]' \ + '-y[Perform a dry run.]' \ + '-t[Enable trace mode debug facilities on platforms that support it (macOS).]' \ + "1:Port actions:(($actions))" \ + '::Per-action arguments:_port_dispatch' \ + && return 0 +} + +_port_dispatch() { + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + zstyle ":completion:${curcontext}:" cache-policy ${cache_policy:-_port_caching_policy} + + case "$words[2]" in + provides) + _files + ;; + search) + _message 'pattern' + ;; + help) + _describe -t actions 'Port actions' actions + ;; + select) + _call_function - _port_select + ;; + contents|deactivate|setrequested|space|uninstall|unsetrequested) + # Cache the list of installed ports. + if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) && + ! _retrieve_cache PORT_INSTALLED_PACKAGES; + then + _port_installed_packages=( $(_call_program path-all "port -q echo installed") ) + _store_cache PORT_INSTALLED_PACKAGES _port_installed_packages + fi + _alternative \ + "ports:Installed ports:($_port_installed_packages)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" + ;; + upgrade) + # No good reason to actually cache outdated ports list + local outdated_packages + outdated_packages=( $(_call_program path-outdated "port -q echo outdated") ) + _alternative -- \ + "upgrade-options:Upgrade options:(($upgrade_options))" \ + "ports:Outdated ports:($outdated_packages)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" + ;; + rev-upgrade) + if (( CURRENT == 3 )); then + _describe 'Rev-upgrade options' revupgrade_options + fi + ;; + outdated|sync) + # No need to complete anything more here. + return 0; + ;; + selfupdate) + _all_labels 'Selfupdate options' '--nosync' + ;; + *) + # Cache the list of all ports. + if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && + ! _retrieve_cache PORT_AVAILABLE_PACKAGES; + then + _port_available_packages=( $(_call_program path-all "port -q echo all") ) + _store_cache PORT_AVAILABLE_PACKAGES _port_available_packages + fi + _alternative \ + "ports:Available ports:($_port_available_packages)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" + ;; + esac +} + +_port_select() { + if (( CURRENT == 3 )); then + _describe 'Port select options' select_options + elif (( CURRENT == 4 )); then + local select_group + select_group=() + for f in $port_prefix/etc/select/*; do + select_group+=$(basename $f) + done + _describe "Port select groups" select_group + elif [[ $CURRENT -eq 5 && $words[3] == '--set' ]]; then + local select_variants + select_variants=("${(f)$(port select --list $words[4] | sed -e '1 d' -e 's/^[ \t]*//' -e 's/ (active)$//')}") + _describe "Port select group $words[4] variants" select_variants + fi +} + +stat -f%m . > /dev/null 2>&1 +if [ "$?" = 0 ]; then + stat_cmd=(stat -f%Z) +else + stat_cmd=(stat --format=%Z) +fi + +_port_caching_policy() { + local reg_time comp_time check_file + case "${1##*/}" in + PORT_INSTALLED_PACKAGES) + check_file=$port_prefix/var/macports/registry/registry.db + ;; + PORT_AVAILABLE_PACKAGES) + check_file=${$(port dir MacPorts)%/*/*}/PortIndex + ;; + esac + reg_time=$($stat_cmd $check_file) + comp_time=$($stat_cmd $1) + return $(( reg_time < comp_time )) +} + +_port "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_protoc b/home/.zsh-server/plugins/zsh-completions/src/_protoc new file mode 100644 index 0000000..4570c6b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_protoc @@ -0,0 +1,84 @@ +#compdef protoc +# ------------------------------------------------------------------------------ +# Copyright (c) 2020 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for protoc -- protocol buffer description file compiler +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Shohei YOSHIDA (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +__protoc_files() { + if compset -P '@'; then + _files + else + _files -g '*.proto' + fi +} + +_protoc() { + _arguments -C \ + '(- : *)'{-h,--help}'[Show summary of options]' \ + '(- : *)--version[Show version of program]' \ + '*'{-I,--proto_path}'=[Specify the directory which to search for imports]:import_dir:_files -/' \ + '--encode=[Read a text-format message of given type from stdin and write it in binary to stdout]' \ + '--decode=[Read a text-format message of given type from stdin and write it in binary to stdout]' \ + '--decode_raw[Read an arbitrary protocol message from stdin and write the raw tag/value pairs in text format to stdout]' \ + '--descriptor_set_in=[Specifies a delimited list of FILES each containing a FileDescriptorSet]:desc_in:_files' \ + {-o,--descriptor_set_out}'=[Writes a FileDescriptorSet to FILE]:desc_out:_files' \ + '--include_imports[When using --descriptor_set_out, also include all dependencies of the input files in the set]' \ + '--include_source_info[When using --descriptor_set_out, do not strip SourceCodeInfo from the FileDescriptorProto]' \ + '--dependency_out=[Write a dependency output file in the format expected by make]:dep_out:_files' \ + '--error_format=[Set the format in which print errors]:error_format:(gcc msvc)' \ + '--print_free_field_numbers[Print the free field numbers of the messages]'\ + '--plugin=[Specifies a plugin executable to use]:plugin:_files' \ + '--cpp_out=[Generate C++ header and source]:out_dir:_files -/' \ + '--csharp_out=[Generate C# source file]:out_dir:_files -/' \ + '--java_out=[Generate Java source file]:out_dir:_files -/' \ + '--js_out=[Generate JavaScript source]:out_dir:_files -/' \ + '--objc_out=[Generate Objective C header and source]:out_dir:_files -/' \ + '--php_out=[Generate PHP source file]:out_dir:_files -/' \ + '--python_out=[Generate Python source file]:out_dir:_files -/' \ + '--ruby_out=[Generate Ruby source file]:out_dir:_files -/' \ + '*: :__protoc_files' +} + +_protoc "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_pygmentize b/home/.zsh-server/plugins/zsh-completions/src/_pygmentize new file mode 100644 index 0000000..02e3600 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_pygmentize @@ -0,0 +1,149 @@ +#compdef pygmentize +# ------------------------------------------------------------------------------ +# Copyright (c) 2012 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for pygmentize 2.13.0 (https://github.com/pygments/pygments) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hideo Hattori +# +# ------------------------------------------------------------------------------ + +_pygmentize() { + local context state line + + _arguments -s -S \ + '(-g)-l[Specify the lexer to use]:LEXER:_pygmentize_get_lexers' \ + '(-l)-g[Guess the lexer from the file contents]' \ + '-F[Add a filter to the token stream]:STYLE:_pygmentize_get_filters' \ + '-f[Specify the formatter to use]:FORMATTER:_pygmentize_get_formatters' \ + '-O[Give options to the lexer and formatter as a comma-separated list of key-value pairs]' \ + '-P[Give a single option to the lexer and formatter]' \ + '-o[output file]:FILENAME:_files' \ + '-v[Print a detailed traceback on unhandled exceptions]' \ + '-s[Process lines one at a time until EOF]' \ + '-x[Allow custom lexers and formatters to be loaded from a .py file]' \ + '--json[Output as JSON]' \ + '(-L -o -F -H -g -l -N)-S[Print style definitions for STYLE for a formatter given with -f]:STYLE:_pygmentize_get_styles' \ + '-L[lists lexers, formatters, styles or filters]:args:(lexers formatters styles filters)' \ + '(-L -f -o -S -F -H -g -l)-N[guesses and prints out a lexer name based solely on given filename]:FILENAME:_files' \ + '-C[Like -N, but print out a lexer name based solely on a given content from standard input]' \ + '-H[prints detailed help for the object of type ]:' \ + '-a[Formatter-specific additional argument for the -S mode]:' \ + '(* -)-V[prints the package version]' \ + '(* -)'{-h,--help}'[prints help]' \ + '*:args:_files' +} + +_pygmentize_get_filters() { + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _pygmentize_caching_policy + fi + + if ( [[ ${+_pygmentize_filters} -eq 0 ]] || _cache_invalid pygmentize_filters ) \ + && ! _retrieve_cache pygmentize_filters; then + _pygmentize_filters=(${${(f)"$(pygmentize -L filters | grep '* ' | cut -c3- | sed -e 's/:$//')"}}) + _store_cache pygmentize_filters _pygmentize_filters + fi + + local expl + _wanted pygmentize_filters expl 'pygmentize filters' compadd -a _pygmentize_filters +} + +_pygmentize_get_formatters() { + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _pygmentize_caching_policy + fi + + if ( [[ ${+_pygmentize_formatter} -eq 0 ]] || _cache_invalid pygmentize_formatter ) \ + && ! _retrieve_cache pygmentize_formatter; then + _pygmentize_formatter=(${${(f)"$(pygmentize -L formatters | grep '* ' | cut -c3- | sed -e 's/, /\n/g' -e 's/:$//')"}}) + _store_cache pygmentize_formatter _pygmentize_formatter + fi + + local expl + _wanted pygmentize_formatter expl 'pygmentize formatters' compadd -a _pygmentize_formatter +} + +_pygmentize_get_lexers() { + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _pygmentize_caching_policy + fi + + if ( [[ ${+_pygmentize_lexer} -eq 0 ]] || _cache_invalid pygmentize_lexer ) \ + && ! _retrieve_cache pygmentize_lexer; then + _pygmentize_lexer=(${${(f)"$(pygmentize -L lexers | grep '* ' | cut -c3- | sed -e 's/, /\n/g' -e 's/:$//')"}}) + _store_cache pygmentize_lexer _pygmentize_lexer + fi + + local expl + _wanted pygmentize_lexer expl 'pygmentize lexers' compadd -a _pygmentize_lexer +} + +_pygmentize_get_styles() { + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _pygmentize_caching_policy + fi + + if ( [[ ${+_pygmentize_style} -eq 0 ]] || _cache_invalid pygmentize_style ) \ + && ! _retrieve_cache pygmentize_style; then + _pygmentize_style=(${${(f)"$(pygmentize -L styles | grep '* ' | cut -c3- | sed -e 's/:$//')"}}) + _store_cache pygmentize_style _pygmentize_style + fi + + local expl + _wanted pygmentize_style expl 'pygmentize styles' compadd -a _pygmentize_style +} + +_pygmentize_caching_policy() { + local -a oldp + oldp=( "$1"(Nmh+24) ) # 24 hour + (( $#oldp )) +} + +_pygmentize "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_qmk b/home/.zsh-server/plugins/zsh-completions/src/_qmk new file mode 100644 index 0000000..2cfd659 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_qmk @@ -0,0 +1,240 @@ +#compdef qmk +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for QMK CLI (https://beta.docs.qmk.fm/cli). +# version: 0.0.48 (Jun 23 2021) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * precondition (https://github.com/precondition) +# * undg (https://github.com/undg) +# +# ------------------------------------------------------------------------------ + + +_qmk_c2json(){ + _arguments \ + {-h,--help}"[show this help message and exit]" \ + {-km,--keymap}"[KEYMAP The keymap's name]" \ + {-kb,--keyboard}"[KEYBOARD The keyboard's name]" \ + {-q,--quiet}"[Quiet mode, only output error messages]" \ + {-o,--output}"[File to write to]:output_file:_files" \ + "--no-cpp[Do not use 'cpp' on keymap.c]" \ +} + +_qmk_chibios-confmigrate(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-f,--force}"[Re-migrates an already migrated file, even if it doesn't detect a full ChibiOS config.]" \ + {-d,--delete}"[If the file has no overrides, migration will delete the input file.]" \ + {-o,--overwrite}"[Overwrites the input file during migration.]" \ + {-r,--reference}"[REFERENCE Specify the reference file to compare against]" \ + {-i,--input}"[INPUT Specify input config file.]" \ +} + +_qmk_clean(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-a,--all}"[Remove *.hex and *.bin files in the QMK root as well.]" \ +} + +_qmk_clone(){ + _arguments \ + {-h,--help}"[show this help message and exit]" \ + {-km,--keymap}"[KEYMAP The keymap's name]" \ + {-kb,--keyboard}"[KEYBOARD The keyboard's name]" \ + {-q,--quiet}"[Quiet mode, only output error messages]" \ + {-o,--output}"[File to write to]:output_file:_files" \ + "--no-cpp[Do not use 'cpp' on keymap.c]" +} + +_qmk_compile(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-n,--dry-run}"[Don't actually build, just show the make command to be run.]::_qmk_compile" \ + {-km,--keymap}"[The keymap to build a firmware for. Ignored when a configurator export is supplied.]::_qmk_compile" \ + {-kb,--keyboard}"[The keyboard to build a firmware for. Ignored when a configurator export is supplied.]::_qmk_compile" \ + "*::configuratorExport:_files -g '*.json'" \ +} + +_qmk_config(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-ro,--read-only}"[Operate in read-only mode.]" \ +} + +_qmk_doctor(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-n,--no}"[Answer no to all questions.]" \ + {-y,--yes}"[Answer yes to all questions.]" \ +} + +_qmk_env(){ + _arguments \ + {-h,--help}"[Print help text.]" \ +} + +_qmk_flash(){ + _arguments \ + {-bl,--bootloader}"[The flash command, corresponding to qmk's make options of bootloaders.]::_qmk_flash" \ + {-b,--bootloaders}"[List the available bootloaders.]::_qmk_flash" \ + {-c,--clean}"[Remove object files before compiling]" \ + {-n,--dry-run}"[Don't actually build, just show the make command to be run.]::_qmk_flash" \ + {-e,--env}"[Set a variable to be passed to make. May be passed multiple times.]" \ + {-h,--help}"[Print help text.]" \ + {-kb,--keyboard}"[The keyboard to build a firmware for. Ignored when a configurator export is supplied.]::_qmk_flash" \ + {-km,--keymap}"[The keymap to build a firmware for. Ignored when a configurator export is supplied.]::_qmk_flash" \ + {-j,--parallel}"[Set the number of parallel make jobs to run.]" \ + "*::configuratorExport:_files -g '*.json'" \ +} + +_qmk_generate-rgb-breathe-table(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-q,--quiet}"[Quiet mode, only output error messages]" \ + {-o,--output}"[File to write to]:output_file:_files" \ + {-m,--max}"[MAX The breathing maximum value, from 0 to 255. Default: 255]" \ + {-c,--center}"[CENTER The breathing center value, from 1 to 2.7. Default: 1.85]" \ +} + +_qmk_info(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-f,--format}"[Format to display the data in (friendly, text, json)(Default: friendly).]: :(friendly text json)" \ + {-m,--matrix}"[Render the layouts with matrix information.]" \ + {-l,--layouts}"[Render the layouts.]" \ + {-km,--keymap}"[Show the layers for a JSON keymap too.]" \ + {-kb,--keyboard}"[Keyboard to show info for.]" \ + "--ascii[Render layout box drawings in ASCII only.]" \ +} + +_qmk_json2c(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-q,--quiet}"[Quiet mode, only output error messages]" \ + {-o,--output}"[File to write to]:output_file:_files" \ + "*::configuratorExport:_files -g '*.json'" +} + +_qmk_lint(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-km,--keymap}"[KEYMAP The keymap to check.]" \ + {-kb,--keyboard}"[KEYBOARD The keyboard to check.]" \ + "--strict[Treat warnings as errors.]" \ +} + +_qmk_list-keyboards(){ + _arguments \ + {-h,--help}"[Print help text.]" \ +} + +_qmk_list-keymaps(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-kb,--keyboard}"[Specify keyboard name. Example: 1upkeyboards/1up60hse]::_qmk_new-keymap" \ +} + +_qmk_new-keymap(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-km,--keymap}"[Specify the name for the new keymap directory]::_qmk_new-keymap" \ + {-kb,--keyboard}"[Specify keyboard name. Example: 1upkeyboards/1up60hse]::_qmk_new-keymap" \ +} + +_qmk_setup(){ + _arguments \ + {-h,--help}"[Print help text.]" \ + {-H,--home}"[The location for QMK Firmware. Defaults to $HOME/qmk_firmware]" \ + {-b,--branch}"[The branch to clone]" \ + {-y,--yes}"[Answer yes to all questions.]" \ + {-n,--no}"[Answer no to all questions.]" \ + "--baseurl[The URL all git operations start from]" \ +} + +_qmk_command(){ + local -a _qmk_cmds + _qmk_cmds=( + "c2json: Creates a keymap.json from a keymap.c file." \ + "chibios-confmigrate: Generates a migrated ChibiOS configuration file, as a result of comparing the input against a reference" \ + "clean: Clean the QMK firmware folder of build artifacts." \ + "clone: Clone a qmk_firmware fork." \ + "compile: Compile a QMK Firmware." \ + "config: Read and write configuration settings." \ + "doctor: Basic QMK environment checks" \ + "env: Prints environment information." \ + "flash: QMK Flash." \ + "generate-rgb-breathe-table: Generates an RGB Light breathing table header." \ + "info: Keyboard information." \ + "json2c: Creates a keymap.c from a QMK Configurator export." \ + "lint: Check keyboard and keymap for common mistakes." \ + "list-keyboards: List the keyboards currently defined within QMK" \ + "list-keymaps: List the keymaps for a specific keyboard" \ + "new-keymap: Creates a new keymap for the keyboard of your choosing" \ + "setup: Setup your computer for qmk_firmware." \ + ) + + if ((CURRENT == 1)); then + _describe -t commands 'qmk commands' _qmk_cmds + else + local curcontext="$curcontext" + cmd="${${_qmk_cmds[(r)$words[1]:*]%%:*}}" + if (($#cmd)); then + if (( $+functions[_qmk_$cmd] )); then + _qmk_$cmd + else + _message "no options for $cmd" + fi + else + _message "no more options" + fi + fi +} + + +_arguments \ + {-h,--help}"[Print help text.]" \ + {-V,--version}"[Prints version information]" \ + {-v,--verbose}"[Make the logging more verbose]" \ + "--datetime-fmt[Format string for datetimes]:DATETIME_FMT:()" \ + "--log-fmt[Format string for printed log output]:LOG_FMT:()" \ + "--log-file-fmt[Format string for log file.]:LOG_FILE_FMT:()" \ + "--log-file-level[Logging level for log file]:debug,info,warning,error,critical" \ + "--log-file[File to write log messages to]:filename:_files" \ + "--color[Enable color in output]" \ + "--no-color[Disable color in output]" \ + "--unicode[Enable unicode loglevels]" \ + "--no-unicode[Disable unicode loglevels]" \ + "--config-file[The location for the configuration file]:filename:_files" \ + "*::qmk commands:_qmk_command" \ + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rails b/home/.zsh-server/plugins/zsh-completions/src/_rails new file mode 100644 index 0000000..6dc85d4 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rails @@ -0,0 +1,624 @@ +#compdef rails +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Ruby on Rails (http://rubyonrails.org/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Kazuya Takeshima (https://github.com/mitukiii) +# +# ------------------------------------------------------------------------------ + + +_rails() { + local context state line curcontext="$curcontext" + + if (( CURRENT > 2 )); then + (( CURRENT-- )) + shift words + _call_function - "_rails_${words[1]}" || _nothing + else + __rails_commands + fi +} + +__rails_commands() { + local context state line curcontext="$curcontext" + + local -a rails_options + __rails_setup_rails_options + + _arguments -C \ + $rails_options \ + ': :->command' + + case "$state" in + command) + local -a commands + local application_directory + __rails_setup_application_directory + + if [ -n "$application_directory" ]; then + commands=( + {generate,g}'[Generate new code]' + {console,c}'[Start the Rails console]' + {server,s}'[Start the Rails server]' + {dbconsole,db}'[Start a console for the database specified in config/database.yml]' + application'[Generate the Rails application code]' + {destroy,d}'[Undo code generated with "generate"]' + benchmarker'[See how fast a piece of code runs]' + profiler'[Get profile information from a piece of code]' + plugin'[Install a plugin]' + {runner,r}'[Run a piece of code in the application environment]' + {test,t}'[Run tests]' + ) + else + commands=( + new'[Create a new Rails application]' + ) + fi + + _values 'command' $commands + ;; + esac +} + +__rails_setup_application_directory() { + application_directory="$(pwd)" + + while [ -n "$application_directory" ]; do + if [ -f "${application_directory}/script/rails" -o -f "${application_directory}/bin/rails" ]; then + return + fi + application_directory="${application_directory%/*}" + done + + application_directory= +} + +__rails_setup_rails_options() { + rails_options=( + {-h,--help}'[Show this help message and quit]' + {-v,--version}'[Show Rails version number and quit]' + ) +} + +__rails_setup_runtime_options() { + runtime_options=( + '(-f --force)'{-f,--force}'[Overwrite files that already exist]' + '(-p --pretend)'{-p,--pretend}'[Run but do not make any changes]' + '(-q --quiet)'{-q,--quiet}'[Suppress status output]' + '(-s --skip)'{-s,--skip}'[Skip files that already exist]' + ) +} + +__rails_setup_generators_options() { + local -a runtime_options + __rails_setup_runtime_options + + generators_options=( + $runtime_options + --skip-namespace'[Skip namespace (affects only isolated applications)]' + --old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]" + ) +} + +__rails_setup_model_generators_options() { + local -a generators_options + __rails_setup_generators_options + + model_generators_options=( + $generators_options + '(-o --orm)'{-o,--orm=}'[Orm to be invoked]:orm' + ) +} + +__rails_setup_resource_generators_options() { + local -a model_generators_options + __rails_setup_model_generators_options + + resource_generators_options=( + $model_generators_options + --force-plural'[Forces the use of a plural ModelName]' + --resource-route'[Indicates when to generate resource route]: :__rails_boolean' + ) +} + +__rails_boolean() { + _values 'boolean' 'true' 'false' +} + +__rails_migration_fields() { + if compset -P '*:*:'; then + _values 'index' 'index' 'uniq' + else + if compset -P '*:'; then + _values -s ':' 'type' 'string' 'text' 'integer' 'float' 'decimal' 'datetime' 'timestamp' 'time' 'date' 'binary' 'boolean' 'references' + else + _guard '[[:alnum:]_]#' 'field' + fi + fi +} + +_rails_generate() { + local context state line curcontext="$curcontext" + + if (( CURRENT > 2 )); then + (( CURRENT-- )) + shift words + _call_function - "_rails_generate_${words[1]}" || _rails_generate_default + else + __rails_generate_commands + fi +} + +_rails_g() { + _rails_generate +} + +__rails_generate_commands() { + local context curcontext="$curcontext" update_policy + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [ -z "$update_policy" ]; then + zstyle ":completion:${curcontext}:" cache-policy _rails_generate_commands_caching_policy + fi + + local application_directory + __rails_setup_application_directory + local cache_name + cache_name="rails/${application_directory##*/}/all_generators" + if ! _retrieve_cache ${cache_name}; then + local -a all_generators + all_generators=($(_call_program rails_generators rails generate 2> /dev/null | awk '/^ [a-zA-Z_]+/{ print $1 }')) + _store_cache ${cache_name} all_generators + fi + + local -a rails_generators + rails_generators=(${all_generators:#*:*}) + _describe -t rails_generators 'rails generator' rails_generators + + local -a -U namespaces + local namespace + local -a generators + namespaces=(${(R)${(M)all_generators:#*:*}%:*}) + for namespace in $namespaces; do + generators=(${${(M)all_generators:#${namespace}:*}/:/\\:}) + _describe -t ${namespace}_generators "${namespace/_/ } generator" generators + done +} + +_rails_generate_commands_caching_policy() { + local application_directory + __rails_setup_application_directory + + if [ "${application_directory}/Gemfile" -nt "$1" ]; then + return 0 + fi + + local -a oldp + oldp=( "$1"(Nmw+1) ) + (( $#oldp )) +} + +_rails_generate_default() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + '*:argument' +} + +_rails_generate_assets() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + '(-j --javascripts)'{-j,--javascripts}'[Generate JavaScripts]: :__rails_boolean' \ + '(-y --stylesheets)'{-y,--stylesheets}'[Generate Stylesheets]: :__rails_boolean' \ + '(-je --javascript-engine)'{-je,--javascript-engine=}'[Engine for JavaScripts]:javascript engine' \ + '(-se --stylesheet-engine)'{-se,--stylesheet-engine=}'[Engine for Stylesheets]:stylesheet engine' \ + ': :_guard "^-*" "name"' +} + +_rails_generate_controller() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + '(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \ + '(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \ + --helper'[Indicates when to generate helper]: :__rails_boolean' \ + --assets'[Indicates when to generate assets]: :__rails_boolean' \ + ': :_guard "^-*" "name"' \ + '*: :_guard "^-*" "action"' +} + +_rails_generate_generator() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + --namespace'[Namespace generator under lib/generators/name]: :__rails_boolean' \ + ': :_guard "^-*" "name"' +} + +_rails_generate_helper() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + '(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \ + ': :_guard "^-*" "name"' \ +} + +_rails_generate_integration_test() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + --integration-tool='[Integration tool to be invoke]:integration tool' \ + ': :_guard "^-*" "name"' \ +} + +_rails_generate_jbuilder() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + ': :_guard "^-*" "name"' \ + '*: :__rails_migration_fields' +} + +_rails_generate_mailer() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + '(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \ + '(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \ + ': :_guard "^-*" "name"' \ + '*: :_guard "^-*" "method"' +} + +_rails_generate_migration() { + local -a modelgenerators_options + __rails_setup_model_generators_options + + _arguments \ + $model_generators_options \ + ': :_guard "^-*" "name"' \ + '*: :__rails_migration_fields' +} + +_rails_generate_model() { + _rails_generate_migration +} + +_rails_generate_observer() { + local -a model_generators_options + __rails_setup_model_generators_options + + _arguments \ + $model_generators_options \ + ': :_guard "^-*" "name"' +} + +_rails_generate_performance_test() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + --performance-tool='[Performance tool to be invoked]:performance tool' \ + ': :_guard "^-*" "name"' \ +} + +_rails_generate_resource() { + local context state line curcontext="$curcontext" + + local -a resource_generators_options + __rails_setup_resource_generators_options + + _arguments -C \ + $resource_generators_options \ + '(-c --resource-controller)'{-c,--resource-controller=}'[Resource controller to be invoked]:name' \ + '(-a --actions)'{-a,--actions=}'[Actions for the resource controller]: :->actions' \ + ': :->name' \ + '*: :->fields' + + if (( words[(I)(--actions=*|-a)] > 0 && words[(I)(--actions=*|-a)] == words[(I)-*] )); then + state=actions + fi + + case "$state" in + actions) + _guard "[[:alnum:]_]#" "actions" + ;; + name) + _guard "^-*" "name" + ;; + fields) + __rails_migration_fields + ;; + esac +} + +_rails_generate_scaffold() { + local -a resource_generators_options + __rails_setup_resource_generators_options + + _arguments \ + $resource_generators_options \ + '(-y --stylesheets)'{-y,--stylesheets}'[Generate Stylesheets]: :__rails_boolean' \ + '(-se --stylesheet-engine)'{-se,--stylesheet-engine=}'[Engine for Stylesheets]:stylesheet engine' \ + '(-c --scaffold-controller)'{-c,--scaffold-controller=}'[Scaffold controller to be invoked]:name' \ + --assets'[Indicates when to generate assets]:boolean:(true false)' \ + ': :_guard "^-*" "name"' \ + '*: :__rails_migration_fields' +} + +_rails_generate_scaffold_controller() { + local -a model_generators_options + __rails_setup_model_generators_options + + _arguments \ + $model_generators_options \ + '(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \ + '(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \ + --helper'[Indicates when to generate helper]: :__rails_boolean' \ + ': :_guard "^-*" "name"' +} + +_rails_generate_session_migration() { + local -a model_generators_options + __rails_setup_model_generators_options + + _arguments \ + $model_generators_options \ + ': :_guard "^-*" "name"' +} + +_rails_generate_task() { + local -a generators_options + __rails_setup_generators_options + + _arguments \ + $generators_options \ + ': :_guard "^-*" "name"' \ + '*: :_guard "^-*" "action"' +} + +_rails_console() { + _arguments \ + '(- *)'{-h,--help}'[Show this help message]' \ + '(-s --sandbox)'{-s,--sandbox}'[Rollback database modifications on exit]' \ + --debugger'[Enable ruby-debugging for the console]' +} + +_rails_c() { + _rails_console +} + +_rails_server() { + _arguments \ + '(- *)'{-h,--help}'[Show this help message]' \ + '(-p --port)'{-p,--port=}'[Runs Rails on the specified port]: :_guard "[[\:digit\:]]#" "port"' \ + '(-b --binding)'{-b,--binding=}'[Binds Rails to the specified ip]:ip:_hosts' \ + '(-c --config)'{-c,--config=}'[Use custom rackup configuration file]:file:_files -g "*.ru"' \ + '(-d --daemon)'{-d,--daemon}'[Make server run as a Daemon]' \ + '(-u --debugger)'{-u,--debugger}'[Enable ruby-debugging for the server]' \ + '(-e --environment)'{-e,--environment=}'[Specifies the environment to run this server under (test/development/production)]:name:(test development production)' \ + '(-P --pid)'{-P,--pid=}'[Specifies the PID file]:pid:_files -g "*.pid"' +} + +_rails_s() { + _rails_server +} + +_rails_dbconsole() { + _arguments \ + '(- *)'--help'[Show this help message]' \ + '(-p --include-password)'{-p,--include-password}'[Automatically provide the password from database.yml]' \ + --mode'[Automatically put the sqlite3 database in the specified mode (html, list, line, column)]:mode:(html list line column)' \ + --header +} + +_rails_new() { + local context state line curcontext="$curcontext" + + local _a rails_options runtime_options + __rails_setup_rails_options + __rails_setup_runtime_options + + _arguments -C \ + $rails_options \ + $runtime_options \ + '(-r --ruby)'{-r,--ruby=}'[Path to the Ruby binary of your choice]:path' \ + '(-b --builder)'{-b,--builder=}'[Path to a application builder (can be a filesystem path or URL)]: :->path_or_url' \ + '(-m --template)'{-m,--template=}'[Path to an application template (can be a filesystem path or URL)]: :->path_or_url' \ + --skip-gemfile"[Don't create a Gemfile]" \ + --skip-bundle"[Don't run bundle install]" \ + '(-G --skip-git)'{-G,--skip-git}'[Skip Git ignores and keeps]' \ + '(-O --skip-active-record)'{-O,--skip-active-record}'[Skip Active Record files]' \ + '(-S --skip-sprockets)'{-S,--skip-sprockets}'[Skip Sprockets files]' \ + '(-d --database)'{-d,--database=}'[Preconfigure for selected database]:database:(mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)' \ + '(-j --javascript)'{-j,--javascript=}'[Preconfigure for selected JavaScript library]:javascript' \ + '(-J --skip-javascript)'{-J,--skip-javascript}'[Skip JavaScript files]' \ + --dev'[Setup the application with Gemfile pointing to your Rails checkout]' \ + --edge'[Setup the application with Gemfile pointing to Rails repository]' \ + '(-T --skip-test-unit)'{-T,--skip-test-unit}'[Skip Test::Unit files]' \ + --old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]" \ + ':app path:_directories' + + case "$state" in + path_or_url) + _alternative \ + 'files:path:_files -g "*.rb"' \ + 'url:url:_urls' + ;; + esac +} + +_rails_application() { + _rails_new +} + +_rails_db() { + _rails_dbconsole +} + +_rails_destroy() { + _rails_generate +} + +_rails_d() { + _rails_destroy +} + +_rails_benchmarker() { + _arguments \ + '(- *)'{-h,--help}'[Show this help message]' \ + '(-r --runs)'{-r,--runs}'[Number of runs]: :_guard "[[\:digit\:]]#" "number"' \ + '(-o --output)'{-o,--output}'[Directory to use when writing the results]:directory:_directories' \ + '(-m --metrics)'{-m,--metrics}'[Metrics to use]: :_values -s "," "metrics" "wall_time" "memory" "objects" "gc_runs" "gc_time"' \ + '*: :_guard "^-*" "ruby code"' +} + +_rails_profiler() { + _arguments \ + '(- *)'{-h,--help}'[Show this help message]' \ + '(-r --runs)'{-r,--runs}'[Number of runs]: :_guard "[[\:digit\:]]#" "number"' \ + '(-o --output)'{-o,--output}'[Directory to use when writing the results]:directory:_directories' \ + '(-m --metrics)'{-m,--metrics}'[Metrics to use]: :_values -s "," "metrics" "process_time" "memory" "objects"' \ + '(-f --formats)'{-f,--formats}'[Formats to output to]: :_values -s "," "formats" "flat" "graph" "html" "call_tree" "call_stack"' \ + '*: :_guard "^-*" "ruby code"' +} + +_rails_plugin() { + local context state line curcontext="$curcontext" + + if (( CURRENT > 2 )); then + (( CURRENT-- )) + shift words + _call_function - "_rails_plugin_${words[1]}" || _nothing + else + __rails_plugin_commands + fi +} + +__rails_plugin_commands() { + _values 'plugin command' \ + install'[Install plugin(s) from known repositories or URLs]' \ + remove'[Uninstall plugins]' \ + new +} + +_rails_plugin_install() { + _arguments \ + '(-x --externals)'{-x,--externals}'[Use svn:externals to grab the plugin. Enables plugin updates and plugin versioning]' \ + '(-o --checkout)'{-o,--checkout}'[Use svn checkout to grab the plugin. Enables updating but does not add a svn:externals entry]' \ + '(-e --export)'{-e,--export}'[Use svn export to grab the plugin. Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry]' \ + '(-q --quiet)'{-q,--quiet}'[Suppresses the output from installation. Ignored if -v is passed (rails plugin -v install ...)]' \ + '(-r --revision)'{-r,--revision=}'[Checks out the given revision from subversion or git. Ignored if subversion/git is not used]:revision' \ + '(-f --force)'{-f,--force}"[Reinstalls a plugin if it's already installed]" \ + '*:plugin:_urls' +} + +_rails_plugin_remove() { + local -a plugins + + plugins=($(_call_program rails_plugins ls -1 vendor/plugins)) + + _describe -t plugins 'plugin' plugins +} + +_rails_plugin_new() { + _rails_new +} + +_rails_runner() { + local context state line curcontext="$curcontext" + + _arguments -C \ + '(- *)'{-h,--help}'[Show this help message]' \ + '(-e --environment)'{-e,--environment=}'[Specifies the environment for the runner to operate under (test/development/production)]:name:(test development production)' \ + ': :->code_or_path' + + case "$state" in + code_or_path) + _alternative \ + 'files:filename:_files -g "*.rb"' \ + 'codes:ruby code:_guard "^-*" "ruby code"' + ;; + esac +} + +_rails_r() { + _rails_runner +} + +_rails_test() { + local context state line curcontext="$curcontext" + + _arguments -C \ + ': :->path' + + case "$state" in + path) + _alternative \ + 'files:filename:_files -g "*.rb"' + ;; + esac +} + +_rails_t() { + _rails_test +} + +_rails "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ralio b/home/.zsh-server/plugins/zsh-completions/src/_ralio new file mode 100644 index 0000000..cedbb02 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ralio @@ -0,0 +1,146 @@ +#compdef ralio +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ralio (https://github.com/oesmith/ralio), a +# Rally client +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Peter Yates +# +# ------------------------------------------------------------------------------ + +_ralio () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' \ + + case $state in + (command) + + local -a subcommands + subcommands=( + "backlog:Show the product backlog" + "sprint:Show the current team iteration" + "show:Show related information for an individual story, defect or task" + "open:Open a story, defect or task in a web browser" + "start:Set a task, defect or story state to in-progress and assign it to you" + "finish:Set a task, defect or story state to completed and assign it to you" + "abandon:Set a task, defect or story state to defined and clear the owner" + "block:Set a task, defect or story state to blocked" + "unblock:Set a task, defect or story state to unblocked" + "current:Show your current tasks and stories" + "point:Set the points for a story or defect" + "task:Allow you to create and delete story tasks." + "configure:Set your Rally configurations." + ) + _describe -t commands 'ralio commands' subcommands + + _arguments -C \ + {-V,--version}"[display version information]" \ + {-h,--help}"[output usage information]" + ;; + + (options) + case $line[1] in + + + (sprint) + _arguments \ + "-t[Show tasks]" \ + "-p[Project name]" \ + "-f[Filter results]" + ;; + + (start | finish) + _arguments \ + '--pair[Pair programming partner]' \ + "--resolution[Resolution status]" \ + "--rootcause[Root cause]" + ;; + + (task) + __ralio-task + ;; + + esac + ;; + esac +} + +__ralio-task () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + "create:Create a new task" + "delete:Delete a task" + ) + _describe -t commands 'ralio task' subcommands + ;; + + (options) + case $line[1] in + + (create|delete) + _arguments \ + -n"[Name of the new task]" \ + -t"[Name of the parent task]" + ;; + + esac + ;; + esac +} + +_ralio "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_redis-cli b/home/.zsh-server/plugins/zsh-completions/src/_redis-cli new file mode 100644 index 0000000..d11c06f --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_redis-cli @@ -0,0 +1,184 @@ +#compdef redis-cli rec +# ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Redis (http://redis.io). +# +# Source: https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/redis-cli +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Alexandru Totolici (https://github.com/totolici) +# +# ------------------------------------------------------------------------------ + + +local -a _1st_arguments +_1st_arguments=( + 'append:append a value to a key' + 'auth:authenticate to the server' + 'bgrewriteeaof:asynchronously rewrite the append-only file' + 'bgsave:asynchornously save the dataset to disk' + 'blpop:remove and get the first element in a list, or block until one is available' + 'brpop:remove and get the last element in a list, or block until one is available' + 'brpoplpush:pop a value from a list, push it to another list and return it; or block until one is available' + # 'config get:get the value of a configuration parameter' + # 'config set:set a configuration parameter to the given value' + # 'config resetstat: reset the stats returned by INFO' + 'dbsize:return the number of keys in the selected database' + # 'debug object:get debugging information about a key' + # 'debug setgfault:make the server crash' + 'decr:decrement the integer value of a key by one' + 'decrby:decrement the integer value of a key by the given number' + 'del:delete a key' + 'discard:discard all commands issued after MULTI' + 'echo:echo the given string' + 'exec:execute all commands issued after a MULTI' + 'exists:determine if a key exists' + 'expire:set the time to live for a key, in seconds' + 'expireat:set the expiration for a key as a UNIX timestamp' + 'flushall:remove all keys from all databases' + 'flushdb:remove all keys from the current database' + 'get:get the value of a key' + 'getbit:returns the bit value at offset in the string value stored at key' + 'getrange:get a substring of the string stored at a key' + 'getset:set the string value of a key and return its old value' + 'hdel:delete a hash field' + 'hexists:determine if a hash field exists' + 'hget:get the value of a hash field' + 'hgetall:get all the fields and values in a hash' + 'hincrby:increment the integer value of a hash field by the given number' + 'hkeys:get all the fields in a hash' + 'hlen:get the number of fields in a hash' + 'hmget:get the values of all the given hash fields' + 'hmset:set multiple hash fields to multiple values' + 'hset:set the string value of a hash field' + 'hsetnx:set the value of a hash field, only if the field does not exist' + 'hvals:get all the values in a hash' + 'incr:increment the integer value of a key by one' + 'incrby:increment the integer value of a key by the given number' + 'info:get information and statistics about the server' + 'keys:find all keys matching the given pattern' + 'lastsave:get the UNIX timestamp of the last successful save to disk' + 'lindex:get an element from a list by its index' + 'linsert:insert an element before or after another element in a list' + 'llen:get the length of a list' + 'lpop:remove and get the first element in a list' + 'lpush:prepend a value to a list' + 'lpushx:prepend a value to a list, only if the list exists' + 'lrange:get a range of elements from a list' + 'lrem:remove elements from a list' + 'lset:set the value of an element in a list by its index' + 'ltrim:trim a list to the specified range' + 'mget:get the values of all the given keys' + 'monitor:listen for all requests received by the server in real time' + 'move:move a key to another database' + 'mset:set multiple keys to multiple values' + 'msetnx:set multiple keys to multiple values, only if none of the keys exist' + 'multi:mark the start of a transaction block' + 'object:inspect the internals of Redis objects' + 'persist:remove the expiration from a key' + 'ping:ping the server' + 'psubscribe:listen for messages published to channels matching the given patterns' + 'publish:post a message to a channel' + 'punsubscribe:stop listening for messages posted to channels matching the given patterns' + 'quit:close the connection' + 'randomkey:return a random key from the keyspace' + 'rename:rename a key' + 'renamenx:rename a key, only if the new key does not exist' + 'rpop:remove and get the last element in a list' + 'rpoplpush:remove the last element in a list, append it to another list and return it' + 'rpush:append a value to a list' + 'rpushx:append a value to a list, only if the list exists' + 'sadd:add a member to a set' + 'save:synchronously save the dataset to disk' + 'scard:get the number of members in a set' + 'sdiff:subtract multiple sets' + 'sdiffstore:subtract multiple sets and store the resulting set in a key' + 'select:change the selected database for the current connection' + 'set:set the string value of a key' + 'setbit:sets or clears the bit at offset in the string value stored at key' + 'setex:set the value and expiration of a key' + 'setnx:set the value of a key, only if the key does not exist' + 'setrange:overwrite part of a string at key starting at the specified offset' + 'shutdown:synchronously save the dataset to disk and then shut down the server' + 'sinter:intersect multiple sets' + 'sinterstore:intersect multiple sets and store the resulting set in a key' + 'sismember:determine if a given value is a member of a set' + 'slaveof:make the server a slave of another instance, or promote it as master' + 'smembers:get all the members in a set' + 'smove:move a member from one set to another' + 'sort:sort the elements in a list, set or sorted set' + 'spop:remove and return a random member from a set' + 'srandmember:get a random member from a set' + 'srem:remove a member from a set' + 'strlen:get the length of the value stored in a key' + 'subscribe:listen for messages published to the given channels' + 'sunion:add multiple sets' + 'sunionstore:add multiple sets and store the resulting set in a key' + 'ttl:get the time to live for a key' + 'type:determine the type stored at key' + 'unsubscribe:stop listening for messages posted to the given channels' + 'unwatch:forget about all watched keys' + 'watch:watch the given keys to determine execution of the MULTI/EXEC block' + 'zadd:add a member to a sorted set, or update its score if it already exists' + 'zcard:get the number of members in a sorted set' + 'zcount:count the members in a sorted set with scores within the given values' + 'zincrby:increment the score of a member in a sorted set' + 'zinterstore:intersect multiple sorted sets and store the resulting sorted set in a new key' + 'zrange:return a range of members in a sorted set, by index' + 'zrangebyscore:return a range of members in a sorted set, by score' + 'zrank:determine the index of a member in a sorted set' + 'zrem:remove a member from a sorted set' + 'zremrangebyrank:remove all members in a sorted set within the given indexes' + 'zremrangebyscore:remove all members in a sorted set within the given scores' + 'zrevrange:return a range of members in a sorted set, by index, with scores ordered from high to low' + 'zrevrangebyscore:return a range of members in a sorted set, by score, with scores ordered from high to low' + 'zrevrank:determine the index of a member in a sorted set, with scores ordered from high to low' + 'zscore:get the score associated with the given member in a sorted set' + 'zunionstore:add multiple sorted sets and store the resulting sorted set in a new key' +) + +local expl + +_arguments \ + '(-v --version)'{-v,--version}'[show version]' \ + '(-h --help)'{-h,--help}'[show help]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "redis-cli subcommand" _1st_arguments + return +fi + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rfkill b/home/.zsh-server/plugins/zsh-completions/src/_rfkill new file mode 100644 index 0000000..1c88133 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rfkill @@ -0,0 +1,102 @@ +#compdef rfkill +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Vincent Bernat +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rfkill (http://wireless.kernel.org/en/users/Documentation/rfkill) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Vincent Bernat +# +# ------------------------------------------------------------------------------ + +_rfkill_types() { + declare -a devicetypes + devicetypes=(all + "wifi:Wireless LAN" "wlan:Wireless LAN" + "bluetooth:Bluetooth" + "uwb:Ultrawide Band" + "ultrawideband:Ultrawide Band" + "wimax:Wimax" + "wwan:3G" + "gps:GPS" + "fm:FM Radio" + "nfc:NFC") + _describe -t device-types "device types" devicetypes +} + +_rfkill_devices() { + declare -a devices + devices=(${(M)${(f)"$(rfkill list)"}:#[0-9]*}) + _rfkill_types + _describe -t devices "devices" devices +} + +_rfkill_commands () { + declare -a subcommands + subcommands=(help event list block unblock) + _describe -t rfkill-commands "rfkill command" subcommands +} + +_rfkill_subcommand () { + case "$words[1]" in + (help|event) + ;; + (list) + _arguments ':types:_rfkill_types' + ;; + (block|unblock) + _arguments ':device:_rfkill_devices' + ;; + (*) + _message 'Unknown subcommand' + esac +} + +_rfkill () { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + '--version[get version]:' \ + '(-): :->command' \ + '(-)*:: :->arguments' + + case $state in + (command) + _rfkill_commands + ;; + (arguments) + curcontext=${curcontext%:*:*}:rfkill-$words[1]: + _rfkill_subcommand + ;; + esac +} + +_rfkill "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rkt b/home/.zsh-server/plugins/zsh-completions/src/_rkt new file mode 100644 index 0000000..d4ce021 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rkt @@ -0,0 +1,369 @@ +#compdef rkt +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rkt (https://coreos.com/rkt/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# +# ------------------------------------------------------------------------------ + +typeset -A opt_args +autoload -U regexp-replace + +_rkt() { + _arguments \ + '--debug[print out more debug information to stderr]' \ + '--dir=[rkt data directory]:data directory:_files -/' \ + '--insecure-options=[comma-separated list of security features to disable]:option:{_values -s , none image tls ondisk http all}' \ + '--local-config=[local configuration directory]:configuration directory:_files -/' \ + '--system-config=[system configuration directory]:configuration directory:_files -/' \ + '--trust-keys-from-https[automatically trust gpg keys fetched from https]' \ + '--user-config=[user configuration directory]:configuration directory:_files -/' \ + '--help' \ + '1: :_rkt_cmds' \ + '*:: :->rkt_cmd_args' + + case $state in + rkt_cmd_args) + case $words[1] in + help) + _arguments \ + '1: :_rkt_cmds' \ + '*:: :->rkt_help_args' \ + ;; + + api-service) + _arguments \ + '--listen=[address to listen for client API requests]:address' \ + ;; + + cat-manifest) + _arguments \ + '--pretty-print[apply indent to format the output]' \ + '--uuid-file=[read pod UUID from file instead of argument]:uuid file:_files' \ + '1:POD:_rkt_pods' \ + ;; + + config) + _arguments \ + '--pretty-print[apply indent to format the output]' \ + ;; + + enter) + _arguments \ + '--app=:appname' \ + '1:POD:_rkt_pods' \ + ;; + + export) + _arguments \ + '--app=:appname' \ + '--overwrite[overwrite output ACI]' \ + '1:POD:_rkt_pods' \ + '2:OUTPUT_ACI_FILE:_files' \ + ;; + + fetch) + _arguments \ + '--full[print the full image hash after fetching]' \ + '--no-store[fetch images ignoring the local store]' \ + '--signature=[local signature file to use in validating the preceding image]:signature:_files' \ + '--store-only[use only available images in the store]' \ + ;; + + gc) + _arguments \ + '--grace-period=[duration to wait before discarding inactive pods from garbage]:duration' \ + '--expire-prepared=[duration to wait before expiring prepared pods]:duration' \ + '--mark-only[move to the garbage directories without actually deleting]' \ + ;; + + image) + _arguments \ + '1: :_rkt_image_cmds' \ + '*:: :->rkt_image_args' + ;; + + list) + _arguments \ + '--full[use long output format]' \ + '--no-legend[suppress a legend with the list]' \ + ;; + + metadata-service) + _arguments \ + '--listen-port=[listen port]:port' \ + ;; + + prepare) + # TODO: autocomplete stage1 images + _arguments \ + '--caps-remove=[capability to remove]:capability' \ + '--caps-retain=[capability to retain]:capability' \ + '--cpu=[cpu limit for the preceding image]:cpu limit' \ + '--cpu-shares=[assign the specified CPU time share weight]:weight' \ + "--environment=[set the app's environment variables]:variable key=value" \ + '--exec=[override the exec command for the preceding image]:command' \ + '--group=[group override for the preceding image]:group' \ + '--inherit-env[inherit all environment variables not set by apps]' \ + '--memory=[memory limit for the preceding image]:memory' \ + '--mount=[mount point binding a volume to a path within an app]:mount point' \ + '--name=[set the name of the app]:name' \ + '--no-overlay[disable overlay filesystem]' \ + '--oom-score-adj=[oom-score-adj isolator override]:oom-score-adj' \ + '--pod-manifest=[the path to the pod manifest]:manifest:_files' \ + '--port=[ports to expose on the host]:NAME\:HOSTPORT' \ + '--private-users[run within user namespaces]' \ + '--quiet[suppress superfluous output on stdout, print only the UUID on success]' \ + '--readonly-rootfs=[mount rootfs read-only]:fs' \ + '--set-env=[an environment variable to set for apps]:NAME=VALUE' \ + '--set-env-file=[the path to an environment variables file]:file:_files' \ + '--signature=[local signature file to use in validating the preceding image]:signature:_files' \ + '--stage1-from-dir=[a filename of an image in stage1 images directory to use as stage1]:image' \ + '--stage1-hash=[a hash of an image to use as stage1]:image hash' \ + '--stage1-name=[a name of an image to use as stage1]:image name' \ + '--stage1-path=[a path to an image to use as stage1]:image path:_files' \ + '--stage1-url=[a URL to an image to use as stage1]:image url' \ + '--supplementary-gids=[supplementary group IDs override for the preceding image]:group IDs' \ + '--user=[user override for the preceding image]:user' \ + "--user-annotation=[set the app's annotations]:annotation key=value" \ + "--user-label=[set the app's labels]:label key=value" \ + '--volume=[volumes to make available in the pod]:volume' \ + '--working-dir=[override the working directory of the preceding image]:working directory:_files -/' \ + '1:IMAGE:_rkt_images' \ + ;; + + rm) + _arguments \ + '--uuid-file=[read pod UUID from file instead of argument]:uuid file:_files' \ + '1:POD:_rkt_pods' \ + ;; + + run) + _arguments \ + '--caps-remove=[capability to remove]:capability' \ + '--caps-retain=[capability to retain]:capability' \ + '--cpu=[cpu limit for the preceding image]:cpu limit' \ + '--cpu-shares=[assign the specified CPU time share weight]:weight' \ + '--dns=[name servers to write in /etc/resolv.conf]:name servers' \ + '--dns-domain=[DNS domain to write in]:domain' \ + '--dns-opt=[DNS options to write in /etc/resolv.conf]:dns options' \ + '--dns-search=[DNS search domains to write in /etc/resolv.conf]:search domains' \ + "--environment=[set the app's environment variables]:variable key=value" \ + '--exec=[override the exec command for the preceding image]:command' \ + '--group=[group override for the preceding image]:group' \ + "--hostname=[pod's hostname]:hostname" \ + "--hosts-entry=[entries to add to the pod-wide /etc/hosts. Pass 'host' to use the host's /etc/hosts]:hosts entry" \ + '--inherit-env[inherit all environment variables not set by apps]' \ + '--interactive[run pod interactively]' \ + '--mds-register[register pod with metadata service]' \ + '--memory=[memory limit for the preceding image]:memory limit' \ + '--mount=[mount point binding a volume to a path within an app]:mount point' \ + '--name=[set the name of the app]:name' \ + "--net=[configure the pod's networking]:networks" \ + '--no-overlay[disable overlay filesystem]' \ + '--pod-manifest=[the path to the pod manifest]:manifest:_files' \ + '--port=[ports to expose on the host]:NAME\:HOSTPORT' \ + '--private-users[run within user namespaces]' \ + '--set-env=[an environment variable to set for apps]:NAME=VALUE' \ + '--set-env-file=[the path to an environment variables file]:file:_files' \ + '--signature=[local signature file to use in validating the preceding image]:signature:_files' \ + '--stage1-from-dir=[a filename of an image in stage1 images directory to use as stage1]:image' \ + '--stage1-hash=[a hash of an image to use as stage1]:image hash' \ + '--stage1-name=[a name of an image to use as stage1]:image name' \ + '--stage1-path=[a path to an image to use as stage1]:image path:_files' \ + '--stage1-url=[a URL to an image to use as stage1]:image url' \ + '--supplementary-gids=[supplementary group IDs override for the preceding image]:group IDs' \ + '--user=[user override for the preceding image]:user' \ + "--user-annotation=[set the app's annotations]:annotation key=value" \ + "--user-label=[set the app's labels]:label key=value" \ + '--uuid-file-save=[write out pod UUID to specified file]:uuid file:_files' \ + '--volume=[volumes to make available in the pod]:volume' \ + '--working-dir=[override the working directory of the preceding image]:working directory:_files -/' \ + '1:IMAGE:_rkt_images' \ + ;; + + run-prepared) + _arguments \ + '--dns=[name servers to write in /etc/resolv.conf]:name servers' \ + '--dns-domain=[DNS domain to write in]:domain' \ + '--dns-opt=[DNS options to write in /etc/resolv.conf]:dns options' \ + '--dns-search=[DNS search domains to write in /etc/resolv.conf]:search domains' \ + "--hostname=[pod's hostname]:hostname" \ + "--hosts-entry=[entries to add to the pod-wide /etc/hosts. Pass 'host' to use the host's /etc/hosts]:hosts entry" \ + '--interactive[run pod interactively]' \ + '--mds-register[register pod with metadata service]' \ + "--net=[configure the pod's networking]:networks" \ + '1:POD:_rkt_pods' \ + ;; + + status) + _arguments \ + '--format=[choose the output format]:format:(json json-pretty)' \ + '--wait[toggles waiting for the pod to exit]' \ + '--wait-ready[toggles waiting until the pod is ready]' \ + '1:POD:_rkt_pods' \ + ;; + + stop) + _arguments \ + '--force[forced stopping]' \ + '--uuid-file=[read pod UUID from file instead of argument]:uuid file:_files' \ + '1:POD:_rkt_pods' \ + ;; + + trust) + _arguments \ + '--insecure-allow-http[allow HTTP use for key discovery and/or retrieval]' \ + '--prefix=[prefix to limit trust to]:prefix' \ + '--root[add root key from filesystem without a prefix]' \ + '--skip-fingerprint-review[accept key without fingerprint confirmation]' \ + ;; + esac + ;; + esac + + case $state in + rkt_help_args) + case $words[1] in + image) + _arguments \ + '1: :_rkt_image_cmds' + ;; + esac + ;; + + rkt_image_args) + case $words[1] in + cat-manifest) + _arguments \ + '--pretty-print[apply indent to format the output]' \ + '1:IMAGE:_rkt_images' \ + ;; + + export) + _arguments \ + '--overwrite[overwrite output ACI]' \ + '1:IMAGE:_rkt_images' \ + '2:OUTPUT_ACI_FILE:_files' \ + ;; + + extract|render) + _arguments \ + '--overwrite[overwrite output ACI]' \ + '--rootfs-only[extract rootfs only]' \ + '1:IMAGE:_rkt_images' \ + '2:OUTPUT_DIR:_files -/' \ + ;; + + gc) + _arguments \ + '--grace-period=[duration to wait before discarding inactive pods from garbage]:duration' \ + ;; + + list) + _arguments \ + '--fields=[comma-separated list of fields to display]:fields:{_values -s , id name importtime lastused size latest}' \ + '--full[use long output format]' \ + '--no-legend[suppress a legend with the list]' \ + ;; + + rm) + _arguments \ + '*:IMAGE:_rkt_images' \ + ;; + esac + ;; + esac +} + +_rkt_cmds() { + local -a commands + commands=( + 'api-service:Run API service' + 'cat-manifest:Inspect and print the pod manifest' + 'config:Print configuration for each stage in JSON format' + 'enter:Enter the namespaces of an app within a rkt pod' + 'export:Export an app from an exited pod to an ACI file' + 'fetch:Fetch image(s) and store them in the local store' + 'gc:Garbage collect rkt pods no longer in use' + 'image:Operate on image(s) in the local store' + 'list:List pods' + 'metadata-service:Run metadata service' + 'prepare:Prepare to run image(s) in a pod in rkt' + 'rm:Remove all files and resources associated with an exited pod' + 'run:Run image(s) in a pod in rkt' + 'run-prepared:Run a prepared application pod in rkt' + 'status:Check the status of a rkt pod' + 'stop:Stop a pod' + 'trust:Trust a key for image verification' + 'version:Print the version and exit' + 'help:Help about any command' + ) + _describe 'command' commands +} + +_rkt_image_cmds() { + local -a commands + commands=( + 'cat-manifest:Inspect and print the image manifest' + 'export:Export a stored image to an ACI file' + 'extract:Extract a stored image to a directory' + 'gc:Garbage collect local store' + 'list:List images in the local store' + 'render:Render a stored image to a directory with all its dependencies' + 'rm:Remove image(s) with the given ID(s) or name(s) from the local store' + ) + _describe 'command' commands +} + +_rkt_images() { + local -a images + images=($(rkt image list --fields id,name --no-legend | sed 's/\t/\n/;s/:/\\:/g' | sort | uniq)) + _describe 'IMAGE' images +} + +_rkt_pods() { + local -a pods + IFS=$'\n' + pods=($(rkt list --full --no-legend | sed 's/:/\\:/g;s/\t/:/;s/\t/ /g')) + _describe 'POD' pods +} + +_rkt "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rmlint b/home/.zsh-server/plugins/zsh-completions/src/_rmlint new file mode 100644 index 0000000..92af0c6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rmlint @@ -0,0 +1,422 @@ +#compdef rmlint rmlint.sh -P rmlint.*.sh + +# Copyright (c) 2021 Github zsh-users - http://github.com/zsh-users +# +# Permission is hereby granted, without written agreement and without +# licence or royalty fees, to use, copy, modify, and distribute this +# software and to distribute modified versions of this software for any +# purpose, provided that the above copyright notice and the following +# two paragraphs appear in all copies of this software. +# +# In no event shall the Zsh Development Group be liable to any party for +# direct, indirect, special, incidental, or consequential damages arising out +# of the use of this software and its documentation, even if the Zsh +# Development Group have been advised of the possibility of such damage. +# +# The Zsh Development Group specifically disclaim any warranties, including, +# but not limited to, the implied warranties of merchantability and fitness +# for a particular purpose. The software provided hereunder is on an "as is" +# basis, and the Zsh Development Group have no obligation to provide +# maintenance, support, updates, enhancements, or modifications. +# +# Description +# ----------- +# +# Zsh completion for rmlint 2.10.1 (https://github.com/sahib/rmlint) +# +# Authors +# ------- +# +# * oxiedi (https://github.com/oxiedi) + +(( $+functions[_rmlint_types] )) || +_rmlint_types() { + compset -P '*[+-]' + # FIXME: all values before `-` are swallowed by `*`, which breaks deduplication of the swallowed values + # TODO: respect `prefix-needed` + _values -s ',' 'list [defaults]' \ + 'all[enables all lint types]' \ + 'defaults[enables all lint types, but nonstripped]' \ + 'minimal[defaults minus emptyfiles and emptydirs]' \ + 'minimaldirs[defaults minus emptyfiles, emptydirs and duplicates, but with duplicatedirs]' \ + 'none[disable all lint types]' \ + '(badids bi)'{badids,bi}'[find files with bad UID, GID or both]' \ + '(badlinks bl)'{badlinks,bl}'[find bad symlinks pointing nowhere valid]' \ + '(emptydirs ed)'{emptydirs,ed}'[find empty directories]' \ + '(emptyfiles ef)'{emptyfiles,ef}'[find empty files]' \ + '(nonstripped ns)'{nonstripped,ns}'[find nonstripped binaries]' \ + '(duplicates df)'{duplicates,df}'[find duplicate files]' \ + '(duplicatedirs dd)'{duplicatedirs,dd}'[find duplicate directories (This is the same -D!)]' +} + +(( $+functions[__rmlint_setup_formatter_descriptions] )) || +__rmlint_setup_formatter_descriptions() { + typeset -gA formatter_descriptions=( + csv 'output all found lint as comma-separated-value list' + sh 'output all found lint as shell script' + json 'print a JSON-formatted dump of all found reports' + py 'outputs a python script and a JSON document, just like the json formatter' + uniques 'outputs all unique paths found during the run, one path per line' + stamp 'outputs a timestamp of the time rmlint was run' + progressbar 'shows a progressbar' + pretty 'shows all found items in realtime nicely colored' + summary 'shows counts of files and their respective size after the run. Also list all written output files' + fdupes 'prints an output similar to the popular duplicate finder fdupes(1)' + ) +} + +(( $+functions[_rmlint_output] )) || +_rmlint_output() { + local -A formatter_descriptions + __rmlint_setup_formatter_descriptions + if compset -P "(${(kj:|:)formatter_descriptions}):"; then + _alternative \ + 'files:file:_files' \ + 'outputs:output:(stdout stderr)' + else + local -a outputs + local f d + for f d in ${(kv)formatter_descriptions}; do + outputs+=( "$f:$d" ) + done + _describe -t outputs 'output' outputs -S ':' -q + fi +} + +(( $+functions[_rmlint_config] )) || +_rmlint_config() { + local -A formatter_descriptions + __rmlint_setup_formatter_descriptions + unset 'formatter_descriptions['{py,pretty,summary}']' + local -a match mbegin mend + if compset -P "(#b)(${(kj:|:)formatter_descriptions}):"; then + case $match[1] in + (csv) + _values 'option' \ + 'no_header[do not write a first line describing the column headers]' \ + 'unique[include unique files in the output]' + ;; + (sh) + local context state state_descr line + _values 'option' \ + 'cmd[specify a user defined command to run on duplicates]: :_cmdstring' \ + 'handler[define a comma separated list of handlers to try on duplicate files in that given order until one handler succeeds]:handler:->handler' \ + 'link[shortcut for -c sh:handler=clone,reflink,hardlink,symlink]' \ + 'hardlink[shortcut for -c sh:handler=hardlink,symlink]' \ + 'symlink[shortcut for -c sh:handler=symlink]' + case $state in + (handler) + _values -s ',' $state_descr \ + 'clone[try to clone both files with the FIDEDUPERANGE ioctl(3p) (or BTRFS_IOC_FILE_EXTENT_SAME on older kernels)]' \ + 'reflink[try to reflink the duplicate file to the original]' \ + 'hardlink[replace the duplicate file with a hardlink to the original file]' \ + 'symlink[tries to replace the duplicate file with a symbolic link to the original]' \ + 'remove[remove the file using rm -rf]' \ + 'usercmd[use the provided user defined command (-c sh:cmd=something)]' + ;; + esac + ;; + (json) + _values 'option' \ + 'unique[include unique files in the output]' \ + 'no_header[print the header with metadata]:boolean [true]:(false true)' \ + 'no_footer[print the footer with statistics]:boolean [true]:(false true)' \ + 'oneline[print one json document per line]:boolean [false]:(true false)' + ;; + (uniques) + _values 'option' \ + 'print0[do not put newlines between paths but zero bytes]' + ;; + (stamp) + _values 'option' \ + 'iso8601[write an ISO8601 formatted timestamps or seconds since epoch]:boolean:(true false)' + ;; + (progressbar) + _values 'option' \ + 'update_interval[number of milliseconds to wait between updates (default: 50)]: :_guard "[0-9]#" "update interval (milliseconds) [50]"' \ + 'ascii[do not attempt to use unicode characters, which might not be supported by some terminals]' \ + 'fancy[use a more fancy style for the progressbar]' + ;; + (fdupes) + _values 'option' \ + 'omitfirst[omits the first line of each set of duplicates]' \ + 'sameline[does not print newlines between files, only a space]' + ;; + esac + else + local -a formatters + local f d + for f d in ${(kv)formatter_descriptions}; do + formatters+=( "$f:$d" ) + done + _describe -t formatters 'formatter' formatters -S ':' + fi +} + +(( $+functions[_rmlint_algorithm] )) || +_rmlint_algorithm() { + local -a tmp=( sha{1,256,512} sha3-{256,384,512} blake{2s,2b,2sp,2bp} highway{64,128,256} ) + _alternative \ + '512bit-algorithms:512-bit:(blake2b blake2bp sha3-512 sha512)' \ + '384bit-algorithms:384-bit:(sha3-384)' \ + '256bit-algorithms:256-bit:(blake2s blake2sp sha3-256 sha256 highway256 metro256 metrocrc256)' \ + '160bit-algorithms:160-bit:(sha1)' \ + '128bit-algorithms:128-bit:(md5 murmur metro metrocrc)' \ + '64bit-algorithms:64-bit:(highway64 xxhash)' \ + "cryptographic-algorithms:cryptographic:($tmp)" \ + 'non-cryptographic-algorithms:non-cryptographic:(metro metro256 xxhash murmur)' \ + 'not-useful-algorithms:not-useful:(cumulative paranoid ext)' +} + +(( $+functions[_rmlint_sort] )) || +_rmlint_sort() { + local -A letter_descriptions=( + s 'sort by size of group' + a 'sort alphabetically by the basename of the original' + m 'sort by mtime of the original' + p 'sort by path-index of the original' + o 'sort by natural found order (might be different on each run)' + n 'sort by number of files in the group' + ) + local -a letters + local l d + for l d in ${(kv)letter_descriptions}; do + letters+=( "${l}[$d]" "${(U)l}[$d (in reverse order)]" ) + done + _values -s '' 'order' $letters +} + +(( $+functions[__rmlint_describe_multipliers] )) || +__rmlint_describe_multipliers() { + local -a multipliers=( + 'C:1^1' + 'W:2^1' + 'B:512^1' + 'K:1000^1' + 'KB:1024^1' + 'M:1000^2' + 'MB:1024^2' + 'G:1000^3' + 'GB:1024^3' + 'T:1000^4' + 'TB:1024^4' + 'P:1000^5' + 'PB:1024^5' + 'E:1000^6' + 'EB:1024^6' + ) + _describe -t multiplier 'multiplier' multipliers "$@" +} + +(( $+functions[__rmlint_multipliers] )) || +__rmlint_multipliers() { + compset -P '[0-9]##' || return + __rmlint_describe_multipliers "$@" +} + +(( $+functions[_rmlint_size] )) || +_rmlint_size() { + ! __rmlint_multipliers && [[ -z $PREFIX ]] && _message -e "${1:-size}" +} + +(( $+functions[_rmlint_size_range] )) || +_rmlint_size_range() { + if compset -P '[0-9]##'; then + if compset -P '(C|W|B|K|KB|M|MB|G|GB|T|TB|P|PB|E|EB)-'; then + _rmlint_size 'max' + else + __rmlint_describe_multipliers -S '-' -q + fi + elif [[ -z $PREFIX ]]; then + _message -e 'min' + fi +} + +(( $+functions[_rmlint_iso8601_or_unix_timestamp] )) || +_rmlint_iso8601_or_unix_timestamp() { + _alternative \ + 'dates:iso8601_timestamp: _dates -f "%FT%T"' \ + 'seconds:unix_timestamp:_guard "[0-9]#" "seconds since epoch"' +} + +(( $+functions[_rmlint_rank] )) || +_rmlint_rank() { + # TODO: {r,R,x,X} + _values -s '' 'criteria [pOma]' \ + 'm[keep lowest mtime (oldest)]' 'M[keep highest mtime (newest)]' \ + 'a[keep first alphabetically]' 'A[keep last alphabetically]' \ + 'p[keep first named path]' 'P[keep last named path]' \ + 'd[keep path with lowest depth]' 'D[keep path with highest depth]' \ + 'l[keep path with shortest basename]' 'L[keep path with longest basename]' \ + 'r[keep paths matching regex]' 'R[keep path not matching regex]' \ + 'x[keep basenames matching regex]' 'X[keep basenames not matching regex]' \ + 'h[keep file with lowest hardlink count]' 'H[keep file with highest hardlink count]' \ + 'o[keep file with lowest number of hardlinks outside of the paths traversed by rmlint]' \ + 'O[keep file with highest number of hardlinks outside of the paths traversed by rmlint]' +} + +(( $+functions[_rmlint_percent] )) || +_rmlint_percent() { + if compset -P '(100|[1-9][0-9]|[1-9])'; then + compadd "$@" -- '%' + elif [[ -z $PREFIX ]]; then + _message -e 'percent%%' + fi +} + +(( $+functions[_rmlint_clamp] )) || +_rmlint_clamp() { + _alternative \ + "factor: :_guard '((|0)(|.[0-9]#)|1(|.0#))' 'fac.tor [$1]'" \ + 'percent:percent%%:_rmlint_percent' \ + 'multiplier:offset: _rmlint_size "offset"' +} + +(( $+functions[_rmlint_files_or_separator] )) || +_rmlint_files_or_separator() { + if (( $words[(i)-] < CURRENT )); then + [[ -z $words[CURRENT] ]] && compadd "$@" -S '' -- - + return + fi + local -a alts=( 'files:file:_files' ) + (( $line[(I)//] || $+opt_args[--equal] )) || alts+=( 'separator:separator:(//)' ) + _alternative $alts +} + +_rmlint() { + if [[ $service = *.sh ]]; then + _arguments -s : \ + '(-)-h[show help message]' \ + '-d[do not ask before running]' \ + '-x[keep rmlint.sh; do not autodelete it]' \ + '-p[recheck that files are still identical before removing duplicates]' \ + '-r[allow deduplication of files on read-only btrfs snapshots (requires sudo)]' \ + '(-d -x)-n[do not perform any modifications, just print what would be done (implies -d and -x)]' \ + '-c[clean up empty directories while deleting duplicates]' \ + '-q[do not show progress]' \ + '-k[keep the timestamp of directories when removing duplicates]' \ + '-i[ask before deleting each file]' + return + fi + + local curcontext="$curcontext" state state_descr + local -a line + local -i ret=1 + typeset -A opt_args + + _arguments -s -w -C : \ + '(-T --types)'{-T,--types}'=[configure the types of lint rmlint will look for]: :_rmlint_types' \ + '*'{-o,--output}'=[configure the way rmlint outputs its results]:spec:_rmlint_output' \ + '*'{-O,--add-output}'=[configure the way rmlint outputs its results (preserve defaults)]:spec:_rmlint_output' \ + '*'{-c,--config}'=[configure a format]:spec:_rmlint_config' \ + '(-z --perms)'{-z,--perms}'=[only look into file if it is readable, writable or executable by the current user]: :_values -s "" perms r w x' \ + '(-a --algorithm)'{-a,--algorithm}'=[choose the algorithm to use for finding duplicate files]:algo:_rmlint_algorithm' \ + '*'{-p,--paranoid}'[increase the paranoia of rmlint'\''s duplicate algorithm]' \ + '*'{-P,--less-paranoid}'[decrease the paranoia of rmlint'\''s duplicate algorithm]' \ + '*'{-v,--loud}'[increase the verbosity]' \ + '*'{-V,--quiet}'[decrease the verbosity]' \ + '(-g --progress)'{-g,--progress}'[show a progressbar with sane defaults]' \ + '(-G --no-progress)'{-G,--no-progress}'[do not show a progressbar with sane defaults (default)]' \ + '(-D --merge-directories)'{-D,--merge-directories}'[makes rmlint use a special mode where all found duplicates are collected and checked if whole directory trees are duplicates]' \ + '(-j --honour-dir-layout)'{-j,--honour-dir-layout}'[only recognize directories as duplicates that have the same path layout]' \ + '(-y --sort-by)'{-y,--sort-by}'=[during output, sort the found duplicate groups by criteria described by order]:order:_rmlint_sort' \ + '(-w --with-color)'{-w,--with-color}'[use color escapes for pretty output (default)]' \ + '(-W --no-with-color)'{-W,--no-with-color}'[disable color escapes for pretty output]' \ + '(- *)'{-h,--help}'[show a shorter reference help text]' \ + '(- *)--help-all[show all help options]' \ + '(- *)'{-H,--show-man}'[show the full man page]' \ + '(- *)--version[print the version of rmlint]' \ + '(-s --size)'{-s,--size}'=[only consider files as duplicates in a certain size range]:range:_rmlint_size_range' \ + '(-d --max-depth)'{-d,--max-depth}'=[only recurse up to this depth]: :_guard "[0-9]#" "depth"' \ + '(-l --hardlinked)'{-l,--hardlinked}'[hardlinked files are treated as duplicates (default)]' \ + '--keep-hardlinked[rmlint will not delete any files that are hardlinked to an original in their respective group]' \ + '(-L --no-hardlinked)'{-L,--no-hardlinked}'[only one file (of a set of hardlinked files) is considered, all the others are ignored]' \ + '(-f --followlinks)'{-f,--followlinks}'[follow symbolic links]' \ + '(-F --no-followlinks)'{-F,--no-followlinks}'[ignore symbolic links completely]' \ + '(-@ --see-symlinks)'{-@,--see-symlinks}'[see symlinks and treats them like small files with the path to their target in them (default)]' \ + '(-x --no-crossdev)'{-x,--no-crossdev}'[stay always on the same device]' \ + '(-X --crossdev)'{-X,--crossdev}'[allow crossing mountpoints (default)]' \ + '(-r --hidden)'{-r,--hidden}'[traverse hidden directories]' \ + '(-R --no-hidden)'{-R,--no-hidden}'[don'\''t traverse hidden directories (default)]' \ + '--partial-hidden[traverse duplicate hidden directories]' \ + '(-b --match-basename)'{-b,--match-basename}'[only consider those files as dupes that have the same basename]' \ + '(-B --unmatched-basename)'{-B,--unmatched-basename}'[only consider those files as dupes that do not share the same basename]' \ + '(-e --match-with-extension)'{-e,--match-with-extension}'[only consider those files as dupes that have the same file extension]' \ + '(-E --no-match-with-extension)'{-E,--no-match-with-extension}'[don'\'t' consider those files as dupes that have the same file extension (default)]' \ + '(-i --match-without-extension)'{-i,--match-without-extension}'[only consider those files as dupes that have the same basename minus the file extension]' \ + '(-I --no-match-without-extension)'{-I,--no-match-without-extension}'[don'\'t' consider those files as dupes that have the same basename minus the file extension (default)]' \ + '(-n --newer-than-stamp)'{-n,--newer-than-stamp}'=[only consider files (and their size siblings for duplicates) newer than a certain modification time (mtime)]:timestamp_filename:_files' \ + '(-N --newer-than)'{-N,--newer-than}'=[don'\'t' consider files (and their size siblings for duplicates) newer than a certain modification time (mtime)]: :_rmlint_iso8601_or_unix_timestamp' \ + '(-k --keep-all-tagged)'{-k,--keep-all-tagged}'[don'\''t delete any duplicates that are in tagged paths]' \ + '(-K --keep-all-untagged)'{-K,--keep-all-untagged}'[don'\''t delete any duplicates that are in non-tagged paths]' \ + '(-m --must-match-tagged)'{-m,--must-match-tagged}'[only look for duplicates of which at least one is in one of the tagged paths]' \ + '(-M --must-match-untagged)'{-M,--must-match-untagged}'[only look for duplicates of which at least one is in one of the non-tagged paths]' \ + '(-S --rank-by)'{-S,--rank-by}'=[sort the files in a group of duplicates into originals and duplicates by one or more criteria]: :_rmlint_rank' \ + '--replay[read an existing json file and re-output it]' \ + '(-C --xattr)'{-C,--xattr}'[shortcut for --xattr-read, --xattr-write, --write-unfinished]' \ + '--xattr-read[read cached checksums from the extended file attributes]' \ + '--xattr-write[write cached checksums from the extended file attributes]' \ + '--xattr-clear[clear cached checksums from the extended file attributes]' \ + '(-U --write-unfinished)'{-U,--write-unfinished}'[include files in output that have not been hashed fully, i.e. files that do not appear to have a duplicate]' \ + '(-t --threads)'{-t,--threads}'=[the number of threads to use during file tree traversal and hashing (default: 16)]: :_guard "[0-9]#" "threads [16]"' \ + '(-u --limit-mem)'{-u,--limit-mem}'=[apply a maximum number of memory to use for hashing and --paranoid]:size: _rmlint_size' \ + '(-q --clamp-low)'{-q,--clamp-low}'=[only look at the content of files in the range of from low to (including) high (default: 0)]: : _rmlint_clamp 0' \ + '(-Q --clamp-top)'{-Q,--clamp-top}'=[only look at the content of files in the range of from low to (including) high (default: 1.0)]: : _rmlint_clamp 1.0' \ + '(-Z --mtime-window)'{-Z,--mtime-window}'=[only consider those files as duplicates that have the same content and the same modification time (mtime) within a certain window of T seconds (default: -1)]: :_guard "[0-9]#" "mtime window (seconds) [-1]"' \ + '--with-fiemap[enable reading the file extents on rotational disk in order to optimize disk access patterns (default)]' \ + '--without-fiemap[disable reading the file extents on rotational disk in order to optimize disk access patterns]' \ + '--gui[start the optional graphical frontend to rmlint called Shredder]:*: :->gui' \ + '--hash[make rmlint work as a multi-threaded file hash utility]:*: :->hash' \ + '--equal[check if the paths given on the commandline all have equal content]: :_rmlint_files_or_separator' \ + '(-0 --stdin0)'{-0,--stdin0}'[read null-separated file list from stdin]' \ + '--backup[do create backups of previous result files]' \ + '--no-backup[do not create backups of previous result files]' \ + '--dedupe[dedupe matching extents from source to dest (if filesystem supports)]:*:: := ->dedupe' \ + '--dedupe-xattr[check extended attributes to see if the file is already deduplicated]' \ + '--dedupe-readonly[(--dedupe option) even dedupe read-only snapshots (needs root)]' \ + '--is-reflink[test if two files are reflinks (share same data extents)]:*:: := ->reflink' \ + '*: :_rmlint_files_or_separator' && return + + case $state in + (gui) + _arguments -s -w : \ + '(- *)'{-h,--help}'[show help options]' \ + {-a,--add-location}'[add locations to locations view]' \ + {-s,--scan}'[add location to scan (as untagged path)]' \ + {-S,--scan-tagged}'[add location to scan (as tagged path)]' \ + {-l,--load-script}'[show `script` in editor view]' \ + '*'{-v,--verbose}'[be more verbose]' \ + '*'{-V,--less-verbose}'[be less verbose]' \ + {-c,--show-settings}'[show the settings view]' \ + '(- *)--version[show the version of Shredder]' && ret=0 + ;; + (hash) + _arguments -s -w : \ + '(- *)'{-h,--help}'[show help options]' \ + {-a,--algorithm}'[digest type \[bLAKE2B\]]:type:_rmlint_algorithm' \ + {-t,--num-threads}'[number of hashing threads \[8\]]: :_guard "[0-9]#" "threads [8]"' \ + {-b,--buffer-mbytes}'[megabytes read buffer \[256 MB\]]: :_guard "[0-9]#" "buffer (MB) [256]"' \ + {-i,--ignore-order}'[print hashes in order completed, not in order entered (reduces memory usage)]' \ + '*:file:_files' && ret=0 + ;; + (dedupe) + _arguments -s -w : \ + '-r[enable deduplication of read-only \[btrfs\] snapshots (requires root)]' \ + '(-V)*-v' \ + '(-v)*-V' \ + ':src:_files' \ + ':dst:_files' && ret=0 + ;; + (reflink) + _arguments -s -w : \ + '(-V)*-v' \ + '(-v)*-V' \ + ':file1:_files' \ + ':file2:_files' && ret=0 + ;; + esac + + return ret +} + +_rmlint "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rslsync b/home/.zsh-server/plugins/zsh-completions/src/_rslsync new file mode 100644 index 0000000..49517bc --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rslsync @@ -0,0 +1,72 @@ +#compdef rslsync +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for resilio sync 2.7.3 (https://www.resilio.com/individuals/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Fabian Klötzl (https://github.com/kloetzl) +# +# ------------------------------------------------------------------------------ + +_rslsync(){ + integer ret=1 + local -a args + args+=( + '(- *)--help[Print help]' + '--config[Use a configuration file]:file:_files' + '--storage[Storage path for identity and license]:path:_files -/' + '--identity[Creates user identity]:name:' + '--license[Apply owner license]:file:_files' + '--decrypt[Decrypt encrypted folder]:' + '--upgradedb[Upgrade databases in specified storage or upgrade a single db]:db:_files' + '--nodaemon[Do not daemonize]' + '--dump-sample-config[Print a sample configuration file]' + '--log[Set log file]:file:_files' + '(--help)--webui.listen[Set the webui listening interface]:ip\:port:' + '--generate-secret[Generate a read/write key]::version:(2)' + '--get-ro-secret[Get the read-only key associated to a read/write key]:key:' + '--server[Set Management Console address]:ip\:port:' + ) + _arguments $args[@] && ret=0 + return ret +} + +_rslsync + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rspec b/home/.zsh-server/plugins/zsh-completions/src/_rspec new file mode 100644 index 0000000..0ca0e99 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rspec @@ -0,0 +1,108 @@ +#compdef rspec +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for RSpec (http://rspec.info/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Kazuya Takeshima (https://github.com/mitukiii) +# +# ------------------------------------------------------------------------------ + + +_rspec() { + local context state line curcontext="$curcontext" + + _arguments -C \ + -I'[Specify PATH to add to $LOAD_PATH (may be used more than once)]:PATH:_files' \ + '*'{-r,--require}'[Require a file]:PATH:_files' \ + '*'{-O,--options}'[Specify the path to a custom options file]:PATH:_files' \ + --order'[Run examples by the specified order type]: :->order' \ + --seed'[Equivalent of --order rand:SEED]: :_guard "[[\:digit\:]]#" "SEED"' \ + --bisect'[Repeatedly runs the suite in order to isolate the failures to the smallest reproducible case]' \ + --only-failures'[Filter to just the examples that failed the last time they ran]' \ + '(-n --next-failure)'{-n,--next-failure}'[Apply `--only-failures` and abort after one failure (equivalent to `--only-failures --fail-fast --order defined`)]' \ + --fail-fast'[Abort the run on first failure]' \ + --no-fail-fast'[Do not abort the run on first failure]' \ + --failure-exit-code'[Override the exit code used when there are failing specs]: :_guard "[[\:digit\:]]#" "CODE"' \ + --dry-run'[Print the formatter output of your suite without running any examples or hooks]' \ + '(-X --drb)'{-X,--drb}'[Run examples via DRb]' \ + --drb-port'[Port to connect to the DRb server]: :_guard "[[\:digit\:]]#" "PORT"' \ + '(-f --format)'{-f,--format}'[Choose a formatter]:FORMATTER:(progress documentation html json failures)' \ + '(-o --out)'{-o,--out}'[Write output to a file instead of $stdout]:FILE:_files' \ + --deprecation-out'[Write deprecation warnings to a file instead of $stderr]:FILE:_files' \ + '(-b --backtrace)'{-b,--backtrace}'[Enable full backtrace]' \ + --force-color'[Force the output to be in color, even if the output is not a TTY]' \ + --no-color'[Force the output to not be in color, even if the output is a TTY]' \ + '(-p --profile)'{-p,--profile}'[Enable profiling of examples and list the slowest examples (default: 10)]: :_guard "[[\:digit\:]]#" "COUNT"' \ + --no-profile'[Disable profiling of examples]' \ + '(-w --warnings)'{-w,--warnings}'[Enable ruby warnings]' \ + '(-P --pattern)'{-P,--pattern}'[Load files matching pattern (default: "spec/**/*_spec.rb")]:PATTERN:' \ + --exclude-pattern'[Load files except those matching pattern]:PATTERN:' \ + '(-e --example)'{-e,--example}'[Run examples whose full nested names include STRING (may be used more than once)]:STRING:' \ + '(-t --tag)'{-t,--tag}'[Run examples with the specified tag, or exclude examples by adding ~ before the tag]: :->tag' \ + --default-path'[Set the default path where RSpec looks for examples (can be a path to a file or a directory)]:PATH:_files' \ + '(- *)'--init'[Initialize your project with RSpec]' \ + '(- *)'{-h,--help}"[You're looking at it]" \ + '(- *)'{-v,--version}'[Display the version]' \ + '*:files or directories:_files' + + case "$state" in + order) + if compset -P '*:'; then + _guard '[[:digit:]]#' 'SEED' + else + _values 'TYPE[:SEED]' \ + defined'[examples and groups are run in the order they are defined]' \ + rand'[randomize the order of groups and examples]' \ + random'[alias for rand]' + fi + ;; + tag) + if compset -P '*:'; then + _message 'VALUE' + else + _message 'TAG[:VALUE]' + fi + ;; + esac +} + +_rspec "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rsvm b/home/.zsh-server/plugins/zsh-completions/src/_rsvm new file mode 100644 index 0000000..d6de50c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rsvm @@ -0,0 +1,88 @@ +#compdef rsvm +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rsvm (https://github.com/sdepold/rsvm). +# Adapted from Docker Machine completion by hhatto (https://github.com/ilkka) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * michaelmior (https://github.com/michaelmior) +# +# ------------------------------------------------------------------------------ + +# helper function for completing available rusts +__rusts() { + declare -a rusts_cmd + rusts_cmd=($(ls "$HOME/.rsvm/versions")) + _describe 'rusts' rusts_cmd +} + +# subcommands +local -a _rsvm_cmds + +_rsvm_cmds=( + 'help:Show a help message' \ + 'install:Download and install a version' \ + 'uninstall:Uninstall a version' \ + 'use:Activate a version for now and the future' \ + 'ls:List all installed versions of rust' \ + 'ls-remote:List remote versions available for install' \ + 'ls-channel:Print a channel version available for install' \ +) + +# subcommand completion functions +__uninstall() { + __rusts +} + +__use() { + __rusts +} + +# common args +_arguments \ + '--help[show help]' \ + '--version[print the version]' \ + '*:: :->command' + +# start rusts! +if (( CURRENT == 1 )); then + _describe -t commands 'rsvm command' _rsvm_cmds +fi + +local -a _command_args +case "$words[1]" in + uninstall) + __uninstall ;; + use) + __use ;; +esac diff --git a/home/.zsh-server/plugins/zsh-completions/src/_rubocop b/home/.zsh-server/plugins/zsh-completions/src/_rubocop new file mode 100644 index 0000000..af3277b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_rubocop @@ -0,0 +1,120 @@ +#compdef rubocop +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rubocop 1.38 (https://github.com/rubocop/rubocop) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Akira Maeda +# * Shohei Yoshida +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_rubocop_format_params() { + local -a formatter=( + "autogenconf" "clang" "emacs" "files" "fuubar" "github" "html" "json" "junit" + "markdown" "offenses" "pacman" "progress" "quiet" "simple" "tap" "worst" + ) + + _values 'formatter' $formatter +} + +_arguments -C \ + '(-l --lint)'{-l,--lint}'[Run only lint cops]' \ + '(-x --fix-layout)'{-x,--fix-layout}'[Run only layout cops, with autocorrect on]' \ + '--safe[Run only safe cops]' \ + '*--except[Exclude the given cops]:cops' \ + '*--only[Run only the given cops]:cops' \ + '--only-guide-cops[Run only cops for rules that link to a style guide]' \ + '(-F --fail-fast)'{-f,--fail-fast}'[Inspect files in order of modification time and stop after the first file containing offenses]' \ + '--disable-pending-cops[Run without pending cops]' \ + '--enable-pending-cops[Run with pending cops]' \ + '--ignore-disable-comments[Run cops even when they are disabled locally by a `rubocop:disable` directive]' \ + '--force-exclusion[Any files excluded by `Exclude` in configuration files will be excluded, even if given explicitly as arguments]' \ + '(-s --stdin)'{-s,--stdin}'[Pipe source from STDIN, using FILE in offense reports]: :_files' \ + '(-P --parallel --no-parallel)'{-p,--parallel}'[Use available CPUs to execute inspection in parallel]' \ + '(-P --parallel --no-parallel)--no-parallel[Execute not parallel]' \ + '--raise-cop-error[Raise cop-related errors with cause and location]' \ + '--fail-level[Minimum severity for exit with error code]:severity:(autocorrect info refactor convention warning error fatal)' \ + '(-C --cache)'{-C,--cache}'[Use result caching or not]: :(TRUE FALSE)' \ + '--cache-root[Set the cache root directory]: :_files -/' \ + '--server[If a server process has not been started yet start the server process and execute inspection with server]' \ + '--restart-server[Restart server process]' \ + '--start-server[Start server process]' \ + '--stop-server[Stop server process]' \ + '--server-status[Show server status]' \ + '(-f --format)'{-f,--format}'[Choose an output formatter]:FORMATTER:_rubocop_format_params' \ + '(-D --display-cop-names)'{-D,--display-cop-names}'[Display cop names in offense messages]' \ + '(-E --extra-details)'{-E,--extra-details}'[Display extra details in offense messages]' \ + '(-S --display-style-guide)'{-S,--display-style-guide}'[Display style guide URLs in offense messages]' \ + '(-o --out)'{-o,--out}'[Write output to a file instead of STDOUT]: :_files' \ + '--stderr[Write all output to stderr except for the autocorrected source]' \ + '--display-time[Display elapsed time in seconds]' \ + '--display-only-failed[Only output offense messages]' \ + '--display-only-fail-level-offenses[Only output offense messages at the specified --fail-level or above]' \ + '--display-only-correctable[Only output correctable offense messages]' \ + '--display-only-safe-correctable[Only output safe-correctable offense messages with combined with --display-only-correctable]' \ + '(-a --autocorrect)'{-a,--autocorrect}"[Auto-correct offenses(only when it's safe)]" \ + '(-A --autocorrect-all)'{-A,--autocorrect-all}'[Autocorrect offenses(safe and unsafe)]' \ + '--auto-gen-config[Generate a configuration file acting as a TODO list]' \ + '--regenerate-todo[Regenerate the TODO configuration file using the last configuration]' \ + '(--no-exclude-limit)--exclude-limit[Set the limit for how many files to explicitly exclude]:count' \ + '(--exclude-limit)--no-exclude-limit[Do not set the limit for how many files to exclude]' \ + '--offense-counts[Include offense counts in configuration file generated by --auto-gen-config]' \ + '--auto-gen-only-exclude[Generate only Exclude parameters and not Max when running --auto-gen-config]' \ + '--auto-gen-timestamp[Include the data and time when the --auto-gen-config was run in the file it generates]' \ + '(-L --list-target-files)'{-L,--list-target-files}'[List all files RuboCop will inspect]' \ + '*--show-cops[Show the given cops or all cops]::cops' \ + '--show-docs-url[Display url to documentation for the given cops or base url by default]::cops' \ + '--init[Generate a .rubocop.yml file in the current directory]' \ + '(-c --config)'{-c,--config}'[Specify configuration file]: :_files' \ + '(-d --debug)'{-d,--debug}'[Display debug info]' \ + '(-r --require)'{-r,--require}'[Require Ruby file]: :_files' \ + '(--no-color --color)--color[Force color output on]' \ + '(--no-color --color)--no-color[Force color output off]' \ + '(-v --version -V --verbose-version)'{-v,--version}'[Display version]' \ + '(-V --verbose-version -v --version)'{-V,--verbose-version}'[Display verbose version]' \ + '(- *)'{-h,--help}'[Show help]' \ + '*: :_files' && ret=0 + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_sbt b/home/.zsh-server/plugins/zsh-completions/src/_sbt new file mode 100644 index 0000000..f2de6e9 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_sbt @@ -0,0 +1,93 @@ +#compdef sbt +# ------------------------------------------------------------------------------ +# Copyright (c) 2013 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for sbt 0.12+ (http://scala-sbt.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Tony Sloane +# * Mirko Caserta +# +# ------------------------------------------------------------------------------ + +local -a _sbt_commands +_sbt_commands=( + 'clean:delete files produced by the build' + 'compile:compile sources' + 'console:start the Scala REPL with project classes on the classpath' + 'console-quick:start the Scala REPL with project deps on the classpath' + 'console-project:start the Scala REPL w/sbt+build-def on the classpath' + 'dist:generate distribution artifacts' + 'dist\:clean:clean distribution artifacts' + 'doc:generate API documentation' + 'gen-idea:generate Intellij Idea project files' + 'package:produce the main artifact, such as a binary jar' + 'package-doc:produce a doc artifact, such as a jar containing API docs' + 'package-src:produce a source artifact, such as a jar containing sources' + 'publish:publish artifacts to a repository' + 'publish-local:publish artifacts to the local repository' + 'run:run a main class' + 'run-main:run the main class selected by the first argument' + 'test:execute all tests' + 'test-only:execute the tests provided as arguments' + 'test-quick:execute previously failed tests' + 'update:resolve and optionally retrieve dependencies' +) + +local expl + +_arguments \ + '(-help)-h[prints an help message]' \ + '(-h)-help[prints an help message]' \ + '(-verbose)-v[this runner is chattier]' \ + '(-v)-verbose[this runner is chattier]' \ + '(-debug)-d[set sbt log level to debug]' \ + '(-d)-debug[set sbt log level to debug]' \ + '-no-colors[disable ANSI color codes]' \ + '-sbt-create[start even if current dir contains no sbt project]' \ + '-sbt-dir[path to global settings/plugins dir (default: ~/.sbt)]' \ + '-sbt-boot[path to shared boot dir (default: ~/.sbt/boot)]' \ + '-ivy[path to local Ivy repository (default: ~/.ivy2)]' \ + '-mem[set memory options]' \ + '-no-share[use all local caches; no sharing]' \ + '-no-global[use global caches, but do not use global ~/.sbt dir]' \ + '-jvm-debug[turn on JVM debugging, open at the given port]' \ + '-batch[disable interactive mode]' \ + '-sbt-version[use the specified version of sbt]' \ + '-sbt-jar[use the specified jar as the sbt launcher]' \ + '(-sbt-snapshot)-sbt-rc[use an RC version of sbt]' \ + '(-sbt-rc)-sbt-snapshot[use a snapshot version of sbt]' \ + '-java-home[alternate JAVA_HOME]' \ + '*:: :->subcmds' && return 0 + +_describe -t commands "sbt subcommand" _sbt_commands +return 0 diff --git a/home/.zsh-server/plugins/zsh-completions/src/_scala b/home/.zsh-server/plugins/zsh-completions/src/_scala new file mode 100644 index 0000000..8043468 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_scala @@ -0,0 +1,249 @@ +#compdef scala scalac +# ------------------------------------------------------------------------------ +# Copyright (c) 2012 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for scala and scalac (http://www.scala-lang.org/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Tony Sloane +# +# ------------------------------------------------------------------------------ + +typeset -A opt_args +local context state line + +_scala_features () { + compadd "postfixOps" "reflectiveCalls" "implicitConversions" "higherKinds" \ + "existentials" "experimental.macros" "_" +} + +_scala_phases () { + compadd "parser" "namer" "packageobjects" "typer" "patmat" "superaccessors" \ + "extmethods" "pickler" "refchecks" "selectiveanf" "selectivecps" "uncurry" \ + "tailcalls" "specialize" "explicitouter" "erasure" "posterasure" "lazyvals" \ + "lambdalift" "constructors" "flatten" "mixin" "cleanup" "icode" "inliner" \ + "inlineExceptionHandlers" "closelim" "dce" "jvm" "terminal" +} + +local -a shared_opts +shared_opts=( + "-bootclasspath+[Override location of bootstrap class files]:bootstrap class directory:_files -/" + "-classpath+[Specify where to find user class files]:directory:_files -/" + "-D-[Pass -Dproperty=value directly to the runtime system]" + "-d+[Destination for generated classfiles]: directory or jar file:_files" + "-dependencyfile+[Set dependency tracking file]:dependency tracking file:_files" + "-deprecation[Emit warning and location for usages of deprecated APIs]" + "-encoding+[Specify character encoding used by source files]:encoding:" + "-explaintypes[Explain type errors in more detail]" + "-extdirs+[Override location of installed extensions]:extensions directory:_files -/" + "-g\:-[Set level of generated debugging info (default\: vars)]:debugging info level:(none source line vars notailcalls)" + "-help[Print a synopsis of standard options]" + "-J-[pass argument directly to Java runtime system]:JVM argument:" + "-javabootclasspath+[Override java boot classpath]:Java boot class path directory]:_files -/" + "-javaextdirs+[Override java extdirs classpath]:Java extdirs directory:_files -/" + "-language\:-[Enable one or more language features]:feature:_scala_features" + "-no-specialization[Ignore @specialize annotations]" + "-nobootcp[Do not use the boot classpath for the scala jars]" + "-nowarn[Generate no warnings]" + "-optimise[Generate faster bytecode by applying optimisations to the program]" + "-P\:-[Pass an option to a plugin (written plugin\:opt)]:plugin option:" + "-print[Print program with Scala-specific features removed]" + "-sourcepath+[Specify location(s) of source files]:source file directory:_files -/" + "-target\:-[Target platform for object files (default\: jvm-1.5)]:platform name:(jvm-1.5 msil)" + "-toolcp+[Add to the runner classpath]:directory:_files -/" + "-unchecked[Enable detailed unchecked (erasure) warnings]" + "-uniqid[Uniquely tag all identifiers in debugging output]" + "-usejavacp[Utilize the java.class.path in classpath resolution]" + "-verbose[Output messages about what the compiler is doing]" + "-version[Print product version and exit]" + "-X[Print a synopsis of advanced options]" + "-Y[Print a synopsis of private options]" +) + +local -a X_opts +X_opts=( + "-Xcheck-null[Warn upon selection of nullable reference]" + "-Xcheckinit[Wrap field accessors to throw an exception on uninitialized access]" + "-Xdisable-assertions[Generate no assertions or assumptions]" + "-Xelide-below+[Calls to @elidable methods are omitted if method priority is lower than integer argument]" + "-Xexperimental[Enable experimental extensions]" + "-Xfatal-warnings[Fail the compilation if there are any warnings]" + "-Xfull-lubs[Retains pre 2.10 behavior of less aggressive truncation of least upper bounds]" + "-Xfuture[Turn on future language features]" + "-Xgenerate-phase-graph+[Generate the phase graphs (outputs .dot files) to fileX.dot]:output file:_files" + "-Xlint[Enable recommended additional warnings]" + "-Xlog-free-terms[Print a message when reification creates a free term]" + "-Xlog-free-types[Print a message when reification resorts to generating a free type]" + "-Xlog-implicits[Show more detail on why some implicits are not applicable]" + "-Xlog-implicit-conversions[Print a message whenever an implicit conversion is inserted]" + "-Xlog-reflective-calls[Print a message when a reflective method call is generated]" + "-Xmacro-settings\:-[Custom settings for macros]:option" + "-Xmain-class+[Class for manifest's Main-Class entry (only useful with -d jar)]:path:" + "-Xmax-classfile-name+[Maximum filename length for generated classes]" + "-Xmigration[Warn about constructs whose behavior may have changed]" + "-Xno-forwarders[Do not generate static forwarders in mirror classes]" + "-Xno-patmat-analysis[Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation]" + "-Xno-uescape[Disable handling of \u unicode escapes]" + "-Xnojline[Do not use JLine for editing]" + "-Xoldpatmat[Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10]" + "-Xprint\:-[Print out program after ]:phase name:_scala_phases" + "-Xprint-icode\:-[Log internal icode to *.icode files after phase (default\: icode)]:phase name:_scala_phases" + "-Xprint-pos[Print tree positions, as offsets]" + "-Xprint-types[Print tree types (debugging option)]" + "-Xprompt[Display a prompt after each error (debugging option)]" + "-Xresident[Compiler stays resident: read source filenames from standard input]" + "-Xscript+[Treat the source file as a script and wrap it in a main method]:main object name" + "-Xshow-class+[Show internal representation of class]:class name" + "-Xshow-object+[Show internal representation of object]:object name" + "-Xshow-phases[Print a synopsis of compiler phases]" + "-Xsource-reader+[Specify a class name for a custom method of reading source files]:class name" + "-Xverify[Verify generic signatures in generated bytecode]" + + "-Xassem-extdirs+[List of directories containing assemblies (requires -target:msil) (default\: lib)]:assembly directory:_files -/" + "-Xassem-name+[Name of the output assembly (requires -target:msil)]:assembly name:_files" + "-Xassem-path+[List of assemblies referenced by the program (requires -target:msil)]:assembly path:_files" + "-Xsourcedir+[Mirror source folder structure in output directory (requires -target:msil)]:source directory:_files -/" + + "-Xplugin\:-[Load one or more plugins from file]:plugin file:_files" + "-Xpluginsdir+[Path to search compiler plugins]:plugin directory:_files -/" + "-Xplugin-list[Print a synopsis of loaded plugins]" + "-Xplugin-disable\:-[Disable the given plugin(s)]" + "-Xplugin-require\:-[Abort unless the given plugin(s) are available]" +) + +local -a Y_opts +Y_opts=( + "-Y[Print a synopsis of private options]" + "-Ybuild-manager-debug[Generate debug information for the Refined Build Manager compiler]" + "-Ybuilder-debug\:-[Compile using the specified build manager (default\: none)]:build manager:(none refined simple)" + "-Yclosure-elim[Perform closure elimination]" + "-Ycompact-trees[Use compact tree printer when displaying trees]" + "-Ydead-code[Perform dead code elimination]" + "-Ydependent-method-types[Allow dependent method types]" + "-Ydump-classes+[Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders)]:output directory:_files -/" + "-Yeta-expand-keeps-star[Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.]" + "-Ygen-javap+[Generate a parallel output directory of .javap files]:output directory:_files -/" + "-Yinfer-argument-types[Infer types for arguments of overridden methods]" + "-Yinline[Perform inlining when possible]" + "-Yinline-handlers[Perform exception handler inlining when possible]" + "-Yinline-warnings[Emit inlining warnings (normally suppressed due to high volume)]" + "-Yinvalidate+[Invalidate classpath entry before run]:classpath entry" + "-Ylinearizer\:-[Linearizer to use (default\: rpo)]:linearizer:(normal dfs rpo dump)" + "-Ylog-classpath[Output information about what classpath is being applied]" + "-Yno-adapted-args[Do not adapt an argument list (either by inserting unit or creating a tuple) to match the receiver]" + "-Ymacro-debug-lite[Trace essential macro-related activities]" + "-Ymacro-debug-verbose[Trace all macro-related activities: compilation, generation of synthetics, classloading, expansion, exceptions]" + "-Yno-completion[Disable tab-completion in the REPL]" + "-Yno-generic-signatures[Suppress generation of generic signatures for Java]" + "-Yno-imports[Compile without any implicit imports]" + "-Yno-predef[Compile without importing Predef]" + "-Yno-self-type-checks[Suppress check for self-type conformance among inherited members]" + "-Yno-squeeze[Disable creation of compact code in matching]" + "-Ynotnull[Enable (experimental and incomplete) scala.NotNull]" + "-Yoverride-objects[Allow member objects to be overridden]" + "-Yoverride-vars[Allow vars to be overridden]" + "-Ypmat-naive[Desugar matches as naively as possible]" + "-Ypresentation-delay+[Wait number of ms after typing before starting typechecking]" + "-Ypresentation-log+[Log presentation compiler events into file]:log file:_files" + "-Ypresentation-replay+[Replay presentation compiler events from file]:log file:_files" + "-Ypresentation-strict[Do not report type errors in sources with syntax errors]" + "-Ypresentation-verbose[Print information about presentation compiler tasks]" + "-Yprofile-class+[Specify name of profiler class]:profiler class name" + "-Yprofile-memory[Heap snapshot after compiler run (requires jgpagent on JVM -agentpath)]" + "-Yrangepos[Use range positions for syntax trees]" + "-Yrecursion+[Set recursion depth used when locking symbols]" + "-Yreify-copypaste[Dump the reified trees in copypasteable representation]" + "-Yrepl-sync[Do not use asynchronous code for REPL startup]" + "-Yresolve-term-conflict\:-[Resolve term conflicts (default\: error)]:resolution strategy:(package object error)" + "-Yself-in-annots[Include a \"self\" identifier inside of annotations]" + "-Yshow\:-[Show after (requires -Xshow-class or -Xshow-object)]:phase name:_scala_phases" + "-Yshow-syms[Print the AST symbol hierarchy after each phase]" + "-Yshow-symkinds[Print abbreviated symbol kinds next to symbol names]" + "-Yshow-trees[Print detailed ASTs (requires -Xprint\:phase)]" + "-Yshow-trees-compact[Print detailed ASTs in compact form (requires -Xprint\:)]" + "-Yshow-trees-stringified[Print stringifications along with detailed ASTs (requires -Xprint\:)]" + "-Ystatistics[Print compiler statistics]" + "-Ystruct-dispatch\:-[Structural method dispatch policy (default\: poly-cache)]:policy name:(no-cache mono-cache poly-cache invoke-dynamic)" + + "-Ybrowse\:-[Browse the abstract syntax tree after ]:phase name:_scala_phases" + "-Ycheck\:-[Check the tree at the end of ]:phase name:_scala_phases" + "-Ylog\:-[Log operations during ]:phase name:_scala_phases" + "-Yprofile\:-[Profile CPU usage of given phases (requires jgpagent on JVM -agentpath)]:phase name:_scala_phases" + "-Yskip\:-[Skip ]:phase name:_scala_phases" + "-Ystop-after\:-[Stop after given phase ]:phase name:_scala_phases" + "-Ystop-before\:-[Stop before given phase ]:phase name:_scala_phases" + + "-Ywarn-adapted-args[Warn if an argument list is modified to match the receiver]" + "-Ywarn-all[Enable all -Y warnings]" + "-Ywarn-dead-code[Warn when dead code is identified]" + "-Ywarn-inaccessible[Warn about inaccessible types in method signatures]" + "-Ywarn-nullary-override[Warn when non-nullary overrides nullary, e.g. def foo() over def foo]" + "-Ywarn-nullary-unit[Warn when nullary methods return Unit]" + "-Ywarn-numeric-widen[Warn when numerics are widened]" + "-Ywarn-value-discard[Warn when non-Unit expression results are unused]" + + "-Ybuild-manager-debug[Generate debug information for the Refined Build Manager compiler]" + "-Ybuilder-debug\:-[Compile using the specified build manager (default\: none)]:manager:(none refined simple)" + "-Ycompletion-debug[Trace all tab completion activity]" + "-Ydebug[Increase the quantity of debugging output]" + "-Ydoc-debug[Trace all scaladoc activity]" + "-Yide-debug[Generate, validate and output trees using the interactive compiler]" + "-Yinfer-debug[Trace type inference and implicit search]" + "-Yissue-debug[Print stack traces when a context issues an error]" + "-Ypatmat-debug[Trace pattern matching translation]" + "-Ypmat-debug[Trace all pattern matcher activity]" + "-Ypos-debug[Trace position validation]" + "-Ypresentation-debug[Enable debugging output for the presentation compiler]" + "-Yreify-debug[Trace reification]" + "-Yrepl-debug[Trace all REPL activity]" + "-Ytyper-debug[Trace all type assignments]" +) + +local -a scala_opts +scala_opts=( + "-e+[execute as if entered in the repl]:string" \ + "-howtorun+[what to run (default\: guess)]:execution mode:(script object jar guess)" \ + "-i+[preload before starting the repl]:file to preload:_files" \ + "-nc[no compilation daemon\: do not use the fsc offline compiler]" \ + "-save[save the compiled script in a jar for future use]" +) + +case $words[$CURRENT] in + -X*) _arguments $X_opts;; + -Y*) _arguments $Y_opts;; + *) case $service in + scala) _arguments $scala_opts $shared_opts "*::filename:_files";; + scalac) _arguments $shared_opts "*::filename:_files";; + esac +esac + +return 0 diff --git a/home/.zsh-server/plugins/zsh-completions/src/_scrub b/home/.zsh-server/plugins/zsh-completions/src/_scrub new file mode 100644 index 0000000..0f02e1c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_scrub @@ -0,0 +1,93 @@ +#compdef scrub +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for scrub 2.6.1 (http://linux.die.net/man/1/scrub). +# +# A utility which iteratively writes patterns on files or disk devices +# to make retrieving the data more difficult. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +_scrub_patterns() { + local patterns=( + 'nnsa:4-pass NNSA Policy Letter NAP-14.1-C (XVI-8)' + 'dod:4-pass DoD 5220.22-M section 8-306 procedure' + 'bsi:9-pass method recommended by the German Center of Security in Information Technologies' + "gutmann:The canonical 35-pass sequence described in Gutmann's paper cited below" + 'schneier:7-pass method described by Bruce Schneier in "Applied Cryptography"' + "pfitzner7:Roy Pfitzner's 7-random-pass method" + "pfitzner33:Roy Pfitzner's 33-random-pass method" + "usarmy:US Army AR380-19 method" + "fillzero:1-pass pattern\: 0x00" + "fillff:1-pass pattern\: 0xff" + "random:1-pass pattern\: random(x1)" + "random2:2-pass pattern: random(x2)" + "old:6-pass pre-version 1.7 scrub method" + "fastold:5-pass pattern\: 0x00, 0xff, 0xaa, 0x55, verify" + 'custom=:1-pass custom pattern' + ) + + _describe 'pattern' patterns +} + +_scrub() { + _arguments -s -S \ + "(- 1 *)"{-v,--version}"[Print scrub version and exit]" \ + {-r,--remove}"[Remove the file after scrubbing]" \ + {-p,--pattern}"[Select the patterns to write]:pattern:_scrub_patterns" \ + {-b,--blocksize}"[Perform read and write calls using the specified blocksize (in bytes)]:block size:" \ + {-f,--force}"[Scrub even if target contains signature indicating it has already been scrubbed]" \ + {-S,--no-signature}"[Do not write scrub signature]" \ + {-X,--freespace}"[Create specified directory and fill it with files until write returns ENOSPC (file sys‐tem full), then scrub the files as us]:directory name:" \ + {-D,--dirent}"[After scrubbing the file, scrub its name in the directory entry, then rename it to the new name]:new name:" \ + {-s,--device-size}"[Override the device size (in bytes)]:size:" \ + {-L,--no-link}"[If file is a symbolic link, do not scrub the link target]" \ + {-R,--no-hwrand}"[Don't use a hardware random number generator even if one is available]" \ + {-t,--no-threads}"[Don't generate random data in parallel with I/O]" \ + {-n,--dry-run}"[Do everything but write to targets]" \ + {-h,--help}"[Print a summary of command line options on stderr]" \ + '*:files:_files' +} + +_scrub + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_sdd b/home/.zsh-server/plugins/zsh-completions/src/_sdd new file mode 100644 index 0000000..c722095 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_sdd @@ -0,0 +1,66 @@ +#compdef sdd +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for sdd (http://freshmeat.net/projects/sdd/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# +# ------------------------------------------------------------------------------ + +_values -w 'option' \ + 'if[specify input file]:input file:_tilde_files' \ + 'of[specify output file]:output file:_tilde_files' \ + '(bs)ibs[input block size]:block size (bytes)' \ + '(bs)obs[output block size]:block size (bytes)' \ + '(ibs obs)bs[block size]:block size (bytes)' \ + 'cbs[conversion buffer size]:buffer size (bytes)' \ + 'skip[input/output initially skipped]:bytes' \ + 'seek[input/output initially skipped]:bytes' \ + 'count[number of input blocks to copy]:blocks' \ + '-notrunc[do not truncate existing output file]' \ + '-pg[print a dot on each write to indicate progress]' \ + '-noerror[do not stop on error]' \ + '-noerrwrite[do not write blocks not read correctly]' \ + "-noseek[don't seek]" \ + 'try[error retry count]:number' \ + '-debug[print debugging messages]' \ + '-fill[fill each record with zeros up to obs]' \ + '-swab' '-block' '-unblock' '-lcase' '-ucase' '-ascii' '-ebcdic' '-ibm' \ + '-help[show help]' \ + '-version[show version]' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_setcap b/home/.zsh-server/plugins/zsh-completions/src/_setcap new file mode 100644 index 0000000..6f34a0e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_setcap @@ -0,0 +1,108 @@ +#compdef setcap +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ------------------------------------------------------------------------------ +# Description +# ------------------------------------------------------------------------------ +# Completion script for libcap's setcap: +# - https://people.redhat.com/sgrubb/libcap-ng/ +# +# ZSH provides the `zsh/cap` module that does not work on most modern systems, +# in lieu of this I have written this zsh-completion modules. +# +# Written by +# - Zephyr Pellerin (https://github.com/zv) +# ------------------------------------------------------------------------------ + +local curcontext=$curcontext state line expl ret=1 +local -a args privs operators + +args=( '*:file:->files' + '1:capability:->capability' + '-v[verify]' '-q[quiet]' ) + +_arguments -C -s "$args[@]" && ret=0 + +operators=("e:effective" "i:inheritable" "p:permitted") + +case "$state" in + capability) + if compset -P '*?[=+-]'; then + _describe -t operators "operator" operators && ret=0 + else + _values -s , capability \ + 'cap_audit_control[Enable and disable kernel auditing]' \ + 'cap_audit_read[Allow reading the audit log]' \ + 'cap_audit_write[Write records to kernel auditing log.]' \ + 'cap_block_suspend[Employ features that can block system suspend]' \ + 'cap_chown[Make arbitrary changes to file UIDs and GIDs]' \ + 'cap_dac_override[Bypass file read, write, and execute permission checks.]' \ + 'cap_dac_read_search[Bypass file read permission checks]' \ + 'cap_fowner[Bypass filesystem UID checks, set extended attrs.]' \ + "cap_fsetid[Don't clear set-user-ID and set-group-ID permission bits when a file is modified]" \ + 'cap_ipc_lock[Lock memory]' \ + 'cap_ipc_owner[Bypass checks on SySV IPC object operations.]' \ + 'cap_kill[Bypass permission checks for sending signals]' \ + 'cap_lease[Establish leases on arbitrary files]' \ + 'cap_linux_immutable[Set immutability or append only]' \ + 'cap_mac_admin[Override Mandatory Access Control]' \ + 'cap_mac_override[Allow MAC configuration or state changes.]' \ + 'cap_mknod[Create special files using mknod(2)]' \ + 'cap_net_admin[Perform various network-related operations]' \ + 'cap_net_bind_service[Bind a socket to a privileged ports.]' \ + 'cap_net_broadcast[Make socket broadcasts and listen to multicast.]' \ + 'cap_net_raw[Use raw sockets.]' \ + 'cap_setgid[Manipulate process GIDs.]' \ + 'cap_setfcap[Set file capabilities.]' \ + "cap_setpcap[Grant or remove any capability in the caller's permitted capability set to or from any other process.]" \ + 'cap_setuid[Manipulate or forge process UIDs]' \ + 'cap_sys_admin[Perform numerous administrative tasks.]' \ + 'cap_sys_boot[Reboot]' \ + 'cap_sys_chroot[Use chroot]' \ + 'cap_sys_module[Load kernel module.]' \ + 'cap_sys_nice[Nice or renice processes.]' \ + 'cap_sys_pacct[Use acct(2).]' \ + 'cap_sys_ptrace[Inspect processes with ptrace or use process_vm_writev.]' \ + 'cap_sys_rawio[Numerous device IO functions, including performing raw IO and access x86 MSRs]' \ + 'cap_sys_resource[Set numerous resource limits]' \ + 'cap_sys_time[Set system clock]' \ + 'cap_sys_tty_config[Use vhangup(2)]' \ + 'cap_syslog[Perform privileged syslog(2) operations.]' \ + 'cap_wake_alarm[Trigger something that will wake up the system]' && ret=0 + fi ;; + files) _files && ret=0 ;; +esac + +return ret + +# Local variables: +# mode: shell-script +# sh-basic-offset: 2 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: sw=2 ts=2 et filetype=sh diff --git a/home/.zsh-server/plugins/zsh-completions/src/_setup.py b/home/.zsh-server/plugins/zsh-completions/src/_setup.py new file mode 100644 index 0000000..242af25 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_setup.py @@ -0,0 +1,715 @@ +#compdef setup.py +# ------------------------------------------------------------------------------ +# Copyright (C) 2015 by Hideo Hattori +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for setup.py (http://docs.python.org/distutils/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hideo Hattori (https://github.com/hhatto) +# +# ------------------------------------------------------------------------------ + +_setup.py() { + typeset -A opt_args + local context state line + + _arguments -s -S \ + "--verbose[run verbosely (default)]" \ + "-v[run verbosely (default)]" \ + "--quiet[run quietly (turns verbosity off)]" \ + "-q[run quietly (turns verbosity off)]" \ + "--dry-run[don't actually do anything]" \ + "-n[don't actually do anything]" \ + "--help[show detailed help message]" \ + "-h[show detailed help message]" \ + "--no-user-cfg[ignore pydistutils.cfg in your home directory]" \ + "--command-packages=[list of packages that provide distutils commands]" \ + "--help-commands[list all available commands]" \ + "--name[print package name]" \ + "--version[print package version]" \ + "-V[print package version]" \ + "--fullname[print -]" \ + "--author[print the author's name]" \ + "--author-email[print the author's email address]" \ + "--maintainer[print the maintainer's name]" \ + "--maintainer-email[print the maintainer's email address]" \ + "--contact[print the maintainer's name if known, else the author's]" \ + "--contact-email[print the maintainer's email address if known, else the author's]" \ + "--url[print the URL for this package]" \ + "--license[print the license of the package]" \ + "--licence[alias for --license]" \ + "--description[print the package description]" \ + "--long-description[print the long package description]" \ + "--platforms[print the list of platforms]" \ + "--classifiers[print the list of classifiers]" \ + "--keywords[print the list of keywords]" \ + "--provides[print the list of packages/modules provided]" \ + "--requires[print the list of packages/modules required]" \ + "--obsoletes[print the list of packages/modules made obsolete]" \ + "*::setup.py commands:_setuppy_command" +} + +(( $+functions[_setuppy_command] )) || +_setuppy_command() { + local cmd ret=1 + + (( $+setuppy_cmds )) || _setuppy_cmds=( + "build:build everything needed to install" \ + "build_py:\"build\" pure Python modules (copy to build directory)" \ + "build_ext:build C/C++ extensions (compile/link to build directory)" \ + "build_clib:build C/C++ libraries used by Python extensions" \ + "build_scripts:\"build\" scripts (copy and fixup #! line)" \ + "clean:clean up temporary files from 'build' command" \ + "install:install everything from build directory" \ + "install_lib:install all Python modules (extensions and pure Python)" \ + "install_headers:install C/C++ header files" \ + "install_scripts:install scripts (Python or otherwise)" \ + "install_data:install data files" \ + "sdist:create a source distribution (tarball, zip file, etc.)" \ + "register:register the distribution with the Python package index" \ + "bdist:create a built (binary) distribution" \ + "bdist_dumb:create a \"dumb\" built distribution" \ + "bdist_rpm:create an RPM distribution" \ + "bdist_wininst:create an executable installer for MS Windows" \ + "upload:upload binary package to PyPI" \ + "check:perform some checks on the package" \ + "alias:define a shortcut to invoke one or more commands" \ + "bdist_egg:create an \"egg\" distribution" \ + "develop:install package in 'development mode'" \ + "easy_install:Find/get/install Python packages" \ + "egg_info:create a distribution's .egg-info directory" \ + "rotate:delete older distributions, keeping N newest files" \ + "saveopts:save supplied options to setup.cfg or other config file" \ + "setopt:set an option in setup.cfg or another config file" \ + "test:run unit tests after in-place build" \ + "install_egg_info:Install an .egg-info directory for the package" \ + "upload_docs:Upload documentation to PyPI" \ + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'setup.py subcommand' _setuppy_cmds || compadd "$@" - ${(s.:.)${(j.:.)_setuppy_syns}} + else + local curcontext="$curcontext" + + cmd="${${_setuppy_cmds[(r)$words[1]:*]%%:*}:-${(k)_setuppy_syns[(r)(*:|)$words[1](:*|)]}}" + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:setuppy-${cmd}:" + _call_function ret _setuppy_$cmd || _message 'no more arguments' + else + _message "unknown setup.py command: $words[1]" + fi + return ret + fi +} + +(( $+functions[_setuppy_build] )) || +_setuppy_build() { + _arguments -s \ + "--build-base=[base directory for build library]" \ + "-b[base directory for build library]" \ + "--build-purelib=[build directory for platform-neutral distributions]" \ + "--build-platlib=[build directory for platform-specific distributions]" \ + "--build-lib=[build directory for all distribution (defaults to either build-purelib or build-platlib]" \ + "--build-scripts=[build directory for scripts]" \ + "--build-temp=[temporary build directory]" \ + "-t[temporary build directory]" \ + "--plat-name=[platform name to build for, if supported (default: linux-i686)]" \ + "-p[platform name to build for, if supported (default: linux-i686)]" \ + "--compiler=[specify the compiler type]" \ + "-c[specify the compiler type]" \ + "--debug[compile extensions and libraries with debugging information]" \ + "-g[compile extensions and libraries with debugging information]" \ + "--force[forcibly build everything (ignore file timestamps)]" \ + "-f[forcibly build everything (ignore file timestamps)]" \ + "--executable=[specify final destination interpreter path (build.py)]" \ + "-e[specify final destination interpreter path (build.py)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_build_py] )) || +_setuppy_build_py() { + _arguments -s \ + "--build-lib=[directory to \"build\" (copy) to]" \ + "-d[directory to \"build\" (copy) to]" \ + "--compile[compile .py to .pyc]" \ + "-c[compile .py to .pyc]" \ + "--no-compile[don't compile .py files \[default\]]" \ + "--optimize=[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "-O[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "--force[forcibly build everything (ignore file timestamps)]" \ + "-f[forcibly build everything (ignore file timestamps)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_build_ext] )) || +_setuppy_build_ext() { + _arguments -s \ + "--build-lib=[directory for compiled extension modules]" \ + "-b[directory for compiled extension modules]" \ + "--build-temp=[directory for temporary files (build by-products)]" \ + "-t[directory for temporary files (build by-products)]" \ + "--plat-name=[platform name to cross-compile for, if supported (default: linux-i686)]" \ + "-p[platform name to cross-compile for, if supported (default: linux-i686)]" \ + "--inplace[ignore build-lib and put compiled extensions into the source directory alongside your pure Python modules]" \ + "-i[ignore build-lib and put compiled extensions into the source directory alongside your pure Python modules]" \ + "--include-dirs=[list of directories to search for header files (separated by ':')]" \ + "-I[list of directories to search for header files (separated by ':')]" \ + "--define=[C preprocessor macros to define]" \ + "-D[C preprocessor macros to define]" \ + "--undef=[C preprocessor macros to undefine]" \ + "-U[C preprocessor macros to undefine]" \ + "--libraries=[external C libraries to link with]" \ + "-l[external C libraries to link with]" \ + "--library-dirs=[directories to search for external C libraries (separated by ':')]" \ + "-L[directories to search for external C libraries (separated by ':')]" \ + "--rpath=[directories to search for shared C libraries at runtime]" \ + "-R[directories to search for shared C libraries at runtime]" \ + "--link-objects=[extra explicit link objects to include in the link]" \ + "-O[extra explicit link objects to include in the link]" \ + "--debug[compile/link with debugging information]" \ + "-g[compile/link with debugging information]" \ + "--force[forcibly build everything (ignore file timestamps)]" \ + "-f[forcibly build everything (ignore file timestamps)]" \ + "--compiler=[specify the compiler type]" \ + "-c[specify the compiler type]" \ + "--swig-cpp[make SWIG create C++ files (default is C)]" \ + "--swig-opts=[list of SWIG command line options]" \ + "--swig=[path to the SWIG executable]" \ + "--user[add user include, library and rpath]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_build_clib] )) || +_setuppy_build_clib() { + _arguments -s \ + "--build-clib=[directory to build C/C++ libraries to]" \ + "-b[directory to build C/C++ libraries to]" \ + "--build-temp=[directory to put temporary build by-products]" \ + "-t[directory to put temporary build by-products]" \ + "--debug[compile with debugging information]" \ + "-g[compile with debugging information]" \ + "--force[forcibly build everything (ignore file timestamps)]" \ + "-f[forcibly build everything (ignore file timestamps)]" \ + "--compiler=[specify the compiler type]" \ + "-c[specify the compiler type]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_build_scripts] )) || +_setuppy_build_scripts() { + _arguments -s \ + "--build-dir=[directory to \"build\" (copy) to]" \ + "-d[directory to \"build\" (copy) to]" \ + "--force[forcibly build everything (ignore file timestamps]" \ + "-f[forcibly build everything (ignore file timestamps]" \ + "--executable=[specify final destination interpreter path]" \ + "-e[specify final destination interpreter path]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_clean] )) || +_setuppy_clean() { + _arguments -s \ + "--build-base=[base build directory (default: 'build.build-base')]" \ + "-b[base build directory (default: 'build.build-base')]" \ + "--build-lib=[build directory for all modules (default: 'build.build-lib')]" \ + "--build-temp=[temporary build directory (default: 'build.build-temp')]" \ + "-t[temporary build directory (default: 'build.build-temp')]" \ + "--build-scripts=[build directory for scripts (default: 'build.build-scripts')]" \ + "--bdist-base=[temporary directory for built distributions]" \ + "--all[remove all build output, not just temporary by-products]" \ + "-a[remove all build output, not just temporary by-products]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_install] )) || +_setuppy_install() { + _arguments -s \ + "--prefix=[installation prefix]" \ + "--exec-prefix=[(Unix only) prefix for platform-specific files]" \ + "--home=[(Unix only) home directory to install under]" \ + "--user[install in user site-package]" \ + "--install-base=[base installation directory (instead of --prefix or --home)]" \ + "--install-platbase=[base installation directory for platform-specific files (instead of --exec-prefix or --home)]" \ + "--root=[install everything relative to this alternate root directory]" \ + "--install-purelib=[installation directory for pure Python module distributions]" \ + "--install-platlib=[installation directory for non-pure module distributions]" \ + "--install-lib=[installation directory for all module distributions (overrides --install-purelib and --install-platlib)]" \ + "--install-headers=[installation directory for C/C++ headers]" \ + "--install-scripts=[installation directory for Python scripts]" \ + "--install-data=[installation directory for data files]" \ + "--compile[compile .py to .pyc \[default\]]" \ + "-c[compile .py to .pyc \[default\]]" \ + "--no-compile[don't compile .py files]" \ + "--optimize=[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "-O[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "--force[force installation (overwrite any existing files)]" \ + "-f[force installation (overwrite any existing files)]" \ + "--skip-build[skip rebuilding everything (for testing/debugging)]" \ + "--record=[filename in which to record list of installed files]" \ + "--old-and-unmanageable[Try not to use this!]" \ + "--single-version-externally-managed[used by system package builders to create 'flat' eggs]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_install_lib] )) || +_setuppy_install_lib() { + _arguments -s \ + "--install-dir=[directory to install to]" \ + "-d[directory to install to]" \ + "--build-dir=[build directory (where to install from)]" \ + "-b[build directory (where to install from)]" \ + "--force[force installation (overwrite existing files)]" \ + "-f[force installation (overwrite existing files)]" \ + "--compile[compile .py to .pyc \[default\]]" \ + "-c[compile .py to .pyc \[default\]]" \ + "--no-compile[don't compile .py files]" \ + "--optimize=[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "-O[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "--skip-build[skip the build steps]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_install_headers] )) || +_setuppy_install_headers() { + _arguments -s \ + "--install-dir=[directory to install header files to]" \ + "-d[directory to install header files to]" \ + "--force[force installation (overwrite existing files)]" \ + "-f[force installation (overwrite existing files)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_install_scripts] )) || +_setuppy_install_scripts() { + _arguments -s \ + "--install-dir=[directory to install scripts to]" \ + "-d[directory to install scripts to]" \ + "--build-dir=[build directory (where to install from)]" \ + "-b[build directory (where to install from)]" \ + "--force[force installation (overwrite existing files)]" \ + "-f[force installation (overwrite existing files)]" \ + "--skip-build[skip the build steps]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_install_data] )) || +_setuppy_install_data() { + _arguments -s \ + "--install-dir=[base directory for installing data files (default: installation base dir)]" \ + "-d[base directory for installing data files (default: installation base dir)]" \ + "--root=[install everything relative to this alternate root directory]" \ + "--force[force installation (overwrite existing files)]" \ + "-f[force installation (overwrite existing files)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_sdist] )) || +_setuppy_sdist() { + _arguments -s \ + "--formats=[formats for source distribution (comma-separated list)]" \ + "--keep-temp[keep the distribution tree around after creating archive file(s)]" \ + "-k[keep the distribution tree around after creating archive file(s)]" \ + "--dist-dir=[directory to put the source distribution archive(s) in \[default: dist\]]" \ + "-d[directory to put the source distribution archive(s) in \[default: dist\]]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_register] )) || +_setuppy_register() { + _arguments -s \ + "--repository=[url of repository \[default: http://pypi.python.org/pypi\]]" \ + "-r[url of repository \[default: http://pypi.python.org/pypi\]]" \ + "--show-response[display full response text from server]" \ + "--list-classifiers[list the valid Trove classifiers]" \ + "--strict[Will stop the registering if the meta-data are not fully compliant]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_bdist] )) || +_setuppy_bdist() { + _arguments -s \ + "--bdist-base=[temporary directory for creating built distributions]" \ + "-b[temporary directory for creating built distributions]" \ + "--plat-name=[platform name to embed in generated filenames (default: linux-i686)]" \ + "-p[platform name to embed in generated filenames (default: linux-i686)]" \ + "--formats=[formats for distribution (comma-separated list)]" \ + "--dist-dir=[directory to put final built distributions in \[default: dist\]]" \ + "-d[directory to put final built distributions in \[default: dist\]]" \ + "--skip-build[skip rebuilding everything (for testing/debugging)]" \ + "--owner=[Owner name used when creating a tar file \[default: current user\]]" \ + "-u[Owner name used when creating a tar file \[default: current user\]]" \ + "--group=[Group name used when creating a tar file \[default: current group\]]" \ + "-g[Group name used when creating a tar file \[default: current group\]]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_bdist_dumb] )) || +_setuppy_bdist_dumb() { + _arguments -s \ + "--bdist-dir=[temporary directory for creating the distribution]" \ + "-d[temporary directory for creating the distribution]" \ + "--plat-name=[platform name to embed in generated filenames (default: linux-i686)]" \ + "-p[platform name to embed in generated filenames (default: linux-i686)]" \ + "--format=[archive format to create (tar, ztar, gztar, zip)]" \ + "-f[archive format to create (tar, ztar, gztar, zip)]" \ + "--keep-temp[keep the pseudo-installation tree around after creating the distribution archive]" \ + "-k[keep the pseudo-installation tree around after creating the distribution archive]" \ + "--dist-dir=[directory to put final built distributions in]" \ + "-d[directory to put final built distributions in]" \ + "--skip-build[skip rebuilding everything (for testing/debugging)]" \ + "--relative[build the archive using relative paths(default: false)]" \ + "--owner=[Owner name used when creating a tar file \[default: current user\]]" \ + "-u[Owner name used when creating a tar file \[default: current user\]]" \ + "--group=[Group name used when creating a tar file \[default: current group\]]" \ + "-g[Group name used when creating a tar file \[default: current group\]]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_bdist_rpm] )) || +_setuppy_bdist_rpm() { + _arguments -s \ + "--bdist-base=[base directory for creating built distributions]" \ + "--rpm-base=[base directory for creating RPMs (defaults to \"rpm\" under --bdist-base; must be specified for RPM 2)]" \ + "--dist-dir=[directory to put final RPM files in (and .spec files if --spec-only)]" \ + "-d[directory to put final RPM files in (and .spec files if --spec-only)]" \ + "--python=[path to Python interpreter to hard-code in the .spec file (default: \"python\")]" \ + "--fix-python[hard-code the exact path to the current Python interpreter in the .spec file]" \ + "--spec-only[only regenerate spec file]" \ + "--source-only[only generate source RPM]" \ + "--binary-only[only generate binary RPM]" \ + "--use-bzip2[use bzip2 instead of gzip to create source distribution]" \ + "--distribution-name=[name of the (Linux) distribution to which this RPM applies (*not* the name of the module distribution!)]" \ + "--group=[package classification \[default: \"Development/Libraries\"\]]" \ + "--release=[RPM release number]" \ + "--serial=[RPM serial number]" \ + "--vendor=[RPM \"vendor\" (eg. \"Joe Blow \") \[default: maintainer or author from setup script\]]" \ + "--packager=[RPM packager (eg. \"Jane Doe \")\[default: vendor\]]" \ + "--doc-files=[list of documentation files (space or comma-separated)]" \ + "--changelog=[RPM changelog]" \ + "--icon=[name of icon file]" \ + "--provides=[capabilities provided by this package]" \ + "--requires=[capabilities required by this package]" \ + "--conflicts=[capabilities which conflict with this package]" \ + "--build-requires=[capabilities required to build this package]" \ + "--obsoletes=[capabilities made obsolete by this package]" \ + "--no-autoreq[do not automatically calculate dependencies]" \ + "--keep-temp[don't clean up RPM build directory]" \ + "-k[don't clean up RPM build directory]" \ + "--no-keep-temp[clean up RPM build directory \[default\]]" \ + "--use-rpm-opt-flags[compile with RPM_OPT_FLAGS when building from source RPM]" \ + "--no-rpm-opt-flags[do not pass any RPM CFLAGS to compiler]" \ + "--rpm3-mode[RPM 3 compatibility mode (default)]" \ + "--rpm2-mode[RPM 2 compatibility mode]" \ + "--prep-script=[Specify a script for the PREP phase of RPM building]" \ + "--build-script=[Specify a script for the BUILD phase of RPM building]" \ + "--pre-install=[Specify a script for the pre-INSTALL phase of RPM building]" \ + "--install-script=[Specify a script for the INSTALL phase of RPM building]" \ + "--post-install=[Specify a script for the post-INSTALL phase of RPM building]" \ + "--pre-uninstall=[Specify a script for the pre-UNINSTALL phase of RPM building]" \ + "--post-uninstall=[Specify a script for the post-UNINSTALL phase of RPM building]" \ + "--clean-script=[Specify a script for the CLEAN phase of RPM building]" \ + "--verify-script=[Specify a script for the VERIFY phase of the RPM build]" \ + "--force-arch=[Force an architecture onto the RPM build process]" \ + "--quiet[Run the INSTALL phase of RPM building in quiet mode]" \ + "-q[Run the INSTALL phase of RPM building in quiet mode]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_bdist_wininst] )) || +_setuppy_bdist_wininst() { + _arguments -s \ + "--bdist-dir=[temporary directory for creating the distribution]" \ + "--plat-name=[platform name to embed in generated filenames (default: linux-i686)]" \ + "-p[platform name to embed in generated filenames (default: linux-i686)]" \ + "--keep-temp[keep the pseudo-installation tree around after creating the distribution archive]" \ + "-k[keep the pseudo-installation tree around after creating the distribution archive]" \ + "--target-version=[require a specific python version on the target system]" \ + "--no-target-compile[do not compile .py to .pyc on the target system]" \ + "-c[do not compile .py to .pyc on the target system]" \ + "--no-target-optimize[do not compile .py to .pyo (optimized)on the target system]" \ + "-o[do not compile .py to .pyo (optimized)on the target system]" \ + "--dist-dir=[directory to put final built distributions in]" \ + "-d[directory to put final built distributions in]" \ + "--bitmap=[bitmap to use for the installer instead of python-powered logo]" \ + "-b[bitmap to use for the installer instead of python-powered logo]" \ + "--title=[title to display on the installer background instead of default]" \ + "-t[title to display on the installer background instead of default]" \ + "--skip-build[skip rebuilding everything (for testing/debugging)]" \ + "--install-script=[basename of installation script to be run after installation or before uninstallation]" \ + "--pre-install-script=[Fully qualified filename of a script to be run before any files are installed. This script need not be in the distribution]" \ + "--user-access-control=[specify Vista's UAC handling - 'none'/default=no handling, 'auto'=use UAC if target Python installed for all users, 'force'=always use UAC]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_upload] )) || +_setuppy_upload() { + _arguments -s \ + "--repository=[url of repository \[default: http://pypi.python.org/pypi\]]" \ + "-r[url of repository \[default: http://pypi.python.org/pypi\]]" \ + "--show-response[display full response text from server]" \ + "--sign[sign files to upload using gpg]" \ + "-s[sign files to upload using gpg]" \ + "--identity=[GPG identity used to sign files]" \ + "-i[GPG identity used to sign files]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_check] )) || +_setuppy_check() { + _arguments -s \ + "--metadata[Verify meta-data]" \ + "-m[Verify meta-data]" \ + "--restructuredtext[Checks if long string meta-data syntax are reStructuredText-compliant]" \ + "-r[Checks if long string meta-data syntax are reStructuredText-compliant]" \ + "--strict[Will exit with an error if a check fails]" \ + "-s[Will exit with an error if a check fails]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_alias] )) || +_setuppy_alias() { + _arguments -s \ + "--remove[remove (unset) the alias]" \ + "-r[remove (unset) the alias]" \ + "--global-config[save options to the site-wide distutils.cfg file]" \ + "-g[save options to the site-wide distutils.cfg file]" \ + "--user-config[save options to the current user's pydistutils.cfg file]" \ + "-u[save options to the current user's pydistutils.cfg file]" \ + "--filename=[configuration file to use (default=setup.cfg)]" \ + "-f[configuration file to use (default=setup.cfg)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_bdist_egg] )) || +_setuppy_bdist_egg() { + _arguments -s \ + "--bdist-dir=[temporary directory for creating the distribution]" \ + "-b[temporary directory for creating the distribution]" \ + "--plat-name=[platform name to embed in generated filenames (default: linux-i686)]" \ + "-p[platform name to embed in generated filenames (default: linux-i686)]" \ + "--exclude-source-files[remove all .py files from the generated egg]" \ + "--keep-temp[keep the pseudo-installation tree around after creating the distribution archive]" \ + "-k[keep the pseudo-installation tree around after creating the distribution archive]" \ + "--dist-dir=[directory to put final built distributions in]" \ + "-d[directory to put final built distributions in]" \ + "--skip-build[skip rebuilding everything (for testing/debugging)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_develop] )) || +_setuppy_develop() { + _arguments -s \ + "--prefix=[installation prefix]" \ + "--zip-ok[install package as a zipfile]" \ + "-z[install package as a zipfile]" \ + "--multi-version[make apps have to require() a version]" \ + "-m[make apps have to require() a version]" \ + "--upgrade[force upgrade (searches PyPI for latest versions)]" \ + "-U[force upgrade (searches PyPI for latest versions)]" \ + "--install-dir=[install package to DIR]" \ + "-d[install package to DIR]" \ + "--script-dir=[install scripts to DIR]" \ + "-s[install scripts to DIR]" \ + "--exclude-scripts[Don't install scripts]" \ + "-x[Don't install scripts]" \ + "--always-copy[Copy all needed packages to install dir]" \ + "-a[Copy all needed packages to install dir]" \ + "--index-url=[base URL of Python Package Index]" \ + "-i[base URL of Python Package Index]" \ + "--find-links=[additional URL(s) to search for packages]" \ + "-f[additional URL(s) to search for packages]" \ + "--build-directory=[download/extract/build in DIR; keep the results]" \ + "-b[download/extract/build in DIR; keep the results]" \ + "--optimize=[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "-O[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "--record=[filename in which to record list of installed files]" \ + "--always-unzip[don't install as a zipfile, no matter what]" \ + "-Z[don't install as a zipfile, no matter what]" \ + "--site-dirs=[list of directories where .pth files work]" \ + "-S[list of directories where .pth files work]" \ + "--editable[Install specified packages in editable form]" \ + "-e[Install specified packages in editable form]" \ + "--no-deps[don't install dependencies]" \ + "-N[don't install dependencies]" \ + "--allow-hosts=[pattern(s) that hostnames must match]" \ + "-H[pattern(s) that hostnames must match]" \ + "--local-snapshots-ok[allow building eggs from local checkouts]" \ + "-l[allow building eggs from local checkouts]" \ + "--version[print version information and exit]" \ + "--no-find-links[Don't load find-links defined in packages being installed]" \ + "--user[install in user site-package]" \ + "--uninstall[Uninstall this source package]" \ + "-u[Uninstall this source package]" \ + "--egg-path=[Set the path to be used in the .egg-link file]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_easy_install] )) || +_setuppy_easy_install() { + _arguments -s \ + "--prefix=[installation prefix]" \ + "--zip-ok[install package as a zipfile]" \ + "-z[install package as a zipfile]" \ + "--multi-version[make apps have to require() a version]" \ + "-m[make apps have to require() a version]" \ + "--upgrade[force upgrade (searches PyPI for latest versions)]" \ + "-U[force upgrade (searches PyPI for latest versions)]" \ + "--install-dir=[install package to DIR]" \ + "-d[install package to DIR]" \ + "--script-dir=[install scripts to DIR]" \ + "-s[install scripts to DIR]" \ + "--exclude-scripts[Don't install scripts]" \ + "-x[Don't install scripts]" \ + "--always-copy[Copy all needed packages to install dir]" \ + "-a[Copy all needed packages to install dir]" \ + "--index-url=[base URL of Python Package Index]" \ + "-i[base URL of Python Package Index]" \ + "--find-links=[additional URL(s) to search for packages]" \ + "-f[additional URL(s) to search for packages]" \ + "--build-directory=[download/extract/build in DIR; keep the results]" \ + "-b[download/extract/build in DIR; keep the results]" \ + "--optimize=[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "-O[also compile with optimization: -O1 for \"python -O\", -O2 for \"python -OO\", and -O0 to disable \[default: -O0\]]" \ + "--record=[filename in which to record list of installed files]" \ + "--always-unzip[don't install as a zipfile, no matter what]" \ + "-Z[don't install as a zipfile, no matter what]" \ + "--site-dirs=[list of directories where .pth files work]" \ + "-S[list of directories where .pth files work]" \ + "--editable[Install specified packages in editable form]" \ + "-e[Install specified packages in editable form]" \ + "--no-deps[don't install dependencies]" \ + "-N[don't install dependencies]" \ + "--allow-hosts=[pattern(s) that hostnames must match]" \ + "-H[pattern(s) that hostnames must match]" \ + "--local-snapshots-ok[allow building eggs from local checkouts]" \ + "-l[allow building eggs from local checkouts]" \ + "--version[print version information and exit]" \ + "--no-find-links[Don't load find-links defined in packages being installed]" \ + "--user[install in user site-package]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_egg_info] )) || +_setuppy_egg_info() { + _arguments -s \ + "--egg-base=[directory containing .egg-info directories (default: top of the source tree)]" \ + "-e[directory containing .egg-info directories (default: top of the source tree)]" \ + "--tag-svn-revision[Add subversion revision ID to version number]" \ + "-r[Add subversion revision ID to version number]" \ + "--tag-date[Add date stamp (e.g. 20050528) to version number]" \ + "-d[Add date stamp (e.g. 20050528) to version number]" \ + "--tag-build=[Specify explicit tag to add to version number]" \ + "-b[Specify explicit tag to add to version number]" \ + "--no-svn-revision[Don't add subversion revision ID \[default\]]" \ + "-R[Don't add subversion revision ID \[default\]]" \ + "--no-date[Don't include date stamp \[default\]]" \ + "-D[Don't include date stamp \[default\]]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_rotate] )) || +_setuppy_rotate() { + _arguments -s \ + "--match=[patterns to match (required)]" \ + "-m[patterns to match (required)]" \ + "--dist-dir=[directory where the distributions are]" \ + "-d[directory where the distributions are]" \ + "--keep=[number of matching distributions to keep]" \ + "-k[number of matching distributions to keep]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_saveopts] )) || +_setuppy_saveopts() { + _arguments -s \ + "--global-config[save options to the site-wide distutils.cfg file]" \ + "-g[save options to the site-wide distutils.cfg file]" \ + "--user-config[save options to the current user's pydistutils.cfg file]" \ + "-u[save options to the current user's pydistutils.cfg file]" \ + "--filename=[configuration file to use (default=setup.cfg)]" \ + "-f[configuration file to use (default=setup.cfg)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_setopt] )) || +_setuppy_setopt() { + _arguments -s \ + "--command=[command to set an option for]" \ + "-c[command to set an option for]" \ + "--option=[option to set]" \ + "-o[option to set]" \ + "--set-value=[value of the option]" \ + "-s[value of the option]" \ + "--remove[remove (unset) the value]" \ + "-r[remove (unset) the value]" \ + "--global-config[save options to the site-wide distutils.cfg file]" \ + "-g[save options to the site-wide distutils.cfg file]" \ + "--user-config[save options to the current user's pydistutils.cfg file]" \ + "-u[save options to the current user's pydistutils.cfg file]" \ + "--filename=[configuration file to use (default=setup.cfg)]" \ + "-f[configuration file to use (default=setup.cfg)]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_test] )) || +_setuppy_test() { + _arguments -s \ + "--test-module=[Run 'test_suite' in specified module]" \ + "-m[Run 'test_suite' in specified module]" \ + "--test-suite=[Test suite to run (e.g. 'some_module.test_suite')]" \ + "-s[Test suite to run (e.g. 'some_module.test_suite')]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_install_egg_info] )) || +_setuppy_install_egg_info() { + _arguments -s \ + "--install-dir=[directory to install to]" \ + "-d[directory to install to]" \ + "*::setup.py commands:_setup.py" +} + +(( $+functions[_setuppy_upload_docs] )) || +_setuppy_upload_docs() { + _arguments -s \ + "--repository=[url of repository \[default: http://pypi.python.org/pypi\]]" \ + "-r[url of repository \[default: http://pypi.python.org/pypi\]]" \ + "--show-response[display full response text from server]" \ + "--upload-dir=[directory to upload]" \ + "*::setup.py commands:_setup.py" +} + +_setup.py "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_sfdx b/home/.zsh-server/plugins/zsh-completions/src/_sfdx new file mode 100644 index 0000000..8332fc0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_sfdx @@ -0,0 +1,935 @@ +#compdef sfdx + +# DESCRIPTION: Zsh completion script for the Salesforce CLI +# AUTHOR: Wade Wegner (@WadeWegner) +# REPO: https://github.com/wadewegner/salesforce-cli-zsh-completion +# LICENSE: https://github.com/wadewegner/salesforce-cli-zsh-completion/blob/master/LICENSE + +local -a _1st_arguments + +_1st_arguments=( + "force\:alias\:list":"list username aliases for the Salesforce CLI" + "force\:alias\:set":"set username aliases for the Salesforce CLI" + "force\:apex\:class\:create":"create an Apex class" + "force\:apex\:execute":"execute anonymous Apex code" + "force\:apex\:log\:get":"fetch a debug log" + "force\:apex\:log\:list":"list debug logs" + "force\:apex\:test\:report":"display test results" + "force\:apex\:test\:run":"invoke Apex tests" + "force\:apex\:trigger\:create":"create an Apex trigger" + "force\:auth\:jwt\:grant":"authorize an org using the JWT flow" + "force\:auth\:sfdxurl\:store":"authorize an org using an SFDX auth URL" + "force\:auth\:web\:login":"authorize an org using the web login flow" + "force\:config\:get":"get config var values for given names" + "force\:config\:list":"list config vars for the Salesforce CLI" + "force\:config\:set":"set config vars for the Salesforce CLI" + "force\:data\:bulk\:delete":"bulk delete records from a csv file" + "force\:data\:bulk\:status":"view the status of a bulk data load job or batch" + "force\:data\:bulk\:upsert":"bulk upsert records from a CSV file" + "force\:data\:record\:create":"create a record" + "force\:data\:record\:delete":"delete a record" + "force\:data\:record\:get":"view a record" + "force\:data\:record\:update":"update a record" + "force\:data\:soql\:query":"execute a SOQL query" + "force\:data\:tree\:export":"export data from an org into sObject tree format for force:data:tree:import consumption" + "force\:data\:tree\:import":"import data into an org using SObject Tree Save API" + "force\:doc\:commands\:display":"display help for force commands" + "force\:doc\:commands\:list":"list the force commands" + "force\:lightning\:app\:create":"create a Lightning app" + "force\:lightning\:component\:create":"create a Lightning component" + "force\:lightning\:event\:create":"create a Lightning event" + "force\:lightning\:interface\:create":"create a Lightning interface" + "force\:lightning\:lint":"analyse (lint) Lightning component code" + "force\:lightning\:test\:create":"create a Lightning test" + "force\:lightning\:test\:install":"install Lightning Testing Service unmanaged package in your org" + "force\:lightning\:test\:run":"invoke Lightning component tests" + "force\:limits\:api\:display":"display current org’s limits" + "force\:mdapi\:convert":"convert Metadata API source into the Salesforce DX source format" + "force\:mdapi\:deploy":"deploy metadata to an org using Metadata API" + "force\:mdapi\:deploy\:report":"check the status of a metadata deployment" + "force\:mdapi\:retrieve":"retrieve metadata from an org using Metadata API" + "force\:mdapi\:retrieve\:report":"check the status of a metadata retrieval" + "force\:org\:create":"create a scratch org" + "force\:org\:delete":"mark a scratch org for deletion" + "force\:org\:display":"get org description" + "force\:org\:list":"list all orgs you’ve created or authenticated to" + "force\:org\:open":"open an org in your browser" + "force\:org\:shape\:create":"create a snapshot of org edition, features, and licenses" + "force\:org\:shape\:delete":"delete all org shapes for a target org" + "force\:org\:shape\:list":"list all org shapes you’ve created" + "force\:package1\:version\:create":"create a first-generation package version in the release org" + "force\:package1\:version\:create\:get":"retrieve the status of a package version creation request" + "force\:package1\:version\:display":"display details about a first-generation package version" + "force\:package1\:version\:list":"list package versions for the specified first-generation package or for the org" + "force\:package2\:create":"create a second-generation package" + "force\:package2\:list":"list all second-generation packages in the Dev Hub org" + "force\:package2\:update":"update a second-generation package" + "force\:package2\:version\:create":"create a second-generation package version" + "force\:package2\:version\:create\:get":"retrieve a package version creation request" + "force\:package2\:version\:create\:list":"list package version creation requests" + "force\:package2\:version\:get":"retrieve a package version in the Dev Hub org" + "force\:package2\:version\:list":"list all package versions in the Dev Hub org" + "force\:package2\:version\:update":"update a second-generation package version" + "force\:package\:install":"install a package in the target org" + "force\:package\:install\:get":"retrieve the status of a package installation request" + "force\:package\:installed\:list":"list the org’s installed packages" + "force\:package\:uninstall":"uninstall a second-generation package from the target org" + "force\:package\:uninstall\:get":"retrieve status of package uninstall request" + "force\:project\:create":"create a new SFDX project" + "force\:project\:upgrade":"update project config files to the latest format" + "force\:schema\:sobject\:describe":"describe an object" + "force\:schema\:sobject\:list":"list all objects of a specified category" + "force\:source\:convert":"convert Salesforce DX source into the Metadata API source format" + "force\:source\:open":"edit a Lightning Page with Lightning App Builder" + "force\:source\:pull":"pull source from the scratch org to the project" + "force\:source\:push":"push source to an org from the project" + "force\:source\:status":"list local changes and/or changes in a scratch org" + "force\:user\:create":"create a user for a scratch org" + "force\:user\:display":"displays information about a user of a scratch org" + "force\:user\:list":"lists all users of a scratch org" + "force\:user\:password\:generate":"generate a password for scratch org users" + "force\:user\:permset\:assign":"assign a permission set to one or more users of an org" + "force\:visualforce\:component\:create":"create a Visualforce component" + "force\:visualforce\:page\:create":"create a Visualforce page" +) + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "sfdx command" _1st_arguments + return +fi + +local -a _command_args +case "$words[1]" in + force:limits:api:display) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:app:create) + _command_args=( + '(-n|--appname)'{-n,--appname}'[name of the generated Lightning app]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningApp*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:bulk:delete) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the sObject type of the records you’re deleting]' \ + '(-f|--csvfile)'{-f,--csvfile}'[the path to the CSV file containing the ids of the records to delete]:file:_files' \ + '(-w|--wait)'{-w,--wait}'[the number of minutes to wait for the command to complete before displaying the results]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:bulk:status) + _command_args=( + '(-i|--jobid)'{-i,--jobid}'[the ID of the job you want to view or of the job whose batch you want to view]' \ + '(-b|--batchid)'{-b,--batchid}'[the ID of the batch whose status you want to view]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:bulk:upsert) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the sObject type of the records you want to upsert]' \ + '(-f|--csvfile)'{-f,--csvfile}'[the path to the CSV file that defines the records to upsert]:file:_files' \ + '(-i|--externalid)'{-i,--externalid}'[the column name of the external ID; if not provided, an arbitrary ID is used]' \ + '(-w|--wait)'{-w,--wait}'[the number of minutes to wait for the command to complete before displaying the results]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:apex:class:create) + _command_args=( + '(-n|--classname)'{-n,--classname}'[name of the generated Apex class]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultApexClass*,ApexException,ApexUnitTest,InboundEmailService)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:doc:commands:display) + _command_args=( + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:doc:commands:list) + _command_args=( + '(-u|--usage)'{-u,--usage}'[list only docopts usage strings]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:visualforce:component:create) + _command_args=( + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultVFComponent*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-n|--componentname)'{-n,--componentname}'[name of the generated Visualforce component]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(-l|--label)'{-l,--label}'[Visualforce component label]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:component:create) + _command_args=( + '(-n|--componentname)'{-n,--componentname}'[name of the generated Lightning component]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningCmp*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:mdapi:convert) + _command_args=( + '(-r|--rootdir)'{-r,--rootdir}'[the root directory containing the Metadata API source]:file:_files' \ + '(-d|--outputdir)'{-d,--outputdir}'[the output directory to store the sfdx source]:file:_files' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:source:convert) + _command_args=( + '(-r|--rootdir)'{-r,--rootdir}'[the source directory for the source to be converted]:file:_files' \ + '(-d|--outputdir)'{-d,--outputdir}'[the output directory to export the Metadata API source to]:file:_files' \ + '(-n|--packagename)'{-n,--packagename}'[the name of the package to associate with the Metadata API source]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:create) + _command_args=( + '(-f|--definitionfile)'{-f,--definitionfile}'[path to a scratch org definition file]:file:_files' \ + '(-j|--definitionjson)'{-j,--definitionjson}'[scratch org definition in json format ]' \ + '(-n|--nonamespace)'{-n,--nonamespace}'[creates the scratch org with no namespace]' \ + '(-c|--noancestors)'{-c,--noancestors}'[do not include second-generation package ancestors in the scratch org]' \ + '(-i|--clientid)'{-i,--clientid}'[connected app consumer key]' \ + '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the created org as the default username]' \ + '(-a|--setalias)'{-a,--setalias}'[set an alias for the created scratch org]' \ + '(-e|--env)'{-e,--env}'[environment where the scratch org is created: \[sandbox*,virtual,prototype\] (sandbox*,virtual,prototype)]' \ + '(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \ + '(-d|--durationdays)'{-d,--durationdays}'[duration of the scratch org (in days) (default:7, min:1, max:30)]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:create) + _command_args=( + '(-n|--name)'{-n,--name}'[package name]' \ + '(-o|--containeroptions)'{-o,--containeroptions}'[\[*Managed | Unlocked | Locked\] container options for the package (Managed=DeveloperManagedSubscriberManaged, Unlocked=DeveloperControlledSubscriberEditable, Locked=DeveloperControlledSubscriberLocked)]' \ + '(-d|--description)'{-d,--description}'[package description]' \ + '(-e|--nonamespace)'{-e,--nonamespace}'[creates the package with no namespace; available only for developer-controlled packages.]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:user:create) + _command_args=( + '(-f|--definitionfile)'{-f,--definitionfile}'[file path to a user definition]:file:_files' \ + '(-a|--setalias)'{-a,--setalias}'[set an alias for the created username to reference within the CLI]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:project:create) + _command_args=( + '(-n|--projectname)'{-n,--projectname}'[name of the generated project]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (Defaultsfdx-project.json*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-l|--loginurl)'{-l,--loginurl}'[Salesforce instance login URL (https://login.salesforce.com*)]' \ + '(-x|--sourceapiversion)'{-x,--sourceapiversion}'[source API version number (41.0*)]' \ + '(-s|--namespace)'{-s,--namespace}'[project associated namespace]' \ + '(-p|--defaultpackagedir)'{-p,--defaultpackagedir}'[default package directory name (force-app*)]:file:_files' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:delete) + _command_args=( + '(-p|--noprompt)'{-p,--noprompt}'[no prompt to confirm deletion]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:mdapi:deploy) + _command_args=( + '(-c|--checkonly)'{-c,--checkonly}'[validate deploy but don’t save to the org (default:false)]' \ + '(-d|--deploydir)'{-d,--deploydir}'[root of directory tree of files to deploy]:file:_files' \ + '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 0)]' \ + '(-i|--jobid)'{-i,--jobid}'[WARNING: The flag "jobid" has been deprecated and will be removed in v41.01.0 or later. Instead, use "sfdx force:mdapi:deploy:report -i ".]' \ + '(-l|--testlevel)'{-l,--testlevel}'[deployment testing level (NoTestRun,RunSpecifiedTests,RunLocalTests,RunAllTestsInOrg)]' \ + '(-r|--runtests)'{-r,--runtests}'[tests to run if --testlevel RunSpecifiedTests]' \ + '(-e|--rollbackonerror)'{-e,--rollbackonerror}'[WARNING: The flag "rollbackonerror" has been deprecated and will be removed in v41.01.0 or later. Instead, use "ignoreerrors".]' \ + '(-o|--ignoreerrors)'{-o,--ignoreerrors}'[ignore any errors and do not roll back deployment (default:false)]' \ + '(-g|--ignorewarnings)'{-g,--ignorewarnings}'[whether a warning will allow a deployment to complete successfully (default:false)]' \ + '(-f|--zipfile)'{-f,--zipfile}'[path to .zip file of metadata to deploy]:file:_files' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[verbose output of deploy results]' \ + ) + ;; + force:mdapi:deploy:report) + _command_args=( + '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 0)]' \ + '(-i|--jobid)'{-i,--jobid}'[job ID of the deployment you want to check]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[verbose output of deploy results]' \ + ) + ;; + force:org:display) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[emit additional command output to stdout]' \ + ) + ;; + force:user:display) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:event:create) + _command_args=( + '(-n|--eventname)'{-n,--eventname}'[name of the generated Lightning event]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningEvt*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:apex:execute) + _command_args=( + '(-f|--apexcodefile)'{-f,--apexcodefile}'[path to a local file containing Apex code]:file:_files' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:config:get) + _command_args=( + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[emit additional command output to stdout]' \ + ) + ;; + force:package:install) + _command_args=( + '(-i|--id)'{-i,--id}'[ID of the package version to install (starts with 04t)]' \ + '(-w|--wait)'{-w,--wait}'[number of minutes to wait for installation status]' \ + '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (default: null)]' \ + '(-p|--publishwait)'{-p,--publishwait}'[number of minutes to wait for subscriber package version ID to become available in the target org]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package:install:get) + _command_args=( + '(-i|--requestid)'{-i,--requestid}'[ID of the package install request you want to check]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package:installed:list) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:interface:create) + _command_args=( + '(-n|--interfacename)'{-n,--interfacename}'[name of the generated Lightning interface]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningIntf*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:auth:jwt:grant) + _command_args=( + '(-u|--username)'{-u,--username}'[authentication username]' \ + '(-f|--jwtkeyfile)'{-f,--jwtkeyfile}'[path to a file containing the private key]:file:_files' \ + '(-i|--clientid)'{-i,--clientid}'[OAuth client ID (sometimes called the consumer key)]' \ + '(-r|--instanceurl)'{-r,--instanceurl}'[the login URL of the instance the org lives on]' \ + '(-d|--setdefaultdevhubusername)'{-d,--setdefaultdevhubusername}'[set the authenticated org as the default dev hub org for scratch org creation]' \ + '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the authenticated org as the default username that all commands run against]' \ + '(-a|--setalias)'{-a,--setalias}'[set an alias for the authenticated org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:lint) + _command_args=( + '(-i|--ignore)'{-i,--ignore}'[pattern used to ignore some folders]' \ + '(--files)--files[pattern used to include specific files]:file:_files' \ + '(-j|--json)'{-j,--json}'[format output as JSON]' \ + '(--config)--config[path to a custom ESLint configuration file]:file:_files' \ + '(--verbose)--verbose[report warnings in addition to errors]' \ + '(--exit)--exit[exit with error code 1 if there are lint issues]' \ + ) + ;; + force:alias:list) + _command_args=( + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:config:list) + _command_args=( + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:list) + _command_args=( + '(--all)--all[include expired, deleted, and unknown-status scratch orgs]' \ + '(--clean)--clean[remove all local org authorizations for non-active orgs]' \ + '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for confirmation]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[list more information about each org]' \ + ) + ;; + force:package2:list) + _command_args=( + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:user:list) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:apex:log:get) + _command_args=( + '(-i|--logid)'{-i,--logid}'[ID of the log to display]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:apex:log:list) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:open) + _command_args=( + '(-p|--path)'{-p,--path}'[navigation URL path]:file:_files' \ + '(-r|--urlonly)'{-r,--urlonly}'[display navigation URL, but don’t launch browser]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:source:open) + _command_args=( + '(-f|--sourcefile)'{-f,--sourcefile}'[file to edit]:file:_files' \ + '(-r|--urlonly)'{-r,--urlonly}'[generate a navigation URL; don’t launch the editor]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:visualforce:page:create) + _command_args=( + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultVFPage*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-n|--pagename)'{-n,--pagename}'[name of the generated Visualforce page]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(-l|--label)'{-l,--label}'[Visualforce page label]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:user:password:generate) + _command_args=( + '(-o|--onbehalfof)'{-o,--onbehalfof}'[comma-separated list of usernames for which to generate passwords]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:user:permset:assign) + _command_args=( + '(-n|--permsetname)'{-n,--permsetname}'[the name of the permission set to assign]' \ + '(-o|--onbehalfof)'{-o,--onbehalfof}'[comma-separated list of usernames or aliases to assign the permission set to]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:source:pull) + _command_args=( + '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \ + '(-f|--forceoverwrite)'{-f,--forceoverwrite}'[ignore conflict warnings and overwrite changes to the project]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:source:push) + _command_args=( + '(-f|--forceoverwrite)'{-f,--forceoverwrite}'[ignore conflict warnings and overwrite changes to scratch org]' \ + '(-g|--ignorewarnings)'{-g,--ignorewarnings}'[deploy changes even if warnings are generated]' \ + '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:record:create) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re creating]' \ + '(-v|--values)'{-v,--values}'[the = pairs you’re creating]' \ + '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[create the record with tooling api]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:record:delete) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re deleting]' \ + '(-i|--sobjectid)'{-i,--sobjectid}'[the ID of the record you’re deleting]' \ + '(-w|--where)'{-w,--where}'[a list of = pairs to search for]' \ + '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[delete the record with Tooling API]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:record:get) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re retrieving]' \ + '(-i|--sobjectid)'{-i,--sobjectid}'[the ID of the record you’re retrieving]' \ + '(-w|--where)'{-w,--where}'[a list of = pairs to search for]' \ + '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[retrieve the record with Tooling API]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:record:update) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re updating]' \ + '(-i|--sobjectid)'{-i,--sobjectid}'[the ID of the record you’re updating]' \ + '(-w|--where)'{-w,--where}'[a list of = pairs to search for]' \ + '(-v|--values)'{-v,--values}'[the = pairs you’re updating]' \ + '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[update the record with Tooling API]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:mdapi:retrieve) + _command_args=( + '(-a|--apiversion)'{-a,--apiversion}'[target API version for the retrieve (default 41.0)]' \ + '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: -1 (no limit))]' \ + '(-r|--retrievetargetdir)'{-r,--retrievetargetdir}'[directory root for the retrieved files]:file:_files' \ + '(-k|--unpackaged)'{-k,--unpackaged}'[file path of manifest of components to retrieve]:file:_files' \ + '(-d|--sourcedir)'{-d,--sourcedir}'[source dir to use instead of default manifest sfdx-project.xml]' \ + '(-p|--packagenames)'{-p,--packagenames}'[a comma-separated list of packages to retrieve]' \ + '(-s|--singlepackage)'{-s,--singlepackage}'[a single-package retrieve (default: false)]' \ + '(-i|--jobid)'{-i,--jobid}'[WARNING: The flag "jobid" has been deprecated and will be removed in v41.01.0 or later. Instead, use "sfdx force:mdapi:retrieve:report -i -r ".]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[verbose output of retrieve result]' \ + ) + ;; + force:mdapi:retrieve:report) + _command_args=( + '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: -1 (no limit))]' \ + '(-r|--retrievetargetdir)'{-r,--retrievetargetdir}'[directory root for the retrieved files]:file:_files' \ + '(-i|--jobid)'{-i,--jobid}'[job ID of the retrieve you want to check]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[verbose output of retrieve result]' \ + ) + ;; + force:alias:set) + _command_args=( + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:config:set) + _command_args=( + '(-g|--global)'{-g,--global}'[set config var globally (to be used from any directory)]:file:_files' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:auth:sfdxurl:store) + _command_args=( + '(-f|--sfdxurlfile)'{-f,--sfdxurlfile}'[path to a file containing the sfdx url]:file:_files' \ + '(-d|--setdefaultdevhubusername)'{-d,--setdefaultdevhubusername}'[set the authenticated org as the default dev hub org for scratch org creation]' \ + '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the authenticated org as the default username that all commands run against]' \ + '(-a|--setalias)'{-a,--setalias}'[set an alias for the authenticated org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:shape:create) + _command_args=( + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:shape:delete) + _command_args=( + '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for confirmation]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username for the target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:org:shape:list) + _command_args=( + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[list more information about each org shape]' \ + ) + ;; + force:schema:sobject:describe) + _command_args=( + '(-s|--sobjecttype)'{-s,--sobjecttype}'[the API name of the object to describe]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:schema:sobject:list) + _command_args=( + '(-c|--sobjecttypecategory)'{-c,--sobjecttypecategory}'[the type of objects to list (all|custom|standard)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:soql:query) + _command_args=( + '(-q|--query)'{-q,--query}'[SOQL query to execute]' \ + '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[execute query with Tooling API]' \ + '(-r|--resultformat)'{-r,--resultformat}'[query result format emitted to stdout; --json flag overrides this parameter (human*,csv,json)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:source:status) + _command_args=( + '(-a|--all)'{-a,--all}'[list all the changes that have been made]' \ + '(-l|--local)'{-l,--local}'[list the changes that have been made locally]' \ + '(-r|--remote)'{-r,--remote}'[list the changes that have been made in the scratch org]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:test:create) + _command_args=( + '(-n|--testname)'{-n,--testname}'[name of the generated Lightning test]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningTest*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:lightning:test:install) + _command_args=( + '(-w|--wait)'{-w,--wait}'[number of minutes to wait for installation status (default:2)]' \ + '(-r|--releaseversion)'{-r,--releaseversion}'[release version of Lightning Testing Service (default:latest)]' \ + '(-t|--packagetype)'{-t,--packagetype}'[type of unmanaged package. 'full' option contains both jasmine and mocha, plus examples (full*,jasmine,mocha)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:apex:test:report) + _command_args=( + '(-i|--testrunid)'{-i,--testrunid}'[ID of test run]' \ + '(-c|--codecoverage)'{-c,--codecoverage}'[retrieve code coverage results]' \ + '(-d|--outputdir)'{-d,--outputdir}'[directory to store test run files]:file:_files' \ + '(-r|--resultformat)'{-r,--resultformat}'[test result format emitted to stdout; --json flag overrides this parameter (human*,tap,junit,json)]' \ + '(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[display Apex test processing details]' \ + ) + ;; + force:apex:test:run) + _command_args=( + '(-n|--classnames)'{-n,--classnames}'[comma-separated list of Apex test class names to execute]' \ + '(-s|--suitenames)'{-s,--suitenames}'[comma-separated list of Apex test suite names to execute]' \ + '(-c|--codecoverage)'{-c,--codecoverage}'[retrieve code coverage results]' \ + '(-d|--outputdir)'{-d,--outputdir}'[directory to store test run files]:file:_files' \ + '(-l|--testlevel)'{-l,--testlevel}'[testlevel enum value (RunLocalTests,RunAllTestsInOrg,RunSpecifiedTests)]' \ + '(-r|--resultformat)'{-r,--resultformat}'[test result format emitted to stdout; --json flag overrides this parameter (human*,tap,junit,json)]' \ + '(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \ + '(--precompilewait)--precompilewait[how long to wait (in minutes) for Apex pre-compilation (default:3, min:3)]' \ + '(-y|--synchronous)'{-y,--synchronous}'[run tests from a single class synchronously]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[display Apex test processing details]' \ + ) + ;; + force:lightning:test:run) + _command_args=( + '(-a|--appname)'{-a,--appname}'[name of your Lightning test application]' \ + '(-d|--outputdir)'{-d,--outputdir}'[directory path to store test run artifacts: for example, log files and test results]:file:_files' \ + '(-r|--resultformat)'{-r,--resultformat}'[test result format emitted to stdout; --json flag overrides this parameter (human*,tap,junit,json)]' \ + '(-f|--configfile)'{-f,--configfile}'[path to config file for the test]:file:_files' \ + '(-o|--leavebrowseropen)'{-o,--leavebrowseropen}'[leave browser open]' \ + '(-t|--timeout)'{-t,--timeout}'[time (ms) to wait for results element in dom (default:60000)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:tree:export) + _command_args=( + '(-q|--query)'{-q,--query}'[soql query, or filepath of file containing a soql query, to retrieve records]:file:_files' \ + '(-p|--plan)'{-p,--plan}'[generate multiple sObject tree files and a plan definition file for aggregated import]' \ + '(-x|--prefix)'{-x,--prefix}'[prefix of generated files]' \ + '(-d|--outputdir)'{-d,--outputdir}'[directory to store files]:file:_files' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:data:tree:import) + _command_args=( + '(-f|--sobjecttreefiles)'{-f,--sobjecttreefiles}'[comma-delimited, ordered paths of json files containing collection of record trees to insert]:file:_files' \ + '(-p|--plan)'{-p,--plan}'[path to plan to insert multiple data files that have master-detail relationships]:file:_files' \ + '(-c|--contenttype)'{-c,--contenttype}'[if data file extension is not .json, provide content type (applies to all files)]' \ + '(--confighelp)--confighelp[display schema information for the --plan configuration file to stdout; if you use this option, all other options except --json are ignored]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:apex:trigger:create) + _command_args=( + '(-n|--triggername)'{-n,--triggername}'[name of the generated Apex trigger]' \ + '(-t|--template)'{-t,--template}'[template to use for file creation (ApexTrigger*)]' \ + '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \ + '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \ + '(-a|--apiversion)'{-a,--apiversion}'[API version number (41.0*,40.0)]' \ + '(-s|--sobject)'{-s,--sobject}'[sObject to create a trigger on (SOBJECT*)]' \ + '(-e|--triggerevents)'{-e,--triggerevents}'[events that fire the trigger (before insert*,before upsert,before delete,after insert,after upsert,after delete,after undelete)]' \ + '(--json)--json[JSON output]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package:uninstall) + _command_args=( + '(-i|--id)'{-i,--id}'[ID of the package to uninstall (starts with 04t)]' \ + '(-w|--wait)'{-w,--wait}'[number of minutes to wait for uninstall status]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package:uninstall:get) + _command_args=( + '(-i|--requestid)'{-i,--requestid}'[ID of the package uninstall request you want to check]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:update) + _command_args=( + '(-i|--package2id)'{-i,--package2id}'[id of the package (starts with 0Ho)]' \ + '(-n|--name)'{-n,--name}'[package name]' \ + '(-d|--description)'{-d,--description}'[package description]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:project:upgrade) + _command_args=( + '(-f|--forceupgrade)'{-f,--forceupgrade}'[run all upgrades even if project has already been upgraded]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package1:version:create) + _command_args=( + '(-i|--packageid)'{-i,--packageid}'[ID of the metadata package (starts with 033) of which you’re creating a new version]' \ + '(-n|--name)'{-n,--name}'[package version name]' \ + '(-d|--description)'{-d,--description}'[package version description]' \ + '(-v|--version)'{-v,--version}'[package version in major.minor format, for example, 3.2]' \ + '(-m|--managedreleased)'{-m,--managedreleased}'[create a managed package version]' \ + '(-r|--releasenotesurl)'{-r,--releasenotesurl}'[release notes URL]' \ + '(-p|--postinstallurl)'{-p,--postinstallurl}'[post install URL]' \ + '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (default: null)]' \ + '(-w|--wait)'{-w,--wait}'[minutes to wait for the package version to be created (default: 2 minutes)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:version:create) + _command_args=( + '(-i|--package2id)'{-i,--package2id}'[ID of the parent package (starts with 0Ho)]' \ + '(-d|--directory)'{-d,--directory}'[path to directory that contains the contents of the package version]:file:_files' \ + '(-b|--branch)'{-b,--branch}'[the package version’s branch]' \ + '(-t|--tag)'{-t,--tag}'[the package version’s tag]' \ + '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (default: null)]' \ + '(-p|--preserve)'{-p,--preserve}'[temp files are preserved that would otherwise be deleted]' \ + '(-j|--validateschema)'{-j,--validateschema}'[sfdx-project.json is validated against JSON schema]' \ + '(-w|--wait)'{-w,--wait}'[minutes to wait for the package version to be created (default:0)]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package1:version:create:get) + _command_args=( + '(-i|--requestid)'{-i,--requestid}'[PackageUploadRequest ID]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:version:create:get) + _command_args=( + '(-i|--package2createrequestid)'{-i,--package2createrequestid}'[package2 version creation request ID (starts with 08c)]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:version:create:list) + _command_args=( + '(-c|--createdlastdays)'{-c,--createdlastdays}'[created in the last specified number of days (starting at 00:00:00 of first day to now; 0 for today)]' \ + '(-s|--status)'{-s,--status}'[filter the list by version creation request status (Queued,InProgress,Success,Error)]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package1:version:display) + _command_args=( + '(-i|--packageversionid)'{-i,--packageversionid}'[metadata package version ID (starts with 04t)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:version:get) + _command_args=( + '(-i|--package2versionid)'{-i,--package2versionid}'[the package version ID (starts wtih 05i)]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package1:version:list) + _command_args=( + '(-i|--packageid)'{-i,--packageid}'[metadata package ID (starts with 033)]' \ + '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:package2:version:list) + _command_args=( + '(-c|--createdlastdays)'{-c,--createdlastdays}'[created in the last specified number of days (starting at 00:00:00 of first day to now; 0 for today)]' \ + '(-m|--modifiedlastdays)'{-m,--modifiedlastdays}'[list items modified in the specified last number of days (starting at 00:00:00 of first day to now; 0 for today)]' \ + '(-i|--package2ids)'{-i,--package2ids}'[filter results on specified comma-delimited package2 ids (start with 0Ho)]' \ + '(-r|--released)'{-r,--released}'[display released versions only]' \ + '(-o|--orderby)'{-o,--orderby}'[order by the specified package2 version fields]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--concise)--concise[display limited package2 version details]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + '(--verbose)--verbose[display extended package2 versions detail]' \ + ) + ;; + force:package2:version:update) + _command_args=( + '(-i|--package2versionid)'{-i,--package2versionid}'[the package version ID (starts wtih 05i)]' \ + '(-n|--name)'{-n,--name}'[the package version name]' \ + '(-d|--description)'{-d,--description}'[the package version description]' \ + '(-b|--branch)'{-b,--branch}'[the package version branch]' \ + '(-t|--tag)'{-t,--tag}'[the package version tag]' \ + '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (default: null)]' \ + '(-s|--setasreleased)'{-s,--setasreleased}'[set the package version as released (can’t be undone)]' \ + '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + force:auth:web:login) + _command_args=( + '(-i|--clientid)'{-i,--clientid}'[OAuth client ID (sometimes called the consumer key)]' \ + '(-r|--instanceurl)'{-r,--instanceurl}'[the login URL of the instance the org lives on]' \ + '(-d|--setdefaultdevhubusername)'{-d,--setdefaultdevhubusername}'[set the authenticated org as the default dev hub org for scratch org creation]' \ + '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the authenticated org as the default username that all commands run against]' \ + '(-a|--setalias)'{-a,--setalias}'[set an alias for the authenticated org]' \ + '(--disablemasking)--disablemasking[disable masking of user input (for use with problematic terminals)]' \ + '(--json)--json[format output as json]' \ + '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \ + ) + ;; + esac + +_arguments \ + $_command_args \ + && return 0 diff --git a/home/.zsh-server/plugins/zsh-completions/src/_shellcheck b/home/.zsh-server/plugins/zsh-completions/src/_shellcheck new file mode 100644 index 0000000..5927c0e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_shellcheck @@ -0,0 +1,65 @@ +#compdef shellcheck +# ------------------------------------------------------------------------------ +# Copyright (c) 2021 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for shellcheck (https://github.com/koalaman/shellcheck) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Khue Nguyen (https://github.com/Z5483) +# +# ------------------------------------------------------------------------------ + +_arguments \ + {-a,--check-sourced}'[include warnings from sourced file]' \ + {-C,--color=}'[specify color]:color:(auto always never)' \ + {-i,--include=}'[consider only given types of warnings]:error code' \ + {-e,--exclude=}'[exclude given types of warnings]:error code' \ + {-f,--format=}'[specify output format]:format:(checkstyle diff gcc json json1 quiet tty)' \ + '--list-optional[list checks disabled by default]' \ + "--norc[don't look for .shellcheckrc files]" \ + {-o,--enable=}"[give list of optional checks to enable (or 'all')]:error code" \ + {-P,--source-path=}'[specify path when looking for sourced files]:_files -/' \ + {-s,--shell=}'[specify dialect]:dialect:(sh bash dash ksh)' \ + {-S,--severity=}'[specify minimum severity of errors to consider]:severity:(error warning info style)' \ + {-V,--version}'[print version information]' \ + {-W,--wiki-link-count=}'[specify number of wiki links to show, when applicable]:number' \ + {-x,--external-sources}'[allow outside sources]' \ + '--help[show this usage summary and exit]' \ + '*: :_files' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_showoff b/home/.zsh-server/plugins/zsh-completions/src/_showoff new file mode 100644 index 0000000..05105fa --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_showoff @@ -0,0 +1,163 @@ +#compdef showoff +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Showoff 0.20.3 (https://github.com/puppetlabs/showoff). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Bruno Michel (https://github.com/nono) +# * Shoehi Yoshida (https://github.com/nono) +# +# ------------------------------------------------------------------------------ + +_showoff_subcommands() { + local -a commands=( + "add:Add a new slide at the end in a given dir" + "new:Add a new slide at the end in a given dir" + "create:Create new showoff presentation" + "init:Create new showoff presentation" + "github:Puts your showoff presentation into a gh-pages branch" + "help:Shows a list of commands or help for one command" + "heroku:Setup your presentation to serve on Heroku" + "info:Display information about a Showoff presentation" + "pdf:Generate PDF version of presentation" + "serve:Serves the showoff presentation in the specified (or current) directory" + "skeleton:Build a showoff presentation from a showoff.json outline" + "static:Generate static version of presentation" + "validate:Validate the consistency of your presentation" + ) + + _describe -t commands 'showoff command' commands +} + +_showoff_help() { + local -a commands=(${(@f)"$(showoff help -c 2>/dev/null)"}) + _values 'commands' $commands +} + +_showoff() { + local curcontext="$curcontext" state line ret=1 + + _arguments -C \ + '--debug[Show application backtraces on crash]' \ + '--dev[Use the next-gen development version of Showoff]' \ + '(- *)--help[Show help message]' \ + '(- *)--version[Display the program version]' \ + '1: :_showoff_subcommands' \ + '*:: :->args' \ + && ret=0 + + case $state in + (args) + case $line[1] in + (add|new) + _arguments \ + '(-d --dir)'{-d,--dir}='[Slide dir (where to put a new slide file)]:directory:_files -/' \ + '(-n --name)'{-n,--name}='[Slide name (name of the new slide file)]:basename' \ + {-s,--source}='[Include code from the given file as the slide body]:file:_files' \ + '(-t --style --type)'{-t,--style,--type}='[Slide Type/Style (default: title)]:style' \ + '(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \ + '1:title' && ret=0 + ;; + (create|init) + _arguments \ + '(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \ + '(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \ + '1:dir_name' && ret=0 + ;; + (help) + _arguments \ + '-c[List commands one per line, to assist with shell completion]' \ + '1: :_showoff_help' && ret=0 + ;; + (heroku) + _arguments \ + '(-f --force)'{-f,--force}'[force overwrite of existing Gemfile, .gems and config.ru files if they exist]' \ + '(-p --password)'{-p,--password}='[add password protection to your heroku site(default: none)]' \ + '1:heroku_name' && ret=0 + ;; + (info) + _arguments \ + '(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \ + '(-j --json)'{-j,--json}'[render output as json]' \ + && ret=0 + ;; + (pdf|static) + _arguments \ + '(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \ + '(-l --lang --language --locale)'{-l,--lang,--language,--locale}'[Language code to generate(default: none)]' \ + '1:name' \ + && ret=0 + ;; + (serve) + _arguments \ + '(-S --standalone)'{-S,--standalone}'[Run in standalone mode with no audience interaction]' \ + '(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \ + '--git_branch=[Branch of git repository to use(default: none)]:branch' \ + '--git_path=[Path of the presentation within the git repository(default: none)]:path' \ + '(-h --host)'{-h,--host}='[Host or ip to run on(default: 0.0.0.0)]' \ + '--nocache[Disable content caching]'\ + '--nosleep[Prevent the computer from sleeping during your presentation]' \ + '(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \ + '(-r --review)'{-r,--review}'[Enable code review]'\ + '(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \ + '--ssl_certificate=[Path to SSL certificate]: :_files' \ + '--ssl_private_key=[Path to SSL private key]: :_files' \ + '(-u --url --git_url)'{-u,--url,--git_url}='[GIT URL to a repository containing the presentation]:url' \ + '(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \ + '(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \ + '1: :_files -/' && ret=0 + ;; + (skeleton|validate) + _arguments \ + '(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \ + && ret=0 + ;; + *) + (( ret )) && _message 'no more arguments' + ;; + esac + ;; + esac + + return ret +} + +_showoff "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_srm b/home/.zsh-server/plugins/zsh-completions/src/_srm new file mode 100644 index 0000000..08d2a32 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_srm @@ -0,0 +1,84 @@ +#compdef srm +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for srm. +# +# It is based on the rm completion script from Zsh. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sorin Ionescu +# +# ------------------------------------------------------------------------------ + +local -a opts args +args=( + '(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]' + '(-r --interactive)'{-i,--interactive}'[prompt before any removal]' + '(-r -R --recursive)'{-r,-R,--recursive}'[remove the contents of directories recursively]' + '(-s --simple)'{-s,--simple}'[only overwrite with a single pass of random data]' + '(-v --verbose)'{-v,--verbose}'[explain what is being done]' + '(- *)--help[display help message and exit]' + '(- *)--version[output version information and exit]' + '*::files:->file' +) + +if _pick_variant gnu=gnu unix --help; then + args+=( + '(-x --one-file-system)'{-x,--one-file-system}'[stay within filesystems of files given as arguments]' + '(-P --openbsd)'{-P,--openbsd}'[overwrite the file 3 times (0xff, 0x00, 0xff)]' + '(-D --dod)'{-D,--dod}'[overwrite the file with 7 US DoD compliant passes (0xF6, 0x00, 0xFF, random, 0x00, 0xFF, random)]' + '(-E --doe)'{-E,--doe}'[overwrite the file with 3 US DoE compliant passes (random, random, DoE)]' + ) +else + args+=( + '(-m --medium)'{-m,--medium}'[overwrite the file with 7 US DoD compliant passes (0xF6, 0x00, 0xFF, random, 0x00, 0xFF, random)]' + '(-z --zero)'{-z,--zero}'[after overwriting, zero blocks used by file]' + '(-n --nounlink)'{-n,--nounlink}'[overwrite file, but do not rename or unlink it]' + ) +fi + +local curcontext=$curcontext state line ret=1 +local -A opt_args + +_arguments -s -S -C $opts \ + $args && ret=0 + +case $state in + (file) + local -a ignored + ignored=() + ((CURRENT > 1)) && + ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH}) + ((CURRENT < $#line)) && + ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH}) + _files -F ignored && ret=0 + ;; +esac + +return $ret diff --git a/home/.zsh-server/plugins/zsh-completions/src/_stack b/home/.zsh-server/plugins/zsh-completions/src/_stack new file mode 100644 index 0000000..9230b4c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_stack @@ -0,0 +1,134 @@ +#compdef stack +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ------------------------------------------------------------------------------ +# +# Completion script for stack (https://github.com/commercialhaskell/stack). +# +# ------------------------------------------------------------------------------ +# Authors +# ------------------------------------------------------------------------------ +# +# * Toshiki Teramura +# * Nikita Ursol +# +# ------------------------------------------------------------------------------ + +_stack () { + _arguments \ + --help'[show usage information]' \ + --version'[show version]' \ + --numeric-version'[show only version number]' \ + --hpack-numeric-version"[show only hpack's version number]" \ + '--docker[enable using a Docker container, run "stack --docker-help" for details]' \ + '--no-docker[disable using a Docker container, run "stack --docker-help" for details]' \ + '--nix[enable use of a Nix-shell, run "stack --nix-help" for details]' \ + '--no-nix[disable use of a Nix-shell, run "stack --nix-help" for details]' \ + --verbosity'[verbosity: silent, error, warn, info, debug]' \ + {-v,--verbose}'[enable verbose mode: verbosity level "debug"]' \ + --silent'[enable silent mode: verbosity level "silent"]' \ + --time-in-log'[enable inclusion of timings in logs, to use diff with logs]' \ + --no-time-in-log'[disable inclusion of timings in logs, to use diff with logs]' \ + --stack-root'[absolute path to the global stack root directory]' \ + --work-dir'[relative path of work directory]' \ + --system-ghc'[enable using the system installed GHC if available and a matching version]' \ + --no-system-ghc'[disable using the system installed GHC if available and a matching version]' \ + --install-ghc'[enable downloading and installing GHC if necessary]' \ + --no-install-ghc'[disable downloading and installing GHC if necessary]' \ + --arch'[system architecture, e.g. i386, x86_64]' \ + --ghc-variant'[specialized GHC variant, e.g. integersimple (incompatible with --system-ghc)]' \ + --ghc-build'[specialized GHC build, e.g. "gmp4" or "standard" (usually auto-detected)]' \ + {-j,--jobs}'[number of concurrent jobs to run]' \ + --extra-include-dirs'[extra directories to check for C header files]' \ + --extra-lib-dirs'[extra directories to check for libraries]' \ + --with-gcc'[use custom path to gcc executable]' \ + --with-hpack'[use custom path to hpack executable]' \ + --skip-ghc-check'[enable skipping the GHC version and architecture check]' \ + --no-skip-ghc-check'[disable skipping the GHC version and architecture check]' \ + --skip-msys'[enable skipping the local MSYS installation (Windows only)]' \ + --no-skip-msys'[disable skipping the local MSYS installation (Windows only)]' \ + --local-bin-path'[install binaries to specified location]' \ + --setup-info-yaml'[alternate URL or relative / absolute path for stack dependencies]' \ + --modify-code-page'[enable setting the codepage to support UTF-8 (Windows only)]' \ + --no-modify-code-page'[disable setting the codepage to support UTF-8 (Windows only)]' \ + --allow-different-user'[enable permission for non-owners to use a stack installation (POSIX only)]' \ + --no-allow-different-user'[disable permission for non-owners to use a stack installation (POSIX only)]' \ + --dump-logs'[enable dump the build output logs for local packages to the console]' \ + --no-dump-logs'[disable dump the build output logs for local packages to the console]' \ + {--color,--colour}'[specify when to use color in output; accepts "always", "never", "auto"]' \ + --resolver'[override resolver in project file]' \ + --terminal'[enable overriding terminal detection in the case of running in a false terminal]' \ + --no-terminal'[disable overriding terminal detection in the case of running in a false terminal]' \ + {--stack-colors,--stack-colours}"[specify stack's output styles]" \ + --terminal-width'[specify the width of the terminal, used for pretty-print messages]' \ + --stack-yaml'[override project stack.yaml file]' \ + --lock-file'[specify how to interact with lock files.]' \ + '*: :__stack_modes' +} + +__stack_modes () { + _values \ + 'subcommand' \ + 'build[build the project(s) in this directory/configuration]' \ + 'install[build executables and install to a user path]' \ + 'test[build and test the project(s) in this directory/configuration]' \ + 'bench[build and benchmark the project(s) in this directory/configuration]' \ + 'haddock[generate haddocks for the project(s) in this directory/configuration]' \ + 'new[create a brand new project]' \ + 'templates[show how to find templates available for "stack new".]' \ + 'init[create stack project config from cabal or hpack package specifications]' \ + 'setup[get the appropriate ghc for your project]' \ + 'path[print out handy path information]' \ + "ls[list command. (supports snapshots, dependencies and stack's styles)]" \ + 'unpack[unpack one or more packages locally]' \ + 'update[update the package index]' \ + 'upgrade[upgrade to the latest stack]' \ + 'upload[upload a package to Hackage]' \ + 'sdist[create source distribution tarballs]' \ + 'dot[visualize your projects dependency graph using Graphviz dot]' \ + 'ghc[run ghc]' \ + 'hoogle[run hoogle, the Haskell API search engine.]' \ + 'exec[execute a command]' \ + 'run[build and run an executable.]' \ + 'ghci[run ghci in the context of package(s) (experimental)]' \ + "repl[run ghci in the context of package(s) (experimental) (alias for 'ghci')]" \ + 'runghc[run runghc]' \ + "runhaskell[run runghc (alias for 'runghc')]" \ + 'script[run a Stack Script]' \ + 'eval[evaluate some haskell code inline.]' \ + 'clean[delete build artefacts for the project packages.]' \ + 'purge[delete the project stack working directories.]' \ + 'query[query general build information (experimental)]' \ + 'ide[ide-specific commands]' \ + 'docker[subcommands specific to Docker use]' \ + 'config[subcommands for accessing and modifying configuration values]' \ + 'hpc[subcommands specific to Haskell Program Coverage]' + +} + +_stack "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_subliminal b/home/.zsh-server/plugins/zsh-completions/src/_subliminal new file mode 100644 index 0000000..f70cf59 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_subliminal @@ -0,0 +1,81 @@ +#compdef subliminal +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Subliminal (https://github.com/Diaoul/subliminal). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# * Shohei Yoshida +# +# ------------------------------------------------------------------------------ + +_subliminal() { + typeset -A opt_args + local context state line + local curcontext="$curcontext" + local ret=1 + + _arguments -C \ + '--addic7ed[Addic7ed configuration]:user name:' \ + '--legendastv[LegendasTV configuration]:user name:' \ + '--opensubtitles[OpenSubtitles configuration]:user name:' \ + '--omdb[OMDB API key]:key' \ + '--cache-dir[Path to the cache directory]: :_files -/' \ + '--debug[Print useful information for debugging]' \ + '(- : *)--version[show version number and exit]' \ + '(- : *)--help[show help message and exit]' \ + '1: :(cache download)' \ + '*::arg:->command' \ + && ret=0 + + case "$state" in + (command) + case $words[1] in + (cache) + _arguments -C \ + '(- *)--help[Show help message and exit]' \ + "--clear-subliminal[Clear subliminal's cache]" \ + '*: :_files' \ + && ret=0 + ;; + (download) + _arguments -C \ + '(-l --language)'{-l,--language}'[Language as IETF code]:lang' \ + \*{-p,--provider}'[Provider to use]: :(argenteam legendastv opensubtitles opensubtitlesvip podnapisi shooter thesubdb tvsubtit)' \ + \*{-r,--refiner}'[Refiner to use]: :(hash metadata omdb tvdb)' \ + '(-a --age)'{-a,--age}'[Filter videos newer than AGE]:age' \ + '(-d --directory)'{-d,--directory}'[Directory where to save subtitles]: :_files -/' \ + '(-e --encoding)'{-e,--encoding}'[Subtitle file encoding]:encoding' \ + '(-s --single)'{-s,--single}'[Save subtitle without language code in the file name]' \ + '(-f --force)'{-f,--force}'[Force download even if a subtitle already exist]' \ + '(-hi,--hearing-impaired)'{-hi,--hearing-impaired}'[Prefer hearing impaired subtitles]' \ + '(-m --min-score)'{-m,--min-score}'[Minimum score for a subtitle to be downloaded]:integer range:' \ + '(-w --max-worked)'{-w,--max-workers}'[Maximum number of threads to use]:integer range:' \ + '(-z --archives -Z --no-archives)'{-z,--archives}'[Scan archives for videos]' \ + '(-z --archives -Z --no-archives)'{-Z,--no-archives}'[Scan archives for videos]' \ + '--verbose[Increase verbosity]' \ + '(- *)--help[Show help message and exit]' \ + '*: :_files' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + +_subliminal "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_supervisorctl b/home/.zsh-server/plugins/zsh-completions/src/_supervisorctl new file mode 100644 index 0000000..b48ce13 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_supervisorctl @@ -0,0 +1,174 @@ +#compdef supervisorctl +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for supervisorctl from Supervisord (http://supervisord.org) +# +# Sources: +# https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/supervisor +# https://github.com/zsh-users/zsh-completions/blob/master/src/_brew +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Matt Black (https://github.com/mafrosis) +# * dongweiming (https://github.com/dongweiming) +# +# ------------------------------------------------------------------------------ + + +_supervisorctl_list_procs() { + procs=(${(f)"$(_call_program supervisor_procs supervisorctl avail | awk '{print $1}')"}) +} +_supervisorctl_list_groups() { + groups=(${(f)"$(_call_program supervisor_procs supervisorctl avail | awk '$1 ~ /:/ { print substr($1,1,index($1,":")) }' | uniq)"}) +} + +_supervisorctl_list_procs_stopped() { + procs=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '/STOPPED/ {print $1}')"}) +} +_supervisorctl_list_groups_stopped() { + groups=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '$1$2 ~ /:(.*)STOPPED/ { print substr($1,1,index($1,":")) }' | uniq)"}) +} + +_supervisorctl_list_procs_running() { + procs=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '/RUNNING/ {print $1}')"}) +} +_supervisorctl_list_groups_running() { + groups=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '$1$2 ~ /:(.*)RUNNING/ { print substr($1,1,index($1,":")) }' | uniq)"}) +} + +local -a _1st_arguments +_1st_arguments=( + 'add:Activates any updates in config for process/group' + 'avail:Display all configured processes' + 'clear:Clear single/multiple/all process log files' + 'exit:Exit the supervisor shell' + 'fg:Connect to a process in foreground mode' + 'maintail:tail of supervisor main log file' + 'open:Connect to a remote supervisord process. (for UNIX domain socket, use unix:///socket/path)' + 'pid:Get the PID of process/supervisord' + 'quit:Exit the supervisor shell' + 'reload:Restart the remote supervisord' + 'remove:Removes process/group from active config' + "reread:Reload the daemon's configuration files" + 'restart:Restart process, group or all' + 'shutdown:Shut the remote supervisord down' + 'start:Start process, group or all' + 'status:Get process/group status info' + 'stop:Stop process, group or all' + 'tail:tail of process stdout' + 'update:Reload config and add/remove as necessary' + 'version:Show the version of the remote supervisord process' + 'help:Show help' +) + +local expl +local -a procs + +_arguments \ + {--configuration,-c}='[configuration file path (default /etc/supervisor.conf)]:filename:_files' \ + {--help,-h}'[print usage message and exit]:' \ + {--interactive,-i}'[start an interactive shell after executing commands]' \ + {--serverurl,-s}='[URL on which supervisord server is listening (default "http://localhost:9001")]' \ + {--username,-u}='[username to use for authentication with server]:username:_users' \ + {--password,-p}='[password to use for authentication with server]:password:' \ + {--history-file,-r}'[keep a readline history (if readline is available)]:filename:_files' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands 'supervisorctl subcommand' _1st_arguments + return +fi + +case "$words[1]" in + help) + tasks=(add avail clear exit fg maintail open pid quit reload remove \ + reread restart shutdown start status stop tail update version) + + _wanted tasks expl 'help' compadd $tasks ;; + + add|fg|remove) + # commands that only operate on processes + _supervisorctl_list_procs + _wanted procs expl 'process' compadd -a procs ;; + + clear|pid) + # commands that operate on processes and "all" + _supervisorctl_list_procs + procs+=('all') + _wanted procs expl 'process' compadd -a procs ;; + + status|update) + # commands that operate on processes, groups & "all" + _supervisorctl_list_procs + procs+=('all') + _wanted procs expl 'process' compadd -a procs + + _supervisorctl_list_groups + _wanted groups expl 'group' compadd -a groups ;; + + stop) + # commands that operate on RUNNING processes, groups & "all" + _supervisorctl_list_procs_running + procs+=('all') + _wanted procs expl 'process' compadd -a procs + + _supervisorctl_list_groups_running + _wanted groups expl 'group' compadd -a groups ;; + + restart|start) + # commands that operate on STOPPED processes, groups & "all" + _supervisorctl_list_procs_stopped + procs+=('all') + _wanted procs expl 'process' compadd -a procs + + _supervisorctl_list_groups_stopped + _wanted groups expl 'group' compadd -a groups ;; + + tail|maintail) + _arguments \ + '-f[Continuous tail of named process stdout]' \ + '-[last N *bytes* of process stdout]:number' \ + '1: :->forms' && return 0 + + if [[ $state == forms ]]; then + _supervisorctl_list_procs + _wanted procs expl 'processes' compadd -a procs + fi ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_svm b/home/.zsh-server/plugins/zsh-completions/src/_svm new file mode 100644 index 0000000..7782397 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_svm @@ -0,0 +1,172 @@ +#compdef svm +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for svm (https://github.com/yuroyoro/svm) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hideaki Miyake (https://github.com/mollifier) +# +# ------------------------------------------------------------------------------ + +local context curcontext="$curcontext" state line ret=1 +typeset -A opt_args + + +local -a _1st_arguments +_1st_arguments=( + 'help:show this usage information' + 'current:show the currently use scala version' + "list:show the scala version installed in svm_path(default is ${HOME}/.svm)" + "versions:show the available scala version not installed" + 'install:install specific scala version' + 'remove:uninstall specific scala version and remove their sources' + 'switch:setup to use a specific scala version' + 'update-latest:install or update nightly build scala version' + 'latest:setup to use nightly build scala version' + 'stable:setup to use stable(x.x.x.final) scala version' + 'self-update:update svm itself' +) + +_arguments -C \ + '(-)-h[show this usage information]' \ + '-c[show the currently use scala version]' \ + "-l[show the scala version installed in svm_path(default is ${HOME}/.svm)]" \ + '-v[show the available scala version not installed]' \ + '-i[install specific scala version]: :_svm_completion_not_installed_scala_versions' \ + '-r[uninstall specific scala version and remove their sources]: :_svm_completion_installed_scala_versions' \ + '(-s -u)'{-s,-u}'[setup to use a specific scala version]: :_svm_completion_not_selected_scala_versions' \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + + +# installed scala versions +(( $+functions[_svm_completion_installed_scala_versions] )) || +_svm_completion_installed_scala_versions() { + local -a _installed_versions + _current_version="${$(_call_program installed svm current)#currently version is[[:space:]]*}" + + # collect lines starts with digit + _installed_versions=( ${(M)${(@f)"$(_call_program installed svm list)"}:#[[:digit:]]*} ) + + _describe -t installed "installed versions" _installed_versions +} + +# installed and not selected scala versions +(( $+functions[_svm_completion_not_selected_scala_versions] )) || +_svm_completion_not_selected_scala_versions() { + local _current_version + local -a _not_selected_versions + + _current_version="${$(_call_program installed svm current)#currently version is[[:space:]]*}" + + # collect lines starts with digit + _not_selected_versions=( ${(M)${(@f)"$(_call_program installed svm list)"}:#[[:digit:]]*} ) + + # remove current version + _not_selected_versions=( ${_not_selected_versions:#$_current_version}) + _describe -t installed "not selected versions" _not_selected_versions +} + +# not installed scala versions +(( $+functions[_svm_completion_not_installed_scala_versions] )) || +_svm_completion_not_installed_scala_versions() { + local -a _not_installed_versions + # collect lines starts with digit + _not_installed_versions=( ${(M)${(@f)"$(_call_program installed svm versions)"}:#[[:digit:]]*} ) + + _describe -t notinstalled "not installed versions" _not_installed_versions +} + + +case $state in + cmds) + # action + case $PREFIX in + u*) + # complete command synonyms + local -a _synonym_arguments + _synonym_arguments=( + 'uninstall:uninstall specific scala version and remove their sources' + 'use:setup to use a specific scala version' + 'update-latest:install or update nightly build scala version' + ) + _describe -t actions 'svm actions' _synonym_arguments && ret=0 + ;; + + *) + _describe -t actions 'svm actions' _1st_arguments + _svm_completion_not_selected_scala_versions && ret=0 + ;; + esac + ;; # end action + + args) + # scala version number + case $words[1] in + (install) + # install not installed version + _arguments \ + '1: :_svm_completion_not_installed_scala_versions' \ + '--docs[download scala-devel-docs]' \ + '--sources[download scala-sources]' && ret=0 + ;; + (update-latest) + # update nightly build scala version + _arguments \ + '--docs[download scala-devel-docs]' \ + '--sources[download scala-sources]' && ret=0 + ;; + (remove|uninstall) + # remove installed version + _arguments \ + '1: :_svm_completion_installed_scala_versions' && ret=0 + ;; + (switch|use) + # use installed version + _arguments \ + '1: :_svm_completion_not_selected_scala_versions' && ret=0 + ;; + esac + + ;; # end args +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_teamocil b/home/.zsh-server/plugins/zsh-completions/src/_teamocil new file mode 100644 index 0000000..faf1e2a --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_teamocil @@ -0,0 +1,56 @@ +#compdef teamocil +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Teamocil 1.4.2 (https://github.com/remiprev/teamocil). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Petr Zelenin +# +# ------------------------------------------------------------------------------ + +_arguments \ + '--here[set up the first window in the current window]' \ + '--edit[edit the YAML layout file instead of using it]' \ + '--layout [use a specific layout file, instead of \`~/.teamocil/.yml\`]' \ + '--list[list all available layouts in \`~/.teamocil/\`]' \ + '--show[show the content of the layout file instead of executing it]' \ + '--debug[show the commands Teamocil will execute instead of actually executing them]' \ + '*:teamocil layouts:_files -W ~/.teamocil -g "*.yml(:r)"' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_thor b/home/.zsh-server/plugins/zsh-completions/src/_thor new file mode 100644 index 0000000..aadaef2 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_thor @@ -0,0 +1,133 @@ +#compdef thor +# ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for thor 1.2.1 (https://github.com/rails/thor). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Andrew Hodges (https://github.com/betawaffle) +# * Shohei Yoshida (https://github.com/syohex) +# +# ------------------------------------------------------------------------------ + +_thor_subcommands() { + local -a commands=( + 'help:Describe available commands or one specific command' + ) + + if [[ -e Thorfile ]]; then + commands=(${(@f)"$(thor list 2>/dev/null | awk '/^thor/{sub(/^thor /,"\\"); sub(/[ ]*#[ ]*/,":");print}')"} $commands) + else + commands=( + $commands + 'install:Install an optionally named Thor file into your system commands' + 'installed:List the installed Thor modules and commands' + 'list:List the available thor commands' + 'uninstall:Uninstall a named Thor module' + 'update:Update a Thor file from its original location' + 'version:Show Thor version' + ) + fi + + _describe -t commands 'command' commands "$@" +} + +_thor_help() { + local -a commands + + if [[ -e Thorfile ]]; then + commands=(${(@f)"$(thor list 2>/dev/null | awk "/^thor/{ printf \"\\\\%s\\n\", \$2 }")"}) + else + commands=(help install installed list uninstall update version) + fi + + _values 'help' $commands +} + +_thor() { + typeset -A opt_args + local context state line + local curcontext="$curcontext" + local ret=1 + + _arguments -C -A "-*" \ + '1: :_thor_subcommands' \ + '*::arg:->args' \ + && ret=0 + + case "$state" in + (args) + case $words[1] in + (help) + _arguments \ + '1: :_thor_help' \ + && ret=0 + ;; + (install) + _arguments \ + '--as=[specify the name]:name' \ + '--relative[use relative path]' \ + '--force[force install]' \ + '*: :_files' \ + && ret=0 + ;; + (installed) + _arguments \ + '--internal[show internal]' \ + && ret=0 + ;; + (list) + _arguments \ + '--substring[use search keyword as substring]' \ + '--group=[specify the group name]' \ + '--all[search from all groups]' \ + '--debug[show all back trace if error raises]' \ + '*::' \ + && ret=0 + ;; + (*) + _arguments \ + '*::_files' \ + && ret=0 + ;; + esac + ;; + esac + + return ret +} + +_thor "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_tmuxinator b/home/.zsh-server/plugins/zsh-completions/src/_tmuxinator new file mode 100644 index 0000000..9fff48e --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_tmuxinator @@ -0,0 +1,65 @@ +#compdef tmuxinator mux +# ------------------------------------------------------------------------------ +# Copyright (c) 2010-2016 Christopher Chow +# +# 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. +# ------------------------------------------------------------------------------ +# +# Description +# ----------- +# +# Completion script for tmuxinator (https://github.com/tmuxinator/tmuxinator) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Christopher Chow (https://github.com/Soliah) +# +# ------------------------------------------------------------------------------ + +_tmuxinator() { + local commands projects + commands=(${(f)"$(tmuxinator commands zsh)"}) + projects=(${(f)"$(tmuxinator completions start)"}) + + if (( CURRENT == 2 )); then + _describe -t commands "tmuxinator subcommands" commands + _describe -t projects "tmuxinator projects" projects + elif (( CURRENT == 3)); then + case $words[2] in + copy|debug|delete|open|start) + _arguments '*:projects:($projects)' + ;; + esac + fi + + return +} + +_tmuxinator + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_tmuxp b/home/.zsh-server/plugins/zsh-completions/src/_tmuxp new file mode 100644 index 0000000..959234c --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_tmuxp @@ -0,0 +1,191 @@ +#compdef tmuxp + +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - https://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for tmuxp (https://github.com/tmux-python/tmuxp) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Bez Hermoso +# +# ------------------------------------------------------------------------------ + +_tmuxp() { + + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ":command:->command" \ + "*::options:->options" \ + "--log-level[log level(default info)]: :(debug info warning error critical)" \ + '(- *)'{-h,--help}'[display usage information]' \ + '(- *)'{-V,--version}'[show version number and exit]' + + case $state in + (command) + local -a subcommands + subcommands=( + 'load:Load tmuxp workspaces' + 'shell:launch python shell for tmux server, session, window and pane' + 'import:Import a teamocil/tmuxinator config' + 'convert:Convert a tmuxp config between JSON and YAML' + 'debug-info:print out all diagnostic info' + 'ls:list sessions in config directory' + 'edit: run $EDITOR on config' + 'freeze:Snapshot a session into a config' + ) + _describe -t commands 'commands' subcommands + ;; + (options) + case $line[1] in + (load) + __tmuxp_load + ;; + (import) + __tmuxp_import + ;; + (freeze) + local sessions="$(__tmux_sessions)" + _arguments -C \ + '(- *)'{-h,--help}'[show help message and exit]' \ + '-S[pass-through for tmux -S]: :_files' \ + '-L[pass-through for tmux -L]: :' \ + '(-f --config-format)'{-f,--config-format}'[format to save in]: :(yaml json)' \ + '(-o --save-to)'{-o,--save-to}'[file to save to]: :_files' \ + '(-y --yes)'{-y,--yes}'[always answer yes]' \ + '(-q --quiet)'{-q,--quiet}"[don't prompt for confirmation]" \ + '--force[overwrite the config file]'\ + "1::session name:compadd $sessions" + ;; + (convert) + _arguments -C \ + '1:: :_files -g "*.(json|yaml|yml)"' + ;; + (shell) + local sessions="$(__tmux_sessions)" + local windows="$(__tmux_windows)" + _arguments -C \ + '(- *)'{-h,--help}'[show help message and exit]' \ + '-S[pass-through for tmux -S]: :_files' \ + '-L[pass-through for tmux -L]: :' \ + '--best[use best shell available in site packages]' \ + '--pdb[use plain pdb]' \ + "--code[use stdlib's code.interact()]" \ + '--ptipython[use ptpython + ipython]' \ + '--ptpython[use ptpython]' \ + '--ipython[use ipython]' \ + '--bpython[use bpython]' \ + (--no-startup)'--use-pythonrc[load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \ + (--use-pythonrc)'--no-startup[do not load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \ + (--no-vi-mode)'--use-vi-mode[use vi-mode in ptpython/ptipython]' \ + (--vi-mode)'--no-vi-mode[do not use vi-mode in ptpython/ptipython]' \ + "1::session name:compadd $sessions" \ + "2::window name:compadd $windows" + ;; + (ls|debug-info) + _arguments -C \ + '(- *)'{-h,--help}'[show help message and exit]' + ;; + (edit) + _arguments -C \ + '(- *)'{-h,--help}'[show help message and exit]' \ + '1:: :_files -g "*.(json|yaml|yml)"' + ;; + esac + esac + +} + +__tmuxp_load() { + local state line + typeset -A opt_args + _arguments -C \ + '*:sessions:->sessions' \ + '--yes:yes' \ + '-d[Load the session without attaching it]' \ + '-2[Force tmux to assume the terminal supports 256 colors]' \ + '-8[Like -2, but indicates that the terminal supports 88 colors]' + + # Can't get the options to be recognized when there are sessions that has + # a dash. + + case $state in + (sessions) + local s + _alternative \ + 'sessions-user:user session:compadd -F line - ~/.tmuxp/*.(json|yml|yaml)(:r:t)' \ + 'sessions-other:session in current directory:_path_files -/ -g "**/.tmuxp.(yml|yaml|json)"' \ + 'sessions-other:session in current directory:_path_files -g "*.(yml|yaml|json)"' + ;; + esac +} + +__tmuxp_import() { + local state line + typeset -A opt_args + _arguments -C \ + '1::program:(tmuxinator teamocil)' \ + '2::project:->project' + + case $state in + (project) + if [[ $line[1] == 'tmuxinator' ]] + then + _wanted tmuxinator-projects exp 'tmuxinator projects' compadd $(tmuxinator completions start) + fi + ;; + esac +} + +__tmux_sessions () { + local tmux_sessions + tmux_sessions=($(_call_program tmux_sessions 'tmux ls -F "#{session_name}"')) + echo $tmux_sessions +} + +__tmux_windows () { + local tmux_windows + tmux_windows=($(_call_program tmux_sessions 'tmux ls -F "#{window_name}"')) + echo $tmux_windows +} + +_tmuxp "$@" + + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_tox b/home/.zsh-server/plugins/zsh-completions/src/_tox new file mode 100644 index 0000000..17231e7 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_tox @@ -0,0 +1,67 @@ +#compdef tox +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for tox (https://tox.readthedocs.io). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +(( $+functions[_tox_envs_list] )) || +_tox_envs_list() { + local envs; envs=($(_call_program envs $service --listenvs-all)) + if [ ${#envs} -gt 0 ]; then + _values -s , 'tox environments' "${envs[@]}" + else + _message 'tox environments (none found)' + fi +} + +_arguments \ + '(- 1 *)--version[show version and exit]' \ + '(- 1 *)'{-h,--help}'[show help options]' \ + '(- 1 *)'{--hi,--help-ini}'[show help about ini-names]' \ + '*'{-v,--verbose}'[increase verbosity of reporting output]' \ + '*-q[progressively silence reporting output]' \ + '(- 1 *)--showconfig[show configuration information for all environments]' \ + '(- 1 *)'{-l,--listenvs}'[show list of test environments]' \ + '(- 1 *)'{-a,--listenvs-all}'[show list of all defined environments]' \ + '-c[config file name or directory with "tox.ini" file]:config path:_files -g "*.ini"' \ + '-e[work against specified environments]: :_tox_envs_list' \ + "--devenv[sets up a development environment at ENVDIR based on the env's tox configuration specified by '-e' ]: :" \ + '--notest[skip invoking test commands]' \ + '--sdistonly[only perform the sdist packaging activity]' \ + '--skip-pkg-install[skip package installation for this run]' \ + '(-p --parallel)'{-p,--parallel}'[run tox environments in parallel]: :' \ + '(-o --parallel-live)'{-o,--parallel-live}'[connect to stdout while running environments]' \ + '--parallel--safe-build[ensure two tox builds can run in parallel]' \ + '--installpkg[ensure two tox builds can run in parallel]:package path:_files -/' \ + '--develop[install package in the venv using "setup.py develop"]' \ + '(-i --index-url)'{-i,--index-url}'[set indexserver url]:index server URL:_urls' \ + '--pre[install pre-releases and development versions of dependencies]' \ + '(-r --recreate)'{-r,--recreate}'[force recreation of virtual environments]' \ + '--result-json[write a json file with detailed information about all commands and results involved]:JSON file path:_files -g "*.json"' \ + '--discover[for python discovery first try the python executables under these paths]:' \ + '--hashseed[set PYTHONHASHSEED to SEED before running commands]:seed' \ + '*--force-dep[forces a certain version of one of the dependencies when configuring the virtual environment]:pip requirement' \ + '--sitepackages[override sitepackages setting to True in all envs]' \ + '--alwayscopy[override alwayscopy setting to True in all envs]' \ + '--no-provision[do not perform provision, but fail and if a path was provided write provision metadata as JSON to it]:JSON file path:_files -g "*.json"' \ + '(-s --skip-missing-interpreters)'{-s,--skip-missing-interpreters}'[do not fail tests for missing interpreters]: :(config true false)' \ + '--workdir[tox working directory]: :_files -/' \ + '*: :_guard "^-*" command positional substitution arguments' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_udisksctl b/home/.zsh-server/plugins/zsh-completions/src/_udisksctl new file mode 100644 index 0000000..43ad958 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_udisksctl @@ -0,0 +1,164 @@ +#compdef udisksctl +# +# ------------------------------------------------------------------------------ +# The MIT License +# +# Copyright 2014 Damir Jelić +# +# 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. +# +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for udisksctl +# (https://cgit.freedesktop.org/udisks/tree/tools) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Damir Jelić [1] +# * Ole Jørgen Brønner (minor additions) +# +# [1] https://lists.freedesktop.org/archives/devkit-devel/2014-February/001554.html +# +# ------------------------------------------------------------------------------ +# Notes +# ----- +# +# udisksctl actually provide built-in support for completion: It accepts an +# special command 'complete' that returns completions. That is what drives the +# upstream bash completion. In the future one might consider rewriting using +# that. (but not sure how straight forward it would be to provide descriptions?) +# + +_paths() { + local -a _path_list + + for _path in $(_call_program paths "udisksctl complete \"udisksctl $words\" $CURSOR" | sed 's/:/\\:/g'); do + _path_list+=$_path + done + + _describe 'path' _path_list +} + +_filesystems() { + _fs_types=( + 'adfs' 'affs' 'autofs' 'cifs' 'coda' 'coherent' 'cramfs' 'debugfs' 'devpts' + 'efs' 'ext' 'ext2' 'ext3' 'ext4' 'hfs' 'hfsplus' 'hpfs' 'iso9660' 'jfs' 'minix' + 'msdos' 'ncpfs' 'nfs' 'nfs4' 'ntfs' 'proc' 'qnx4' 'ramfs' 'reiserfs' 'romfs' + 'squashfs' 'smbfs' 'sysv' 'tmpfs' 'ubifs' 'udf' 'ufs' 'umsdos' 'usbfs' 'vfat' + 'xenix' 'xfs' 'xiafs' + ) + + _describe 'file system type' _fs_types +} + +_udisksctl() { + typeset -A opt_args + local curcontext="$curcontext" state line ret=1 + + _arguments -C \ + '1:udisksctl commands:->cmds' \ + '*:: :->cmd_args' && ret=0 + + case $state in + cmds) + local commands; commands=( + 'help:show help' + 'info:show info about an object' + 'dump:show info about all object' + 'status:shows high-level status' + 'monitor:monitor changes to objects' + 'mount:mount a filesystem' + 'unmount:unmount a filesystem' + 'unlock:unlock an encrypted device' + 'lock:lock an encrypted device' + 'loop-setup:set-up a loop device' + 'loop-delete:delete a loop device' + 'power-off:safely power off a drive' + 'smart-simulate:set SMART data for a drive' + ) + _describe -t commands 'udisksctl command' commands && ret=0 + ;; + + cmd_args) + case $words[1] in + info) + _arguments \ + {-p,--object-path}'[specify object to get information about]:object path:_paths' \ + {-b,--block-device}'[specify block device to get information about]:block device:_paths' \ + {-d,--drive}'[specify drive to get information about]:drive:_paths' && ret=0 + ;; + mount) + _arguments \ + {-p,--object-path}'[specify object to mount]:object path:_paths' \ + {-b,--block-device}'[specify block device to mount]:block device:_paths' \ + {-t,--filesystem-type}'[specify filesystem type to use]:fs type:_filesystems' \ + {-o,--options}'[mount options]' \ + "(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0 + ;; + unmount) + _arguments \ + {-p,--object-path}'[object to unmount]:object path:_paths' \ + {-b,--block-device}'[block device to unmount]:block device:_paths' \ + {-f,--force}'[force/lazy unmount]' \ + "(--no-user-interaction)--no-user-interaction[don't auhenticate the user if needed]" && ret=0 + ;; + unlock|lock) + _arguments \ + {-p,--object-path}'[object to lock/unlock]:object path:_paths' \ + {-b,--block-device}'[block device to lock/unlock]:block device:_paths' \ + "(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0 + ;; + loop-setup) + _arguments \ + {-f,--file}'[specify file to set-up a loop device for]:files:_files' \ + {-r,--read-only}'[setup read-only device]' \ + {-o,--offset}'[start at specified offset into file]:offset (bytes)' \ + {-s,--size}'[limit size]:limit (bytes)' \ + "(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0 + ;; + loop-delete) + _arguments \ + {-p,--object-path}'[object for loop device to delete]:object path:_paths' \ + {-b,--block-device}'[loop device to delete]:block device:_paths' \ + "(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0 + ;; + power-off) + _arguments \ + {-p,--object-path}'[object path for ATA device]:object path:_paths' \ + {-b,--block-device}'[device file for ATA device]:block device:_paths' \ + "(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0 + ;; + smart-simulate) + _arguments \ + {-f,--file}'[file with libatasmart blob]:files:_files' \ + {-p,--object-path}'[object to get information about]:object path:_paths' \ + {-b,--block-device}'[block device to get information about]:block device:_paths' \ + "(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0 + ;; + esac + ;; + esac + return ret +} + +_udisksctl "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_ufw b/home/.zsh-server/plugins/zsh-completions/src/_ufw new file mode 100644 index 0000000..ffd04f8 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_ufw @@ -0,0 +1,145 @@ +#compdef ufw +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for The Uncomplicated Firewall (ufw). (https://launchpad.net/ufw). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_ufw_logging() { + + local params additional second + second=$words[2] + + if [ ! -z $second ]; then + return + fi + + params=( + "on" + "off" + ) + + additional=( + "low" + "medium" + "high" + "full" + ) + + _describe -t params 'on/off' params + _describe -t additional 'level' additional +} + + +_ufw_delete() { + local rules complrules second + + second=$words[2] + + if [ ! -z $second ]; then + return + fi + + complrules=() + rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}") + + for ((i=1; i<=${#rules[@]}; i++)); do + complrules+=("$i:$rules[i]"); + done + + _describe -t complrules 'Rules' complrules +} + +_ufw() { + local curcontext="$curcontext" ret=1 + local -a state line commands + + commands=( + "enable:enable the firewall" + "disable:disable the firewall" + "default:set default policy" + "logging:set logging level" + "allow:add allow rule" + "deny:add deny rule" + "reject:add reject rule" + "limit:add limit rule" + "delete:delete rule" + "insert:insert rule at position" + "route:add route rule" + "reload:reload firewall" + "reset:reset firewall" + "status:show firewall status" + "show:show firewall report" + "version:display version information" + "prepend:add rule before all of the same type" + ) + + _arguments -C -s -S -n \ + '(- 1 *)'--version"[display version information]: :->full" \ + '(- 1 *)'{-h,--help}'[display usage information]: :->full' \ + '(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \ + '1:cmd:->cmds' \ + '*:: :->args' && ret=0 + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (args) + local cmd + cmd=$words[1] + case "$cmd" in + (logging) + _ufw_logging && ret=0 + ;; + (delete) + _ufw_delete && ret=0 + ;; + (*) + _default && ret=0 + ;; + esac + ;; + (*) + ;; + esac + + return ret +} + +_ufw + diff --git a/home/.zsh-server/plugins/zsh-completions/src/_virtualbox b/home/.zsh-server/plugins/zsh-completions/src/_virtualbox new file mode 100644 index 0000000..03b49d6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_virtualbox @@ -0,0 +1,322 @@ +#compdef VBoxManage=vboxmanage VBoxHeadless=vboxheadless vboxmanage=vboxmanage +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for VirtualBox (http://www.virtualbox.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + + +_vboxmachines() { + VBoxManage list vms | grep -Eo '^"[^"]+"' 2>/dev/null | sed -e 's|"||g' | while read machine; do + _wanted 'machine' expl 'machine' compadd $machine + done +} + +_vboxnatnets() { + vboxmanage list natnetworks | awk -F: '/NetworkName:/{print $2}'| while read natnet; do + _wanted 'natnet' expl 'natnet' compadd $natnet + done +} + +# Roughly guess command options +_vboxcommandoptions() { + cmd="$1" + cmdoutput=$(VBoxManage "$cmd" 2>/dev/null | tail -n +2 | grep -v 'Syntax error:' | grep -v '|' | sed 's|<[^>]\+>||g' | sed 's|VBoxManage [^ ]\+ | |') + + optcount=0 + option="" + optlines=() + echo "$cmdoutput" | grep -Eo ' [\[A-Za-z0-9\-\<].*' | while read line; do + option="${option}${line}" + if [[ $line[-1] != '|' ]]; then + optcount=$(($optcount+1)) + optlines[$optcount]="$option" + option="" + fi + done + + # optionals ([abc]) + for line in $optlines; do + echo "$line" | grep -Eo '\[[^]]+\]' | while read option; do + option=$(echo $option | sed 's|[]\[]||g' | cut -d ' ' -f 1) + _options=(${(s:|:)option}) + for option in $_options; do + _wanted "${cmd}_option" expl "${cmd} option" compadd -- $option + done + done + done + + # mandatory + for line in $optlines; do + echo "$line" | sed 's|\[[^]]\+\]|\n|g' | while read option; do + if [[ "$option" != "" ]]; then + _option=$(echo $option | cut -d ' ' -f 1) + _options=(${(s:|:)option}) + for option in $_options; do + _wanted "${cmd}_option" expl "${cmd} option" compadd -- $option + done + fi + done + done +} + +# List possible mediums +_vboxmediums() { + _wanted "mediums" expl "mediums" compadd -- "none" + _wanted "mediums" expl "mediums" compadd -- "emptydrive" + _wanted "mediums" expl "mediums" compadd -- "iscsi" + + _files -g '*.{iso,vmdk,vdi}' + + for CD in /dev/cd/*; do + readlink -f $CD + done | uniq | while read CD; do + _wanted "host drives" expl "host drives" compadd -- "host:$CD" + done +} + +# List available os types +_vboxostypes() { + VBoxManage list ostypes | grep '^ID' | awk '{print $2}' | while read OSTYPE; do + _wanted 'ostype' expl 'os type' compadd -- $OSTYPE + done +} + +# Guess options for this commands +_vboxopts_controlvm() { _vboxcommandoptions controlvm } +_vboxopts_modifyvm() { _vboxcommandoptions modifyvm } +_vboxopts_export() { _vboxcommandoptions export } + +_vboxmanage() { + local -a _1st_arguments + _1st_arguments=( + "list:gives information about VirtualBox's current settings" + 'showvminfo:shows information about a particular virtual machine' + 'registervm:import a virtual machine definition in an XML file into VirtualBox' + 'unregistervm:unregisters a virtual machine' + 'createvm:creates a new XML virtual machine definition file' + 'modifyvm:changes the properties of a registered virtual machine which is not running' + 'import:imports a virtual appliance in OVF format by copying the virtual disk images and creating virtual machines in VirtualBox' + 'export:exports one or more virtual machines from VirtualBox into a virtual appliance in OVF format' + 'startvm:starts a virtual machine that is currently in the "Powered off" or "Saved" states' + 'controlvm:change the state of a virtual machine that is currently running' + 'discardstate:discards the saved state of a virtual machine which is not currently running' + 'adoptstate:adopt a saved state file (.sav)' + 'snapshot:control snapshots' + 'closemedium:removes a hard disk, DVD or floppy image from a VirtualBox media registry' + 'storageattach:attaches/modifies/removes a storage medium connected to a storage controller' + 'storagectl:attaches/modifies/removes a storage controller' + 'bandwidthctl:creates/deletes/modifies bandwidth groups' + 'showmediuminfo:shows information about a virtual hard disk image' + 'createmedium:creates a new virtual hard disk image' + 'modifymedium:change the characteristics of a disk image after it has been created' + 'clonemedium:duplicates a registered virtual hard disk image to a new image file with a new unique identifier' + 'convertfromraw:converts a raw disk image to a VirtualBox Disk Image (VDI) file' + 'getextradata:retrieve string data to a virtual machine or to a VirtualBox configuration' + 'setextradata:attach string data to a virtual machine or to a VirtualBox configuration' + 'setproperty:change global settings which affect the entire VirtualBox installation' + 'usbfilter:used for working with USB filters in virtual machines, or global filters' + 'sharedfolder:share folders on the host computer with guest operating systems' + 'guestproperty:get or set properties of a running virtual machine' + 'guestcontrol:control certain things inside a guest from the host' + 'debugvm:for experts who want to tinker with the exact details of virtual machine execution' + 'metrics:monitor the usage of system resources' + 'hostonlyif:change the IP configuration of a host-only network interface' + 'dhcpserver:control the DHCP server that is built into VirtualBox' + 'extpack:add or remove VirtualBox extension packs' + 'natnetwork:add,modify,remove or start NatNetworks' + ) + + local context state line expl + local -A opt_args + + _arguments '*:: :->subcmds' && return 0 + + if (( CURRENT == 1 )); then + _describe -t commands "VBoxManage commands" _1st_arguments -V1 + return + fi + + case "$words[1]" in + list) + _arguments \ + '--long' \ + ':list option:(vms runningvms ostypes hostdvds hostfloppies bridgedifs hostonlyifs dhcpservers hostinfo hostcpuids hddbackends hdds dvds floppies usbhost usbfilters systemproperties natnetworks extpacks)' + ;; + showvminfo) + _arguments \ + :machine:_vboxmachines \ + '--details' \ + '--machinereadable' \ + '--log: :' + ;; + unregistervm) + _arguments \ + :machine:_vboxmachines \ + '--delete' + ;; + createvm) + _arguments \ + '--name: :' \ + '--ostype:os type:_vboxostypes' \ + '--register' \ + '--basefolder:folder:_files -/' \ + '--settingsfile:file:_files' \ + '--uuid: :' + ;; + modifyvm) + _arguments \ + :machine:_vboxmachines \ + :modifyvm_option:_vboxopts_modifyvm + ;; + modifymedium|modifyhd) + _arguments \ + :filename:_files \ + '--type:hd type:(normal writethrough immutable shareable readonly multiattach)' \ + '--autoreset:on off:(on off)' \ + '--property: :' \ + '--compact' \ + '--resize:megabytes:' \ + '--resizebyte:bytes:' + ;; + import) + _arguments \ + ':ovf file:_files -g \*.{ovf,ova}' \ + '--dry-run' + ;; + export) + _arguments \ + :machine:_vboxmachines \ + :export_option:_vboxopts_export + ;; + startvm) + _arguments \ + :machine:_vboxmachines \ + '--type:running mode:(gui sdl headless)' + ;; + controlvm) + _arguments \ + :machine:_vboxmachines \ + :controlvm_option:_vboxopts_controlvm + ;; + adoptstate) + _arguments \ + :machine:_vboxmachines \ + ':sav file:_files -g \*.sav' + ;; + closemedium) + _arguments \ + ':type:(disk dvd floppy)' \ + ':file:_files' \ + '--delete' + ;; + discardstate|bandwidthctl|getextradata|setextradata|debugvm) + _arguments \ + :machine:_vboxmachines + ;; + storagectl) + _arguments \ + :machine:_vboxmachines \ + '--name: :' \ + '--add:type:(ide scsi floppy sas)' \ + '--controller:type:(LSILogic|LSILogicSAS|BusLogic|IntelAHCI|PIIX3|PIIX4|ICH6|I82078)' \ + --sataideemulation{1..4}":port:({1..30})" \ + "--sataportcount:num:({1..30})" \ + '--hostiocache:bool:(on off)' \ + '--bootable:bool:(on off)' \ + '--remove' #" + ;; + storageattach) + _arguments \ + :machine:_vboxmachines\ + '--storagectl:storage ctl:("IDE Controller" "SATA Controller")' \ + '--port: :' \ + '--device: :' \ + '--type:drive type:(dvddrive hdd fdd)' \ + '--medium:mediums:_vboxmediums' \ + '--mtype:behaviour:(normal writethrough immutable shareable)' \ + '--comment: :' \ + '--passthrough:enabled?:(on off)' \ + '--bandwidthgroup: :' \ + '--forceunmount' '--server: :' \ + '--target: :' \ + '--lun: :' \ + '--encodedlun: :' \ + '--username: :' \ + '--password: :' \ + '--intnet: :' + ;; + createmedium|createhd) + _arguments \ + '--filename:filename:_files -g \*.{vdi,vmdk,vhd}' \ + '--size:megabytes:' \ + '--sizebyte:bytes:' \ + '--format:type:(VDI VMDK VHD)' \ + '--variant:type:(Standard Fixed Split2G Stream ESX)' + ;; + sharedfolder) + _arguments \ + ':action:(add remove)' \ + :machine:_vboxmachines \ + '--name: :' \ + '--hostpath:path:_files -/' \ + '--transient' \ + '--readonly' \ + '--automount' + ;; + natnetwork) + _arguments \ + ':action:(add modify remove start stop)' \ + '--netname:natnet:_vboxnatnets' \ + '--dhcp:bool:(on off)' \ + '--ipv6:bool:(on off)' \ + '--enable' \ + '--disable' + ;; + + esac + return 1 +} + +_vboxheadless() { + local context state line expl + local -A opt_args + + _arguments \ + '(-s -startvm --startvm)'{-s,-startvm,--startvm}'[Start given VM]:machine:_vboxmachines' \ + '(-n --vnc)'{-n,--vnc}'[Enable the built in VNC server]' \ + '(-m --vncport)'{-m,--vncport}'[TCP port number to use for the VNC server]:port:' \ + '(-o --vncpass)'{-o,--vncpass}'[Set the VNC server password]:pw:' \ + '(-v -vrde --vrde)'{-v,-vrde,--vrde}"[Enable (default) or disable the VRDE server or don't change the setting]::(on off config)" \ + '(-e -vrdeproperty --vrdeproperty)'{-e,-vrdeproperty,--vrdeproperty}'[Set a VRDE property]: :' \ + '(-c -capture --capture)'{-c,-capture,--capture}'[Record the VM screen output to a file]' \ + '(-w --width)'{-w,--width}'[Frame width when recording]:width:' \ + '(-h --height)'{-h,--height}'[Frame height when recording]:height:' \ + '(-r --bitrate)'{-r,--bitrate}'[Recording bit rate when recording]:bitrate:' \ + '(-f --filename)'{-f,--filename}'[File name when recording. The codec used will be chosen based on the file extension]:filename:_files' +} + +_virtualbox() { + local ret=1 + _call_function ret _$service + return ret +} + +_virtualbox "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_vnstat b/home/.zsh-server/plugins/zsh-completions/src/_vnstat new file mode 100644 index 0000000..fec8ae0 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_vnstat @@ -0,0 +1,124 @@ +#compdef vnstat +# ------------------------------------------------------------------------------ +# Copyright (c) 2012 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for vnstat 2.6 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Aaron Schrab +# +# ------------------------------------------------------------------------------ + +local curcontext="$curcontext" state state_descr line ret=1 +typeset -A opt_args + +local period="-d --days -h --hours -m --months -w --weeks" + +_arguments -C : \ + '--add[create database entry for interface specified]' \ + '(-b --begin)'{-b,--begin}'[begin the list output with a specific date]:date:' \ + '--config[specify alternate configuration file]:file:_files' \ + "($period)"{-d,--days}'[show traffic for days]' \ + "($period)"{-h,--hours}'[show traffic for last 24 hours]' \ + "($period)"{-m,--months}'[show traffic for months]' \ + "($period)"{-w,--weeks}'[show traffic for 7 days]' \ + "($period)"{-y,--years}'[show traffic statistics for the last year]' \ + "($period)"{-5,--fiveminutes}'[show traffic statistic with a 5 minute resolution for the last hours]' \ + '--dbdir[specify database directory]:directory:_files -/' \ + '(-D --debug)'{-D,--debug}'[show additional debug output]' \ + '(-e --end)'{-e,--end}'[end the list output with a specific date]:date:' \ + '--delete[delete database and stop monitoring selected interface]' \ + '--dumpdb[dump database in parseable format]' \ + '(--disable)--enable[enable updates for selected interface]' \ + '(--enable)--disable[disable updates for selected interface]' \ + '(-hg --hoursgraph)'{-hg,--hoursgraph}'[show traffic statistics using a bar graph]' \ + '(-i --iface)'{-i,--iface}'[specify interface for actions]:interface:->interface' \ + '--iflist[list available interfaces]' \ + '--limit[set the maximum number of shown entries]:limit:' \ + '(-l --live)'{-l,--live}'[display current transfer rate]:mode:->live' \ + '--json[show database content in json format]' \ + '--locale[specify locale]:locale:' \ + '--nick[set nickname for alias]:nickname:' \ + '--oneline[traffic summary in one-line, parseable format]' \ + '(-q --query)'{-q,--query}'[force database query mode]' \ + '--remove[delete the database entry for the interface specified]' \ + '--rename[rename the interface specified in the database with new name]' \ + '(-r --reset)'{-r,--reset}'[reset internal counters]' \ + '--setalias[set alias as an alias for the selected interface]:alias:' \ + '(-ru --rateunit)'{-ru,--rateunit}'[swap configured rate unit]' \ + '(-s --short)'{-s,--short}'[use short output mode]' \ + '--showconfig[show current configuration]' \ + '--style[modify content and style of output]:style:->style' \ + '--sync[synchronize internal counters]' \ + '--testkernel[test kernel boot time information]' \ + '(-t --top)'{-t,--top}'[show all time top traffic days]' \ + '(-tr --traffic)'{-tr,--traffic}'[calculate amount of traffic in given time]:seconds:' \ + '--xml[show database content in XML format]' \ + '(-)'{-v,--version}'[show current version]' \ + '(-)'{-\?,--help}'[show command summary]' \ + '(-)--longhelp[show complete options list]' \ + && ret=0 + +case "$state" in + + (live) + _values 'live mode' \ + '0[packets per second]' \ + '1[traffic counters]' && ret=0 + ;; + + (style) + _values 'output style' \ + '0[narrow output]' \ + '1[enable bar column]' \ + '2[bar column with average traffic rate]' \ + '3[enable average traffic rate]' \ + '4[disable use of terminal control characters]' && ret=0 + ;; + + (interface) + local interfaces="$(_call_program interfaces 'vnstat --iflist')" + interfaces="${interfaces#*:}" + _values -s + 'interface' ${(z)interfaces} && ret=0 + ;; + +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: filetype=zsh shiftwidth=2 tabstop=2 expandtab diff --git a/home/.zsh-server/plugins/zsh-completions/src/_wemux b/home/.zsh-server/plugins/zsh-completions/src/_wemux new file mode 100644 index 0000000..d38fc28 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_wemux @@ -0,0 +1,82 @@ +#compdef wemux +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for wemux (https://github.com/zolrath/wemux) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Akira Maeda +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ + +_wemux() { + + local -a host_commands client_commands multi_host_commands + + host_commands=( + 'start:Start the wemux server/attach to an existing wemux server.' + 'attach:Attach to an existing wemux server.' + 'stop:Kill the wemux server '\''wemux'\'', delete its socket.' + 'users:List all users currently attached to '\''wemux'\''' + 'kick:Disconnect an SSH user, remove their wemux server.' + 'config:Open the wemux configuration file in your $EDITOR.' + 'help:Display this screen.' + 'version:shows wemux version number' + ) + + client_commands=( + 'mirror:Attach to Host in read-only mode.' + 'pair:Attach to Host in pair mode, which allows editing.' + 'rogue:Attach to Host in rogue mode, which allows editing and switching to windows independently from the host.' + 'logout:Log out of the wemux rogueing session.' + 'users:List the currently attached wemux users.' + ) + + multi_host_commands=( + 'join:Join wemux server with supplied name.' + 'reset:Join default wemux server: wemux' + 'list:List all currently active wemux servers.' + ) + + if (( CURRENT == 2 )); then + _describe -t host_commands 'HOST COMMANDS' host_commands + _describe -t client_commands 'CLIENT COMMANDS' client_commands + _describe -t multi_host_commands 'MULTI-HOST COMMANDS' multi_host_commands + fi + + return 0 +} + +_wemux diff --git a/home/.zsh-server/plugins/zsh-completions/src/_wg-quick b/home/.zsh-server/plugins/zsh-completions/src/_wg-quick new file mode 100644 index 0000000..8de17ce --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_wg-quick @@ -0,0 +1,25 @@ +#compdef wg-quick +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for wg-quick (a script for easy managemant of wireguard +# VPN tunnels) (https://www.wireguard.com/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Nicolas Lenz +# +# ------------------------------------------------------------------------------ + +# The possible modes +local modes=('up\:"bring a wireguard interface up"'\ + 'down\:"tear down and remove a wireguard interface"'\ + 'save\:"save configuration of a running wireguard interface"') + +# 1: Complete mode +# 2: Complete interface with all .conf files in /etc/wireguard without the filename extension. +_arguments "1:mode:((${modes}))"\ + '2:interface:_path_files -W /etc/wireguard -g "*.conf(^/:r)"' diff --git a/home/.zsh-server/plugins/zsh-completions/src/_xinput b/home/.zsh-server/plugins/zsh-completions/src/_xinput new file mode 100644 index 0000000..9c0e9b2 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_xinput @@ -0,0 +1,208 @@ +#compdef xinput +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for xinput +# TODO: Add property handler +# TODO: Add buttons handler +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Timofey Titovets +# +# ------------------------------------------------------------------------------ +_xinput(){ + # list of xinput arguments + local -a _1st_arguments + _1st_arguments=( + 'version:show version' '--version:show version' + 'help:show help options' '--help:show help options' + get-feedbacks + set-ptr-feedback + set-integer-feedback + get-button-map + set-button-map + set-pointer + 'set-mode:change the mode of device' '--set-mode:change the mode of device' + 'list:show devices' '--list:show devices' + query-state + test --test + create-master + remove-master + reattach + float + set-cp + test-xi2 + map-to-output + list-props + set-int-prop + set-float-prop + set-atom-prop + watch-props + delete-prop + set-prop + 'disable:disable the device' '--disable:disable the device' + 'enable:enable the device' '--enable:enable the device' + --get-feedbacks + --set-ptr-feedback + --set-integer-feedback + --get-button-map + --set-button-map + --set-pointer + --query-state + --create-master + --remove-master + --reattach + --float + --set-cp + --test-xi2 + --map-to-output + --list-props + --set-int-prop + --set-float-prop + --set-atom-prop + --watch-props + --delete-prop + --set-prop + ) + + local context state line + local -A opt_args + # Used with "-O expl" for unsorted. + local -a expl + expl=(-Vx) + + _arguments '*:: :->subcmds' && return 0 + + if (( CURRENT == 1 )); then + _describe -t commands "xinput commands" _1st_arguments -V1 + return + fi + + typeset -a xinput_devices_id xinput_devices xinput_devices_name + local i name + for i in ${(on)$(xinput list --id-only)}; do + # Removing prefixes, e.g. from "∼ 7" (floating slave). + i=${i##[^[:digit:]]#} + [[ -n "$i" ]] || continue + xinput_devices_id+=($i) + name="$(xinput list --name-only $i)" + xinput_devices_name+=(${name//:/\\:}) + xinput_devices+=($i\:$name) + done + xinput_devices+=($xinput_devices_name) + + # xinput arguments handler + case "$words[1]" in + --get-feedbacks|--set-ptr-feedback|--get-button-map|--query-state|--list-props|--watch-props|get-feedbacks|set-ptr-feedback|get-button-map|query-state|list-props|watch-props|--enable|enable|--map-to-output|map-to-output|--disable|disable) + _arguments -O expl \ + ':list option:(($xinput_devices))' + ;; + --list|list) + _arguments -O expl \ + '--short' \ + '--long' \ + '--name-only' \ + '--id-only' \ + ':list option:(($xinput_devices))' \ + ;; + --set-integer-feedback|set-integer-feedback) + _arguments -O expl \ + ':list option:(($xinput_devices))' \ + ':list option:( feedback )' \ + ':list option:( $xinput_devices_id )' + ;; + --set-button-map|set-button-map) + _arguments -O expl \ + ':list option:(($xinput_devices))' #map button 1 [map button 2 [...]] + ;; + --set-pointer|set-pointer) + _arguments -O expl \ + ':list option:(($xinput_devices))' # [x index y index] + ;; + --set-mode|set-mode) + _arguments -O expl \ + ':list option:(($xinput_devices))' \ + ':list option:(ABSOLUTE RELATIVE)' + ;; + --test|test) + _arguments -O expl \ + ':list option:(-proximity ($xinput_devices ))' \ + ':list option:(($xinput_devices))' + ;; + --reattach|reattach) + _arguments -O expl \ + ':list option:(($xinput_devices))' \ + ':list option:(master slave)' + ;; + --float|float) + _arguments -O expl \ + ':list option:(($xinput_devices))' + ;; + --test-xi2|test-xi2) + _arguments -O expl \ + ':list option:(($xinput_devices --root))' \ + ':list option:(($xinput_devices))' + ;; + --delete-prop|delete-prop) + _arguments -O expl \ + ':list option:(($xinput_devices))' #property + ;; + --create-master|create-master) + _arguments -O expl \ + ':list option:(($xinput_devices))' # [sendCore (dflt:1)] [enable (dflt:1)] + ;; + --remove-master|remove-master) + _arguments -O expl \ + ':list option:($xinput_devices_id)' # [Floating|AttachToMaster (dflt:Floating)] [returnPointer] [returnKeyboard] + ;; + # --set-cp|set-cp); window device;; + --set-prop|set-prop) + _arguments -O expl \ + ':list option:(($xinput_devices))' \ + ':list option:(--type={atom,float,int} --format={8,16,32})' \ + ':list option:(--type={atom,float,int} --format={8,16,32})' # property val [val ...] + ;; + --set-int-prop|set-int-prop) + _arguments -O expl \ + ':list option:(($xinput_devices))' # property format (8, 16, 32) val [val ...] + ;; + --set-float-prop|set-float-prop) + _arguments -O expl \ + ':list option:(($xinput_devices))' # property val [val ...] + ;; + --set-atom-prop|set-atom-prop) + _arguments -O expl \ + ':list option:(($xinput_devices))' # property val [val ...] + ;; + esac +} + +_xinput "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_xsel b/home/.zsh-server/plugins/zsh-completions/src/_xsel new file mode 100644 index 0000000..3ba249b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_xsel @@ -0,0 +1,63 @@ +#compdef xsel +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for xsel (http://www.vergenet.net/~conrad/software/xsel/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Tomo Kazahaya (https://github.com/tomonacci) +# +# ------------------------------------------------------------------------------ + +local input='(-a --append -f --follow -i --input)' +local operation='(-c --clear -d --delete -k --keep -x --exchange)' +local selection='(-p --primary -s --secondary -b --clipboard)' + +_arguments -s \ + $input{-a,--append}'[append standard input to the selection]' \ + $input{-f,--follow}'[append to selection as standard input grows]' \ + $input{-i,--input}'[read standard input into the selection]' \ + {-o,--output}'[write the selection to standard output]' \ + $operation{-c,--clear}'[clear the selection]' \ + $operation{-d,--delete}'[request that the current selection be deleted]' \ + $selection{-p,--primary}'[operate on the PRIMARY selection (default)]' \ + $selection{-s,--secondary}'[operate on the SECONDARY selection]' \ + $selection{-b,--clipboard}'[operate on the CLIPBOARD selection]' \ + $operation{-k,--keep}'[do not modify the selections, but make the PRIMARY and SECONDARY selections persist even after the programs they were selected in exit]' \ + $operation{-x,--exchange}'[exchange the PRIMARY and SECONDARY selections]' \ + '--display[specify the server to use; see X(1)]:X display:_x_display' \ + {-t,--selectionTimeout}'[specify the timeout in milliseconds within which the selection must be retrieved]:number' \ + {-l,--logfile}'[specify the file to log errors to when detached (default $HOME/.xsel.log)]:log file:_files' \ + {-n,--nodetach}'[do not detach from the controlling terminal]' \ + {-h,--help}'[display usage information and exit]' \ + {-v,--verbose}'[print informative messages; additional instances of -v raise the debugging level]' \ + '--version[output version information and exit]' diff --git a/home/.zsh-server/plugins/zsh-completions/src/_yaourt b/home/.zsh-server/plugins/zsh-completions/src/_yaourt new file mode 100644 index 0000000..4727502 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_yaourt @@ -0,0 +1,368 @@ +#compdef yaourt yaourt.static=yaourt +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for yaourt (https://archlinux.fr/yaourt-en) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * zsh-users mailing list +# +# ------------------------------------------------------------------------------ + +# handles --help subcommand +_yaourt_action_help() { + _arguments -s : \ + "$_yaourt_opts_commands[@]" +} + +# handles cases where no subcommand has yet been given +_yaourt_action_none() { + _arguments -s : \ + "$_yaourt_opts_commands[@]" +} + +# handles --query subcommand +_yaourt_action_query() { + local context state line + typeset -A opt_args + +# _arguments -s : \ +# "$_yaourt_opts_common[@]" \ +# "$_yaourt_opts_query_actions[@]" \ +# "$_yaourt_opts_query_modifiers[@]" + + case $state in + query_file) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:package file:_files -g "*.pkg.tar*"' + ;; + query_group) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:groups:_yaourt_completions_installed_groups' + ;; + query_owner) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:file:_files' + ;; + query_search) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:search text: ' + ;; + *) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_actions[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:package:_yaourt_completions_installed_packages' + ;; + esac +} + +# handles --remove subcommand +_yaourt_action_remove() { + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_remove[@]" +} + +# handles --sync subcommand +_yaourt_action_sync() { + local context state line + typeset -A opt_args + +# _arguments -s : \ +# "$_yaourt_opts_common[@]" \ +# "$_yaourt_opts_sync_actions[@]" #\ +# #"$_yaourt_opts_sync_modifiers[@]" + + case $state in + sync_clean) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_sync_modifiers[@]" \ + '*-c[remove old packages from cache]' \ + ;; + sync_group) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_sync_modifiers[@]" \ + '*:package group:_yaourt_completions_all_groups' + ;; + sync_search) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_sync_modifiers[@]" \ + '*:search text: ' + ;; + *) + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_sync_modifiers[@]" \ + '*:package:_yaourt_completions_all_packages' + ;; + esac +} + +# handles --upgrade subcommand +_yaourt_action_upgrade() { + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_pkgfile[@]" +} + +# handles --version subcommand +_yaourt_action_version() { + # no further arguments + return 0 +} + +# provides completions for package groups +_yaourt_completions_all_groups() { + local -a cmd groups + _yaourt_get_command + groups=( $(_call_program groups $cmd[@] -Sg) ) + typeset -U groups + compadd "$@" -a groups +} + +# provides completions for packages available from repositories +# these can be specified as either 'package' or 'repository/package' +_yaourt_completions_all_packages() { + local -a cmd packages repositories packages_long + _yaourt_get_command + + if compset -P1 '*/*'; then + packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) ) + typeset -U packages + if [[ -d /var/aur ]]; then + packages=( $packages $(ls /var/aur) ) + fi + _wanted repo_packages expl "repository/package" compadd ${(@)packages} + else + packages=( $(_call_program packages $cmd[@] -Sql) ) + typeset -U packages + if [[ -d /var/aur ]]; then + packages=( $packages $(ls /var/aur) ) + fi + _wanted packages expl "packages" compadd - "${(@)packages}" + + repositories=(${(o)${${${(M)${(f)"$(query_group' + '-o[query the package that owns a file]:file:_files' + '-p[package file to query]:*:package file:->query_file' + '-s[search package names and descriptions]:*:search text:->query_search' + ) + + # options for passing to _arguments: options for --query and subcommands + typeset -a _yaourt_opts_query_modifiers + _yaourt_opts_query_modifiers=( + '-c[list package changelog]' + '-d[list packages installed as dependencies]' + '-e[list packages explicitly installed]' + '-i[view package information]' + '-ii[view package information including backup files]' + '-k[check package files]' + '-l[list package contents]' + '-m[list installed packages not found in sync db(s)]' + '-t[list packages not required by any package]' + '-u[list packages that can be upgraded]' + '--aur[install packages from aur, even if they are in community, or, with the -u option, update packages installed from aur]' + '--devel[used with -u updates all cvs/svn/git/hg/bzr packages]' + '--date[list packages sorted in ascending order (oldest first) by installation date]' + ) + + # options for passing to _arguments: options for --remove command + typeset -a _yaourt_opts_remove + _yaourt_opts_remove=( + '-c[remove all dependent packages]' + '-d[skip dependency checks]' + "-k[only remove database entry, don't remove files]" + '-n[remove protected configuration files]' + '-s[remove dependencies not required by other packages]' + '*:installed package:_yaourt_completions_installed_packages' + ) + + # options for passing to _arguments: options for --sync command + typeset -a _yaourt_opts_sync_actions + _yaourt_opts_sync_actions=( + '*-c[remove old packages from cache]:*:clean:->sync_clean' + '*-cc[remove all packages from cache]:*:clean:->sync_clean' + '-g[view all members of a package group]:*:package group:->sync_group' + '-s[search package names and descriptions]:*:search text:->sync_search' + ) + + # options for passing to _arguments: options for --sync command + typeset -a _yaourt_opts_sync_modifiers + _yaourt_opts_sync_modifiers=( + '-d[skip dependency checks]' + '-f[overwrite conflicting files]' + '-i[view package information]' + '-l[list all packages in a repository]' + '-p[print download URIs for each package to be installed]' + '-u[upgrade all out-of-date packages]' + '-w[download packages only]' + '-y[download fresh package databases]' + '*--ignore[ignore a package upgrade]:package: + _yaourt_completions_all_packages' + '*--ignoregroup[ignore a group upgrade]:package group: + _yaourt_completions_all_groups' + '--asdeps[install packages as non-explicitly installed]' + '--asexplicit[install packages as explicitly installed]' + "--needed[don't reinstall up to date packages]" + '--devel[used with -u updates all cvs/svn/git/hg/bzr packages]' + ) + + case $words[2] in + -Q*g*) # ipkg groups + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:groups:_yaourt_completions_installed_groups' + ;; + -Q*o*) # file + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:package file:_files' + ;; + -Q*p*) # file *.pkg.tar* + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_query_modifiers[@]" \ + '*:package file:_files -g "*.pkg.tar*"' + ;; + -Q*) _yaourt_action_query ;; + -R*) _yaourt_action_remove ;; + -S*c*) # no completion + return 0 + ;; + -S*l*) # repos + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_sync_modifiers[@]" \ + '*:package repo:_yaourt_completions_repositories' \ + ;; + -S*g*) # pkg groups + _arguments -s : \ + "$_yaourt_opts_common[@]" \ + "$_yaourt_opts_sync_modifiers[@]" \ + '*:package group:_yaourt_completions_all_groups' + ;; + -S*) _yaourt_action_sync ;; + -U*) _yaourt_action_upgrade ;; + -V*) _yaourt_action_version ;; + -h*) _yaourt_action_help ;; + - ) _yaourt_action_none ;; + * ) return 1 ;; + esac +} + +# run the main dispatcher +_yaourt "$@" diff --git a/home/.zsh-server/plugins/zsh-completions/src/_yarn b/home/.zsh-server/plugins/zsh-completions/src/_yarn new file mode 100644 index 0000000..1237ba6 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_yarn @@ -0,0 +1,502 @@ +#compdef yarn +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for yarn (https://yarnpkg.com/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# * Shohei YOSHIDA +# +# ------------------------------------------------------------------------------ + +declare -g _yarn_run_cwd + +_commands=( + 'access' + 'audit:Checks for known security issues with the installed packages' + 'autoclean:Clean and remove unnecessary files from package dependencies' + 'cache:List or clean every cached package' + "check:Verify package dependencies against yarn's lock file" + 'config:Manages the yarn configuration files' + 'create:Creates new projects from any create-* starter kits' + 'exec' + 'generate-lock-entry:Generates a lock file entry' + 'global:Install packages globally on your operating system' + 'help:Show information about a command' + 'import:Generate yarn.lock from an existing npm-installed node_modules folder' + 'info:Show information about a package' + 'init:Interactively creates or updates a package.json file' + 'install:Install all the dependencies listed within package.json' + 'licenses:List licenses for installed packages' + 'link:Symlink a package folder during development' + 'login:Store registry username and email' + 'logout:Clear registry username and email' + 'node:Runs Node with the same version that the one used by Yarn itself' + 'outdated:Check for outdated package dependencies' + 'owner:Manage package owners' + 'pack:Create a compressed gzip archive of package dependencies' + 'policies:Defines project-wide policies for your project' + 'publish:Publish a package to the npm registry' + 'run:Run a defined package script' + 'tag:Add, remove, or list tags on a package' + 'team:Maintain team memberships' + 'unlink:Unlink a previously created symlink for a package' + 'unplug:Temporarily copies a package outside of the global cache for debugging purposes' + 'version:Update the package version' + 'versions:Display version information of currently installed Yarn, Node.js, and its dependencies' + 'why:Show information about why a package is installed' + 'workspace' + 'workspaces:Show information about your workspaces' +) + +_global_commands=( + 'add:Installs a package and any packages that it depends on' + 'bin:Displays the location of the yarn bin folder' + 'list:List installed packages' + 'remove:Remove installed package from dependencies updating package.json' + 'upgrade:Upgrades packages to their latest version based on the specified range' + 'upgrade-interactive:Interactively upgrade packages' +) + +_yarn_find_package_json() { + local dir=$(cd "$1" && pwd) + + while true + do + if [[ -e "${dir}/package.json" ]]; then + echo "${dir}/package.json" + return + fi + + if [[ $dir == '/' ]]; then + break + fi + + dir=$(dirname $dir) + done +} + +_yarn_commands_scripts() { + local -a scripts binaries + local packageJson + + if [[ -n $opt_args[--cwd] ]]; then + packageJson=$(_yarn_find_package_json $opt_args[--cwd]) + binaries=($(cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t))) + else + packageJson=$(_yarn_find_package_json $pwd) + binaries=($(echo node_modules/.bin/*(x:t))) + fi + + if [[ -n $packageJson ]]; then + scripts=($(cat "$packageJson" | perl -0777 -MJSON::PP -n -E '$r=decode_json($_); do{($k=$_)=~s/:/\\:/g;say $k}for sort keys %{$r->{scripts}}')) + fi + + _describe 'command or script' _commands -- _global_commands -- scripts -- binaries +} + +_yarn_scripts() { + local -a binaries scripts + local -a commands + local packageJson + + if [[ -n $_yarn_run_cwd ]]; then + packageJson=$(_yarn_find_package_json $_yarn_run_cwd) + if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then + binaries=($(cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t))) + else + binaries=($(cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1')) + fi + else + packageJson=$(_yarn_find_package_json $pwd) + if [[ -d node_modules ]]; then + binaries=($(echo node_modules/.bin/*(x:t))) + else + binaries=($(yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1')) + fi + fi + + if [[ -n $packageJson ]]; then + scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}") + fi + + commands=('env' $scripts $binaries) + _describe 'command' commands +} + +_yarn_global_commands() { + local -a cmds + cmds=('ls:List installed packages') + _describe 'command' _global_commands +} + +_yarn_commands() { + _describe 'command' _commands -- _global_commands +} + +_yarn_add_files() { + if compset -P "(file|link):"; then + _files + fi +} + +_yarn_workspaces() { + local version=$(yarn --version |sed -n 's|\([0-9]*\).*|\1|p') + local -a workspaces + if [[ $version == "1" ]]; then + workspaces=(${(@f)$(yarn workspaces info |sed -n -e 's/^ "\([^"]*\)": {/\1/p')}) + else + workspaces=(${(@f)$(yarn workspaces list --json | sed -n 's|.*"name":"\([^"]*\)"}|\1|p')}) + fi + _describe 'workspace' workspaces +} + +_yarn() { + local context state state_descr line + typeset -A opt_args + + _arguments \ + '(-h --help)'{-h,--help}'[output usage information]' \ + '(-V --version)'{-V,--version}'[output the version number]' \ + '--verbose[output verbose messages on internal operations]' \ + '--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \ + '--check-files[install will verify file tree of packages for consistency]' \ + '--cwd=[working directory to use]:path:_files -/' \ + "(--enable-pnp --pnp)--disable-pnp[disable the Plug'n'Play installation]" \ + '(--no-emoji)--emoji=[enable emoji in output(default: false)]:enabled:(true false)' \ + '(--emoji)--no-emoji[disable emoji in output]' \ + '(--disable-pnp)'{--enable-pnp,--pnp}"[enable the Plug'n'Play installation]" \ + '--flat[only allow one version of a package]' \ + '--focus[Focus on a single workspace by installing remote copies of its sibling workspaces]' \ + '--force[install and build packages even if they were built before, overwrite lockfile]' \ + "--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \ + '--global-folder=[modules folder]:folder:_files -/' \ + '--har[save HAR output of network traffic]' \ + '--https-proxy=[HTTPS proxy]:host:_hosts' \ + '--ignore-engines[ignore engines check]' \ + "--ignore-scripts[don't run lifecycle scripts]" \ + '--ignore-optional[ignore optional dependencies]' \ + '--ignore-platform[ignore platform checks]' \ + '--json[format Yarn log messages as lines of JSON]' \ + '--link-duplicates[create hardlinks to the repeated modules in node_modules]' \ + '--link-folder=[specify a custom folder to store global links]' \ + '--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \ + '--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \ + '--network-concurrency=[maximum number of concurrent network requests]:number' \ + '--network-timeout=[TCP timeout for network requests]:milliseconds' \ + "--no-bin-links[don't generate bin links when setting up packages]" \ + '--no-default-rc[prevent Yarn from automatically detecting yarnrc and npmrc files]' \ + "--no-lockfile[don't read or generate a lockfile]" \ + '--non-interactive[do not show interactive prompts]' \ + '--no-node-version-check[do not warn when using a potentially unsupported Node version]' \ + '--no-progress[disable progress bar]' \ + '--offline[trigger an error if any required dependencies are not available in local cache]' \ + '--otp=[one-time password for two factor authentication]:otpcode' \ + '--prefer-offline[use network only if dependencies are not available in local cache]' \ + '--preferred-cache-folder=[specify a custom folder to store the yarn cache if possible]:folder:_files -/' \ + '(--prod --production)'{--prod,--production}'[install only production dependencies]' \ + '--proxy=[HTTP proxy]:host:_hosts' \ + "--pure-lockfile[don't generate a lockfile]" \ + '--registry=[override configuration registry]:url:_urls' \ + '(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \ + '--scripts-prepend-node-path=[prepend the node executable dir to the PATH in scripts]:bool:(true false)' \ + '--skip-integrity-check[run install without checking if node_modules is installed]' \ + "--strict-semver[don't compare semver loosely]" \ + '--update-checksum[update package checksums from current repository]' \ + '--use-yarnrc=[specifies a yarnrc that Yarn should use]:yarnrc:_files' \ + '1: :_yarn_commands_scripts' \ + '*:: :->command_args' + + + case $state in + command_args) + case $words[1] in + help) + _arguments \ + '1: :_yarn_commands' \ + ;; + + access) + _arguments \ + '1: :(public restricted grant revoke ls-packages ls-collaborators edit)' + ;; + + add) + _arguments \ + '(-D --dev)'{-D,--dev}'[install packages in devDependencies]' \ + '(-P --peer)'{-P,--peer}'[install packages in peerDependencies]' \ + '(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \ + '(-E --exact)'{-E,--exact}'[install packages as exact versions]' \ + '(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \ + '(--ignore-workspace-root-check -W)'{--ignore-workspace-root-check,-W}'[allows a package to be installed at the workspaces root]' \ + '--audit[checks for known security issues with the installed packages]' \ + '*:package-name:_yarn_add_files' + ;; + + audit) + _arguments \ + '--verbose[output verbose message]' \ + '--json[format Yarn log messages as lines of JSON]' \ + '--level=[only print advisories with severity greater than or equal to]:level:(info low moderate high critical)' \ + '--groups=[only audit dependencies from listed groups]:groups:->groups_args' + ;; + + cache) + _arguments \ + '1: :(list dir clean)' \ + '*:: :->cache_args' + ;; + + check) + _arguments \ + '--integrity[Verifies that versions and hashed values of the package contents in package.json]' \ + '--verify-tree[Recursively verifies that the dependencies in package.json are present in node_modules]' + ;; + + config) + _arguments \ + '1: :(set get delete list)' \ + '*:: :->config_args' + ;; + + global) + _arguments \ + '--prefix=[bin prefix to use to install binaries]' \ + '1: :_yarn_global_commands' \ + '*:: :->command_args' + ;; + + info) + _arguments \ + '1:package:' \ + '2:field' + ;; + + init) + _arguments \ + '(-y --yes)'{-y,--yes}'[install packages in devDependencies]' + ;; + + licenses) + _arguments \ + '1: :(ls generate-disclaimer)' \ + ;; + + link|unlink|outdated) + _arguments \ + '1:package' \ + ;; + + list) + _arguments \ + '--depth=[Limit the depth of the shown dependencies]:depth' \ + '--pattern=[filter the list of dependencies by the pattern]' + ;; + + owner) + _arguments \ + '1: :(list add rm)' \ + '*:: :->owner_args' + ;; + + pack) + _arguments \ + '(-f --filename)'{-f,--filename}':filename:_files' + ;; + + publish) + _arguments \ + '--new-version:version:' \ + '--message:message:' \ + '--no-git-tag-version' \ + '--access:access:' \ + '--tag:tag:' \ + '1: :_files' + ;; + + policies) + _arguments \ + '1: :(set-version)' + ;; + + remove|upgrade) + _arguments \ + '*:package:' + ;; + + run) + if [[ -n $opt_args[--cwd] ]]; then + _yarn_run_cwd=$opt_args[--cwd] + else + _yarn_run_cwd='' + fi + _arguments \ + '1: :_yarn_scripts' \ + '*:: :_default' + ;; + + tag) + _arguments \ + '1: :(lists add rm)' \ + '*:: :->tag_args' + ;; + + team) + _arguments \ + '1: :(create destroy add rm list)' \ + '*:: :->team_args' + ;; + + upgrade-interactive) + _arguments \ + '--latest[use the version tagged latest in the registry]' + ;; + + version) + _arguments \ + '--new-version[create a new version using an interactive session to prompt you]:version:' \ + '--major[creates a new version by incrementing the major version]' \ + '--minor[creates a new version by incrementing the minor version]' \ + '--patch[creates a new version by incrementing the patch version]' \ + '--premajor[creates a new prerelease version by incrementing the major version]' \ + '--preminor[creates a new prerelease version by incrementing the minor version]' \ + '--prepatch[creates a new prerelease version by incrementing the patch version]' \ + '--prerelease[increments the prerelease version number keeping the main version]' \ + '--no-git-tag-version[creates a new version without creating a git tag]' \ + '--no-commit-hooks[bypasses running commit hooks when committing the new version]' + ;; + + why) + _arguments \ + '1:query:_files' + ;; + + workspace) + _arguments \ + '1:workspace:_yarn_workspaces' \ + '*:: :_yarn_global_commands' + ;; + + workspaces) + _arguments \ + '--json[format Yarn log messages as lines of JSON]' \ + '1:commands:(info run)' + ;; + + *) + _default + ;; + esac + ;; + esac + + case $state in + cache_args) + if [[ $words[1] == "list" ]]; then + _arguments \ + '--pattern=[print out every cached package that matches the pattern]:pattern:' + fi + ;; + config_args) + case $words[1] in + get|delete) + _arguments \ + '1:key:' + ;; + + set) + _arguments \ + '(-g --global)'{-g,--global} \ + '1:key:' \ + '2:value:' + ;; + esac + ;; + groups_args) + local dependency_groups=(devDependencies dependencies optionalDependencies peerDependencies bundledDependencies) + _values -s ',' 'groups' $dependency_groups + ;; + + owner_args) + case $words[1] in + ls) + _arguments \ + '1:package:' + ;; + + add|rm) + _arguments \ + '1:user:' \ + '2:package:' + ;; + esac + ;; + + tag_args) + case $words[1] in + ls) + _arguments \ + '1:package' + ;; + + add|rm) + _arguments \ + '1:package:' \ + '2:tag:' + ;; + esac + ;; + + team_args) + case $words[1] in + create|destroy|ls) + _arguments \ + '1:scope\:team:' + ;; + + add|rm) + _arguments \ + '1:scope\:team:' \ + '2:user:' + ;; + esac + ;; + esac +} + +_yarn "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/src/_zcash-cli b/home/.zsh-server/plugins/zsh-completions/src/_zcash-cli new file mode 100644 index 0000000..70ffa40 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/src/_zcash-cli @@ -0,0 +1,181 @@ +#compdef zcash-cli +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for zcash-cli (https://z.cash). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jordy van Wolferen (https://github.com/jvwdev) +# +# ------------------------------------------------------------------------------ + +local state line curcontext="$curcontext" ret=1 + +_arguments -C \ + '-?[display usage information]' \ + -conf='[specify configuration file]:file [zcash.conf]:_files' \ + -datadir='[specify data directory]:directory:_directories' \ + -testnet'[use the test network]' \ + -regtest'[enter regression test mode, which uses a special chain in which blocks can be solved instantly. This is intended for regression testing tools and app development.]' \ + -rpcconnect='[send commands to node running on specified ip]:rpcconnect [127.0.0.1]:_hosts' \ + -rpcport='[connect to JSON-RPC on specified port]: :_guard "[[\:digit\:]]#" "port [8232 or testnet\: 18232]"' \ + -rpcwait'[wait for RPC server to start]' \ + -rpcuser='[username for JSON-RPC connections]:rpcuser' \ + -rpcpassword='[password for JSON-RPC connections]:rpcpassword' \ + -rpcclienttimeout='[specify timeout during HTTP requests, or 0 for no timeout]: :_guard "[[\:digit\:]]#" "timeout (seconds) [900]"' \ + ':subcommand:->subcommand' && ret=0 + +case $state in + subcommand) + subcommands=( + 'getbestblockhash' + 'getblock' + 'getblockchaininfo' + 'getblockcount' + 'getblockhash' + 'getblockheader' + 'getchaintips' + 'getdifficulty' + 'getmempoolinfo' + 'getrawmempool' + 'gettxout' + 'gettxoutproof' + 'gettxoutsetinfo' + 'verifychain' + 'verifytxoutproof' + 'getinfo' + 'help' + 'stop' + 'generate' + 'getgenerate' + 'setgenerate' + 'getblocksubsidy' + 'getblocktemplate' + 'getlocalsolps' + 'getmininginfo' + 'getnetworkhashps' + 'getnetworksolps' + 'prioritisetransaction' + 'submitblock' + 'addnode' + 'clearbanned' + 'disconnectnode' + 'getaddednodeinfo' + 'getconnectioncount' + 'getnettotals' + 'getnetworkinfo' + 'getpeerinfo' + 'listbanned' + 'ping' + 'setban' + 'createrawtransaction' + 'decoderawtransaction' + 'decodescript' + 'fundrawtransaction' + 'getrawtransaction' + 'sendrawtransaction' + 'signrawtransaction' + 'createmultisig' + 'estimatefee' + 'estimatepriority' + 'validateaddress' + 'verifymessage' + 'z_validateaddress' + 'addmultisigaddress' + 'backupwallet' + 'dumpprivkey' + 'dumpwallet' + 'encryptwallet' + 'getaccount' + 'getaccountaddress' + 'getaddressesbyaccount' + 'getbalance' + 'getnewaddress' + 'getrawchangeaddress' + 'getreceivedbyaccount' + 'getreceivedbyaddress' + 'gettransaction' + 'getunconfirmedbalance' + 'getwalletinfo' + 'importaddress' + 'importprivkey' + 'importwallet' + 'keypoolrefill' + 'listaccounts' + 'listaddressgroupings' + 'listlockunspent' + 'listreceivedbyaccount' + 'listreceivedbyaddress' + 'listsinceblock' + 'listtransactions' + 'listunspent' + 'lockunspent' + 'move' + 'sendfrom' + 'sendmany' + 'sendtoaddress' + 'setaccount' + 'settxfee' + 'signmessage' + 'z_exportkey' + 'z_exportwallet' + 'z_getbalance' + 'z_getnewaddress' + 'z_getoperationresult' + 'z_getoperationstatus' + 'z_gettotalbalance' + 'z_importkey' + 'z_importwallet' + 'z_listaddresses' + 'z_listoperationids' + 'z_listreceivedbyaddress' + 'z_sendmany' + 'zcbenchmark' + 'zcrawjoinsplit' + 'zcrawkeygen' + 'zcrawreceive' + 'zcsamplejoinsplit' + ) + + _describe -t subcommands 'zcash-cli subcommand' subcommands && ret=0 + ;; +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/home/.zsh-server/plugins/zsh-completions/zsh-completions-howto.org b/home/.zsh-server/plugins/zsh-completions/zsh-completions-howto.org new file mode 100644 index 0000000..0ea805b --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/zsh-completions-howto.org @@ -0,0 +1,464 @@ +* Table of Contents :TOC: +- [[#intro][Intro]] +- [[#getting-started][Getting started]] + - [[#telling-zsh-which-function-to-use-for-completing-a-command][Telling zsh which function to use for completing a command]] + - [[#completing-generic-gnu-commands][Completing generic gnu commands]] + - [[#copying-completions-from-another-command][Copying completions from another command]] +- [[#writing-your-own-completion-functions][Writing your own completion functions]] + - [[#utility-functions][Utility functions]] + - [[#writing-simple-completion-functions-using-_describe][Writing simple completion functions using _describe]] + - [[#writing-completion-functions-using-_alternative][Writing completion functions using _alternative]] + - [[#writing-completion-functions-using-_arguments][Writing completion functions using _arguments]] + - [[#writing-completion-functions-using-_regex_arguments-and-_regex_words][Writing completion functions using _regex_arguments and _regex_words]] + - [[#complex-completions-with-_values-_sep_parts--_multi_parts][complex completions with _values, _sep_parts, & _multi_parts]] + - [[#adding-completion-words-directly-using-compadd][Adding completion words directly using compadd]] +- [[#testing--debugging][Testing & debugging]] +- [[#gotchas-things-to-watch-out-for][Gotchas (things to watch out for)]] +- [[#tips][Tips]] +- [[#other-resources][Other resources]] + +* Intro +The official documentation for writing zsh completion functions is difficult to understand, and doesn't give many examples. +At the time of writing this document I was able to find a few other tutorials on the web, however those tutorials only +explain a small portion of the capabilities of the completion system. This document aims to cover areas not explained elsewhere, +with examples, so that you can learn how to write more advanced completion functions. I do not go into all the details, but will +give enough information and examples to get you up and running. If you need more details you can look it up for yourself in the + [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][official documentation]]. + +Please make any scripts that you create publicly available for others (e.g. by forking this repo and making a [[id:64bcd501-b0f0-48c7-b8e2-07af708b95ec][pull request]]). +Also if you have any more information to add or improvements to make to this tutorial, please do. +* Getting started +** Telling zsh which function to use for completing a command +Completion functions for commands are stored in files with names beginning with an underscore _, and these files should +be placed in a directory listed in the $fpath variable. +You can add a directory to $fpath by adding a line like this to your ~/.zshrc file: +#+BEGIN_SRC sh +fpath=(~/newdir $fpath) +#+END_SRC +The first line of a completion function file can look something like this: +#+BEGIN_SRC sh +#compdef foobar +#+END_SRC +This tells zsh that the file contains code for completing the foobar command. +This is the format that you will use most often for the first line, but you can also use the same file for completing +several different functions if you want. See [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Autoloaded-files][here]] for more details. + +You can also use the compdef command directly (e.g. in your ~/.zshrc file) to tell zsh which function to use for completing +a command like this: +#+BEGIN_SRC sh +> compdef _function foobar +#+END_SRC +or to use the same completions for several commands: +#+BEGIN_SRC sh +> compdef _function foobar goocar hoodar +#+END_SRC +or if you want to supply arguments: +#+BEGIN_SRC sh +> compdef '_function arg1 arg2' foobar +#+END_SRC +See [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Functions-4][here]] for more details. +** Completing generic gnu commands +Many [[http://www.gnu.org/][gnu]] commands have a standardized way of listing option descriptions (when the --help option is used). +For these commands you can use the _gnu_generic function for automatically creating completions, like this: +#+BEGIN_SRC sh +> compdef _gnu_generic foobar +#+END_SRC +or to use _gnu_generic with several different commands: +#+BEGIN_SRC sh +> compdef _gnu_generic foobar goocar hoodar +#+END_SRC +This line can be placed in your ~/.zshrc file. +** Copying completions from another command +If you want a command, say cmd1, to have the same completions as another, say cmd2, which has already had +completions defined for it, you can do this: +#+BEGIN_SRC sh +> compdef cmd1=cmd2 +#+END_SRC +This can be useful for example if you have created an alias for a command to help you remember it. +* Writing your own completion functions +A good way to get started is to look at some already defined completion functions. +On my linux installation these are found in /usr/share/zsh/functions/Completion/Unix +and /usr/share/zsh/functions/Completion/Linux and a few other subdirs. + +You will notice that the _arguments function is used a lot in these files. +This is a utility function that makes it easy to write simple completion functions. +The _arguments function is a wrapper around the compadd builtin function. +The compadd builtin is the core function used to add completion words to the command line, and control its behaviour. +However, most of the time you will not need to use compadd, since there are many utility functions such as _arguments +and _describe which are easier to use. + +For very basic completions the _describe function should be adequate + +** Utility functions +Here is a list of some of the utility functions that may be of use. +The full list of utility functions, with full explanations, is available [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions][here]]. +Examples of how to use these functions are given in the next section. + +*** main utility functions for overall completion +| _alternative | Can be used to generate completion candidates from other utility functions or shell code. | +| _arguments | Used to specify how to complete individual options & arguments for a command with unix style options. | +| _describe | Used for creating simple completions consisting of words with descriptions (but no actions). Easier to use than _arguments | +| _gnu_generic | Can be used to complete options for commands that understand the `--help' option. | +| _regex_arguments | Creates a function for matching commandline arguments with regular expressions, and then performing actions/completions. | +*** functions for performing complex completions of single words +| _values | Used for completing arbitrary keywords (values) and their arguments, or comma separated lists of such combinations. | +| _combination | Used to complete combinations of values, for example pairs of hostnames and usernames. | +| _multi_parts | Used for completing multiple parts of words separately where each part is separated by some char, e.g. for completing partial filepaths: /u/i/sy -> /usr/include/sys | +| _sep_parts | Like _multi_parts but allows different separators at different parts of the completion. | +| _sequence | Used as a wrapper around another completion function to complete a delimited list of matches generated by that other function. +*** functions for completing specific types of objects +| _path_files | Used to complete filepaths. Take several options to control behaviour. | +| _files | Calls _path_files with all options except -g and -/. These options depend on file-patterns style setting. | +| _net_interfaces | Used for completing network interface names | +| _users | Used for completing user names | +| _groups | Used for completing group names | +| _options | Used for completing the names of shell options. | +| _parameters | Used for completing the names of shell parameters/variables (can restrict to those matching a pattern). | +*** functions for handling cached completions +If you have a very large number of completions you can save them in a cache file so that the completions load quickly. +| _cache_invalid | indicates whether the completions cache corresponding to a given cache identifier needs rebuilding | +| _retrieve_cache | retrieves completion information from a cache file | +| _store_cache | store completions corresponding to a given cache identifier in a cache file | +*** other functions +| _message | Used for displaying help messages in places where no completions can be generated. | +| _regex_words | Can be used to generate arguments for the _regex_arguments command. This is easier than writing the arguments manually. | +| _guard | Can be used in the ACTION of specifications for _arguments and similar functions to check the word being completed. | +*** Actions +Many of the utility functions such as _arguments, _regex_arguments, _alternative and _values may include an action +at the end of an option/argument specification. This action indicates how to complete the corresponding argument. +The actions can take one of the following forms: +| ( ) | Argument is required but no matches are generated for it. | +| (ITEM1 ITEM2) | List of possible matches | +| ((ITEM1\:'DESC1' ITEM2\:'DESC2')) | List of possible matches, with descriptions. Make sure to use different quotes than those around the whole specification. | +| ->STRING | Set $state to STRING and continue ($state can be checked in a case statement after the utility function call) | +| FUNCTION | Name of a function to call for generating matches or performing some other action, e.g. _files or _message | +| {EVAL-STRING} | Evaluate string as shell code to generate matches. This can be used to call a utility function with arguments, e.g. _values or _describe | +| =ACTION | Inserts a dummy word into completion command line without changing the point at which completion takes place. | +Not all action types are available for all utility functions that use them. For example the ->STRING type is not available in the +_regex_arguments or _alternative functions. +** Writing simple completion functions using _describe +The _describe function can be used for simple completions where the order and position of the options/arguments is +not important. You just need to create an array parameter to hold the options & their descriptions, and then pass +the parameter name as an argument to _describe. The following example creates completion candidates c and d, with +the descriptions (note this should be put in a file called _cmd in some directory listed in $fpath). +#+BEGIN_SRC sh +#compdef cmd +local -a subcmds +subcmds=('c:description for c command' 'd:description for d command') +_describe 'command' subcmds +#+END_SRC + +You can use several different lists separated by a double hyphen as follows but note that this mixes the matches under and single heading and is not intended to be used with different types of completion candidates: +#+BEGIN_SRC sh +local -a subcmds topics +subcmds=('c:description for c command' 'd:description for d command') +topics=('e:description for e help topic' 'f:description for f help topic') +_describe 'command' subcmds -- topics +#+END_SRC + +If two candidates have the same description, _describe collects them together on the same row and ensures that descriptions are aligned in neatly in columns. +The _describe function can be used in an ACTION as part of a specification for _alternative, _arguments or _regex_arguments. +In this case you will have to put it in braces with its arguments, e.g. 'TAG:DESCRIPTION:{_describe 'values' options}' +** Writing completion functions using _alternative +Like _describe, this function performs simple completions where the order and position of options/arguments is not important. +However, unlike _describe, instead of fixed matches further functions may be called to generate the completion candidates. Furthermore, _alternative allows a mix of different types of completion candidates to be mixed. + +As arguments it takes a list of specifications each in the form 'TAG:DESCRIPTION:ACTION' where TAG is a special tag that identifies the type of completion matches, +DESCRIPTION is used as a heading to describe the group of completion candidates collectively, and ACTION is one of the action types listed previously (apart from the ->STRING and =ACTION forms). +For example: +#+BEGIN_SRC sh +_alternative 'arguments:custom arg:(a b c)' 'files:filename:_files' +#+END_SRC +The first specification adds completion candidates a, b & c, and the second specification calls the _files function for completing filepaths. + +We could split the specifications over several lines with \ and add descriptions to each of the custom args like this: +#+BEGIN_SRC sh +_alternative \ + 'args:custom arg:((a\:"description a" b\:"description b" c\:"description c"))' \ + 'files:filename:_files' +#+END_SRC + +If we want to pass arguments to _files they can simply be included, like this: +#+BEGIN_SRC sh +_alternative \ + 'args:custom arg:((a\:"description a" b\:"description b" c\:"description c"))'\ + 'files:filename:_files -/' +#+END_SRC + +To use parameter expansion to create our list of completions we must use double quotes to quote the specifications, +e.g: +#+BEGIN_SRC sh +_alternative \ + "dirs:user directory:($userdirs)" \ + "pids:process ID:($(ps -A o pid=))" +#+END_SRC +In this case the first specification adds the words stored in the $userdirs variable, and the second specification +evaluates 'ps -A o pid=' to get a list of pids to use as completion candidates. In practice, we would make used of the existing _pids function for this. + +We can use other utility functions such as _values in the ACTION to perform more complex completions, e.g: +#+BEGIN_SRC sh +_alternative \ + "directories:user directory:($userdirs)" \ + 'options:comma-separated opt: _values -s , letter a b c' +#+END_SRC +this will complete the items in $userdirs, as well as a comma separated list containing a, b &/or c. Note the use of the initial space before _values. This is needed because _values doesn't understand standard compadd options for descriptions. + +As with _describe, the _alternative function can itself be used in an ACTION as part of a specification for _arguments +or _regex_arguments. +** Writing completion functions using _arguments +With a single call to the _arguments function you can create fairly sophisticated completion functions. It is intended to handle typical commands that take a variety of options along with some normal arguments. +Like the _alternative function, _arguments takes a list of specification strings as arguments. +These specification strings specify options and any corresponding option arguments (e.g. -f filename), +or command arguments. + +Basic option specifications take the form '-OPT[DESCRIPTION]', e.g. like this: +#+BEGIN_SRC sh +_arguments '-s[sort output]' '--l[long output]' '-l[long output]' +#+END_SRC +Arguments for the option can be specified after the option description in this form '-OPT[DESCRIPTION]:MESSAGE:ACTION', +where MESSAGE is a message to display and ACTION can be any of the forms mentioned in the ACTIONS section above. +For example: +#+BEGIN_SRC sh +_arguments '-f[input file]:filename:_files' +#+END_SRC + +Command argument specifications take the form 'N:MESSAGE:ACTION' where N indicates that it is the Nth command argument, +and MESSAGE & ACTION are as before. If the N is omitted then it just means the next command argument (after any that have +already been specified). If a double colon is used at the start (after N) then the argument is optional. +For example: +#+BEGIN_SRC sh +_arguments '-s[sort output]' '1:first arg:_net_interfaces' '::optional arg:_files' ':next arg:(a b c)' +#+END_SRC +here the first arg is a network interface, the next optional arg is a file name, the last arg can be either a, b or c, +and the -s option may be completed at any position. + +The _arguments function allows the full set of ACTION forms listed in the ACTION section above. +This means that you can use actions for selecting case statement branches like this: +#+BEGIN_SRC sh +_arguments '-m[music file]:filename:->files' '-f[flags]:flag:->flags' +case "$state" in + files) + local -a music_files + music_files=( Music/**/*.{mp3,wav,flac,ogg} ) + _multi_parts / music_files + ;; + flags) + _values -s , 'flags' a b c d e + ;; +esac +#+END_SRC +In this case paths to music files are completed stepwise descending down directories using the _multi_parts function, +and the flags are completed as a comma separated list using the _values function. + +I have just given you the basics of _arguments specifications here, you can also specify mutually exclusive options, +repeated options & arguments, options beginning with + instead of -, etc. For more details see the [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][official documentation]]. +Also have a look at the tutorials mentioned at the end of this document, and the completion functions in the [[https://github.com/vapniks/zsh-completions/tree/master/src][src directory]]. +** Writing completion functions using _regex_arguments and _regex_words +If you have a complex command line specification with several different possible argument sequences then +the _regex_arguments function may be what you need. It typically works well where you have a series of keywords followed by a variable number of arguments. + +_regex_arguments creates a completion function whose name is given by the first argument. +Hence you need to first call _regex_arguments to create the completion function, and then call that function, +e.g. like this: +#+BEGIN_SRC sh +_regex_arguments _cmd OTHER_ARGS.. +_cmd "$@" +#+END_SRC + +The OTHER_ARGS should be sequences of specifications for matching & completing words on the command line. +These sequences can be separated by '|' to represent alternative sequences of words. +You can use bracketing to arbitrary depth to specify alternate subsequences, but the brackets must be backslashed like this \( \) +or quoted like this '(' ')'. + +For example: +#+BEGIN_SRC sh +_regex_arguments _cmd SEQ1 '|' SEQ2 \( SEQ2a '|' SEQ2b \) +_cmd "$@" +#+END_SRC +This specifies a command line matching either SEQ1, or SEQ2 followed by SEQ2a or SEQ2b. You are describing the form arguments to the command take in the form of a regular expression grammar. + +Each specification in a sequence must contain a / PATTERN/ part at the start followed by an optional ':TAG:DESCRIPTION:ACTION' +part. + +Each PATTERN is a regular expression to match a word on the command line. These patterns are processed sequentially +until we reach a pattern that doesn't match at which point any corresponding ACTION is performed to obtain completions +for that word. Note that there needs to be a pattern to match the initial command itself. +See below for further explanation about PATTERNs. + +The ':TAG:DESCRIPTION:ACTION' part is interpreted in the same way as for the _alternative function specifications, +except that it has an extra : at the start, and now all of the possible ACTION formats listed previously are allowed. + +Here is an example: +#+BEGIN_SRC sh +_regex_arguments _cmd /$'[^\0]##\0'/ \( /$'word1(a|b|c)\0'/ ':word:first word:(word1a word1b word1c)' '|'\ + /$'word11(a|b|c)\0'/ ':word:first word:(word11a word11b word11c)' \( /$'word2(a|b|c)\0'/ ':word:second word:(word2a word2b word2c)'\ + '|' /$'word22(a|b|c)\0'/ ':word:second word:(word22a word22b word22c)' \) \) +_cmd "$@" +#+END_SRC +in this case the first word can be word1 or word11 followed by an a, b or c, and if the first word contains 11 then a second +word is allowed which can be word2 followed by and a, b, or c, or a filename. + +If this sounds too complicated a much simpler alternative is to use the _regex_words function for creating +specifications for _regex_arguments. +*** Patterns +You may notice that the / PATTERN/ specs in the previous example don't look like normal regular expressions. +Often a string parameter in the form $'foo\0' is used. This is so that the \0 in the string is interpreted correctly +as a null char which is used to separate words in the internal representation. If you don't include the \0 at the end +of the pattern you may get problems matching the next word. If you need to use the contents of a variable in a pattern, +you can double quote it so that it gets expanded and then put a string parameter containing a null char afterwards, +like this: "$somevar"$'\0' + +The regular expression syntax for patterns seems to be a bit different from normal regular expressions, +and I can't find documentation anywhere. +However I have managed to work out what the following special chars are for: +| * | wildcard - any number of chars | +| ? | wildcard - single char | +| # | zero or more of the previous char (like * in a normal regular expression) | +| ## | one or more of the previous char (like + in a normal regular expression) | +*** _regex_words +The _regex_words function makes it much easier to create specifications for _regex_arguments. +The results of calling _regex_words can be stored in a variable which can then be used instead +of a specification for _regex_arguments. + +To create a specification using _regex_words you supply it with a tag followed by a description followed by a list +of specifications for individual words. These specifications take the form 'WORD:DESCRIPTION:SPEC' where WORD is the +word to be completed, DESCRIPTION is a description for it, and SPEC can be another variable created by _regex_words +specifying words that come after the current word or blank if there are no further words. +For example: +#+BEGIN_SRC sh +_regex_words firstword 'The first word' 'word1a:a word:' 'word1b:b word:' 'word1c:c word' +#+END_SRC +the results of this function call will be stored in the $reply array, and so we should store it in another array +before $reply gets changed again, like this: +#+BEGIN_SRC sh +local -a firstword +_regex_words word 'The first word' 'word1a:a word:' 'word1b:b word:' 'word1c:c word' +firstword="$reply[@]" +#+END_SRC +we could then use it with _regex_arguments like this: +#+BEGIN_SRC sh +_regex_arguments _cmd /$'[^\0]##\0'/ "$firstword[@]" +_cmd "$@" +#+END_SRC +Note that I have added an extra pattern for the initial command word itself. + +Here is a more complex example where we call _regex_words for different words on the command line +#+BEGIN_SRC sh +local -a firstword firstword2 secondword secondword2 +_regex_words word1 'The second word' 'woo:tang clan' 'hoo:not me' +secondword=("$reply[@]") +_regex_words word2 'Another second word' 'yee:thou' 'haa:very funny!' +secondword2=("$reply[@]") +_regex_words commands 'The first word' 'foo:do foo' 'man:yeah man' 'chu:at chu' +firstword=("$reply[@]") +_regex_words word4 'Another first word' 'boo:scare somebody:$secondword' 'ga:baby noise:$secondword'\ + 'loo:go to the toilet:$secondword2' +firstword2=("$reply[@]") + +_regex_arguments _hello /$'[^\0]##\0'/ "${firstword[@]}" "${firstword2[@]}" +_hello "$@" +#+END_SRC +In this case the first word can be one of "foo", "man", "chu", "boo", "ga" or "loo". +If the first word is "boo" or "ga" then the second word can be "woo" or "hoo", +and if the first word is "loo" then the second word can be "yee" or "haa", in the other +cases there is no second word. + +For a good example of the usage of _regex_words have a look at the _ip function. +** complex completions with _values, _sep_parts, & _multi_parts +The _values, _sep_parts & _multi_parts functions can be used either on their own, or as ACTIONs in specifications for +_alternative, _arguments or _regex_arguments. The following examples may be instructive. +See the [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][official documentation]] for more info. + +Space separated list of mp3 files: +#+BEGIN_SRC sh +_values 'mp3 files' ~/*.mp3 +#+END_SRC + +Comma separated list of session id numbers: +#+BEGIN_SRC sh +_values -s , 'session id' "${(uonzf)$(ps -A o sid=)}" +#+END_SRC + +Completes foo@news:woo, or foo@news:laa, or bar@news:woo, etc: +#+BEGIN_SRC sh +_sep_parts '(foo bar)' @ '(news ftp)' : '(woo laa)' +#+END_SRC + +Complete some MAC addresses one octet at a time: +#+BEGIN_SRC sh +_multi_parts : '(00:11:22:33:44:55 00:23:34:45:56:67 00:23:45:56:67:78)' +#+END_SRC + +** Adding completion words directly using compadd +For more fine grained control you can use the builtin compadd function to add completion words directly. +This function has many different options for controlling how completions are displayed and how text on the command line +can be altered when words are completed. Read the [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][official documentation]] for full details. +Here I just give a few simple examples. + +Add some words to the list of possible completions: +#+BEGIN_SRC sh +compadd foo bar blah +#+END_SRC + +As above but also display an explanation: +#+BEGIN_SRC sh +compadd -X 'Some completions' foo bar blah +#+END_SRC + +As above but automatically insert a prefix of "what_" before the completed word: +#+BEGIN_SRC sh +compadd -P what_ foo bar blah +#+END_SRC + +As above but automatically insert a suffix of "_todo" after the completed word: +#+BEGIN_SRC sh +compadd -S _todo foo bar blah +#+END_SRC + +As above but automatically remove the "_todo" suffix if a blank char is typed after the suffix: +#+BEGIN_SRC sh +compadd -P _todo -q foo bar blah +#+END_SRC + +Add words in array $wordsarray to the list of possible completions +#+BEGIN_SRC sh +compadd -a wordsarray +#+END_SRC + +* Testing & debugging +To reload a completion function: +#+BEGIN_SRC sh +> unfunction _func +> autoload -U _func +#+END_SRC + +The following functions can be called to obtain useful information. +If the default keybindings don't work you can try pressing Alt+x and then enter the command name. +| Function | Default keybinding | Description | +|-----------------+--------------------+--------------------------------------------------------------------------------------------------------------------------------| +| _complete_help | Ctrl+x h | displays information about context names, tags, and completion functions used when completing at the current cursor position | +| _complete_help | Alt+2 Ctrl+x h | as above but displays even more information | +| _complete_debug | Ctrl+x ? | performs ordinary completion, but captures in a temporary file a trace of the shell commands executed by the completion system | +* Gotchas (things to watch out for) +Remember to include a #compdef line at the beginning of the file containing the completion function. + +Take care to use the correct type of quoting for specifications to _arguments or _regex_arguments: +use double quotes if there is a parameter that needs to be expanded in the specification, single quotes otherwise, +and make sure to use different quotes around item descriptions. + +Check that you have the correct number of :'s in the correct places for specifications for _arguments, +_alternative, _regex_arguments, etc. + +Remember to include an initial pattern to match the command word when using _regex_arguments (it does not need a matching action). + +Remember to put a null char $'\0' at the end of any PATTERN argument for _regex_arguments +* Tips +Sometimes you have a situation where there is just one option that can come after a subcommand, and zsh will complete this +automatically when tab is pressed after the subcommand. If instead you want it listed with its description before completing +you can add another empty option (i.e. \:) to the ACTION like this ':TAG:DESCRIPTION:((opt1\:"description for opt1" \:))' +Note this only applies to utility functions that use ACTIONs in their specification arguments (_arguments, _regex_arguments, etc.) + +* Other resources +[[https://wikimatze.de/writing-zsh-completion-for-padrino/][Here]] is a nicely formatted short tutorial showing basic usage of the _arguments function, +and [[https://web.archive.org/web/20190411104837/http://www.linux-mag.com/id/1106/][here]] is a slightly more advanced tutorial using the _arguments function. +[[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][Here]] is the zshcompsys man page. diff --git a/home/.zsh-server/plugins/zsh-completions/zsh-completions.plugin.zsh b/home/.zsh-server/plugins/zsh-completions/zsh-completions.plugin.zsh new file mode 100644 index 0000000..4c8b884 --- /dev/null +++ b/home/.zsh-server/plugins/zsh-completions/zsh-completions.plugin.zsh @@ -0,0 +1 @@ +fpath+="${0:A:h}/src" diff --git a/home/.zsh-server/themes/bira/bira.zsh-theme b/home/.zsh-server/themes/bira/bira.zsh-theme new file mode 100644 index 0000000..42a70a0 --- /dev/null +++ b/home/.zsh-server/themes/bira/bira.zsh-theme @@ -0,0 +1,32 @@ +local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" +local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n@%m%{$reset_color%} " +local user_symbol='%(!.#.$)' +local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}" + +local vcs_branch='$(git_prompt_info)$(hg_prompt_info)' +local rvm_ruby='$(ruby_prompt_info)' +local venv_prompt='$(virtualenv_prompt_info)' + +ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" + +PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt} +╰─%B${user_symbol}%b " +RPROMPT="%B${return_code}%b" + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹" +ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[yellow]%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[yellow]%}" + +ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX" +ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX" +ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY" +ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN" + +ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}‹" +ZSH_THEME_RUBY_PROMPT_SUFFIX="› %{$reset_color%}" + +ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$fg[green]%}‹" +ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="› %{$reset_color%}" +ZSH_THEME_VIRTUALENV_PREFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX" +ZSH_THEME_VIRTUALENV_SUFFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX" diff --git a/home/.zsh-server/zshrc b/home/.zsh-server/zshrc new file mode 100644 index 0000000..e4fa291 --- /dev/null +++ b/home/.zsh-server/zshrc @@ -0,0 +1,54 @@ +### ENVVARS +export EDITOR=vim + +### Alias +alias l="ls --color -lah" +alias ll="ls --color -lh" +alias la="ls --color -ah" +alias ls="ls --color -h" + +### ZSH HOME +export ZSH=$HOME/.zsh-server + +### ---- history config ------------------------------------- +export HISTFILE=$ZSH/.zsh_history + +# How many commands zsh will load to memory. +export HISTSIZE=10000 + +# How many commands history will save on file. +export SAVEHIST=10000 + +# History won't save duplicates. +setopt HIST_IGNORE_ALL_DUPS + +# History won't show duplicates on search. +setopt HIST_FIND_NO_DUPS + +### ---- zsh options ------------------------------------- +setopt autocd + +### --- Inputs Config ------------------------------------ +bindkey "^[[1;5C" forward-word +bindkey "^[[1;5D" backward-word +bindkey -s "^X" 'n^M' +bindkey -v + +### ---- PLUGINS & THEMES ----------------------------------- +source $ZSH/themes/bira/bira.zsh-theme +source $ZSH/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh +source $ZSH/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh +source /usr/share/doc/fzf/examples/key-bindings.zsh +source $ZSH/plugins/wakeonlan/wakeonlan.plugin.zsh +fpath=($ZSH/plugins/zsh-completions/src $fpath) + +### --- fzf Config ------------------------------------ +export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'" +export FZF_CTRL_R_OPTS='--no-sort --exact' + +### --- nnn Config ------------------------------------ +source /usr/share/nnn/quitcd/quitcd.bash_zsh + +### --- zsh tab completion Config ------------------------------------ +autoload -Uz compinit && compinit +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' diff --git a/home/.zsh/zshrc b/home/.zsh/zshrc index e35684f..6f34e9a 100644 --- a/home/.zsh/zshrc +++ b/home/.zsh/zshrc @@ -15,6 +15,9 @@ alias ll="lsd -lh" alias la="lsd -a" alias ls="lsd" alias kalishell="ssh kali@192.168.100.244" +alias rm="echo please consider using trash instead: trash " +alias purge="/usr/bin/rm" +alias plasmarestart="kquitapp5 plasmashell && kstart5 plasmashell" ### ZSH HOME export ZSH=$HOME/.zsh diff --git a/usr/share/fzf/key-bindings.zsh b/usr/share/fzf/key-bindings.zsh index dfb473c..458a3a4 100644 --- a/usr/share/fzf/key-bindings.zsh +++ b/usr/share/fzf/key-bindings.zsh @@ -94,11 +94,12 @@ bindkey -M vicmd '\ec' fzf-cd-widget bindkey -M viins '\ec' fzf-cd-widget # CTRL-R - Paste the selected command from history into the command line +# EDIT BY plex: removed --scheme-history , as it causes errors on some debian based systems as it seems. fzf-history-widget() { local selected num setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null selected=( $(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' | - FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) + FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} -n2..,.. --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) local ret=$? if [ -n "$selected" ]; then num=$selected[1]