summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ag/README.md13
-rw-r--r--plugins/ag/_ag66
-rw-r--r--plugins/aliases/README.md21
-rw-r--r--plugins/aliases/aliases.plugin.zsh10
-rw-r--r--plugins/aliases/cheatsheet.py55
-rw-r--r--plugins/aliases/termcolor.py168
-rw-r--r--plugins/ansible/ansible.plugin.zsh4
-rw-r--r--plugins/archlinux/README.md280
-rw-r--r--plugins/archlinux/archlinux.plugin.zsh283
-rw-r--r--plugins/autojump/autojump.plugin.zsh1
-rw-r--r--plugins/aws/README.md41
-rw-r--r--plugins/aws/aws.plugin.zsh114
-rw-r--r--plugins/battery/README.md20
-rw-r--r--plugins/battery/battery.plugin.zsh101
-rw-r--r--plugins/bedtools/README.md5
-rw-r--r--plugins/bedtools/_bedtools64
-rw-r--r--plugins/bgnotify/bgnotify.plugin.zsh2
-rw-r--r--plugins/bower/bower.plugin.zsh2
-rw-r--r--plugins/brew/README.md21
-rw-r--r--plugins/brew/brew.plugin.zsh5
-rw-r--r--plugins/bundler/README.md79
-rw-r--r--plugins/bundler/bundler.plugin.zsh116
-rw-r--r--plugins/cargo/_cargo407
-rw-r--r--plugins/cargo/cargo.plugin.zsh23
-rw-r--r--plugins/chruby/chruby.plugin.zsh2
-rw-r--r--plugins/chucknorris/README.md4
-rw-r--r--plugins/chucknorris/chucknorris.plugin.zsh36
-rw-r--r--plugins/chucknorris/fortunes/chucknorris308
-rw-r--r--plugins/cloudapp/README.md24
-rw-r--r--plugins/cloudapp/cloudapp.plugin.zsh6
-rwxr-xr-xplugins/cloudapp/cloudapp.rb60
-rw-r--r--plugins/colemak/.gitignore1
-rw-r--r--plugins/colemak/colemak.plugin.zsh13
-rw-r--r--plugins/colored-man-pages/README.md14
-rw-r--r--plugins/colored-man-pages/colored-man-pages.plugin.zsh73
-rwxr-xr-xplugins/colored-man-pages/nroff12
-rw-r--r--plugins/colorize/README.md8
-rw-r--r--plugins/colorize/colorize.plugin.zsh9
-rw-r--r--plugins/command-not-found/README.md1
-rw-r--r--plugins/command-not-found/command-not-found.plugin.zsh90
-rw-r--r--plugins/common-aliases/README.md4
-rw-r--r--plugins/common-aliases/common-aliases.plugin.zsh8
-rw-r--r--plugins/composer/composer.plugin.zsh2
-rw-r--r--plugins/copybuffer/copybuffer.plugin.zsh6
-rw-r--r--plugins/cp/README.md2
-rw-r--r--plugins/cp/cp.plugin.zsh2
-rw-r--r--plugins/debian/README.md2
-rw-r--r--plugins/debian/debian.plugin.zsh14
-rw-r--r--plugins/deno/README.md18
-rw-r--r--plugins/deno/deno.plugin.zsh35
-rw-r--r--plugins/dirhistory/README.md3
-rw-r--r--plugins/dirhistory/dirhistory.plugin.zsh41
-rw-r--r--plugins/django/README.md38
-rw-r--r--plugins/django/django.plugin.zsh3
-rw-r--r--plugins/docker-compose/README.md36
-rw-r--r--plugins/docker-compose/_docker-compose12
-rw-r--r--plugins/docker-compose/docker-compose.plugin.zsh46
-rw-r--r--plugins/docker/README.md22
-rw-r--r--plugins/docker/_docker115
-rw-r--r--plugins/dotenv/README.md24
-rw-r--r--plugins/dotenv/dotenv.plugin.zsh66
-rw-r--r--plugins/emacs/emacs.plugin.zsh92
-rwxr-xr-xplugins/emacs/emacsclient.sh51
-rw-r--r--plugins/emotty/emotty.plugin.zsh2
-rw-r--r--plugins/encode64/README.md2
-rw-r--r--plugins/extract/README.md4
-rw-r--r--plugins/extract/_extract2
-rw-r--r--plugins/extract/extract.plugin.zsh147
-rw-r--r--plugins/fedora/README.md1
-rw-r--r--plugins/fedora/fedora.plugin.zsh3
-rw-r--r--plugins/fnm/README.md9
-rw-r--r--plugins/fnm/fnm.plugin.zsh23
-rw-r--r--plugins/fossil/fossil.plugin.zsh4
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh14
-rw-r--r--plugins/fzf/README.md53
-rw-r--r--plugins/fzf/fzf.plugin.zsh158
-rw-r--r--plugins/gcloud/gcloud.plugin.zsh1
-rw-r--r--plugins/genpass/README.md66
-rwxr-xr-xplugins/genpass/genpass-apple79
-rwxr-xr-xplugins/genpass/genpass-monkey32
-rwxr-xr-xplugins/genpass/genpass-xkcd68
-rw-r--r--plugins/genpass/genpass.plugin.zsh1
-rw-r--r--plugins/gh/README.md23
-rw-r--r--plugins/gh/gh.plugin.zsh24
-rw-r--r--plugins/git-auto-fetch/README.md43
-rw-r--r--plugins/git-auto-fetch/git-auto-fetch.plugin.zsh83
-rw-r--r--plugins/git-flow/git-flow.plugin.zsh7
-rw-r--r--plugins/git-lfs/README.md24
-rw-r--r--plugins/git-lfs/git-lfs.plugin.zsh17
-rw-r--r--plugins/git-prompt/README.md5
-rw-r--r--plugins/git-prompt/git-prompt.plugin.zsh12
-rw-r--r--plugins/git-prompt/gitstatus.py24
-rw-r--r--plugins/git/README.md65
-rw-r--r--plugins/git/git.plugin.zsh92
-rw-r--r--plugins/gitfast/_git200
-rw-r--r--plugins/gitfast/git-completion.bash2279
-rw-r--r--plugins/gitfast/git-prompt.sh72
-rwxr-xr-xplugins/gitfast/update11
-rw-r--r--plugins/gitfast/updates.patch56
-rw-r--r--plugins/github/README.md4
-rw-r--r--plugins/globalias/README.md19
-rw-r--r--plugins/globalias/globalias.plugin.zsh10
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh2
-rw-r--r--plugins/go/README.md1
-rw-r--r--plugins/go/go.plugin.zsh3
-rw-r--r--plugins/golang/README.md2
-rw-r--r--plugins/golang/golang.plugin.zsh4
-rw-r--r--plugins/gpg-agent/README.md2
-rw-r--r--plugins/gpg-agent/gpg-agent.plugin.zsh25
-rw-r--r--plugins/gradle/_gradle4
-rw-r--r--plugins/grc/README.md15
-rw-r--r--plugins/grc/grc.plugin.zsh17
-rw-r--r--plugins/hanami/README.md63
-rw-r--r--plugins/hanami/hanami.plugin.zsh6
-rw-r--r--plugins/hitchhiker/.gitignore1
-rw-r--r--plugins/hitchhiker/README.md44
-rw-r--r--plugins/hitchhiker/fortunes/hitchhiker275
-rw-r--r--plugins/hitchhiker/hitchhiker.plugin.zsh23
-rw-r--r--plugins/httpie/README.md6
-rw-r--r--plugins/httpie/httpie.plugin.zsh7
-rw-r--r--plugins/invoke/README.md10
-rw-r--r--plugins/invoke/invoke.plugin.zsh5
-rw-r--r--plugins/ipfs/LICENSE22
-rw-r--r--plugins/ipfs/README.md17
-rw-r--r--plugins/ipfs/_ipfs717
-rw-r--r--plugins/isodate/README.md22
-rw-r--r--plugins/isodate/isodate.plugin.zsh7
-rw-r--r--plugins/jake-node/jake-node.plugin.zsh2
-rw-r--r--plugins/jsontools/README.md47
-rw-r--r--plugins/jsontools/jsontools.plugin.zsh137
-rw-r--r--plugins/juju/README.md117
-rw-r--r--plugins/juju/juju.plugin.zsh127
-rw-r--r--plugins/kube-ps1/README.md8
-rw-r--r--plugins/kubectl/README.md35
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh35
-rw-r--r--plugins/kubectx/README.md26
-rw-r--r--plugins/kubectx/kubectx.plugin.zsh9
-rw-r--r--plugins/kubectx/prod.pngbin0 -> 3834 bytes
-rw-r--r--plugins/kubectx/stage.pngbin0 -> 3829 bytes
-rw-r--r--plugins/lando/LICENSE21
-rw-r--r--plugins/lando/README.md37
-rw-r--r--plugins/lando/lando.plugin.zsh41
-rw-r--r--plugins/laravel5/laravel5.plugin.zsh19
-rw-r--r--plugins/last-working-dir/README.md28
-rw-r--r--plugins/last-working-dir/last-working-dir.plugin.zsh14
-rw-r--r--plugins/macports/_port1
-rw-r--r--plugins/magic-enter/magic-enter.plugin.zsh53
-rw-r--r--plugins/mercurial/README.md3
-rw-r--r--plugins/mercurial/mercurial.plugin.zsh35
-rw-r--r--plugins/minikube/minikube.plugin.zsh10
-rw-r--r--plugins/mix-fast/mix-fast.plugin.zsh5
-rw-r--r--plugins/mongocli/README.md19
-rw-r--r--plugins/mongocli/mongocli.plugin.zsh4
-rw-r--r--plugins/mvn/README.md2
-rw-r--r--plugins/mvn/mvn.plugin.zsh573
-rw-r--r--plugins/npm/README.md4
-rw-r--r--plugins/npm/npm.plugin.zsh12
-rw-r--r--plugins/npx/README.md28
-rw-r--r--plugins/nvm/README.md25
-rw-r--r--plugins/nvm/nvm.plugin.zsh81
-rw-r--r--plugins/octozen/README.md12
-rw-r--r--plugins/octozen/octozen.plugin.zsh11
-rw-r--r--plugins/osx/README.md9
-rw-r--r--plugins/osx/_security90
-rw-r--r--plugins/osx/music170
-rw-r--r--plugins/osx/osx.plugin.zsh288
-rw-r--r--plugins/per-directory-history/per-directory-history.zsh64
-rw-r--r--plugins/pip/README.md9
-rw-r--r--plugins/pip/pip.plugin.zsh17
-rw-r--r--plugins/pipenv/pipenv.plugin.zsh3
-rw-r--r--plugins/pm2/README.md19
-rw-r--r--plugins/pm2/_pm2168
-rw-r--r--plugins/pm2/pm2.plugin.zsh6
-rw-r--r--plugins/pyenv/README.md10
-rw-r--r--plugins/pyenv/pyenv.plugin.zsh108
-rw-r--r--plugins/python/README.md1
-rw-r--r--plugins/python/python.plugin.zsh3
-rw-r--r--plugins/rails/README.md4
-rw-r--r--plugins/rails/rails.plugin.zsh8
-rw-r--r--plugins/rbenv/rbenv.plugin.zsh2
-rw-r--r--plugins/react-native/react-native.plugin.zsh3
-rw-r--r--plugins/rustup/_rustup1143
-rw-r--r--plugins/rustup/rustup.plugin.zsh22
-rw-r--r--plugins/safe-paste/safe-paste.plugin.zsh128
-rw-r--r--plugins/samtools/README.md5
-rw-r--r--plugins/samtools/_samtools40
-rw-r--r--plugins/scd/README.md54
-rw-r--r--plugins/scd/_scd60
-rwxr-xr-x[-rw-r--r--]plugins/scd/scd343
-rw-r--r--plugins/scd/scd.plugin.zsh16
-rw-r--r--plugins/screen/screen.plugin.zsh4
-rwxr-xr-xplugins/shell-proxy/proxy.py7
-rw-r--r--plugins/shell-proxy/shell-proxy.plugin.zsh2
-rwxr-xr-xplugins/shell-proxy/ssh-agent.py2
-rw-r--r--plugins/shrink-path/README.md87
-rw-r--r--plugins/shrink-path/shrink-path.plugin.zsh12
-rw-r--r--plugins/ssh-agent/README.md60
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh161
-rw-r--r--plugins/sublime-merge/README.md17
-rw-r--r--plugins/sublime-merge/sublime-merge.plugin.zsh55
-rw-r--r--plugins/sublime/sublime.plugin.zsh4
-rw-r--r--plugins/sudo/sudo.plugin.zsh84
-rw-r--r--plugins/supervisor/supervisor.plugin.zsh13
-rw-r--r--plugins/suse/README.md10
-rw-r--r--plugins/suse/suse.plugin.zsh20
-rw-r--r--plugins/systemadmin/README.md22
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh9
-rw-r--r--plugins/term_tab/README16
-rw-r--r--plugins/term_tab/term_tab.plugin.zsh41
-rw-r--r--plugins/terraform/README.md3
-rw-r--r--plugins/terraform/_terraform228
-rw-r--r--plugins/terraform/terraform.plugin.zsh6
-rw-r--r--plugins/thefuck/README.md4
-rw-r--r--plugins/thefuck/thefuck.plugin.zsh3
-rw-r--r--plugins/timer/README.md1
-rw-r--r--plugins/timer/timer.plugin.zsh13
-rw-r--r--plugins/ubuntu/ubuntu.plugin.zsh3
-rw-r--r--plugins/universalarchive/README.md46
-rw-r--r--plugins/universalarchive/_universalarchive6
-rw-r--r--plugins/universalarchive/universalarchive.plugin.zsh70
-rw-r--r--plugins/vagrant-prompt/vagrant-prompt.plugin.zsh25
-rw-r--r--plugins/vagrant/_vagrant2
-rw-r--r--plugins/vi-mode/README.md102
-rw-r--r--plugins/vi-mode/vi-mode.plugin.zsh121
-rw-r--r--plugins/vim-interaction/vim-interaction.plugin.zsh49
-rw-r--r--plugins/virtualenv/virtualenv.plugin.zsh2
-rw-r--r--plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh23
-rw-r--r--plugins/vscode/README.md32
-rw-r--r--plugins/vscode/vscode.plugin.zsh27
-rw-r--r--plugins/wd/README.md186
-rw-r--r--plugins/wd/wd.sh165
-rw-r--r--plugins/web-search/README.md25
-rw-r--r--plugins/web-search/web-search.plugin.zsh15
-rw-r--r--plugins/wp-cli/README.md202
-rw-r--r--plugins/wp-cli/wp-cli.plugin.zsh51
-rw-r--r--plugins/yarn/README.md66
-rw-r--r--plugins/yarn/_yarn176
-rw-r--r--plugins/yarn/yarn.plugin.zsh9
-rw-r--r--plugins/z/README8
-rw-r--r--plugins/z/z.13
-rw-r--r--plugins/z/z.sh60
-rw-r--r--plugins/zbell/README.md30
-rw-r--r--plugins/zbell/zbell.plugin.zsh83
-rw-r--r--plugins/zoxide/README.md14
-rw-r--r--plugins/zoxide/zoxide.plugin.zsh5
-rw-r--r--plugins/zsh_reload/README.md22
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh15
247 files changed, 9545 insertions, 5599 deletions
diff --git a/plugins/ag/README.md b/plugins/ag/README.md
new file mode 100644
index 000000000..1983aaa41
--- /dev/null
+++ b/plugins/ag/README.md
@@ -0,0 +1,13 @@
+# The Silver Searcher
+
+This plugin provides completion support for [`ag`](https://github.com/ggreer/the_silver_searcher).
+
+To use it, add ag to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... ag)
+```
+
+## INSTALLATION NOTES
+
+Besides oh-my-zsh, `ag` needs to be installed by following these steps: https://github.com/ggreer/the_silver_searcher#installing.
diff --git a/plugins/ag/_ag b/plugins/ag/_ag
new file mode 100644
index 000000000..25b0c27a7
--- /dev/null
+++ b/plugins/ag/_ag
@@ -0,0 +1,66 @@
+#compdef ag
+#autoload
+
+typeset -A opt_args
+
+# Took the liberty of not listing every option… specially aliases and -D
+_ag () {
+ local -a _1st_arguments
+ _1st_arguments=(
+ '--ackmate:Print results in AckMate-parseable format'
+ {'-A','--after'}':[LINES] Print lines after match (Default: 2)'
+ {'-B','--before'}':[LINES] Print lines before match (Default: 2)'
+ '--break:Print newlines between matches in different files'
+ '--nobreak:Do not print newlines between matches in different files'
+ {'-c','--count'}':Only print the number of matches in each file'
+ '--color:Print color codes in results (Default: On)'
+ '--nocolor:Do not print color codes in results'
+ '--color-line-number:Color codes for line numbers (Default: 1;33)'
+ '--color-match:Color codes for result match numbers (Default: 30;43)'
+ '--color-path:Color codes for path names (Default: 1;32)'
+ '--column:Print column numbers in results'
+ {'-H','--heading'}':Print file names (On unless searching a single file)'
+ '--noheading:Do not print file names (On unless searching a single file)'
+ '--line-numbers:Print line numbers even for streams'
+ {'-C','--context'}':[LINES] Print lines before and after matches (Default: 2)'
+ '-g:[PATTERN] Print filenames matching PATTERN'
+ {'-l','--files-with-matches'}':Only print filenames that contain matches'
+ {'-L','--files-without-matches'}':Only print filenames that do not contain matches'
+ '--no-numbers:Do not print line numbers'
+ {'-o','--only-matching'}':Prints only the matching part of the lines'
+ '--print-long-lines:Print matches on very long lines (Default: 2k characters)'
+ '--passthrough:When searching a stream, print all lines even if they do not match'
+ '--silent:Suppress all log messages, including errors'
+ '--stats:Print stats (files scanned, time taken, etc.)'
+ '--vimgrep:Print results like vim :vimgrep /pattern/g would'
+ {'-0','--null'}':Separate filenames with null (for "xargs -0")'
+
+ {'-a','--all-types'}':Search all files (does not include hidden files / .gitignore)'
+ '--depth:[NUM] Search up to NUM directories deep (Default: 25)'
+ {'-f','--follow'}':Follow symlinks'
+ {'-G','--file-search-regex'}':[PATTERN] Limit search to filenames matching PATTERN'
+ '--hidden:Search hidden files (obeys .*ignore files)'
+ {'-i','--ignore-case'}':Match case insensitively'
+ '--ignore:[PATTERN] Ignore files/directories matching PATTERN'
+ {'-m','--max-count'}':[NUM] Skip the rest of a file after NUM matches (Default: 10k)'
+ {'-p','--path-to-agignore'}':[PATH] Use .agignore file at PATH'
+ {'-Q','--literal'}':Do not parse PATTERN as a regular expression'
+ {'-s','--case-sensitive'}':Match case'
+ {'-S','--smart-case'}':Insensitive match unless PATTERN has uppercase (Default: On)'
+ '--search-binary:Search binary files for matches'
+ {'-t','--all-text'}':Search all text files (Hidden files not included)'
+ {'-u','--unrestricted'}':Search all files (ignore .agignore and _all_)'
+ {'-U','--skip-vcs-ignores'}':Ignore VCS files (stil obey .agignore)'
+ {'-v','--invert-match'}':Invert match'
+ {'-w','--word-regexp'}':Only match whole words'
+ {'-z','--search-zip'}':Search contents of compressed (e.g., gzip) files'
+
+ '--list-file-types:list of supported file types'
+ )
+
+ if [[ $words[-1] =~ "^-" ]]; then
+ _describe -t commands "ag options" _1st_arguments && ret=0
+ else
+ _files && ret=0
+ fi
+}
diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md
new file mode 100644
index 000000000..481c1bd4e
--- /dev/null
+++ b/plugins/aliases/README.md
@@ -0,0 +1,21 @@
+## Aliases Cheatsheet
+
+**Maintainer:** [@hqingyi](https://github.com/hqingyi)
+
+With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
+that are currently available based on the plugins you have enabled.
+
+Enable this plugin by adding it to your `plugins` definition in `~/.zshrc`.
+
+ ```
+ plugins=(aliases)
+ ```
+
+Requirements: Python needs to be installed.
+
+### Usage
+
+```
+ acs: group all alias
+ acs $keywordquickly filter alias & highlight
+```
diff --git a/plugins/aliases/aliases.plugin.zsh b/plugins/aliases/aliases.plugin.zsh
new file mode 100644
index 000000000..28d8fba24
--- /dev/null
+++ b/plugins/aliases/aliases.plugin.zsh
@@ -0,0 +1,10 @@
+# with lots of 3rd-party amazing aliases installed, just need something to explore it quickly.
+#
+# - acs: alias cheatsheet
+# group alias by command, pass addition argv to grep.
+ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd)
+function acs(){
+ which python >>/dev/null
+ [[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return
+ alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@
+}
diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py
new file mode 100644
index 000000000..d6d507b92
--- /dev/null
+++ b/plugins/aliases/cheatsheet.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+import sys
+import itertools
+import termcolor
+
+def parse(line):
+ left = line[0:line.find('=')].strip()
+ right = line[line.find('=')+1:].strip('\'"\n ')
+ try:
+ cmd = next(part for part in right.split() if len([char for char in '=<>' if char in part])==0)
+ except StopIteration:
+ cmd = right
+ return (left, right, cmd)
+
+def cheatsheet(lines):
+ exps = [ parse(line) for line in lines ]
+ cheatsheet = {'_default': []}
+ for key, group in itertools.groupby(exps, lambda exp:exp[2]):
+ group_list = [ item for item in group ]
+ if len(group_list)==1:
+ target_aliases = cheatsheet['_default']
+ else:
+ if key not in cheatsheet:
+ cheatsheet[key] = []
+ target_aliases = cheatsheet[key]
+ target_aliases.extend(group_list)
+ return cheatsheet
+
+def pretty_print_group(key, aliases, hightlight=None):
+ if len(aliases) == 0:
+ return
+ group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
+ alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
+ group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
+ alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
+ if hightlight and len(hightlight)>0:
+ print (group_hl_formatter(key, hightlight))
+ print ('\n'.join([alias_hl_formatter(alias, hightlight) for alias in aliases]))
+ else:
+ print (group_formatter(key))
+ print ('\n'.join([alias_formatter(alias) for alias in aliases]))
+ print ('')
+
+def pretty_print(cheatsheet, wfilter):
+ sorted_key = sorted(cheatsheet.keys())
+ for key in sorted_key:
+ aliases = cheatsheet.get(key)
+ if not wfilter:
+ pretty_print_group(key, aliases, wfilter)
+ else:
+ pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
+
+if __name__ == '__main__':
+ lines = sys.stdin.readlines()
+ pretty_print(cheatsheet(lines), sys.argv[1] if len(sys.argv)>1 else None)
diff --git a/plugins/aliases/termcolor.py b/plugins/aliases/termcolor.py
new file mode 100644
index 000000000..f11b824b2
--- /dev/null
+++ b/plugins/aliases/termcolor.py
@@ -0,0 +1,168 @@
+# coding: utf-8
+# Copyright (c) 2008-2011 Volvox Development Team
+#
+# 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.
+#
+# Author: Konstantin Lepa <konstantin.lepa@gmail.com>
+
+"""ANSII Color formatting for output in terminal."""
+
+from __future__ import print_function
+import os
+
+
+__ALL__ = [ 'colored', 'cprint' ]
+
+VERSION = (1, 1, 0)
+
+ATTRIBUTES = dict(
+ list(zip([
+ 'bold',
+ 'dark',
+ '',
+ 'underline',
+ 'blink',
+ '',
+ 'reverse',
+ 'concealed'
+ ],
+ list(range(1, 9))
+ ))
+ )
+del ATTRIBUTES['']
+
+
+HIGHLIGHTS = dict(
+ list(zip([
+ 'on_grey',
+ 'on_red',
+ 'on_green',
+ 'on_yellow',
+ 'on_blue',
+ 'on_magenta',
+ 'on_cyan',
+ 'on_white'
+ ],
+ list(range(40, 48))
+ ))
+ )
+
+
+COLORS = dict(
+ list(zip([
+ 'grey',
+ 'red',
+ 'green',
+ 'yellow',
+ 'blue',
+ 'magenta',
+ 'cyan',
+ 'white',
+ ],
+ list(range(30, 38))
+ ))
+ )
+
+
+RESET = '\033[0m'
+
+
+def colored(text, color=None, on_color=None, attrs=None):
+ """Colorize text.
+
+ Available text colors:
+ red, green, yellow, blue, magenta, cyan, white.
+
+ Available text highlights:
+ on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
+
+ Available attributes:
+ bold, dark, underline, blink, reverse, concealed.
+
+ Example:
+ colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
+ colored('Hello, World!', 'green')
+ """
+ if os.getenv('ANSI_COLORS_DISABLED') is None:
+ fmt_str = '\033[%dm%s'
+ if color is not None:
+ text = fmt_str % (COLORS[color], text)
+
+ if on_color is not None:
+ text = fmt_str % (HIGHLIGHTS[on_color], text)
+
+ if attrs is not None:
+ for attr in attrs:
+ text = fmt_str % (ATTRIBUTES[attr], text)
+
+ text += RESET
+ return text
+
+
+def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
+ """Print colorize text.
+
+ It accepts arguments of print function.
+ """
+
+ print((colored(text, color, on_color, attrs)), **kwargs)
+
+
+if __name__ == '__main__':
+ print('Current terminal type: %s' % os.getenv('TERM'))
+ print('Test basic colors:')
+ cprint('Grey color', 'grey')
+ cprint('Red color', 'red')
+ cprint('Green color', 'green')
+ cprint('Yellow color', 'yellow')
+ cprint('Blue color', 'blue')
+ cprint('Magenta color', 'magenta')
+ cprint('Cyan color', 'cyan')
+ cprint('White color', 'white')
+ print(('-' * 78))
+
+ print('Test highlights:')
+ cprint('On grey color', on_color='on_grey')
+ cprint('On red color', on_color='on_red')
+ cprint('On green color', on_color='on_green')
+ cprint('On yellow color', on_color='on_yellow')
+ cprint('On blue color', on_color='on_blue')
+ cprint('On magenta color', on_color='on_magenta')
+ cprint('On cyan color', on_color='on_cyan')
+ cprint('On white color', color='grey', on_color='on_white')
+ print('-' * 78)
+
+ print('Test attributes:')
+ cprint('Bold grey color', 'grey', attrs=['bold'])
+ cprint('Dark red color', 'red', attrs=['dark'])
+ cprint('Underline green color', 'green', attrs=['underline'])
+ cprint('Blink yellow color', 'yellow', attrs=['blink'])
+ cprint('Reversed blue color', 'blue', attrs=['reverse'])
+ cprint('Concealed Magenta color', 'magenta', attrs=['concealed'])
+ cprint('Bold underline reverse cyan color', 'cyan',
+ attrs=['bold', 'underline', 'reverse'])
+ cprint('Dark blink concealed white color', 'white',
+ attrs=['dark', 'blink', 'concealed'])
+ print(('-' * 78))
+
+ print('Test mixing:')
+ cprint('Underline red on grey color', 'red', 'on_grey',
+ ['underline'])
+ cprint('Reversed green on red color', 'green', 'on_red', ['reverse'])
+
diff --git a/plugins/ansible/ansible.plugin.zsh b/plugins/ansible/ansible.plugin.zsh
index f68ff23a5..75393b704 100644
--- a/plugins/ansible/ansible.plugin.zsh
+++ b/plugins/ansible/ansible.plugin.zsh
@@ -4,7 +4,7 @@ function ansible-version(){
}
function ansible-role-init(){
- if ! [ -z $1] ; then
+ if ! [ -z $1 ] ; then
echo "Ansible Role : $1 Creating...."
ansible-galaxy init $1
tree $1
@@ -25,4 +25,4 @@ alias ainv='ansible-inventory '
alias adoc='ansible-doc '
alias agal='ansible-galaxy '
alias apull='ansible-pull '
-alias aval='ansible-vault' \ No newline at end of file
+alias aval='ansible-vault'
diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md
index 5882c7603..c8ec1de1e 100644
--- a/plugins/archlinux/README.md
+++ b/plugins/archlinux/README.md
@@ -1,4 +1,4 @@
-# Archlinux plugin
+# Arch Linux plugin
This plugin adds some aliases and functions to work with Arch Linux.
@@ -10,145 +10,163 @@ plugins=(... archlinux)
## Features
-#### YAY
-
-| Alias | Command | Description |
-|---------|------------------------------------|---------------------------------------------------------------------|
-| yaconf | yay -Pg | Print current configuration |
-| yain | yay -S | Install packages from the repositories |
-| yains | yay -U | Install a package from a local file |
-| yainsd | yay -S --asdeps | Install packages as dependencies of another package |
-| yaloc | yay -Qi | Display information about a package in the local database |
-| yalocs | yay -Qs | Search for packages in the local database |
-| yalst | yay -Qe | List installed packages including from AUR (tagged as "local") |
-| yamir | yay -Syy | Force refresh of all package lists after updating mirrorlist |
-| yaorph | yay -Qtd | Remove orphans using yay |
-| yare | yay -R | Remove packages, keeping its settings and dependencies |
-| yarem | yay -Rns | Remove packages, including its settings and unneeded dependencies |
-| yarep | yay -Si | Display information about a package in the repositories |
-| yareps | yay -Ss | Search for packages in the repositories |
-| yaupg | yay -Syu | Sync with repositories before upgrading packages |
-| yasu | yay -Syu --no-confirm | Same as `yaupg`, but without confirmation |
-
-#### TRIZEN
-
-| Alias | Command | Description |
-|---------|------------------------------------|---------------------------------------------------------------------|
-| trconf | trizen -C | Fix all configuration files with vimdiff |
-| trin | trizen -S | Install packages from the repositories |
-| trins | trizen -U | Install a package from a local file |
-| trinsd | trizen -S --asdeps | Install packages as dependencies of another package |
-| trloc | trizen -Qi | Display information about a package in the local database |
-| trlocs | trizen -Qs | Search for packages in the local database |
-| trlst | trizen -Qe | List installed packages including from AUR (tagged as "local") |
-| trmir | trizen -Syy | Force refresh of all package lists after updating mirrorlist |
-| trorph | trizen -Qtd | Remove orphans using yaourt |
-| trre | trizen -R | Remove packages, keeping its settings and dependencies |
-| trrem | trizen -Rns | Remove packages, including its settings and unneeded dependencies |
-| trrep | trizen -Si | Display information about a package in the repositories |
-| trreps | trizen -Ss | Search for packages in the repositories |
-| trupd | trizen -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
-| trupd | trizen -Sy && sudo abs | Update and refresh the local package and ABS databases |
-| trupd | trizen -Sy && sudo aur | Update and refresh the local package and AUR databases |
-| trupd | trizen -Sy | Update and refresh the local package database |
-| trupg | trizen -Syua | Sync with repositories before upgrading all packages (from AUR too) |
-| trsu | trizen -Syua --no-confirm | Same as `trupg`, but without confirmation |
-| upgrade | trizen -Syu | Sync with repositories before upgrading packages |
-
-#### YAOURT
-
-| Alias | Command | Description |
-|---------|------------------------------------|---------------------------------------------------------------------|
-| yaconf | yaourt -C | Fix all configuration files with vimdiff |
-| yain | yaourt -S | Install packages from the repositories |
-| yains | yaourt -U | Install a package from a local file |
-| yainsd | yaourt -S --asdeps | Install packages as dependencies of another package |
-| yaloc | yaourt -Qi | Display information about a package in the local database |
-| yalocs | yaourt -Qs | Search for packages in the local database |
-| yalst | yaourt -Qe | List installed packages including from AUR (tagged as "local") |
-| yamir | yaourt -Syy | Force refresh of all package lists after updating mirrorlist |
-| yaorph | yaourt -Qtd | Remove orphans using yaourt |
-| yare | yaourt -R | Remove packages, keeping its settings and dependencies |
-| yarem | yaourt -Rns | Remove packages, including its settings and unneeded dependencies |
-| yarep | yaourt -Si | Display information about a package in the repositories |
-| yareps | yaourt -Ss | Search for packages in the repositories |
-| yaupd | yaourt -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
-| yaupd | yaourt -Sy && sudo abs | Update and refresh the local package and ABS databases |
-| yaupd | yaourt -Sy && sudo aur | Update and refresh the local package and AUR databases |
-| yaupd | yaourt -Sy | Update and refresh the local package database |
-| yaupg | yaourt -Syua | Sync with repositories before upgrading all packages (from AUR too) |
-| yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation |
-| upgrade | yaourt -Syu | Sync with repositories before upgrading packages |
-
-#### PACAUR
-
-| Alias | Command | Description |
-|---------|------------------------------------|---------------------------------------------------------------------|
-| pain | pacaur -S | Install packages from the repositories |
-| pains | pacaur -U | Install a package from a local file |
-| painsd | pacaur -S --asdeps | Install packages as dependencies of another package |
-| paloc | pacaur -Qi | Display information about a package in the local database |
-| palocs | pacaur -Qs | Search for packages in the local database |
-| palst | pacaur -Qe | List installed packages including from AUR (tagged as "local") |
-| pamir | pacaur -Syy | Force refresh of all package lists after updating mirrorlist |
-| paorph | pacaur -Qtd | Remove orphans using pacaur |
-| pare | pacaur -R | Remove packages, keeping its settings and dependencies |
-| parem | pacaur -Rns | Remove packages, including its settings and unneeded dependencies |
-| parep | pacaur -Si | Display information about a package in the repositories |
-| pareps | pacaur -Ss | Search for packages in the repositories |
-| paupd | pacaur -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
-| paupd | pacaur -Sy && sudo abs | Update and refresh the local package and ABS databases |
-| paupd | pacaur -Sy && sudo aur | Update and refresh the local package and AUR databases |
-| paupd | pacaur -Sy | Update and refresh the local package database |
-| paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) |
-| pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation |
-| upgrade | pacaur -Syu | Sync with repositories before upgrading packages |
-
-#### PACMAN
-
-| Alias | Command | Description |
-|--------------|-----------------------------------------|--------------------------------------------------------------|
-| pacin | sudo pacman -S | Install packages from the repositories |
-| pacins | sudo pacman -U | Install a package from a local file |
-| pacinsd | sudo pacman -S --asdeps | Install packages as dependencies of another package |
-| pacloc | pacman -Qi | Display information about a package in the local database |
-| paclocs | pacman -Qs | Search for packages in the local database |
-| paclsorphans | sudo pacman -Qdt | List all orphaned packages |
-| pacmir | sudo pacman -Syy | Force refresh of all package lists after updating mirrorlist |
-| pacre | sudo pacman -R | Remove packages, keeping its settings and dependencies |
-| pacrem | sudo pacman -Rns | Remove packages, including its settings and dependencies |
-| pacrep | pacman -Si | Display information about a package in the repositories |
-| pacreps | pacman -Ss | Search for packages in the repositories |
-| pacrmorphans | sudo pacman -Rs $(pacman -Qtdq) | Delete all orphaned packages |
-| pacupd | sudo pacman -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases |
-| pacupd | sudo pacman -Sy && sudo abs | Update and refresh the local package and ABS databases |
-| pacupd | sudo pacman -Sy && sudo aur | Update and refresh the local package and AUR databases |
-| pacupd | sudo pacman -Sy | Update and refresh the local package database |
-| pacupg | sudo pacman -Syu | Sync with repositories before upgrading packages |
-| upgrade | sudo pacman -Syu | Sync with repositories before upgrading packages |
-| pacfileupg | sudo pacman -Fy | Download fresh package databases from the server |
-| pacfiles | pacman -F | Search package file names for matching strings |
-| pacls | pacman -Ql | List files in a package |
-| pacown | pacman -Qo | Show which package owns a file |
-
-| Function | Description |
-|----------------|------------------------------------------------------|
-| pacdisowned | List all disowned files in your system |
-| paclist | List all installed packages with a short description |
-| pacmanallkeys | Get all keys for developers and trusted users |
-| pacmansignkeys | Locally trust all keys passed as parameters |
-| pacweb | Open the website of an ArchLinux package |
+### Pacman
+
+| Alias | Command | Description |
+|--------------|----------------------------------------|------------------------------------------------------------------|
+| pacin | `sudo pacman -S` | Install packages from the repositories |
+| pacins | `sudo pacman -U` | Install a package from a local file |
+| pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
+| pacloc | `pacman -Qi` | Display information about a package in the local database |
+| paclocs | `pacman -Qs` | Search for packages in the local database |
+| paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
+| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
+| pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
+| pacrem | `sudo pacman -Rns` | Remove packages, including its settings and dependencies |
+| pacrep | `pacman -Si` | Display information about a package in the repositories |
+| pacreps | `pacman -Ss` | Search for packages in the repositories |
+| pacrmorphans | `sudo pacman -Rs $(pacman -Qtdq)` | Delete all orphaned packages |
+| pacupd | `sudo pacman -Sy` | Update and refresh local package, ABS and AUR databases |
+| pacupg | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
+| pacfileupg | `sudo pacman -Fy` | Download fresh package databases from the server |
+| pacfiles | `pacman -F` | Search package file names for matching strings |
+| pacls | `pacman -Ql` | List files in a package |
+| pacown | `pacman -Qo` | Show which package owns a file |
+| upgrade[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
+
+| Function | Description |
+|----------------|-----------------------------------------------------------|
+| pacdisowned | List all disowned files in your system |
+| paclist | List all explicitly installed packages with a description |
+| pacmanallkeys | Get all keys for developers and trusted users |
+| pacmansignkeys | Locally trust all keys passed as parameters |
+| pacweb | Open the website of an ArchLinux package |
+
+Note: paclist used to print packages with a description which are (1) explicitly installed
+and (2) available for upgrade. Due to flawed scripting, it also printed all packages if no
+upgrades were available. Use `pacman -Que` instead.
+
+### AUR helpers
+
+#### Aura
+
+| Alias | Command | Description |
+|---------|-------------------------------------------------|-------------------------------------------------------------------------|
+| auin | `sudo aura -S` | Install packages from the repositories |
+| aurin | `sudo aura -A` | Install packages from the repositories |
+| auins | `sudo aura -U` | Install a package from a local file |
+| auinsd | `sudo aura -S --asdeps` | Install packages as dependencies of another package (repositories only) |
+| aurinsd | `sudo aura -A --asdeps` | Install packages as dependencies of another package (AUR only) |
+| auloc | `aura -Qi` | Display information about a package in the local database |
+| aulocs | `aura -Qs` | Search for packages in the local database |
+| auls | `aura -Qql` | List all files owned by a given package |
+| aulst | `aura -Qe` | List installed packages including from AUR (tagged as "local") |
+| aumir | `sudo aura -Syy` | Force refresh of all package lists after updating mirrorlist |
+| aurph | `sudo aura -Oj` | Remove orphans using aura |
+| auown | `aura -Qqo` | Search for packages that own the specified file(s) |
+| aure | `sudo aura -R` | Remove packages, keeping its settings and dependencies |
+| aurem | `sudo aura -Rns` | Remove packages, including its settings and unneeded dependencies |
+| aurep | `aura -Si` | Display information about a package in the repositories |
+| aurrep | `aura -Ai` | Display information about a package from AUR |
+| aureps | `aura -As --both` | Search for packages in the repositories and AUR |
+| auras | `aura -As --both` | Same as above |
+| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
+| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
+| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
+| upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
+
+| Function | Description |
+|-----------------|---------------------------------------------------------------------|
+| auownloc _file_ | Display information about a package that owns the specified file(s) |
+| auownls _file_ | List all files owned by a package that owns the specified file(s) |
+
+#### Pacaur
+
+| Alias | Command | Description |
+|---------|-----------------------------------|---------------------------------------------------------------------|
+| pain | `pacaur -S` | Install packages from the repositories |
+| pains | `pacaur -U` | Install a package from a local file |
+| painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package |
+| paloc | `pacaur -Qi` | Display information about a package in the local database |
+| palocs | `pacaur -Qs` | Search for packages in the local database |
+| palst | `pacaur -Qe` | List installed packages including from AUR (tagged as "local") |
+| pamir | `pacaur -Syy` | Force refresh of all package lists after updating mirrorlist |
+| paorph | `pacaur -Qtd` | Remove orphans using pacaur |
+| pare | `pacaur -R` | Remove packages, keeping its settings and dependencies |
+| parem | `pacaur -Rns` | Remove packages, including its settings and unneeded dependencies |
+| parep | `pacaur -Si` | Display information about a package in the repositories |
+| pareps | `pacaur -Ss` | Search for packages in the repositories |
+| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
+| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
+| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
+| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
+
+#### Trizen
+
+| Alias | Command | Description |
+|---------|-----------------------------------|---------------------------------------------------------------------|
+| trconf | `trizen -C` | Fix all configuration files with vimdiff |
+| trin | `trizen -S` | Install packages from the repositories |
+| trins | `trizen -U` | Install a package from a local file |
+| trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package |
+| trloc | `trizen -Qi` | Display information about a package in the local database |
+| trlocs | `trizen -Qs` | Search for packages in the local database |
+| trlst | `trizen -Qe` | List installed packages including from AUR (tagged as "local") |
+| trmir | `trizen -Syy` | Force refresh of all package lists after updating mirrorlist |
+| trorph | `trizen -Qtd` | Remove orphans using yaourt |
+| trre | `trizen -R` | Remove packages, keeping its settings and dependencies |
+| trrem | `trizen -Rns` | Remove packages, including its settings and unneeded dependencies |
+| trrep | `trizen -Si` | Display information about a package in the repositories |
+| trreps | `trizen -Ss` | Search for packages in the repositories |
+| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
+| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
+| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
+| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
+
+#### Yay
+
+| Alias | Command | Description |
+|---------|--------------------------------|-------------------------------------------------------------------|
+| yaconf | `yay -Pg` | Print current configuration |
+| yain | `yay -S` | Install packages from the repositories |
+| yains | `yay -U` | Install a package from a local file |
+| yainsd | `yay -S --asdeps` | Install packages as dependencies of another package |
+| yaloc | `yay -Qi` | Display information about a package in the local database |
+| yalocs | `yay -Qs` | Search for packages in the local database |
+| yalst | `yay -Qe` | List installed packages including from AUR (tagged as "local") |
+| yamir | `yay -Syy` | Force refresh of all package lists after updating mirrorlist |
+| yaorph | `yay -Qtd` | Remove orphans using yay |
+| yare | `yay -R` | Remove packages, keeping its settings and dependencies |
+| yarem | `yay -Rns` | Remove packages, including its settings and unneeded dependencies |
+| yarep | `yay -Si` | Display information about a package in the repositories |
+| yareps | `yay -Ss` | Search for packages in the repositories |
+| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
+| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
+| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
+| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
---
+<span id="f1">¹</span>
+The `upgrade` alias is set for all package managers. Its value will depend on
+whether the package manager is installed, checked in the following order:
+
+1. `yay`
+2. `trizen`
+3. `pacaur`
+4. `aura`
+5. `pacman`
+
## Contributors
- Benjamin Boudreau - dreurmail@gmail.com
- Celso Miranda - contacto@celsomiranda.net
+- ratijas (ivan tkachenko) - me@ratijas.tk
+- Juraj Fiala - doctorjellyface@riseup.net
- KhasMek - Boushh@gmail.com
+- Majora320 (Moses Miller) - Majora320@gmail.com
- Martin Putniorz - mputniorz@gmail.com
- MatthR3D - matthr3d@gmail.com
- ornicar - thibault.duplessis@gmail.com
-- Juraj Fiala - doctorjellyface@riseup.net
-- Majora320 (Moses Miller) - Majora320@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
+- Jeff M. Hubbard - jeffmhubbard@gmail.com
diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh
index 2d0c51b3d..0c5782d98 100644
--- a/plugins/archlinux/archlinux.plugin.zsh
+++ b/plugins/archlinux/archlinux.plugin.zsh
@@ -1,138 +1,6 @@
-if (( $+commands[trizen] )); then
- alias trconf='trizen -C'
- alias trupg='trizen -Syua'
- alias trsu='trizen -Syua --noconfirm'
- alias trin='trizen -S'
- alias trins='trizen -U'
- alias trre='trizen -R'
- alias trrem='trizen -Rns'
- alias trrep='trizen -Si'
- alias trreps='trizen -Ss'
- alias trloc='trizen -Qi'
- alias trlocs='trizen -Qs'
- alias trlst='trizen -Qe'
- alias trorph='trizen -Qtd'
- alias trinsd='trizen -S --asdeps'
- alias trmir='trizen -Syy'
-
-
- if (( $+commands[abs] && $+commands[aur] )); then
- alias trupd='trizen -Sy && sudo abs && sudo aur'
- elif (( $+commands[abs] )); then
- alias trupd='trizen -Sy && sudo abs'
- elif (( $+commands[aur] )); then
- alias trupd='trizen -Sy && sudo aur'
- else
- alias trupd='trizen -Sy'
- fi
-fi
-
-if (( $+commands[yaourt] )); then
- alias yaconf='yaourt -C'
- alias yaupg='yaourt -Syua'
- alias yasu='yaourt -Syua --noconfirm'
- alias yain='yaourt -S'
- alias yains='yaourt -U'
- alias yare='yaourt -R'
- alias yarem='yaourt -Rns'
- alias yarep='yaourt -Si'
- alias yareps='yaourt -Ss'
- alias yaloc='yaourt -Qi'
- alias yalocs='yaourt -Qs'
- alias yalst='yaourt -Qe'
- alias yaorph='yaourt -Qtd'
- alias yainsd='yaourt -S --asdeps'
- alias yamir='yaourt -Syy'
-
-
- if (( $+commands[abs] && $+commands[aur] )); then
- alias yaupd='yaourt -Sy && sudo abs && sudo aur'
- elif (( $+commands[abs] )); then
- alias yaupd='yaourt -Sy && sudo abs'
- elif (( $+commands[aur] )); then
- alias yaupd='yaourt -Sy && sudo aur'
- else
- alias yaupd='yaourt -Sy'
- fi
-fi
-
-if (( $+commands[yay] )); then
- alias yaconf='yay -Pg'
- alias yaupg='yay -Syu'
- alias yasu='yay -Syu --noconfirm'
- alias yain='yay -S'
- alias yains='yay -U'
- alias yare='yay -R'
- alias yarem='yay -Rns'
- alias yarep='yay -Si'
- alias yareps='yay -Ss'
- alias yaloc='yay -Qi'
- alias yalocs='yay -Qs'
- alias yalst='yay -Qe'
- alias yaorph='yay -Qtd'
- alias yainsd='yay -S --asdeps'
- alias yamir='yay -Syy'
-
-
- if (( $+commands[abs] && $+commands[aur] )); then
- alias yaupd='yay -Sy && sudo abs && sudo aur'
- elif (( $+commands[abs] )); then
- alias yaupd='yay -Sy && sudo abs'
- elif (( $+commands[aur] )); then
- alias yaupd='yay -Sy && sudo aur'
- else
- alias yaupd='yay -Sy'
- fi
-fi
-
-if (( $+commands[pacaur] )); then
- alias paupg='pacaur -Syu'
- alias pasu='pacaur -Syu --noconfirm'
- alias pain='pacaur -S'
- alias pains='pacaur -U'
- alias pare='pacaur -R'
- alias parem='pacaur -Rns'
- alias parep='pacaur -Si'
- alias pareps='pacaur -Ss'
- alias paloc='pacaur -Qi'
- alias palocs='pacaur -Qs'
- alias palst='pacaur -Qe'
- alias paorph='pacaur -Qtd'
- alias painsd='pacaur -S --asdeps'
- alias pamir='pacaur -Syy'
-
- if (( $+commands[abs] && $+commands[aur] )); then
- alias paupd='pacaur -Sy && sudo abs && sudo aur'
- elif (( $+commands[abs] )); then
- alias paupd='pacaur -Sy && sudo abs'
- elif (( $+commands[aur] )); then
- alias paupd='pacaur -Sy && sudo aur'
- else
- alias paupd='pacaur -Sy'
- fi
-fi
-
-if (( $+commands[trizen] )); then
- function upgrade() {
- trizen -Syu
- }
-elif (( $+commands[pacaur] )); then
- function upgrade() {
- pacaur -Syu
- }
-elif (( $+commands[yaourt] )); then
- function upgrade() {
- yaourt -Syu
- }
-elif (( $+commands[yay] )); then
- function upgrade() {
- yay -Syu
- }
-else
- function upgrade() {
- sudo pacman -Syu
- }
-fi
+#######################################
+# Pacman #
+#######################################
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu'
@@ -152,33 +20,24 @@ alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -F'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
-
-
-if (( $+commands[abs] && $+commands[aur] )); then
- alias pacupd='sudo pacman -Sy && sudo abs && sudo aur'
-elif (( $+commands[abs] )); then
- alias pacupd='sudo pacman -Sy && sudo abs'
-elif (( $+commands[aur] )); then
- alias pacupd='sudo pacman -Sy && sudo aur'
-else
- alias pacupd='sudo pacman -Sy'
-fi
+alias pacupd="sudo pacman -Sy"
+alias upgrade='sudo pacman -Syu'
function paclist() {
- # Source: https://bbs.archlinux.org/viewtopic.php?id=93683
- LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \
- awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}'
+ # Based on https://bbs.archlinux.org/viewtopic.php?id=93683
+ pacman -Qqe | \
+ xargs -I '{}' \
+ expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
}
function pacdisowned() {
- emulate -L zsh
-
+ local tmp db fs
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
mkdir "$tmp"
- trap 'rm -rf "$tmp"' EXIT
+ trap 'rm -rf "$tmp"' EXIT
pacman -Qlq | sort -u > "$db"
@@ -188,16 +47,11 @@ function pacdisowned() {
comm -23 "$fs" "$db"
}
-function pacmanallkeys() {
- emulate -L zsh
- curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \
- awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \
- xargs sudo pacman-key --recv-keys
-}
+alias pacmanallkeys='sudo pacman-key --refresh-keys'
function pacmansignkeys() {
- emulate -L zsh
- for key in $*; do
+ local key
+ for key in $@; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
@@ -207,13 +61,114 @@ function pacmansignkeys() {
if (( $+commands[xdg-open] )); then
function pacweb() {
- pkg="$1"
- infos="$(LANG=C pacman -Si "$pkg")"
+ if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then
+ local underline_color="\e[${color[underline]}m"
+ echo "$0 - open the website of an ArchLinux package"
+ echo
+ echo "Usage:"
+ echo " $bold_color$0$reset_color ${underline_color}target${reset_color}"
+ return 1
+ fi
+
+ local pkg="$1"
+ local infos="$(LANG=C pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
- repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
- arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
+ local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
+ local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi
+
+#######################################
+# AUR helpers #
+#######################################
+
+if (( $+commands[aura] )); then
+ alias auin='sudo aura -S'
+ alias aurin='sudo aura -A'
+ alias auins='sudo aura -U'
+ alias auinsd='sudo aura -S --asdeps'
+ alias aurinsd='sudo aura -A --asdeps'
+ alias auloc='aura -Qi'
+ alias aulocs='aura -Qs'
+ alias aulst='aura -Qe'
+ alias aumir='sudo aura -Syy'
+ alias aurph='sudo aura -Oj'
+ alias aure='sudo aura -R'
+ alias aurem='sudo aura -Rns'
+ alias aurep='aura -Si'
+ alias aurrep='aura -Ai'
+ alias aureps='aura -As --both'
+ alias auras='aura -As --both'
+ alias auupd="sudo aura -Sy"
+ alias auupg='sudo sh -c "aura -Syu && aura -Au"'
+ alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
+ alias upgrade='sudo aura -Syu'
+
+ # extra bonus specially for aura
+ alias auown="aura -Qqo"
+ alias auls="aura -Qql"
+ function auownloc() { aura -Qi $(aura -Qqo $@); }
+ function auownls () { aura -Qql $(aura -Qqo $@); }
+fi
+
+if (( $+commands[pacaur] )); then
+ alias paupg='pacaur -Syu'
+ alias pasu='pacaur -Syu --noconfirm'
+ alias pain='pacaur -S'
+ alias pains='pacaur -U'
+ alias pare='pacaur -R'
+ alias parem='pacaur -Rns'
+ alias parep='pacaur -Si'
+ alias pareps='pacaur -Ss'
+ alias paloc='pacaur -Qi'
+ alias palocs='pacaur -Qs'
+ alias palst='pacaur -Qe'
+ alias paorph='pacaur -Qtd'
+ alias painsd='pacaur -S --asdeps'
+ alias pamir='pacaur -Syy'
+ alias paupd="pacaur -Sy"
+ alias upgrade='pacaur -Syu'
+fi
+
+if (( $+commands[trizen] )); then
+ alias trconf='trizen -C'
+ alias trupg='trizen -Syua'
+ alias trsu='trizen -Syua --noconfirm'
+ alias trin='trizen -S'
+ alias trins='trizen -U'
+ alias trre='trizen -R'
+ alias trrem='trizen -Rns'
+ alias trrep='trizen -Si'
+ alias trreps='trizen -Ss'
+ alias trloc='trizen -Qi'
+ alias trlocs='trizen -Qs'
+ alias trlst='trizen -Qe'
+ alias trorph='trizen -Qtd'
+ alias trinsd='trizen -S --asdeps'
+ alias trmir='trizen -Syy'
+ alias trupd="trizen -Sy"
+ alias upgrade='trizen -Syu'
+fi
+
+if (( $+commands[yay] )); then
+ alias yaconf='yay -Pg'
+ alias yaupg='yay -Syu'
+ alias yasu='yay -Syu --noconfirm'
+ alias yain='yay -S'
+ alias yains='yay -U'
+ alias yare='yay -R'
+ alias yarem='yay -Rns'
+ alias yarep='yay -Si'
+ alias yareps='yay -Ss'
+ alias yaloc='yay -Qi'
+ alias yalocs='yay -Qs'
+ alias yalst='yay -Qe'
+ alias yaorph='yay -Qtd'
+ alias yainsd='yay -S --asdeps'
+ alias yamir='yay -Syy'
+ alias yaupd="yay -Sy"
+ alias upgrade='yay -Syu'
+fi
diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh
index f40b0e931..3117c6da4 100644
--- a/plugins/autojump/autojump.plugin.zsh
+++ b/plugins/autojump/autojump.plugin.zsh
@@ -10,6 +10,7 @@ autojump_paths=(
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
+ /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
)
for file in $autojump_paths; do
diff --git a/plugins/aws/README.md b/plugins/aws/README.md
index 57c3b54ac..011bbd8b4 100644
--- a/plugins/aws/README.md
+++ b/plugins/aws/README.md
@@ -15,6 +15,13 @@ plugins=(... aws)
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile.
+* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by
+ assuming the role specified in the `<profile>` configuration. It supports MFA and sets
+ `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
+ requires the roles to be configured as per the
+ [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
+ Run `acp` without arguments to clear the profile.
+
* `agp`: gets the current value of `$AWS_PROFILE`.
* `aws_change_access_key`: changes the AWS access key of a profile.
@@ -33,6 +40,36 @@ plugins=(... aws)
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
-- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
+* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
+
+* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
+
+## Configuration
+
+[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
-- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
+### Scenario: IAM roles with a source profile and MFA authentication
+
+Source profile credentials in `~/.aws/credentials`:
+
+```
+[source-profile-name]
+aws_access_key_id = ...
+aws_secret_access_key = ...
+```
+
+Role configuration in `~/.aws/config`:
+
+```
+[profile source-profile-name]
+mfa_serial = arn:aws:iam::111111111111:mfa/myuser
+region = us-east-1
+output = json
+
+[profile profile-with-role]
+role_arn = arn:aws:iam::9999999999999:role/myrole
+mfa_serial = arn:aws:iam::111111111111:mfa/myuser
+source_profile = source-profile-name
+region = us-east-1
+output = json
+```
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
index 4b5446407..2d095635b 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -23,31 +23,131 @@ function asp() {
export AWS_EB_PROFILE=$1
}
+# AWS profile switch
+function acp() {
+ if [[ -z "$1" ]]; then
+ unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
+ unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
+ echo AWS profile cleared.
+ return
+ fi
+
+ local -a available_profiles
+ available_profiles=($(aws_profiles))
+ if [[ -z "${available_profiles[(r)$1]}" ]]; then
+ echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
+ echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
+ return 1
+ fi
+
+ local profile="$1"
+
+ # Get fallback credentials for if the aws command fails or no command is run
+ local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
+ local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
+ local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
+
+
+ # First, if the profile has MFA configured, lets get the token and session duration
+ local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
+ local sess_duration="$(aws configure get duration_seconds --profile $profile)"
+
+ if [[ -n "$mfa_serial" ]]; then
+ local -a mfa_opt
+ local mfa_token
+ echo -n "Please enter your MFA token for $mfa_serial: "
+ read -r mfa_token
+ if [[ -z "$sess_duration" ]]; then
+ echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
+ read -r sess_duration
+ fi
+ mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
+ fi
+
+ # Now see whether we need to just MFA for the current role, or assume a different one
+ local role_arn="$(aws configure get role_arn --profile $profile)"
+ local sess_name="$(aws configure get role_session_name --profile $profile)"
+
+ if [[ -n "$role_arn" ]]; then
+ # Means we need to assume a specified role
+ aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
+
+ # Check whether external_id is configured to use while assuming the role
+ local external_id="$(aws configure get external_id --profile $profile)"
+ if [[ -n "$external_id" ]]; then
+ aws_command+=(--external-id "$external_id")
+ fi
+
+ # Get source profile to use to assume role
+ local source_profile="$(aws configure get source_profile --profile $profile)"
+ if [[ -z "$sess_name" ]]; then
+ sess_name="${source_profile:-profile}"
+ fi
+ aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
+
+ echo "Assuming role $role_arn using profile ${source_profile:-profile}"
+ else
+ # Means we only need to do MFA
+ aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
+ echo "Obtaining session token for profile $profile"
+ fi
+
+ # Format output of aws command for easier processing
+ aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
+
+ # Run the aws command to obtain credentials
+ local -a credentials
+ credentials=(${(ps:\t:)"$(${aws_command[@]})"})
+
+ if [[ -n "$credentials" ]]; then
+ aws_access_key_id="${credentials[1]}"
+ aws_secret_access_key="${credentials[2]}"
+ aws_session_token="${credentials[3]}"
+ fi
+
+ # Switch to AWS profile
+ if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
+ export AWS_DEFAULT_PROFILE="$profile"
+ export AWS_PROFILE="$profile"
+ export AWS_EB_PROFILE="$profile"
+ export AWS_ACCESS_KEY_ID="$aws_access_key_id"
+ export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
+
+ if [[ -n "$aws_session_token" ]]; then
+ export AWS_SESSION_TOKEN="$aws_session_token"
+ else
+ unset AWS_SESSION_TOKEN
+ fi
+
+ echo "Switched to AWS Profile: $profile"
+ fi
+}
+
function aws_change_access_key() {
if [[ -z "$1" ]]; then
echo "usage: $0 <profile>"
return 1
fi
- echo Insert the credentials when asked.
+ echo "Insert the credentials when asked."
asp "$1" || return 1
AWS_PAGER="" aws iam create-access-key
AWS_PAGER="" aws configure --profile "$1"
- echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`
- echo Your current keys are:
+ echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
+ echo "Your current keys are:"
AWS_PAGER="" aws iam list-access-keys
}
function aws_profiles() {
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
- grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'
+ grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
}
function _aws_profiles() {
reply=($(aws_profiles))
}
-compctl -K _aws_profiles asp aws_change_access_key
+compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
@@ -55,7 +155,7 @@ function aws_prompt_info() {
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
}
-if [ "$SHOW_AWS_PROMPT" != false ]; then
+if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi
@@ -63,7 +163,7 @@ fi
# Load awscli completions
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
-if [[ -x /usr/local/bin/aws_completer ]]; then
+if command -v aws_completer &> /dev/null; then
autoload -Uz bashcompinit && bashcompinit
complete -C aws_completer aws
else
diff --git a/plugins/battery/README.md b/plugins/battery/README.md
index b7a13a7ec..18e5bd882 100644
--- a/plugins/battery/README.md
+++ b/plugins/battery/README.md
@@ -8,6 +8,22 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
Then, add the `battery_pct_prompt` function to your custom theme. For example:
+```zsh
+RPROMPT='$(battery_pct_prompt) ...'
```
-RPROMPT='$(battery_pct_prompt)'
-```
+
+## Requirements
+
+- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
+ On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
+
+- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
+
+ 1. The `Termux:API` addon app installed:
+ [Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
+
+ 2. The `termux-api` package installed within termux:
+
+ ```sh
+ pkg install termux-api
+ ```
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index 755ec8d64..db5eeb93a 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -10,20 +10,17 @@
# Author: J (927589452) #
# Modified to add support for FreeBSD #
###########################################
+# Author: Avneet Singh (kalsi-avneet) #
+# Modified to add support for Android #
+###########################################
if [[ "$OSTYPE" = darwin* ]]; then
-
function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
-
function battery_pct() {
- local battery_status="$(ioreg -rc AppleSmartBattery)"
- local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
- local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
- echo $(( current * 100 / capacity ))
+ pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
-
function battery_pct_remaining() {
if battery_is_charging; then
echo "External Power"
@@ -31,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
battery_pct
fi
}
-
function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
@@ -45,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
echo "∞"
fi
}
-
function battery_pct_prompt () {
local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
@@ -64,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
elif [[ "$OSTYPE" = freebsd* ]]; then
-
function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
}
-
function battery_pct() {
if (( $+commands[sysctl] )); then
sysctl -n hw.acpi.battery.life
fi
}
-
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
@@ -82,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "External Power"
fi
}
-
function battery_time_remaining() {
local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time)
@@ -92,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
printf %02d:%02d $hour $minute
fi
}
-
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
@@ -109,19 +99,83 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
-
+elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
+ function battery_is_charging() {
+ termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
+ }
+ function battery_pct() {
+ # Sample output:
+ # {
+ # "health": "GOOD",
+ # "percentage": 93,
+ # "plugged": "UNPLUGGED",
+ # "status": "DISCHARGING",
+ # "temperature": 29.0,
+ # "current": 361816
+ # }
+ termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
+ }
+ function battery_pct_remaining() {
+ if ! battery_is_charging; then
+ battery_pct
+ else
+ echo "External Power"
+ fi
+ }
+ function battery_time_remaining() { } # Not available on android
+ function battery_pct_prompt() {
+ local battery_pct color
+ battery_pct=$(battery_pct_remaining)
+ if battery_is_charging; then
+ echo "∞"
+ else
+ if [[ $battery_pct -gt 50 ]]; then
+ color='green'
+ elif [[ $battery_pct -gt 20 ]]; then
+ color='yellow'
+ else
+ color='red'
+ fi
+ echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
+ fi
+ }
elif [[ "$OSTYPE" = linux* ]]; then
-
function battery_is_charging() {
- ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
+ if (( $+commands[acpitool] )); then
+ ! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
+ elif (( $+commands[acpi] )); then
+ ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
+ fi
}
-
function battery_pct() {
- if (( $+commands[acpi] )); then
- acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]'
+ if (( $+commands[acpitool] )); then
+ # Sample output:
+ # Battery #1 : Unknown, 99.55%
+ # Battery #2 : Discharging, 49.58%, 01:12:05
+ # All batteries : 62.60%, 02:03:03
+ local -i pct=$(acpitool 2>/dev/null | command awk -F, '
+ /^\s+All batteries/ {
+ gsub(/[^0-9.]/, "", $1)
+ pct=$1
+ exit
+ }
+ !pct && /^\s+Battery/ {
+ gsub(/[^0-9.]/, "", $2)
+ pct=$2
+ }
+ END { print pct }
+ ')
+ echo $pct
+ elif (( $+commands[acpi] )); then
+ # Sample output:
+ # Battery 0: Discharging, 0%, rate information unavailable
+ # Battery 1: Full, 100%
+ acpi 2>/dev/null | command awk -F, '
+ /rate information unavailable/ { next }
+ /^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
+ '
fi
}
-
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
@@ -129,13 +183,11 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "External Power"
fi
}
-
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
-
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
@@ -152,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
-
else
# Empty functions so we don't cause errors in prompts
function battery_is_charging { false }
@@ -177,7 +228,7 @@ function battery_level_gauge() {
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
- local battery_remaining_percentage=$(battery_pct)
+ local -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
diff --git a/plugins/bedtools/README.md b/plugins/bedtools/README.md
new file mode 100644
index 000000000..c4de4e3a9
--- /dev/null
+++ b/plugins/bedtools/README.md
@@ -0,0 +1,5 @@
+# Bedtools plugin
+
+This plugin adds support for the [bedtools suite](http://bedtools.readthedocs.org/en/latest/):
+
+* Adds autocomplete options for all bedtools sub commands.
diff --git a/plugins/bedtools/_bedtools b/plugins/bedtools/_bedtools
new file mode 100644
index 000000000..ef6c4179a
--- /dev/null
+++ b/plugins/bedtools/_bedtools
@@ -0,0 +1,64 @@
+#compdef bedtools
+#autoload
+
+local curcontext="$curcontext" state line ret=1
+local -a _files
+
+_arguments -C \
+ '1: :->cmds' \
+ '2:: :->args' && ret=0
+
+case $state in
+ cmds)
+ _values "bedtools command" \
+ "--contact[Feature requests, bugs, mailing lists, etc.]" \
+ "--help[Print this help menu.]" \
+ "--version[What version of bedtools are you using?.]" \
+ "annotate[Annotate coverage of features from multiple files.]" \
+ "bamtobed[Convert BAM alignments to BED (& other) formats.]" \
+ "bamtofastq[Convert BAM records to FASTQ records.]" \
+ "bed12tobed6[Breaks BED12 intervals into discrete BED6 intervals.]" \
+ "bedpetobam[Convert BEDPE intervals to BAM records.]" \
+ "bedtobam[Convert intervals to BAM records.]" \
+ "closest[Find the closest, potentially non-overlapping interval.]" \
+ "cluster[Cluster (but don't merge) overlapping/nearby intervals.]" \
+ "complement[Extract intervals _not_ represented by an interval file.]" \
+ "coverage[Compute the coverage over defined intervals.]" \
+ "expand[Replicate lines based on lists of values in columns.]" \
+ "fisher[Calculate Fisher statistic b/w two feature files.]" \
+ "flank[Create new intervals from the flanks of existing intervals.]" \
+ "genomecov[Compute the coverage over an entire genome.]" \
+ "getfasta[Use intervals to extract sequences from a FASTA file.]" \
+ "groupby[Group by common cols. & summarize oth. cols. (~ SQL "groupBy")]" \
+ "igv[Create an IGV snapshot batch script.]" \
+ "intersect[Find overlapping intervals in various ways.]" \
+ "jaccard[Calculate the Jaccard statistic b/w two sets of intervals.]" \
+ "links[Create a HTML page of links to UCSC locations.]" \
+ "makewindows[Make interval "windows" across a genome.]" \
+ "map[Apply a function to a column for each overlapping interval.]" \
+ "maskfasta[Use intervals to mask sequences from a FASTA file.]" \
+ "merge[Combine overlapping/nearby intervals into a single interval.]" \
+ "multicov[Counts coverage from multiple BAMs at specific intervals.]" \
+ "multiinter[Identifies common intervals among multiple interval files.]" \
+ "nuc[Profile the nucleotide content of intervals in a FASTA file.]" \
+ "overlap[Computes the amount of overlap from two intervals.]" \
+ "pairtobed[Find pairs that overlap intervals in various ways.]" \
+ "pairtopair[Find pairs that overlap other pairs in various ways.]" \
+ "random[Generate random intervals in a genome.]" \
+ "reldist[Calculate the distribution of relative distances b/w two files.]" \
+ "sample[Sample random records from file using reservoir sampling.]" \
+ "shuffle[Randomly redistrubute intervals in a genome.]" \
+ "slop[Adjust the size of intervals.]" \
+ "sort[Order the intervals in a file.]" \
+ "subtract[Remove intervals based on overlaps b/w two files.]" \
+ "tag[Tag BAM alignments based on overlaps with interval files.]" \
+ "unionbedg[Combines coverage intervals from multiple BEDGRAPH files.]" \
+ "window[Find overlapping intervals within a window around an interval.]" \
+ ret=0
+ ;;
+ *)
+ _files
+ ;;
+esac
+
+return ret
diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
index b3a6890b8..aecde20ea 100644
--- a/plugins/bgnotify/bgnotify.plugin.zsh
+++ b/plugins/bgnotify/bgnotify.plugin.zsh
@@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS
- bgnotify_lastcmd="$1"
+ bgnotify_lastcmd="${1:-$2}"
bgnotify_windowid=$(currentWindowId)
}
diff --git a/plugins/bower/bower.plugin.zsh b/plugins/bower/bower.plugin.zsh
index 6019b9d37..3a40b3af0 100644
--- a/plugins/bower/bower.plugin.zsh
+++ b/plugins/bower/bower.plugin.zsh
@@ -1,4 +1,6 @@
alias bi="bower install"
+alias bisd="bower install --save-dev"
+alias bis="bower install --save"
alias bl="bower list"
alias bs="bower search"
diff --git a/plugins/brew/README.md b/plugins/brew/README.md
index 44af05225..bf952bf01 100644
--- a/plugins/brew/README.md
+++ b/plugins/brew/README.md
@@ -10,16 +10,17 @@ plugins=(... brew)
## Aliases
-| Alias | Command | Description |
-|----------|-------------------------------------------------------------|---------------------------------------------------------------------|
-| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
-| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
-| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
-| `bubo` | `brew update && brew outdated` | Update Homebrew and all formulae, then list outdated formulae. |
-| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae, then run cleanup. |
-| `bubu` | `bubo && bubc` | Do the last two operations above. |
-| `bcubo` | `brew update && brew cask outdated` | Update Homebrew and alll formulae, then list outdated casks. |
-| `bcubc` | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Update outdated casks, then run cleanup. |
+| Alias | Command | Description |
+|----------|---------------------------------------|---------------------------------------------------------------------|
+| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
+| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
+| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
+| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
+| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
+| `bubu` | `bubo && bubc` | Do the last two operations above. |
+| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
+| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
+| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
## Completion
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index fdea76c74..532dd9be7 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -4,5 +4,6 @@ alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc'
-alias bcubo='brew update && brew cask outdated'
-alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup'
+alias buf='brew upgrade --formula'
+alias bcubo='brew update && brew outdated --cask'
+alias bcubc='brew upgrade --cask && brew cleanup'
diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md
index a3bceb0ae..7b79cbcdc 100644
--- a/plugins/bundler/README.md
+++ b/plugins/bundler/README.md
@@ -1,34 +1,48 @@
# Bundler
-- Adds completion for basic bundler commands
-
-- Adds short aliases for common bundler commands
- - `ba` aliased to `bundle add`
- - `be` aliased to `bundle exec`.
- It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`).
- - `bl` aliased to `bundle list`
- - `bp` aliased to `bundle package`
- - `bo` aliased to `bundle open`
- - `bout` aliased to `bundle outdated`
- - `bu` aliased to `bundle update`
- - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`)
- - `bcn` aliased to `bundle clean`
- - `bck` aliased to `bundle check`
-
-- Adds a wrapper for common gems:
- - Looks for a binstub under `./bin/` and executes it (if present)
- - Calls `bundle exec <gem executable>` otherwise
+This plugin adds completion for basic bundler commands, as well as aliases and helper functions for
+an easier experience with bundler.
+
+To use it, add `bundler` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... bundler)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|--------|--------------------------------------|------------------------------------------------------------------------------------------|
+| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install |
+| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems |
+| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory |
+| `be` | `bundle exec` | Execute a command in the context of the bundle |
+| `bi` | `bundle install --jobs=<core_count>` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) |
+| `bl` | `bundle list` | List all the gems in the bundle |
+| `bo` | `bundle open` | Opens the source directory for a gem in your bundle |
+| `bout` | `bundle outdated` | List installed gems with newer versions available |
+| `bp` | `bundle package` | Package your needed .gem files into your application |
+| `bu` | `bundle update` | Update your gems to the latest available versions |
+
+## Gem wrapper
+
+The plugin adds a wrapper for common gems, which:
+
+- Looks for a binstub under `./bin/` and executes it if present.
+- Calls `bundle exec <gem>` otherwise.
Common gems wrapped by default (by name of the executable):
+
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
-## Configuration
+### Settings
-Please use the exact name of the executable and not the gem name.
+You can add or remove gems from the list of wrapped commands.
+Please **use the exact name of the executable** and not the gem name.
-### Add additional gems to be wrapped
+#### Include gems to be wrapped (`BUNDLED_COMMANDS`)
-Add this before the plugin-list in your `.zshrc`:
+Add this before the plugin list in your `.zshrc`:
```sh
BUNDLED_COMMANDS=(rubocop)
@@ -37,10 +51,9 @@ plugins=(... bundler ...)
This will add the wrapper for the `rubocop` gem (i.e. the executable).
+#### Exclude gems from being wrapped (`UNBUNDLED_COMMANDS`)
-### Exclude gems from being wrapped
-
-Add this before the plugin-list in your `.zshrc`:
+Add this before the plugin list in your `.zshrc`:
```sh
UNBUNDLED_COMMANDS=(foreman spin)
@@ -49,13 +62,13 @@ plugins=(... bundler ...)
This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
-## Excluded gems
+### Excluded gems
-These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification.
+These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification:
-`berks`
-`foreman`
-`mailcatcher`
-`rails`
-`ruby`
-`spin`
+- `berks`
+- `foreman`
+- `mailcatcher`
+- `rails`
+- `ruby`
+- `spin`
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index 65b0ffa6e..6293dc28a 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -1,13 +1,49 @@
+## Aliases
+
alias ba="bundle add"
+alias bck="bundle check"
+alias bcn="bundle clean"
alias be="bundle exec"
+alias bi="bundle_install"
alias bl="bundle list"
-alias bp="bundle package"
alias bo="bundle open"
alias bout="bundle outdated"
+alias bp="bundle package"
alias bu="bundle update"
-alias bi="bundle_install"
-alias bcn="bundle clean"
-alias bck="bundle check"
+
+## Functions
+
+bundle_install() {
+ # Bail out if bundler is not installed
+ if (( ! $+commands[bundle] )); then
+ echo "Bundler is not installed"
+ return 1
+ fi
+
+ # Bail out if not in a bundled project
+ if ! _within-bundled-project; then
+ echo "Can't 'bundle install' outside a bundled project"
+ return 1
+ fi
+
+ # Check the bundler version is at least 1.4.0
+ autoload -Uz is-at-least
+ local bundler_version=$(bundle version | cut -d' ' -f3)
+ if ! is-at-least 1.4.0 "$bundler_version"; then
+ bundle install "$@"
+ return $?
+ fi
+
+ # If bundler is at least 1.4.0, use all the CPU cores to bundle install
+ if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then
+ local cores_num="$(sysctl -n hw.ncpu)"
+ else
+ local cores_num="$(nproc)"
+ fi
+ bundle install --jobs="$cores_num" "$@"
+}
+
+## Gem wrapper
bundled_commands=(
annotate
@@ -54,65 +90,41 @@ for cmd in $BUNDLED_COMMANDS; do
bundled_commands+=($cmd);
done
-## Functions
-
-bundle_install() {
- if ! _bundler-installed; then
- echo "Bundler is not installed"
- elif ! _within-bundled-project; then
- echo "Can't 'bundle install' outside a bundled project"
- else
- local bundler_version=`bundle version | cut -d' ' -f3`
- if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
- if [[ "$OSTYPE" = (darwin|freebsd)* ]]
- then
- local cores_num="$(sysctl -n hw.ncpu)"
- else
- local cores_num="$(nproc)"
- fi
- bundle install --jobs=$cores_num $@
- else
- bundle install $@
- fi
- fi
-}
-
-_bundler-installed() {
- which bundle > /dev/null 2>&1
-}
-
+# Check if in the root or a subdirectory of a bundled project
_within-bundled-project() {
local check_dir="$PWD"
- while [ "$check_dir" != "/" ]; do
- [ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return
- check_dir="$(dirname $check_dir)"
+ while [[ "$check_dir" != "/" ]]; do
+ if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
+ return 0
+ fi
+ check_dir="${check_dir:h}"
done
- false
-}
-
-_binstubbed() {
- [ -f "./bin/${1}" ]
+ return 1
}
_run-with-bundler() {
- if _bundler-installed && _within-bundled-project; then
- if _binstubbed $1; then
- ./bin/${^^@}
- else
- bundle exec $@
- fi
+ if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
+ "$@"
+ return $?
+ fi
+
+ if [[ -f "./bin/${1}" ]]; then
+ ./bin/${^^@}
else
- $@
+ bundle exec "$@"
fi
}
-## Main program
for cmd in $bundled_commands; do
- eval "function unbundled_$cmd () { $cmd \$@ }"
- eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
- alias $cmd=bundled_$cmd
+ # Create wrappers for bundled and unbundled execution
+ eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
+ eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
+ alias "$cmd"="bundled_$cmd"
- if which _$cmd > /dev/null 2>&1; then
- compdef _$cmd bundled_$cmd=$cmd
+ # Bind completion function to wrapped gem if available
+ if (( $+functions[_$cmd] )); then
+ compdef "_$cmd" "bundled_$cmd"="$cmd"
fi
done
+
+unset cmd bundled_commands
diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo
deleted file mode 100644
index 12694901e..000000000
--- a/plugins/cargo/_cargo
+++ /dev/null
@@ -1,407 +0,0 @@
-#compdef cargo
-
-autoload -U regexp-replace
-
-_cargo() {
- local curcontext="$curcontext" ret=1
- local -a command_scope_spec common parallel features msgfmt triple target registry
- local -a state line state_descr # These are set by _arguments
- typeset -A opt_args
-
- common=(
- '(-q --quiet)*'{-v,--verbose}'[use verbose output]'
- '(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
- '-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
- '--frozen[require that Cargo.lock and cache are up-to-date]'
- '--locked[require that Cargo.lock is up-to-date]'
- '--color=[specify colorization option]:coloring:(auto always never)'
- '(- 1 *)'{-h,--help}'[show help message]'
- )
-
- # leading items in parentheses are an exclusion list for the arguments following that arg
- # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
- # - => exclude all other options
- # 1 => exclude positional arg 1
- # * => exclude all other args
- # +blah => exclude +blah
- _arguments -s -S -C $common \
- '(- 1 *)--list[list installed commands]' \
- '(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
- '(- 1 *)'{-V,--version}'[show version information]' \
- '(+beta +nightly)+stable[use the stable toolchain]' \
- '(+stable +nightly)+beta[use the beta toolchain]' \
- '(+stable +beta)+nightly[use the nightly toolchain]' \
- '1: :_cargo_cmds' \
- '*:: :->args'
-
- # These flags are mutually exclusive specifiers for the scope of a command; as
- # they are used in multiple places without change, they are expanded into the
- # appropriate command's `_arguments` where appropriate.
- command_scope_spec=(
- '(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
- '(--bench --bin --test --lib)--example=[specify example name]:example name'
- '(--bench --example --test --lib)--bin=[specify binary name]:binary name'
- '(--bench --bin --example --test)--lib=[specify library name]:library name'
- '(--bench --bin --example --lib)--test=[specify test name]:test name'
- )
-
- parallel=(
- '(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
- )
-
- features=(
- '(--all-features)--features=[specify features to activate]:feature'
- '(--features)--all-features[activate all available features]'
- "--no-default-features[don't build the default features]"
- )
-
- msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
- triple='--target=[specify target triple]:target triple'
- target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
- manifest='--manifest-path=[specify path to manifest]:path:_directories'
- registry='--registry=[specify registry to use]:registry'
-
- case $state in
- args)
- curcontext="${curcontext%:*}-${words[1]}:"
- case ${words[1]} in
- bench)
- _arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
- "${command_scope_spec[@]}" \
- '--all-targets[benchmark all targets]' \
- "--no-run[compile but don't run]" \
- '(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
- '--exclude=[exclude packages from the benchmark]:spec' \
- '--no-fail-fast[run all benchmarks regardless of failure]' \
- '1: :_guard "^-*" "bench name"' \
- '*:args:_default'
- ;;
-
- build)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
- "${command_scope_spec[@]}" \
- '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
- '--release[build in release mode]' \
- '--build-plan[output the build plan in JSON]' \
- ;;
-
- check)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
- "${command_scope_spec[@]}" \
- '(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
- '--release[check in release mode]' \
- ;;
-
- clean)
- _arguments -s -S $common $triple $target $manifest \
- '(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
- '--release[clean release artifacts]' \
- '--doc[clean just the documentation directory]'
- ;;
-
- doc)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '--no-deps[do not build docs for dependencies]' \
- '--document-private-items[include non-public items in the documentation]' \
- '--open[open docs in browser after the build]' \
- '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
- '--release[build artifacts in release mode, with optimizations]' \
- ;;
-
- fetch)
- _arguments -s -S $common $triple $manifest
- ;;
-
- fix)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- "${command_scope_spec[@]}" \
- '--broken-code[fix code even if it already has compiler errors]' \
- '--edition[fix in preparation for the next edition]' \
- '--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
- '--allow-no-vcs[fix code even if a VCS was not detected]' \
- '--allow-dirty[fix code even if the working directory is dirty]' \
- '--allow-staged[fix code even if the working directory has staged changes]'
- ;;
-
- generate-lockfile)
- _arguments -s -S $common $manifest
- ;;
-
- git-checkout)
- _arguments -s -S $common \
- '--reference=:reference' \
- '--url=:url:_urls'
- ;;
-
- help)
- _cargo_cmds
- ;;
-
- init)
- _arguments -s -S $common $registry \
- '--lib[use library template]' \
- '--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
- '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
- '--name=[set the resulting package name]:name' \
- '1:path:_directories'
- ;;
-
- install)
- _arguments -s -S $common $parallel $features $triple $registry \
- '(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
- '--bin=[only install the specified binary]:binary' \
- '--branch=[branch to use when installing from git]:branch' \
- '--debug[build in debug mode instead of release mode]' \
- '--example=[install the specified example instead of binaries]:example' \
- '--git=[specify URL from which to install the crate]:url:_urls' \
- '--path=[local filesystem path to crate to install]: :_directories' \
- '--rev=[specific commit to use when installing from git]:commit' \
- '--root=[directory to install packages into]: :_directories' \
- '--tag=[tag to use when installing from git]:tag' \
- '--vers=[version to install from crates.io]:version' \
- '--list[list all installed packages and their versions]' \
- '*: :_guard "^-*" "crate"'
- ;;
-
- locate-project)
- _arguments -s -S $common $manifest
- ;;
-
- login)
- _arguments -s -S $common $registry \
- '*: :_guard "^-*" "token"'
- ;;
-
- metadata)
- _arguments -s -S $common $features $manifest \
- "--no-deps[output information only about the root package and don't fetch dependencies]" \
- '--format-version=[specify format version]:version [1]:(1)'
- ;;
-
- new)
- _arguments -s -S $common $registry \
- '--lib[use library template]' \
- '--vcs:initialize a new repo with a given VCS:(git hg none)' \
- '--name=[set the resulting package name]'
- ;;
-
- owner)
- _arguments -s -S $common $registry \
- '(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
- '--index=[specify registry index]:index' \
- '(-l --list)'{-l,--list}'[list owners of a crate]' \
- '(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
- '--token=[specify API token to use when authenticating]:token' \
- '*: :_guard "^-*" "crate"'
- ;;
-
- package)
- _arguments -s -S $common $parallel $features $triple $target $manifest \
- '(-l --list)'{-l,--list}'[print files included in a package without making one]' \
- '--no-metadata[ignore warnings about a lack of human-usable metadata]' \
- '--allow-dirty[allow dirty working directories to be packaged]' \
- "--no-verify[don't build to verify contents]"
- ;;
-
- pkgid)
- _arguments -s -S $common $manifest \
- '(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
- '*: :_guard "^-*" "spec"'
- ;;
-
- publish)
- _arguments -s -S $common $parallel $features $triple $target $manifest $registry \
- '--index=[specify registry index]:index' \
- '--allow-dirty[allow dirty working directories to be packaged]' \
- "--no-verify[don't verify the contents by building them]" \
- '--token=[specify token to use when uploading]:token' \
- '--dry-run[perform all checks without uploading]'
- ;;
-
- read-manifest)
- _arguments -s -S $common $manifest
- ;;
-
- run)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '--example=[name of the bin target]:name' \
- '--bin=[name of the bin target]:name' \
- '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
- '--release[build in release mode]' \
- '*: :_default'
- ;;
-
- rustc)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
- '--profile=[specify profile to build the selected target for]:profile' \
- '--release[build artifacts in release mode, with optimizations]' \
- "${command_scope_spec[@]}" \
- '*: : _dispatch rustc rustc -default-'
- ;;
-
- rustdoc)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '--document-private-items[include non-public items in the documentation]' \
- '--open[open the docs in a browser after the operation]' \
- '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
- '--release[build artifacts in release mode, with optimizations]' \
- "${command_scope_spec[@]}" \
- '*: : _dispatch rustdoc rustdoc -default-'
- ;;
-
- search)
- _arguments -s -S $common $registry \
- '--index=[specify registry index]:index' \
- '--limit=[limit the number of results]:results [10]' \
- '*: :_guard "^-*" "query"'
- ;;
-
- test)
- _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
- '--test=[test name]: :_cargo_test_names' \
- '--no-fail-fast[run all tests regardless of failure]' \
- '--no-run[compile but do not run]' \
- '(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
- '--all[test all packages in the workspace]' \
- '--release[build artifacts in release mode, with optimizations]' \
- '1: :_cargo_test_names' \
- '(--doc --bin --example --test --bench)--lib[only test library]' \
- '(--lib --bin --example --test --bench)--doc[only test documentation]' \
- '(--lib --doc --example --test --bench)--bin=[binary name]' \
- '(--lib --doc --bin --test --bench)--example=[example name]' \
- '(--lib --doc --bin --example --bench)--test=[test name]' \
- '(--lib --doc --bin --example --test)--bench=[benchmark name]' \
- '*: :_default'
- ;;
-
- uninstall)
- _arguments -s -S $common \
- '(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
- '--bin=[only uninstall the specified binary]:name' \
- '--root=[directory to uninstall packages from]: :_files -/' \
- '*:crate:_cargo_installed_crates -F line'
- ;;
-
- update)
- _arguments -s -S $common $manifest \
- '--aggressive=[force dependency update]' \
- "--dry-run[don't actually write the lockfile]" \
- '(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
- '--precise=[update single dependency to precise release]:release'
- ;;
-
- verify-project)
- _arguments -s -S $common $manifest
- ;;
-
- version)
- _arguments -s -S $common
- ;;
-
- yank)
- _arguments -s -S $common $registry \
- '--vers=[specify yank version]:version' \
- '--undo[undo a yank, putting a version back into the index]' \
- '--index=[specify registry index to yank from]:registry index' \
- '--token=[specify API token to use when authenticating]:token' \
- '*: :_guard "^-*" "crate"'
- ;;
- *)
- # allow plugins to define their own functions
- if ! _call_function ret _cargo-${words[1]}; then
- # fallback on default completion for unknown commands
- _default && ret=0
- fi
- (( ! ret ))
- ;;
- esac
- ;;
- esac
-}
-
-_cargo_unstable_flags() {
- local flags
- flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
- _describe -t flags 'unstable flag' flags
-}
-
-_cargo_installed_crates() {
- local expl
- _description crates expl 'crate'
- compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
-}
-
-_cargo_cmds() {
- local -a commands
- # This uses Parameter Expansion Flags, which are a built-in Zsh feature.
- # See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
- # and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
- #
- # # How this work?
- #
- # First it splits the result of `cargo --list` at newline, then it removes the first line.
- # Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
- # Then it replaces those spaces between item and description with a `:`
- #
- # [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
- commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
- _describe -t commands 'command' commands
-}
-
-
-#FIXME: Disabled until fixed
-#gets package names from the manifest file
-_cargo_package_names() {
- _message -e packages package
-}
-
-# Extracts the values of "name" from the array given in $1 and shows them as
-# command line options for completion
-_cargo_names_from_array() {
- # strip json from the path
- local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
- if [[ -z $manifest ]]; then
- return 0
- fi
-
- local last_line
- local -a names;
- local in_block=false
- local block_name=$1
- names=()
- while read -r line; do
- if [[ $last_line == "[[$block_name]]" ]]; then
- in_block=true
- else
- if [[ $last_line =~ '\s*\[\[.*' ]]; then
- in_block=false
- fi
- fi
-
- if [[ $in_block == true ]]; then
- if [[ $line =~ '\s*name\s*=' ]]; then
- regexp-replace line '^\s*name\s*=\s*|"' ''
- names+=( "$line" )
- fi
- fi
-
- last_line=$line
- done < "$manifest"
- _describe "$block_name" names
-
-}
-
-#Gets the test names from the manifest file
-_cargo_test_names() {
- _cargo_names_from_array "test"
-}
-
-#Gets the bench names from the manifest file
-_cargo_benchmark_names() {
- _cargo_names_from_array "bench"
-}
-
-_cargo
diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh
new file mode 100644
index 000000000..7082d2d55
--- /dev/null
+++ b/plugins/cargo/cargo.plugin.zsh
@@ -0,0 +1,23 @@
+if (( $+commands[rustup] && $+commands[cargo] )); then
+ # remove old generated completion file
+ command rm -f "${0:A:h}/_cargo"
+
+ # generate new completion file
+ ver="$(cargo --version)"
+ ver_file="$ZSH_CACHE_DIR/cargo_version"
+ comp_file="$ZSH_CACHE_DIR/completions/_cargo"
+
+ mkdir -p "${comp_file:h}"
+ (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
+
+ if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
+ rustup completions zsh cargo >| "$comp_file"
+ echo "$ver" >| "$ver_file"
+ fi
+
+ declare -A _comps
+ autoload -Uz _cargo
+ _comps[cargo]=_cargo
+
+ unset ver ver_file comp_file
+fi
diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh
index f7fedb5f2..32f0525aa 100644
--- a/plugins/chruby/chruby.plugin.zsh
+++ b/plugins/chruby/chruby.plugin.zsh
@@ -37,7 +37,7 @@ _homebrew-installed() {
}
_chruby-from-homebrew-installed() {
- [ -r _brew_prefix ] &> /dev/null
+ [ -r $_brew_prefix ] &> /dev/null
}
_ruby-build_installed() {
diff --git a/plugins/chucknorris/README.md b/plugins/chucknorris/README.md
index 35f989180..b51875de9 100644
--- a/plugins/chucknorris/README.md
+++ b/plugins/chucknorris/README.md
@@ -1,8 +1,6 @@
# chucknorris
-Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
-
-**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
+Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
To use it add `chucknorris` to the plugins array in you zshrc file.
diff --git a/plugins/chucknorris/chucknorris.plugin.zsh b/plugins/chucknorris/chucknorris.plugin.zsh
index 1dbb04ef0..b90abe320 100644
--- a/plugins/chucknorris/chucknorris.plugin.zsh
+++ b/plugins/chucknorris/chucknorris.plugin.zsh
@@ -1,28 +1,24 @@
-# chucknorris: Chuck Norris fortunes
+() {
+ # %x: name of file containing code being executed
+ local fortunes_dir="${${(%):-%x}:h}/fortunes"
-# Automatically generate or update Chuck's compiled fortune data file
-# $0 must be used outside a local function. This variable name is unlikly to collide.
-CHUCKNORRIS_PLUGIN_DIR=${0:h}
+ # Aliases
+ alias chuck="fortune -a $fortunes_dir"
+ alias chuck_cow="chuck | cowthink"
-() {
-local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes
-if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
- # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
- local strfile=strfile
- if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
- strfile=/usr/sbin/strfile
+ # Automatically generate or update Chuck's compiled fortune data file
+ if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
+ return
fi
- if which $strfile &> /dev/null; then
- $strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
- else
+
+ # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
+ local strfile="${commands[strfile]:-/usr/sbin/strfile}"
+ if [[ ! -x "$strfile" ]]; then
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
+ return
fi
-fi
-# Aliases
-alias chuck="fortune -a $DIR"
-alias chuck_cow="chuck | cowthink"
+ # Generate the compiled fortune data file
+ $strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
}
-
-unset CHUCKNORRIS_PLUGIN_DIR
diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris
index 181bcc094..6ba5bb9b5 100644
--- a/plugins/chucknorris/fortunes/chucknorris
+++ b/plugins/chucknorris/fortunes/chucknorris
@@ -20,7 +20,7 @@ Aliens fear that Chuck Norris might abduct them.
%
An angry glare from Chuck Norris is known to kill on the spot.
%
-Behind every successful man is Chuck Norris
+Behind every successful man is Chuck Norris.
%
Beware of dogs... Dogs, beware of Chuck Norris.
%
@@ -34,25 +34,25 @@ Chuck Norris - the new standard.
%
Chuck Norris CAN balance the light-switch between ON and OFF.
%
-Chuck Norris CAN believe it's not butter
+Chuck Norris CAN believe it's not butter.
%
Chuck Norris CAN spell with an I before E even after C.
%
-Chuck Norris Can Play the Theme from the Twilight Zone with His Beard
+Chuck Norris can play the theme from the Twilight Zone with his beard.
%
-Chuck Norris Can Power Solar Panels. At Night.
+Chuck Norris can power solar panels. At night.
%
-Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel
+Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel.
%
-Chuck Norris bowled a 301 after constructing another pin out of his beard hair
+Chuck Norris bowled a 301 after constructing another pin out of his beard hair.
%
Chuck Norris burnt a fire proof vest, UNDERWATER!
%
Chuck Norris can French kiss his elbow.
%
-Chuck Norris can bake in a Freezer.
+Chuck Norris can bake in a freezer.
%
-Chuck Norris can defuse bomb even if he cut the wrong wire
+Chuck Norris can defuse a bomb by cutting the wrong wire.
%
Chuck Norris can dig a hole in air.
%
@@ -60,19 +60,19 @@ Chuck Norris can divide by zero.
%
Chuck Norris can do a regime change with a roundhouse kick.
%
-Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket
+Chuck Norris can fit 10 gallons of water in a 5 gallon bucket.
%
-Chuck Norris can grill a popsicle
+Chuck Norris can grill a popsicle.
%
Chuck Norris can lead a horse to water AND make it drink.
%
-Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord"
+Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord".
%
-Chuck Norris can milk an alligator
+Chuck Norris can milk an alligator.
%
Chuck Norris can play the death waltz with his chin.
%
-Chuck Norris can roundhouse kick someone through a window without breaking the glass
+Chuck Norris can roundhouse kick someone through a window without breaking the glass.
%
Chuck Norris can roundhouse-kick round houses into squares.
%
@@ -80,36 +80,30 @@ Chuck Norris can rub two fires together and make a stick!
%
Chuck Norris can see in 3D with just one eye.
%
-Chuck Norris can shoot a person 28 times with an unloaded gun.
-%
Chuck Norris can slam a revolving door.
%
Chuck Norris can terminate a repeating decimal.
%
-Chuck Norris can turn toast back into bread
+Chuck Norris can turn toast back into bread.
%
Chuck Norris can win a game of Connect Four in only three moves.
%
-Chuck Norris can win in a top spinning tournament with a cube
-%
-Chuck Norris can't get fired by Donald Trump
+Chuck Norris can win in a top spinning tournament with a cube.
%
-Chuck Norris can't perform Hadoukens, he IS a Hadouken
+Chuck Norris can't perform Hadoukens, he IS a Hadouken.
%
Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
%
Chuck Norris counted to infinity - twice.
%
-Chuck Norris created Heavy Metal when he was upset
+Chuck Norris created Heavy Metal when he was upset.
%
Chuck Norris does not get frostbite. Chuck Norris bites frost.
%
-Chuck Norris does not have a cell phone because he hears everything
+Chuck Norris does not have a cell phone because he hears everything.
%
Chuck Norris does not sleep. He waits.
%
-Chuck Norris does not teabag the ladies. He potato-sacks them.
-%
Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
%
Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
@@ -118,93 +112,79 @@ Chuck Norris doesn't cheat death, he beats it fair and square.
%
Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
%
-Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it
+Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it.
%
Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
%
-Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face.
-%
Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
%
Chuck Norris doesn't let it go.
%
-Chuck Norris doesn't like Mudkipz
+Chuck Norris doesn't like Mudkipz.
%
Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
%
-Chuck Norris doesn't need a bulletproof vest to be bulletproof
-%
Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
%
-Chuck Norris doesn't need air, he is air
+Chuck Norris doesn't need air, he is air.
%
-Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses
+Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses.
%
Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach.
%
Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
%
-Chuck Norris doesn't read. He just stares at the book until he gets the information he wants.
-%
Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
%
-Chuck Norris doesn’t brew up tea. He sucks the bag.
+Chuck Norris doesn't eat salad, he eats vegetarians.
%
-Chuck Norris doesn’t eat salad, he eats vegetarians
+Chuck Norris doesn't wash his clothes, he disembowels them.
%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
+Chuck Norris doesn't wear a watch. HE decides what time it is.
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris dosent carry a list. He always knows what to do.
+Chuck Norris doesn't carry a list. He always knows what to do.
%
Chuck Norris drives an ice cream truck covered in human skulls.
%
Chuck Norris drowned a man ON LAND.
%
-Chuck Norris fed the Hunger Games
+Chuck Norris fed the Hunger Games.
%
Chuck Norris found the hay in the needle stack.
%
-Chuck Norris found the last digit of pie
-%
-Chuck Norris had a knife thrown at him............ the knife didn't impale him, he impaled the knife
+Chuck Norris found the last digit of pi.
%
-Chuck Norris has a battlecruiser AND a car.
+Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife.
%
-Chuck Norris has killed the Dead Sea
+Chuck Norris has a battle cruiser AND a car.
%
-Chuck Norris has made a 148 break a snooker.
+Chuck Norris has killed the Dead Sea.
%
-Chuck Norris has two speeds. Walk, and Kill.
+Chuck Norris has made a 148 break at snooker.
%
Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
%
-Chuck Norris is Chuck Norris
-%
Chuck Norris is allowed two carry-ons.
%
Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
%
Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick.
%
-Chuck Norris is entitiled to his own facts.
+Chuck Norris is entitled to his own facts.
%
Chuck Norris is my Homeboy.
%
-Chuck Norris is overra...
-%
Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
%
Chuck Norris is so hard, he uses diamonds as stress balls.
%
-Chuck Norris is so scary he makes Sharks swim backwards away from him
+Chuck Norris is so scary, he makes sharks swim backwards away from him.
%
Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
%
Chuck Norris is the ghost in paranormal activity.
%
-Chuck Norris is the life of parties he dosen't attend
+Chuck Norris is the life of parties he doesn't attend.
%
Chuck Norris is the meaning of life. Too bad he's also the meaning of death.
%
@@ -212,101 +192,81 @@ Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
%
Chuck Norris is the only one who can tear a facebook page!
%
-Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth
+Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth.
%
-Chuck Norris is the reason tumbleweeds tumble
+Chuck Norris is the reason tumbleweeds tumble.
%
Chuck Norris is the reason why Waldo is hiding.
%
Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time.
%
-Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages
-%
-Chuck Norris isn't appropriate...appropriate isn't Chuck Norris
-%
-Chuck Norris killed Kemper
-%
-Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead...
+Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages.
%
Chuck Norris made a statue bleed.
%
-Chuck Norris made the big bang just by clicking his fingers
+Chuck Norris made the big bang just by clicking his fingers.
%
Chuck Norris never trains, because he's Chuck Norris.
%
-Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf.
-%
Chuck Norris once cried just to see what it was like. The end result was the creation of life.
%
Chuck Norris once cut a knife with a stick of butter.
%
-Chuck Norris once got a 200 yard punt return
+Chuck Norris once got a 200 yard punt return.
%
-Chuck Norris once had a pet monkey........his name was KING KONG
+Chuck Norris once had a pet monkey named KING KONG.
%
-Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives
+Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives.
%
Chuck Norris once had a weak moment, just to know what it felt like.
%
-Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade
+Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade.
%
Chuck Norris once proved p^~p by induction on his beard hairs.
%
-Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill
+Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill.
%
Chuck Norris once round-house kicked a salesman. Over the phone.
%
-Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean.
-%
-Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet
-%
-Chuck Norris once taught a class of martial arts.Unfortunately Chuck had forgiven to take elephant tranquilizers and killed every one just by saluting
+Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet.
%
Chuck Norris once thought he was wrong. He was, however, mistaken.
%
-Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal.
-%
Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
%
-Chuck Norris once won the tour de france riding a " big wheel"
+Chuck Norris once won the Tour de France riding a "big wheel".
%
Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch."
%
Chuck Norris owns all number 1 pencils.
%
-Chuck Norris pees Adamantium
+Chuck Norris pees Adamantium.
%
-Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month
+Chuck Norris plays Texas Hold'Em with Zeus, every second Wednesday of the month.
%
Chuck Norris played "Got your Nose" with Voldemort and won.
%
-Chuck Norris played the game of thrones and won
+Chuck Norris played the game of thrones and won.
%
-Chuck Norris protects his body guards.
+Chuck Norris protects his bodyguards.
%
Chuck Norris rolled a 20 on a 6 sided die.
%
Chuck Norris roundhouse kicks people in the face first and asks questions later.
%
-Chuck Norris sent a BBM to an iphone.
-%
-Chuck Norris shops at Sam's Club, but leaves without having his receipt checked
-%
-Chuck Norris shot a man with a knife
+Chuck Norris sent a BBM to an iPhone.
%
-Chuck Norris sleeps in Seattle.
+Chuck Norris shops at Sam's Club, but leaves without having his receipt checked.
%
-Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick!
+Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick!
%
Chuck Norris started Chuck Norris.
%
-Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury
-%
-Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white.
+Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury.
%
Chuck Norris told me to put this here.
%
-Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee.
+Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, and make coffee.
%
Chuck Norris uses pepper spray to spice up his steaks.
%
@@ -322,21 +282,21 @@ Chuck Norris was the reason why the Great Wall of China was constructed. It fail
%
Chuck Norris was what Willis was talking about.
%
-Chuck Norris wasn't born on his birthday
+Chuck Norris wasn't born on his birthday.
%
-Chuck Norris watched the first steps on the moon... From his summer home on Mars
+Chuck Norris watched the first steps on the moon... from his summer home on Mars.
%
-Chuck Norris went up the creek without a paddle... or a canoe
+Chuck Norris went up the creek without a paddle... or a canoe.
%
Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
%
Chuck Norris wins NASCAR races with all right turns.
%
-Chuck Norris won a stepdance contest by standing on his hands
+Chuck Norris won a stepdance contest by standing on his hands.
%
-Chuck Norris yells at Drill Sergeants
+Chuck Norris yells at drill Sergeants.
%
-Chuck Norris' dog pick up after him.
+Chuck Norris' dog picks up after him.
%
Chuck Norris' films are factual documentaries.
%
@@ -346,55 +306,47 @@ Chuck Norris' glass is never half full or half empty. It stays full even after h
%
Chuck Norris' hand is the only hand that can beat a Royal Flush.
%
-Chuck Norris' personal airplane is called Air Force Chuck
+Chuck Norris' personal airplane is called Air Force Chuck.
%
Chuck Norris. Enough said.
%
-Chuck Norris: even Naruto can't believe it
+Chuck Norris: even Naruto can't believe it.
%
-Chunk Norris can make sour milk turn fresh
+Chuck Norris can make sour milk turn fresh.
%
-Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris.
+Contrary to popular belief, Rome WAS built in a day, by Chuck Norris.
%
Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth.
%
-Cops don't need a badges in their wallets but only a picture of Chuck Norris.
+Cops don't need badges in their wallets, but only a picture of Chuck Norris.
%
Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
%
-Dead bodies were found of people that are still alive. These people will cross Chuck Norris in the future and will be round-house kicked back in time.
-%
-Did you here about the boy who cried Chuck Norris?
-%
-Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning.
+Did you hear about the boy who cried Chuck Norris?
%
Dog the Bounty Hunter can't track Chuck Norris down.
%
-Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon.
-%
-During the Civil War Chuck Norris was a slave, his master would often beg him for mercy
+Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon.
%
Earth's rotation is purely governed by the direction that Chuck Norris is walking.
%
-Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming
+Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming.
%
-Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
+Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
%
-Every phobia known to man has a phobia of Chuck Norris
+Every phobia known to man has a phobia of Chuck Norris.
%
Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
%
-Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should
-%
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
%
-Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic
+Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
%
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
%
-Ghosts can see Chuck Norris
+Ghosts can see Chuck Norris.
%
Guns don't kill people. Chuck Norris kills people.
%
@@ -404,55 +356,47 @@ If Chuck Norris were a calendar, every month would be named Chucktober, and ever
%
If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
%
-If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else!
+If God doesn't know, Chuck does.
%
-If God doesn't know, Chuck does
-%
-If Goliath listened to Chuck Norris he would have won.
+If Goliath listened to Chuck Norris, he would have won.
%
If at first you don't succeed, you're not Chuck Norris.
%
If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face.
%
-If you put in the correct cheat code in Halo 2, you can have Master Cheif play without his helmet; revealing to be Chuck Norris.
+If you put in the correct cheat code in Halo 2, you can have Master Chief play without his helmet, revealing himself to be Chuck Norris.
%
If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face.
%
If you spell Chuck Norris in Scrabble, you win. Forever.
%
-In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese.
+In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese.
%
-In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris Sized. It is a cup made of a human skull.
+In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris sized. It is a cup made of a human skull.
%
In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
%
-In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten.
-%
In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place."
%
James Bond has a license to kill. He got it from Chuck Norris.
%
-Jedis are now taught to use the "Chuck"
+Jedis are now taught to use the "Chuck".
%
MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart.
%
Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
%
-May the Force be with Chuck Norris... for it's own good.
+May the Force be with Chuck Norris... for its own good.
%
Merlin was Chuck Norris' assistant.
%
-More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win?
-%
Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
%
-Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima?
+Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
%
-Note to self: Don’t be the cashier to tell Chuck Norris his coupons have expired.
+Chuck Norris' keyboard has no control key. Chuck Norris is always in control.
%
-On the keyboard there is no control button because Chuck Norris is always in control.
-%
-Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store.
+Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store.
%
One glance from Chuck Norris and snow turns itself yellow.
%
@@ -472,11 +416,9 @@ Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
%
Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
%
-Simon doesn't say...Chuck Norris says.
-%
-Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.?
+Simon doesn't say... Chuck Norris says.
%
-Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you.
+Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you.
%
Some kids pee their name in snow. Chuck Norris pees his name in concrete.
%
@@ -486,9 +428,9 @@ Someone once videotaped Chuck Norris getting pissed off. It was called Walker: T
%
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face.
%
-Taking Karate Lessons = $100, Buying MMA DVD's= $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS
+Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
%
-That's not an eclipse....that's the sun hiding from Chuck Norris.
+That's not an eclipse. That's the sun hiding from Chuck Norris.
%
The Beatles are on iTunes because Chuck Norris bought a Mac.
%
@@ -498,29 +440,25 @@ The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norri
%
The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
%
-The Jone's are trying to keep up with Chuck Norris
+The Joneses are trying to keep up with Chuck Norris.
%
-The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.”
+The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.”
%
-The answer to life, the universe and everything isnt 42. It's Chuck Norris.
+The answer to life, the universe and everything isn't 42. It's Chuck Norris.
%
-The apple falls far from the tree, when a roundhouse kick is taken to the trunk.
+The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk.
%
-The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live.
+The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live.
%
-The chief export of Chuck Norris is Pain.
+The chief export of Chuck Norris is pain.
%
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
%
-The kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened.
-%
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
%
The letters in Chuck Norris cannot be unscrambled.
%
-The meaning of life is Chuck Norris
-%
-The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them.
+The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet... which is all of them.
%
The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there.
%
@@ -528,47 +466,37 @@ The only sure things are Death and Taxes, and when Chuck Norris goes to work for
%
The only way sharks will come near CN underwater is when CN is inside of a cage.
%
-The only word that rhymes with orange is Chuck Norris
-%
-The planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller.
+The only word that rhymes with orange is Chuck Norris.
%
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender".
%
The quickest way to a man's heart is with Chuck Norris' fist.
%
-The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon.
+The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon.
%
-The red phone in the oval office...Rings directly to Chuck Norris Cell Phone
+The red phone in the oval office rings directly to Chuck Norris' cell phone.
%
The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage.
%
-The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death
+The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death.
%
The sun only rises every morning because Chuck Norris allows it to.
%
-The truth hurts dosen't it, Chuck Norris' truth kills.
+The truth hurts, doesn't it? Chuck Norris' truth kills.
%
There is no chin behind Chuck Norris' beard. There is only another fist.
%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-There is no limbo, only a world that doesn't know of Chuck Norris
-%
-There is no such thing as being hard its called the Chuck Norris factor.
+There is no limbo, only a world that doesn't know of Chuck Norris.
%
There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-They say death by a 1000 lashes was the most painful way to die, that was before they got roundhouse kicked in the face by Chuck Norris
+There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live.
%
This one time at band camp... BAM! Chuck Norris.
%
Those who ignore history, are doomed by Chuck Norris.
%
-Trick me once, shame on you, trick Chuck Norris.....rest in peace.
+Trick me once, shame on you, trick Chuck Norris.. rest in peace.
%
Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
%
@@ -580,7 +508,7 @@ Whatever Chuck Norris wants, it will instantly appear.
%
When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
%
-When Chuck Norris creates a login, it tells him "password not strong enough", he types in his name and it tells him "password too strong."
+When Chuck Norris creates a login, it tells him "password not strong enough." He types in his name and it tells him "password too strong."
%
When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
%
@@ -590,7 +518,7 @@ When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just giv
%
When Chuck Norris goes to rodeos, bulls ride him.
%
-When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section.
+When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section.
%
When Chuck Norris inhales helium, his voice doesn't change.
%
@@ -600,37 +528,41 @@ When Chuck Norris played the card game War with a friend, France surrendered.
%
When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
%
-When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact .
+When Chuck Norris roundhouse-kicks you, he decides when you will feel the impact.
%
When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever.
%
-When Chuck Norris tosses a coin, it lands on both head and tail.
-%
-When God said "Let there be light!", Chuck Norris said "Only for half the day
+When Chuck Norris tosses a coin, it lands on both heads and tails.
%
-When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris.
+When God said "Let there be light!", Chuck Norris said "Only for half the day."
%
-When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens.
+When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens.
%
When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
%
When chuck Norris was in school, he made his PE teacher run laps.
%
-When does Chuck Norris run out of shotgun bullets?.....whenever he wants to.
+When does Chuck Norris run out of shotgun bullets? whenever he wants to.
%
When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000.
%
When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
%
-When things go bump in the night.... it's Chuck Norris
+When things go bump in the night, it's Chuck Norris
%
-While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
+While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
%
Why didn't the chicken cross the road? Because Chuck Norris got to it first.
%
-World War II began because Chuck Norris took a nap. When he woke up, Hitler found out and killed himself out of fear Chuck Norris would kill him.
-%
You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well.
%
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
%
+Chuck Norris made the first Giraffe by uppercutting a horse.
+%
+Chuck Norris can hear sign language.
+%
+Chuck Norris make onions cry.
+%
+Chuck Norris doesn't shake hands, he makes them tremble.
+%
diff --git a/plugins/cloudapp/README.md b/plugins/cloudapp/README.md
deleted file mode 100644
index fc9fc32bd..000000000
--- a/plugins/cloudapp/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# CloudApp plugin
-
-[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
-
-To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
-
-```zsh
-plugins=(... cloudapp)
-```
-
-## Requirements
-
-1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
-
-2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
- ```
- email
- password
- ```
-
-## Usage
-
-- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
- macOS, copies the URL to your clipboard.
diff --git a/plugins/cloudapp/cloudapp.plugin.zsh b/plugins/cloudapp/cloudapp.plugin.zsh
deleted file mode 100644
index 3b363c81b..000000000
--- a/plugins/cloudapp/cloudapp.plugin.zsh
+++ /dev/null
@@ -1,6 +0,0 @@
-alias cloudapp="${0:a:h}/cloudapp.rb"
-
-# Ensure only the owner can access the credentials file
-if [[ -f ~/.cloudapp ]]; then
- chmod 600 ~/.cloudapp
-fi
diff --git a/plugins/cloudapp/cloudapp.rb b/plugins/cloudapp/cloudapp.rb
deleted file mode 100755
index a11cfdb32..000000000
--- a/plugins/cloudapp/cloudapp.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env ruby
-#
-# cloudapp
-# Zach Holman / @holman
-#
-# Uploads a file from the command line to CloudApp, drops it into your
-# clipboard (on a Mac, at least).
-#
-# Example:
-#
-# cloudapp drunk-blake.png
-#
-# This requires Aaron Russell's cloudapp_api gem:
-#
-# gem install cloudapp_api
-#
-# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of:
-#
-# email
-# password
-
-require 'rubygems'
-begin
- require 'cloudapp_api'
-rescue LoadError
- puts "You need to install cloudapp_api: gem install cloudapp_api"
- exit!(1)
-end
-
-config_file = "#{ENV['HOME']}/.cloudapp"
-unless File.exist?(config_file)
- puts "You need to type your email and password (one per line) into "+
- "`~/.cloudapp`"
- exit!(1)
-end
-
-email,password = File.read(config_file).split("\n")
-
-class HTTParty::Response
- # Apparently HTTPOK.ok? IS NOT OKAY WTFFFFFFFFFFUUUUUUUUUUUUUU
- # LETS MONKEY PATCH IT I FEEL OKAY ABOUT IT
- def ok? ; true end
-end
-
-if ARGV[0].nil?
- puts "You need to specify a file to upload."
- exit!(1)
-end
-
-CloudApp.authenticate(email,password)
-url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url
-
-# Say it for good measure.
-puts "Uploaded to #{url}."
-
-# Get the embed link.
-url = "#{url}/#{ARGV[0].split('/').last}"
-
-# Copy it to your (Mac's) clipboard.
-`echo '#{url}' | tr -d "\n" | pbcopy`
diff --git a/plugins/colemak/.gitignore b/plugins/colemak/.gitignore
new file mode 100644
index 000000000..8241f5ed6
--- /dev/null
+++ b/plugins/colemak/.gitignore
@@ -0,0 +1 @@
+.less
diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh
index cb7cc5068..8d3393c44 100644
--- a/plugins/colemak/colemak.plugin.zsh
+++ b/plugins/colemak/colemak.plugin.zsh
@@ -19,4 +19,15 @@ bindkey -a 'N' vi-join
bindkey -a 'j' vi-forward-word-end
bindkey -a 'J' vi-forward-blank-word-end
-lesskey $ZSH/plugins/colemak/colemak-less
+# New less versions will read this file directly
+export LESSKEYIN="${0:h:A}/colemak-less"
+
+# Only run lesskey if less version is older than v582
+less_ver=$(less --version | awk '{print $2;exit}')
+autoload -Uz is-at-least
+if ! is-at-least 582 $less_ver; then
+ # Old less versions will read this transformed file
+ export LESSKEY="${0:h:A}/.less"
+ lesskey -o "$LESSKEY" "$LESSKEYIN" 2>/dev/null
+fi
+unset less_ver
diff --git a/plugins/colored-man-pages/README.md b/plugins/colored-man-pages/README.md
index f34941e73..4cbf64d3e 100644
--- a/plugins/colored-man-pages/README.md
+++ b/plugins/colored-man-pages/README.md
@@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with `
```zsh
colored git help clone
```
+
+## Customization
+
+The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape
+sequences for the `less` pager. This mapping can be further customized by the user after the plugin is
+loaded. Check out sources for more.
+
+For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less`
+how to print something in bold. It's currently shown in bold red, but if you want to change it, you
+can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced:
+
+```zsh
+less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue
+```
diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
index ec518472c..37faed672 100644
--- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh
+++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
@@ -1,39 +1,48 @@
-if [[ "$OSTYPE" = solaris* ]]
-then
- if [[ ! -x "$HOME/bin/nroff" ]]
- then
- mkdir -p "$HOME/bin"
- cat > "$HOME/bin/nroff" <<EOF
-#!/bin/sh
-if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
- shift
- exec /usr/bin/nroff -u\$_NROFF_U "\$@"
-fi
-#-- Some other invocation of nroff
-exec /usr/bin/nroff "\$@"
-EOF
- chmod +x "$HOME/bin/nroff"
- fi
-fi
+# Requires colors autoload.
+# See termcap(5).
+
+# Set up once, and then reuse. This way it supports user overrides after the
+# plugin is loaded.
+typeset -AHg less_termcap
+
+# bold & blinking mode
+less_termcap[mb]="${fg_bold[red]}"
+less_termcap[md]="${fg_bold[red]}"
+less_termcap[me]="${reset_color}"
+# standout mode
+less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
+less_termcap[se]="${reset_color}"
+# underlining
+less_termcap[us]="${fg_bold[green]}"
+less_termcap[ue]="${reset_color}"
+
+# Absolute path to this file's directory.
+typeset __colored_man_pages_dir="${0:A:h}"
function colored() {
- command env \
- LESS_TERMCAP_mb=$(printf "\e[1;31m") \
- LESS_TERMCAP_md=$(printf "\e[1;31m") \
- LESS_TERMCAP_me=$(printf "\e[0m") \
- LESS_TERMCAP_se=$(printf "\e[0m") \
- LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
- LESS_TERMCAP_ue=$(printf "\e[0m") \
- LESS_TERMCAP_us=$(printf "\e[1;32m") \
- PAGER="${commands[less]:-$PAGER}" \
- _NROFF_U=1 \
- PATH="$HOME/bin:$PATH" \
- "$@"
+ local -a environment
+
+ # Convert associative array to plain array of NAME=VALUE items.
+ local k v
+ for k v in "${(@kv)less_termcap}"; do
+ environment+=( "LESS_TERMCAP_${k}=${v}" )
+ done
+
+ # Prefer `less` whenever available, since we specifically configured
+ # environment for it.
+ environment+=( PAGER="${commands[less]:-$PAGER}" )
+
+ # See ./nroff script.
+ if [[ "$OSTYPE" = solaris* ]]; then
+ environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
+ fi
+
+ command env $environment "$@"
}
# Colorize man and dman/debman (from debian-goodies)
function man \
- dman \
- debman {
- colored $0 "$@"
+ dman \
+ debman {
+ colored $0 "$@"
}
diff --git a/plugins/colored-man-pages/nroff b/plugins/colored-man-pages/nroff
new file mode 100755
index 000000000..4ae155d29
--- /dev/null
+++ b/plugins/colored-man-pages/nroff
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# The whole point of this wrapper is to replace emboldening factor -u0 with
+# -u1 under certain circumstances on Solaris.
+
+if [ "$1,$2,$3" = "-u0,-Tlp,-man" ]; then
+ shift
+ exec /usr/bin/nroff -u1 "$@"
+else
+ # Some other invocation of nroff
+ exec /usr/bin/nroff "$@"
+fi
diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md
index ee4ab8036..405bb6d39 100644
--- a/plugins/colorize/README.md
+++ b/plugins/colorize/README.md
@@ -38,6 +38,14 @@ Pygments offers multiple styles. By default, the `default` style is used, but yo
ZSH_COLORIZE_STYLE="colorful"
```
+### Chroma Formatter Settings
+
+Chroma supports terminal output in 8 color, 256 color, and true-color. If you need to change the default terminal output style from the standard 8 color output, set the `ZSH_COLORIZE_CHROMA_FORMATTER` environment variable:
+
+```
+ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
+```
+
## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
index 6ed9739fa..8ea98f80a 100644
--- a/plugins/colorize/colorize.plugin.zsh
+++ b/plugins/colorize/colorize.plugin.zsh
@@ -6,7 +6,8 @@ alias cless="colorize_less"
ZSH_COLORIZE_PLUGIN_PATH=$0:A
colorize_check_requirements() {
- local available_tools=("chroma" "pygmentize")
+ local -a available_tools
+ available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
@@ -46,7 +47,7 @@ colorize_cat() {
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
else
- chroma --style="$ZSH_COLORIZE_STYLE"
+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
fi
return $?
fi
@@ -62,7 +63,7 @@ colorize_cat() {
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
fi
else
- chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME"
+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
fi
done
}
@@ -95,7 +96,7 @@ colorize_less() {
# which assumes that his LESSOPEN has been executed.
local LESSCLOSE=""
- LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@"
+ LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" command less "$@"
}
if [ -t 0 ]; then
diff --git a/plugins/command-not-found/README.md b/plugins/command-not-found/README.md
index 1cf4ba66e..f267f0c89 100644
--- a/plugins/command-not-found/README.md
+++ b/plugins/command-not-found/README.md
@@ -28,5 +28,6 @@ It works out of the box with the command-not-found packages for:
- [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found)
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
+- [Termux](https://github.com/termux/command-not-found)
You can add support for other platforms by submitting a Pull Request.
diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
index 81d76e638..3ec13429c 100644
--- a/plugins/command-not-found/command-not-found.plugin.zsh
+++ b/plugins/command-not-found/command-not-found.plugin.zsh
@@ -1,38 +1,62 @@
-# Uses the command-not-found package zsh support
-# as seen in https://www.porcheron.info/command-not-found-for-zsh/
-# this is installed in Ubuntu
-
-[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
-
-# Arch Linux command-not-found support, you must have package pkgfile installed
-# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
-[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
-
-# Fedora command-not-found support
-if [ -f /usr/libexec/pk-command-not-found ]; then
- command_not_found_handler () {
- runcnf=1
- retval=127
- [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
- [ ! -x /usr/libexec/packagekitd ] && runcnf=0
- if [ $runcnf -eq 1 ]
- then
- /usr/libexec/pk-command-not-found $@
- retval=$?
- fi
- return $retval
- }
+## Platforms with a built-in command-not-found handler init file
+
+for file (
+ # Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
+ /usr/share/doc/pkgfile/command-not-found.zsh
+ # macOS (M1 and classic Homebrew): https://github.com/Homebrew/homebrew-command-not-found
+ /opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
+ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
+); do
+ if [[ -r "$file" ]]; then
+ source "$file"
+ unset file
+ return 0
+ fi
+done
+unset file
+
+
+## Platforms with manual command_not_found_handler() setup
+
+# Debian and derivatives: https://launchpad.net/ubuntu/+source/command-not-found
+if [[ -x /usr/lib/command-not-found || -x /usr/share/command-not-found/command-not-found ]]; then
+ command_not_found_handler() {
+ if [[ -x /usr/lib/command-not-found ]]; then
+ /usr/lib/command-not-found -- "$1"
+ return $?
+ elif [[ -x /usr/share/command-not-found/command-not-found ]]; then
+ /usr/share/command-not-found/command-not-found -- "$1"
+ return $?
+ else
+ printf "zsh: command not found: %s\n" "$1" >&2
+ return 127
+ fi
+ }
+fi
+
+# Fedora: https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound
+if [[ -x /usr/libexec/pk-command-not-found ]]; then
+ command_not_found_handler() {
+ if [[ -S /var/run/dbus/system_bus_socket && -x /usr/libexec/packagekitd ]]; then
+ /usr/libexec/pk-command-not-found "$@"
+ return $?
+ fi
+
+ printf "zsh: command not found: %s\n" "$1" >&2
+ return 127
+ }
fi
-# OSX command-not-found support
-# https://github.com/Homebrew/homebrew-command-not-found
-if [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then
- source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh'
+# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
+if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
+ command_not_found_handler() {
+ /run/current-system/sw/bin/command-not-found -- "$@"
+ }
fi
-# NixOS command-not-found support
-if [ -x /run/current-system/sw/bin/command-not-found ]; then
- command_not_found_handler () {
- /run/current-system/sw/bin/command-not-found $@
- }
+# Termux: https://github.com/termux/command-not-found
+if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
+ command_not_found_handler() {
+ /data/data/com.termux/files/usr/libexec/termux/command-not-found -- "$1"
+ }
fi
diff --git a/plugins/common-aliases/README.md b/plugins/common-aliases/README.md
index d198a29ac..b6f34cb54 100644
--- a/plugins/common-aliases/README.md
+++ b/plugins/common-aliases/README.md
@@ -40,11 +40,13 @@ plugins=(... common-aliases)
| Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------|
-| fd | `find . -type d -name` | Find a directory with the given name |
+| fd\* | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
+\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed.
+
### Other Aliases
| Alias | Command | Description |
diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
index 023b1a51e..4e5ff848f 100644
--- a/plugins/common-aliases/common-aliases.plugin.zsh
+++ b/plugins/common-aliases/common-aliases.plugin.zsh
@@ -34,7 +34,7 @@ alias -g P="2>&1| pygmentize -l pytb"
alias dud='du -d 1 -h'
alias duf='du -sh *'
-alias fd='find . -type d -name'
+(( $+commands[fd] )) || alias fd='find . -type d -name'
alias ff='find . -type f -name'
alias h='history'
@@ -55,15 +55,15 @@ if is-at-least 4.2.0; then
# open browser on urls
if [[ -n "$BROWSER" ]]; then
_browser_fts=(htm html de org net com at cx nl se dk)
- for ft in $_browser_fts; do alias -s $ft=$BROWSER; done
+ for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
fi
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
- for ft in $_editor_fts; do alias -s $ft=$EDITOR; done
+ for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
if [[ -n "$XIVIEWER" ]]; then
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
- for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done
+ for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
fi
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
index 330360cdd..218a13e5f 100644
--- a/plugins/composer/composer.plugin.zsh
+++ b/plugins/composer/composer.plugin.zsh
@@ -51,6 +51,8 @@ alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
+ autoload -Uz _store_cache _retrieve_cache _cache_invalid
+
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh
index 483ed5a5f..e67f920f0 100644
--- a/plugins/copybuffer/copybuffer.plugin.zsh
+++ b/plugins/copybuffer/copybuffer.plugin.zsh
@@ -5,10 +5,12 @@ copybuffer () {
if which clipcopy &>/dev/null; then
printf "%s" "$BUFFER" | clipcopy
else
- echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
+ zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
fi
}
zle -N copybuffer
-bindkey "^O" copybuffer
+bindkey -M emacs "^O" copybuffer
+bindkey -M viins "^O" copybuffer
+bindkey -M vicmd "^O" copybuffer
diff --git a/plugins/cp/README.md b/plugins/cp/README.md
index e8a9b6ccc..23734243c 100644
--- a/plugins/cp/README.md
+++ b/plugins/cp/README.md
@@ -25,7 +25,7 @@ The enabled options for rsync are:
* `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T).
-* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync".
+* `--backup-dir="/tmp/rsync-$USERNAME"`: move backup copies to "/tmp/rsync-$USERNAME".
* `-e /dev/null`: only work on local files (disable remote shells).
diff --git a/plugins/cp/cp.plugin.zsh b/plugins/cp/cp.plugin.zsh
index fe6ea87a8..a56259106 100644
--- a/plugins/cp/cp.plugin.zsh
+++ b/plugins/cp/cp.plugin.zsh
@@ -1,4 +1,4 @@
cpv() {
- rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
+ rsync -pogbr -hhh --backup-dir="/tmp/rsync-${USERNAME}" -e /dev/null --progress "$@"
}
compdef _files cpv
diff --git a/plugins/debian/README.md b/plugins/debian/README.md
index da5675c66..922d68cb3 100644
--- a/plugins/debian/README.md
+++ b/plugins/debian/README.md
@@ -10,7 +10,7 @@ plugins=(... debian)
## Settings
-- `$apt_pref`: use apt or aptitude if installed, fallback is apt-get.
+- `$apt_pref`: use aptitude or apt if installed, fallback is apt-get.
- `$apt_upgr`: use upgrade or safe-upgrade (for aptitude).
Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior.
diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
index 68c6df1ae..bde97cd30 100644
--- a/plugins/debian/debian.plugin.zsh
+++ b/plugins/debian/debian.plugin.zsh
@@ -1,13 +1,13 @@
-# Use apt or aptitude if installed, fallback is apt-get
+# Use aptitude or apt if installed, fallback is apt-get
# You can just set apt_pref='apt-get' to override it.
if [[ -z $apt_pref || -z $apt_upgr ]]; then
- if [[ -e $commands[apt] ]]; then
- apt_pref='apt'
- apt_upgr='upgrade'
- elif [[ -e $commands[aptitude] ]]; then
+ if [[ -e $commands[aptitude] ]]; then
apt_pref='aptitude'
apt_upgr='safe-upgrade'
+ elif [[ -e $commands[apt] ]]; then
+ apt_pref='apt'
+ apt_upgr='upgrade'
else
apt_pref='apt-get'
apt_upgr='upgrade'
@@ -66,7 +66,7 @@ if [[ $use_sudo -eq 1 ]]; then
alias di="sudo dpkg -i"
# Remove ALL kernel images and headers EXCEPT the one in use
- alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))'
+ alias kclean='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))"'
# commands using su #########
@@ -105,7 +105,7 @@ else
alias di='su -lc "dpkg -i" root'
# Remove ALL kernel images and headers EXCEPT the one in use
- alias kclean='su -lc "aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))" root'
+ alias kclean='su -lc "aptitude remove -P \"?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))\"" root'
fi
# Completion ################################################################
diff --git a/plugins/deno/README.md b/plugins/deno/README.md
new file mode 100644
index 000000000..828e6af39
--- /dev/null
+++ b/plugins/deno/README.md
@@ -0,0 +1,18 @@
+# Deno Plugin
+
+This plugin sets up completion and aliases for [Deno](https://deno.land).
+
+## Aliases
+
+| Alias | Full command |
+| ----- | ---------------- |
+| db | deno bundle |
+| dc | deno compile |
+| dca | deno cache |
+| dfmt | deno fmt |
+| dh | deno help |
+| dli | deno lint |
+| drn | deno run |
+| drw | deno run --watch |
+| dts | deno test |
+| dup | deno upgrade |
diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh
new file mode 100644
index 000000000..34adddc37
--- /dev/null
+++ b/plugins/deno/deno.plugin.zsh
@@ -0,0 +1,35 @@
+# ALIASES
+alias db='deno bundle'
+alias dc='deno compile'
+alias dca='deno cache'
+alias dfmt='deno fmt'
+alias dh='deno help'
+alias dli='deno lint'
+alias drn='deno run'
+alias drw='deno run --watch'
+alias dts='deno test'
+alias dup='deno upgrade'
+
+# COMPLETION FUNCTION
+if (( $+commands[deno] )); then
+ # remove old generated completion file
+ command rm -f "${0:A:h}/_deno"
+
+ ver="$(deno --version)"
+ ver_file="$ZSH_CACHE_DIR/deno_version"
+ comp_file="$ZSH_CACHE_DIR/completions/_deno"
+
+ mkdir -p "${comp_file:h}"
+ (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
+
+ if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
+ deno completions zsh >| "$comp_file"
+ echo "$ver" >| "$ver_file"
+ fi
+
+ declare -A _comps
+ autoload -Uz _deno
+ _comps[deno]=_deno
+
+ unset ver ver_file comp_file
+fi
diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md
index 223650727..602fc8284 100644
--- a/plugins/dirhistory/README.md
+++ b/plugins/dirhistory/README.md
@@ -17,6 +17,9 @@ plugins=(... dirhistory)
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory |
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order |
+NOTE: some terminals might override the ALT+Arrows key bindings (Windows Terminal, for example).
+If these don't work check your terminal settings and change them to a different keyboard shortcut.
+
## Usage
This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT.
diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
index 35c43d76a..cbac84600 100644
--- a/plugins/dirhistory/dirhistory.plugin.zsh
+++ b/plugins/dirhistory/dirhistory.plugin.zsh
@@ -2,7 +2,7 @@
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
#
-# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented)
+# Navigate directory hierarchy using ALT-UP and ALT-DOWN.
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order
#
@@ -108,26 +108,30 @@ function dirhistory_forward() {
# Bind keys to history navigation
function dirhistory_zle_dirhistory_back() {
# Erase current line in buffer
- zle kill-buffer
- dirhistory_back
- zle accept-line
+ zle .kill-buffer
+ dirhistory_back
+ zle .accept-line
}
function dirhistory_zle_dirhistory_future() {
# Erase current line in buffer
- zle kill-buffer
+ zle .kill-buffer
dirhistory_forward
- zle accept-line
+ zle .accept-line
}
zle -N dirhistory_zle_dirhistory_back
# xterm in normal mode
bindkey "\e[3D" dirhistory_zle_dirhistory_back
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
-# Mac teminal (alt+left/right)
+# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[b" dirhistory_zle_dirhistory_back
fi
+# iTerm2
+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[^[[D" dirhistory_zle_dirhistory_back
+fi
# Putty:
bindkey "\e\e[D" dirhistory_zle_dirhistory_back
# GNU screen:
@@ -136,9 +140,14 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
zle -N dirhistory_zle_dirhistory_future
bindkey "\e[3C" dirhistory_zle_dirhistory_future
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
+# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[f" dirhistory_zle_dirhistory_future
fi
+# iTerm2
+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[^[[C" dirhistory_zle_dirhistory_future
+fi
bindkey "\e\e[C" dirhistory_zle_dirhistory_future
bindkey "\eO3C" dirhistory_zle_dirhistory_future
@@ -160,23 +169,24 @@ function dirhistory_down() {
# Bind keys to hierarchy navigation
function dirhistory_zle_dirhistory_up() {
- zle kill-buffer # Erase current line in buffer
+ zle .kill-buffer # Erase current line in buffer
dirhistory_up
- zle accept-line
+ zle .accept-line
}
function dirhistory_zle_dirhistory_down() {
- zle kill-buffer # Erase current line in buffer
+ zle .kill-buffer # Erase current line in buffer
dirhistory_down
- zle accept-line
+ zle .accept-line
}
zle -N dirhistory_zle_dirhistory_up
# xterm in normal mode
bindkey "\e[3A" dirhistory_zle_dirhistory_up
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
-# Mac teminal (alt+up)
- #bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it
+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[[A" dirhistory_zle_dirhistory_up
+fi
# Putty:
bindkey "\e\e[A" dirhistory_zle_dirhistory_up
# GNU screen:
@@ -185,7 +195,8 @@ bindkey "\eO3A" dirhistory_zle_dirhistory_up
zle -N dirhistory_zle_dirhistory_down
bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
-# Mac teminal (alt+down)
- #bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it
+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[[B" dirhistory_zle_dirhistory_down
+fi
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down
diff --git a/plugins/django/README.md b/plugins/django/README.md
index 1740e55e5..cfab43980 100644
--- a/plugins/django/README.md
+++ b/plugins/django/README.md
@@ -1,36 +1,12 @@
# Django plugin
-This plugin adds completion and hints for the [Django Project](https://www.djangoproject.com/) `manage.py` commands
-and options.
+This plugin adds completion for the [Django Project](https://www.djangoproject.com/) commands
+(`manage.py`, `django-admin`, ...).
-To use it, add `django` to the plugins array in your zshrc file:
+## Deprecation (2021-09-22)
-```zsh
-plugins=(... django)
-```
+The plugin used to provide completion for `./manage.py` and `django-admin`, but Zsh already provides
+a better, more extensive completion for those, so this plugin is no longer needed.
-## Usage
-
-```zsh
-$> python manage.py (press <TAB> here)
-```
-
-Would result in:
-
-```zsh
-cleanup -- remove old data from the database
-compilemessages -- compile .po files to .mo for use with gettext
-createcachetable -- creates table for SQL cache backend
-createsuperuser -- create a superuser
-dbshell -- run command-line client for the current database
-diffsettings -- display differences between the current settings and Django defaults
-dumpdata -- output contents of database as a fixture
-flush -- execute 'sqlflush' on the current database
-inspectdb -- output Django model module for tables in database
-loaddata -- install the named fixture(s) in the database
-makemessages -- pull out all strings marked for translation
-reset -- executes 'sqlreset' for the given app(s)
-runfcgi -- run this project as a fastcgi
-runserver -- start a lightweight web server for development
-...
-```
+Right now a warning message is shown, but in the near future the plugin will stop working altogether.
+So you can remove it from your plugins and you'll automatically start using Zsh's django completion.
diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh
index c2d00c171..a07a30889 100644
--- a/plugins/django/django.plugin.zsh
+++ b/plugins/django/django.plugin.zsh
@@ -402,3 +402,6 @@ compdef _managepy django
compdef _managepy django-admin
compdef _managepy django-admin.py
compdef _managepy django-manage
+
+print -P "%F{yellow}The django plugin is deprecated in favor of Zsh's Django completion.
+%BPlease remove it from your plugins to stop using it.%b%f"
diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md
index 1105e03f6..13f3c2cea 100644
--- a/plugins/docker-compose/README.md
+++ b/plugins/docker-compose/README.md
@@ -11,20 +11,22 @@ plugins=(... docker-compose)
## Aliases
-| Alias | Command | Description |
-|-----------|--------------------------|------------------------------------------------------------------|
-| dco | `docker-compose` | Docker-compose main command |
-| dcb | `docker-compose build` | Build containers |
-| dce | `docker-compose exec` | Execute command inside a container |
-| dcps | `docker-compose ps` | List containers |
-| dcrestart | `docker-compose restart` | Restart container |
-| dcrm | `docker-compose rm` | Remove container |
-| dcr | `docker-compose run` | Run a command in container |
-| dcstop | `docker-compose stop` | Stop a container |
-| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
-| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
-| dcdn | `docker-compose down` | Stop and remove containers |
-| dcl | `docker-compose logs` | Show logs of container |
-| dclf | `docker-compose logs -f` | Show logs and follow output |
-| dcpull | `docker-compose pull` | Pull image of a service |
-| dcstart | `docker-compose start` | Start a container |
+| Alias | Command | Description |
+|-----------|--------------------------------|------------------------------------------------------------------|
+| dco | `docker-compose` | Docker-compose main command |
+| dcb | `docker-compose build` | Build containers |
+| dce | `docker-compose exec` | Execute command inside a container |
+| dcps | `docker-compose ps` | List containers |
+| dcrestart | `docker-compose restart` | Restart container |
+| dcrm | `docker-compose rm` | Remove container |
+| dcr | `docker-compose run` | Run a command in container |
+| dcstop | `docker-compose stop` | Stop a container |
+| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
+| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers |
+| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
+| dcdn | `docker-compose down` | Stop and remove containers |
+| dcl | `docker-compose logs` | Show logs of container |
+| dclf | `docker-compose logs -f` | Show logs and follow output |
+| dcpull | `docker-compose pull` | Pull image of a service |
+| dcstart | `docker-compose start` | Start a container |
+| dck | `docker-compose kill` | Kills containers |
diff --git a/plugins/docker-compose/_docker-compose b/plugins/docker-compose/_docker-compose
index 808b068a3..c6b733500 100644
--- a/plugins/docker-compose/_docker-compose
+++ b/plugins/docker-compose/_docker-compose
@@ -121,12 +121,6 @@ __docker-compose_subcommand() {
'--parallel[Build images in parallel.]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
- (bundle)
- _arguments \
- $opts_help \
- '--push-images[Automatically push images for any services which have a `build` option specified.]' \
- '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
- ;;
(config)
_arguments \
$opts_help \
@@ -290,7 +284,7 @@ __docker-compose_subcommand() {
(up)
_arguments \
$opts_help \
- '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \
+ '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit and --attach-dependencies.]' \
$opts_no_color \
$opts_no_deps \
$opts_force_recreate \
@@ -298,6 +292,7 @@ __docker-compose_subcommand() {
$opts_no_build \
"(--no-build)--build[Build images before starting containers.]" \
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
+ "(-d)--attach-dependencies[Attach to dependent containers. Incompatible with -d.]" \
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
'--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \
'--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \
@@ -341,11 +336,13 @@ _docker-compose() {
'(- :)'{-h,--help}'[Get help]' \
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
+ '--env-file[Specify an alternate environment file (default: .env)]:env-file:_files' \
"--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \
'(- :)'{-v,--version}'[Print version and exit]' \
'--verbose[Show more output]' \
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
'--no-ansi[Do not print ANSI control characters]' \
+ '--ansi=[Control when to print ANSI control characters]:when:(never always auto)' \
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
'--tls[Use TLS; implied by --tlsverify]' \
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
@@ -359,6 +356,7 @@ _docker-compose() {
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=(
+ "--env-file"
"--file" "-f"
"--host" "-H"
"--project-name" "-p"
diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh
index 9ffe1edf6..13985fc82 100644
--- a/plugins/docker-compose/docker-compose.plugin.zsh
+++ b/plugins/docker-compose/docker-compose.plugin.zsh
@@ -1,26 +1,24 @@
-# Authors:
-# https://github.com/tristola
-#
-# Docker-compose related zsh aliases
+# support Compose v2 as docker CLI plugin
+DOCKER_CONTEXT=default command docker compose &>/dev/null \
+ && dccmd='docker compose' \
+ || dccmd='docker-compose'
-# Aliases ###################################################################
+alias dco="$dccmd"
+alias dcb="$dccmd build"
+alias dce="$dccmd exec"
+alias dcps="$dccmd ps"
+alias dcrestart="$dccmd restart"
+alias dcrm="$dccmd rm"
+alias dcr="$dccmd run"
+alias dcstop="$dccmd stop"
+alias dcup="$dccmd up"
+alias dcupb="$dccmd up --build"
+alias dcupd="$dccmd up -d"
+alias dcdn="$dccmd down"
+alias dcl="$dccmd logs"
+alias dclf="$dccmd logs -f"
+alias dcpull="$dccmd pull"
+alias dcstart="$dccmd start"
+alias dck="$dccmd kill"
-# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator'
-# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
-
-alias dco='docker-compose'
-
-alias dcb='docker-compose build'
-alias dce='docker-compose exec'
-alias dcps='docker-compose ps'
-alias dcrestart='docker-compose restart'
-alias dcrm='docker-compose rm'
-alias dcr='docker-compose run'
-alias dcstop='docker-compose stop'
-alias dcup='docker-compose up'
-alias dcupd='docker-compose up -d'
-alias dcdn='docker-compose down'
-alias dcl='docker-compose logs'
-alias dclf='docker-compose logs -f'
-alias dcpull='docker-compose pull'
-alias dcstart='docker-compose start'
+unset dccmd
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index 241a6a448..fab7aa8f1 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -10,3 +10,25 @@ plugins=(... docker)
A copy of the completion script from the docker/cli git repo:
https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
+
+## Settings
+
+By default, the completion doesn't allow option-stacking, meaning if you try to
+complete `docker run -it <TAB>` it won't work, because you're _stacking_ the
+`-i` and `-t` options.
+
+[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding
+the lines below to your zshrc file**, but be aware of the side effects:
+
+> This enables Zsh to understand commands like `docker run -it
+> ubuntu`. However, by enabling this, this also makes Zsh complete
+> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The
+> users have to put the space or the equal sign themselves before trying
+> to complete.
+>
+> Therefore, this behavior is disabled by default. To enable it:
+>
+> ```
+> zstyle ':completion:*:*:docker:*' option-stacking yes
+> zstyle ':completion:*:*:docker-*:*' option-stacking yes
+> ```
diff --git a/plugins/docker/_docker b/plugins/docker/_docker
index 10c19e233..8ee35abcf 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -624,7 +624,8 @@ __docker_container_subcommand() {
"($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: "
"($help)*--env-file=[Read environment variables from a file]:environment file:_files"
"($help)*--expose=[Expose a port from the container without publishing it]: "
- "($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups"
+ "($help)*--gpus=[GPU devices to add to the container ('all' to pass all GPUs)]:device: "
+ "($help)*--group-add=[Set one or more supplementary user groups for the container]:group:_groups"
"($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
"($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
"($help)--init[Run an init inside the container that forwards signals and reaps processes]"
@@ -750,6 +751,7 @@ __docker_container_subcommand() {
$opts_attach_exec_run_start \
"($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
"($help)*"{-e=,--env=}"[Set environment variables]:environment variable: " \
+ "($help)*--env-file=[Read environment variables from a file]:environment file:_files" \
"($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \
"($help)--privileged[Give extended Linux capabilities to the command]" \
"($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \
@@ -791,7 +793,7 @@ __docker_container_subcommand() {
"($help -f --follow)"{-f,--follow}"[Follow log output]" \
"($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \
"($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
- "($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \
+ "($help -n --tail)"{-n=,--tail=}"[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
"($help -)*:containers:__docker_complete_containers" && ret=0
;;
(ls|list)
@@ -1018,6 +1020,7 @@ __docker_image_subcommand() {
"($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " \
"($help)--squash[Squash newly built layers into a single new layer]" \
"($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_complete_repositories_with_tags" \
+ "($help)--target=[Set the target build stage to build.]" \
"($help)*--ulimit=[ulimit options]:ulimit: " \
"($help)--userns=[Container user namespace]:user namespace:(host)" \
"($help -):path or URL:_directories" && ret=0
@@ -1340,7 +1343,7 @@ __docker_node_complete_ls_filters() {
;;
esac
else
- opts=('id' 'label' 'membership' 'name' 'role')
+ opts=('id' 'label' 'membership' 'name' 'node.label' 'role')
_describe -t filter-opts "filter options" opts -qS "=" && ret=0
fi
@@ -1958,6 +1961,8 @@ __docker_service_subcommand() {
opts_help=("(: -)--help[Print usage]")
opts_create_update=(
+ "($help)*--cap-add=[Add Linux capabilities]:capability: "
+ "($help)*--cap-drop=[Drop Linux capabilities]:capability: "
"($help)*--constraint=[Placement constraints]:constraint: "
"($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)"
"($help)*"{-e=,--env=}"[Set environment variables]:env: "
@@ -1970,6 +1975,7 @@ __docker_service_subcommand() {
"($help)*--label=[Service labels]:label: "
"($help)--limit-cpu=[Limit CPUs]:value: "
"($help)--limit-memory=[Limit Memory]:value: "
+ "($help)--limit-pids[Limit maximum number of processes (default 0 = unlimited)]"
"($help)--log-driver=[Logging driver for service]:logging driver:__docker_complete_log_drivers"
"($help)*--log-opt=[Logging driver options]:log driver options:__docker_complete_log_options"
"($help)*--mount=[Attach a filesystem mount to the service]:mount: "
@@ -2012,6 +2018,7 @@ __docker_service_subcommand() {
"($help)*--dns-option=[Set DNS options]:DNS option: " \
"($help)*--dns-search=[Set custom DNS search domains]:DNS search: " \
"($help)*--env-file=[Read environment variables from a file]:environment file:_files" \
+ "($help)*--group=[Set one or more supplementary user groups for the container]:group: _groups " \
"($help)--mode=[Service Mode]:mode:(global replicated)" \
"($help)--name=[Service name]:name: " \
"($help)*--placement-pref=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \
@@ -2035,7 +2042,7 @@ __docker_service_subcommand() {
"($help)--no-task-ids[Do not include task IDs]" \
"($help)--no-trunc[Do not truncate output]" \
"($help)--since=[Show logs since timestamp]:timestamp: " \
- "($help)--tail=[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
+ "($help -n --tail)"{-n=,--tail=}"[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \
"($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
"($help -)1:service:__docker_complete_services" && ret=0
;;
@@ -2537,6 +2544,82 @@ __docker_volume_subcommand() {
# EO volume
+# BO context
+
+__docker_complete_contexts() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a contexts
+
+ contexts=(${(f)${:-"$(_call_program commands docker $docker_options context ls -q)"$'\n'}})
+
+ _describe -t context-list "context" contexts && ret=0
+ return ret
+}
+
+__docker_context_commands() {
+ local -a _docker_context_subcommands
+ _docker_context_subcommands=(
+ "create:Create new context"
+ "inspect:Display detailed information on one or more contexts"
+ "list:List available contexts"
+ "rm:Remove one or more contexts"
+ "show:Print the current context"
+ "update:Update a context"
+ "use:Set the default context"
+ )
+ _describe -t docker-context-commands "docker context command" _docker_context_subcommands
+}
+
+__docker_context_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (create)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \
+ "($help)--description=[Description of the context]:description:" \
+ "($help)--docker=[Set the docker endpoint]:docker:" \
+ "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \
+ "($help)--from=[Create context from a named context]:from:__docker_complete_contexts" \
+ "($help -):name: " && ret=0
+ ;;
+ (use)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:context:__docker_complete_contexts" && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:context:__docker_complete_contexts" && ret=0
+ ;;
+ (rm)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:context:__docker_complete_contexts" && ret=0
+ ;;
+ (update)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \
+ "($help)--description=[Description of the context]:description:" \
+ "($help)--docker=[Set the docker endpoint]:docker:" \
+ "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \
+ "($help -):name:" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO context
+
__docker_caching_policy() {
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
@@ -2569,7 +2652,7 @@ __docker_commands() {
then
local -a lines
lines=(${(f)"$(_call_program commands docker 2>&1)"})
- _docker_subcommands=(${${${(M)${lines[$((${lines[(i)*Commands:]} + 1)),-1]}:# *}## #}/ ##/:})
+ _docker_subcommands=(${${${(M)${lines[$((${lines[(i)*Commands:]} + 1)),-1]}:# *}## #}/\*# ##/:})
_docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command')
(( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands
fi
@@ -2624,6 +2707,23 @@ __docker_subcommand() {
;;
esac
;;
+ (context)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_context_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_context_subcommand && ret=0
+ ;;
+ esac
+ ;;
(daemon)
_arguments $(__docker_arguments) \
$opts_help \
@@ -2639,6 +2739,8 @@ __docker_subcommand() {
"($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \
"($help)--config-file=[Path to daemon configuration file]:Config File:_files" \
"($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \
+ "($help)--containerd-namespace=[Containerd namespace to use]:containerd namespace:" \
+ "($help)--containerd-plugins-namespace=[Containerd namespace to use for plugins]:containerd namespace:" \
"($help)--data-root=[Root directory of persisted Docker data]:path:_directories" \
"($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
"($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \
@@ -2689,7 +2791,8 @@ __docker_subcommand() {
"($help)--tlsverify[Use TLS and verify the remote]" \
"($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \
"($help)--userland-proxy[Use userland proxy for loopback traffic]" \
- "($help)--userland-proxy-path=[Path to the userland proxy binary]:binary:_files" && ret=0
+ "($help)--userland-proxy-path=[Path to the userland proxy binary]:binary:_files" \
+ "($help)--validate[Validate daemon configuration and exit]" && ret=0
case $state in
(cluster-store)
diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md
index f66124731..ab9d329f6 100644
--- a/plugins/dotenv/README.md
+++ b/plugins/dotenv/README.md
@@ -53,24 +53,30 @@ Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmat
You can also choose the `Always` option when prompted to always allow sourcing the .env file
in that directory. See the next section for more details.
-### ZSH_DOTENV_ALLOWED_LIST
+### ZSH_DOTENV_ALLOWED_LIST, ZSH_DOTENV_DISALLOWED_LIST
The default behavior of the plugin is to always ask whether to source a dotenv file. There's
-a **Y**es, **N**o, and **A**lways option. If you choose Always, the directory of the .env file
-will be added to an allowed list. If a directory is found in this list, the plugin won't ask
-for confirmation and will instead source the .env file directly.
+a **Y**es, **N**o, **A**lways and N**e**ver option. If you choose Always, the directory of the .env file
+will be added to an allowed list; if you choose Never, it will be added to a disallowed list.
+If a directory is found in either of those lists, the plugin won't ask for confirmation and will
+instead either source the .env file or proceed without action respectively.
-This allowed list is saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list`. If you want
-to change that location, change the `$ZSH_DOTENV_ALLOWED_LIST` variable, like so:
+The allowed and disallowed lists are saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list` and
+`$ZSH_CACHE_DIR/dotenv-disallowed.list` respectively. If you want to change that location,
+change the `$ZSH_DOTENV_ALLOWED_LIST` and `$ZSH_DOTENV_DISALLOWED_LIST` variables, like so:
```zsh
# in ~/.zshrc, before Oh My Zsh is sourced:
ZSH_DOTENV_ALLOWED_LIST=/path/to/dotenv/allowed/list
+ZSH_DOTENV_DISALLOWED_LIST=/path/to/dotenv/disallowed/list
```
-This file is just a list of directories allowed, separated by a newline character. If you want
-to disallow a directory, just edit this file and remove the line for the directory you want to
-disallow.
+The file is just a list of directories, separated by a newline character. If you want
+to change your decision, just edit the file and remove the line for the directory you want to
+change.
+
+NOTE: if a directory is found in both the allowed and disallowed lists, the disallowed list
+takes preference, _i.e._ the .env file will never be sourced.
## Version Control
diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
index ac3210d7f..40ec5c46f 100644
--- a/plugins/dotenv/dotenv.plugin.zsh
+++ b/plugins/dotenv/dotenv.plugin.zsh
@@ -5,39 +5,57 @@
# Path to the file containing allowed paths
: ${ZSH_DOTENV_ALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-allowed.list"}
+: ${ZSH_DOTENV_DISALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-disallowed.list"}
## Functions
source_env() {
- if [[ -f $ZSH_DOTENV_FILE ]]; then
- if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then
- local confirmation dirpath="${PWD:A}"
-
- # make sure there is an allowed file
- touch "$ZSH_DOTENV_ALLOWED_LIST"
-
- # check if current directory's .env file is allowed or ask for confirmation
- if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
- # print same-line prompt and output newline character if necessary
- echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways) "
- read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo
-
- # check input
- case "$confirmation" in
- [nN]) return ;;
- [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
- *) ;; # interpret anything else as a yes
- esac
- fi
+ if [[ ! -f "$ZSH_DOTENV_FILE" ]]; then
+ return
+ fi
+
+ if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then
+ local confirmation dirpath="${PWD:A}"
+
+ # make sure there is an (dis-)allowed file
+ touch "$ZSH_DOTENV_ALLOWED_LIST"
+ touch "$ZSH_DOTENV_DISALLOWED_LIST"
+
+ # early return if disallowed
+ if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
+ return
fi
- # test .env syntax
- zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
+ # check if current directory's .env file is allowed or ask for confirmation
+ if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
+ # get cursor column and print new line before prompt if not at line beginning
+ local column
+ echo -ne "\e[6n" > /dev/tty
+ read -t 1 -s -d R column < /dev/tty
+ column="${column##*\[*;}"
+ [[ $column -eq 1 ]] || echo
- setopt localoptions allexport
- source $ZSH_DOTENV_FILE
+ # print same-line prompt and output newline character if necessary
+ echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) "
+ read -k 1 confirmation
+ [[ "$confirmation" = $'\n' ]] || echo
+
+ # check input
+ case "$confirmation" in
+ [nN]) return ;;
+ [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
+ [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;;
+ *) ;; # interpret anything else as a yes
+ esac
+ fi
fi
+
+ # test .env syntax
+ zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
+
+ setopt localoptions allexport
+ source $ZSH_DOTENV_FILE
}
autoload -U add-zsh-hook
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index db0ab13af..027c7550f 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -9,47 +9,55 @@
# - You can share opened buffered across opened frames.
# - Configuration changes made at runtime are applied to all frames.
-
-if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
- export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
-
- # set EDITOR if not already defined.
- export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
-
- alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
- alias e=emacs
- # open terminal emacsclient
- alias te="$EMACS_PLUGIN_LAUNCHER -nw"
-
- # same than M-x eval but from outside Emacs.
- alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
- # create a new X frame
- alias eframe='emacsclient --alternate-editor "" --create-frame'
-
-
- # Write to standard output the path to the file
- # opened in the current buffer.
- function efile {
- local cmd="(buffer-file-name (window-buffer))"
- "$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \"
- }
-
- # Write to standard output the directory of the file
- # opened in the the current buffer
- function ecd {
- local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
- (if buf-name (file-name-directory buf-name)))"
-
- local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")"
- if [ -n "$dir" ] ;then
- echo "$dir"
- else
- echo "can not deduce current buffer filename." >/dev/stderr
- return 1
- fi
- }
+# Require emacs version to be minimum 24
+autoload -Uz is-at-least
+is-at-least 24 "${${(Az)"$(emacsclient --version 2>/dev/null)"}[2]}" || return 0
+
+# Path to custom emacsclient launcher
+export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh"
+
+# set EDITOR if not already defined.
+export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
+
+alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
+alias e=emacs
+# open terminal emacsclient
+alias te="$EMACS_PLUGIN_LAUNCHER -nw"
+
+# same than M-x eval but from outside Emacs.
+alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
+# create a new X frame
+alias eframe='emacsclient --alternate-editor "" --create-frame'
+
+# Emacs ANSI Term tracking
+if [[ -n "$INSIDE_EMACS" ]]; then
+ chpwd_emacs() { print -P "\033AnSiTc %d"; }
+ print -P "\033AnSiTc %d" # Track current working directory
+ print -P "\033AnSiTu %n" # Track username
+
+ # add chpwd hook
+ autoload -Uz add-zsh-hook
+ add-zsh-hook chpwd chpwd_emacs
fi
-## Local Variables:
-## mode: sh
-## End:
+# Write to standard output the path to the file
+# opened in the current buffer.
+function efile {
+ local cmd="(buffer-file-name (window-buffer))"
+ local file="$("$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \")"
+
+ if [[ -z "$file" ]]; then
+ echo "Can't deduce current buffer filename." >&2
+ return 1
+ fi
+
+ echo "$file"
+}
+
+# Write to standard output the directory of the file
+# opened in the the current buffer
+function ecd {
+ local file
+ file="$(efile)" || return $?
+ echo "${file:h}"
+}
diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
index 0aa8d6f40..25efe0d68 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -1,29 +1,38 @@
#!/bin/sh
-_emacsfun()
-{
- # get list of emacs frames.
- frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'`
+emacsfun() {
+ local cmd frames
- if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then
- # prevent creating another X frame if there is at least one present.
- emacsclient --alternate-editor "" "$@"
- else
- # Create one if there is no X window yet.
- emacsclient --alternate-editor "" --create-frame "$@"
- fi
-}
+ # Build the Emacs Lisp command to check for suitable frames
+ # See https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html#index-framep
+ case "$*" in
+ *-t*|*--tty*|*-nw*) cmd="(memq 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are tty frames
+ *) cmd="(delete 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are graphical terminals (x, w32, ns)
+ esac
+
+ # Check if there are suitable frames
+ frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null)"
+ # Only create another X frame if there isn't one present
+ if [ -z "$frames" -o "$frames" = nil ]; then
+ emacsclient --alternate-editor "" --create-frame "$@"
+ return $?
+ fi
-# adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
+ emacsclient --alternate-editor "" "$@"
+}
+
+# Adapted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
# If the second argument is - then write stdin to a tempfile and open the
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
-if [ "$#" -ge "2" -a "$2" = "-" ]
-then
- tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
- || mktemp -t emacs-stdin-$USER)" # support BSD mktemp
- cat - > "$tempfile"
- _emacsfun --no-wait $tempfile
-else
- _emacsfun "$@"
+if [ $# -ge 2 -a "$2" = "-" ]; then
+ # Create a tempfile to hold stdin
+ tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
+ || mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
+ # Redirect stdin to the tempfile
+ cat - > "$tempfile"
+ # Reset $2 to the tempfile so that "$@" works as expected
+ set -- "$1" "$tempfile" "${@:3}"
fi
+
+emacsfun "$@"
diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh
index e288b5cfb..4511275d6 100644
--- a/plugins/emotty/emotty.plugin.zsh
+++ b/plugins/emotty/emotty.plugin.zsh
@@ -29,7 +29,7 @@ function emotty() {
# Parse tty number via prompt expansion. %l equals:
# - N if tty = /dev/ttyN
# - pts/N if tty = /dev/pts/N
- local tty = ${${(%):-%l}##pts/}
+ local tty=${${(%):-%l}##pts/}
# Normalize it to an emotty set index
(( tty = (tty % ${#${=emotty}}) + 1 ))
diff --git a/plugins/encode64/README.md b/plugins/encode64/README.md
index a83a3d3d2..86320cffb 100644
--- a/plugins/encode64/README.md
+++ b/plugins/encode64/README.md
@@ -53,6 +53,6 @@ plugins=(... encode64)
```console
$ echo "b2gtbXktenNoCg==" | decode64
oh-my-zsh
- $ echo "b2gtbXktenNoCg==" | decode64
+ $ echo "b2gtbXktenNoCg==" | d64
oh-my-zsh
```
diff --git a/plugins/extract/README.md b/plugins/extract/README.md
index 81e8e1d23..44f0b05a1 100644
--- a/plugins/extract/README.md
+++ b/plugins/extract/README.md
@@ -21,8 +21,12 @@ plugins=(... extract)
| `apk` | Android app file |
| `aar` | Android library file |
| `bz2` | Bzip2 file |
+| `cab` | Microsoft cabinet archive |
+| `cpio` | Cpio archive |
| `deb` | Debian package |
+| `ear` | Enterprise Application aRchive |
| `gz` | Gzip file |
+| `ipa` | iOS app package |
| `ipsw` | iOS firmware file |
| `jar` | Java Archive |
| `lrz` | LRZ archive |
diff --git a/plugins/extract/_extract b/plugins/extract/_extract
index 1a263a744..27b099c9e 100644
--- a/plugins/extract/_extract
+++ b/plugins/extract/_extract
@@ -3,5 +3,5 @@
_arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
- "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
+ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
&& return 0
diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
index a5594b81a..1112dd52f 100644
--- a/plugins/extract/extract.plugin.zsh
+++ b/plugins/extract/extract.plugin.zsh
@@ -1,82 +1,85 @@
alias x=extract
extract() {
- local remove_archive
- local success
- local extract_dir
+ setopt localoptions noautopushd
- if (( $# == 0 )); then
- cat <<-'EOF' >&2
- Usage: extract [-option] [file ...]
+ if (( $# == 0 )); then
+ cat >&2 <<'EOF'
+Usage: extract [-option] [file ...]
- Options:
- -r, --remove Remove archive after unpacking.
- EOF
- fi
+Options:
+ -r, --remove Remove archive after unpacking.
+EOF
+ fi
- remove_archive=1
- if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
- remove_archive=0
- shift
- fi
+ local remove_archive=1
+ if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
+ remove_archive=0
+ shift
+ fi
- while (( $# > 0 )); do
- if [[ ! -f "$1" ]]; then
- echo "extract: '$1' is not a valid file" >&2
- shift
- continue
- fi
+ local pwd="$PWD"
+ while (( $# > 0 )); do
+ if [[ ! -f "$1" ]]; then
+ echo "extract: '$1' is not a valid file" >&2
+ shift
+ continue
+ fi
- success=0
- extract_dir="${1:t:r}"
- case "${1:l}" in
- (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
- (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
- (*.tar.xz|*.txz)
- tar --xz --help &> /dev/null \
- && tar --xz -xvf "$1" \
- || xzcat "$1" | tar xvf - ;;
- (*.tar.zma|*.tlz)
- tar --lzma --help &> /dev/null \
- && tar --lzma -xvf "$1" \
- || lzcat "$1" | tar xvf - ;;
- (*.tar.zst|*.tzst)
- tar --zstd --help &> /dev/null \
- && tar --zstd -xvf "$1" \
- || zstdcat "$1" | tar xvf - ;;
- (*.tar) tar xvf "$1" ;;
- (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;;
- (*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;;
- (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;;
- (*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;;
- (*.bz2) bunzip2 "$1" ;;
- (*.xz) unxz "$1" ;;
- (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;;
- (*.lz4) lz4 -d "$1" ;;
- (*.lzma) unlzma "$1" ;;
- (*.z) uncompress "$1" ;;
- (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
- (*.rar) unrar x -ad "$1" ;;
- (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
- (*.7z) 7za x "$1" ;;
- (*.deb)
- mkdir -p "$extract_dir/control"
- mkdir -p "$extract_dir/data"
- cd "$extract_dir"; ar vx "../${1}" > /dev/null
- cd control; tar xzvf ../control.tar.gz
- cd ../data; extract ../data.tar.*
- cd ..; rm *.tar.* debian-binary
- cd ..
- ;;
- (*.zst) unzstd "$1" ;;
- (*)
- echo "extract: '$1' cannot be extracted" >&2
- success=1
- ;;
- esac
+ local success=0
+ local extract_dir="${1:t:r}"
+ local file="$1" full_path="${1:A}"
+ case "${file:l}" in
+ (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;;
+ (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;;
+ (*.tar.xz|*.txz)
+ tar --xz --help &> /dev/null \
+ && tar --xz -xvf "$file" \
+ || xzcat "$file" | tar xvf - ;;
+ (*.tar.zma|*.tlz)
+ tar --lzma --help &> /dev/null \
+ && tar --lzma -xvf "$file" \
+ || lzcat "$file" | tar xvf - ;;
+ (*.tar.zst|*.tzst)
+ tar --zstd --help &> /dev/null \
+ && tar --zstd -xvf "$file" \
+ || zstdcat "$file" | tar xvf - ;;
+ (*.tar) tar xvf "$file" ;;
+ (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;;
+ (*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;;
+ (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;;
+ (*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;;
+ (*.bz2) bunzip2 "$file" ;;
+ (*.xz) unxz "$file" ;;
+ (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;;
+ (*.lz4) lz4 -d "$file" ;;
+ (*.lzma) unlzma "$file" ;;
+ (*.z) uncompress "$file" ;;
+ (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;;
+ (*.rar) unrar x -ad "$file" ;;
+ (*.rpm)
+ command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \
+ && rpm2cpio "$full_path" | cpio --quiet -id ;;
+ (*.7z) 7za x "$file" ;;
+ (*.deb)
+ command mkdir -p "$extract_dir/control" "$extract_dir/data"
+ builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null
+ builtin cd -q control; extract ../control.tar.*
+ builtin cd -q ../data; extract ../data.tar.*
+ builtin cd -q ..; command rm *.tar.* debian-binary ;;
+ (*.zst) unzstd "$file" ;;
+ (*.cab) cabextract -d "$extract_dir" "$file" ;;
+ (*.cpio) cpio -idmvF "$file" ;;
+ (*)
+ echo "extract: '$file' cannot be extracted" >&2
+ success=1 ;;
+ esac
- (( success = $success > 0 ? $success : $? ))
- (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
- shift
- done
+ (( success = success > 0 ? success : $? ))
+ (( success == 0 && remove_archive == 0 )) && rm "$full_path"
+ shift
+
+ # Go back to original working directory in case we ran cd previously
+ builtin cd -q "$pwd"
+ done
}
diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md
deleted file mode 100644
index 85d8d7dea..000000000
--- a/plugins/fedora/README.md
+++ /dev/null
@@ -1 +0,0 @@
-The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead.
diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh
deleted file mode 100644
index 226506c05..000000000
--- a/plugins/fedora/fedora.plugin.zsh
+++ /dev/null
@@ -1,3 +0,0 @@
-print -P "%F{yellow}The 'fedora' plugin is deprecated. Use the '%Udnf%u' plugin instead.%f"
-
-source "$ZSH/plugins/dnf/dnf.plugin.zsh"
diff --git a/plugins/fnm/README.md b/plugins/fnm/README.md
new file mode 100644
index 000000000..00fab5cd4
--- /dev/null
+++ b/plugins/fnm/README.md
@@ -0,0 +1,9 @@
+# fnm plugin
+
+This plugin adds autocompletion for [fnm](https://github.com/Schniz/fnm) - a Node.js version manager.
+
+To use it, add `fnm` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... fnm)
+```
diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh
new file mode 100644
index 000000000..c161b27cd
--- /dev/null
+++ b/plugins/fnm/fnm.plugin.zsh
@@ -0,0 +1,23 @@
+if (( $+commands[fnm] )); then
+ # remove old generated completion file
+ command rm -f "${0:A:h}/_fnm"
+
+ ver="$(fnm --version)"
+ ver_file="$ZSH_CACHE_DIR/fnm_version"
+ comp_file="$ZSH_CACHE_DIR/completions/_fnm"
+
+ mkdir -p "${comp_file:h}"
+ (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
+
+ if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
+ fnm completions --shell=zsh >| "$comp_file"
+ echo "$ver" >| "$ver_file"
+ fi
+
+ declare -A _comps
+ autoload -Uz _fnm
+ _comps[fnm]=_fnm
+
+ unset ver ver_file comp_file
+fi
+
diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh
index 1ae166e62..25a8d121d 100644
--- a/plugins/fossil/fossil.plugin.zsh
+++ b/plugins/fossil/fossil.plugin.zsh
@@ -73,9 +73,9 @@ function _fossil_prompt () {
local is_prompt=`echo $PROMPT | grep git`
if [ "$is_prompt" = "" ]; then
- export RPROMPT="$_rprompt"'$(fossil_prompt_info)'
+ RPROMPT="$_rprompt"'$(fossil_prompt_info)'
else
- export PROMPT="$_prompt"'$(fossil_prompt_info) '
+ PROMPT="$_prompt"'$(fossil_prompt_info) '
fi
_FOSSIL_PROMPT="1"
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index 4517e21a8..437e477b9 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -29,14 +29,10 @@ alias unheap='frontend unheap'
alias vuejs='frontend vuejs'
function _frontend_fallback() {
- local url
- if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
- url="https://duckduckgo.com/?sites=$1&q="
- else
- url="https://google.com/search?as_sitesearch=$1&as_q="
- fi
-
- echo "$url"
+ case "$FRONTEND_SEARCH_FALLBACK" in
+ duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;;
+ *) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;;
+ esac
}
function frontend() {
@@ -51,7 +47,7 @@ function frontend() {
bootsnipp 'https://bootsnipp.com/search?q='
bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search='
- codepen 'https://codepen.io/search?q='
+ codepen 'https://codepen.io/search/pens?q='
compassdoc 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md
index b3a434347..791a3eb6f 100644
--- a/plugins/fzf/README.md
+++ b/plugins/fzf/README.md
@@ -1,19 +1,52 @@
# fzf
-This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings
+This plugin tries to find [junegunn's fzf](https://github.com/junegunn/fzf) based on where
+it's been installed, and enables its fuzzy auto-completion and key bindings.
+
+To use it, add `fzf` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... fzf)
+```
+
+## Settings
+
+All these settings should go in your zshrc file, before Oh My Zsh is sourced.
+
+### `FZF_BASE`
+
+Set to fzf installation directory path:
```zsh
-# Set fzf installation directory path
export FZF_BASE=/path/to/fzf/install/dir
+```
+
+### `FZF_DEFAULT_COMMAND`
+
+Set default command to use when input is tty:
-# Uncomment the following line to disable fuzzy completion
-# export DISABLE_FZF_AUTO_COMPLETION="true"
+```zsh
+export FZF_DEFAULT_COMMAND='<your fzf default commmand>'
+```
+
+If not set, the plugin will try to set it to these, in the order in which they're found:
-# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
-# export DISABLE_FZF_KEY_BINDINGS="true"
+- [`rg`](https://github.com/BurntSushi/ripgrep)
+- [`fd`](https://github.com/sharkdp/fd)
+- [`ag`](https://github.com/ggreer/the_silver_searcher)
-plugins=(
- ...
- fzf
-)
+### `DISABLE_FZF_AUTO_COMPLETION`
+
+Set whether to load fzf auto-completion:
+
+```zsh
+DISABLE_FZF_AUTO_COMPLETION="true"
+```
+
+### `DISABLE_FZF_KEY_BINDINGS`
+
+Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C):
+
+```zsh
+DISABLE_FZF_KEY_BINDINGS="true"
```
diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh
index 53bdcbc97..a979fe222 100644
--- a/plugins/fzf/fzf.plugin.zsh
+++ b/plugins/fzf/fzf.plugin.zsh
@@ -1,9 +1,5 @@
function setup_using_base_dir() {
- # Declare all variables local not no mess with outside env in any way
- local fzf_base
- local fzf_shell
- local fzfdirs
- local dir
+ local fzf_base fzf_shell fzfdirs dir
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
@@ -11,6 +7,7 @@ function setup_using_base_dir() {
fzfdirs=(
"${HOME}/.fzf"
"${HOME}/.nix-profile/share/fzf"
+ "${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
"/usr/local/opt/fzf"
"/usr/share/fzf"
"/usr/local/share/examples/fzf"
@@ -31,53 +28,62 @@ function setup_using_base_dir() {
fi
fi
- if [[ -d "${fzf_base}" ]]; then
- # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
- if [[ ! -d "${fzf_base}/shell" ]]; then
- fzf_shell="${fzf_base}"
- else
- fzf_shell="${fzf_base}/shell"
- fi
+ if [[ ! -d "${fzf_base}" ]]; then
+ return 1
+ fi
- # Setup fzf binary path
- if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
- export PATH="$PATH:$fzf_base/bin"
- fi
+ # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
+ if [[ ! -d "${fzf_base}/shell" ]]; then
+ fzf_shell="${fzf_base}"
+ else
+ fzf_shell="${fzf_base}/shell"
+ fi
- # Auto-completion
- if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
- [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
- fi
+ # Setup fzf binary path
+ if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then
+ export PATH="$PATH:$fzf_base/bin"
+ fi
- # Key bindings
- if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
- source "${fzf_shell}/key-bindings.zsh"
- fi
- else
- return 1
+ # Auto-completion
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source "${fzf_shell}/completion.zsh" 2> /dev/null
+ fi
+
+ # Key bindings
+ if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
+ source "${fzf_shell}/key-bindings.zsh"
fi
}
function setup_using_debian_package() {
- (( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
- if (( $? )); then
- # Either not a debian based distro, or no fzf installed. In any case skip ahead
+ if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
+ # Either not a debian based distro, or no fzf installed
return 1
fi
# NOTE: There is no need to configure PATH for debian package, all binaries
# are installed to /usr/bin by default
- # Determine completion file path: first bullseye/sid, then buster/stretch
- local completions="/usr/share/doc/fzf/examples/completion.zsh"
- [[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
-
- local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
+ local completions key_bindings
+
+ case $PREFIX in
+ *com.termux*)
+ # Support Termux package
+ completions="${PREFIX}/share/fzf/completion.zsh"
+ key_bindings="${PREFIX}/share/fzf/key-bindings.zsh"
+ ;;
+ *)
+ # Determine completion file path: first bullseye/sid, then buster/stretch
+ completions="/usr/share/doc/fzf/examples/completion.zsh"
+ [[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
+ key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
+ ;;
+ esac
# Auto-completion
- if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
- source $completions 2> /dev/null
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source $completions 2> /dev/null
fi
# Key bindings
@@ -88,13 +94,81 @@ function setup_using_debian_package() {
return 0
}
+function setup_using_opensuse_package() {
+ # OpenSUSE installs fzf in /usr/bin/fzf
+ # If the command is not found, the package isn't installed
+ (( $+commands[fzf] )) || return 1
+
+ # The fzf-zsh-completion package installs the auto-completion in
+ local completions="/usr/share/zsh/site-functions/_fzf"
+ # The fzf-zsh-completion package installs the key-bindings file in
+ local key_bindings="/etc/zsh_completion.d/fzf-key-bindings"
+
+ # If these are not found: (1) maybe we're not on OpenSUSE, or
+ # (2) maybe the fzf-zsh-completion package isn't installed.
+ if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
+ return 1
+ fi
+
+ # Auto-completion
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source "$completions" 2>/dev/null
+ fi
+
+ # Key bindings
+ if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
+ source "$key_bindings" 2>/dev/null
+ fi
+
+ return 0
+}
+
+function setup_using_openbsd_package() {
+ # openBSD installs fzf in /usr/local/bin/fzf
+ if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
+ return 1
+ fi
+
+ # The fzf package installs the auto-completion in
+ local completions="/usr/local/share/zsh/site-functions/_fzf_completion"
+ # The fzf package installs the key-bindings file in
+ local key_bindings="/usr/local/share/zsh/site-functions/_fzf_key_bindings"
+
+ # Auto-completion
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source "$completions" 2>/dev/null
+ fi
+
+ # Key bindings
+ if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
+ source "$key_bindings" 2>/dev/null
+ fi
+
+ return 0
+}
+
function indicate_error() {
- print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
- "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
+ cat >&2 <<EOF
+[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
+Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc
+EOF
}
-# Check for debian package first, because it easy to short cut
# Indicate to user that fzf installation not found if nothing worked
-setup_using_debian_package || setup_using_base_dir || indicate_error
-
-unset -f setup_using_debian_package setup_using_base_dir indicate_error
+setup_using_openbsd_package \
+ || setup_using_debian_package \
+ || setup_using_opensuse_package \
+ || setup_using_base_dir \
+ || indicate_error
+
+unset -f setup_using_opensuse_package setup_using_debian_package setup_using_base_dir indicate_error
+
+if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
+ if (( $+commands[rg] )); then
+ export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
+ elif (( $+commands[fd] )); then
+ export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
+ elif (( $+commands[ag] )); then
+ export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
+ fi
+fi
diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh
index c7aebe697..7368eb3a6 100644
--- a/plugins/gcloud/gcloud.plugin.zsh
+++ b/plugins/gcloud/gcloud.plugin.zsh
@@ -7,6 +7,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=(
"$HOME/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
+ "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
"/snap/google-cloud-sdk/current"
"/usr/lib64/google-cloud-sdk/"
diff --git a/plugins/genpass/README.md b/plugins/genpass/README.md
new file mode 100644
index 000000000..a5ff4a876
--- /dev/null
+++ b/plugins/genpass/README.md
@@ -0,0 +1,66 @@
+# genpass
+
+This plugin provides three unique password generators for ZSH. Each generator
+has at least a 128-bit security margin and generates passwords from the
+cryptographically secure `/dev/urandom`. Each generator can also take an
+optional numeric argument to generate multiple passwords.
+
+To use it from an interactive ZSH, add `genpass` to the plugins array in your
+zshrc file:
+
+ plugins=(... genpass)
+
+You can also invoke password generators directly (they are implemented as
+standalone executable files), which can be handy when you need to generate
+passwords in a script:
+
+ ~/.oh-my-zsh/plugins/genpass/genpass-apple 3
+
+## genpass-apple
+
+Generates a pronounceable pseudoword passphrase of the "cvccvc" consonant/vowel
+syntax, inspired by [Apple's iCloud Keychain password generator][1]. Each
+password has exactly 1 digit placed at the edge of a "word" and exactly 1
+capital letter to satisfy most password security requirements.
+
+ % genpass-apple
+ gelcyv-foqtam-fotqoh-viMleb-lexduv-6ixfuk
+
+ % genpass-apple 3
+ japvyz-qyjti4-kajrod-nubxaW-hukkan-dijcaf
+ vydpig-fucnul-3ukpog-voggom-zygNad-jepgad
+ zocmez-byznis-hegTaj-jecdyq-qiqmiq-5enwom
+
+[1]: https://developer.apple.com/password-rules/
+
+## genpass-monkey
+
+Generates visually unambiguous random meaningless strings using [Crockford's
+base32][2].
+
+ % genpass-monkey
+ xt7gn976e7jj3fstgpy27330x3
+
+ % genpass-monkey 3
+ n1qqwtzgejwgqve9yzf2gxvx4m
+ r2n3f5s6vbqs2yx7xjnmahqewy
+ 296w9y9rts3p5r9yay0raek8e5
+
+[2]: https://www.crockford.com/base32.html
+
+## genpass-xkcd
+
+Generates passphrases from `/usr/share/dict/words` inspired by the [famous (and
+slightly misleading) XKCD comic][3]. Each passphrase is prepended with a digit
+showing the number of words in the passphrase to adhere to password security
+requirements that require digits. Each word is 6 characters or less.
+
+ % genpass-xkcd
+ 9-eaten-Slav-rife-aired-hill-cordon-splits-welsh-napes
+
+ % genpass-xkcd 3
+ 9-worker-Vlad-horde-shrubs-smite-thwart-paw-alters-prawns
+ 9-tutors-stink-rhythm-junk-snappy-hooray-barbs-mewl-clomp
+ 9-vital-escape-Angkor-Huff-wet-Mayra-abbés-putts-guzzle
+
+[3]: https://xkcd.com/936/
diff --git a/plugins/genpass/genpass-apple b/plugins/genpass/genpass-apple
new file mode 100755
index 000000000..963ab6447
--- /dev/null
+++ b/plugins/genpass/genpass-apple
@@ -0,0 +1,79 @@
+#!/usr/bin/env zsh
+#
+# Usage: genpass-apple [NUM]
+#
+# Generate a password made of 6 pseudowords of 6 characters each
+# with the security margin of at least 128 bits.
+#
+# Example password: xudmec-4ambyj-tavric-mumpub-mydVop-bypjyp
+#
+# If given a numerical argument, generate that many passwords.
+
+emulate -L zsh -o no_unset -o warn_create_global -o warn_nested_var
+
+if [[ ARGC -gt 1 || ${1-1} != ${~:-<1-$((16#7FFFFFFF))>} ]]; then
+ print -ru2 -- "usage: $0 [NUM]"
+ return 1
+fi
+
+zmodload zsh/system zsh/mathfunc || return
+
+{
+ local -r vowels=aeiouy
+ local -r consonants=bcdfghjklmnpqrstvwxz
+ local -r digits=0123456789
+
+ # Sets REPLY to a uniformly distributed random number in [1, $1].
+ # Requires: $1 <= 256.
+ function -$0-rand() {
+ local c
+ while true; do
+ sysread -s1 c || return
+ # Avoid bias towards smaller numbers.
+ (( #c < 256 / $1 * $1 )) && break
+ done
+ typeset -g REPLY=$((#c % $1 + 1))
+ }
+
+ local REPLY chars
+
+ repeat ${1-1}; do
+ # Generate 6 pseudowords of the form cvccvc where c and v
+ # denote random consonants and vowels respectively.
+ local words=()
+ repeat 6; do
+ words+=('')
+ repeat 2; do
+ for chars in $consonants $vowels $consonants; do
+ -$0-rand $#chars || return
+ words[-1]+=$chars[REPLY]
+ done
+ done
+ done
+
+ local pwd=${(j:-:)words}
+
+ # Replace either the first or the last character in one of
+ # the words with a random digit.
+ -$0-rand $#digits || return
+ local digit=$digits[REPLY]
+ -$0-rand $((2 * $#words)) || return
+ pwd[REPLY/2*7+2*(REPLY%2)-1]=$digit
+
+ # Convert one lower-case character to upper case.
+ while true; do
+ -$0-rand $#pwd || return
+ [[ $vowels$consonants == *$pwd[REPLY]* ]] && break
+ done
+ # NOTE: We aren't using ${(U)c} here because its results are
+ # locale-dependent. For example, when upper-casing 'i' in Turkish
+ # locale we would get 'İ', a.k.a. latin capital letter i with dot
+ # above. We could set LC_CTYPE=C locally but then we would run afoul
+ # of this zsh bug: https://www.zsh.org/mla/workers/2020/msg00588.html.
+ local c=$pwd[REPLY]
+ printf -v c '%o' $((#c - 32))
+ printf "%s\\$c%s\\n" "$pwd[1,REPLY-1]" "$pwd[REPLY+1,-1]" || return
+ done
+} always {
+ unfunction -m -- "-${(b)0}-*"
+} </dev/urandom
diff --git a/plugins/genpass/genpass-monkey b/plugins/genpass/genpass-monkey
new file mode 100755
index 000000000..94ff5e131
--- /dev/null
+++ b/plugins/genpass/genpass-monkey
@@ -0,0 +1,32 @@
+#!/usr/bin/env zsh
+#
+# Usage: genpass-monkey [NUM]
+#
+# Generate a password made of 26 alphanumeric characters
+# with the security margin of at least 128 bits.
+#
+# Example password: nz5ej2kypkvcw0rn5cvhs6qxtm
+#
+# If given a numerical argument, generate that many passwords.
+
+emulate -L zsh -o no_unset -o warn_create_global -o warn_nested_var
+
+if [[ ARGC -gt 1 || ${1-1} != ${~:-<1-$((16#7FFFFFFF))>} ]]; then
+ print -ru2 -- "usage: $0 [NUM]"
+ return 1
+fi
+
+zmodload zsh/system || return
+
+{
+ local -r chars=abcdefghjkmnpqrstvwxyz0123456789
+ local c
+ repeat ${1-1}; do
+ repeat 26; do
+ sysread -s1 c || return
+ # There is uniform because $#chars divides 256.
+ print -rn -- $chars[#c%$#chars+1]
+ done
+ print
+ done
+} </dev/urandom
diff --git a/plugins/genpass/genpass-xkcd b/plugins/genpass/genpass-xkcd
new file mode 100755
index 000000000..ed0397138
--- /dev/null
+++ b/plugins/genpass/genpass-xkcd
@@ -0,0 +1,68 @@
+#!/usr/bin/env zsh
+#
+# Usage: genpass-xkcd [NUM]
+#
+# Generate a password made of words from /usr/share/dict/words
+# with the security margin of at least 128 bits.
+#
+# Example password: 9-mien-flood-Patti-buxom-dozes-ickier-pay-ailed-Foster
+#
+# If given a numerical argument, generate that many passwords.
+#
+# The name of this utility is a reference to https://xkcd.com/936/.
+
+emulate -L zsh -o no_unset -o warn_create_global -o warn_nested_var -o extended_glob
+
+if [[ ARGC -gt 1 || ${1-1} != ${~:-<1-$((16#7FFFFFFF))>} ]]; then
+ print -ru2 -- "usage: $0 [NUM]"
+ return 1
+fi
+
+zmodload zsh/system zsh/mathfunc || return
+
+local -r dict=/usr/share/dict/words
+
+if [[ ! -e $dict ]]; then
+ print -ru2 -- "$0: file not found: $dict"
+ return 1
+fi
+
+# Read all dictionary words and leave only those made of 1-6 characters.
+local -a words
+words=(${(M)${(f)"$(<$dict)"}:#[a-zA-Z](#c1,6)}) || return
+
+if (( $#words < 2 )); then
+ print -ru2 -- "$0: not enough suitable words in $dict"
+ return 1
+fi
+
+if (( $#words > 16#7FFFFFFF )); then
+ print -ru2 -- "$0: too many words in $dict"
+ return 1
+fi
+
+# Figure out how many words we need for 128 bits of security margin.
+# Each word adds log2($#words) bits.
+local -i n=$((ceil(128. / (log($#words) / log(2)))))
+
+{
+ local c
+ repeat ${1-1}; do
+ print -rn -- $n
+ repeat $n; do
+ while true; do
+ # Generate a random number in [0, 2**31).
+ local -i rnd=0
+ repeat 4; do
+ sysread -s1 c || return
+ (( rnd = (~(1 << 23) & rnd) << 8 | #c ))
+ done
+ # Avoid bias towards words in the beginning of the list.
+ (( rnd < 16#7FFFFFFF / $#words * $#words )) || continue
+ print -rn -- -$words[rnd%$#words+1]
+ break
+ done
+ done
+ print
+ done
+} </dev/urandom
diff --git a/plugins/genpass/genpass.plugin.zsh b/plugins/genpass/genpass.plugin.zsh
new file mode 100644
index 000000000..a0ea841cd
--- /dev/null
+++ b/plugins/genpass/genpass.plugin.zsh
@@ -0,0 +1 @@
+autoload -Uz genpass-apple genpass-monkey genpass-xkcd
diff --git a/plugins/gh/README.md b/plugins/gh/README.md
new file mode 100644
index 000000000..54e046a1c
--- /dev/null
+++ b/plugins/gh/README.md
@@ -0,0 +1,23 @@
+# GitHub CLI plugin
+
+This plugin adds completion for the [GitHub CLI](https://cli.github.com/).
+
+To use it, add `gh` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... gh)
+```
+
+This plugin does not add any aliases.
+
+## Cache
+
+This plugin caches the completion script and is automatically updated when the
+plugin is loaded, which is usually when you start up a new terminal emulator.
+
+The cache is stored at:
+
+- `$ZSH/plugins/gh/_gh` completions script
+
+- `$ZSH_CACHE_DIR/gh_version` version of GitHub CLI, used to invalidate
+ the cache.
diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh
new file mode 100644
index 000000000..3e4cdee5e
--- /dev/null
+++ b/plugins/gh/gh.plugin.zsh
@@ -0,0 +1,24 @@
+# Autocompletion for the GitHub CLI (gh).
+if (( $+commands[gh] )); then
+ # remove old generated completion file
+ command rm -f "${0:A:h}/_gh"
+
+ ver="$(gh --version)"
+ ver_file="$ZSH_CACHE_DIR/gh_version"
+ comp_file="$ZSH_CACHE_DIR/completions/_gh"
+
+ mkdir -p "${comp_file:h}"
+ (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
+
+ if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
+ gh completion --shell zsh >| "$comp_file"
+ echo "$ver" >| "$ver_file"
+ fi
+
+ declare -A _comps
+ autoload -Uz _gh
+ _comps[gh]=_gh
+
+ unset ver ver_file comp_file
+fi
+
diff --git a/plugins/git-auto-fetch/README.md b/plugins/git-auto-fetch/README.md
index 35f3c2f71..e96ab42a3 100644
--- a/plugins/git-auto-fetch/README.md
+++ b/plugins/git-auto-fetch/README.md
@@ -1,26 +1,29 @@
# Git auto-fetch
-Automatically fetches all changes from all remotes while you are working in git-initialized directory.
+Automatically fetches all changes from all remotes while you are working in a git-initialized directory.
-#### Usage
-
-Add `git-auto-fetch` to the plugins array in your zshrc file:
+To use it, add `git-auto-fetch` to the plugins array in your zshrc file:
```shell
plugins=(... git-auto-fetch)
```
-Every time you launch a command in your shell all remotes will be fetched in background.
-By default autofetch will be triggered only if last fetch was done at least 60 seconds ago.
-You can change fetch interval in your .zshrc:
-```
-GIT_AUTO_FETCH_INTERVAL=1200 #in seconds
+## Usage
+
+Every time the command prompt is shown all remotes will be fetched in the background. By default,
+`git-auto-fetch` will be triggered only if the last auto-fetch was done at least 60 seconds ago.
+You can change the fetch interval in your .zshrc:
+
+```sh
+GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
```
-Log of `git fetch --all` will be saved into `.git/FETCH_LOG`
+A log of `git fetch --all` will be saved in `.git/FETCH_LOG`.
+
+## Toggle auto-fetch per folder
-#### Toggle auto fetch per folder
-If you are using mobile connection or for any other reason you can disable git-auto-fetch for any folder:
+If you are using a mobile connection or for any other reason you can disable git-auto-fetch
+for any folder:
```shell
$ cd to/your/project
@@ -29,3 +32,19 @@ disabled
$ git-auto-fetch
enabled
```
+
+## Caveats
+
+Automatically fetching all changes defeats the purpose of `git push --force-with-lease`,
+and makes it behave like `git push --force` in some cases. For example:
+
+Consider that you made some changes and possibly rebased some stuff, which means you'll
+need to use `--force-with-lease` to overwrite the remote history of a branch. Between the
+time when you make the changes (maybe do a `git log`) and the time when you `git push`,
+it's possible that someone else updates the branch you're working on.
+
+If `git-auto-fetch` triggers then, you'll have fetched the remote changes without knowing
+it, and even though you're running the push with `--force-with-lease`, git will overwrite
+the recent changes because you already have them in your local repository. The
+[`git push --force-with-lease` docs](https://git-scm.com/docs/git-push) talk about possible
+solutions to this problem.
diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
index 5c42c21a7..efe8cbe66 100644
--- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
+++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
@@ -1,36 +1,63 @@
-GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60}
+# Default auto-fetch interval: 60 seconds
+: ${GIT_AUTO_FETCH_INTERVAL:=60}
+
+# Necessary for the git-fetch-all function
+zmodload zsh/datetime zsh/stat
function git-fetch-all {
- (`command git rev-parse --is-inside-work-tree 2>/dev/null` &&
- dir=`command git rev-parse --git-dir` &&
- [[ ! -f $dir/NO_AUTO_FETCH ]] &&
- (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) &&
- GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
- command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &)
+ (
+ # Get git root directory
+ if ! gitdir="$(command git rev-parse --git-dir 2>/dev/null)"; then
+ return 0
+ fi
+
+ # Do nothing if auto-fetch is disabled or don't have permissions
+ if [[ ! -w "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]] ||
+ [[ -f "$gitdir/FETCH_LOG" && ! -w "$gitdir/FETCH_LOG" ]]; then
+ return 0
+ fi
+
+ # Get time (seconds) when auto-fetch was last run
+ lastrun="$(zstat +mtime "$gitdir/FETCH_LOG" 2>/dev/null || echo 0)"
+ # Do nothing if not enough time has passed since last auto-fetch
+ if (( EPOCHSECONDS - lastrun < $GIT_AUTO_FETCH_INTERVAL )); then
+ return 0
+ fi
+
+ # Fetch all remotes (avoid ssh passphrase prompt)
+ date -R &>! "$gitdir/FETCH_LOG"
+ GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
+ command git fetch --all 2>/dev/null &>> "$gitdir/FETCH_LOG"
+ ) &|
}
function git-auto-fetch {
- `command git rev-parse --is-inside-work-tree 2>/dev/null` || return
- guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH"
+ # Do nothing if not in a git repository
+ command git rev-parse --is-inside-work-tree &>/dev/null || return 0
- (rm $guard 2>/dev/null &&
- echo "${fg_bold[green]}enabled${reset_color}") ||
- (touch $guard &&
- echo "${fg_bold[red]}disabled${reset_color}")
+ # Remove or create guard file depending on its existence
+ local guard="$(command git rev-parse --git-dir)/NO_AUTO_FETCH"
+ if [[ -f "$guard" ]]; then
+ command rm "$guard" && echo "${fg_bold[green]}enabled${reset_color}"
+ else
+ command touch "$guard" && echo "${fg_bold[red]}disabled${reset_color}"
+ fi
}
-# Override zle-line-init if it exists
-if (( $+functions[zle-line-init] )); then
- eval "override-git-auto-fetch-$(declare -f zle-line-init)"
-
- function zle-line-init () {
- git-fetch-all
- override-git-auto-fetch-zle-line-init
- }
-else
- function zle-line-init () {
- git-fetch-all
- }
-fi
-
-zle -N zle-line-init
+# zle-line-init widget (don't redefine if already defined)
+(( ! ${+functions[_git-auto-fetch_zle-line-init]} )) || return 0
+
+case "$widgets[zle-line-init]" in
+ # Simply define the function if zle-line-init doesn't yet exist
+ builtin|"") function _git-auto-fetch_zle-line-init() {
+ git-fetch-all
+ } ;;
+ # Override the current zle-line-init widget, calling the old one
+ user:*) zle -N _git-auto-fetch_orig_zle-line-init "${widgets[zle-line-init]#user:}"
+ function _git-auto-fetch_zle-line-init() {
+ git-fetch-all
+ zle _git-auto-fetch_orig_zle-line-init -- "$@"
+ } ;;
+esac
+
+zle -N zle-line-init _git-auto-fetch_zle-line-init
diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh
index eab969d8a..8f0714b16 100644
--- a/plugins/git-flow/git-flow.plugin.zsh
+++ b/plugins/git-flow/git-flow.plugin.zsh
@@ -23,9 +23,9 @@
#Alias
alias gfl='git flow'
alias gfli='git flow init'
-alias gcd='git checkout develop'
-alias gch='git checkout hotfix'
-alias gcr='git checkout release'
+alias gcd='git checkout $(git config gitflow.branch.develop)'
+alias gch='git checkout $(git config gitflow.prefix.hotfix)'
+alias gcr='git checkout $(git config gitflow.prefix.release)'
alias gflf='git flow feature'
alias gflh='git flow hotfix'
alias gflr='git flow release'
@@ -36,7 +36,6 @@ alias gflff='git flow feature finish'
alias gflfp='git flow feature publish'
alias gflhf='git flow hotfix finish'
alias gflrf='git flow release finish'
-alias gflfp='git flow feature publish'
alias gflhp='git flow hotfix publish'
alias gflrp='git flow release publish'
alias gflfpll='git flow feature pull'
diff --git a/plugins/git-lfs/README.md b/plugins/git-lfs/README.md
new file mode 100644
index 000000000..1222b2767
--- /dev/null
+++ b/plugins/git-lfs/README.md
@@ -0,0 +1,24 @@
+# git lfs plugin
+
+The git lfs plugin provides [aliases](#aliases) and [functions](#functions) for [git-lfs](https://github.com/git-lfs/git-lfs).
+
+To use it, add `git-lfs` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... git-lfs)
+```
+
+## Aliases
+
+| Alias | Command |
+| :------- | :---------------------------------- |
+| `glfsi` | `git lfs install` |
+| `glfst` | `git lfs track` |
+| `glfsls` | `git lfs ls-files` |
+| `glfsmi` | `git lfs migrate import --include=` |
+
+## Functions
+
+| Function | Command |
+| :------- | :---------------------------------------------- |
+| `gplfs` | `git lfs push origin "$(current_branch)" --all` |
diff --git a/plugins/git-lfs/git-lfs.plugin.zsh b/plugins/git-lfs/git-lfs.plugin.zsh
new file mode 100644
index 000000000..e7bb67603
--- /dev/null
+++ b/plugins/git-lfs/git-lfs.plugin.zsh
@@ -0,0 +1,17 @@
+#
+# Aliases
+#
+
+alias glfsi='git lfs install'
+alias glfst='git lfs track'
+alias glfsls='git lfs ls-files'
+alias glfsmi='git lfs migrate import --include='
+
+#
+# Functions
+#
+
+function gplfs() {
+ local b="$(git_current_branch)"
+ git lfs push origin "$b" --all
+}
diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md
index e3b2d623a..c6610fa94 100644
--- a/plugins/git-prompt/README.md
+++ b/plugins/git-prompt/README.md
@@ -11,6 +11,9 @@ plugins=(... git-prompt)
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
+## Prerequisites
+This plugin uses `python`, so your host needs to have it installed
+
## Examples
The prompt may look like the following:
@@ -21,6 +24,7 @@ The prompt may look like the following:
- `(master|✖2✚3)`: on branch `master`, 2 conflicts, 3 files changed
- `(experimental↓2↑3|✔)`: on branch `experimental`; your branch has diverged by 3 commits, remote by 2 commits; the repository is otherwise clean
- `(:70c2952|✔)`: not on any branch; parent commit has hash `70c2952`; the repository is otherwise clean
+- `(master|⚑2)`: on branch `master`, there are 2 stashed changes
## Prompt Structure
@@ -40,6 +44,7 @@ The symbols are as follows:
| ●n | there are `n` staged files |
| ✖n | there are `n` unmerged files |
| ✚n | there are `n` unstaged files |
+| ⚑n | there are `n` stashed changes |
| … | there are some untracked files |
### Branch Tracking Symbols
diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh
index da674af98..a4c952471 100644
--- a/plugins/git-prompt/git-prompt.plugin.zsh
+++ b/plugins/git-prompt/git-prompt.plugin.zsh
@@ -40,6 +40,8 @@ function update_current_git_vars() {
GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5]
GIT_CHANGED=$__CURRENT_GIT_STATUS[6]
GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7]
+ GIT_STASHED=$__CURRENT_GIT_STATUS[8]
+ GIT_CLEAN=$__CURRENT_GIT_STATUS[9]
}
git_super_status() {
@@ -63,9 +65,12 @@ git_super_status() {
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}"
fi
if [ "$GIT_UNTRACKED" -ne "0" ]; then
- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}"
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED$GIT_UNTRACKED%{${reset_color}%}"
fi
- if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then
+ if [ "$GIT_STASHED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STASHED$GIT_STASHED%{${reset_color}%}"
+ fi
+ if [ "$GIT_CLEAN" -eq "1" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
@@ -83,7 +88,8 @@ ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}"
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
-ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}"
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}"
+ZSH_THEME_GIT_PROMPT_STASHED="%{$fg_bold[blue]%}%{⚑%G%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}"
# Set the prompt.
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index 300365d71..786274a71 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -11,11 +11,11 @@ def get_tagname_or_hash():
"""return tagname if exists else hash"""
# get hash
hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
- hash_ = check_output(hash_cmd).strip()
+ hash_ = check_output(hash_cmd).decode('utf-8').strip()
# get tagname
tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
- tags = check_output(tags_cmd).split()
+ tags = check_output(tags_cmd).decode('utf-8').split()
if tags:
return tags[0] + ('+' if len(tags) > 1 else '')
@@ -23,6 +23,18 @@ def get_tagname_or_hash():
return hash_
return None
+# Re-use method from https://github.com/magicmonty/bash-git-prompt to get stashs count
+def get_stash():
+ cmd = Popen(['git', 'rev-parse', '--git-dir'], stdout=PIPE, stderr=PIPE)
+ so, se = cmd.communicate()
+ stash_file = '%s%s' % (so.decode('utf-8').rstrip(), '/logs/refs/stash')
+
+ try:
+ with open(stash_file) as f:
+ return sum(1 for _ in f)
+ except IOError:
+ return 0
+
# `git status --porcelain --branch` can collect all information
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
@@ -68,6 +80,12 @@ for st in status:
elif st[0] != ' ':
staged.append(st)
+stashed = get_stash()
+if not changed and not staged and not conflicts and not untracked and not stashed:
+ clean = 1
+else:
+ clean = 0
+
out = ' '.join([
branch,
str(ahead),
@@ -76,5 +94,7 @@ out = ' '.join([
str(len(conflicts)),
str(len(changed)),
str(len(untracked)),
+ str(stashed),
+ str(clean)
])
print(out, end='')
diff --git a/plugins/git/README.md b/plugins/git/README.md
index 8642dd055..113080874 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -23,7 +23,7 @@ plugins=(... git)
| gb | git branch |
| gba | git branch -a |
| gbd | git branch -d |
-| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*(master\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d |
+| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch -d 2>/dev/null |
| gbD | git branch -D |
| gbl | git blame -b -w |
| gbnm | git branch --no-merged |
@@ -41,16 +41,20 @@ plugins=(... git)
| gcan! | git commit -v -a --no-edit --amend |
| gcans! | git commit -v -a -s --no-edit --amend |
| gcam | git commit -a -m |
+| gcas | git commit -a -s |
+| gcasm | git commit -a -s -m |
| gcsm | git commit -s -m |
| gcb | git checkout -b |
| gcf | git config --list |
| gcl | git clone --recurse-submodules |
+| gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" |
| gclean | git clean -id |
| gpristine | git reset --hard && git clean -dffx |
-| gcm | git checkout master |
-| gcd | git checkout develop |
+| gcm | git checkout $(git_main_branch) |
+| gcd | git checkout $(git_develop_branch) |
| gcmsg | git commit -m |
| gco | git checkout |
+| gcor | git checkout --recurse-submodules |
| gcount | git shortlog -sn |
| gcp | git cherry-pick |
| gcpa | git cherry-pick --abort |
@@ -63,6 +67,7 @@ plugins=(... git)
| gds | git diff --staged |
| gdt | git diff-tree --no-commit-id --name-only -r |
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)&ast;.lock" |
+| gdup | git diff @{upstream} |
| gdv | git diff -w $@ \| view - |
| gdw | git diff --word-diff |
| gf | git fetch |
@@ -85,9 +90,9 @@ plugins=(... git)
| ghh | git help |
| gignore | git update-index --assume-unchanged |
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
-| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk |
-| gk | gitk --all --branches |
-| gke | gitk --all $(git log -g --pretty=%h) |
+| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
+| gk | gitk --all --branches &! |
+| gke | gitk --all $(git log -g --pretty=%h) &! |
| gl | git pull |
| glg | git log --stat |
| glgp | git log --stat -p |
@@ -95,25 +100,26 @@ plugins=(... git)
| glgga | git log --graph --decorate --all |
| glgm | git log --graph --max-count=10 |
| glo | git log --oneline --decorate |
-| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' |
-| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat |
+| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' |
+| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat |
| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' |
| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short |
-| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all |
+| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all |
| glog | git log --oneline --decorate --graph |
| gloga | git log --oneline --decorate --graph --all |
-| glp | git log --pretty=\<format\> |
+| glp | git log --pretty=\<format\> |
| gm | git merge |
-| gmom | git merge origin/master |
-| gmt | git mergetool --no-prompt |
-| gmtvim | git mergetool --no-prompt --tool=vimdiff |
-| gmum | git merge upstream/master |
+| gmom | git merge origin/$(git_main_branch) |
+| gmtl | git mergetool --no-prompt |
+| gmtlvim | git mergetool --no-prompt --tool=vimdiff |
+| gmum | git merge upstream/$(git_main_branch) |
| gma | git merge --abort |
| gp | git push |
| gpd | git push --dry-run |
| gpf | git push --force-with-lease |
| gpf! | git push --force |
| gpoat | git push origin --all && git push origin --tags |
+| gpr | git pull --rebase |
| gpu | git push upstream |
| gpv | git push -v |
| gr | git remote |
@@ -121,9 +127,10 @@ plugins=(... git)
| grb | git rebase |
| grba | git rebase --abort |
| grbc | git rebase --continue |
-| grbd | git rebase develop |
+| grbd | git rebase $(git_develop_branch) |
| grbi | git rebase -i |
-| grbm | git rebase master |
+| grbm | git rebase $(git_main_branch) |
+| grbo | git rebase --onto |
| grbs | git rebase --skip |
| grev | git revert |
| grh | git reset |
@@ -136,6 +143,7 @@ plugins=(... git)
| grs | git restore |
| grset | git remote set-url |
| grss | git restore --source |
+| grst | git restore --staged |
| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" |
| gru | git reset -- |
| grup | git remote update |
@@ -161,6 +169,8 @@ plugins=(... git)
| gsu | git submodule update |
| gsw | git switch |
| gswc | git switch -c |
+| gswm | git switch $(git_main_branch) |
+| gswd | git switch $(git_develop_branch) |
| gts | git tag -s |
| gtv | git tag \| sort -V |
| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
@@ -170,7 +180,7 @@ plugins=(... git)
| gupv | git pull --rebase -v |
| gupa | git pull --rebase --autostash |
| gupav | git pull --rebase --autostash -v |
-| glum | git pull upstream master |
+| glum | git pull upstream $(git_main_branch) |
| gwch | git whatchanged -p --abbrev-commit --pretty=medium |
| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" |
| gam | git am |
@@ -179,6 +189,13 @@ plugins=(... git)
| gama | git am --abort |
| gamscp | git am --show-current-patch |
+### Main branch preference
+
+Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using
+a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means
+that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the
+function `git_main_branch`.
+
### Deprecated aliases
These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
@@ -201,12 +218,14 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
### Current
-| Command | Description |
-|:-----------------------|:---------------------------------------------------------|
-| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
-| current_branch | Return the name of the current branch |
-| git_current_user_name | Returns the `user.name` config value |
-| git_current_user_email | Returns the `user.email` config value |
+| Command | Description |
+|:-----------------------|:---------------------------------------------------------------------------------------------------------|
+| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
+| current_branch | Return the name of the current branch |
+| git_current_user_name | Returns the `user.name` config value |
+| git_current_user_email | Returns the `user.email` config value |
+| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
+| git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
### Work in Progress (WIP)
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 1112421bf..5a3c98287 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -1,3 +1,7 @@
+# Git version checking
+autoload -Uz is-at-least
+git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
+
#
# Functions
#
@@ -25,6 +29,32 @@ function work_in_progress() {
fi
}
+# Check if main exists and use instead of master
+function git_main_branch() {
+ command git rev-parse --git-dir &>/dev/null || return
+ local ref
+ for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk}; do
+ if command git show-ref -q --verify $ref; then
+ echo ${ref:t}
+ return
+ fi
+ done
+ echo master
+}
+
+# Check for develop and similarly named branches
+function git_develop_branch() {
+ command git rev-parse --git-dir &>/dev/null || return
+ local branch
+ for branch in dev devel development; do
+ if command git show-ref -q --verify refs/heads/$branch; then
+ echo $branch
+ return
+ fi
+ done
+ echo develop
+}
+
#
# Aliases
# (sorted alphabetically)
@@ -43,7 +73,7 @@ alias gapt='git apply --3way'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -d'
-alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
+alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch -d 2>/dev/null'
alias gbD='git branch -D'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
@@ -63,20 +93,32 @@ alias gcan!='git commit -v -a --no-edit --amend'
alias gcans!='git commit -v -a -s --no-edit --amend'
alias gcam='git commit -a -m'
alias gcsm='git commit -s -m'
+alias gcas='git commit -a -s'
+alias gcasm='git commit -a -s -m'
alias gcb='git checkout -b'
alias gcf='git config --list'
+
+function gccd() {
+ command git clone --recurse-submodules "$@"
+ [[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
+}
+compdef _git gccd=git-clone
+
alias gcl='git clone --recurse-submodules'
alias gclean='git clean -id'
alias gpristine='git reset --hard && git clean -dffx'
-alias gcm='git checkout master'
-alias gcd='git checkout develop'
+alias gcm='git checkout $(git_main_branch)'
+alias gcd='git checkout $(git_develop_branch)'
alias gcmsg='git commit -m'
alias gco='git checkout'
+alias gcor='git checkout --recurse-submodules'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcs='git commit -S'
+alias gcss='git commit -S -s'
+alias gcssm='git commit -S -s -m'
alias gd='git diff'
alias gdca='git diff --cached'
@@ -84,6 +126,7 @@ alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
+alias gdup='git diff @{upstream}'
alias gdw='git diff --word-diff'
function gdnolock() {
@@ -95,7 +138,10 @@ function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gf='git fetch'
-alias gfa='git fetch --all --prune'
+# --jobs=<n> was added in git 2.8
+is-at-least 2.8 "$git_version" \
+ && alias gfa='git fetch --all --prune --jobs=10' \
+ || alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gfg='git ls-files | grep'
@@ -160,10 +206,10 @@ alias ghh='git help'
alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
-alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
+alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
-alias gk='\gitk --all --branches'
-alias gke='\gitk --all $(git log -g --pretty=%h)'
+alias gk='\gitk --all --branches &!'
+alias gke='\gitk --all $(git log -g --pretty=%h) &!'
alias gl='git pull'
alias glg='git log --stat'
@@ -172,20 +218,20 @@ alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate'
-alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
-alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
+alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'"
+alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat"
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
-alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"
+alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all"
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily"
alias gm='git merge'
-alias gmom='git merge origin/master'
-alias gmt='git mergetool --no-prompt'
-alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
-alias gmum='git merge upstream/master'
+alias gmom='git merge origin/$(git_main_branch)'
+alias gmtl='git mergetool --no-prompt'
+alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
+alias gmum='git merge upstream/$(git_main_branch)'
alias gma='git merge --abort'
alias gp='git push'
@@ -193,6 +239,7 @@ alias gpd='git push --dry-run'
alias gpf='git push --force-with-lease'
alias gpf!='git push --force'
alias gpoat='git push origin --all && git push origin --tags'
+alias gpr='git pull --rebase'
alias gpu='git push upstream'
alias gpv='git push -v'
@@ -201,9 +248,10 @@ alias gra='git remote add'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
-alias grbd='git rebase develop'
+alias grbd='git rebase $(git_develop_branch)'
alias grbi='git rebase -i'
-alias grbm='git rebase master'
+alias grbm='git rebase $(git_main_branch)'
+alias grbo='git rebase --onto'
alias grbs='git rebase --skip'
alias grev='git revert'
alias grh='git reset'
@@ -216,6 +264,7 @@ alias grrm='git remote remove'
alias grs='git restore'
alias grset='git remote set-url'
alias grss='git restore --source'
+alias grst='git restore --staged'
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
alias gru='git reset --'
alias grup='git remote update'
@@ -231,8 +280,7 @@ alias gss='git status -s'
alias gst='git status'
# use the default stash push on git 2.13 and newer
-autoload -Uz is-at-least
-is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
+is-at-least 2.13 "$git_version" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
@@ -242,11 +290,13 @@ alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'
-alias gstu='git stash --include-untracked'
+alias gstu='gsta --include-untracked'
alias gstall='git stash --all'
alias gsu='git submodule update'
alias gsw='git switch'
alias gswc='git switch -c'
+alias gswm='git switch $(git_main_branch)'
+alias gswd='git switch $(git_develop_branch)'
alias gts='git tag -s'
alias gtv='git tag | sort -V'
@@ -258,7 +308,7 @@ alias gup='git pull --rebase'
alias gupv='git pull --rebase -v'
alias gupa='git pull --rebase --autostash'
alias gupav='git pull --rebase --autostash -v'
-alias glum='git pull upstream master'
+alias glum='git pull upstream $(git_main_branch)'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
@@ -282,3 +332,5 @@ function grename() {
git push --set-upstream origin "$2"
fi
}
+
+unset git_version
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
index 78a6dbb3d..988f5b1c6 100644
--- a/plugins/gitfast/_git
+++ b/plugins/gitfast/_git
@@ -2,25 +2,24 @@
# zsh completion wrapper for git
#
-# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
+# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
#
-# You need git's bash completion script installed somewhere, by default it
-# would be the location bash-completion uses.
+# The recommended way to install this script is to make a copy of it as a
+# file named '_git' inside any directory in your fpath.
#
-# If your script is somewhere else, you can configure it on your ~/.zshrc:
+# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
+# and then add the following to your ~/.zshrc file:
#
-# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
+# fpath=(~/.zsh $fpath)
#
-# The recommended way to install this script is to copy to '~/.zsh/_git', and
-# then add the following to your ~/.zshrc file:
+# You need git's bash completion script installed. By default bash-completion's
+# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
+#
+# If your bash completion script is somewhere else, you can specify the
+# location in your ~/.zshrc:
+#
+# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
#
-# fpath=(~/.zsh $fpath)
-
-complete ()
-{
- # do nothing
- return 0
-}
zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
@@ -28,18 +27,32 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle -s ":completion:*:*:git:*" script script
if [ -z "$script" ]; then
local -a locations
- local e
+ local e bash_completion
+
+ bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
+ bash_completion='/usr/share/bash-completion/completions/'
+
locations=(
- "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
- '/etc/bash_completion.d/git' # fedora, old debian
- '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
- '/usr/share/bash-completion/git' # gentoo
+ "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
+ "$HOME/.local/share/bash-completion/completions/git"
+ "$bash_completion/git"
+ '/etc/bash_completion.d/git' # old debian
)
for e in $locations; do
test -f $e && script="$e" && break
done
fi
-ZSH_VERSION='' . "$script"
+
+local old_complete="$functions[complete]"
+functions[complete]=:
+COMP_WORDBREAKS=':'
+GIT_SOURCING_ZSH_COMPLETION=y . "$script"
+functions[complete]="$old_complete"
+
+__gitcompadd ()
+{
+ compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
+}
__gitcomp ()
{
@@ -47,59 +60,85 @@ __gitcomp ()
local cur_="${3-$cur}"
- case "$cur_" in
- --*=)
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- c="$c${4-}"
+ [[ "$cur_" == *= ]] && return
+
+ local c IFS=$' \t\n' sfx
+ for c in ${=1}; do
+ if [[ $c == "--" ]]; then
+ [[ "$cur_" == --no-* ]] && continue
+ __gitcompadd "--no-..."
+ break
+ fi
+
+ if [[ -z "${4-}" ]]; then
case $c in
- --*=*|*.) ;;
- *) c="$c " ;;
+ *=) c="${c%=}"; sfx="=" ;;
+ *.) sfx="" ;;
+ *) sfx=" " ;;
esac
- array+=("$c")
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
+ else
+ sfx="$4"
+ fi
+ __gitcompadd "$c" "${2-}" "$sfx" -q
+ done
}
-__gitcomp_direct ()
+__gitcomp_nl ()
{
emulate -L zsh
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -- ${=1} && _ret=0
+ IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
}
-__gitcomp_nl ()
+__gitcomp_file ()
{
emulate -L zsh
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+ compadd -f -p "${2-}" -- ${(f)1} && _ret=0
+}
+
+__gitcomp_direct ()
+{
+ __gitcomp_nl "$1" "" "" ""
+}
+
+__gitcomp_file_direct ()
+{
+ __gitcomp_file "$1" ""
}
__gitcomp_nl_append ()
{
- emulate -L zsh
+ __gitcomp_nl "$@"
+}
+
+__gitcomp_direct_append ()
+{
+ __gitcomp_direct "$@"
+}
- local IFS=$'\n'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+_git_zsh ()
+{
+ __gitcomp "v1.2"
}
-__gitcomp_file ()
+__git_complete_command ()
{
emulate -L zsh
- local IFS=$'\n'
compset -P '*[=:]'
- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
+
+ local command="$1"
+ local completion_func="_git_${command//-/_}"
+ if (( $+functions[$completion_func] )); then
+ emulate ksh -c $completion_func
+ return 0
+ elif emulate ksh -c "__git_support_parseopt_helper $command"; then
+ emulate ksh -c "__git_complete_common $command"
+ return 0
+ else
+ return 1
+ fi
}
__git_zsh_bash_func ()
@@ -108,14 +147,12 @@ __git_zsh_bash_func ()
local command=$1
- local completion_func="_git_${command//-/_}"
- declare -f $completion_func >/dev/null && $completion_func && return
+ __git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
- completion_func="_git_${expansion//-/_}"
- declare -f $completion_func >/dev/null && $completion_func
+ __git_complete_command "$expansion"
fi
}
@@ -140,9 +177,11 @@ __git_zsh_cmd_common ()
push:'update remote refs along with associated objects'
rebase:'forward-port local commits to the updated upstream head'
reset:'reset current HEAD to the specified state'
+ restore:'restore working tree files'
rm:'remove files from the working tree and from the index'
show:'show various types of objects'
status:'show the working tree status'
+ switch:'switch branches'
tag:'create, list, delete or verify a tag object signed with GPG')
_describe -t common-commands 'common commands' list && _ret=0
}
@@ -150,8 +189,9 @@ __git_zsh_cmd_common ()
__git_zsh_cmd_alias ()
{
local -a list
- list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
- _describe -t alias-commands 'aliases' list $* && _ret=0
+ list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.})
+ list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"})
+ _describe -t alias-commands 'aliases' list && _ret=0
}
__git_zsh_cmd_all ()
@@ -166,33 +206,43 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
- local -a orig_words
+ local -a orig_words __git_C_args
orig_words=( ${words[@]} )
_arguments -C \
- '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
- '(-p --paginate)--no-pager[do not pipe git output into a pager]' \
- '--git-dir=-[set the path to the repository]: :_directories' \
- '--bare[treat the repository as a bare repository]' \
+ '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
+ '(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \
+ '(--bare)--git-dir=[set the path to the repository]: :_directories' \
+ '(--git-dir)--bare[treat the repository as a bare repository]' \
'(- :)--version[prints the git suite version]' \
- '--exec-path=-[path to where your core git programs are installed]:: :_directories' \
- '--html-path[print the path where git''s HTML documentation is installed]' \
- '--info-path[print the path where the Info files are installed]' \
- '--man-path[print the manpath (see `man(1)`) for the man pages]' \
- '--work-tree=-[set the path to the working tree]: :_directories' \
- '--namespace=-[set the git namespace]' \
+ '--exec-path=[path to where your core git programs are installed]: :_directories' \
+ '(- :)--exec-path[print the path where your core git programs are installed]' \
+ '(- :)--html-path[print the path where git''s HTML documentation is installed]' \
+ '(- :)--info-path[print the path where the Info files are installed]' \
+ '(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \
+ '--work-tree=[set the path to the working tree]: :_directories' \
+ '--namespace=[set the git namespace]:' \
'--no-replace-objects[do not use replacement refs to replace git objects]' \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
+ '*-C[run as if git was started in the given path]: :_directories' \
+ '*-c[pass a configuration parameter to the command]: :->config' \
'(-): :->command' \
'(-)*:: :->arg' && return
case $state in
(command)
- _alternative \
- 'alias-commands:alias:__git_zsh_cmd_alias' \
- 'common-commands:common:__git_zsh_cmd_common' \
- 'all-commands:all:__git_zsh_cmd_all' && _ret=0
+ _tags common-commands alias-commands all-commands
+ while _tags; do
+ _requested common-commands && __git_zsh_cmd_common
+ _requested alias-commands && __git_zsh_cmd_alias
+ _requested all-commands && __git_zsh_cmd_all
+ let _ret || break
+ done
+ ;;
+ (config)
+ compset -P '*[=:]'
+ emulate ksh -c __git_complete_config_variable_name_and_value
;;
(arg)
local command="${words[1]}" __git_dir
@@ -200,9 +250,13 @@ __git_zsh_main ()
if (( $+opt_args[--bare] )); then
__git_dir='.'
else
- __git_dir=${opt_args[--git-dir]}
+ __git_dir=${~opt_args[--git-dir]}
fi
+ for x in ${(s.:.)opt_args[-C]}; do
+ __git_C_args+=('-C' ${~x})
+ done
+
(( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} )
@@ -227,6 +281,8 @@ _git ()
emulate ksh -c __${service}_main
elif (( $+functions[_${service}] )); then
emulate ksh -c _${service}
+ elif (( $+functions[_${service//-/_}] )); then
+ emulate ksh -c _${service//-/_}
fi
let _ret && _default && _ret=0
diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
index b6ff5dc08..4497a294f 100644
--- a/plugins/gitfast/git-completion.bash
+++ b/plugins/gitfast/git-completion.bash
@@ -29,25 +29,28 @@
# tell the completion to use commit completion. This also works with aliases
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
#
+# Compatible with bash 3.2.57.
+#
# You can set the following environment variables to influence the behavior of
# the completion routines:
#
# GIT_COMPLETION_CHECKOUT_NO_GUESS
#
# When set to "1", do not include "DWIM" suggestions in git-checkout
-# completion (e.g., completing "foo" when "origin/foo" exists).
-
-case "$COMP_WORDBREAKS" in
-*:*) : great ;;
-*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
-esac
+# and git-switch completion (e.g., completing "foo" when "origin/foo"
+# exists).
+#
+# GIT_COMPLETION_SHOW_ALL
+#
+# When set to "1" suggest all options, including options which are
+# typically hidden (e.g. '--allow-empty' for 'git commit').
# Discovers the path to the git repository taking any '--git-dir=<path>' and
# '-C <path>' options into account and stores it in the $__git_repo_path
# variable.
__git_find_repo_path ()
{
- if [ -n "$__git_repo_path" ]; then
+ if [ -n "${__git_repo_path-}" ]; then
# we already know where it is
return
fi
@@ -92,6 +95,70 @@ __git ()
${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
}
+# Removes backslash escaping, single quotes and double quotes from a word,
+# stores the result in the variable $dequoted_word.
+# 1: The word to dequote.
+__git_dequote ()
+{
+ local rest="$1" len ch
+
+ dequoted_word=""
+
+ while test -n "$rest"; do
+ len=${#dequoted_word}
+ dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
+ rest="${rest:$((${#dequoted_word}-$len))}"
+
+ case "${rest:0:1}" in
+ \\)
+ ch="${rest:1:1}"
+ case "$ch" in
+ $'\n')
+ ;;
+ *)
+ dequoted_word="$dequoted_word$ch"
+ ;;
+ esac
+ rest="${rest:2}"
+ ;;
+ \')
+ rest="${rest:1}"
+ len=${#dequoted_word}
+ dequoted_word="$dequoted_word${rest%%\'*}"
+ rest="${rest:$((${#dequoted_word}-$len+1))}"
+ ;;
+ \")
+ rest="${rest:1}"
+ while test -n "$rest" ; do
+ len=${#dequoted_word}
+ dequoted_word="$dequoted_word${rest%%[\\\"]*}"
+ rest="${rest:$((${#dequoted_word}-$len))}"
+ case "${rest:0:1}" in
+ \\)
+ ch="${rest:1:1}"
+ case "$ch" in
+ \"|\\|\$|\`)
+ dequoted_word="$dequoted_word$ch"
+ ;;
+ $'\n')
+ ;;
+ *)
+ dequoted_word="$dequoted_word\\$ch"
+ ;;
+ esac
+ rest="${rest:2}"
+ ;;
+ \")
+ rest="${rest:1}"
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+ done
+}
+
# The following function is based on code from:
#
# bash_completion - programmable completion functions for bash 3.2+
@@ -234,6 +301,19 @@ __gitcomp_direct ()
COMPREPLY=($1)
}
+# Similar to __gitcomp_direct, but appends to COMPREPLY instead.
+# Callers must take care of providing only words that match the current word
+# to be completed and adding any prefix and/or suffix (trailing space!), if
+# necessary.
+# 1: List of newline-separated matching completion words, complete with
+# prefix and suffix.
+__gitcomp_direct_append ()
+{
+ local IFS=$'\n'
+
+ COMPREPLY+=($1)
+}
+
__gitcompappend ()
{
local x i=${#COMPREPLY[@]}
@@ -262,15 +342,38 @@ __gitcomp ()
local cur_="${3-$cur}"
case "$cur_" in
- --*=)
+ *=)
+ ;;
+ --no-*)
+ local c i=0 IFS=$' \t\n'
+ for c in $1; do
+ if [[ $c == "--" ]]; then
+ continue
+ fi
+ c="$c${4-}"
+ if [[ $c == "$cur_"* ]]; then
+ case $c in
+ --*=|*.) ;;
+ *) c="$c " ;;
+ esac
+ COMPREPLY[i++]="${2-}$c"
+ fi
+ done
;;
*)
local c i=0 IFS=$' \t\n'
for c in $1; do
+ if [[ $c == "--" ]]; then
+ c="--no-...${4-}"
+ if [[ $c == "$cur_"* ]]; then
+ COMPREPLY[i++]="${2-}$c "
+ fi
+ break
+ fi
c="$c${4-}"
if [[ $c == "$cur_"* ]]; then
case $c in
- --*=*|*.) ;;
+ *=|*.) ;;
*) c="$c " ;;
esac
COMPREPLY[i++]="${2-}$c"
@@ -280,6 +383,163 @@ __gitcomp ()
esac
}
+# Clear the variables caching builtins' options when (re-)sourcing
+# the completion script.
+if [[ -n ${ZSH_VERSION-} ]]; then
+ unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null
+else
+ unset $(compgen -v __gitcomp_builtin_)
+fi
+
+__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign"
+__gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --inaccurate-eof --recount --directory= --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-inaccurate-eof --no-recount --no-directory"
+__gitcomp_builtin_archive_default=" --output= --remote= --exec= --no-output -- --no-remote --no-exec"
+__gitcomp_builtin_bisect__helper_default=" --next-all --write-terms --bisect-clean-state --check-expected-revs --bisect-reset --bisect-write --check-and-set-terms --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-auto-next --bisect-autostart --no-log --log"
+__gitcomp_builtin_blame_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
+__gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-points-at --no-ignore-case --no-format"
+__gitcomp_builtin_bugreport_default=" --output-directory= --suffix= --no-output-directory -- --no-suffix"
+__gitcomp_builtin_cat_file_default=" --textconv --filters --path= --allow-unknown-type --buffer --batch --batch-check --follow-symlinks --batch-all-objects --unordered --no-path -- --no-allow-unknown-type --no-buffer --no-follow-symlinks --no-batch-all-objects --no-unordered"
+__gitcomp_builtin_check_attr_default=" --all --cached --stdin --no-all -- --no-cached --no-stdin"
+__gitcomp_builtin_check_ignore_default=" --quiet --verbose --stdin --non-matching --no-index --index -- --no-quiet --no-verbose --no-stdin --no-non-matching"
+__gitcomp_builtin_check_mailmap_default=" --stdin --no-stdin"
+__gitcomp_builtin_checkout_default=" --guess --overlay --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-guess -- --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_checkout_index_default=" --all --force --quiet --no-create --index --stdin --temp --prefix= --stage= --create -- --no-all --no-force --no-quiet --no-index --no-stdin --no-temp --no-prefix"
+__gitcomp_builtin_cherry_default=" --abbrev --verbose --no-abbrev -- --no-verbose"
+__gitcomp_builtin_cherry_pick_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --ff --allow-empty --allow-empty-message --keep-redundant-commits --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign --no-ff --no-allow-empty --no-allow-empty-message --no-keep-redundant-commits"
+__gitcomp_builtin_clean_default=" --quiet --dry-run --interactive --exclude= --no-quiet -- --no-dry-run --no-interactive"
+__gitcomp_builtin_clone_default=" --verbose --quiet --progress --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --recursive --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse"
+__gitcomp_builtin_column_default=" --command= --mode --raw-mode= --width= --indent= --nl= --padding= --no-command -- --no-mode --no-raw-mode --no-width --no-indent --no-nl --no-padding"
+__gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_commit_graph_default=" --object-dir= --no-object-dir"
+__gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default"
+__gitcomp_builtin_count_objects_default=" --verbose --human-readable --no-verbose -- --no-human-readable"
+__gitcomp_builtin_credential_cache_default=" --timeout= --socket= --no-timeout -- --no-socket"
+__gitcomp_builtin_credential_cache__daemon_default=" --debug --no-debug"
+__gitcomp_builtin_credential_store_default=" --file= --no-file"
+__gitcomp_builtin_describe_default=" --contains --debug --all --tags --long --first-parent --abbrev --exact-match --candidates= --match= --exclude= --always --dirty --broken --no-contains -- --no-debug --no-all --no-tags --no-long --no-first-parent --no-abbrev --no-exact-match --no-candidates --no-match --no-exclude --no-always --no-dirty --no-broken"
+__gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd"
+__gitcomp_builtin_env__helper_default=" --type= --default= --exit-code --no-default -- --no-exit-code"
+__gitcomp_builtin_fast_export_default=" --progress= --signed-tags= --tag-of-filtered-object= --reencode= --export-marks= --import-marks= --import-marks-if-exists= --fake-missing-tagger --full-tree --use-done-feature --no-data --refspec= --anonymize --anonymize-map= --reference-excluded-parents --show-original-ids --mark-tags --data -- --no-progress --no-signed-tags --no-tag-of-filtered-object --no-reencode --no-export-marks --no-import-marks --no-import-marks-if-exists --no-fake-missing-tagger --no-full-tree --no-use-done-feature --no-refspec --no-anonymize --no-reference-excluded-parents --no-show-original-ids --no-mark-tags"
+__gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --upload-pack= --force --multiple --tags --jobs= --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin"
+__gitcomp_builtin_fmt_merge_msg_default=" --log --message= --file= --no-log -- --no-message --no-file"
+__gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-points-at --no-ignore-case"
+__gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
+__gitcomp_builtin_fsck_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
+__gitcomp_builtin_fsck_objects_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
+__gitcomp_builtin_gc_default=" --quiet --prune --aggressive --keep-largest-pack --no-quiet -- --no-prune --no-aggressive --no-keep-largest-pack"
+__gitcomp_builtin_grep_default=" --cached --no-index --untracked --exclude-standard --recurse-submodules --invert-match --ignore-case --word-regexp --text --textconv --recursive --max-depth= --extended-regexp --basic-regexp --fixed-strings --perl-regexp --line-number --column --full-name --files-with-matches --name-only --files-without-match --only-matching --count --color --break --heading --context= --before-context= --after-context= --threads= --show-function --function-context --and --or --not --quiet --all-match --index -- --no-cached --no-untracked --no-exclude-standard --no-recurse-submodules --no-invert-match --no-ignore-case --no-word-regexp --no-text --no-textconv --no-recursive --no-extended-regexp --no-basic-regexp --no-fixed-strings --no-perl-regexp --no-line-number --no-column --no-full-name --no-files-with-matches --no-name-only --no-files-without-match --no-only-matching --no-count --no-color --no-break --no-heading --no-context --no-before-context --no-after-context --no-threads --no-show-function --no-function-context --no-or --no-quiet --no-all-match"
+__gitcomp_builtin_hash_object_default=" --stdin --stdin-paths --no-filters --literally --path= --filters -- --no-stdin --no-stdin-paths --no-literally --no-path"
+__gitcomp_builtin_help_default=" --all --guides --config --man --web --info --verbose --no-all -- --no-guides --no-config --no-man --no-web --no-info --no-verbose"
+__gitcomp_builtin_init_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
+__gitcomp_builtin_init_db_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
+__gitcomp_builtin_interpret_trailers_default=" --in-place --trim-empty --where= --if-exists= --if-missing= --only-trailers --only-input --unfold --parse --no-divider --trailer= --divider -- --no-in-place --no-trim-empty --no-where --no-if-exists --no-if-missing --no-only-trailers --no-only-input --no-unfold --no-trailer"
+__gitcomp_builtin_log_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug"
+__gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-symref --no-server-option"
+__gitcomp_builtin_ls_tree_default=" --long --name-only --name-status --full-name --full-tree --abbrev --no-long -- --no-name-only --no-name-status --no-full-name --no-full-tree --no-abbrev"
+__gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff"
+__gitcomp_builtin_merge_base_default=" --all --octopus --independent --is-ancestor --fork-point --no-all"
+__gitcomp_builtin_merge_file_default=" --stdout --diff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet"
+__gitcomp_builtin_mktree_default=" --missing --batch --no-missing -- --no-batch"
+__gitcomp_builtin_multi_pack_index_default=" --object-dir= --progress --batch-size= --no-object-dir -- --no-progress"
+__gitcomp_builtin_mv_default=" --verbose --dry-run --no-verbose -- --no-dry-run"
+__gitcomp_builtin_name_rev_default=" --name-only --tags --refs= --exclude= --all --stdin --undefined --always --no-name-only -- --no-tags --no-refs --no-exclude --no-all --no-stdin --no-undefined --no-always"
+__gitcomp_builtin_notes_default=" --ref= --no-ref"
+__gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol"
+__gitcomp_builtin_pack_refs_default=" --all --prune --no-all -- --no-prune"
+__gitcomp_builtin_pickaxe_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
+__gitcomp_builtin_prune_default=" --dry-run --verbose --progress --expire= --exclude-promisor-objects --no-dry-run -- --no-verbose --no-progress --no-expire --no-exclude-promisor-objects"
+__gitcomp_builtin_prune_packed_default=" --dry-run --quiet --no-dry-run -- --no-quiet"
+__gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream"
+__gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6"
+__gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv"
+__gitcomp_builtin_read_tree_default=" --index-output= --empty --verbose --trivial --aggressive --reset --prefix= --exclude-per-directory= --dry-run --no-sparse-checkout --debug-unpack --recurse-submodules --quiet --sparse-checkout -- --no-empty --no-verbose --no-trivial --no-aggressive --no-reset --no-dry-run --no-debug-unpack --no-recurse-submodules --no-quiet"
+__gitcomp_builtin_rebase_default=" --onto= --keep-base --no-verify --quiet --verbose --no-stat --signoff --committer-date-is-author-date --reset-author-date --ignore-whitespace --whitespace= --force-rebase --no-ff --continue --skip --abort --quit --edit-todo --show-current-patch --apply --merge --interactive --rerere-autoupdate --empty= --autosquash --gpg-sign --autostash --exec= --rebase-merges --fork-point --strategy= --strategy-option= --root --reschedule-failed-exec --reapply-cherry-picks --verify --stat --ff -- --no-onto --no-keep-base --no-quiet --no-verbose --no-signoff --no-committer-date-is-author-date --no-reset-author-date --no-ignore-whitespace --no-whitespace --no-force-rebase --no-rerere-autoupdate --no-autosquash --no-gpg-sign --no-autostash --no-exec --no-rebase-merges --no-fork-point --no-strategy --no-strategy-option --no-root --no-reschedule-failed-exec --no-reapply-cherry-picks"
+__gitcomp_builtin_rebase__interactive_default=" --ff --rebase-merges --rebase-cousins --autosquash --signoff --verbose --continue --skip --edit-todo --show-current-patch --shorten-ids --expand-ids --check-todo-list --rearrange-squash --add-exec-commands --onto= --restrict-revision= --squash-onto= --upstream= --head-name= --gpg-sign --strategy= --strategy-opts= --switch-to= --onto-name= --cmd= --rerere-autoupdate --reschedule-failed-exec --no-ff -- --no-rebase-merges --no-rebase-cousins --no-autosquash --no-signoff --no-verbose --no-head-name --no-gpg-sign --no-strategy --no-strategy-opts --no-switch-to --no-onto-name --no-cmd --no-rerere-autoupdate --no-reschedule-failed-exec"
+__gitcomp_builtin_receive_pack_default=" --quiet --no-quiet"
+__gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_remote_default=" --verbose --no-verbose"
+__gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack"
+__gitcomp_builtin_replace_default=" --list --delete --edit --graft --convert-graft-file --raw --format= --no-raw -- --no-format"
+__gitcomp_builtin_rerere_default=" --rerere-autoupdate --no-rerere-autoupdate"
+__gitcomp_builtin_reset_default=" --quiet --mixed --soft --hard --merge --keep --recurse-submodules --patch --intent-to-add --pathspec-from-file= --pathspec-file-nul --no-quiet -- --no-mixed --no-soft --no-hard --no-merge --no-keep --no-recurse-submodules --no-patch --no-intent-to-add --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_restore_default=" --source= --staged --worktree --ignore-unmerged --overlay --quiet --recurse-submodules --progress --merge --conflict= --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-source -- --no-staged --no-worktree --no-ignore-unmerged --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_revert_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign"
+__gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease"
+__gitcomp_builtin_shortlog_default=" --committer --numbered --summary --email --group= --no-committer -- --no-numbered --no-summary --no-email --no-group"
+__gitcomp_builtin_show_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_show_branch_default=" --all --remotes --color --more --list --no-name --current --sha1-name --merge-base --independent --topo-order --topics --sparse --date-order --reflog --name -- --no-all --no-remotes --no-color --no-more --no-list --no-current --no-sha1-name --no-merge-base --no-independent --no-topo-order --no-topics --no-sparse --no-date-order"
+__gitcomp_builtin_show_index_default=" --object-format= --no-object-format"
+__gitcomp_builtin_show_ref_default=" --tags --heads --verify --head --dereference --hash --abbrev --quiet --exclude-existing --no-tags -- --no-heads --no-verify --no-head --no-dereference --no-hash --no-abbrev --no-quiet"
+__gitcomp_builtin_sparse_checkout_default=""
+__gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_stash_default=""
+__gitcomp_builtin_status_default=" --verbose --short --branch --show-stash --ahead-behind --porcelain --long --null --untracked-files --ignored --ignore-submodules --column --no-renames --find-renames --renames -- --no-verbose --no-short --no-branch --no-show-stash --no-ahead-behind --no-porcelain --no-long --no-null --no-untracked-files --no-ignored --no-ignore-submodules --no-column"
+__gitcomp_builtin_stripspace_default=" --strip-comments --comment-lines"
+__gitcomp_builtin_switch_default=" --create= --force-create= --guess --discard-changes --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --no-create -- --no-force-create --no-guess --no-discard-changes --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees"
+__gitcomp_builtin_symbolic_ref_default=" --quiet --delete --short --no-quiet -- --no-delete --no-short"
+__gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-points-at --no-format --no-color --no-ignore-case"
+__gitcomp_builtin_update_index_default=" --ignore-submodules --add --replace --remove --unmerged --refresh --really-refresh --cacheinfo --chmod= --assume-unchanged --no-assume-unchanged --skip-worktree --no-skip-worktree --ignore-skip-worktree-entries --info-only --force-remove --stdin --index-info --unresolve --again --ignore-missing --verbose --clear-resolve-undo --index-version= --split-index --untracked-cache --test-untracked-cache --force-untracked-cache --force-write-index --fsmonitor --fsmonitor-valid --no-fsmonitor-valid -- --no-ignore-submodules --no-add --no-replace --no-remove --no-unmerged --no-ignore-skip-worktree-entries --no-info-only --no-force-remove --no-ignore-missing --no-verbose --no-index-version --no-split-index --no-untracked-cache --no-test-untracked-cache --no-force-untracked-cache --no-force-write-index --no-fsmonitor"
+__gitcomp_builtin_update_ref_default=" --no-deref --stdin --create-reflog --deref -- --no-stdin --no-create-reflog"
+__gitcomp_builtin_update_server_info_default=" --force --no-force"
+__gitcomp_builtin_upload_pack_default=" --stateless-rpc --advertise-refs --strict --timeout= --no-stateless-rpc -- --no-advertise-refs --no-strict --no-timeout"
+__gitcomp_builtin_verify_commit_default=" --verbose --raw --no-verbose -- --no-raw"
+__gitcomp_builtin_verify_pack_default=" --verbose --stat-only --object-format= --no-verbose -- --no-stat-only --no-object-format"
+__gitcomp_builtin_verify_tag_default=" --verbose --raw --format= --no-verbose -- --no-raw --no-format"
+__gitcomp_builtin_version_default=" --build-options --no-build-options"
+__gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_write_tree_default=" --missing-ok --prefix= --no-missing-ok -- --no-prefix"
+__gitcomp_builtin_send_email_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
+
+__gitcomp_builtin_get_default ()
+{
+ eval "test -n \"\$${1}_default\" && echo \"\$${1}_default\""
+}
+
+# This function is equivalent to
+#
+# __gitcomp "$(git xxx --git-completion-helper) ..."
+#
+# except that the output is cached. Accept 1-3 arguments:
+# 1: the git command to execute, this is also the cache key
+# 2: extra options to be added on top (e.g. negative forms)
+# 3: options to be excluded
+__gitcomp_builtin ()
+{
+ # spaces must be replaced with underscore for multi-word
+ # commands, e.g. "git remote add" becomes remote_add.
+ local cmd="$1"
+ local incl="${2-}"
+ local excl="${3-}"
+
+ local var=__gitcomp_builtin_"${cmd//-/_}"
+ local options
+ eval "options=\${$var-}"
+
+ if [ -z "$options" ]; then
+ local completion_helper
+ if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
+ completion_helper="--git-completion-helper-all"
+ else
+ completion_helper="--git-completion-helper"
+ fi
+ completion="$(__git ${cmd/_/ } $completion_helper ||
+ __gitcomp_builtin_get_default $var)" || return
+ # leading and trailing spaces are significant to make
+ # option removal work correctly.
+ options=" $incl $completion "
+
+ for i in $excl; do
+ options="${options/ $i / }"
+ done
+ eval "$var=\"$options\""
+ fi
+
+ __gitcomp "$options"
+}
+
# Variation of __gitcomp_nl () that appends to the existing list of
# completion candidates, COMPREPLY.
__gitcomp_nl_append ()
@@ -303,6 +563,24 @@ __gitcomp_nl ()
__gitcomp_nl_append "$@"
}
+# Fills the COMPREPLY array with prefiltered paths without any additional
+# processing.
+# Callers must take care of providing only paths that match the current path
+# to be completed and adding any prefix path components, if necessary.
+# 1: List of newline-separated matching paths, complete with all prefix
+# path components.
+__gitcomp_file_direct ()
+{
+ local IFS=$'\n'
+
+ COMPREPLY=($1)
+
+ # use a hack to enable file mode in bash < 4
+ compopt -o filenames +o nospace 2>/dev/null ||
+ compgen -f /non-existing-dir/ >/dev/null ||
+ true
+}
+
# Generates completion reply with compgen from newline-separated possible
# completion filenames.
# It accepts 1 to 3 arguments:
@@ -322,7 +600,8 @@ __gitcomp_file ()
# use a hack to enable file mode in bash < 4
compopt -o filenames +o nospace 2>/dev/null ||
- compgen -f /non-existing-dir/ > /dev/null
+ compgen -f /non-existing-dir/ >/dev/null ||
+ true
}
# Execute 'git ls-files', unless the --committable option is specified, in
@@ -332,10 +611,12 @@ __gitcomp_file ()
__git_ls_files_helper ()
{
if [ "$2" == "--committable" ]; then
- __git -C "$1" diff-index --name-only --relative HEAD
+ __git -C "$1" -c core.quotePath=false diff-index \
+ --name-only --relative HEAD -- "${3//\\/\\\\}*"
else
# NOTE: $2 is not quoted in order to support multiple options
- __git -C "$1" ls-files --exclude-standard $2
+ __git -C "$1" -c core.quotePath=false ls-files \
+ --exclude-standard $2 -- "${3//\\/\\\\}*"
fi
}
@@ -346,17 +627,103 @@ __git_ls_files_helper ()
# If provided, only files within the specified directory are listed.
# Sub directories are never recursed. Path must have a trailing
# slash.
+# 3: List only paths matching this path component (optional).
__git_index_files ()
{
- local root="${2-.}" file
+ local root="$2" match="$3"
- __git_ls_files_helper "$root" "$1" |
- while read -r file; do
- case "$file" in
- ?*/*) echo "${file%%/*}" ;;
- *) echo "$file" ;;
- esac
- done | sort | uniq
+ __git_ls_files_helper "$root" "$1" "${match:-?}" |
+ awk -F / -v pfx="${2//\\/\\\\}" '{
+ paths[$1] = 1
+ }
+ END {
+ for (p in paths) {
+ if (substr(p, 1, 1) != "\"") {
+ # No special characters, easy!
+ print pfx p
+ continue
+ }
+
+ # The path is quoted.
+ p = dequote(p)
+ if (p == "")
+ continue
+
+ # Even when a directory name itself does not contain
+ # any special characters, it will still be quoted if
+ # any of its (stripped) trailing path components do.
+ # Because of this we may have seen the same directory
+ # both quoted and unquoted.
+ if (p in paths)
+ # We have seen the same directory unquoted,
+ # skip it.
+ continue
+ else
+ print pfx p
+ }
+ }
+ function dequote(p, bs_idx, out, esc, esc_idx, dec) {
+ # Skip opening double quote.
+ p = substr(p, 2)
+
+ # Interpret backslash escape sequences.
+ while ((bs_idx = index(p, "\\")) != 0) {
+ out = out substr(p, 1, bs_idx - 1)
+ esc = substr(p, bs_idx + 1, 1)
+ p = substr(p, bs_idx + 2)
+
+ if ((esc_idx = index("abtvfr\"\\", esc)) != 0) {
+ # C-style one-character escape sequence.
+ out = out substr("\a\b\t\v\f\r\"\\",
+ esc_idx, 1)
+ } else if (esc == "n") {
+ # Uh-oh, a newline character.
+ # We cannot reliably put a pathname
+ # containing a newline into COMPREPLY,
+ # and the newline would create a mess.
+ # Skip this path.
+ return ""
+ } else {
+ # Must be a \nnn octal value, then.
+ dec = esc * 64 + \
+ substr(p, 1, 1) * 8 + \
+ substr(p, 2, 1)
+ out = out sprintf("%c", dec)
+ p = substr(p, 3)
+ }
+ }
+ # Drop closing double quote, if there is one.
+ # (There is not any if this is a directory, as it was
+ # already stripped with the trailing path components.)
+ if (substr(p, length(p), 1) == "\"")
+ out = out substr(p, 1, length(p) - 1)
+ else
+ out = out p
+
+ return out
+ }'
+}
+
+# __git_complete_index_file requires 1 argument:
+# 1: the options to pass to ls-file
+#
+# The exception is --committable, which finds the files appropriate commit.
+__git_complete_index_file ()
+{
+ local dequoted_word pfx="" cur_
+
+ __git_dequote "$cur"
+
+ case "$dequoted_word" in
+ ?*/*)
+ pfx="${dequoted_word%/*}/"
+ cur_="${dequoted_word##*/}"
+ ;;
+ *)
+ cur_="$dequoted_word"
+ esac
+
+ __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")"
}
# Lists branches from the local repository.
@@ -372,6 +739,19 @@ __git_heads ()
"refs/heads/$cur_*" "refs/heads/$cur_*/**"
}
+# Lists branches from remote repositories.
+# 1: A prefix to be added to each listed branch (optional).
+# 2: List only branches matching this word (optional; list all branches if
+# unset or empty).
+# 3: A suffix to be appended to each listed branch (optional).
+__git_remote_heads ()
+{
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
+ "refs/remotes/$cur_*" "refs/remotes/$cur_*/**"
+}
+
# Lists tags from the local repository.
# Accepts the same positional parameters as __git_heads() above.
__git_tags ()
@@ -382,6 +762,26 @@ __git_tags ()
"refs/tags/$cur_*" "refs/tags/$cur_*/**"
}
+# List unique branches from refs/remotes used for 'git checkout' and 'git
+# switch' tracking DWIMery.
+# 1: A prefix to be added to each listed branch (optional)
+# 2: List only branches matching this word (optional; list all branches if
+# unset or empty).
+# 3: A suffix to be appended to each listed branch (optional).
+__git_dwim_remote_heads ()
+{
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+ local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
+
+ # employ the heuristic used by git checkout and git switch
+ # Try to find a remote branch that cur_es the completion word
+ # but only output if the branch name is unique
+ __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
+ --sort="refname:strip=3" \
+ "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \
+ uniq -u
+}
+
# Lists refs from the local (by default) or from a remote repository.
# It accepts 0, 1 or 2 arguments:
# 1: The remote to list refs from (optional; ignored, if set but empty).
@@ -439,7 +839,7 @@ __git_refs ()
track=""
;;
*)
- for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
+ for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
case "$i" in
$match*)
if [ -e "$dir/$i" ]; then
@@ -457,13 +857,7 @@ __git_refs ()
__git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \
"${refs[@]}"
if [ -n "$track" ]; then
- # employ the heuristic used by git checkout
- # Try to find a remote branch that matches the completion word
- # but only output if the branch name is unique
- __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
- --sort="refname:strip=3" \
- "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \
- uniq -u
+ __git_dwim_remote_heads "$pfx" "$match" "$sfx"
fi
return
fi
@@ -510,29 +904,51 @@ __git_refs ()
# Usage: __git_complete_refs [<option>]...
# --remote=<remote>: The remote to list refs from, can be the name of a
# configured remote, a path, or a URL.
-# --track: List unique remote branches for 'git checkout's tracking DWIMery.
+# --dwim: List unique remote branches for 'git switch's tracking DWIMery.
# --pfx=<prefix>: A prefix to be added to each ref.
# --cur=<word>: The current ref to be completed. Defaults to the current
# word to be completed.
# --sfx=<suffix>: A suffix to be appended to each ref instead of the default
# space.
+# --mode=<mode>: What set of refs to complete, one of 'refs' (the default) to
+# complete all refs, 'heads' to complete only branches, or
+# 'remote-heads' to complete only remote branches. Note that
+# --remote is only compatible with --mode=refs.
__git_complete_refs ()
{
- local remote track pfx cur_="$cur" sfx=" "
+ local remote= dwim= pfx= cur_="$cur" sfx=" " mode="refs"
while test $# != 0; do
case "$1" in
--remote=*) remote="${1##--remote=}" ;;
- --track) track="yes" ;;
+ --dwim) dwim="yes" ;;
+ # --track is an old spelling of --dwim
+ --track) dwim="yes" ;;
--pfx=*) pfx="${1##--pfx=}" ;;
--cur=*) cur_="${1##--cur=}" ;;
--sfx=*) sfx="${1##--sfx=}" ;;
+ --mode=*) mode="${1##--mode=}" ;;
*) return 1 ;;
esac
shift
done
- __gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
+ # complete references based on the specified mode
+ case "$mode" in
+ refs)
+ __gitcomp_direct "$(__git_refs "$remote" "" "$pfx" "$cur_" "$sfx")" ;;
+ heads)
+ __gitcomp_direct "$(__git_heads "$pfx" "$cur_" "$sfx")" ;;
+ remote-heads)
+ __gitcomp_direct "$(__git_remote_heads "$pfx" "$cur_" "$sfx")" ;;
+ *)
+ return 1 ;;
+ esac
+
+ # Append DWIM remote branch names if requested
+ if [ "$dwim" = "yes" ]; then
+ __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
+ fi
}
# __git_refs2 requires 1 argument (to pass to __git_refs)
@@ -594,7 +1010,7 @@ __git_is_configured_remote ()
__git_list_merge_strategies ()
{
- git merge -s help 2>&1 |
+ LANG=C LC_ALL=C git merge -s help 2>&1 |
sed -n -e '/[Aa]vailable strategies are: /,/^$/{
s/\.$//
s/.*://
@@ -604,6 +1020,7 @@ __git_list_merge_strategies ()
}'
}
+__git_merge_strategies_default='octopus ours recursive resolve subtree'
__git_merge_strategies=
# 'git merge -s help' (and thus detection of the merge strategy
# list) fails, unfortunately, if run outside of any git working
@@ -613,12 +1030,18 @@ __git_merge_strategies=
__git_compute_merge_strategies ()
{
test -n "$__git_merge_strategies" ||
- __git_merge_strategies=$(__git_list_merge_strategies)
+ { __git_merge_strategies=$(__git_list_merge_strategies);
+ __git_merge_strategies="${__git_merge_strategies:-__git_merge_strategies_default}"; }
}
+__git_merge_strategy_options="ours theirs subtree subtree= patience
+ histogram diff-algorithm= ignore-space-change ignore-all-space
+ ignore-space-at-eol renormalize no-renormalize no-renames
+ find-renames find-renames= rename-threshold="
+
__git_complete_revlist_file ()
{
- local pfx ls ref cur_="$cur"
+ local dequoted_word pfx ls ref cur_="$cur"
case "$cur_" in
*..?*:*)
return
@@ -626,14 +1049,18 @@ __git_complete_revlist_file ()
?*:*)
ref="${cur_%%:*}"
cur_="${cur_#*:}"
- case "$cur_" in
+
+ __git_dequote "$cur_"
+
+ case "$dequoted_word" in
?*/*)
- pfx="${cur_%/*}"
- cur_="${cur_##*/}"
+ pfx="${dequoted_word%/*}"
+ cur_="${dequoted_word##*/}"
ls="$ref:$pfx"
pfx="$pfx/"
;;
*)
+ cur_="$dequoted_word"
ls="$ref"
;;
esac
@@ -643,21 +1070,10 @@ __git_complete_revlist_file ()
*) pfx="$ref:$pfx" ;;
esac
- __gitcomp_nl "$(__git ls-tree "$ls" \
- | sed '/^100... blob /{
- s,^.* ,,
- s,$, ,
- }
- /^120000 blob /{
- s,^.* ,,
- s,$, ,
- }
- /^040000 tree /{
- s,^.* ,,
- s,$,/,
- }
- s/^.* //')" \
- "$pfx" "$cur_" ""
+ __gitcomp_file "$(__git ls-tree "$ls" \
+ | sed 's/^.* //
+ s/$//')" \
+ "$pfx" "$cur_"
;;
*...*)
pfx="${cur_%...*}..."
@@ -675,26 +1091,6 @@ __git_complete_revlist_file ()
esac
}
-
-# __git_complete_index_file requires 1 argument:
-# 1: the options to pass to ls-file
-#
-# The exception is --committable, which finds the files appropriate commit.
-__git_complete_index_file ()
-{
- local pfx="" cur_="$cur"
-
- case "$cur_" in
- ?*/*)
- pfx="${cur_%/*}"
- cur_="${cur_##*/}"
- pfx="${pfx}/"
- ;;
- esac
-
- __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
-}
-
__git_complete_file ()
{
__git_complete_revlist_file
@@ -726,6 +1122,7 @@ __git_complete_remote_or_refspec ()
*) ;;
esac
;;
+ --multiple) no_complete_refspec=1; break ;;
-*) ;;
*) remote="$i"; break ;;
esac
@@ -785,136 +1182,30 @@ __git_complete_strategy ()
-s|--strategy)
__gitcomp "$__git_merge_strategies"
return 0
+ ;;
+ -X)
+ __gitcomp "$__git_merge_strategy_options"
+ return 0
+ ;;
esac
case "$cur" in
--strategy=*)
__gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
return 0
;;
+ --strategy-option=*)
+ __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
+ return 0
+ ;;
esac
return 1
}
-__git_commands () {
- if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
- then
- printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
- else
- git help -a|egrep '^ [a-zA-Z0-9]'
- fi
-}
-
-__git_list_all_commands ()
-{
- local i IFS=" "$'\n'
- for i in $(__git_commands)
- do
- case $i in
- *--*) : helper pattern;;
- *) echo $i;;
- esac
- done
-}
-
__git_all_commands=
__git_compute_all_commands ()
{
test -n "$__git_all_commands" ||
- __git_all_commands=$(__git_list_all_commands)
-}
-
-__git_list_porcelain_commands ()
-{
- local i IFS=" "$'\n'
- __git_compute_all_commands
- for i in $__git_all_commands
- do
- case $i in
- *--*) : helper pattern;;
- applymbox) : ask gittus;;
- applypatch) : ask gittus;;
- archimport) : import;;
- cat-file) : plumbing;;
- check-attr) : plumbing;;
- check-ignore) : plumbing;;
- check-mailmap) : plumbing;;
- check-ref-format) : plumbing;;
- checkout-index) : plumbing;;
- column) : internal helper;;
- commit-tree) : plumbing;;
- count-objects) : infrequent;;
- credential) : credentials;;
- credential-*) : credentials helper;;
- cvsexportcommit) : export;;
- cvsimport) : import;;
- cvsserver) : daemon;;
- daemon) : daemon;;
- diff-files) : plumbing;;
- diff-index) : plumbing;;
- diff-tree) : plumbing;;
- fast-import) : import;;
- fast-export) : export;;
- fsck-objects) : plumbing;;
- fetch-pack) : plumbing;;
- fmt-merge-msg) : plumbing;;
- for-each-ref) : plumbing;;
- hash-object) : plumbing;;
- http-*) : transport;;
- index-pack) : plumbing;;
- init-db) : deprecated;;
- local-fetch) : plumbing;;
- ls-files) : plumbing;;
- ls-remote) : plumbing;;
- ls-tree) : plumbing;;
- mailinfo) : plumbing;;
- mailsplit) : plumbing;;
- merge-*) : plumbing;;
- mktree) : plumbing;;
- mktag) : plumbing;;
- pack-objects) : plumbing;;
- pack-redundant) : plumbing;;
- pack-refs) : plumbing;;
- parse-remote) : plumbing;;
- patch-id) : plumbing;;
- prune) : plumbing;;
- prune-packed) : plumbing;;
- quiltimport) : import;;
- read-tree) : plumbing;;
- receive-pack) : plumbing;;
- remote-*) : transport;;
- rerere) : plumbing;;
- rev-list) : plumbing;;
- rev-parse) : plumbing;;
- runstatus) : plumbing;;
- sh-setup) : internal;;
- shell) : daemon;;
- show-ref) : plumbing;;
- send-pack) : plumbing;;
- show-index) : plumbing;;
- ssh-*) : transport;;
- stripspace) : plumbing;;
- symbolic-ref) : plumbing;;
- unpack-file) : plumbing;;
- unpack-objects) : plumbing;;
- update-index) : plumbing;;
- update-ref) : plumbing;;
- update-server-info) : daemon;;
- upload-archive) : plumbing;;
- upload-pack) : plumbing;;
- write-tree) : plumbing;;
- var) : infrequent;;
- verify-pack) : infrequent;;
- verify-tag) : plumbing;;
- *) echo $i;;
- esac
- done
-}
-
-__git_porcelain_commands=
-__git_compute_porcelain_commands ()
-{
- test -n "$__git_porcelain_commands" ||
- __git_porcelain_commands=$(__git_list_porcelain_commands)
+ __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
}
# Lists all set config variables starting with the given section prefix,
@@ -932,45 +1223,75 @@ __git_pretty_aliases ()
__git_get_config_variables "pretty"
}
-__git_aliases ()
-{
- __git_get_config_variables "alias"
-}
-
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
- local word cmdline=$(__git config --get "alias.$1")
- for word in $cmdline; do
- case "$word" in
- \!gitk|gitk)
- echo "gitk"
- return
- ;;
- \!*) : shell command alias ;;
- -*) : option ;;
- *=*) : setting env ;;
- git) : git itself ;;
- \(\)) : skip parens of shell function definition ;;
- {) : skip start of shell helper function ;;
- :) : skip null command ;;
- \'*) : skip opening quote after sh -c ;;
- *)
- echo "$word"
+ local cur=$1 last list word cmdline
+
+ while [[ -n "$cur" ]]; do
+ if [[ "$list" == *" $cur "* ]]; then
+ # loop detected
return
- esac
+ fi
+
+ cmdline=$(__git config --get "alias.$cur")
+ list=" $cur $list"
+ last=$cur
+ cur=
+
+ for word in $cmdline; do
+ case "$word" in
+ \!gitk|gitk)
+ cur="gitk"
+ break
+ ;;
+ \!*) : shell command alias ;;
+ -*) : option ;;
+ *=*) : setting env ;;
+ git) : git itself ;;
+ \(\)) : skip parens of shell function definition ;;
+ {) : skip start of shell helper function ;;
+ :) : skip null command ;;
+ \'*) : skip opening quote after sh -c ;;
+ *)
+ cur="$word"
+ break
+ esac
+ done
done
+
+ cur=$last
+ if [[ "$cur" != "$1" ]]; then
+ echo "$cur"
+ fi
}
-# __git_find_on_cmdline requires 1 argument
+# Check whether one of the given words is present on the command line,
+# and print the first word found.
+#
+# Usage: __git_find_on_cmdline [<option>]... "<wordlist>"
+# --show-idx: Optionally show the index of the found word in the $words array.
__git_find_on_cmdline ()
{
- local word subcommand c=1
+ local word c=1 show_idx
+
+ while test $# -gt 1; do
+ case "$1" in
+ --show-idx) show_idx=y ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+ local wordlist="$1"
+
while [ $c -lt $cword ]; do
- word="${words[c]}"
- for subcommand in $1; do
- if [ "$subcommand" = "$word" ]; then
- echo "$subcommand"
+ for word in $wordlist; do
+ if [ "$word" = "${words[c]}" ]; then
+ if [ -n "${show_idx-}" ]; then
+ echo "$c $word"
+ else
+ echo "$word"
+ fi
return
fi
done
@@ -978,6 +1299,40 @@ __git_find_on_cmdline ()
done
}
+# Similar to __git_find_on_cmdline, except that it loops backwards and thus
+# prints the *last* word found. Useful for finding which of two options that
+# supersede each other came last, such as "--guess" and "--no-guess".
+#
+# Usage: __git_find_last_on_cmdline [<option>]... "<wordlist>"
+# --show-idx: Optionally show the index of the found word in the $words array.
+__git_find_last_on_cmdline ()
+{
+ local word c=$cword show_idx
+
+ while test $# -gt 1; do
+ case "$1" in
+ --show-idx) show_idx=y ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+ local wordlist="$1"
+
+ while [ $c -gt 1 ]; do
+ ((c--))
+ for word in $wordlist; do
+ if [ "$word" = "${words[c]}" ]; then
+ if [ -n "$show_idx" ]; then
+ echo "$c $word"
+ else
+ echo "$word"
+ fi
+ return
+ fi
+ done
+ done
+}
+
# Echo the value of an option set on the command line or config
#
# $1: short option name
@@ -1072,12 +1427,15 @@ __git_count_arguments ()
}
__git_whitespacelist="nowarn warn error error-all fix"
+__git_patchformat="mbox stgit stgit-series hg mboxrd"
+__git_showcurrentpatch="diff raw"
+__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
_git_am ()
{
__git_find_repo_path
if [ -d "$__git_repo_path"/rebase-apply ]; then
- __gitcomp "--skip --continue --resolved --abort"
+ __gitcomp "$__git_am_inprogress_options"
return
fi
case "$cur" in
@@ -1085,13 +1443,17 @@ _git_am ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
+ --patch-format=*)
+ __gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
+ return
+ ;;
+ --show-current-patch=*)
+ __gitcomp "$__git_showcurrentpatch" "" "${cur##--show-current-patch=}"
+ return
+ ;;
--*)
- __gitcomp "
- --3way --committer-date-is-author-date --ignore-date
- --ignore-whitespace --ignore-space-change
- --interactive --keep --no-utf8 --signoff --utf8
- --whitespace= --scissors
- "
+ __gitcomp_builtin am "" \
+ "$__git_am_inprogress_options"
return
esac
}
@@ -1104,14 +1466,7 @@ _git_apply ()
return
;;
--*)
- __gitcomp "
- --stat --numstat --summary --check --index
- --cached --index-info --reverse --reject --unidiff-zero
- --apply --no-add --exclude=
- --ignore-whitespace --ignore-space-change
- --whitespace= --inaccurate-eof --verbose
- --recount --directory=
- "
+ __gitcomp_builtin apply
return
esac
}
@@ -1119,11 +1474,12 @@ _git_apply ()
_git_add ()
{
case "$cur" in
+ --chmod=*)
+ __gitcomp "+x -x" "" "${cur##--chmod=}"
+ return
+ ;;
--*)
- __gitcomp "
- --interactive --refresh --patch --update --dry-run
- --ignore-errors --intent-to-add --force --edit --chmod=
- "
+ __gitcomp_builtin add
return
esac
@@ -1147,10 +1503,7 @@ _git_archive ()
return
;;
--*)
- __gitcomp "
- --format= --list --verbose
- --prefix= --remote= --exec= --output
- "
+ __gitcomp_builtin archive "--format= --list --verbose --prefix= --worktree-attributes"
return
;;
esac
@@ -1182,6 +1535,8 @@ _git_bisect ()
esac
}
+__git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
+
_git_branch ()
{
local i c=1 only_local_ref="n" has_r="n"
@@ -1200,13 +1555,7 @@ _git_branch ()
__git_complete_refs --cur="${cur##--set-upstream-to=}"
;;
--*)
- __gitcomp "
- --color --no-color --verbose --abbrev= --no-abbrev
- --track --no-track --contains --no-contains --merged --no-merged
- --set-upstream-to= --edit-description --list
- --unset-upstream --delete --move --copy --remotes
- --column --no-column --sort= --points-at
- "
+ __gitcomp_builtin branch
;;
*)
if [ $only_local_ref = "y" -a $has_r = "n" ]; then
@@ -1238,49 +1587,111 @@ _git_bundle ()
esac
}
+# Helper function to decide whether or not we should enable DWIM logic for
+# git-switch and git-checkout.
+#
+# To decide between the following rules in priority order
+# 1) the last provided of "--guess" or "--no-guess" explicitly enable or
+# disable completion of DWIM logic respectively.
+# 2) If the --no-track option is provided, take this as a hint to disable the
+# DWIM completion logic
+# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
+# logic, as requested by the user.
+# 4) Enable DWIM logic otherwise.
+#
+__git_checkout_default_dwim_mode ()
+{
+ local last_option dwim_opt="--dwim"
+
+ if [ "${GIT_COMPLETION_CHECKOUT_NO_GUESS-}" = "1" ]; then
+ dwim_opt=""
+ fi
+
+ # --no-track disables DWIM, but with lower priority than
+ # --guess/--no-guess
+ if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
+ dwim_opt=""
+ fi
+
+ # Find the last provided --guess or --no-guess
+ last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
+ case "$last_option" in
+ --guess)
+ dwim_opt="--dwim"
+ ;;
+ --no-guess)
+ dwim_opt=""
+ ;;
+ esac
+
+ echo "$dwim_opt"
+}
+
_git_checkout ()
{
__git_has_doubledash && return
+ local dwim_opt="$(__git_checkout_default_dwim_mode)"
+
+ case "$prev" in
+ -b|-B|--orphan)
+ # Complete local branches (and DWIM branch
+ # remote branch names) for an option argument
+ # specifying a new branch name. This is for
+ # convenience, assuming new branches are
+ # possibly based on pre-existing branch names.
+ __git_complete_refs $dwim_opt --mode="heads"
+ return
+ ;;
+ *)
+ ;;
+ esac
+
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
- __gitcomp "
- --quiet --ours --theirs --track --no-track --merge
- --conflict= --orphan --patch --detach --ignore-skip-worktree-bits
- --recurse-submodules --no-recurse-submodules
- "
+ __gitcomp_builtin checkout
;;
*)
- # check if --track, --no-track, or --no-guess was specified
- # if so, disable DWIM mode
- local flags="--track --no-track --no-guess" track_opt="--track"
- if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
- [ -n "$(__git_find_on_cmdline "$flags")" ]; then
- track_opt=''
+ # At this point, we've already handled special completion for
+ # the arguments to -b/-B, and --orphan. There are 3 main
+ # things left we can possibly complete:
+ # 1) a start-point for -b/-B, -d/--detach, or --orphan
+ # 2) a remote head, for --track
+ # 3) an arbitrary reference, possibly including DWIM names
+ #
+
+ if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then
+ __git_complete_refs --mode="refs"
+ elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
+ __git_complete_refs --mode="remote-heads"
+ else
+ __git_complete_refs $dwim_opt --mode="refs"
fi
- __git_complete_refs $track_opt
;;
esac
}
-_git_cherry ()
-{
- __git_complete_refs
-}
+__git_sequencer_inprogress_options="--continue --quit --abort --skip"
+
+__git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
_git_cherry_pick ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
- __gitcomp "--continue --quit --abort"
+ __gitcomp "$__git_cherry_pick_inprogress_options"
return
fi
+
+ __git_complete_strategy && return
+
case "$cur" in
--*)
- __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
+ __gitcomp_builtin cherry-pick "" \
+ "$__git_cherry_pick_inprogress_options"
;;
*)
__git_complete_refs
@@ -1292,7 +1703,7 @@ _git_clean ()
{
case "$cur" in
--*)
- __gitcomp "--dry-run --quiet"
+ __gitcomp_builtin clean
return
;;
esac
@@ -1303,28 +1714,20 @@ _git_clean ()
_git_clone ()
{
+ case "$prev" in
+ -c|--config)
+ __git_complete_config_variable_name_and_value
+ return
+ ;;
+ esac
case "$cur" in
+ --config=*)
+ __git_complete_config_variable_name_and_value \
+ --cur="${cur##--config=}"
+ return
+ ;;
--*)
- __gitcomp "
- --local
- --no-hardlinks
- --shared
- --reference
- --quiet
- --no-checkout
- --bare
- --mirror
- --origin
- --upload-pack
- --template=
- --depth
- --single-branch
- --no-tags
- --branch
- --recurse-submodules
- --no-single-branch
- --shallow-submodules
- "
+ __gitcomp_builtin clone
return
;;
esac
@@ -1357,16 +1760,7 @@ _git_commit ()
return
;;
--*)
- __gitcomp "
- --all --author= --signoff --verify --no-verify
- --edit --no-edit
- --amend --include --only --interactive
- --dry-run --reuse-message= --reedit-message=
- --reset-author --file= --message= --template=
- --cleanup= --untracked-files --untracked-files=
- --verbose --quiet --fixup= --squash=
- --patch --short --date --allow-empty
- "
+ __gitcomp_builtin commit
return
esac
@@ -1382,11 +1776,7 @@ _git_describe ()
{
case "$cur" in
--*)
- __gitcomp "
- --all --tags --contains --abbrev= --candidates=
- --exact-match --debug --long --match --always --first-parent
- --exclude --dirty --broken
- "
+ __gitcomp_builtin describe
return
esac
__git_complete_refs
@@ -1396,9 +1786,16 @@ __git_diff_algorithms="myers minimal patience histogram"
__git_diff_submodule_formats="diff log short"
+__git_color_moved_opts="no default plain blocks zebra dimmed-zebra"
+
+__git_color_moved_ws_opts="no ignore-space-at-eol ignore-space-change
+ ignore-all-space allow-indentation-change"
+
__git_diff_common_options="--stat --numstat --shortstat --summary
--patch-with-stat --name-only --name-status --color
--no-color --color-words --no-renames --check
+ --color-moved --color-moved= --no-color-moved
+ --color-moved-ws= --no-color-moved-ws
--full-index --binary --abbrev --diff-filter=
--find-copies-harder --ignore-cr-at-eol
--text --ignore-space-at-eol --ignore-space-change
@@ -1411,7 +1808,9 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative
--diff-algorithm=
- --submodule --submodule=
+ --submodule --submodule= --ignore-submodules
+ --indent-heuristic --no-indent-heuristic
+ --textconv --no-textconv
"
_git_diff ()
@@ -1427,6 +1826,14 @@ _git_diff ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --color-moved=*)
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
+ return
+ ;;
+ --color-moved-ws=*)
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ return
+ ;;
--*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index
@@ -1439,7 +1846,8 @@ _git_diff ()
}
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
- tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
+ tkdiff vimdiff nvimdiff gvimdiff xxdiff araxis p4merge
+ bc codecompare smerge
"
_git_difftool ()
@@ -1452,11 +1860,11 @@ _git_difftool ()
return
;;
--*)
- __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
- --base --ours --theirs
- --no-renames --diff-filter= --find-copies-harder
- --relative --ignore-submodules
- --tool="
+ __gitcomp_builtin difftool "$__git_diff_common_options
+ --base --cached --ours --theirs
+ --pickaxe-all --pickaxe-regex
+ --relative --staged
+ "
return
;;
esac
@@ -1465,12 +1873,6 @@ _git_difftool ()
__git_fetch_recurse_submodules="yes on-demand no"
-__git_fetch_options="
- --quiet --verbose --append --upload-pack --force --keep --depth=
- --tags --no-tags --all --prune --dry-run --recurse-submodules=
- --unshallow --update-shallow
-"
-
_git_fetch ()
{
case "$cur" in
@@ -1478,21 +1880,21 @@ _git_fetch ()
__gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
return
;;
+ --filter=*)
+ __gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}"
+ return
+ ;;
--*)
- __gitcomp "$__git_fetch_options"
+ __gitcomp_builtin fetch
return
;;
esac
__git_complete_remote_or_refspec
}
-__git_format_patch_options="
- --stdout --attach --no-attach --thread --thread= --no-thread
- --numbered --start-number --numbered-files --keep-subject --signoff
- --signature --no-signature --in-reply-to= --cc= --full-index --binary
- --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
- --inline --suffix= --ignore-if-in-upstream --subject-prefix=
- --output-directory --reroll-count --to= --quiet --notes
+__git_format_patch_extra_options="
+ --full-index --not --all --no-prefix --src-prefix=
+ --dst-prefix= --notes
"
_git_format_patch ()
@@ -1504,32 +1906,23 @@ _git_format_patch ()
" "" "${cur##--thread=}"
return
;;
- --*)
- __gitcomp "$__git_format_patch_options"
+ --base=*|--interdiff=*|--range-diff=*)
+ __git_complete_refs --cur="${cur#--*=}"
return
;;
- esac
- __git_complete_revlist
-}
-
-_git_fsck ()
-{
- case "$cur" in
--*)
- __gitcomp "
- --tags --root --unreachable --cache --no-reflogs --full
- --strict --verbose --lost-found --name-objects
- "
+ __gitcomp_builtin format-patch "$__git_format_patch_extra_options"
return
;;
esac
+ __git_complete_revlist
}
-_git_gc ()
+_git_fsck ()
{
case "$cur" in
--*)
- __gitcomp "--prune --aggressive"
+ __gitcomp_builtin fsck
return
;;
esac
@@ -1585,21 +1978,7 @@ _git_grep ()
case "$cur" in
--*)
- __gitcomp "
- --cached
- --text --ignore-case --word-regexp --invert-match
- --full-name --line-number
- --extended-regexp --basic-regexp --fixed-strings
- --perl-regexp
- --threads
- --files-with-matches --name-only
- --files-without-match
- --max-depth
- --count
- --and --or --not --all-match
- --break --heading --show-function --function-context
- --untracked --no-index
- "
+ __gitcomp_builtin grep
return
;;
esac
@@ -1617,17 +1996,16 @@ _git_help ()
{
case "$cur" in
--*)
- __gitcomp "--all --guides --info --man --web"
+ __gitcomp_builtin help
return
;;
esac
- __git_compute_all_commands
- __gitcomp "$__git_all_commands $(__git_aliases)
- attributes cli core-tutorial cvs-migration
- diffcore everyday gitk glossary hooks ignore modules
- namespaces repository-layout revisions tutorial tutorial-2
- workflows
- "
+ if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
+ then
+ __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
+ else
+ __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
+ fi
}
_git_init ()
@@ -1640,7 +2018,7 @@ _git_init ()
return
;;
--*)
- __gitcomp "--quiet --bare --template= --shared --shared="
+ __gitcomp_builtin init
return
;;
esac
@@ -1650,13 +2028,7 @@ _git_ls_files ()
{
case "$cur" in
--*)
- __gitcomp "--cached --deleted --modified --others --ignored
- --stage --directory --no-empty-directory --unmerged
- --killed --exclude= --exclude-from=
- --exclude-per-directory= --exclude-standard
- --error-unmatch --with-tree= --full-name
- --abbrev --ignored --exclude-per-directory
- "
+ __gitcomp_builtin ls-files
return
;;
esac
@@ -1670,7 +2042,7 @@ _git_ls_remote ()
{
case "$cur" in
--*)
- __gitcomp "--heads --tags --refs --get-url --symref"
+ __gitcomp_builtin ls-remote
return
;;
esac
@@ -1679,6 +2051,13 @@ _git_ls_remote ()
_git_ls_tree ()
{
+ case "$cur" in
+ --*)
+ __gitcomp_builtin ls-tree
+ return
+ ;;
+ esac
+
__git_complete_file
}
@@ -1705,8 +2084,8 @@ __git_log_shortlog_options="
--all-match --invert-grep
"
-__git_log_pretty_formats="oneline short medium full fuller email raw format:"
-__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
+__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
+__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
_git_log ()
{
@@ -1752,6 +2131,10 @@ _git_log ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --no-walk=*)
+ __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
+ return
+ ;;
--*)
__gitcomp "
$__git_log_common_options
@@ -1759,19 +2142,23 @@ _git_log ()
$__git_log_gitk_options
--root --topo-order --date-order --reverse
--follow --full-diff
- --abbrev-commit --abbrev=
+ --abbrev-commit --no-abbrev-commit --abbrev=
--relative-date --date=
--pretty= --format= --oneline
--show-signature
--cherry-mark
--cherry-pick
--graph
- --decorate --decorate=
+ --decorate --decorate= --no-decorate
--walk-reflogs
+ --no-walk --no-walk= --do-walk
--parents --children
+ --expand-tabs --expand-tabs= --no-expand-tabs
+ --patch
$merge
$__git_diff_common_options
--pickaxe-all --pickaxe-regex
+ --patch --no-patch
"
return
;;
@@ -1794,22 +2181,13 @@ _git_log ()
__git_complete_revlist
}
-# Common merge options shared by git-merge(1) and git-pull(1).
-__git_merge_options="
- --no-commit --no-stat --log --no-log --squash --strategy
- --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
- --verify-signatures --no-verify-signatures --gpg-sign
- --quiet --verbose --progress --no-progress
-"
-
_git_merge ()
{
__git_complete_strategy && return
case "$cur" in
--*)
- __gitcomp "$__git_merge_options
- --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
+ __gitcomp_builtin merge
return
esac
__git_complete_refs
@@ -1823,7 +2201,7 @@ _git_mergetool ()
return
;;
--*)
- __gitcomp "--tool= --prompt --no-prompt"
+ __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
return
;;
esac
@@ -1833,7 +2211,7 @@ _git_merge_base ()
{
case "$cur" in
--*)
- __gitcomp "--octopus --independent --is-ancestor --fork-point"
+ __gitcomp_builtin merge-base
return
;;
esac
@@ -1844,7 +2222,7 @@ _git_mv ()
{
case "$cur" in
--*)
- __gitcomp "--dry-run"
+ __gitcomp_builtin mv
return
;;
esac
@@ -1858,19 +2236,14 @@ _git_mv ()
fi
}
-_git_name_rev ()
-{
- __gitcomp "--tags --all --stdin"
-}
-
_git_notes ()
{
- local subcommands='add append copy edit list prune remove show'
+ local subcommands='add append copy edit get-ref list merge prune remove show'
local subcommand="$(__git_find_on_cmdline "$subcommands")"
case "$subcommand,$cur" in
,--*)
- __gitcomp '--ref'
+ __gitcomp_builtin notes
;;
,*)
case "$prev" in
@@ -1882,21 +2255,14 @@ _git_notes ()
;;
esac
;;
- add,--reuse-message=*|append,--reuse-message=*|\
- add,--reedit-message=*|append,--reedit-message=*)
+ *,--reuse-message=*|*,--reedit-message=*)
__git_complete_refs --cur="${cur#*=}"
;;
- add,--*|append,--*)
- __gitcomp '--file= --message= --reedit-message=
- --reuse-message='
- ;;
- copy,--*)
- __gitcomp '--stdin'
+ *,--*)
+ __gitcomp_builtin notes_$subcommand
;;
- prune,--*)
- __gitcomp '--dry-run --verbose'
- ;;
- prune,*)
+ prune,*|get-ref,*)
+ # this command does not take a ref, do not complete it
;;
*)
case "$prev" in
@@ -1920,12 +2286,8 @@ _git_pull ()
return
;;
--*)
- __gitcomp "
- --rebase --no-rebase
- --autostash --no-autostash
- $__git_merge_options
- $__git_fetch_options
- "
+ __gitcomp_builtin pull
+
return
;;
esac
@@ -1976,27 +2338,39 @@ _git_push ()
return
;;
--*)
+ __gitcomp_builtin push
+ return
+ ;;
+ esac
+ __git_complete_remote_or_refspec
+}
+
+_git_range_diff ()
+{
+ case "$cur" in
+ --*)
__gitcomp "
- --all --mirror --tags --dry-run --force --verbose
- --quiet --prune --delete --follow-tags
- --receive-pack= --repo= --set-upstream
- --force-with-lease --force-with-lease= --recurse-submodules=
+ --creation-factor= --no-dual-color
+ $__git_diff_common_options
"
return
;;
esac
- __git_complete_remote_or_refspec
+ __git_complete_revlist
}
+__git_rebase_inprogress_options="--continue --skip --abort --quit --show-current-patch"
+__git_rebase_interactive_inprogress_options="$__git_rebase_inprogress_options --edit-todo"
+
_git_rebase ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
- __gitcomp "--continue --skip --abort --quit --edit-todo"
+ __gitcomp "$__git_rebase_interactive_inprogress_options"
return
elif [ -d "$__git_repo_path"/rebase-apply ] || \
[ -d "$__git_repo_path"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort --quit"
+ __gitcomp "$__git_rebase_inprogress_options"
return
fi
__git_complete_strategy && return
@@ -2005,19 +2379,13 @@ _git_rebase ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
+ --onto=*)
+ __git_complete_refs --cur="${cur##--onto=}"
+ return
+ ;;
--*)
- __gitcomp "
- --onto --merge --strategy --interactive
- --preserve-merges --stat --no-stat
- --committer-date-is-author-date --ignore-date
- --ignore-whitespace --whitespace=
- --autosquash --no-autosquash
- --fork-point --no-fork-point
- --autostash --no-autostash
- --verify --no-verify
- --keep-empty --root --force-rebase --no-ff
- --exec
- "
+ __gitcomp_builtin rebase "" \
+ "$__git_rebase_interactive_inprogress_options"
return
esac
@@ -2077,16 +2445,16 @@ _git_send_email ()
return
;;
--*)
- __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
+ __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to
--compose --confirm= --dry-run --envelope-sender
--from --identity
--in-reply-to --no-chain-reply-to --no-signed-off-by-cc
- --no-suppress-from --no-thread --quiet
+ --no-suppress-from --no-thread --quiet --reply-to
--signed-off-by-cc --smtp-pass --smtp-server
--smtp-server-port --smtp-encryption= --smtp-user
--subject --suppress-cc= --suppress-from --thread --to
--validate --no-validate
- $__git_format_patch_options"
+ $__git_format_patch_extra_options"
return
;;
esac
@@ -2119,11 +2487,7 @@ _git_status ()
return
;;
--*)
- __gitcomp "
- --short --branch --porcelain --long --verbose
- --untracked-files= --ignore-submodules= --ignored
- --column= --no-column
- "
+ __gitcomp_builtin status
return
;;
esac
@@ -2148,6 +2512,57 @@ _git_status ()
__git_complete_index_file "$complete_opt"
}
+_git_switch ()
+{
+ local dwim_opt="$(__git_checkout_default_dwim_mode)"
+
+ case "$prev" in
+ -c|-C|--orphan)
+ # Complete local branches (and DWIM branch
+ # remote branch names) for an option argument
+ # specifying a new branch name. This is for
+ # convenience, assuming new branches are
+ # possibly based on pre-existing branch names.
+ __git_complete_refs $dwim_opt --mode="heads"
+ return
+ ;;
+ *)
+ ;;
+ esac
+
+ case "$cur" in
+ --conflict=*)
+ __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ ;;
+ --*)
+ __gitcomp_builtin switch
+ ;;
+ *)
+ # Unlike in git checkout, git switch --orphan does not take
+ # a start point. Thus we really have nothing to complete after
+ # the branch name.
+ if [ -n "$(__git_find_on_cmdline "--orphan")" ]; then
+ return
+ fi
+
+ # At this point, we've already handled special completion for
+ # -c/-C, and --orphan. There are 3 main things left to
+ # complete:
+ # 1) a start-point for -c/-C or -d/--detach
+ # 2) a remote head, for --track
+ # 3) a branch name, possibly including DWIM remote branches
+
+ if [ -n "$(__git_find_on_cmdline "-c -C -d --detach")" ]; then
+ __git_complete_refs --mode="refs"
+ elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
+ __git_complete_refs --mode="remote-heads"
+ else
+ __git_complete_refs $dwim_opt --mode="heads"
+ fi
+ ;;
+ esac
+}
+
__git_config_get_set_variables ()
{
local prevword word config_file= c=$cword
@@ -2170,496 +2585,287 @@ __git_config_get_set_variables ()
__git config $config_file --name-only --list
}
-_git_config ()
+__git_config_vars=
+__git_compute_config_vars ()
{
- case "$prev" in
+ test -n "$__git_config_vars" ||
+ __git_config_vars="$(git help --config-for-completion | sort -u)"
+}
+
+# Completes possible values of various configuration variables.
+#
+# Usage: __git_complete_config_variable_value [<option>]...
+# --varname=<word>: The name of the configuration variable whose value is
+# to be completed. Defaults to the previous word on the
+# command line.
+# --cur=<word>: The current value to be completed. Defaults to the current
+# word to be completed.
+__git_complete_config_variable_value ()
+{
+ local varname="$prev" cur_="$cur"
+
+ while test $# != 0; do
+ case "$1" in
+ --varname=*) varname="${1##--varname=}" ;;
+ --cur=*) cur_="${1##--cur=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
+ varname="${varname,,}"
+ else
+ varname="$(echo "$varname" |tr A-Z a-z)"
+ fi
+
+ case "$varname" in
branch.*.remote|branch.*.pushremote)
- __gitcomp_nl "$(__git_remotes)"
+ __gitcomp_nl "$(__git_remotes)" "" "$cur_"
return
;;
branch.*.merge)
- __git_complete_refs
+ __git_complete_refs --cur="$cur_"
return
;;
branch.*.rebase)
- __gitcomp "false true preserve interactive"
+ __gitcomp "false true merges preserve interactive" "" "$cur_"
return
;;
remote.pushdefault)
- __gitcomp_nl "$(__git_remotes)"
+ __gitcomp_nl "$(__git_remotes)" "" "$cur_"
return
;;
remote.*.fetch)
- local remote="${prev#remote.}"
+ local remote="${varname#remote.}"
remote="${remote%.fetch}"
- if [ -z "$cur" ]; then
+ if [ -z "$cur_" ]; then
__gitcomp_nl "refs/heads/" "" "" ""
return
fi
- __gitcomp_nl "$(__git_refs_remotes "$remote")"
+ __gitcomp_nl "$(__git_refs_remotes "$remote")" "" "$cur_"
return
;;
remote.*.push)
- local remote="${prev#remote.}"
+ local remote="${varname#remote.}"
remote="${remote%.push}"
__gitcomp_nl "$(__git for-each-ref \
- --format='%(refname):%(refname)' refs/heads)"
+ --format='%(refname):%(refname)' refs/heads)" "" "$cur_"
return
;;
pull.twohead|pull.octopus)
__git_compute_merge_strategies
- __gitcomp "$__git_merge_strategies"
- return
- ;;
- color.branch|color.diff|color.interactive|\
- color.showbranch|color.status|color.ui)
- __gitcomp "always never auto"
+ __gitcomp "$__git_merge_strategies" "" "$cur_"
return
;;
color.pager)
- __gitcomp "false true"
+ __gitcomp "false true" "" "$cur_"
return
;;
color.*.*)
__gitcomp "
normal black red green yellow blue magenta cyan white
bold dim ul blink reverse
- "
+ " "" "$cur_"
+ return
+ ;;
+ color.*)
+ __gitcomp "false true always never auto" "" "$cur_"
return
;;
diff.submodule)
- __gitcomp "log short"
+ __gitcomp "$__git_diff_submodule_formats" "" "$cur_"
return
;;
help.format)
- __gitcomp "man info web html"
+ __gitcomp "man info web html" "" "$cur_"
return
;;
log.date)
- __gitcomp "$__git_log_date_formats"
+ __gitcomp "$__git_log_date_formats" "" "$cur_"
return
;;
- sendemail.aliasesfiletype)
- __gitcomp "mutt mailrc pine elm gnus"
+ sendemail.aliasfiletype)
+ __gitcomp "mutt mailrc pine elm gnus" "" "$cur_"
return
;;
sendemail.confirm)
- __gitcomp "$__git_send_email_confirm_options"
+ __gitcomp "$__git_send_email_confirm_options" "" "$cur_"
return
;;
sendemail.suppresscc)
- __gitcomp "$__git_send_email_suppresscc_options"
+ __gitcomp "$__git_send_email_suppresscc_options" "" "$cur_"
return
;;
sendemail.transferencoding)
- __gitcomp "7bit 8bit quoted-printable base64"
- return
- ;;
- --get|--get-all|--unset|--unset-all)
- __gitcomp_nl "$(__git_config_get_set_variables)"
+ __gitcomp "7bit 8bit quoted-printable base64" "" "$cur_"
return
;;
*.*)
return
;;
esac
- case "$cur" in
- --*)
- __gitcomp "
- --system --global --local --file=
- --list --replace-all
- --get --get-all --get-regexp
- --add --unset --unset-all
- --remove-section --rename-section
- --name-only
- "
- return
- ;;
+}
+
+# Completes configuration sections, subsections, variable names.
+#
+# Usage: __git_complete_config_variable_name [<option>]...
+# --cur=<word>: The current configuration section/variable name to be
+# completed. Defaults to the current word to be completed.
+# --sfx=<suffix>: A suffix to be appended to each fully completed
+# configuration variable name (but not to sections or
+# subsections) instead of the default space.
+__git_complete_config_variable_name ()
+{
+ local cur_="$cur" sfx
+
+ while test $# != 0; do
+ case "$1" in
+ --cur=*) cur_="${1##--cur=}" ;;
+ --sfx=*) sfx="${1##--sfx=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ case "$cur_" in
branch.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" "$sfx"
return
;;
branch.*)
- local pfx="${cur%.*}." cur_="${cur#*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
- __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
+ __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }"
return
;;
guitool.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
__gitcomp "
- argprompt cmd confirm needsfile noconsole norescan
- prompt revprompt revunmerged title
- " "$pfx" "$cur_"
+ argPrompt cmd confirm needsFile noConsole noRescan
+ prompt revPrompt revUnmerged title
+ " "$pfx" "$cur_" "$sfx"
return
;;
difftool.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "cmd path" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
return
;;
man.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "cmd path" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
return
;;
mergetool.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" "$sfx"
return
;;
pager.*)
- local pfx="${cur%.*}." cur_="${cur#*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
__git_compute_all_commands
- __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
+ __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
return
;;
remote.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
__gitcomp "
url proxy fetch push mirror skipDefaultUpdate
- receivepack uploadpack tagopt pushurl
- " "$pfx" "$cur_"
+ receivepack uploadpack tagOpt pushurl
+ " "$pfx" "$cur_" "$sfx"
return
;;
remote.*)
- local pfx="${cur%.*}." cur_="${cur#*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
- __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
+ __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }"
return
;;
url.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
- return
- ;;
- esac
- __gitcomp "
- add.ignoreErrors
- advice.amWorkDir
- advice.commitBeforeMerge
- advice.detachedHead
- advice.implicitIdentity
- advice.pushAlreadyExists
- advice.pushFetchFirst
- advice.pushNeedsForce
- advice.pushNonFFCurrent
- advice.pushNonFFMatching
- advice.pushUpdateRejected
- advice.resolveConflict
- advice.rmHints
- advice.statusHints
- advice.statusUoption
- advice.ignoredHook
- alias.
- am.keepcr
- am.threeWay
- apply.ignorewhitespace
- apply.whitespace
- branch.autosetupmerge
- branch.autosetuprebase
- browser.
- clean.requireForce
- color.branch
- color.branch.current
- color.branch.local
- color.branch.plain
- color.branch.remote
- color.decorate.HEAD
- color.decorate.branch
- color.decorate.remoteBranch
- color.decorate.stash
- color.decorate.tag
- color.diff
- color.diff.commit
- color.diff.frag
- color.diff.func
- color.diff.meta
- color.diff.new
- color.diff.old
- color.diff.plain
- color.diff.whitespace
- color.grep
- color.grep.context
- color.grep.filename
- color.grep.function
- color.grep.linenumber
- color.grep.match
- color.grep.selected
- color.grep.separator
- color.interactive
- color.interactive.error
- color.interactive.header
- color.interactive.help
- color.interactive.prompt
- color.pager
- color.showbranch
- color.status
- color.status.added
- color.status.changed
- color.status.header
- color.status.localBranch
- color.status.nobranch
- color.status.remoteBranch
- color.status.unmerged
- color.status.untracked
- color.status.updated
- color.ui
- commit.cleanup
- commit.gpgSign
- commit.status
- commit.template
- commit.verbose
- core.abbrev
- core.askpass
- core.attributesfile
- core.autocrlf
- core.bare
- core.bigFileThreshold
- core.checkStat
- core.commentChar
- core.compression
- core.createObject
- core.deltaBaseCacheLimit
- core.editor
- core.eol
- core.excludesfile
- core.fileMode
- core.fsyncobjectfiles
- core.gitProxy
- core.hideDotFiles
- core.hooksPath
- core.ignoreStat
- core.ignorecase
- core.logAllRefUpdates
- core.loosecompression
- core.notesRef
- core.packedGitLimit
- core.packedGitWindowSize
- core.packedRefsTimeout
- core.pager
- core.precomposeUnicode
- core.preferSymlinkRefs
- core.preloadindex
- core.protectHFS
- core.protectNTFS
- core.quotepath
- core.repositoryFormatVersion
- core.safecrlf
- core.sharedRepository
- core.sparseCheckout
- core.splitIndex
- core.sshCommand
- core.symlinks
- core.trustctime
- core.untrackedCache
- core.warnAmbiguousRefs
- core.whitespace
- core.worktree
- credential.helper
- credential.useHttpPath
- credential.username
- credentialCache.ignoreSIGHUP
- diff.autorefreshindex
- diff.external
- diff.ignoreSubmodules
- diff.mnemonicprefix
- diff.noprefix
- diff.renameLimit
- diff.renames
- diff.statGraphWidth
- diff.submodule
- diff.suppressBlankEmpty
- diff.tool
- diff.wordRegex
- diff.algorithm
- difftool.
- difftool.prompt
- fetch.recurseSubmodules
- fetch.unpackLimit
- format.attach
- format.cc
- format.coverLetter
- format.from
- format.headers
- format.numbered
- format.pretty
- format.signature
- format.signoff
- format.subjectprefix
- format.suffix
- format.thread
- format.to
- gc.
- gc.aggressiveDepth
- gc.aggressiveWindow
- gc.auto
- gc.autoDetach
- gc.autopacklimit
- gc.logExpiry
- gc.packrefs
- gc.pruneexpire
- gc.reflogexpire
- gc.reflogexpireunreachable
- gc.rerereresolved
- gc.rerereunresolved
- gc.worktreePruneExpire
- gitcvs.allbinary
- gitcvs.commitmsgannotation
- gitcvs.dbTableNamePrefix
- gitcvs.dbdriver
- gitcvs.dbname
- gitcvs.dbpass
- gitcvs.dbuser
- gitcvs.enabled
- gitcvs.logfile
- gitcvs.usecrlfattr
- guitool.
- gui.blamehistoryctx
- gui.commitmsgwidth
- gui.copyblamethreshold
- gui.diffcontext
- gui.encoding
- gui.fastcopyblame
- gui.matchtrackingbranch
- gui.newbranchtemplate
- gui.pruneduringfetch
- gui.spellingdictionary
- gui.trustmtime
- help.autocorrect
- help.browser
- help.format
- http.lowSpeedLimit
- http.lowSpeedTime
- http.maxRequests
- http.minSessions
- http.noEPSV
- http.postBuffer
- http.proxy
- http.sslCipherList
- http.sslVersion
- http.sslCAInfo
- http.sslCAPath
- http.sslCert
- http.sslCertPasswordProtected
- http.sslKey
- http.sslVerify
- http.useragent
- i18n.commitEncoding
- i18n.logOutputEncoding
- imap.authMethod
- imap.folder
- imap.host
- imap.pass
- imap.port
- imap.preformattedHTML
- imap.sslverify
- imap.tunnel
- imap.user
- init.templatedir
- instaweb.browser
- instaweb.httpd
- instaweb.local
- instaweb.modulepath
- instaweb.port
- interactive.singlekey
- log.date
- log.decorate
- log.showroot
- mailmap.file
- man.
- man.viewer
- merge.
- merge.conflictstyle
- merge.log
- merge.renameLimit
- merge.renormalize
- merge.stat
- merge.tool
- merge.verbosity
- mergetool.
- mergetool.keepBackup
- mergetool.keepTemporaries
- mergetool.prompt
- notes.displayRef
- notes.rewrite.
- notes.rewrite.amend
- notes.rewrite.rebase
- notes.rewriteMode
- notes.rewriteRef
- pack.compression
- pack.deltaCacheLimit
- pack.deltaCacheSize
- pack.depth
- pack.indexVersion
- pack.packSizeLimit
- pack.threads
- pack.window
- pack.windowMemory
- pager.
- pretty.
- pull.octopus
- pull.twohead
- push.default
- push.followTags
- rebase.autosquash
- rebase.stat
- receive.autogc
- receive.denyCurrentBranch
- receive.denyDeleteCurrent
- receive.denyDeletes
- receive.denyNonFastForwards
- receive.fsckObjects
- receive.unpackLimit
- receive.updateserverinfo
- remote.pushdefault
- remotes.
- repack.usedeltabaseoffset
- rerere.autoupdate
- rerere.enabled
- sendemail.
- sendemail.aliasesfile
- sendemail.aliasfiletype
- sendemail.bcc
- sendemail.cc
- sendemail.cccmd
- sendemail.chainreplyto
- sendemail.confirm
- sendemail.envelopesender
- sendemail.from
- sendemail.identity
- sendemail.multiedit
- sendemail.signedoffbycc
- sendemail.smtpdomain
- sendemail.smtpencryption
- sendemail.smtppass
- sendemail.smtpserver
- sendemail.smtpserveroption
- sendemail.smtpserverport
- sendemail.smtpuser
- sendemail.suppresscc
- sendemail.suppressfrom
- sendemail.thread
- sendemail.to
- sendemail.tocmd
- sendemail.validate
- sendemail.smtpbatchsize
- sendemail.smtprelogindelay
- showbranch.default
- status.relativePaths
- status.showUntrackedFiles
- status.submodulesummary
- submodule.
- tar.umask
- transfer.unpackLimit
- url.
- user.email
- user.name
- user.signingkey
- web.browser
- branch. remote.
- "
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" "$sfx"
+ return
+ ;;
+ *.*)
+ __git_compute_config_vars
+ __gitcomp "$__git_config_vars" "" "$cur_" "$sfx"
+ ;;
+ *)
+ __git_compute_config_vars
+ __gitcomp "$(echo "$__git_config_vars" |
+ awk -F . '{
+ sections[$1] = 1
+ }
+ END {
+ for (s in sections)
+ print s "."
+ }
+ ')" "" "$cur_"
+ ;;
+ esac
+}
+
+# Completes '='-separated configuration sections/variable names and values
+# for 'git -c section.name=value'.
+#
+# Usage: __git_complete_config_variable_name_and_value [<option>]...
+# --cur=<word>: The current configuration section/variable name/value to be
+# completed. Defaults to the current word to be completed.
+__git_complete_config_variable_name_and_value ()
+{
+ local cur_="$cur"
+
+ while test $# != 0; do
+ case "$1" in
+ --cur=*) cur_="${1##--cur=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ case "$cur_" in
+ *=*)
+ __git_complete_config_variable_value \
+ --varname="${cur_%%=*}" --cur="${cur_#*=}"
+ ;;
+ *)
+ __git_complete_config_variable_name --cur="$cur_" --sfx='='
+ ;;
+ esac
+}
+
+_git_config ()
+{
+ case "$prev" in
+ --get|--get-all|--unset|--unset-all)
+ __gitcomp_nl "$(__git_config_get_set_variables)"
+ return
+ ;;
+ *.*)
+ __git_complete_config_variable_value
+ return
+ ;;
+ esac
+ case "$cur" in
+ --*)
+ __gitcomp_builtin config
+ ;;
+ *)
+ __git_complete_config_variable_name
+ ;;
+ esac
}
_git_remote ()
@@ -2672,7 +2878,7 @@ _git_remote ()
if [ -z "$subcommand" ]; then
case "$cur" in
--*)
- __gitcomp "--verbose"
+ __gitcomp_builtin remote
;;
*)
__gitcomp "$subcommands"
@@ -2683,33 +2889,33 @@ _git_remote ()
case "$subcommand,$cur" in
add,--*)
- __gitcomp "--track --master --fetch --tags --no-tags --mirror="
+ __gitcomp_builtin remote_add
;;
add,*)
;;
set-head,--*)
- __gitcomp "--auto --delete"
+ __gitcomp_builtin remote_set-head
;;
set-branches,--*)
- __gitcomp "--add"
+ __gitcomp_builtin remote_set-branches
;;
set-head,*|set-branches,*)
__git_complete_remote_or_refspec
;;
update,--*)
- __gitcomp "--prune"
+ __gitcomp_builtin remote_update
;;
update,*)
- __gitcomp "$(__git_get_config_variables "remotes")"
+ __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
;;
set-url,--*)
- __gitcomp "--push --add --delete"
+ __gitcomp_builtin remote_set-url
;;
get-url,--*)
- __gitcomp "--push --all"
+ __gitcomp_builtin remote_get-url
;;
prune,--*)
- __gitcomp "--dry-run"
+ __gitcomp_builtin remote_prune
;;
*)
__gitcomp_nl "$(__git_remotes)"
@@ -2720,8 +2926,12 @@ _git_remote ()
_git_replace ()
{
case "$cur" in
+ --format=*)
+ __gitcomp "short medium long" "" "${cur##--format=}"
+ return
+ ;;
--*)
- __gitcomp "--edit --graft --format= --list --delete"
+ __gitcomp_builtin replace
return
;;
esac
@@ -2745,26 +2955,49 @@ _git_reset ()
case "$cur" in
--*)
- __gitcomp "--merge --mixed --hard --soft --patch --keep"
+ __gitcomp_builtin reset
return
;;
esac
__git_complete_refs
}
+_git_restore ()
+{
+ case "$prev" in
+ -s)
+ __git_complete_refs
+ return
+ ;;
+ esac
+
+ case "$cur" in
+ --conflict=*)
+ __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ ;;
+ --source=*)
+ __git_complete_refs --cur="${cur##--source=}"
+ ;;
+ --*)
+ __gitcomp_builtin restore
+ ;;
+ esac
+}
+
+__git_revert_inprogress_options=$__git_sequencer_inprogress_options
+
_git_revert ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
- __gitcomp "--continue --quit --abort"
+ __gitcomp "$__git_revert_inprogress_options"
return
fi
+ __git_complete_strategy && return
case "$cur" in
--*)
- __gitcomp "
- --edit --mainline --no-edit --no-commit --signoff
- --strategy= --strategy-option=
- "
+ __gitcomp_builtin revert "" \
+ "$__git_revert_inprogress_options"
return
;;
esac
@@ -2775,7 +3008,7 @@ _git_rm ()
{
case "$cur" in
--*)
- __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
+ __gitcomp_builtin rm
return
;;
esac
@@ -2818,9 +3051,18 @@ _git_show ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --color-moved=*)
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
+ return
+ ;;
+ --color-moved-ws=*)
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ return
+ ;;
--*)
- __gitcomp "--pretty= --format= --abbrev-commit --oneline
- --show-signature
+ __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
+ --oneline --show-signature --patch
+ --expand-tabs --expand-tabs= --no-expand-tabs
$__git_diff_common_options
"
return
@@ -2833,28 +3075,52 @@ _git_show_branch ()
{
case "$cur" in
--*)
- __gitcomp "
- --all --remotes --topo-order --date-order --current --more=
- --list --independent --merge-base --no-name
- --color --no-color
- --sha1-name --sparse --topics --reflog
- "
+ __gitcomp_builtin show-branch
return
;;
esac
__git_complete_revlist
}
+_git_sparse_checkout ()
+{
+ local subcommands="list init set disable"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ return
+ fi
+
+ case "$subcommand,$cur" in
+ init,--*)
+ __gitcomp "--cone"
+ ;;
+ set,--*)
+ __gitcomp "--stdin"
+ ;;
+ *)
+ ;;
+ esac
+}
+
_git_stash ()
{
local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
- local subcommands='push save list show apply clear drop pop create branch'
- local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ local subcommands='push list show apply clear drop pop create branch'
+ local subcommand="$(__git_find_on_cmdline "$subcommands save")"
+ if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
+ subcommand="push"
+ fi
if [ -z "$subcommand" ]; then
case "$cur" in
--*)
__gitcomp "$save_opts"
;;
+ sa*)
+ if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
+ __gitcomp "save"
+ fi
+ ;;
*)
if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
__gitcomp "$subcommands"
@@ -2875,6 +3141,9 @@ _git_stash ()
drop,--*)
__gitcomp "--quiet"
;;
+ list,--*)
+ __gitcomp "--name-status --oneline --patch-with-stat"
+ ;;
show,--*|branch,--*)
;;
branch,*)
@@ -2899,7 +3168,7 @@ _git_submodule ()
{
__git_has_doubledash && return
- local subcommands="add status init deinit update summary foreach sync"
+ local subcommands="add status init deinit update set-branch set-url summary foreach sync absorbgitdirs"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
case "$cur" in
@@ -2930,6 +3199,9 @@ _git_submodule ()
--force --rebase --merge --reference --depth --recursive --jobs
"
;;
+ set-branch,--*)
+ __gitcomp "--default --branch"
+ ;;
summary,--*)
__gitcomp "--cached --files --summary-limit"
;;
@@ -2960,6 +3232,7 @@ _git_svn ()
--log-window-size= --no-checkout --quiet
--repack-flags --use-log-author --localtime
--add-author-from
+ --recursive
--ignore-paths= --include-paths= $remote_opts
"
local init_opts="
@@ -3045,7 +3318,7 @@ _git_tag ()
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- -d|-v)
+ -d|--delete|-v|--verify)
__gitcomp_direct "$(__git_tags "" "$cur" " ")"
return
;;
@@ -3071,11 +3344,7 @@ _git_tag ()
case "$cur" in
--*)
- __gitcomp "
- --list --delete --verify --annotate --message --file
- --sign --cleanup --local-user --force --column --sort=
- --contains --no-contains --points-at --merged --no-merged --create-reflog
- "
+ __gitcomp_builtin tag
;;
esac
}
@@ -3085,29 +3354,128 @@ _git_whatchanged ()
_git_log
}
+__git_complete_worktree_paths ()
+{
+ local IFS=$'\n'
+ __gitcomp_nl "$(git worktree list --porcelain |
+ # Skip the first entry: it's the path of the main worktree,
+ # which can't be moved, removed, locked, etc.
+ sed -n -e '2,$ s/^worktree //p')"
+}
+
_git_worktree ()
{
- local subcommands="add list lock prune unlock"
- local subcommand="$(__git_find_on_cmdline "$subcommands")"
- if [ -z "$subcommand" ]; then
+ local subcommands="add list lock move prune remove unlock"
+ local subcommand subcommand_idx
+
+ subcommand="$(__git_find_on_cmdline --show-idx "$subcommands")"
+ subcommand_idx="${subcommand% *}"
+ subcommand="${subcommand#* }"
+
+ case "$subcommand,$cur" in
+ ,*)
__gitcomp "$subcommands"
- else
- case "$subcommand,$cur" in
- add,--*)
- __gitcomp "--detach"
- ;;
- list,--*)
- __gitcomp "--porcelain"
- ;;
- lock,--*)
- __gitcomp "--reason"
+ ;;
+ *,--*)
+ __gitcomp_builtin worktree_$subcommand
+ ;;
+ add,*) # usage: git worktree add [<options>] <path> [<commit-ish>]
+ # Here we are not completing an --option, it's either the
+ # path or a ref.
+ case "$prev" in
+ -b|-B) # Complete refs for branch to be created/reseted.
+ __git_complete_refs
;;
- prune,--*)
- __gitcomp "--dry-run --expire --verbose"
+ -*) # The previous word is an -o|--option without an
+ # unstuck argument: have to complete the path for
+ # the new worktree, so don't list anything, but let
+ # Bash fall back to filename completion.
;;
- *)
+ *) # The previous word is not an --option, so it must
+ # be either the 'add' subcommand, the unstuck
+ # argument of an option (e.g. branch for -b|-B), or
+ # the path for the new worktree.
+ if [ $cword -eq $((subcommand_idx+1)) ]; then
+ # Right after the 'add' subcommand: have to
+ # complete the path, so fall back to Bash
+ # filename completion.
+ :
+ else
+ case "${words[cword-2]}" in
+ -b|-B) # After '-b <branch>': have to
+ # complete the path, so fall back
+ # to Bash filename completion.
+ ;;
+ *) # After the path: have to complete
+ # the ref to be checked out.
+ __git_complete_refs
+ ;;
+ esac
+ fi
;;
esac
+ ;;
+ lock,*|remove,*|unlock,*)
+ __git_complete_worktree_paths
+ ;;
+ move,*)
+ if [ $cword -eq $((subcommand_idx+1)) ]; then
+ # The first parameter must be an existing working
+ # tree to be moved.
+ __git_complete_worktree_paths
+ else
+ # The second parameter is the destination: it could
+ # be any path, so don't list anything, but let Bash
+ # fall back to filename completion.
+ :
+ fi
+ ;;
+ esac
+}
+
+__git_complete_common () {
+ local command="$1"
+
+ case "$cur" in
+ --*)
+ __gitcomp_builtin "$command"
+ ;;
+ esac
+}
+
+__git_cmds_with_parseopt_helper=
+__git_support_parseopt_helper () {
+ test -n "$__git_cmds_with_parseopt_helper" ||
+ __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
+
+ case " $__git_cmds_with_parseopt_helper " in
+ *" $1 "*)
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
+__git_complete_command () {
+ local command="$1"
+ local completion_func="_git_${command//-/_}"
+ if ! declare -f $completion_func >/dev/null 2>/dev/null &&
+ declare -f _completion_loader >/dev/null 2>/dev/null
+ then
+ _completion_loader "git-$command"
+ fi
+ if declare -f $completion_func >/dev/null 2>/dev/null
+ then
+ $completion_func
+ return 0
+ elif __git_support_parseopt_helper "$command"
+ then
+ __git_complete_common "$command"
+ return 0
+ else
+ return 1
fi
}
@@ -3134,14 +3502,18 @@ __git_main ()
((c++))
done
- if [ -z "$command" ]; then
+ if [ -z "${command-}" ]; then
case "$prev" in
--git-dir|-C|--work-tree)
# these need a path argument, let's fall back to
# Bash filename completion
return
;;
- -c|--namespace)
+ -c)
+ __git_complete_config_variable_name_and_value
+ return
+ ;;
+ --namespace)
# we don't support completing these options' arguments
return
;;
@@ -3164,20 +3536,24 @@ __git_main ()
--help
"
;;
- *) __git_compute_porcelain_commands
- __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
+ *)
+ if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}"
+ then
+ __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
+ else
+ __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
+ fi
+ ;;
esac
return
fi
- local completion_func="_git_${command//-/_}"
- declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
+ __git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
- completion_func="_git_${expansion//-/_}"
- declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
+ __git_complete_command "$expansion"
fi
}
@@ -3205,76 +3581,8 @@ __gitk_main ()
__git_complete_revlist
}
-if [[ -n ${ZSH_VERSION-} ]]; then
- echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
-
- autoload -U +X compinit && compinit
-
- __gitcomp ()
- {
- emulate -L zsh
-
- local cur_="${3-$cur}"
-
- case "$cur_" in
- --*=)
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- c="$c${4-}"
- case $c in
- --*=*|*.) ;;
- *) c="$c " ;;
- esac
- array[${#array[@]}+1]="$c"
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
- }
-
- __gitcomp_direct ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -- ${=1} && _ret=0
- }
-
- __gitcomp_nl ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
- }
-
- __gitcomp_file ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
- }
-
- _git ()
- {
- local _ret=1 cur cword prev
- cur=${words[CURRENT]}
- prev=${words[CURRENT-1]}
- let cword=CURRENT-1
- emulate ksh -c __${service}_main
- let _ret && _default && _ret=0
- return _ret
- }
-
- compdef _git git gitk
+if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
+ echo "ERROR: this script is obsolete, please see git-completion.zsh" 1>&2
return
fi
@@ -3296,17 +3604,42 @@ __git_complete ()
|| complete -o default -o nospace -F $wrapper $1
}
-# wrapper for backwards compatibility
-_git ()
-{
- __git_wrap__git_main
-}
+if ! git --list-cmds=main >/dev/null 2>&1; then
-# wrapper for backwards compatibility
-_gitk ()
-{
- __git_wrap__gitk_main
-}
+ declare -A __git_cmds
+ __git_cmds[list-complete]="apply blame cherry config difftool fsck help instaweb mergetool prune reflog remote repack replace request-pull send-email show-branch stage whatchanged"
+ __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore modules namespaces remote-helpers repository-layout revisions submodules tutorial-2 tutorial workflows"
+ __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init gitk log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree"
+ __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase rebase--interactive receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree"
+ __git_cmds[others]="compare reintegrate related remote-hg remote-sync send-series smartlist"
+ __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase rebase--interactive receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree "
+
+ # Override __git
+ __git ()
+ {
+ case "$1" in
+ --list-cmds=*)
+ while read -r -d ',' x; do
+ case "$x" in
+ nohelpers)
+ ;;
+ alias)
+ ;;
+ config)
+ ;;
+ *)
+ echo ${__git_cmds[$x]}
+ ;;
+ esac
+ done <<< "${1##--list-cmds=},"
+ return
+ ;;
+ esac
+ git ${__git_C_args:+"${__git_C_args[@]}"} \
+ ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
+ }
+
+fi
__git_complete git __git_main
__git_complete gitk __gitk_main
@@ -3315,6 +3648,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
-if [[ "$OSTYPE" = cygwin* ]]; then
-__git_complete git.exe __git_main
+if [ "$OSTYPE" = cygwin ]; then
+ __git_complete git.exe __git_main
fi
diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
index fd2b049db..54e123d63 100644
--- a/plugins/gitfast/git-prompt.sh
+++ b/plugins/gitfast/git-prompt.sh
@@ -70,6 +70,15 @@
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
# is SP.
#
+# When there is an in-progress operation such as a merge, rebase,
+# revert, cherry-pick, or bisect, the prompt will include information
+# related to the operation, often in the form "|<OPERATION-NAME>".
+#
+# When the repository has a sparse-checkout, a notification of the form
+# "|SPARSE" will be included in the prompt. This can be shortened to a
+# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
+# by setting GIT_PS1_OMITSPARSESTATE.
+#
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
# find one, or @{upstream} otherwise. Once you have set
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
@@ -88,7 +97,8 @@
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
-# using __git_ps1 for PROMPT_COMMAND or precmd.
+# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
+# but always available in Zsh.
#
# If you would like __git_ps1 to do nothing in the case when the current
# directory is set up to be ignored by git, then set
@@ -286,6 +296,37 @@ __git_eread ()
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
+# see if a cherry-pick or revert is in progress, if the user has committed a
+# conflict resolution with 'git commit' in the middle of a sequence of picks or
+# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
+# the todo file.
+__git_sequencer_status ()
+{
+ local todo
+ if test -f "$g/CHERRY_PICK_HEAD"
+ then
+ r="|CHERRY-PICKING"
+ return 0;
+ elif test -f "$g/REVERT_HEAD"
+ then
+ r="|REVERTING"
+ return 0;
+ elif __git_eread "$g/sequencer/todo" todo
+ then
+ case "$todo" in
+ p[\ \ ]|pick[\ \ ]*)
+ r="|CHERRY-PICKING"
+ return 0
+ ;;
+ revert[\ \ ]*)
+ r="|REVERTING"
+ return 0
+ ;;
+ esac
+ fi
+ return 1
+}
+
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -390,6 +431,13 @@ __git_ps1 ()
return $exit
fi
+ local sparse=""
+ if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ [ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
+ [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
+ sparse="|SPARSE"
+ fi
+
local r=""
local b=""
local step=""
@@ -398,11 +446,7 @@ __git_ps1 ()
__git_eread "$g/rebase-merge/head-name" b
__git_eread "$g/rebase-merge/msgnum" step
__git_eread "$g/rebase-merge/end" total
- if [ -f "$g/rebase-merge/interactive" ]; then
- r="|REBASE-i"
- else
- r="|REBASE-m"
- fi
+ r="|REBASE"
else
if [ -d "$g/rebase-apply" ]; then
__git_eread "$g/rebase-apply/next" step
@@ -417,10 +461,8 @@ __git_ps1 ()
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
- elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
- r="|CHERRY-PICKING"
- elif [ -f "$g/REVERT_HEAD" ]; then
- r="|REVERTING"
+ elif __git_sequencer_status; then
+ :
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
@@ -467,6 +509,7 @@ __git_ps1 ()
local i=""
local s=""
local u=""
+ local h=""
local c=""
local p=""
@@ -499,6 +542,11 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
+ if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
+ h="?"
+ fi
+
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
@@ -519,8 +567,8 @@ __git_ps1 ()
b="\${__git_ps1_branch_name}"
fi
- local f="$w$i$s$u"
- local gitstring="$c$b${f:+$z$f}$r$p"
+ local f="$h$w$i$s$u"
+ local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
diff --git a/plugins/gitfast/update b/plugins/gitfast/update
index 05054245f..5311065a1 100755
--- a/plugins/gitfast/update
+++ b/plugins/gitfast/update
@@ -1,9 +1,8 @@
#!/bin/sh
-url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
-version="2.16.0"
+url="https://raw.githubusercontent.com/felipec/git-completion"
+version="1.2"
-curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
-curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
-curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
-git apply updates.patch
+curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
+curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
+curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh"
diff --git a/plugins/gitfast/updates.patch b/plugins/gitfast/updates.patch
deleted file mode 100644
index 28a31f859..000000000
--- a/plugins/gitfast/updates.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-diff --git b/plugins/gitfast/_git a/plugins/gitfast/_git
-index e2554130..a2e3bef5 100644
---- b/plugins/gitfast/_git
-+++ a/plugins/gitfast/_git
-@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
- local -a locations
- local e
- locations=(
-- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
-+ "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
- '/etc/bash_completion.d/git' # fedora, old debian
- '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
- '/usr/share/bash-completion/git' # gentoo
-@@ -214,8 +214,10 @@ _git ()
-
- if (( $+functions[__${service}_zsh_main] )); then
- __${service}_zsh_main
-- else
-+ elif (( $+functions[__${service}_main] )); then
- emulate ksh -c __${service}_main
-+ elif (( $+functions[_${service}] )); then
-+ emulate ksh -c _${service}
- fi
-
- let _ret && _default && _ret=0
-diff --git b/plugins/gitfast/git-completion.bash a/plugins/gitfast/git-completion.bash
-index 9c8f7380..14012cab 100644
---- b/plugins/gitfast/git-completion.bash
-+++ a/plugins/gitfast/git-completion.bash
-@@ -2915,6 +2915,6 @@ __git_complete gitk __gitk_main
- # when the user has tab-completed the executable name and consequently
- # included the '.exe' suffix.
- #
--if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-+if [[ "$OSTYPE" = cygwin* ]]; then
- __git_complete git.exe __git_main
- fi
-diff --git b/plugins/gitfast/git-prompt.sh a/plugins/gitfast/git-prompt.sh
-index 97eacd78..c1de34eb 100644
---- b/plugins/gitfast/git-prompt.sh
-+++ a/plugins/gitfast/git-prompt.sh
-@@ -502,9 +502,11 @@ __git_ps1 ()
-
- local z="${GIT_PS1_STATESEPARATOR-" "}"
-
-- # NO color option unless in PROMPT_COMMAND mode
-- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-- __git_ps1_colorize_gitstring
-+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
-+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
-+ __git_ps1_colorize_gitstring
-+ fi
- fi
-
- b=${b##refs/heads/}
diff --git a/plugins/github/README.md b/plugins/github/README.md
index 70b863f64..af2b8a4e7 100644
--- a/plugins/github/README.md
+++ b/plugins/github/README.md
@@ -2,8 +2,8 @@
This plugin supports working with GitHub from the command line. It provides a few things:
-* Sets up the `hub` wrapper and completions for the `git` command if you have `hub` installed.
-* Completion for the `github` Ruby gem.
+* Sets up the `hub` wrapper and completions for the `git` command if you have [`hub`](https://github.com/github/hub) installed.
+* Completion for the [`github` Ruby gem](https://github.com/defunkt/github-gem).
* Convenience functions for working with repos and URLs.
### Functions
diff --git a/plugins/globalias/README.md b/plugins/globalias/README.md
index 0b064105d..cd7fc3cb2 100644
--- a/plugins/globalias/README.md
+++ b/plugins/globalias/README.md
@@ -17,6 +17,9 @@ Then just press `SPACE` to trigger the expansion of a command you've written.
If you only want to insert a space without expanding the command line, press
`CTRL`+`SPACE`.
+if you would like to filter out any values from expanding set `GLOBALIAS_FILTER_VALUES` to
+an array of said values. See [Filtered values](#filtered-values).
+
## Examples
#### Glob expressions
@@ -37,7 +40,6 @@ $ ls folder/file.json anotherfolder/another.json
$ mkdir "`date -R`"
# expands to
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
-
```
#### Aliases
@@ -60,3 +62,18 @@ $ S<space>
# expands to:
$ sudo systemctl
```
+
+#### Filtered values
+
+```
+# .zshrc
+alias l='ls -lh'
+alias la='ls --color=auto -lah'
+GLOBALIAS_FILTER_VALUES=(l)
+
+$ l<space>
+# does not expand
+$ la<space>
+# expands to:
+$ ls --color=auto -lah
+```
diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh
index 9602a9606..bd27d589d 100644
--- a/plugins/globalias/globalias.plugin.zsh
+++ b/plugins/globalias/globalias.plugin.zsh
@@ -1,6 +1,12 @@
globalias() {
- zle _expand_alias
- zle expand-word
+ # Get last word to the left of the cursor:
+ # (z) splits into words using shell parsing
+ # (A) makes it an array even if there's only one element
+ local word=${${(Az)LBUFFER}[-1]}
+ if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
+ zle _expand_alias
+ zle expand-word
+ fi
zle self-insert
}
zle -N globalias
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index 23e00c295..539e7fe4d 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -36,7 +36,7 @@ __gnu_utils() {
gcmds+=('gfind' 'gxargs' 'glocate')
# Not part of either coreutils or findutils, installed separately.
- gcmds+=('gsed' 'gtar' 'gtime' 'gmake')
+ gcmds+=('gsed' 'gtar' 'gtime' 'gmake' 'ggrep')
for gcmd in "${gcmds[@]}"; do
# Do nothing if the command isn't found
diff --git a/plugins/go/README.md b/plugins/go/README.md
deleted file mode 100644
index bf43b9feb..000000000
--- a/plugins/go/README.md
+++ /dev/null
@@ -1 +0,0 @@
-The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead.
diff --git a/plugins/go/go.plugin.zsh b/plugins/go/go.plugin.zsh
deleted file mode 100644
index da7c87cfd..000000000
--- a/plugins/go/go.plugin.zsh
+++ /dev/null
@@ -1,3 +0,0 @@
-print -P "%F{yellow}The 'go' plugin is deprecated. Use the '%Ugolang%u' plugin instead.%f"
-
-source "$ZSH/plugins/golang/golang.plugin.zsh"
diff --git a/plugins/golang/README.md b/plugins/golang/README.md
index 0a1b43c30..af2c4dff9 100644
--- a/plugins/golang/README.md
+++ b/plugins/golang/README.md
@@ -19,6 +19,7 @@ plugins=(... golang)
| gof | `go fmt` | Gofmt formats (aligns and indents) Go programs. |
| gofa | `go fmt ./...` | Run go fmt for all packages in current directory, recursively |
| gog | `go get` | Downloads packages and then installs them to $GOPATH |
+| gog | `go get ./...` | Installs all dependencies in current directory, recursively |
| goi | `go install` | Compiles and installs packages to $GOPATH |
| gol | `go list` | Lists Go packages |
| gom | `go mod` | Access to operations on modules |
@@ -27,4 +28,5 @@ plugins=(... golang)
| gops | `cd $GOPATH/src` | Takes you to $GOPATH/src |
| gor | `go run` | Compiles and runs your code |
| got | `go test` | Runs tests |
+| gota | `go test ./...` | Runs tests in all subdirectories |
| gov | `go vet` | Vet examines Go source code and reports suspicious constructs |
diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
index 47b10988e..fce663fd6 100644
--- a/plugins/golang/golang.plugin.zsh
+++ b/plugins/golang/golang.plugin.zsh
@@ -41,7 +41,7 @@ __go_tool_complete() {
return
fi
build_flags=(
- '-a[force reinstallation of packages that are already up-to-date]'
+ '-a[force reinstallation of packages that are already up to date]'
'-n[print the commands but do not run them]'
'-p[number of parallel builds]:number'
'-race[enable data race detection]'
@@ -263,6 +263,7 @@ alias god='go doc'
alias gof='go fmt'
alias gofa='go fmt ./...'
alias gog='go get'
+alias goga='go get ./...'
alias goi='go install'
alias gol='go list'
alias gom='go mod'
@@ -271,4 +272,5 @@ alias gopb='cd $GOPATH/bin'
alias gops='cd $GOPATH/src'
alias gor='go run'
alias got='go test'
+alias gota='go test ./...'
alias gov='go vet'
diff --git a/plugins/gpg-agent/README.md b/plugins/gpg-agent/README.md
index 9c1e6d2cc..8eeb94f92 100644
--- a/plugins/gpg-agent/README.md
+++ b/plugins/gpg-agent/README.md
@@ -2,7 +2,7 @@
Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running.
-To use it, add gpg-agent to the plugins array of your zshrc file:
+To use it, add `gpg-agent` to the plugins array of your zshrc file:
```zsh
plugins=(... gpg-agent)
diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh
index 3e24c2527..0adc8de5d 100644
--- a/plugins/gpg-agent/gpg-agent.plugin.zsh
+++ b/plugins/gpg-agent/gpg-agent.plugin.zsh
@@ -1,16 +1,17 @@
-# Enable gpg-agent if it is not running-
-# --use-standard-socket will work from version 2 upwards
-
-AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
-
-if [[ ! -S $AGENT_SOCK ]]; then
- gpg-agent --daemon --use-standard-socket &>/dev/null
-fi
export GPG_TTY=$TTY
-# Set SSH to use gpg-agent if it's enabled
-GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
-if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then
- export SSH_AUTH_SOCK="$AGENT_SOCK.ssh"
+# Fix for passphrase prompt on the correct tty
+# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
+function _gpg-agent_update-tty_preexec {
+ gpg-connect-agent updatestartuptty /bye &>/dev/null
+}
+autoload -U add-zsh-hook
+add-zsh-hook preexec _gpg-agent_update-tty_preexec
+
+# If enable-ssh-support is set, fix ssh agent integration
+if [[ $(gpgconf --list-options gpg-agent | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
unset SSH_AGENT_PID
+ if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
+ export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
+ fi
fi
diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle
index 647626615..e77b23cdb 100644
--- a/plugins/gradle/_gradle
+++ b/plugins/gradle/_gradle
@@ -116,9 +116,9 @@ __gradle-generate-tasks-cache() {
# Reuse Gradle Daemon if IDLE but don't start a new one.
local gradle_tasks_output
if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then
- gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file -q tasks --all 2>/dev/null)"
+ gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)"
else
- gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file -q tasks --all 2>/dev/null)"
+ gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)"
fi
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
local -a match
diff --git a/plugins/grc/README.md b/plugins/grc/README.md
new file mode 100644
index 000000000..515e87640
--- /dev/null
+++ b/plugins/grc/README.md
@@ -0,0 +1,15 @@
+# Generic Colouriser plugin
+
+This plugin adds wrappers for commands supported by [Generic Colouriser](https://github.com/garabik/grc):
+
+To use it, add `grc` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... grc)
+```
+
+## Commands
+
+The plugin sources the bundled alias generator from the installation, available at `/etc/grc.zsh`.
+The complete list of wrapped commands may vary depending on the installed version of `grc`, look
+at the file mentioned above (`/etc/grc.zsh`) to see which commands are wrapped.
diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh
new file mode 100644
index 000000000..b709b9e02
--- /dev/null
+++ b/plugins/grc/grc.plugin.zsh
@@ -0,0 +1,17 @@
+#!/usr/bin/env zsh
+
+# common grc.zsh paths
+files=(
+ /etc/grc.zsh # default
+ /usr/local/etc/grc.zsh # homebrew
+)
+
+# verify the file is readable and source it
+for file in $files; do
+ if [[ -r "$file" ]]; then
+ source "$file"
+ break
+ fi
+done
+
+unset file files
diff --git a/plugins/hanami/README.md b/plugins/hanami/README.md
index 3ac8defbb..c9e09f4f2 100644
--- a/plugins/hanami/README.md
+++ b/plugins/hanami/README.md
@@ -1,32 +1,45 @@
-# Hanami Plugin #
-This plugin adds convenient ways to work with [Hanami](https://hanamirb.org/) via console.
+# Hanami Plugin
+
+This plugin adds convenient aliases to work with [Hanami](https://hanamirb.org/) via console.
It's inspired by Rails plugin, so if you've used it, you'll feel like home.
-## Usage ##
+To use it, add `hanami` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... hanami)
+```
+
+## Usage
For example, type `hc` into your console when you're within Hanami project directory to run
the application console. Have a look at available shortcuts below. You can read more about
these commands [on the official website](https://hanamirb.org/guides/command-line/applications/).
-## Aliases ##
-
-| Alias | Command | Description |
-|-------|---------------------------|---------------------------------------------------------|
-| HED | HANAMI_ENV=development | Set environment variable HANAMI_ENV to development |
-| HEP | HANAMI_ENV=production | Set environment variable HANAMI_ENV to production |
-| HET | HANAMI_ENV=test | Set environment variable HANAMI_ENV to test |
-| hc | hanami console | Run application console |
-| hd | hanami destroy | Remove specified hanami resource |
-| hg | hanami generate | Create specified hanami resource |
-| hgm | hanami generate migration | Create migration file |
-| hs | hanami server | Launch server with hanami application |
-| hsp | hanami server -p | Launch server with specified port |
-| hr | hanami routes | List application routes |
-| hdc | hanami db create | Create application database |
-| hdd | hanami db drop | Delete application database |
-| hdp | hanami db prepare | Prepare database for the current environment |
-| hda | hanami db apply | Recreates a fresh schema after migrations (destructive) |
-| hdv | hanami db version | Print current database version |
-| hdrs | hdd && hdp | Drop and recreate application database |
-| hdtp | HET hdp | Actualize test environment database |
-| hrg | hr &#124; grep | Grep hanami routes with specified pattern |
+## Aliases
+
+| Alias | Command | Description |
+|-------|-----------------------------|---------------------------------------------------------|
+| HED\* | `HANAMI_ENV=development` | Set environment variable HANAMI_ENV to development |
+| HEP\* | `HANAMI_ENV=production` | Set environment variable HANAMI_ENV to production |
+| HET\* | `HANAMI_ENV=test` | Set environment variable HANAMI_ENV to test |
+| hc | `hanami console` | Run application console |
+| hd | `hanami destroy` | Remove specified hanami resource |
+| hg | `hanami generate` | Create specified hanami resource |
+| hgm | `hanami generate migration` | Create migration file |
+| hs | `hanami server` | Launch server with hanami application |
+| hsp | `hanami server -p` | Launch server with specified port |
+| hr | `hanami routes` | List application routes |
+| hdc | `hanami db create` | Create application database |
+| hdd | `hanami db drop` | Delete application database |
+| hdp | `hanami db prepare` | Prepare database for the current environment |
+| hda | `hanami db apply` | Recreates a fresh schema after migrations (destructive) |
+| hdv | `hanami db version` | Print current database version |
+| hdrs | `hdd && hdp` | Drop and recreate application database |
+| hdtp | `HET hdp` | Actualize test environment database |
+| hrg | `hr | grep` | Grep hanami routes with specified pattern |
+
+\* You should use these at the beginning of a command, for example:
+
+```console
+$ HED hdd # equivalent to 'HANAMI_ENV=development hanami db drop'
+```
diff --git a/plugins/hanami/hanami.plugin.zsh b/plugins/hanami/hanami.plugin.zsh
index 349c42cae..42143b428 100644
--- a/plugins/hanami/hanami.plugin.zsh
+++ b/plugins/hanami/hanami.plugin.zsh
@@ -1,6 +1,6 @@
-alias -g HED='HANAMI_ENV=development'
-alias -g HEP='HANAMI_ENV=production'
-alias -g HET='HANAMI_ENV=test'
+alias HED='HANAMI_ENV=development '
+alias HEP='HANAMI_ENV=production '
+alias HET='HANAMI_ENV=test '
alias hc='hanami console'
alias hd='hanami destroy'
diff --git a/plugins/hitchhiker/.gitignore b/plugins/hitchhiker/.gitignore
new file mode 100644
index 000000000..63c2b54c4
--- /dev/null
+++ b/plugins/hitchhiker/.gitignore
@@ -0,0 +1 @@
+fortunes/hitchhiker.dat
diff --git a/plugins/hitchhiker/README.md b/plugins/hitchhiker/README.md
new file mode 100644
index 000000000..d12a1e93f
--- /dev/null
+++ b/plugins/hitchhiker/README.md
@@ -0,0 +1,44 @@
+# hitchhiker
+
+This plugin adds quotes from The Hitchhiker's Guide to the Galaxy, from Douglas Adams.
+
+To use it, add `hitchhiker` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... hitchhiker)
+```
+
+## Aliases
+
+- `hitchhiker`: displays a quote from the book using `fortune`.
+- `hitchhiker_cow`: displays a quote from the book using `cowthink`.
+
+```console
+$ hitchhiker_cow
+ _______________________________________
+( "OK, so ten out of ten for style, but )
+( minus several million for good )
+( thinking, yeah? " )
+ ---------------------------------------
+ o ^__^
+ o (oo)\_______
+ (__)\ )\/\
+ ||----w |
+ || ||
+```
+
+## Requirements
+
+- `fortune` and `strfile`.
+- `cowthink` if using the `hitchhiker_cow` command.
+
+## Credits
+
+Fortune file: Andreas Gohr <andi@splitbrain.org> ([splitbrain.org](https://www.splitbrain.org/projects/fortunes/hg2g))
+
+Spelling and formatting fixes: grok@resist.ca
+
+Original quotes from:
+
+- https://web.archive.org/web/20120106083254/http://tatooine.fortunecity.com/vonnegut/29/hitch/parhaat.html
+- https://web.archive.org/web/20011112065737/http://www-personal.umd.umich.edu/~nhughes/dna/faqs/quotedir.html
diff --git a/plugins/hitchhiker/fortunes/hitchhiker b/plugins/hitchhiker/fortunes/hitchhiker
new file mode 100644
index 000000000..825b86cd6
--- /dev/null
+++ b/plugins/hitchhiker/fortunes/hitchhiker
@@ -0,0 +1,275 @@
+"`...You hadn't exactly gone out of your way to call attention to them had you? I mean like actually telling anyone or anything.' `But the plans were on display...' `On display? I eventually had to go down to the cellar to find them.' `That's the display department.' `With a torch.' `Ah, well the lights had probably gone.' `So had the stairs.' `But look you found the notice didn't you?' `Yes,' said Arthur, `yes I did. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of The Leopard".'"
+
+- Arthur singing the praises of the local council planning department.
+%
+"`Time is an illusion. Lunchtime doubly so.' `Very deep,' said Arthur, `you should send that in to the "Reader's Digest". They've got a page for people like you.'"
+
+- Ford convincing Arthur to drink three pints in ten minutes at lunchtime.
+%
+"`This must be Thursday,' said Arthur to himself, sinking low over his beer, `I never could get the hang of Thursdays.'"
+
+- Arthur, on what was to be his last Thursday on Earth.
+%
+"Pages one and two [of Zaphod's presidential speech] had been salvaged by a Damogran Frond Crested Eagle and had already become incorporated into an extraordinary new form of nest which the eagle had invented. It was constructed largely of papier mache and it was virtually impossible for a newly hatched baby eagle to break out of it. The Damogran Frond Crested Eagle had heard of the notion of survival of the species but wanted no truck with it."
+
+- An example of Damogran wildlife.
+%
+"`How do you feel?' he asked him. `Like a military academy,' said Arthur, `bits of me keep passing out.'" .... `We're safe,' he said. `Oh good,' said Arthur. `We're in a small galley cabin,' said Ford, `in one of the spaceships of the Vogon Constructor Fleet.' `Ah,' said Arthur, `this is obviously some strange usage of the word "safe" that I wasn't previously aware of.'
+
+- Arthur after his first ever teleport ride.
+%
+"`The best way to get a drink out of a Vogon is to stick your finger down his throat...'"
+
+- The Book, on one of the Vogon's social inadequacies.
+%
+"`You'd better be prepared for the jump into hyperspace. It's unpleasantly like being drunk.' `What's so unpleasant about being drunk?' `You ask a glass of water.'"
+
+- Arthur getting ready for his first jump into hyperspace.
+%
+"`You know,' said Arthur, `it's at times like this, when I'm trapped in a Vogon airlock with a man from Betelgeuse, and about to die from asphyxiation in deep space that I really wish I'd listened to what my mother told me when I was young.' `Why, what did she tell you?' `I don't know, I didn't listen.'"
+
+- Arthur coping with certain death as best as he could.
+%
+"`Ford, you're turning into a penguin. Stop it.'"
+
+- Arthur experiences the improbability drive at work.
+%
+"`I think you ought to know that I'm feeling very depressed.'" "`Life, don't talk to me about life.'" "`Here I am, brain the size of a planet and they ask me to take you down to the bridge. Call that "job satisfaction"? 'Cos I don't.'" "`I've got this terrible pain in all the diodes down my left side.'"
+
+- Guess who.
+%
+"`If there's anything more important than my ego around, I want it caught and shot now.'"
+
+- Zaphod.
+%
+"`In those days spirits were brave, the stakes were high, men were REAL men, women were REAL women, and small furry creatures from Alpha Centauri were REAL small furry creatures from Aplha Centauri.'"
+
+- The Book getting all nostalgic.
+%
+"`Hey this is terrific!' Zaphod said. `Someone down there is trying to kill us!' `Terrific,' said Arthur. `But don't you see what this means?' `Yes. We are going to die.' `Yes, but apart from that.' `APART from that?' `It means we must be on to something!' `How soon can we get off it?'"
+
+- Zaphod and Arthur in a certain death situation over Magrathea.
+%
+"And wow! Hey! What's this thing coming towards me very fast? Very very fast. So big and flat and round, it needs a big wide sounding word like... ow... ound... round... ground! That's it! That's a good name - ground! I wonder if it will be friends with me?"
+
+- For the sperm whale, it wasn't.
+%
+"Oh no, not again."
+
+- A bowl of petunias on it's way to certain death.
+%
+"`Er, hey Earthman...' `Arthur,' said Arthur. `Yeah, could you just sort of keep this robot with you and guard this end of the passageway. OK?' `Guard?' said Arthur. `What from? You just said there's no one here.' `Yeah, well, just for safety, OK?' said Zaphod. `Whose? Yours or mine?'"
+
+- Arthur drawing the short straw on Magrathea.
+%
+"There are of course many problems connected with life, of which some of the most popular are `Why are people born?' `Why do they die?' `Why do they spend so much of the intervening time wearing digital watches?'"
+
+- The Book.
+%
+"`Right,' said Ford, `I'm going to have a look.' He glanced round at the others. `Is no one going to say, "No you can't possibly, let me go instead"?' They all shook their heads. `Oh well.'"
+
+- Ford attempting to be heroic whilst being seiged by Shooty and Bangbang.
+%
+"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - The Book just recapping what happened in the last book. "`I am so amazingly cool you could keep a side of meat in me for a month. I am so hip I have difficulty seeing over my pelvis.'"
+
+- Zaphod being cool.
+%
+"`You ARE Zaphod Beeblebrox?' `Yeah,' said Zaphod, `but don't shout it out or they'll all want one.' `THE Zaphod Beeblebrox?' `No, just A Zaphod Bebblebrox, didn't you hear I come in six packs?' `But sir,' it squealed, `I just heard on the sub-ether radio report. It said you were dead...' `Yeah, that's right, I just haven't stopped moving yet.'"
+
+- Zaphod and the Guide's receptionist.
+%
+"The fronting for the eighty-yard-long marble-topped bar had been made by stitching together nearly twenty thousand Antarean Mosaic Lizard skins, despite the fact that the twenty thousand lizards concerned had needed them to keep their insides in."
+
+- The Book decribing Milliways' politically incorrect decor.
+%
+"`...and the Universe,' continued the waiter, determined not to be deflected on his home stretch, `will explode later for your pleasure.' Ford's head swivelled slowly towards him. He spoke with feeling. `Wow,' he said, `What sort of drinks do you serve in this place?' The waiter laughed a polite little waiter's laugh. `Ah,' he said, `I think sir has perhaps misunderstood me.' `Oh, I hope not,' breathed Ford."
+
+- Ford in paradise.
+%
+"Zaphod grinned two manic grins, sauntered over to the bar and bought most of it."
+
+- Zaphod in paradise.
+%
+"`Maybe somebody here tipped off the Galactic Police,' said Trillian. `Everybody saw you come in.' `You mean they want to arrest me over the phone?' said Zaphod, `Could be. I'm a pretty dangerous dude when I'm cornered.' `Yeah,' said a voice from under the table [Ford's now completely rat-arsed at this point], `you go to pieces so fast people get hit by the shrapnel.'"
+
+- Zaphod getting paranoid over a phone call.
+%
+"`Hand me the rap-rod, Plate Captain.' The little waiter's eyebrows wandered about his forehead in confusion. `I beg your pardon, sir?' he said. `The phone, waiter,' said Zaphod, grabbing it off him. `Shee, you guys are so unhip it's a wonder your bums don't fall off.'"
+
+- Zaphod discovers that waiters are the least hip people in the Universe.
+%
+"The main reception foyer was almost empty but Ford nevertheless weaved his way through it."
+
+- Ford making his way out of Milliways whilst under the influence of enough alcohol to make a rhino sing.
+%
+"`The first ten million years were the worst,' said Marvin, `and the second ten million, they were the worst too. The third ten million I didn't enjoy at all. After that I went into a bit of a decline.'"
+
+- Marvin reflecting back on his 576,000,003,579 year career as Milliways' car park attendent.
+%
+"`Incidentally,' he said, `what does teleport mean?' Another moment passed. Slowly, the others turned to face him. `Probably the wrong moment to ask,' said Arthur, `It's just I remember you use the word a short while ago and I only bring it up because...' `Where,' said Ford quietly, `does it say teleport?' `Well, just over here in fact,' said Arthur, pointing at a dark control box in the rear of the cabin, `Just under the word "emergency", above the word "system" and beside the sign saying "out of order".'"
+
+- Arthur finding an escape route from a certain death situation.
+%
+"I teleported home one night With Ron and Sid and Meg. Ron stole Meggie's heart away And I got Sidney's leg."
+
+- A poem about matter transference beams.
+%
+"Anyone who is capable of getting themselves made President should on no account be allowed to do the job."
+
+- Some wisdom from The Book.
+%
+"`We've got to find out what people want from fire, how they relate to it, what sort of image it has for them.' The crowd were tense. They were expecting something wonderful from Ford. `Stick it up your nose,' he said. `Which is precisely the sort of thing we need to know,' insisted the girl, `Do people want fire that can be fitted nasally?'"
+
+- Ford "debating" what to do with fire with a marketing girl.
+%
+"The story goes that I first had the idea for THHGTTG while lying drunk in a field in Innsbruck (or `Spain' as the BBC TV publicity department authoritatively has it, probably because it's easier to spell)." - Foreward by DNA.
+
+FORD Six pints of bitter. And quickly please, the world's about to end. BARMAN Oh yes, sir? Nice weather for it.
+%
+BOOK Meanwhile, the starship has landed on the surface of Magrathea and Trillian is about to make one of the most important statements of her life. Its importance is not immediately recognised by her companions. TRILL. Hey, my white mice have escaped. ZAPHOD Nuts to your white mice.
+%
+BOOK ...Man had always assumed that he was more intelligent than dolphins because he had achieved so much... the wheel, New York, wars, and so on, whilst all the dolphins had ever done was muck about in the water having a good time. But conversely the dolphins believed themselves to be more intelligent than man for precisely the same reasons.
+%
+ARTHUR What is an Algolian Zylatburger anyway? FORD They're a kind of meatburger made from the most unpleasant parts of a creature well known for its total lack of any pleasant parts. ARTHUR So you mean that the Universe does actually end not with a bang but with a Wimpy?
+
+- Cut dialogue from Fit the Fifth.
+%
+BOOK There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarrely inexplicable. There is another theory which states that this has already happened.
+
+- Introduction to Fit the Seventh.
+%
+FORD Tell me Arthur... ARTHUR Yes? FORD This boulder we're stuck under, how big would you say it was? Roughly? ARTHUR Oh, about the size of Coventry Cathedral. FORD Do you think we could move it? (Arthur doesn't reply) Just asking.
+
+- Ford and Arthur in a tricky situation, Fit the Eighth.
+%
+BOOK What to do if you find yourself stuck in a crack in the ground underneath a giant boulder you can't move, with no hope of rescue. Consider how lucky you are that life has been good to you so far. Alternatively, if life hasn't been good to you so far, which given your current circumstances seems more likely, consider how lucky you are that it won't be troubling you much longer.
+
+- Comforting advice for Ford and Arthur in this current situation, Fit the Eighth.
+%
+ZAPHOD Hey, this rock... FORD Marble... ZAPHOD Marble... FORD Ice-covered marble... ZAPHOD Right... it's as slippery as... as... What's the slipperiest thing you can think of? FORD At the moment? This marble. ZAPHOD Right. This marble is as slippery as this marble.
+
+- Zaphod and Ford trying to get a grip on things in Brontitall, Fit the Tenth.
+%
+ARTHUR It's not a question of whose habitat it is, it's a question of how hard you hit it.
+
+- Arthur pointing out one of the disadvantages of gravity, Fit the Tenth.
+%
+ARTHUR It probably seems a terrible thing to say, but you know what I sometimes think would be useful in these situations? LINT. What? ARTHUR A gun of some sort. LINT.2 Will this help? ARTHUR What is it? LINT.2 A gun of some sort. ARTHUR Oh, that'll help. Can you make it fire? LINT. Er... F/X DEAFENING ROAR LINT. Yes.
+
+- Arthur and the Lintillas gaining the upper hand, Fit the Twelfth.
+%
+"He stood up straight and looked the world squarely in the fields and hills. To add weight to his words he stuck the rabbit bone in his hair. He spread his arms out wide. `I will go mad!' he announced."
+
+- Arthur discovering a way of coping with life on Prehistoric Earth.
+%
+"`... then I decided that I was a lemon for a couple of weeks. I kept myself amused all that time jumping in and out of a gin and tonic.' Arthur cleared his throat, and then did it again. `Where,' he said, `did you...?' `Find a gin and tonic?' said Ford brightly. `I found a small lake that thought it was a gin and tonic, and jumped in and out of that. At least, I think it thought it was a gin and tonic.' `I may,' he addded with a grin which would have sent sane men scampering into the trees, `have been imagining it.'"
+
+- Ford updating Arthur about what he's been doing for the past four years.
+%
+"`Eddies,' said Ford, `in the space-time continuum.' `Ah,' nodded Arthur, `is he? Is he?'"
+
+- Arthur failing in his first lesson of galactic physics in four years.
+%
+"Ford grabbed him by the lapels of his dressing gown and spoke to him as slowly and distinctly and patiently as if he were somebody from a telephone company accounts department."
+
+- Ford trying to rectify that situation.
+%
+"...[Arthur] leapt to his feet like an author hearing the phone ring..."
+
+- Who says that the character of Arthur isn't autobiographical?
+%
+"Arthur's consciousness approached his body as from a great distance, and reluctantly. It had had some bad times in there. Slowly, nervously, it entered and settled down into its accustomed position. Arthur sat up. `Where am I?' he said. `Lord's Cricket Ground,' said Ford. `Fine,' said Arthur, and his consciousness stepped out again for a quick breather. His body flopped back on the grass."
+
+- Arthur coping with his return to Earth as best as he could.
+%
+"`A curse,' said Slartibartfast, `which will engulf the Galaxy in fire and destruction, and possibly bring the Universe to a premature doom. I mean it,' he added. `Sounds like a bad time,' said Ford, `with luck I'll be drunk enough not to notice.'"
+
+- Ford ensuring everyone knew where his priorities lay.
+%
+"`My doctor says that I have a malformed public-duty gland and a natural deficiency in moral fibre, and that I am therefore excused from saving Universes.'"
+
+- Ford's last-ditch attempt to get out of helping Slartibartfast.
+%
+"Trillian did a little research in the ship's copy of THHGTTG. It had some advice to offer on drunkenness. `Go to it,' it said, `and good luck.' It was cross-referenced to the entry concerning the size of the Universe and ways of coping with that."
+
+- One of the more preferable pieces of advice contained in the Guide.
+%
+"His eyes seemed to be popping out of his head. He wasn't certain if this was because they were trying to see more clearly, or if they simply wanted to leave at this point."QUOTEHERESTRINGMAGIC1234- Arthur trying to see who had diverted him from going to a party.
+%
+"Arthur yawed wildly as his skin tried to jump one way and his skeleton the other, whilst his brain tried to work out which of his ears it most wanted to crawl out of. `Bet you weren't expecting to see me again,' said the monster, which Arthur couldn't help thinking was a strange remark for it to make, seeing as he had never met the creature before. He could tell that he hadn't met the creature before from the simple fact that he was able to sleep at nights."QUOTEHERESTRINGMAGIC1234- Arthur discovering who had diverted him from going to a party.
+%
+"`That young girl is one of the least benightedly unintelligent organic life forms it has been my profound lack of pleasure not to be able to avoid meeting.'"QUOTEHERESTRINGMAGIC1234- Marvin's first ever compliment about anybody.
+%
+"Arthur hoped and prayed that there wasn't an afterlife. Then he realised there was a contradiction there and merely hoped that there wasn't an afterlife."QUOTEHERESTRINGMAGIC1234- Arthur realising that he's in a certain death situation with a supernova bomb that is shaped like a cricket ball.
+%
+"`Credit?' he said. `Aaaargggh...' These two words are usually coupled together in the Old Pink Dog Bar."QUOTEHERESTRINGMAGIC1234- Ford in a spot of bother.
+%
+"`...we might as well start with where your hand is now.' Arthur said, `So which way do I go?' `Down,' said Fenchurch, `on this occasion.' He moved his hand. `Down,' she said, `is in fact the other way.' `Oh yes.'"QUOTEHERESTRINGMAGIC1234- Arthur trying to discover which part of Fenchurch is wrong.
+%
+"There was a point to this story, but it has temporarily escaped the chronicler's mind."QUOTEHERESTRINGMAGIC1234- This line perhaps best sums up the whole book.
+%
+"The last time anybody made a list of the top hundred character attributes of New Yorkers, common sense snuck in at number 79. .... When it's fall in New York, the air smells as if someone's been frying goats in it, and if you are keen to breathe the best plan is to open a window and stick your head in a building."QUOTEHERESTRINGMAGIC1234- Nuff said??
+%
+"`What's been happening here?' he demanded. `Oh just the nicest things, sir, just the nicest things. can I sit on your lap please?'" "`Colin, I am going to abandon you to your fate.' `I'm so happy.'" "`It will be very, very nasty for you, and that's just too bad. Got it?' `I gurgle with pleasure.'"QUOTEHERESTRINGMAGIC1234- Ford and Colin the robot.
+%
+"What the hell, he thought, you're only young once, and threw himself out of the window. That would at least keep the element of surprise on his side."QUOTEHERESTRINGMAGIC1234- Ford outwitting a Vogon with a rocket launcher by going into another certain death situation.
+%
+"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."QUOTEHERESTRINGMAGIC1234- One of the laws of computers and programming revealed.
+%
+"`You know they've reintroduced the death penalty for insurance company directors?' `Really?' said Arthur. `No I didn't. For what offence?' Trillian frowned. `What do you mean, offence?' `I see.'"QUOTEHERESTRINGMAGIC1234- Evidence that there will be some justice in the Universe eventually.
+%
+"`She hit me on the head with the rock again.' `I think I can confirm that that was my daughter.' `Sweet kid.' `You have to get to know her,' said Arthur. `She eases up does she?' `No,' said Arthur, `but you get a better sense of when to duck.'"QUOTEHERESTRINGMAGIC1234- Ford and Arthur on Random.
+%
+"Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun. "
+%
+"Ah, " said Arthur, "this is obviously some strange usage of the word safe that I wasn't previously aware of. "
+%
+"I don't know, " said the voice on the PA, "apathetic bloody planet, I've no sympathy at all. "
+%
+"Now it is such a bizarrely improbable coincidence that anything so mindboggingly useful could have evolved purely by chance that some thinkers have chosen to see it as the final and clinching proof of the non-existence of God. "The argument goes something like this: `I refuse to prove that I exist,' says God, `for proof denies faith, and without faith I am nothing.' "`But,' says Man, `The Babel fish is a dead giveaway, isn't it? It could not have evolved by chance. It proves you exist, and so therefore, by your own arguments, you don't. QED.'
+%
+"Prostetnic Vogon Jeltz smiled very slowly. This was done not so much for effect as because he was trying to remember the sequence of muscle movements. "
+%
+"OK, so ten out of ten for style, but minus several million for good thinking, yeah? "
+%
+"In those days spirits were brave, the stakes were high, men were real men, women were real women, and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri. "
+%
+"For a moment, nothing happened. Then, after a second or so, nothing continued to happen. "
+%
+(aikamuotojen k�ytt� aikamatkustuksessa) "You can arrive (mayan arivan on-when) for any sitting you like without prior (late fore-when) reservation because you can book retrospectively, as it were when you return to your own time. (you can have on-book haventa forewhen presooning returningwenta retrohome.) "
+%
+"The suit into which the man's body had been stuffed looked as if it's only purpose in life was to demonstrate how difficult it was to get this sort of body into a suit. "
+%
+"He dropped his voice still lower. In the stillness, a fly would not have dared clear its throat. "
+%
+"And finally, " said Max, quieting the audience down and putting on his solemn face, "finally I believe we have with us here tonight, a party of believers, very devout believers, from the Church of the Second Coming of the Great Prophet Zarquon. " ... "There they are, " said Max, "sitting there, patiently. He said he'd come again, and he's kept you waiting a long time, so let's hope he's hurrying fellas, because he's only got eight minutes left! "
+%
+"As he came into the light they could see his black and gold uniform on which the buttons were so highly polished that they shone with an intensity that would have made an approaching motorist flash his lights in annoyance. "
+%
+"You're very sure of your facts, " he said at last, "I couldn't trust the thinking of a man who takes the Universe - if there is one - for granted. "
+%
+"What are you talking about? " "Never mind, eat the fruit. " "You know, this place almost looks like the Garden of Eden. " "Eat the fruit. " "Sounds quite like it too. "
+%
+"Rome wasn't burned in a day. "
+%
+"Does it worry you that you don't talk any kind of sense? "
+%
+"One's never alone with a rubber duck. "
+%
+"Another world, another day, another dawn. "
+%
+"He expanded his chest to make it totally clear that here was the sort of man you only dared to cross if you had a team of Sherpas with you. "
+%
+"It was real. At least, if it wasn't real, it did support them, and as that is what sofas are supposed to do, this, by any test that mattered, was a real sofa. "
+%
+Arthur said, "So which way do I go? " "Down, " said Fenchurch, "on this occasion. " He moved his hand. "Down, " she said, "is in fact the other way. " "Oh yes. "
+%
+"You're one hundred percent positive that the ship which is crashed on the bottom of this ocean is the ship which you said you were one hundred percent positive could one hundred percent positively never crash? "
+%
+"Yes, it's the right planet, all right, " he said again. "Right planet, wrong universe. "
+%
+"Ford had his own code of ethics. It wasn't much of one, but it was his and he stuck by it, more or less. One rule he made was never to buy his own drinks. He wasn't sure if that counted as an ethic, but you have to go with what you've got. "
+%
+"Arthur felt at a bit of a loss. There was a whole Galaxy of stuff out there for him, and he wondered if it was churlish of him to complain to himself that it lacked just two things: the world he was born on and the woman he loved. "
+%
+"What was the self-sacrifice? " "I jettisoned half of a much loved and I think irreplaceable pair of shoes. " "Why was that self-sacrifice? " "Because they were mine! " said Ford crossly. "I think we have different value systems. " "Well mine's better. " "That's according to your... oh never mind. "
diff --git a/plugins/hitchhiker/hitchhiker.plugin.zsh b/plugins/hitchhiker/hitchhiker.plugin.zsh
new file mode 100644
index 000000000..aeafaf01e
--- /dev/null
+++ b/plugins/hitchhiker/hitchhiker.plugin.zsh
@@ -0,0 +1,23 @@
+HITCHHIKER_DIR="${0:h}/fortunes"
+
+# Aliases
+alias hitchhiker="fortune -a $HITCHHIKER_DIR"
+alias hitchhiker_cow="hitchhiker | cowthink"
+
+() {
+ # Don't generate hitchhiker.dat if it exists and is up-to-date
+ if [[ -f "$HITCHHIKER_DIR/hitchhiker.dat" ]] && ! [[ "$HITCHHIKER_DIR/hitchhiker.dat" -ot "$HITCHHIKER_DIR/hitchhiker" ]]; then
+ return
+ fi
+
+ # If strfile is not found: some systems install strfile in /usr/sbin but it's not in $PATH
+ if ! command -v strfile &>/dev/null && ! [[ -f /usr/sbin/strfile ]]; then
+ echo "[oh-my-zsh] hitchhiker depends on strfile, which is not installed" >&2
+ echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
+ return
+ fi
+
+ "${commands[strfile]:-/usr/sbin/strfile}" "$HITCHHIKER_DIR/hitchhiker" "$HITCHHIKER_DIR/hitchhiker.dat" >/dev/null
+}
+
+unset HITCHHIKER_DIR
diff --git a/plugins/httpie/README.md b/plugins/httpie/README.md
index 25bdd0c7d..40d60c47d 100644
--- a/plugins/httpie/README.md
+++ b/plugins/httpie/README.md
@@ -11,4 +11,10 @@ plugins=(... httpie)
It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions).
+## Aliases
+
+| Alias | Command |
+| ------------ | ---------------------------------------------------------------- |
+| `https` | `http --default-scheme=https` |
+
**Maintainer:** [lululau](https://github.com/lululau)
diff --git a/plugins/httpie/httpie.plugin.zsh b/plugins/httpie/httpie.plugin.zsh
new file mode 100644
index 000000000..088a1f1cf
--- /dev/null
+++ b/plugins/httpie/httpie.plugin.zsh
@@ -0,0 +1,7 @@
+#
+# Aliases
+# (sorted alphabetically)
+#
+
+alias https='http --default-scheme=https'
+
diff --git a/plugins/invoke/README.md b/plugins/invoke/README.md
new file mode 100644
index 000000000..3f4b88078
--- /dev/null
+++ b/plugins/invoke/README.md
@@ -0,0 +1,10 @@
+# Invoke plugin
+
+This plugin adds completion for [invoke](https://github.com/pyinvoke/invoke).
+
+To use it, add `invoke` to the plugins array in your `~/.zshrc` file:
+
+```zsh
+plugins=(... invoke)
+```
+
diff --git a/plugins/invoke/invoke.plugin.zsh b/plugins/invoke/invoke.plugin.zsh
new file mode 100644
index 000000000..8c807de02
--- /dev/null
+++ b/plugins/invoke/invoke.plugin.zsh
@@ -0,0 +1,5 @@
+# Autocompletion for invoke.
+#
+if [ $commands[invoke] ]; then
+ source <(invoke --print-completion-script=zsh)
+fi
diff --git a/plugins/ipfs/LICENSE b/plugins/ipfs/LICENSE
new file mode 100644
index 000000000..cf84491bb
--- /dev/null
+++ b/plugins/ipfs/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Angel Ramboi
+
+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/plugins/ipfs/README.md b/plugins/ipfs/README.md
new file mode 100644
index 000000000..0808a26c1
--- /dev/null
+++ b/plugins/ipfs/README.md
@@ -0,0 +1,17 @@
+# zsh-ipfs
+
+zsh completion plugin for [The InterPlanetary File System (IPFS)][1]
+
+Please submit issues and pull requests to the [main zsh-ipfs repo][2].
+
+### About
+
+[IPFS (InterPlanetary File System)][1] is a peer-to-peer hypermedia protocol
+designed to make the web faster, safer, and more open.
+
+### License
+
+See: https://github.com/hellounicorn/zsh-ipfs/blob/master/LICENSE
+
+[1]: http://ipfs.io/
+[2]: https://github.com/hellounicorn/zsh-ipfs
diff --git a/plugins/ipfs/_ipfs b/plugins/ipfs/_ipfs
new file mode 100644
index 000000000..9ee8bd79c
--- /dev/null
+++ b/plugins/ipfs/_ipfs
@@ -0,0 +1,717 @@
+#compdef ipfs
+#autoload
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'add:Add a file or directory to ipfs.'
+ 'bitswap:Interact with the bitswap agent.'
+ 'block:Interact with raw IPFS blocks.'
+ 'bootstrap:Show or edit the list of bootstrap peers.'
+ 'cat:Show IPFS object data.'
+ 'cid:Convert and discover properties of CIDs'
+ 'commands:List all available commands.'
+ 'config:Get and set ipfs config values.'
+ 'daemon:Run a network-connected IPFS node.'
+ 'dag:Interact with ipld dag objects. (experimental)'
+ 'dht:Issue commands directly through the DHT.'
+ 'diag:Generate diagnostic reports.'
+ 'dns:Resolve DNS links.'
+ 'files:Interact with unixfs files.'
+ 'filestore:Interact with filestore objects. (experimental)'
+ 'get:Download IPFS objects.'
+ 'id:Show ipfs node id info.'
+ 'init:Initializes ipfs config file.'
+ 'key:Create and list IPNS name keypairs.'
+ 'log:Interact with the daemon log output.'
+ 'ls:List directory contents for Unix filesystem objects.'
+ 'mount:Mounts IPFS to the filesystem (read-only).'
+ 'name:Publish and resolve IPNS names.'
+ 'object:Interact with IPFS objects.'
+ 'p2p:Libp2p stream mounting.'
+ 'pin:Pin (and unpin) objects to local storage.'
+ 'ping:Send echo request packets to IPFS hosts.'
+ 'refs:List links (references) from an object.'
+ 'repo:Manipulate the IPFS repo.'
+ 'resolve:Resolve the value of names to IPFS.'
+ 'stats:Query IPFS statistics.'
+ 'swarm:Interact with the swarm.'
+ 'tar:Utility functions for tar files in ipfs.'
+ 'update:Download and apply go-ipfs updates'
+ 'version:Show ipfs version information.'
+)
+
+_ipfs_subcommand(){
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ _arguments -C ':command:->command' '*::options:->options'
+ case $state in
+ (command)
+ _describe -t commands "ipfs subcommand" $1
+ return
+ ;;
+ (options)
+ case $line[1] in
+ (wantlist)
+ case $MAIN_SUBCOMMAND in
+ (bitswap)
+ _arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for. Default: self.]'
+ ;;
+ esac
+ ;;
+ (add)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s). Default: true.]' \
+ '--progress[Show progress.]'
+ ;;
+ (bootstrap)
+ local -a _bootstrap_rm_arguments
+ _bootstrap_rm_arguments=(
+ 'default:Add default peers to the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_rm_arguments
+ ;;
+ esac
+ ;;
+ (rm)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s). Default: true.]'
+ ;;
+ (bootstrap)
+ local -a _bootstrap_rm_arguments
+ _bootstrap_rm_arguments=(
+ 'all:Remove all peers from the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_rm_arguments
+ ;;
+ esac
+ ;;
+ (ls)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Default: all.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write just hashes of objects.]'
+ ;;
+ (p2p)
+ _arguments '(-v --headers)'{-v,--headers}'[Print table headers (Protocol, Listen, Target).]'
+ ;;
+ esac
+ ;;
+ (update)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments '--unpin[Remove the old pin. Default: true.]'
+ ;;
+ esac
+ ;;
+ (verify)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '--verbose[Also write the hashes of non-broken pins.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write just hashes of broken pins.]'
+ ;;
+ esac
+ ;;
+ (get|query|findpeer)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ (object)
+ _arguments '--data-encoding[Encoding type of the data field, either "text" or "base64". Default: text.]'
+ ;;
+ esac
+ ;;
+ (put)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ (object)
+ _arguments \
+ '--inputenc[Encoding type of input data. One of: {"protobuf", "json"}. Default: json.]' \
+ '--datafieldenc[Encoding type of the data field, either "text" or "base64". Default: text.]' \
+ '--pin[Pin this object when adding.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output]'
+ ;;
+ esac
+ ;;
+ (findprovs)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '(-n --num-providers)'{-n,--num-providers}'[The number of providers to find. Default: 20.]'
+ ;;
+ esac
+ ;;
+ (provide)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '(-r --recursive)'{-r,--recursive}'[Recursively provide entire graph.]'
+ ;;
+ esac
+ ;;
+ (cmds|diff)
+ case $MAIN_SUBCOMMAND in
+ (diag|object)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ esac
+ ;;
+ (stat)
+ case $MAIN_SUBCOMMAND in
+ (object)
+ _arguments '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ (repo)
+ _arguments \
+ '--size-only[Only report RepoSize and StorageMax.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (publish)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ _arguments \
+ '--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
+ '(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
+ '--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \
+ '--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
+ '(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
+ '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]'
+ ;;
+ esac
+ ;;
+ (pubsub)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ local -a _name_pubsub_arguments
+ _name_pubsub_arguments=(
+ 'cancel:Cancel a name subscription'
+ 'state:Query the state of IPNS pubsub'
+ 'subs:Show current name subscriptions'
+ )
+ _ipfs_subcommand _name_pubsub_arguments
+ ;;
+ esac
+ ;;
+ (resolve)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name. Default: true.]' \
+ '(-n --nocache)'{-n,--nocache}'[Do not use cached entries.]' \
+ '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
+ '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' \
+ '(-s --stream)'{-s,--stream}'[Stream entries as they are found.]'
+ ;;
+ esac
+ ;;
+ (patch)
+ case $MAIN_SUBCOMMAND in
+ (object)
+ local -a _object_patch_arguments
+ _object_patch_arguments=(
+ 'add-link:Add a link to a given object.'
+ 'append-data:Append data to the data segment of a dag node.'
+ 'rm-link:Remove a link from a given object.'
+ 'set-data:Set the data field of an IPFS object.'
+ )
+ _ipfs_subcommand _object_patch_arguments
+ ;;
+ esac
+ ;;
+ (gc)
+ case $MAIN_SUBCOMMAND in
+ (repo)
+ _arguments \
+ '--stream-errors[Stream errors.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output.]'
+ ;;
+ esac
+ ;;
+ (bitswap)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (bw)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for.]' \
+ '(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for.]' \
+ '--poll[Print bandwidth at an interval.]' \
+ '(-i --interval)'{-i,--interval}'[Time interval to wait between updating output, if 'poll' is true.]'
+ ;;
+ esac
+ ;;
+ (repo)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '--size-only[Only report RepoSize and StorageMax.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (bases)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments \
+ '--prefix[also include the single leter prefixes in addition to the code.]' \
+ '--numeric[also include numeric codes.]'
+ ;;
+ esac
+ ;;
+ (codecs|hashes)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments '--numeric[also include numeric codes.]'
+ ;;
+ esac
+ ;;
+ (format)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments \
+ '-f[Printf style format string. Default: %s.]' \
+ '-v[CID version to convert to.]' \
+ '-b[Multibase to display CID in.]'
+ ;;
+ esac
+ ;;
+ (close)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments \
+ '(-a --all)'{-a,--all}'[Close all listeners.]' \
+ '(-p --protocol)'{-p,--protocol}'[Match protocol name.]' \
+ '(-l --listen-address)'{-l,--listen-address}'[Match listen address.]' \
+ '(-t --target-address)'{-t,--target-address}'[Match target address.]'
+ ;;
+ esac
+ ;;
+ (forward)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments "--allow-custom-protocol[Don't require /x/ prefix.]"
+ ;;
+ esac
+ ;;
+ (listen)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments \
+ "--allow-custom-protocol[Don't require /x/ prefix.]" \
+ '(-r --report-peer-id)'{-r,--report-peer-id}'[Send remote base58 peerid to target when a new connection is established.]'
+ ;;
+ esac
+ ;;
+ (stream)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ local -a _p2p_stream_arguments
+ _p2p_stream_arguments=(
+ 'close:Close active p2p stream.'
+ 'ls:List active p2p streams.'
+ )
+ _ipfs_subcommand _p2p_stream_arguments
+ ;;
+ esac
+ ;;
+ (addrs)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ local -a _swarm_addrs_arguments
+ _swarm_addrs_arguments=(
+ 'listen:List interface listening addresses.'
+ 'local:List local addresses.'
+ )
+ _ipfs_subcommand _swarm_addrs_arguments
+ ;;
+ esac
+ ;;
+ (filters)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ local -a _swarm_filters_arguments
+ _swarm_filters_arguments=(
+ 'add:Add an address filter.'
+ 'rm:Remove an address filter.'
+ )
+ _ipfs_subcommand _swarm_filters_arguments
+ ;;
+ esac
+ ;;
+ (peers)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[display all extra information.]' \
+ '--streams[Also list information about open streams for each peer.]' \
+ '--latency[Also list information about latency to each peer.]' \
+ '--direction[Also list information about the direction of connection.]'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+}
+
+local expl
+
+_arguments \
+ '(-c --config)'{-c,--config}'[Path to the configuration file to use.]' \
+ '(-D --debug)'{-D,--debug}'[Operate in debug mode.]' \
+ '(--help)--help[Show the full command help text.]' \
+ '(--h)-h[Show a short version of the command help text.]' \
+ '(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon. DEPRECATED: use --offline.]' \
+ '(--offline)--offline[Run the command offline.]' \
+ '(--api)--api[Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001).]' \
+ '(--cid-base)--cid-base[Multibase encoding used for version 1 CIDs in output.]' \
+ '(--upgrade-cidv0-in-output)--upgrade-cidv0-in-output[Upgrade version 0 to version 1 CIDs in output.]' \
+ '(--enc --encoding)'{--enc,--encoding}'[The encoding type the output should be encoded with (json, xml, or text). Default: text.]' \
+ '(--stream-channels)--stream-channels[Stream channel output.]' \
+ '(--timeout)--timeout[Set a global timeout on the command.]' \
+ '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "ipfs subcommand" _1st_arguments
+ return
+fi
+
+MAIN_SUBCOMMAND="$words[1]"
+case $MAIN_SUBCOMMAND in
+ (add)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Add directory paths recursively.]' \
+ '(--dereference-args)--dereference-args[Symlinks supplied in arguments are dereferenced.]' \
+ '(--stdin-name)--stdin-name[Assign a name if the file source is stdin.]' \
+ '(-H --hidden)'{-H,--hidden}'[Include files that are hidden. Only takes effect on recursive add.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output.]' \
+ '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
+ '(--silent)--silent[Write no output.]' \
+ '(-p --progress)'{-p,--progress}'[Stream progress data.]' \
+ '(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation.]' \
+ '(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk.]' \
+ '(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object.]' \
+ '(-s --chunker)'{-s,--chunker}'[Chunking algorithm, size-(bytes) or rabin-(min)-(avg)-(max). Default: size-262144.]' \
+ '(--pin)--pin[Pin this object when adding. Default: true.]' \
+ '(--raw-leaves)--raw-leaves[Use raw blocks for leaf nodes. (experimental).]' \
+ '(--nocopy)--nocopy[Add the file using filestore. Implies raw-leaves. (experimental).]' \
+ '(--fscache)--fscache[Check the filestore for pre-existing blocks. (experimental).]' \
+ '(--cid-version)--cid-version[CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental).]' \
+ '(--hash)--hash[Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default: sha2-256.]' \
+ '(--inline)--inline[Inline small blocks into CIDs. (experimental).]' \
+ '(--inline-limit)--inline-limit[Maximum block size to inline. (experimental). Default: 32.]'
+ ;;
+ (bitswap)
+ local -a _bitswap_arguments
+ _bitswap_arguments=(
+ 'ledger:Show the current ledger for a peer.'
+ 'reprovide:Trigger reprovider.'
+ 'stat:Show some diagnostic information on the bitswap agent.'
+ 'wantlist:Show blocks currently on the wantlist.'
+ )
+ _ipfs_subcommand _bitswap_arguments
+ ;;
+ (block)
+ local -a _block_arguments
+ _block_arguments=(
+ 'get:Get a raw IPFS block.'
+ 'put:Store input as an IPFS block.'
+ 'rm:Remove IPFS block(s).'
+ 'stat:Print information of a raw IPFS block.'
+ )
+ _ipfs_subcommand _block_arguments
+ ;;
+ (bootstrap)
+ local -a _bootstrap_arguments
+ _bootstrap_arguments=(
+ 'add:Add peers to the bootstrap list.'
+ 'list:Show peers in the bootstrap list.'
+ 'rm:Remove peers from the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_arguments
+ ;;
+ (cat)
+ _arguments \
+ '(-o --offset)'{-o,--offset}'[Byte offset to begin reading from.]' \
+ '(-l --length)'{-l,--length}'[Maximum number of bytes to read.]'
+ ;;
+ (cid)
+ local -a _cid_arguments
+ _cid_arguments=(
+ 'base32:Convert CIDs to Base32 CID version 1.'
+ 'bases:List available multibase encodings.'
+ 'codecs:List available CID codecs.'
+ 'format:Format and convert a CID in various useful ways.'
+ 'hashes:List available multihashes.'
+ )
+ _ipfs_subcommand _cid_arguments
+ ;;
+ (commands)
+ _arguments '(-f --flags)'{-f,--flags}'[Show command flags.]'
+ ;;
+ (config)
+ _arguments \
+ '--bool[Set a boolean value.]' \
+ '--json[Parse stringified JSON.]'
+ local -a _config_arguments
+ _config_arguments=(
+ 'edit:Open the config file for editing in $EDITOR.'
+ 'profile:Apply profiles to config.'
+ 'replace:Replace the config with <file>.'
+ 'show:Output config file contents.'
+ )
+ _ipfs_subcommand _config_arguments
+ ;;
+ (daemon)
+ _arguments \
+ '--init[Initialize ipfs with default settings if not already initialized.]' \
+ '--init-profile[Configuration profiles to apply for --init. See ipfs init --help for more.]' \
+ '--routing[Overrides the routing option. Default: default.]' \
+ '--mount[Mounts IPFS to the filesystem.]' \
+ '--writable[Enable writing objects (with POST, PUT and DELETE).]' \
+ '--mount-ipfs[Path to the mountpoint for IPFS (if using --mount). Defaults to config setting.]' \
+ '--mount-ipns[Path to the mountpoint for IPNS (if using --mount). Defaults to config setting.]' \
+ '--unrestricted-api[Allow API access to unlisted hashes.]' \
+ '--disable-transport-encryption[Disable transport encryption (for debugging protocols).]' \
+ '--enable-gc[Enable automatic periodic repo garbage collection.]' \
+ '--manage-fdlimit[Check and raise file descriptor limits if needed. Default: true.]' \
+ '--migrate[If true, assume yes at the migrate prompt. If false, assume no.]' \
+ '--enable-pubsub-experiment[Instantiate the ipfs daemon with the experimental pubsub feature enabled.]' \
+ '--enable-namesys-pubsub[Enable IPNS record distribution through pubsub; enables pubsub.]' \
+ '--enable-mplex-experiment[Add the experimental 'go-multiplex' stream muxer to libp2p on construction. Default: true.]'
+ ;;
+ (dag)
+ local -a _dag_arguments
+ _dag_arguments=(
+ 'get:Get a dag node from ipfs.'
+ 'put:Add a dag node to ipfs.'
+ 'resolve:Resolve ipld block.'
+ )
+ _ipfs_subcommand _dag_arguments
+ ;;
+ (dht)
+ local -a _dht_arguments
+ _dht_arguments=(
+ 'findpeer:Find the multiaddresses associated with a Peer ID.'
+ 'findprovs:Find peers that can provide a specific value, given a key.'
+ 'get:Given a key, query the routing system for its best value.'
+ 'provide:Announce to the network that you are providing given values.'
+ 'put:Write a key/value pair to the routing system.'
+ 'query:Find the closest Peer IDs to a given Peer ID by querying the DHT.'
+ )
+ _ipfs_subcommand _dht_arguments
+ ;;
+ (diag)
+ local -a _diag_arguments
+ _diag_arguments=(
+ 'cmds:List commands run on this IPFS node.'
+ 'sys:Print system diagnostic information.'
+ )
+ _ipfs_subcommand _diag_arguments
+ ;;
+ (dns)
+ _arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link. Default: true.]'
+ ;;
+ (files)
+ _arguments '(-f --flush)'{-f,--flush}'[Flush target and ancestors after write. Default: true.]'
+ local -a _files_arguments
+ _files_arguments=(
+ 'chcid:Change the cid version or hash function of the root node of a given path.'
+ 'cp:Copy files into mfs.'
+ "flush:Flush a given path's data to disk."
+ 'ls:List directories in the local mutable namespace.'
+ 'mkdir:Make directories.'
+ 'mv:Move files.'
+ 'read:Read a file in a given mfs.'
+ 'rm:Remove a file.'
+ 'stat:Display file status.'
+ 'write:Write to a mutable file in a given filesystem.'
+ )
+ _ipfs_subcommand _files_arguments
+ ;;
+ (filestore)
+ local -a _filestore_arguments
+ _filestore_arguments=(
+ 'dups:List blocks that are both in the filestore and standard block storage.'
+ 'ls:List objects in filestore.'
+ 'verify:Verify objects in filestore.'
+ )
+ _ipfs_subcommand _filestore_arguments
+ ;;
+ (get)
+ _arguments \
+ '(-o --output)'{-o,--output}'[The path where the output should be stored.]'\
+ '(-a --archive)'{-a,--archive}'[Output a TAR archive.]' \
+ '(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression.]' \
+ '(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9).]'
+ ;;
+ (id)
+ _arguments '(-f --format)'{-f,--format}'[Optional output format.]'
+ ;;
+ (init)
+ _arguments \
+ '(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key. Default: 2048.]' \
+ '(-e --empty-repo)'{-e,--empty-repo}"[Don't add and pin help files to the local storage.]" \
+ '(-p --profile)'{-p,--profile}"[Apply profile settings to config. Multiple profiles can be separated by ','.]"
+ ;;
+ (key)
+ local -a _key_arguments
+ _key_arguments=(
+ 'gen:Create a new keypair'
+ 'list:List all local keypairs'
+ 'rename:Rename a keypair'
+ 'rm:Remove a keypair'
+ )
+ _ipfs_subcommand _key_arguments
+ ;;
+ (log)
+ local -a _log_arguments
+ _log_arguments=(
+ 'level:Change the logging level.'
+ 'ls:List the logging subsystems.'
+ 'tail:Read the event log.'
+ )
+ _ipfs_subcommand _log_arguments
+ ;;
+ (ls)
+ _arguments \
+ '(-v --headers)'{-v,--headers}'[Print table headers (Hash, Size, Name).]' \
+ '--resolve-type[Resolve linked objects to find out their types. Default: true.]' \
+ '--size[Resolve linked objects to find out their file size. Default: true.]' \
+ '(-s --stream)'{-s,--stream}'[Enable exprimental streaming of directory entries as they are traversed.]' \
+ ;;
+ (mount)
+ _arguments \
+ '(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted.]' \
+ '(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted.]'
+ ;;
+ (name)
+ local -a _name_arguments
+ _name_arguments=(
+ 'publish:Publish IPNS names.'
+ 'pubsub:IPNS pubsub management.'
+ 'resolve:Resolve IPNS names.'
+ )
+ _ipfs_subcommand _name_arguments
+ ;;
+ (object)
+ local -a _object_arguments
+ _object_arguments=(
+ 'data:Output the raw bytes of an IPFS object.'
+ 'diff:Display the diff between two ipfs objects.'
+ 'get:Get and serialize the DAG node named by <key>.'
+ 'links:Output the links pointed to by the specified object.'
+ 'new:Create a new object from an ipfs template.'
+ 'patch:Create a new merkledag object based on an existing one.'
+ 'put:Store input as a DAG object, print its key.'
+ 'stat:Get stats for the DAG node named by <key>.'
+ )
+ _ipfs_subcommand _object_arguments
+ ;;
+ (p2p)
+ local -a _p2p_arguments
+ _p2p_arguments=(
+ 'close:Stop listening for new connections to forward.'
+ 'forward:Forward connections to libp2p service'
+ 'listen:Create libp2p service'
+ 'ls:List active p2p listeners.'
+ 'stream:P2P stream management.'
+ )
+ _ipfs_subcommand _p2p_arguments
+ ;;
+ (pin)
+ local -a _pin_arguments
+ _pin_arguments=(
+ 'add:Pin objects to local storage.'
+ 'ls:List objects pinned to local storage.'
+ 'rm:Remove pinned objects from local storage.'
+ 'update:Update a recursive pin'
+ 'verify:Verify that recursive pins are complete.'
+ )
+ _ipfs_subcommand _pin_arguments
+ ;;
+ (ping)
+ _arguments '(-n --count)'{-n,--count}'[Number of ping messages to send. Default: 10.]'
+ ;;
+ (refs)
+ _arguments \
+ '--format[Emit edges with given format. Available tokens: <src> <dst> <linkname>. Default: <dst>.]' \
+ '(-e --edges)'{-e,--edges}'[Emit edge format: `<from> -> <to>`.]' \
+ '(-u --unique)'{-u,--unique}'[Omit duplicate refs from output.]' \
+ '(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes.]' \
+ '--max-depth[Only for recursive refs, limits fetch and listing to the given depth. Default: -1.]'
+ local -a _refs_arguments
+ _refs_arguments='local:List all local references.'
+ _ipfs_subcommand _refs_arguments
+ ;;
+ (repo)
+ local -a _repo_arguments
+ _repo_arguments=(
+ 'fsck:Remove repo lockfiles.'
+ 'gc:Perform a garbage collection sweep on the repo.'
+ 'stat:Get stats for the currently used repo.'
+ 'verify:Verify all blocks in repo are not corrupted.'
+ 'version:Show the repo version.'
+ )
+ _ipfs_subcommand _repo_arguments
+ ;;
+ (resolve)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name. Default: true.]' \
+ '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
+ '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]'
+ ;;
+ (stats)
+ local -a _stats_arguments
+ _stats_arguments=(
+ 'bitswap:Show some diagnostic information on the bitswap agent.'
+ 'bw:Print ipfs bandwidth information.'
+ 'repo:Get stats for the currently used repo.'
+ )
+ _ipfs_subcommand _stats_arguments
+ ;;
+ (swarm)
+ local -a _swarm_arguments
+ _swarm_arguments=(
+ 'addrs:List known addresses. Useful for debugging.'
+ 'connect:Open connection to a given address.'
+ 'disconnect:Close connection to a given address.'
+ 'filters:Manipulate address filters.'
+ 'peers:List peers with open connections.'
+ )
+ _ipfs_subcommand _swarm_arguments
+ ;;
+ (tar)
+ local -a _tar_arguments
+ _tar_arguments=(
+ 'add:Import a tar file into ipfs.'
+ 'cat:Export a tar file from IPFS.'
+ )
+ _ipfs_subcommand _tar_arguments
+ ;;
+ (version)
+ _arguments \
+ '(-n --number)'{-n,--number}'[Only show the version number.]' \
+ '--commit[Show the commit hash.]' \
+ '--repo[Show repo version.]' \
+ '--all[Show all version information.]'
+ ;;
+esac
diff --git a/plugins/isodate/README.md b/plugins/isodate/README.md
new file mode 100644
index 000000000..1ec75b2d4
--- /dev/null
+++ b/plugins/isodate/README.md
@@ -0,0 +1,22 @@
+# Isodate plugin
+
+**Maintainer:** [@Frani](https://github.com/frani)
+
+This plugin adds completion for the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601),
+as well as some aliases for common Date commands.
+
+To use it, add `isodate` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... isodate)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|---------------|--------------------------------------|----------------------------------------------------------------------------|
+| isodate | `date +%Y-%m-%dT%H:%M:%S%z` | Display the current date with UTC offset and ISO 8601-2 extended format |
+| isodate_utc | `date -u +%Y-%m-%dT%H:%M:%SZ` | Display the current date in UTC and ISO 8601-2 extended format |
+| isodate_basic | `date -u +%Y%m%dT%H%M%SZ` | Display the current date in UTC and ISO 8601 basic format |
+| unixstamp | `date +%s` | Display the current date as a Unix timestamp (seconds since the Unix epoch)|
+| date_locale | `date +"%c"` | Display the current date using the default locale's format |
diff --git a/plugins/isodate/isodate.plugin.zsh b/plugins/isodate/isodate.plugin.zsh
new file mode 100644
index 000000000..1a827e785
--- /dev/null
+++ b/plugins/isodate/isodate.plugin.zsh
@@ -0,0 +1,7 @@
+# work with date ISO 8601 easy
+
+alias isodate="date +%Y-%m-%dT%H:%M:%S%z"
+alias isodate_utc="date -u +%Y-%m-%dT%H:%M:%SZ"
+alias isodate_basic="date -u +%Y%m%dT%H%M%SZ"
+alias unixstamp="date +%s"
+alias date_locale="date +"%c""
diff --git a/plugins/jake-node/jake-node.plugin.zsh b/plugins/jake-node/jake-node.plugin.zsh
index 3b692f899..c2dad28af 100644
--- a/plugins/jake-node/jake-node.plugin.zsh
+++ b/plugins/jake-node/jake-node.plugin.zsh
@@ -6,7 +6,7 @@
# Inspiration : https://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
function _jake () {
- if [ -f Jakefile ]||[ -f jakefile ]; then
+ if [ -f Jakefile ] || [ -f jakefile ] || [ -f Jakefile.js ] || [ -f jakefile.js ]; then
compadd `jake -T | cut -d " " -f 2 | sed -E "s/.\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"`
fi
}
diff --git a/plugins/jsontools/README.md b/plugins/jsontools/README.md
index 1fa2b8eed..6a2740014 100644
--- a/plugins/jsontools/README.md
+++ b/plugins/jsontools/README.md
@@ -17,32 +17,63 @@ Usage is simple... just take your json data and pipe it into the appropriate jso
- `urlencode_json`: returns a url encoded string for the given json.
- `urldecode_json`: returns decoded json for the given url encoded string.
+### Supports NDJSON (Newline Delimited JSON)
+
+The plugin also supports [NDJSON](http://ndjson.org/) input, which means all functions
+have an alternative function that reads and processes the input line by line. These
+functions have the same name except using `ndjson` instead of `json`:
+
+> `pp_ndjson`, `is_ndjson`, `urlencode_ndjson`, `urldecode_ndjson`.
+
### Examples
- **pp_json**:
-```sh
+```console
# curl json data and pretty print the results
curl https://coderwall.com/bobwilliams.json | pp_json
```
- **is_json**:
-```sh
-# Validate if file's content conforms to a valid JSON schema
-less data.json | is_json
+```console
+# validate if file's content conforms to a valid JSON schema
+$ is_json < data.json
+true
+# shows true / false and returns the proper exit code
+$ echo $?
+0
```
- **urlencode_json**:
-```sh
+```console
# json data directly from the command line
-echo '{"b":2, "a":1}' | urlencode_json
+$ echo '{"b":2, "a":1}' | urlencode_json
+%7B%22b%22:2,%20%22a%22:1%7D
```
- **urldecode_json**:
-```sh
+```console
# url encoded string to decode
-echo '%7B%22b%22:2,%20%22a%22:1%7D%0A' | urldecode_json
+$ echo '%7B%22b%22:2,%20%22a%22:1%7D' | urldecode_json
+{"b":2, "a":1}
+```
+
+- **pp_ndjson**:
+
+```console
+# echo two separate json objects and pretty print both
+$ echo '{"a": "b"}\n{"c": [1,2,3]}' | pp_ndjson
+{
+ "a": "b"
+}
+{
+ "c": [
+ 1,
+ 2,
+ 3
+ ]
+}
```
diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh
index 912c83509..857ca0ec9 100644
--- a/plugins/jsontools/jsontools.plugin.zsh
+++ b/plugins/jsontools/jsontools.plugin.zsh
@@ -1,42 +1,113 @@
# JSON Tools
# Adds command line aliases useful for dealing with JSON
-if [[ $(whence $JSONTOOLS_METHOD) = "" ]]; then
- JSONTOOLS_METHOD=""
+# Check that user-defined method is installed
+if [[ -n "$JSONTOOLS_METHOD" ]]; then
+ (( $+commands[$JSONTOOLS_METHOD] )) || unset JSONTOOLS_METHOD
fi
-if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xnode" ) ]]; then
- alias pp_json='xargs -0 node -e "console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));"'
- alias is_json='xargs -0 node -e "try {json = JSON.parse(process.argv[1]);} catch (e) { console.log(false); json = null; } if(json) { console.log(true); }"'
- alias urlencode_json='xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"'
- alias urldecode_json='xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"'
-elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
- alias pp_json='python -c "import sys; del sys.path[0]; import runpy; runpy._run_module_as_main(\"json.tool\")"'
- alias is_json='python -c "
+# If method undefined, find the first one that is installed
+if [[ -z "$JSONTOOLS_METHOD" ]]; then
+ for JSONTOOLS_METHOD in node python ruby; do
+ # If method found, break out of loop
+ (( $+commands[$JSONTOOLS_METHOD] )) && break
+ # Otherwise unset the variable
+ unset JSONTOOLS_METHOD
+ done
+
+ # If no methods were found, exit the plugin
+ [[ -n "$JSONTOOLS_METHOD" ]] || return 1
+fi
+
+# Define json tools for each method
+case "$JSONTOOLS_METHOD" in
+ node)
+ # node doesn't make it easy to deal with stdin, so we pass it as an argument with xargs -0
+ function pp_json() {
+ xargs -0 node -e 'console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));'
+ }
+ function is_json() {
+ xargs -0 node -e '
+ try {
+ json = JSON.parse(process.argv[1]);
+ console.log("true");
+ process.exit(0);
+ } catch (e) {
+ console.log("false");
+ process.exit(1);
+ }
+ '
+ }
+ function urlencode_json() {
+ xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"
+ }
+ function urldecode_json() {
+ xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"
+ }
+ ;;
+ python)
+ function pp_json() {
+ python -c 'import sys; del sys.path[0]; import runpy; runpy._run_module_as_main("json.tool")'
+ }
+ function is_json() {
+ python -c '
import sys; del sys.path[0];
-import json;
-try:
- json.loads(sys.stdin.read())
-except ValueError, e:
- print False
-else:
- print True
-sys.exit(0)"'
- alias urlencode_json='python -c "
+import json
+try:
+ json.loads(sys.stdin.read())
+ print("true"); sys.exit(0)
+except ValueError:
+ print("false"); sys.exit(1)
+ '
+ }
+ function urlencode_json() {
+ python -c '
import sys; del sys.path[0];
-import urllib, json;
-print urllib.quote_plus(sys.stdin.read())
-sys.exit(0)"'
- alias urldecode_json='python -c "
+from urllib.parse import quote_plus
+print(quote_plus(sys.stdin.read()))
+ '
+ }
+ function urldecode_json() {
+ python -c '
import sys; del sys.path[0];
-import urllib, json;
-print urllib.unquote_plus(sys.stdin.read())
-sys.exit(0)"'
-elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
- alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"'
- alias is_json='ruby -e "require \"json\"; begin; JSON.parse(STDIN.read); puts true; rescue Exception => e; puts false; end"'
- alias urlencode_json='ruby -e "require \"uri\"; puts URI.escape(STDIN.read)"'
- alias urldecode_json='ruby -e "require \"uri\"; puts URI.unescape(STDIN.read)"'
-fi
-
+from urllib.parse import unquote_plus
+print(unquote_plus(sys.stdin.read()))
+ '
+ }
+ ;;
+ ruby)
+ function pp_json() {
+ ruby -e '
+ require "json"
+ require "yaml"
+ puts JSON.parse(STDIN.read).to_yaml
+ '
+ }
+ function is_json() {
+ ruby -e '
+ require "json"
+ begin
+ puts !!JSON.parse(STDIN.read); exit(0)
+ rescue JSON::ParserError
+ puts false; exit(1)
+ end
+ '
+ }
+ function urlencode_json() {
+ ruby -e 'require "cgi"; puts CGI.escape(STDIN.read)'
+ }
+ function urldecode_json() {
+ ruby -e 'require "cgi"; puts CGI.unescape(STDIN.read)'
+ }
+ ;;
+esac
unset JSONTOOLS_METHOD
+
+## Add NDJSON support
+
+function {pp,is,urlencode,urldecode}_ndjson() {
+ local json jsonfunc="${0//ndjson/json}"
+ while read -r json; do
+ $jsonfunc <<< "$json"
+ done
+}
diff --git a/plugins/juju/README.md b/plugins/juju/README.md
new file mode 100644
index 000000000..49f8b0d47
--- /dev/null
+++ b/plugins/juju/README.md
@@ -0,0 +1,117 @@
+# juju plugin
+
+This plugin provides useful aliases and functions for [juju](https://juju.is/) (for TAB completion,
+refer to the [official repo](https://github.com/juju/juju/blob/develop/etc/bash_completion.d/juju)).
+
+To use this plugin, add `juju` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... juju)
+```
+
+## Aliases
+
+Naming convention:
+
+- `!` suffix: `--force --no-wait -y`.
+- `ds` suffix: `--destroy-storage`.
+
+### General
+
+| Alias | Command | Description |
+|--------|---------------------------------------------|--------------------------------------------------------|
+| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
+| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
+| `jh` | `juju help` | Show help on a command or other topic |
+| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity |
+| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
+| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
+
+### Bootstrap
+
+| Alias | Command | Description |
+|-------|---------------------------|-------------------------------------------|
+| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
+| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
+
+### Controller
+
+| Alias | Command | Description |
+|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
+| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
+| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
+| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
+| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
+| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
+| `jsw` | `juju switch` | Select or identify the current controller and model |
+
+### Model
+
+| Alias | Command | Description |
+|----------|-------------------------------------------------------------|-------------------------------------------------------|
+| `jam` | `juju add-model` | Add a hosted model |
+| `jdm` | `juju destroy-model` | Non-recoverable, complete removal of a model |
+| `jdm!` | `juju destroy-model --force --no-wait -y` | Non-recoverable, complete removal of a model |
+| `jdmds` | `juju destroy-model --destroy-storage` | Non-recoverable, complete removal of a model |
+| `jdmds!` | `juju destroy-model --destroy-storage --force --no-wait -y` | Non-recoverable, complete removal of a model |
+| `jmc` | `juju model-config` | Display or set configuration values on a model |
+| `jm` | `juju models` | List models a user can access on a controller |
+| `jshm` | `juju show-model` | Show information about the current or specified model |
+| `jsw` | `juju switch` | Select or identify the current controller and model |
+
+### Application / unit
+
+| Alias | Command | Description |
+|----------|---------------------------------------------------------------|---------------------------------------------------------------------------|
+| `jc` | `juju config` | Get, set, or reset configuration for a deployed application |
+| `jde` | `juju deploy --channel=edge` | Deploy a new application or bundle from the edge channel |
+| `jd` | `juju deploy` | Deploy a new application or bundle |
+| `jra` | `juju run-action` | Queue an action for execution |
+| `jraw` | `juju run-action --wait` | Queue an action for execution and wait for results, with optional timeout |
+| `jrm` | `juju remove-application` | Remove application |
+| `jrm!` | `juju remove-application --force --no-wait` | Remove application forcefully |
+| `jrmds` | `juju remove-application --destroy-storage` | Remove application and destroy attached storage |
+| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
+| `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
+| `jsa` | `juju scale-application` | Set the desired number of application units |
+| `jsh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
+| `jshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
+| `jsu` | `juju show-unit` | Displays information about a unit |
+
+### Storage
+
+| Alias | Command | Description |
+|---------|-------------------------------|-------------------------------------------------|
+| `jrs` | `juju remove-storage` | Remove storage |
+| `jrs!` | `juju remove-storage --force` | Remove storage even if it is currently attached |
+
+### Relation
+
+| Alias | Command | Description |
+|-----------|--------------------------------|-------------------------------------------------------------------|
+| `jrel` | `juju relate` | Relate two applications |
+| `jrmrel` | `juju remove-relation` | Remove an existing relation between two applications. |
+| `jrmrel!` | `juju remove-relation --force` | Remove an existing relation between two applications, forcefully. |
+
+### Cross-model relation (CMR)
+
+| Alias | Command | Description |
+|----------|--------------------|----------------------------------------------------------------|
+| `jex` | `juju expose` | Make an application publicly available over the network |
+| `jof` | `juju offer` | Offer application endpoints for use in other models |
+| `jcon` | `juju consume` | Add a remote offer to the model |
+| `jrmsas` | `juju remove-saas` | Remove consumed applications (SAAS) from the model |
+| `junex` | `juju unexpose` | Remove public availability over the network for an application |
+
+### Bundle
+
+| Alias | Command | Description |
+|-------|----------------------|-------------------------------------------------------------|
+| `jeb` | `juju export-bundle` | Export the current model configuration as a reusable bundle |
+
+## Functions
+
+- `jaddr <app_name> [unit_num]`: display app or unit IP address.
+- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
+- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
+ (default: 5s); you may pass additional arguments to `watch`.
diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh
new file mode 100644
index 000000000..07f15b392
--- /dev/null
+++ b/plugins/juju/juju.plugin.zsh
@@ -0,0 +1,127 @@
+# ---------------------------------------------------------- #
+# Aliases and functions for juju (https://juju.is) #
+# ---------------------------------------------------------- #
+
+# Load TAB completions
+# You need juju's bash completion script installed. By default bash-completion's
+# location will be used (i.e. pkg-config --variable=completionsdir bash-completion).
+completion_file="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)/juju" || \
+ completion_file="/usr/share/bash-completion/completions/juju"
+[[ -f "$completion_file" ]] && source "$completion_file"
+unset completion_file
+
+# ---------------------------------------------------------- #
+# Aliases (in alphabetic order) #
+# #
+# Generally, #
+# - `!` means --force --no-wait -y #
+# - `ds` suffix means --destroy-storage #
+# ---------------------------------------------------------- #
+alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
+ --config update-status-hook-interval=\"60m\""
+alias jb='juju bootstrap'
+alias jbm='juju bootstrap microk8s'
+alias jc='juju config'
+alias jdc='juju destroy-controller --destroy-all-models'
+alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
+alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
+alias 'jdcds!'='juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y'
+alias jdm='juju destroy-model'
+alias 'jdm!'='juju destroy-model --force --no-wait -y'
+alias jdmds='juju destroy-model --destroy-storage'
+alias 'jdmds!'='juju destroy-model --destroy-storage --force --no-wait -y'
+alias jde='juju deploy --channel=edge'
+alias jd='juju deploy'
+alias jdl='juju debug-log --ms'
+alias jdlr='juju debug-log --ms --replay'
+alias jcon='juju consume'
+alias jeb='juju export-bundle'
+alias jex='juju expose'
+alias jh='juju help'
+alias jkc='juju kill-controller -y -t 0'
+alias jm='juju models'
+alias jmc='juju model-config'
+alias jof='juju offer'
+alias jra='juju run-action'
+alias jraw='juju run-action --wait'
+alias jrel='juju relate'
+alias jrm='juju remove-application'
+alias 'jrm!'='juju remove-application --force --no-wait'
+alias jrmds='juju remove-application --destroy-storage'
+alias 'jrmds!'='juju remove-application --destroy-storage --force --no-wait'
+alias jrmrel='juju remove-relation'
+alias 'jrmrel!'='juju remove-relation --force'
+alias jrmsas='juju remove-saas'
+alias jrp='juju refresh --path'
+alias jrs='juju remove-storage'
+alias 'jrs!'='juju remove-storage --force'
+alias jsa='juju scale-application'
+alias jsh='juju ssh'
+alias jshc='juju ssh --container'
+alias jshm='juju show-model'
+alias jssl='juju show-status-log'
+alias jstj='juju status --format=json'
+alias jst='juju status --relations --storage --color'
+alias jsu='juju show-unit'
+alias jsw='juju switch'
+
+# ---------------------------------------------------------- #
+# Functions (in alphabetic order) #
+# ---------------------------------------------------------- #
+
+# Get app or unit address
+jaddr() {
+ # $1 = app name
+ # $2 = unit number (optional)
+ if (( ! ${+commands[jq]} )); then
+ echo "jq is required but could not be found." >&2
+ return 1
+ fi
+
+ if [[ $# -eq 1 ]]; then
+ # Get app address
+ juju status "$1" --format=json \
+ | jq -r ".applications.\"$1\".address"
+ elif [[ $# -eq 2 ]]; then
+ # Get unit address
+ juju status "$1/$2" --format=json \
+ | jq -r ".applications.\"$1\".units.\"$1/$2\".address"
+ else
+ echo "Invalid number of arguments."
+ echo "Usage: jaddr <app-name> [<unit-number>]"
+ echo "Example: jaddr karma"
+ echo "Example: jaddr karma 0"
+ return 1
+ fi
+}
+
+# Display app and unit relation data
+jreld() {
+ # $1 = relation name
+ # $2 = app name
+ # $3 = unit number
+ if [[ $# -ne 3 ]]; then
+ echo "Invalid number of arguments."
+ echo "Usage: jreld <relation-name> <app-name> <unit-number>"
+ echo "Example: jreld karma-dashboard alertmanager 0"
+ return 1
+ fi
+
+ local relid="$(juju run "relation-ids $1" --unit $2/$3)"
+ if [[ -z "$relid" ]]; then
+ return 1
+ fi
+
+ echo "App data:"
+ juju run "relation-get -r $relid --app - $2" --unit $2/$3
+ echo
+ echo "Unit data:"
+ juju run "relation-get -r $relid - $2" --unit $2/$3
+}
+
+# Watch juju status, with optional interval (default: 5 sec)
+wjst() {
+ local interval="${1:-5}"
+ shift $(( $# > 0 ))
+ watch -n "$interval" --color juju status --relations --storage --color "$@"
+}
diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md
index a14337278..b08997b0f 100644
--- a/plugins/kube-ps1/README.md
+++ b/plugins/kube-ps1/README.md
@@ -6,14 +6,6 @@ configured on `kubectl` to your Bash/Zsh prompt strings (i.e. the `$PS1`).
Inspired by several tools used to simplify usage of `kubectl`.
-![prompt](img/screenshot2.png)
-
-![prompt_sol_light](img/screenshot-sol-light.png)
-
-![prompt_img](img/screenshot-img.png)
-
-![prompt demo](img/kube-ps1.gif)
-
## Installing
### MacOS
diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
index c0db59362..f6651c8cd 100644
--- a/plugins/kubectl/README.md
+++ b/plugins/kubectl/README.md
@@ -22,7 +22,7 @@ plugins=(... kubectl)
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
| kccc | `kubectl config current-context` | Display the current-context |
-| kcgc | `kubectl config get-contexts` | List of contexts available
+| kcgc | `kubectl config get-contexts` | List of contexts available
| | | **General aliases** |
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
@@ -33,7 +33,8 @@ plugins=(... kubectl)
| kep | `kubectl edit pods` | Edit pods from the default editor |
| kdp | `kubectl describe pods` | Describe all pods |
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
-| kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` |
+| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
+| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
| | | **Service management** |
| kgs | `kubectl get svc` | List all services in ps output format |
| kgsw | `kgs --watch` | After listing all services, watch for changes |
@@ -48,7 +49,7 @@ plugins=(... kubectl)
| kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
| | | **Namespace management** |
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
-| kcn | `kubectl config set-context ...` | Change current namespace |
+| kcn | `kubectl config set-context --current --namespace` | Change current namespace |
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
@@ -90,13 +91,13 @@ plugins=(... kubectl)
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
| kdno | `kubectl describe node` | Describe node resource in detail |
| kdelno | `kubectl delete node` | Delete the node |
-| | | **Persistent Volume Claim management** |
+| | | **Persistent Volume Claim management** |
| kgpvc | `kubectl get pvc` | List all PVCs |
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
-| kdpvc | `kubectl describe pvc` | Descirbe all pvcs |
+| kdpvc | `kubectl describe pvc` | Describe all pvcs |
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
-| | | |
+| | | **StatefulSets management** |
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
@@ -105,3 +106,25 @@ plugins=(... kubectl)
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
| ksss | `kubectl scale statefulset` | Scale a statefulset |
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
+| | | **Service Accounts management** |
+| kdsa | `kubectl describe sa` | Describe a service account in details |
+| kdelsa | `kubectl delete sa` | Delete the service account |
+| | | **DaemonSet management** |
+| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
+| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
+| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
+| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
+| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
+| | | **CronJob management** |
+| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
+| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
+| kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
+| kdelcj | `kubectl delete cronjob` | Delete the CronJob |
+
+## Wrappers
+
+This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
+
+- `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
+- `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
+- `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
index 92688c53c..3630facaa 100644
--- a/plugins/kubectl/kubectl.plugin.zsh
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -1,7 +1,7 @@
if (( $+commands[kubectl] )); then
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
- if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
+ if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
@@ -43,10 +43,14 @@ alias kgpwide='kgp -o wide'
alias kep='kubectl edit pods'
alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods'
+alias kgpall='kubectl get pods --all-namespaces -o wide'
# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='kgp -l'
+# get pod by namespace: kgpn kube-system"
+alias kgpn='kgp -n'
+
# Service management.
alias kgs='kubectl get svc'
alias kgsa='kubectl get svc --all-namespaces'
@@ -68,7 +72,7 @@ alias kgns='kubectl get namespaces'
alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace'
-alias kcn='kubectl config set-context $(kubectl config current-context) --namespace'
+alias kcn='kubectl config set-context --current --namespace'
# ConfigMap management
alias kgcm='kubectl get configmaps'
@@ -147,3 +151,30 @@ alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'
+# Service account management.
+alias kdsa="kubectl describe sa"
+alias kdelsa="kubectl delete sa"
+
+# DaemonSet management.
+alias kgds='kubectl get daemonset'
+alias kgdsw='kgds --watch'
+alias keds='kubectl edit daemonset'
+alias kdds='kubectl describe daemonset'
+alias kdelds='kubectl delete daemonset'
+
+# CronJob management.
+alias kgcj='kubectl get cronjob'
+alias kecj='kubectl edit cronjob'
+alias kdcj='kubectl describe cronjob'
+alias kdelcj='kubectl delete cronjob'
+
+# Only run if the user actually has kubectl installed
+if (( ${+_comps[kubectl]} )); then
+ kj() { kubectl "$@" -o json | jq; }
+ kjx() { kubectl "$@" -o json | fx; }
+ ky() { kubectl "$@" -o yaml | yh; }
+
+ compdef kj=kubectl
+ compdef kjx=kubectl
+ compdef ky=kubectl
+fi
diff --git a/plugins/kubectx/README.md b/plugins/kubectx/README.md
new file mode 100644
index 000000000..98f1cf032
--- /dev/null
+++ b/plugins/kubectx/README.md
@@ -0,0 +1,26 @@
+# kubectx - show active kubectl context
+
+This plugins adds ```kubectx_prompt_info()``` function. It shows name of the
+active kubectl context (```kubectl config current-context```).
+
+You can use it to customize prompt and know if You are on prod cluster ;)
+
+_Example_. Add to **.zshrc**:
+
+```
+RPS1='$(kubectx_prompt_info)'
+```
+
+### custom ctx names
+
+One can rename default context name for better readability.
+
+_Example_. Add to **.zshrc**:
+```
+kubectx_mapping[minikube]="mini"
+kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]"
+kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}"
+```
+
+![staging](stage.png)
+![production](prod.png)
diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh
new file mode 100644
index 000000000..abbdc254b
--- /dev/null
+++ b/plugins/kubectx/kubectx.plugin.zsh
@@ -0,0 +1,9 @@
+typeset -A kubectx_mapping
+
+function kubectx_prompt_info() {
+ if [ $commands[kubectl] ]; then
+ local current_ctx=`kubectl config current-context`
+ # use value in associative array if it exists, otherwise fall back to the context name
+ echo "${kubectx_mapping[$current_ctx]:-$current_ctx}"
+ fi
+}
diff --git a/plugins/kubectx/prod.png b/plugins/kubectx/prod.png
new file mode 100644
index 000000000..0c194a66d
--- /dev/null
+++ b/plugins/kubectx/prod.png
Binary files differ
diff --git a/plugins/kubectx/stage.png b/plugins/kubectx/stage.png
new file mode 100644
index 000000000..ac15b3929
--- /dev/null
+++ b/plugins/kubectx/stage.png
Binary files differ
diff --git a/plugins/lando/LICENSE b/plugins/lando/LICENSE
new file mode 100644
index 000000000..1d4983163
--- /dev/null
+++ b/plugins/lando/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Joshua Bedford
+
+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. \ No newline at end of file
diff --git a/plugins/lando/README.md b/plugins/lando/README.md
new file mode 100644
index 000000000..928a42bca
--- /dev/null
+++ b/plugins/lando/README.md
@@ -0,0 +1,37 @@
+# Lando ZSH (lando-zsh)
+
+This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories.
+
+To use it, add `lando` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... lando)
+```
+
+## ALIASES:
+
+| Alias | Description |
+|:----------:|:----------------:|
+| `artisan` | `lando artisan` |
+| `composer` | `lando composer` |
+| `drush` | `lando drush` |
+| `gulp` | `lando gulp` |
+| `npm` | `lando npm` |
+| `wp` | `lando wp` |
+| `yarn` | `lando yarn` |
+
+## How It Works:
+
+This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
+- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
+- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
+
+## Settings:
+
+- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
+- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
+
+## Author:
+
+- Author: Joshua Bedford
+- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh)
diff --git a/plugins/lando/lando.plugin.zsh b/plugins/lando/lando.plugin.zsh
new file mode 100644
index 000000000..af53e7e5a
--- /dev/null
+++ b/plugins/lando/lando.plugin.zsh
@@ -0,0 +1,41 @@
+# Settings
+: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
+: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
+
+# Enable multiple commands with lando.
+function artisan \
+ composer \
+ drush \
+ gulp \
+ npm \
+ php \
+ wp \
+ yarn {
+ if checkForLandoFile; then
+ lando "$0" "$@"
+ else
+ command "$0" "$@"
+ fi
+}
+
+# Check for the file in the current and parent directories.
+checkForLandoFile() {
+ # Only bother checking for lando within the Sites directory.
+ if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
+ # Not within $LANDO_ZSH_SITES_DIRECTORY
+ return 1
+ fi
+
+ local curr_dir="$PWD"
+ # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
+ while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
+ if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
+ return 0
+ fi
+ curr_dir="${curr_dir:h}"
+ done
+
+ # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
+ # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
+ return 1
+} \ No newline at end of file
diff --git a/plugins/laravel5/laravel5.plugin.zsh b/plugins/laravel5/laravel5.plugin.zsh
index 487a0742b..70dc4ed02 100644
--- a/plugins/laravel5/laravel5.plugin.zsh
+++ b/plugins/laravel5/laravel5.plugin.zsh
@@ -1,20 +1,19 @@
+# Alias
+alias la5='php artisan'
+alias la5cache='php artisan cache:clear'
+alias la5routes='php artisan route:list'
+alias la5vendor='php artisan vendor:publish'
+
# Laravel5 basic command completion
_laravel5_get_command_list () {
- php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
+ php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
}
_laravel5 () {
- if [ -f artisan ]; then
- compadd `_laravel5_get_command_list`
+ if [[ -f artisan ]]; then
+ compadd $(_laravel5_get_command_list)
fi
}
compdef _laravel5 artisan
compdef _laravel5 la5
-
-#Alias
-alias la5='php artisan'
-
-alias la5cache='php artisan cache:clear'
-alias la5routes='php artisan route:list'
-alias la5vendor='php artisan vendor:publish'
diff --git a/plugins/last-working-dir/README.md b/plugins/last-working-dir/README.md
index ced9e0370..b5cc55828 100644
--- a/plugins/last-working-dir/README.md
+++ b/plugins/last-working-dir/README.md
@@ -1,15 +1,33 @@
# last-working-dir plugin
Keeps track of the last used working directory and automatically jumps into it
-for new shells, unless:
+for new shells, unless the starting directory is not `$HOME`.
-- The plugin is already loaded.
-- The current `$PWD` is not `$HOME`.
-
-Also adds `lwd` function to jump to the last working directory.
+Also adds a `lwd` function to jump to the last working directory.
To use it, add `last-working-dir` to the plugins array in your zshrc file:
```zsh
plugins=(... last-working-dir)
```
+
+## Features
+
+### Use separate last-working-dir files with different SSH keys
+
+If the same user account is used by multiple users connecting via different SSH keys, you can
+configure SSH to map them to different `SSH_USER`s and the plugin will use separate lwd files
+for each one.
+
+Make sure that your SSH server allows environment variables. You can enable this feature
+within the `/etc/sshd/sshd_config` file:
+
+```
+PermitUserEnvironment yes
+```
+
+Then, add `environment="SSH_USER=<SSH_USERNAME>"` before the SSH keys in your `authorized_keys` file:
+
+```
+environment="SSH_USER=a.test@example.com" ssh-ed25519 AAAAC3Nz...
+```
diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh
index fd21705ae..905a02a70 100644
--- a/plugins/last-working-dir/last-working-dir.plugin.zsh
+++ b/plugins/last-working-dir/last-working-dir.plugin.zsh
@@ -5,16 +5,18 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY
autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_last_working_dir
chpwd_last_working_dir() {
- if [ "$ZSH_SUBSHELL" = 0 ]; then
- local cache_file="$ZSH_CACHE_DIR/last-working-dir"
- pwd >| "$cache_file"
- fi
+ # Don't run in subshells
+ [[ "$ZSH_SUBSHELL" -eq 0 ]] || return 0
+ # Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty
+ local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}"
+ pwd >| "$cache_file"
}
# Changes directory to the last working directory
lwd() {
- local cache_file="$ZSH_CACHE_DIR/last-working-dir"
- [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")"
+ # Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty
+ local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}"
+ [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")"
}
# Jump to last directory automatically unless:
diff --git a/plugins/macports/_port b/plugins/macports/_port
index 6a9ebe0c6..897598a46 100644
--- a/plugins/macports/_port
+++ b/plugins/macports/_port
@@ -43,6 +43,7 @@ subcmds=(
'provides'
'rdependents'
'rdeps'
+'reclaim'
'rpmpackage'
'search'
'selfupdate'
diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh
index 2d4d578b6..55b893535 100644
--- a/plugins/magic-enter/magic-enter.plugin.zsh
+++ b/plugins/magic-enter/magic-enter.plugin.zsh
@@ -1,27 +1,38 @@
-# Bind quick stuff to enter!
-#
-# Pressing enter in a git directory runs `git status`
-# in other directories `ls`
-magic-enter () {
- # If commands are not already set, use the defaults
- [ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ."
- [ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ."
+# Default commands
+: ${MAGIC_ENTER_GIT_COMMAND:="git status -u ."} # run when in a git repository
+: ${MAGIC_ENTER_OTHER_COMMAND:="ls -lh ."} # run anywhere else
- if [[ -z $BUFFER ]]; then
- echo ""
- if git rev-parse --is-inside-work-tree &>/dev/null; then
- eval "$MAGIC_ENTER_GIT_COMMAND"
- else
- eval "$MAGIC_ENTER_OTHER_COMMAND"
- fi
- zle redisplay
+magic-enter() {
+ # Only run MAGIC_ENTER commands when in PS1 and command line is empty
+ # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#User_002dDefined-Widgets
+ if [[ -n "$BUFFER" || "$CONTEXT" != start ]]; then
+ return
+ fi
+
+ if command git rev-parse --is-inside-work-tree &>/dev/null; then
+ BUFFER="$MAGIC_ENTER_GIT_COMMAND"
else
- zle accept-line
+ BUFFER="$MAGIC_ENTER_OTHER_COMMAND"
fi
}
-zle -N magic-enter
+# Wrapper for the accept-line zle widget (run when pressing Enter)
+
+# If the wrapper already exists don't redefine it
+(( ! ${+functions[_magic-enter_accept-line]} )) || return 0
+
+case "$widgets[accept-line]" in
+ # Override the current accept-line widget, calling the old one
+ user:*) zle -N _magic-enter_orig_accept-line "${widgets[accept-line]#user:}"
+ function _magic-enter_accept-line() {
+ magic-enter
+ zle _magic-enter_orig_accept-line -- "$@"
+ } ;;
+ # If no user widget defined, call the original accept-line widget
+ builtin) function _magic-enter_accept-line() {
+ magic-enter
+ zle .accept-line
+ } ;;
+esac
-bindkey -M emacs "^M" magic-enter
-bindkey -M vicmd "^M" magic-enter
-bindkey -M viins "^M" magic-enter
+zle -N accept-line _magic-enter_accept-line
diff --git a/plugins/mercurial/README.md b/plugins/mercurial/README.md
index 80ea2de31..756964896 100644
--- a/plugins/mercurial/README.md
+++ b/plugins/mercurial/README.md
@@ -30,7 +30,8 @@ plugins=(... mercurial)
| `hgl` | `hg pull -u` |
| `hglr` | `hg pull --rebase` |
| `hgo` | `hg outgoing` |
-
+| `hglg` | `hg log --stat -v` |
+| `hglgp`| `hg log --stat -p -v` |
## Prompt usage
- Switch to a theme which uses `hg_prompt_info`
diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh
index f13430476..e098664c0 100644
--- a/plugins/mercurial/mercurial.plugin.zsh
+++ b/plugins/mercurial/mercurial.plugin.zsh
@@ -17,39 +17,42 @@ alias hgi='hg incoming'
alias hgl='hg pull -u'
alias hglr='hg pull --rebase'
alias hgo='hg outgoing'
+alias hglg='hg log --stat -v'
+alias hglgp='hg log --stat -p -v'
function in_hg() {
- if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then
+ if $(hg branch > /dev/null 2>&1); then
echo 1
fi
}
function hg_get_branch_name() {
- if [ $(in_hg) ]; then
- echo $(hg branch)
+ branch=`hg branch 2>/dev/null`
+ if [ $? -eq 0 ]; then
+ echo $branch
fi
+ unset branch
}
function hg_prompt_info {
- if [ $(in_hg) ]; then
- _DISPLAY=$(hg_get_branch_name)
+ _DISPLAY=`hg branch 2>/dev/null`
+ if [ $? -eq 0 ]; then
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR"
- unset _DISPLAY
fi
+ unset _DISPLAY
}
function hg_dirty_choose {
- if [ $(in_hg) ]; then
- hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
+ hg status -mar 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
+ if [ $? -eq 0 ]; then
if [ $pipestatus[-1] -eq 0 ]; then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
- else
- # Otherwise, no lines were found, or an error occurred. Return clean.
- echo $2
+ return
fi
fi
+ echo $2
}
function hg_dirty {
@@ -57,9 +60,15 @@ function hg_dirty {
}
function hgic() {
- hg incoming "$@" | grep "changeset" | wc -l
+ hg incoming "$@" | grep "changeset" | wc -l
}
function hgoc() {
- hg outgoing "$@" | grep "changeset" | wc -l
+ hg outgoing "$@" | grep "changeset" | wc -l
+}
+
+function hg_get_bookmark_name() {
+ if [ $(in_hg) ]; then
+ echo $(hg id -B)
+ fi
}
diff --git a/plugins/minikube/minikube.plugin.zsh b/plugins/minikube/minikube.plugin.zsh
index f7b365c7f..e87abceaf 100644
--- a/plugins/minikube/minikube.plugin.zsh
+++ b/plugins/minikube/minikube.plugin.zsh
@@ -1,13 +1,13 @@
# Autocompletion for Minikube.
#
if (( $+commands[minikube] )); then
- __MINICUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minicube_completion"
+ __MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion"
- if [[ ! -f $__MINICUBE_COMPLETION_FILE ]]; then
- minikube completion zsh >! $__MINICUBE_COMPLETION_FILE
+ if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then
+ minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE
fi
- [[ -f $__MINICUBE_COMPLETION_FILE ]] && source $__MINICUBE_COMPLETION_FILE
+ [[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_COMPLETION_FILE
- unset __MINICUBE_COMPLETION_FILE
+ unset __MINIKUBE_COMPLETION_FILE
fi
diff --git a/plugins/mix-fast/mix-fast.plugin.zsh b/plugins/mix-fast/mix-fast.plugin.zsh
index e27e30d64..564c50561 100644
--- a/plugins/mix-fast/mix-fast.plugin.zsh
+++ b/plugins/mix-fast/mix-fast.plugin.zsh
@@ -12,7 +12,7 @@ _mix_does_task_list_need_generating () {
}
_mix_generate () {
- mix help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks
+ mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks
}
_mix () {
@@ -21,7 +21,8 @@ _mix () {
echo "\nGenerating .mix_tasks..." > /dev/stderr
_mix_generate
fi
- compadd `cat .mix_tasks`
+ local tasks=(${(f)"$(cat .mix_tasks)"})
+ _describe 'tasks' tasks
fi
}
diff --git a/plugins/mongocli/README.md b/plugins/mongocli/README.md
new file mode 100644
index 000000000..e245f2a4a
--- /dev/null
+++ b/plugins/mongocli/README.md
@@ -0,0 +1,19 @@
+# mongocli plugin
+
+The plugin adds several aliases for common [mongocli](https://docs.mongodb.com/mongocli/stable/) commands.
+
+To use it, add `mongocli` to the plugins array of your zshrc file:
+
+```zsh
+plugins=(... mongocli)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|----------|-------------------------------------------------------------|--------------------------------------------------------|
+| `ma` | `mongocli atlas` | Shortcut for mongocli Atlas commands. |
+| `mcm` | `mongocli cloud-manager` | Shortcut for mongocli Cloud Manager commands. |
+| `mom` | `mongocli ops-manager` | Shortcut for mongocli Cloud Manager commands. |
+| `miam` | `mongocli iam` | Shortcut for mongocli IAM commands. |
+
diff --git a/plugins/mongocli/mongocli.plugin.zsh b/plugins/mongocli/mongocli.plugin.zsh
new file mode 100644
index 000000000..0ca877e61
--- /dev/null
+++ b/plugins/mongocli/mongocli.plugin.zsh
@@ -0,0 +1,4 @@
+alias ma='mongocli atlas'
+alias mcm='mongocli cloud-manager'
+alias mom='mongocli ops-manager'
+alias miam='mongocli iam'
diff --git a/plugins/mvn/README.md b/plugins/mvn/README.md
index 72cea9cb9..815dfd57c 100644
--- a/plugins/mvn/README.md
+++ b/plugins/mvn/README.md
@@ -19,6 +19,7 @@ if it's found, or the mvn command otherwise.
| `mvn!` | `mvn -f <root>/pom.xml` |
| `mvnag` | `mvn archetype:generate` |
| `mvnboot` | `mvn spring-boot:run` |
+| `mvnqdev` | `mvn quarkus:dev` |
| `mvnc` | `mvn clean` |
| `mvncd` | `mvn clean deploy` |
| `mvnce` | `mvn clean eclipse:clean eclipse:eclipse` |
@@ -36,6 +37,7 @@ if it's found, or the mvn command otherwise.
| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
| `mvndt` | `mvn dependency:tree` |
| `mvne` | `mvn eclipse:eclipse` |
+| `mvnfmt` | `mvn fmt:format` |
| `mvnjetty` | `mvn jetty:run` |
| `mvnp` | `mvn package` |
| `mvns` | `mvn site` |
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 0866e5553..e32729aa6 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -1,39 +1,46 @@
-# Calls ./mvnw if found, otherwise execute the original mvn
+# Calls mvnw if found in the current project, otherwise execute the original mvn
mvn-or-mvnw() {
- if [ -x ./mvnw ]; then
- echo "executing mvnw instead of mvn"
- ./mvnw "$@"
- else
- command mvn "$@"
- fi
+ local dir="$PWD"
+ while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
+ dir="${dir:h}"
+ done
+
+ if [[ -x "$dir/mvnw" ]]; then
+ echo "Running \`$dir/mvnw\`..." >&2
+ "$dir/mvnw" "$@"
+ return $?
+ fi
+
+ command mvn "$@"
}
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
mvn-color() {
- local BOLD=$(echoti bold)
- local TEXT_RED=$(echoti setaf 1)
- local TEXT_GREEN=$(echoti setaf 2)
- local TEXT_YELLOW=$(echoti setaf 3)
- local TEXT_BLUE=$(echoti setaf 4)
- local TEXT_WHITE=$(echoti setaf 7)
- local RESET_FORMATTING=$(echoti sgr0)
- (
- # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
- unset LANG
- LC_CTYPE=C mvn "$@" | sed \
- -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
- -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
- -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
- -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
- -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
- -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
-
- # Make sure formatting is reset
- echo -ne "${RESET_FORMATTING}"
- )
+ local BOLD=$(echoti bold)
+ local TEXT_RED=$(echoti setaf 1)
+ local TEXT_GREEN=$(echoti setaf 2)
+ local TEXT_YELLOW=$(echoti setaf 3)
+ local TEXT_BLUE=$(echoti setaf 4)
+ local TEXT_WHITE=$(echoti setaf 7)
+ local RESET_FORMATTING=$(echoti sgr0)
+
+ (
+ # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
+ unset LANG
+ LC_CTYPE=C mvn "$@" | sed \
+ -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
+ -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
+ -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
+ -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
+
+ # Make sure formatting is reset
+ echo -ne "${RESET_FORMATTING}"
+ )
}
-# either use orignal mvn or the mvn wrapper
+# either use original mvn or the mvn wrapper
alias mvn="mvn-or-mvnw"
# Run mvn against the pom found in a project's root directory (assumes a git repo)
@@ -59,8 +66,10 @@ alias mvnd='mvn deploy'
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
alias mvndt='mvn dependency:tree'
alias mvne='mvn eclipse:eclipse'
+alias mvnfmt='mvn fmt:format'
alias mvnjetty='mvn jetty:run'
alias mvnp='mvn package'
+alias mvnqdev='mvn quarkus:dev'
alias mvns='mvn site'
alias mvnsrc='mvn dependency:sources'
alias mvnt='mvn test'
@@ -70,256 +79,262 @@ alias mvn-updates='mvn versions:display-dependency-updates'
function listMavenCompletions {
- local file new_file
- local -a profiles POM_FILES
-
- # Root POM
- POM_FILES=(~/.m2/settings.xml)
-
- # POM in the current directory
- if [[ -f pom.xml ]]; then
- local file=pom.xml
- POM_FILES+=("${file:A}")
- fi
-
- # Look for POM files in parent directories
- while [[ -n "$file" ]] && grep -q "<parent>" "$file"; do
- # look for a new relativePath for parent pom.xml
- new_file=$(grep -e "<relativePath>.*</relativePath>" "$file" | sed -e 's/.*<relativePath>\(.*\)<\/relativePath>.*/\1/')
-
- # if <parent> is present but not defined, assume ../pom.xml
- if [[ -z "$new_file" ]]; then
- new_file="../pom.xml"
- fi
-
- # if file doesn't exist break
- file="${file:h}/${new_file}"
- if ! [[ -e "$file" ]]; then
- break
- fi
-
- POM_FILES+=("${file:A}")
- done
-
- # Get profiles from found files
- for file in $POM_FILES; do
- [[ -e $file ]] || continue
- profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
- done
-
- reply=(
- # common lifecycle
- clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
-
- # integration testing
- pre-integration-test integration-test
-
- # common plugins
- deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt
-
- # deploy
- deploy:deploy-file
- # failsafe
- failsafe:integration-test failsafe:verify
- # install
- install:install-file install:help
- # site
- site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
- # surefire
- surefire:test
-
- # checkstyle
- checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
- # javadoc
- javadoc:javadoc javadoc:test-javadoc javadoc:javadoc-no-fork javadoc:test-javadoc-no-fork javadoc:aggregate javadoc:test-aggregate javadoc:jar javadoc:test-jar javadoc:aggregate-jar javadoc:test-aggregate-jar javadoc:fix javadoc:test-fix javadoc:resource-bundle javadoc:test-resource-bundle
- # jxr
- jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
- # pmd
- pmd:pmd pmd:cpd pmd:check pmd:cpd-check
-
- # ant
- ant:ant ant:clean
- # antrun
- antrun:run
- # archetype
- archetype:generate archetype:create-from-project archetype:crawl
- # assembly
- assembly:single assembly:assembly
- # dependency
- dependency:analyze dependency:analyze-dep-mgt dependency:analyze-only dependency:analyze-report dependency:analyze-duplicate dependency:build-classpath dependency:copy dependency:copy-dependencies dependency:display-ancestors dependency:get dependency:go-offline dependency:list dependency:list-repositories dependency:properties dependency:purge-local-repository dependency:resolve dependency:resolve-plugins dependency:sources dependency:tree dependency:unpack dependency:unpack-dependencies
- # enforcer
- enforcer:enforce enforcer:display-info
- # gpg
- gpg:sign gpg:sign-and-deploy-file
- # help
- help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
- # release
- release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
- # jgitflow
- jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
- # repository
- repository:bundle-create repository:bundle-pack
- # source
- source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
-
- # eclipse
- eclipse:clean eclipse:eclipse
- # idea
- idea:clean idea:idea
-
- # jetty
- jetty:run jetty:run-exploded
- # cargo
- cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
- # jboss
- jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
- # tomcat
- tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
- # tomcat6
- tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
- # tomcat7
- tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
- # tomee
- tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
- # spring-boot
- spring-boot:run spring-boot:repackage
- # exec
- exec:exec exec:java
- # versions
- versions:display-dependency-updates versions:display-plugin-updates versions:display-property-updates versions:update-parent versions:update-properties versions:update-child-modules versions:lock-snapshots versions:unlock-snapshots versions:resolve-ranges versions:set versions:use-releases versions:use-next-releases versions:use-latest-releases versions:use-next-snapshots versions:use-latest-snapshots versions:use-next-versions versions:use-latest-versions versions:commit versions:revert
- # scm
- scm:add scm:bootstrap scm:branch scm:changelog scm:check-local-modification scm:checkin scm:checkout scm:diff scm:edit scm:export scm:list scm:remove scm:status scm:tag scm:unedit scm:update scm:update-subprojects scm:validate
- # buildnumber
- buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
-
- # war
- war:war war:exploded war:inplace war:manifest
- # ear
- ear:ear ear:generate-application-xml
- # ejb
- ejb:ejb
- # android
- android:apk android:apklib android:deploy android:deploy-dependencies android:dex android:emulator-start android:emulator-stop android:emulator-stop-all android:generate-sources android:help android:instrument android:manifest-update android:pull android:push android:redeploy android:run android:undeploy android:unpack android:version-update android:zipalign android:devices
- # nexus
- nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
- # repository
- repository:bundle-create repository:bundle-pack repository:help
-
- # sonar
- sonar:sonar
- # license
- license:format license:check
- # hibernate3
- hibernate3:hbm2ddl hibernate3:help
- # liquibase
- liquibase:changelogSync liquibase:changelogSyncSQL liquibase:clearCheckSums liquibase:dbDoc liquibase:diff liquibase:dropAll liquibase:help liquibase:migrate liquibase:listLocks liquibase:migrateSQL liquibase:releaseLocks liquibase:rollback liquibase:rollbackSQL liquibase:status liquibase:tag liquibase:update liquibase:updateSQL liquibase:updateTestingRollback
- # flyway
- flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
- # gwt
- gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test
- # asciidoctor
- asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
- # compiler
- compiler:compile compiler:testCompile
- # resources
- resources:resources resources:testResources resources:copy-resources
- # verifier
- verifier:verify
- # jar
- jar:jar jar:test-jar
- # rar
- rar:rar
- # acr
- acr:acr
- # shade
- shade:shade
- # changelog
- changelog:changelog changelog:dev-activity changelog:file-activity
- # changes
- changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
- # doap
- doap:generate
- # docck
- docck:check
- # jdeps
- jdeps:jdkinternals jdeps:test-jdkinternals
- # linkcheck
- linkcheck:linkcheck
- # project-info-reports
- project-info-reports:cim project-info-reports:dependencies project-info-reports:dependency-convergence project-info-reports:dependency-info project-info-reports:dependency-management project-info-reports:distribution-management project-info-reports:help project-info-reports:index project-info-reports:issue-tracking project-info-reports:license project-info-reports:mailing-list project-info-reports:modules project-info-reports:plugin-management project-info-reports:plugins project-info-reports:project-team project-info-reports:scm project-info-reports:summary
- # surefire-report
- surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
- # invoker
- invoker:install invoker:integration-test invoker:verify invoker:run
- # jarsigner
- jarsigner:sign jarsigner:verify
- # patch
- patch:apply
- # pdf
- pdf:pdf
- # plugin
- plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
- # remote-resources
- remote-resources:bundle remote-resources:process
- # scm-publish
- scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
- # stage
- stage:copy
- # toolchain
- toolchain:toolchain
- #liberty
- liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
-
- # options
- "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
-
- # arguments
- -am --also-make
- -amd --also-make-dependents-am
- -B --batch-mode
- -b --builder
- -C --strict-checksums
- -c --lax-checksums
- -cpu --check-plugin-updates
- -D --define
- -e --errors
- -emp --encrypt-master-password
- -ep --encrypt-password
- -f --file
- -fae --fail-at-end
- -ff --fail-fast
- -fn --fail-never
- -gs --global-settings
- -gt --global-toolchains
- -h --help
- -l --log-file
- -llr --legacy-local-repository
- -N --non-recursive
- -npr --no-plugin-registry
- -npu --no-plugin-updates
- -nsu --no-snapshot-updates
- -o --offline
- -P --activate-profiles
- -pl --projects
- -q --quiet
- -rf --resume-from
- -s --settings
- -t --toolchains
- -T --threads
- -U --update-snapshots
- -up --update-plugins
- -v --version
- -V --show-version
- -X --debug
-
- cli:execute cli:execute-phase
- archetype:generate generate-sources
- cobertura:cobertura
- -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
- -Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
-
- $profiles
- )
+ local file new_file
+ local -a profiles POM_FILES modules
+
+ # Root POM
+ POM_FILES=(~/.m2/settings.xml)
+
+ # POM in the current directory
+ if [[ -f pom.xml ]]; then
+ local file=pom.xml
+ POM_FILES+=("${file:A}")
+ fi
+
+ # Look for POM files in parent directories
+ while [[ -n "$file" ]] && grep -q "<parent>" "$file"; do
+ # look for a new relativePath for parent pom.xml
+ new_file=$(grep -e "<relativePath>.*</relativePath>" "$file" | sed -e 's/.*<relativePath>\(.*\)<\/relativePath>.*/\1/')
+
+ # if <parent> is present but not defined, assume ../pom.xml
+ if [[ -z "$new_file" ]]; then
+ new_file="../pom.xml"
+ fi
+
+ # if file doesn't exist break
+ file="${file:h}/${new_file}"
+ if ! [[ -e "$file" ]]; then
+ break
+ fi
+
+ POM_FILES+=("${file:A}")
+ done
+
+ # Get profiles from found files
+ for file in $POM_FILES; do
+ [[ -e $file ]] || continue
+ profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
+ done
+
+ # List modules
+ modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
+
+ reply=(
+ # common lifecycle
+ clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
+
+ # integration testing
+ pre-integration-test integration-test
+
+ # common plugins
+ deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt
+
+ # deploy
+ deploy:deploy-file
+ # failsafe
+ failsafe:integration-test failsafe:verify
+ # install
+ install:install-file install:help
+ # site
+ site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
+ # surefire
+ surefire:test
+
+ # checkstyle
+ checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
+ # javadoc
+ javadoc:javadoc javadoc:test-javadoc javadoc:javadoc-no-fork javadoc:test-javadoc-no-fork javadoc:aggregate javadoc:test-aggregate javadoc:jar javadoc:test-jar javadoc:aggregate-jar javadoc:test-aggregate-jar javadoc:fix javadoc:test-fix javadoc:resource-bundle javadoc:test-resource-bundle
+ # jxr
+ jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
+ # pmd
+ pmd:pmd pmd:cpd pmd:check pmd:cpd-check
+
+ # ant
+ ant:ant ant:clean
+ # antrun
+ antrun:run
+ # archetype
+ archetype:generate archetype:create-from-project archetype:crawl
+ # assembly
+ assembly:single assembly:assembly
+ # dependency
+ dependency:analyze dependency:analyze-dep-mgt dependency:analyze-only dependency:analyze-report dependency:analyze-duplicate dependency:build-classpath dependency:copy dependency:copy-dependencies dependency:display-ancestors dependency:get dependency:go-offline dependency:list dependency:list-repositories dependency:properties dependency:purge-local-repository dependency:resolve dependency:resolve-plugins dependency:sources dependency:tree dependency:unpack dependency:unpack-dependencies
+ # enforcer
+ enforcer:enforce enforcer:display-info
+ # gpg
+ gpg:sign gpg:sign-and-deploy-file
+ # help
+ help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
+ # release
+ release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
+ # jgitflow
+ jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
+ # repository
+ repository:bundle-create repository:bundle-pack
+ # source
+ source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
+
+ # eclipse
+ eclipse:clean eclipse:eclipse
+ # idea
+ idea:clean idea:idea
+
+ # jetty
+ jetty:run jetty:run-exploded
+ # cargo
+ cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
+ # jboss
+ jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
+ # tomcat
+ tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
+ # tomcat6
+ tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
+ # tomcat7
+ tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
+ # tomee
+ tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
+ # spring-boot
+ spring-boot:run spring-boot:repackage
+ # quarkus
+ quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
+ # exec
+ exec:exec exec:java
+ # versions
+ versions:display-dependency-updates versions:display-plugin-updates versions:display-property-updates versions:update-parent versions:update-properties versions:update-child-modules versions:lock-snapshots versions:unlock-snapshots versions:resolve-ranges versions:set versions:use-releases versions:use-next-releases versions:use-latest-releases versions:use-next-snapshots versions:use-latest-snapshots versions:use-next-versions versions:use-latest-versions versions:commit versions:revert
+ # scm
+ scm:add scm:bootstrap scm:branch scm:changelog scm:check-local-modification scm:checkin scm:checkout scm:diff scm:edit scm:export scm:list scm:remove scm:status scm:tag scm:unedit scm:update scm:update-subprojects scm:validate
+ # buildnumber
+ buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
+
+ # war
+ war:war war:exploded war:inplace war:manifest
+ # ear
+ ear:ear ear:generate-application-xml
+ # ejb
+ ejb:ejb
+ # android
+ android:apk android:apklib android:deploy android:deploy-dependencies android:dex android:emulator-start android:emulator-stop android:emulator-stop-all android:generate-sources android:help android:instrument android:manifest-update android:pull android:push android:redeploy android:run android:undeploy android:unpack android:version-update android:zipalign android:devices
+ # nexus
+ nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
+ # repository
+ repository:bundle-create repository:bundle-pack repository:help
+
+ # sonar
+ sonar:sonar
+ # license
+ license:format license:check
+ # hibernate3
+ hibernate3:hbm2ddl hibernate3:help
+ # liquibase
+ liquibase:changelogSync liquibase:changelogSyncSQL liquibase:clearCheckSums liquibase:dbDoc liquibase:diff liquibase:dropAll liquibase:help liquibase:migrate liquibase:listLocks liquibase:migrateSQL liquibase:releaseLocks liquibase:rollback liquibase:rollbackSQL liquibase:status liquibase:tag liquibase:update liquibase:updateSQL liquibase:updateTestingRollback
+ # flyway
+ flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
+ # gwt
+ gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test
+ # asciidoctor
+ asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
+ # compiler
+ compiler:compile compiler:testCompile
+ # resources
+ resources:resources resources:testResources resources:copy-resources
+ # verifier
+ verifier:verify
+ # jar
+ jar:jar jar:test-jar
+ # rar
+ rar:rar
+ # acr
+ acr:acr
+ # shade
+ shade:shade
+ # changelog
+ changelog:changelog changelog:dev-activity changelog:file-activity
+ # changes
+ changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
+ # doap
+ doap:generate
+ # docck
+ docck:check
+ # jdeps
+ jdeps:jdkinternals jdeps:test-jdkinternals
+ # linkcheck
+ linkcheck:linkcheck
+ # project-info-reports
+ project-info-reports:cim project-info-reports:dependencies project-info-reports:dependency-convergence project-info-reports:dependency-info project-info-reports:dependency-management project-info-reports:distribution-management project-info-reports:help project-info-reports:index project-info-reports:issue-tracking project-info-reports:license project-info-reports:mailing-list project-info-reports:modules project-info-reports:plugin-management project-info-reports:plugins project-info-reports:project-team project-info-reports:scm project-info-reports:summary
+ # surefire-report
+ surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
+ # invoker
+ invoker:install invoker:integration-test invoker:verify invoker:run
+ # jarsigner
+ jarsigner:sign jarsigner:verify
+ # patch
+ patch:apply
+ # pdf
+ pdf:pdf
+ # plugin
+ plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
+ # remote-resources
+ remote-resources:bundle remote-resources:process
+ # scm-publish
+ scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
+ # stage
+ stage:copy
+ # toolchain
+ toolchain:toolchain
+ #liberty
+ liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
+
+ # options
+ "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
+
+ # arguments
+ -am --also-make
+ -amd --also-make-dependents-am
+ -B --batch-mode
+ -b --builder
+ -C --strict-checksums
+ -c --lax-checksums
+ -cpu --check-plugin-updates
+ -D --define
+ -e --errors
+ -emp --encrypt-master-password
+ -ep --encrypt-password
+ -f --file
+ -fae --fail-at-end
+ -ff --fail-fast
+ -fn --fail-never
+ -gs --global-settings
+ -gt --global-toolchains
+ -h --help
+ -l --log-file
+ -llr --legacy-local-repository
+ -N --non-recursive
+ -npr --no-plugin-registry
+ -npu --no-plugin-updates
+ -nsu --no-snapshot-updates
+ -o --offline
+ -P --activate-profiles
+ -pl --projects
+ -q --quiet
+ -rf --resume-from
+ -s --settings
+ -t --toolchains
+ -T --threads
+ -U --update-snapshots
+ -up --update-plugins
+ -v --version
+ -V --show-version
+ -X --debug
+
+ cli:execute cli:execute-phase
+ archetype:generate generate-sources
+ cobertura:cobertura
+ -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
+ -Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
+
+ $profiles
+ $modules
+ )
}
compctl -K listMavenCompletions mvn mvnw
diff --git a/plugins/npm/README.md b/plugins/npm/README.md
index 0b1a2280f..47d153619 100644
--- a/plugins/npm/README.md
+++ b/plugins/npm/README.md
@@ -15,8 +15,10 @@ plugins=(... npm)
| `npmg` | `npm i -g` | Install dependencies globally |
| `npmS` | `npm i -S` | Install and save to dependencies in your package.json |
| `npmD` | `npm i -D` | Install and save to dev-dependencies in your package.json |
+| `npmF` | `npm i -f` | Force install from remote registries ignoring local cache |
| `npmE` | `PATH="$(npm bin)":"$PATH"` | Run command from node_modules folder based on current directory |
| `npmO` | `npm outdated` | Check which npm modules are outdated |
+| `npmU` | `npm update` | Update all the packages listed to the latest version |
| `npmV` | `npm -v` | Check package versions |
| `npmL` | `npm list` | List installed packages |
| `npmL0` | `npm ls --depth=0` | List top-level installed packages |
@@ -25,3 +27,5 @@ plugins=(... npm)
| `npmR` | `npm run` | Run npm scripts |
| `npmP` | `npm publish` | Run npm publish |
| `npmI` | `npm init` | Run npm init |
+| `npmi` | `npm info` | Run npm info |
+| `npmSe` | `npm search` | Run npm search |
diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
index 87c68f3fb..f7d6d3939 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -27,6 +27,9 @@ alias npmS="npm i -S "
# npmd is used by https://github.com/dominictarr/npmd
alias npmD="npm i -D "
+# Force npm to fetch remote resources even if a local copy exists on disk.
+alias npmF='npm i -f'
+
# Execute command from node_modules folder based on current directory
# i.e npmE gulp
alias npmE='PATH="$(npm bin)":"$PATH"'
@@ -34,6 +37,9 @@ alias npmE='PATH="$(npm bin)":"$PATH"'
# Check which npm modules are outdated
alias npmO="npm outdated"
+# Update all the packages listed to the latest version
+alias npmU="npm update"
+
# Check package versions
alias npmV="npm -v"
@@ -57,3 +63,9 @@ alias npmP="npm publish"
# Run npm init
alias npmI="npm init"
+
+# Run npm info
+alias npmi="npm info"
+
+# Run npm search
+alias npmSe="npm search"
diff --git a/plugins/npx/README.md b/plugins/npx/README.md
index 1c052930b..41e4c1352 100644
--- a/plugins/npx/README.md
+++ b/plugins/npx/README.md
@@ -1,21 +1,15 @@
# NPX Plugin
-> npx(1) -- execute npm package binaries. ([more info](https://github.com/zkat/npx))
-This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
+> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx))
-## Setup
+This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
-- Add plugin to `~/.zshrc`
+To use it, add `npx` to the plugins array in your zshrc file:
-```bash
+```zsh
plugins=(.... npx)
```
-- Globally install npx binary (npx will be auto installed with recent versions of Node.js)
-```bash
-sudo npm install -g npx
-```
-
## Note
The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`:
@@ -29,3 +23,17 @@ Started
It does it this way so folks using the fallback don't accidentally try to install regular typoes.
+## Deprecation
+
+Since npm v7, `npx` has been moved to `npm exec`. With the move, [the `--shell-auto-fallback` argument
+for `npx` has been removed](https://github.com/npm/cli/blob/v7.0.0/docs/content/cli-commands/npm-exec.md#compatibility-with-older-npx-versions):
+
+> Shell fallback functionality is removed, as it is not advisable.
+
+When using npm v7, you'll get this error:
+
+> npx: the --shell-auto-fallback argument has been removed
+
+If you get this error, just disable the plugin by removing it from the plugins array in your zshrc file.
+This plugin will no longer be maintained and will be removed in the future, when the older `npx` versions
+are no longer available.
diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
index 079cf0009..0c2bbf9f0 100644
--- a/plugins/nvm/README.md
+++ b/plugins/nvm/README.md
@@ -1,9 +1,32 @@
# nvm plugin
-This plugin adds autocompletions for [nvm](https://github.com/creationix/nvm) — a Node.js version manager.
+This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager.
It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`.
To use it, add `nvm` to the plugins array of your zshrc file:
+
```zsh
plugins=(... nvm)
```
+
+## Settings
+
+If you installed nvm in a directory other than `$HOME/.nvm`, set and export `NVM_DIR` to be the directory
+where you installed nvm.
+
+These settings should go in your zshrc file, before Oh My Zsh is sourced:
+
+- **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you
+ can set `NVM_HOMEBREW` to be the directory where you installed it.
+
+- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session,
+ set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function
+ for `node`, `npm`, `yarn`, and the command(s) specified by `NVM_LAZY_CMD`, so when you call either of them,
+ nvm will load with `nvm use default`.
+
+- **`NVM_LAZY_CMD`**: if you want additional command(s) to trigger lazy loading of nvm, set `NVM_LAZY_CMD` to
+ the command or an array of the commands.
+
+- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when
+ if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating
+ which node version to load.
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 4bab8e9d7..3ef8cc1d8 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -1,8 +1,77 @@
-# Set NVM_DIR if it isn't already defined
-[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
+# See https://github.com/nvm-sh/nvm#installation-and-update
+if [[ -z "$NVM_DIR" ]]; then
+ if [[ -d "$HOME/.nvm" ]]; then
+ export NVM_DIR="$HOME/.nvm"
+ elif [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]]; then
+ export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm"
+ fi
+fi
+
+# Don't try to load nvm if command already available
+which nvm &> /dev/null && return
+
+if [[ -f "$NVM_DIR/nvm.sh" ]]; then
+ # Load nvm if it exists in $NVM_DIR
+ source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
+else
+ # Otherwise try to load nvm installed via Homebrew
+ # User can set this if they have an unusual Homebrew setup
+ NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
+ # Load nvm from Homebrew location if it exists
+ if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then
+ source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
+ else
+ # Exit the plugin if we couldn't find nvm
+ return
+ fi
+fi
+
+# Call nvm when first using node, npm or yarn
+if (( $+NVM_LAZY )); then
+ function node npm yarn $NVM_LAZY_CMD {
+ unfunction node npm yarn $NVM_LAZY_CMD
+ nvm use default
+ command "$0" "$@"
+ }
+fi
-# Try to load nvm only if command not already available
-if ! type "nvm" &> /dev/null; then
- # Load nvm if it exists
- [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
+# Autoload nvm when finding a .nvmrc file in the current directory
+# Adapted from: https://github.com/nvm-sh/nvm#zsh
+if (( $+NVM_AUTOLOAD )); then
+ load-nvmrc() {
+ local node_version="$(nvm version)"
+ local nvmrc_path="$(nvm_find_nvmrc)"
+
+ if [[ -n "$nvmrc_path" ]]; then
+ local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
+
+ if [[ "$nvmrc_node_version" = "N/A" ]]; then
+ nvm install
+ elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
+ nvm use
+ fi
+ elif [[ "$node_version" != "$(nvm version default)" ]]; then
+ echo "Reverting to nvm default version"
+ nvm use default
+ fi
+ }
+
+ autoload -U add-zsh-hook
+ add-zsh-hook chpwd load-nvmrc
+
+ load-nvmrc
fi
+
+# Load nvm bash completion
+for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
+ if [[ -f "$nvm_completion" ]]; then
+ # Load bashcompinit
+ autoload -U +X bashcompinit && bashcompinit
+ # Bypass compinit call in nvm bash completion script. See:
+ # https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
+ ZSH_VERSION= source "$nvm_completion"
+ break
+ fi
+done
+
+unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion
diff --git a/plugins/octozen/README.md b/plugins/octozen/README.md
new file mode 100644
index 000000000..2051248ca
--- /dev/null
+++ b/plugins/octozen/README.md
@@ -0,0 +1,12 @@
+# Octozen plugin
+
+Displays a zen quote from GitHub's Octocat on start up.
+
+To use it, add `octozen` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... octozen)
+```
+
+It defines a `display_octozen` function that fetches a GitHub Octocat zen quote.
+NOTE: Internet connection is required (will time out if not fetched in 2 seconds).
diff --git a/plugins/octozen/octozen.plugin.zsh b/plugins/octozen/octozen.plugin.zsh
new file mode 100644
index 000000000..71ee550a5
--- /dev/null
+++ b/plugins/octozen/octozen.plugin.zsh
@@ -0,0 +1,11 @@
+# octozen plugin
+
+# Displays a zen quote from octocat
+function display_octozen() {
+ curl -m 2 -fsL "https://api.github.com/octocat"
+ add-zsh-hook -d precmd display_octozen
+}
+
+# Display the octocat on the first precmd, after the whole starting process has finished
+autoload -Uz add-zsh-hook
+add-zsh-hook precmd display_octozen
diff --git a/plugins/osx/README.md b/plugins/osx/README.md
index 50e9e7f21..ecc9327d0 100644
--- a/plugins/osx/README.md
+++ b/plugins/osx/README.md
@@ -22,14 +22,17 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
| `pfs` | Return the current Finder selection |
| `cdf` | `cd` to the current Finder directory |
| `pushdf` | `pushd` to the current Finder directory |
+| `pxd` | Return the current Xcode project directory |
+| `cdx` | `cd` to the current Xcode project directory |
| `quick-look` | Quick-Look a specified file |
| `man-preview` | Open a specified man page in Preview app |
-| `showfiles` | Show hidden files |
-| `hidefiles` | Hide the hidden files |
-| `itunes` | DEPRECATED. Use `music` from macOS Catalina on |
+| `showfiles` | Show hidden files in Finder |
+| `hidefiles` | Hide the hidden files in Finder |
+| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
| `music` | Control Apple Music. Use `music -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track… |
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
+| `btrestart` | Restart the Bluetooth daemon |
## Acknowledgements
diff --git a/plugins/osx/_security b/plugins/osx/_security
new file mode 100644
index 000000000..e4ed585ac
--- /dev/null
+++ b/plugins/osx/_security
@@ -0,0 +1,90 @@
+#compdef security
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'help:Show all commands, or show usage for a command'
+ 'list-keychains:Display or manipulate the keychain search list'
+ 'default-keychain:Display or set the default keychain'
+ 'login-keychain:Display or set the login keychain'
+ 'create-keychain:Create keychains and add them to the search list'
+ 'delete-keychain:Delete keychains and remove them from the search list'
+ 'lock-keychain:Lock the specified keychain'
+ 'lock-keychain:Unlock the specified keychain'
+ 'set-keychain-settings:Set settings for a keychain'
+ 'set-keychain-password:Set password for a keychain'
+ 'show-keychain-info:Show the settings for keychain'
+ 'dump-keychain:Dump the contents of one or more keychains'
+ 'create-keypair:Create an asymmetric key pair'
+ 'add-generic-password:Add a generic password item'
+ 'add-internet-password:Add an internet password item'
+ 'add-certificates:Add certificates to a keychain'
+ 'find-generic-password:Find a generic password item'
+ 'delete-generic-password:Delete a generic password item'
+ 'find-internet-password:Find an internet password item'
+ 'delete-internet-password:Delete an internet password item'
+ 'find-certificate:Find a certificate item'
+ 'find-identity:Find an identity certificate + private key'
+ 'delete-certificate:Delete a certificate from a keychain'
+ 'set-identity-preference:Set the preferred identity to use for a service'
+ 'get-identity-preference:Get the preferred identity to use for a service'
+ 'create-db:Create a db using the DL'
+ 'export:Export items from a keychain'
+ 'import:Import items into a keychain'
+ 'cms:Encode or decode CMS messages'
+ 'install-mds:MDS database'
+ 'add-trusted-cert:Add trusted certificates:'
+ 'remove-trusted-cert:Remove trusted certificates:'
+ 'dump-trust-settings:Display contents of trust settings'
+ 'user-trust-settings-enable:Display or manipulate user-level trust settings'
+ 'trust-settings-export:Export trust settings'
+ 'trust-settings-import:Import trust settings'
+ 'verify-cert:Verify certificates:'
+ 'authorize:Perform authorization operations'
+ 'authorizationdb:Make changes to the authorization policy database'
+ 'execute-with-privileges:Execute tool with privileges'
+ 'leaks:Run /usr/bin/leaks on this process'
+ 'error:Display a descriptive message for the given error codes:'
+ 'create-filevaultmaster-keychain:"Create a keychain containing a key pair for FileVault recovery use'
+)
+_arguments '*:: :->command'
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "security command" _1st_arguments
+ return
+fi
+
+case "$words[1]" in
+ find-(generic|internet)-password)
+ _values \
+ 'Usage: find-[internet/generic]-password [-a account] [-s server] [options...] [-g] [keychain...]' \
+ '-a[Match "account" string]' \
+ '-c[Match "creator" (four-character code)]' \
+ '-C[Match "type" (four-character code)]' \
+ '-D[Match "kind" string]' \
+ '-G[Match "value" string (generic attribute)]' \
+ '-j[Match "comment" string]' \
+ '-l[Match "label" string]' \
+ '-s[Match "service" string]' \
+ '-g[Display the password for the item found]' \
+ '-w[Display only the password on stdout]' ;;
+ add-(generic|internet)-password)
+ _values \
+ 'Usage: add-[internet/generic]-password [-a account] [-s server] [-w password] [options...] [-A|-T appPath] [keychain]]' \
+ '-a[Specify account name (required)]' \
+ '-c[Specify item creator (optional four-character code)]' \
+ '-C[Specify item type (optional four-character code)]' \
+ '-d[Specify security domain string (optional)]' \
+ '-D[Specify kind (default is "Internet password")]' \
+ '-j[Specify comment string (optional)]' \
+ '-l[Specify label (if omitted, server name is used as default label)]' \
+ '-p[Specify path string (optional)]' \
+ '-P[Specify port number (optional)]' \
+ '-r[Specify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")]' \
+ '-s[Specify server name (required)]' \
+ '-t[Specify authentication type (as a four-character SecAuthenticationType, default is "dflt")]' \
+ '-w[Specify password to be added]' \
+ '-A[Allow any application to access this item without warning (insecure, not recommended!)]' \
+ '-T[Specify an application which may access this item (multiple -T options are allowed)]' \
+ '-U[Update item if it already exists (if omitted, the item cannot already exist) ]' \
+ 'utils)]' ;;
+esac
diff --git a/plugins/osx/music b/plugins/osx/music
new file mode 100644
index 000000000..50566797b
--- /dev/null
+++ b/plugins/osx/music
@@ -0,0 +1,170 @@
+#!/usr/bin/env zsh
+
+function music itunes() {
+ local APP_NAME=Music sw_vers=$(sw_vers -productVersion 2>/dev/null)
+
+ autoload is-at-least
+ if [[ -z "$sw_vers" ]] || is-at-least 10.15 $sw_vers; then
+ if [[ $0 = itunes ]]; then
+ echo >&2 The itunes function name is deprecated. Use \'music\' instead.
+ return 1
+ fi
+ else
+ APP_NAME=iTunes
+ fi
+
+ local opt=$1 playlist=$2
+ (( $# > 0 )) && shift
+ case "$opt" in
+ launch|play|pause|stop|rewind|resume|quit)
+ ;;
+ mute)
+ opt="set mute to true"
+ ;;
+ unmute)
+ opt="set mute to false"
+ ;;
+ next|previous)
+ opt="$opt track"
+ ;;
+ vol)
+ local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
+ if [[ $# -eq 0 ]]; then
+ echo "Current volume is ${volume}."
+ return 0
+ fi
+ case $1 in
+ up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;;
+ down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;;
+ <0-100>) new_volume=$1 ;;
+ *) echo "'$1' is not valid. Expected <0-100>, up or down."
+ return 1 ;;
+ esac
+ opt="set sound volume to ${new_volume}"
+ ;;
+ playlist)
+ # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
+ if [[ -n "$playlist" ]]; then
+ osascript 2>/dev/null <<EOF
+ tell application "$APP_NAME"
+ set new_playlist to "$playlist" as string
+ play playlist new_playlist
+ end tell
+EOF
+ if [[ $? -eq 0 ]]; then
+ opt="play"
+ else
+ opt="stop"
+ fi
+ else
+ opt="set allPlaylists to (get name of every playlist)"
+ fi
+ ;;
+ playing|status)
+ local currenttrack currentartist state=$(osascript -e "tell application \"$APP_NAME\" to player state as string")
+ if [[ "$state" = "playing" ]]; then
+ currenttrack=$(osascript -e "tell application \"$APP_NAME\" to name of current track as string")
+ currentartist=$(osascript -e "tell application \"$APP_NAME\" to artist of current track as string")
+ echo -E "Listening to ${fg[yellow]}${currenttrack}${reset_color} by ${fg[yellow]}${currentartist}${reset_color}"
+ else
+ echo "$APP_NAME is $state"
+ fi
+ return 0
+ ;;
+ shuf|shuff|shuffle)
+ # The shuffle property of current playlist can't be changed in iTunes 12,
+ # so this workaround uses AppleScript to simulate user input instead.
+ # Defaults to toggling when no options are given.
+ # The toggle option depends on the shuffle button being visible in the Now playing area.
+ # On and off use the menu bar items.
+ local state=$1
+
+ if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then
+ print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
+ return 1
+ fi
+
+ case "$state" in
+ on|off)
+ # Inspired by: https://stackoverflow.com/a/14675583
+ osascript >/dev/null 2>&1 <<EOF
+ tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
+EOF
+ return 0
+ ;;
+ toggle|*)
+ osascript >/dev/null 2>&1 <<EOF
+ tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
+EOF
+ return 0
+ ;;
+ esac
+ ;;
+ ""|-h|--help)
+ echo "Usage: $0 <option>"
+ echo "option:"
+ echo "\t-h|--help\tShow this message and exit"
+ echo "\tlaunch|play|pause|stop|rewind|resume|quit"
+ echo "\tmute|unmute\tMute or unmute $APP_NAME"
+ echo "\tnext|previous\tPlay next or previous track"
+ echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
+ echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
+ echo "\tplaying|status\tShow what song is currently playing in Music."
+ echo "\tplaylist [playlist name]\t Play specific playlist"
+ return 0
+ ;;
+ *)
+ print "Unknown option: $opt"
+ return 1
+ ;;
+ esac
+ osascript -e "tell application \"$APP_NAME\" to $opt"
+}
+
+function _music() {
+ local app_name
+ case "$words[1]" in
+ itunes) app_name="iTunes" ;;
+ music|*) app_name="Music" ;;
+ esac
+
+ local -a cmds subcmds
+ cmds=(
+ "launch:Launch the ${app_name} app"
+ "play:Play ${app_name}"
+ "pause:Pause ${app_name}"
+ "stop:Stop ${app_name}"
+ "rewind:Rewind ${app_name}"
+ "resume:Resume ${app_name}"
+ "quit:Quit ${app_name}"
+ "mute:Mute the ${app_name} app"
+ "unmute:Unmute the ${app_name} app"
+ "next:Skip to the next song"
+ "previous:Skip to the previous song"
+ "vol:Change the volume"
+ "playlist:Play a specific playlist"
+ {playing,status}":Show what song is currently playing"
+ {shuf,shuff,shuffle}":Set shuffle mode"
+ {-h,--help}":Show usage"
+ )
+
+ if (( CURRENT == 2 )); then
+ _describe 'command' cmds
+ elif (( CURRENT == 3 )); then
+ case "$words[2]" in
+ vol) subcmds=( 'up:Raise the volume' 'down:Lower the volume' )
+ _describe 'command' subcmds ;;
+ shuf|shuff|shuffle) subcmds=('on:Switch on shuffle mode' 'off:Switch off shuffle mode' 'toggle:Toggle shuffle mode (default)')
+ _describe 'command' subcmds ;;
+ esac
+ elif (( CURRENT == 4 )); then
+ case "$words[2]" in
+ playlist) subcmds=('play:Play the playlist (default)' 'stop:Stop the playlist')
+ _describe 'command' subcmds ;;
+ esac
+ fi
+
+ return 0
+}
+
+compdef _music music itunes
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 03e9c1c8c..5455d7c5f 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -1,15 +1,22 @@
# Open the current directory in a Finder window
alias ofd='open_command $PWD'
+# Show/hide hidden files in the Finder
+alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
+alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
+
+# Bluetooth restart
+function btrestart() {
+ sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
+ sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
+}
+
function _omz_osx_get_frontmost_app() {
- local the_app=$(
- osascript 2>/dev/null <<EOF
- tell application "System Events"
- name of first item of (every process whose frontmost is true)
- end tell
+ osascript 2>/dev/null <<EOF
+ tell application "System Events"
+ name of first item of (every process whose frontmost is true)
+ end tell
EOF
- )
- echo "$the_app"
}
function tab() {
@@ -27,7 +34,6 @@ function tab() {
end tell
tell application "Terminal" to do script "${command}" in front window
EOF
-
elif [[ "$the_app" == 'iTerm' ]]; then
osascript <<EOF
tell application "iTerm"
@@ -41,32 +47,29 @@ EOF
end tell
end tell
EOF
-
elif [[ "$the_app" == 'iTerm2' ]]; then
- osascript <<EOF
- tell application "iTerm2"
- tell current window
- create tab with default profile
- tell current session to write text "${command}"
- end tell
+ osascript <<EOF
+ tell application "iTerm2"
+ tell current window
+ create tab with default profile
+ tell current session to write text "${command}"
end tell
+ end tell
EOF
elif [[ "$the_app" == 'Hyper' ]]; then
osascript >/dev/null <<EOF
- tell application "System Events"
- tell process "Hyper" to keystroke "t" using command down
- end tell
- delay 1
- tell application "System Events"
- keystroke "${command}"
- key code 36 #(presses enter)
- end tell
+ tell application "System Events"
+ tell process "Hyper" to keystroke "t" using command down
+ end tell
+ delay 1
+ tell application "System Events"
+ keystroke "${command}"
+ key code 36 #(presses enter)
+ end tell
EOF
-
else
- echo "tab: unsupported terminal app: $the_app"
- false
-
+ echo "$0: unsupported terminal app: $the_app" >&2
+ return 1
fi
}
@@ -79,7 +82,6 @@ function vsplit_tab() {
if [[ "$the_app" == 'iTerm' ]]; then
osascript <<EOF
-- tell application "iTerm" to activate
-
tell application "System Events"
tell process "iTerm"
tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
@@ -89,37 +91,33 @@ function vsplit_tab() {
keystroke "${command} \n"
end tell
EOF
-
elif [[ "$the_app" == 'iTerm2' ]]; then
- osascript <<EOF
- tell application "iTerm2"
- tell current session of first window
- set newSession to (split vertically with same profile)
- tell newSession
- write text "${command}"
- select
- end tell
+ osascript <<EOF
+ tell application "iTerm2"
+ tell current session of first window
+ set newSession to (split vertically with same profile)
+ tell newSession
+ write text "${command}"
+ select
end tell
end tell
+ end tell
EOF
-
elif [[ "$the_app" == 'Hyper' ]]; then
- osascript >/dev/null <<EOF
- tell application "System Events"
- tell process "Hyper"
- tell menu item "Split Vertically" of menu "Shell" of menu bar 1
- click
- end tell
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Hyper"
+ tell menu item "Split Vertically" of menu "Shell" of menu bar 1
+ click
end tell
- delay 1
- keystroke "${command} \n"
end tell
+ delay 1
+ keystroke "${command} \n"
+ end tell
EOF
-
else
echo "$0: unsupported terminal app: $the_app" >&2
- false
-
+ return 1
fi
}
@@ -142,44 +140,40 @@ function split_tab() {
keystroke "${command} \n"
end tell
EOF
-
elif [[ "$the_app" == 'iTerm2' ]]; then
- osascript <<EOF
- tell application "iTerm2"
- tell current session of first window
- set newSession to (split horizontally with same profile)
- tell newSession
- write text "${command}"
- select
- end tell
+ osascript <<EOF
+ tell application "iTerm2"
+ tell current session of first window
+ set newSession to (split horizontally with same profile)
+ tell newSession
+ write text "${command}"
+ select
end tell
end tell
+ end tell
EOF
-
elif [[ "$the_app" == 'Hyper' ]]; then
- osascript >/dev/null <<EOF
- tell application "System Events"
- tell process "Hyper"
- tell menu item "Split Horizontally" of menu "Shell" of menu bar 1
- click
- end tell
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Hyper"
+ tell menu item "Split Horizontally" of menu "Shell" of menu bar 1
+ click
end tell
- delay 1
- keystroke "${command} \n"
end tell
+ delay 1
+ keystroke "${command} \n"
+ end tell
EOF
-
else
echo "$0: unsupported terminal app: $the_app" >&2
- false
-
+ return 1
fi
}
function pfd() {
osascript 2>/dev/null <<EOF
tell application "Finder"
- return POSIX path of (target of window 1 as alias)
+ return POSIX path of (insertion location as alias)
end tell
EOF
}
@@ -205,12 +199,28 @@ function pushdf() {
pushd "$(pfd)"
}
+function pxd() {
+ dirname $(osascript 2>/dev/null <<EOF
+ if application "Xcode" is running then
+ tell application "Xcode"
+ return path of active workspace document
+ end tell
+ end if
+EOF
+)
+}
+
+function cdx() {
+ cd "$(pxd)"
+}
+
function quick-look() {
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
}
function man-preview() {
- man -t "$@" | open -f -a Preview
+ # Don't let Preview.app steal focus if the man page doesn't exist
+ man -w "$@" &>/dev/null && man -t "$@" | open -f -a Preview || man "$@"
}
compdef _man man-preview
@@ -218,133 +228,13 @@ function vncviewer() {
open vnc://$@
}
-# iTunes control function
-function itunes music() {
- local APP_NAME=Music
-
- autoload is-at-least
- if is-at-least 10.15 $(sw_vers -productVersion); then
- if [[ $0 = itunes ]]; then
- echo >&2 The itunes function name is deprecated. Use \`music\' instead.
- return 1
- fi
- else
- APP_NAME=iTunes
- fi
-
- local opt=$1
- local playlist=$2
- shift
- case "$opt" in
- launch|play|pause|stop|rewind|resume|quit)
- ;;
- mute)
- opt="set mute to true"
- ;;
- unmute)
- opt="set mute to false"
- ;;
- next|previous)
- opt="$opt track"
- ;;
- vol)
- local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
- if [[ $# -eq 0 ]]; then
- echo "Current volume is ${volume}."
- return 0
- fi
- case $1 in
- up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;;
- down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;;
- <0-100>) new_volume=$1 ;;
- *) echo "'$1' is not valid. Expected <0-100>, up or down."
- return 1 ;;
- esac
- opt="set sound volume to ${new_volume}"
- ;;
- playlist)
- # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
- if [[ ! -z "$playlist" ]]; then
- osascript -e "tell application \"$APP_NAME\"" -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
- if [[ $? -eq 0 ]]; then
- opt="play"
- else
- opt="stop"
- fi
- else
- opt="set allPlaylists to (get name of every playlist)"
- fi
- ;;
- playing|status)
- local state=`osascript -e "tell application \"$APP_NAME\" to player state as string"`
- if [[ "$state" = "playing" ]]; then
- currenttrack=`osascript -e "tell application \"$APP_NAME\" to name of current track as string"`
- currentartist=`osascript -e "tell application \"$APP_NAME\" to artist of current track as string"`
- echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
- else
- echo "$APP_NAME is" $state;
- fi
- return 0
- ;;
- shuf|shuff|shuffle)
- # The shuffle property of current playlist can't be changed in iTunes 12,
- # so this workaround uses AppleScript to simulate user input instead.
- # Defaults to toggling when no options are given.
- # The toggle option depends on the shuffle button being visible in the Now playing area.
- # On and off use the menu bar items.
- local state=$1
-
- if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
- then
- print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
- return 1
- fi
-
- case "$state" in
- on|off)
- # Inspired by: https://stackoverflow.com/a/14675583
- osascript 1>/dev/null 2>&1 <<-EOF
- tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
-EOF
- return 0
- ;;
- toggle|*)
- osascript 1>/dev/null 2>&1 <<-EOF
- tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
-EOF
- return 0
- ;;
- esac
- ;;
- ""|-h|--help)
- echo "Usage: $0 <option>"
- echo "option:"
- echo "\tlaunch|play|pause|stop|rewind|resume|quit"
- echo "\tmute|unmute\tcontrol volume set"
- echo "\tnext|previous\tplay next or previous track"
- echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
- echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
- echo "\tplaying|status\tShow what song is currently playing in Music."
- echo "\tplaylist [playlist name]\t Play specific playlist"
- echo "\thelp\tshow this message and exit"
- return 0
- ;;
- *)
- print "Unknown option: $opt"
- return 1
- ;;
- esac
- osascript -e "tell application \"$APP_NAME\" to $opt"
-}
-
-# Spotify control function
-source ${ZSH}/plugins/osx/spotify
-
-# Show/hide hidden files in the Finder
-alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
-alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
-
# Remove .DS_Store files recursively in a directory, default .
function rmdsstore() {
- find "${@:-.}" -type f -name .DS_Store -delete
+ find "${@:-.}" -type f -name .DS_Store -delete
}
+
+# Music / iTunes control function
+source "${0:h:A}/music"
+
+# Spotify control function
+source "${0:h:A}/spotify"
diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh
index 41de2f91d..7cd673cdb 100644
--- a/plugins/per-directory-history/per-directory-history.zsh
+++ b/plugins/per-directory-history/per-directory-history.zsh
@@ -32,7 +32,7 @@
#
# Copyright (c) 2014 Jim Hester
#
-# This software is provided 'as-is', without any express or implied warranty.
+# This software is provided 'as-is', without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from the
# use of this software.
#
@@ -57,6 +57,7 @@
#-------------------------------------------------------------------------------
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
+[[ -z $HISTORY_START_WITH_GLOBAL ]] && HISTORY_START_WITH_GLOBAL=false
[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
#-------------------------------------------------------------------------------
@@ -66,9 +67,11 @@
function per-directory-history-toggle-history() {
if [[ $_per_directory_history_is_global == true ]]; then
_per-directory-history-set-directory-history
+ _per_directory_history_is_global=false
print -n "\nusing local history"
else
_per-directory-history-set-global-history
+ _per_directory_history_is_global=true
print -n "\nusing global history"
fi
zle .push-line
@@ -114,43 +117,58 @@ function _per-directory-history-addhistory() {
true
else
print -Sr -- "${1%%$'\n'}"
+ # instantly write history if set options require it.
+ if [[ -o share_history ]] || \
+ [[ -o inc_append_history ]] || \
+ [[ -o inc_append_history_time ]]; then
+ fc -AI $HISTFILE
+ fc -AI $_per_directory_history_directory
+ fi
fc -p $_per_directory_history_directory
fi
}
+function _per-directory-history-precmd() {
+ if [[ $_per_directory_history_initialized == false ]]; then
+ _per_directory_history_initialized=true
-function _per-directory-history-set-directory-history() {
- if [[ $_per_directory_history_is_global == true ]]; then
- fc -AI $HISTFILE
- local original_histsize=$HISTSIZE
- HISTSIZE=0
- HISTSIZE=$original_histsize
- if [[ -e "$_per_directory_history_directory" ]]; then
- fc -R "$_per_directory_history_directory"
+ if [[ $HISTORY_START_WITH_GLOBAL == true ]]; then
+ _per-directory-history-set-global-history
+ _per_directory_history_is_global=true
+ else
+ _per-directory-history-set-directory-history
+ _per_directory_history_is_global=false
fi
fi
- _per_directory_history_is_global=false
}
+
+function _per-directory-history-set-directory-history() {
+ fc -AI $HISTFILE
+ local original_histsize=$HISTSIZE
+ HISTSIZE=0
+ HISTSIZE=$original_histsize
+ if [[ -e "$_per_directory_history_directory" ]]; then
+ fc -R "$_per_directory_history_directory"
+ fi
+}
+
function _per-directory-history-set-global-history() {
- if [[ $_per_directory_history_is_global == false ]]; then
- fc -AI $_per_directory_history_directory
- local original_histsize=$HISTSIZE
- HISTSIZE=0
- HISTSIZE=$original_histsize
- if [[ -e "$HISTFILE" ]]; then
- fc -R "$HISTFILE"
- fi
+ fc -AI $_per_directory_history_directory
+ local original_histsize=$HISTSIZE
+ HISTSIZE=0
+ HISTSIZE=$original_histsize
+ if [[ -e "$HISTFILE" ]]; then
+ fc -R "$HISTFILE"
fi
- _per_directory_history_is_global=true
}
+mkdir -p ${_per_directory_history_directory:h}
#add functions to the exec list for chpwd and zshaddhistory
autoload -U add-zsh-hook
add-zsh-hook chpwd _per-directory-history-change-directory
add-zsh-hook zshaddhistory _per-directory-history-addhistory
+add-zsh-hook precmd _per-directory-history-precmd
-#start in directory mode
-mkdir -p ${_per_directory_history_directory:h}
-_per_directory_history_is_global=true
-_per-directory-history-set-directory-history
+# set initialized flag to false
+_per_directory_history_initialized=false
diff --git a/plugins/pip/README.md b/plugins/pip/README.md
index f07b5c058..88d88227e 100644
--- a/plugins/pip/README.md
+++ b/plugins/pip/README.md
@@ -17,3 +17,12 @@ or you can run `zsh-pip-cache-packages` directly.
To reset the cache, run `zsh-pip-clear-cache` and it will be rebuilt next
the next time you autocomplete `pip install`.
+
+## Aliases
+
+| Alias | Description |
+| :------- | :-------------------------------------------- |
+| pipreq | Create requirements file |
+| pipir | Install packages from `requirements.txt` file |
+| pipupall | Update all installed packages |
+| pipunall | Uninstall all installed packages |
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh
index aaae90185..629147bae 100644
--- a/plugins/pip/pip.plugin.zsh
+++ b/plugins/pip/pip.plugin.zsh
@@ -9,7 +9,11 @@
# If you would like to clear your cache, go ahead and do a
# "zsh-pip-clear-cache".
-ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
+if [[ -d "${XDG_CACHE_HOME:-$HOME/.cache}/pip" ]]; then
+ ZSH_PIP_CACHE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/pip/zsh-cache"
+else
+ ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
+fi
ZSH_PIP_INDEXES=(https://pypi.org/simple/)
zsh-pip-clear-cache() {
@@ -80,3 +84,14 @@ zsh-pip-test-clean-packages() {
alias pip="noglob pip" # allows square brackets for pip command invocation
+# Create requirements file
+alias pipreq="pip freeze > requirements.txt"
+
+# Update all installed packages
+alias pipupall="pipreq && sed -i 's/==/>=/g' requirements.txt && pip install -r requirements.txt --upgrade && rm -rf requirements.txt"
+
+# Install packages from requirements file
+alias pipir="pip install -r requirements.txt"
+
+# Uninstalled all installed packages
+alias pipunall="pipreq && pip uninstall -r requirements.txt -y && rm -rf requirements.txt"
diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh
index e7a9e6b3c..4be61a920 100644
--- a/plugins/pipenv/pipenv.plugin.zsh
+++ b/plugins/pipenv/pipenv.plugin.zsh
@@ -1,6 +1,6 @@
# Pipenv completion
_pipenv() {
- eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
+ eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
}
compdef _pipenv pipenv
@@ -25,6 +25,7 @@ _togglePipenvShell() {
}
autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePipenvShell
+_togglePipenvShell
# Aliases
alias pch="pipenv check"
diff --git a/plugins/pm2/README.md b/plugins/pm2/README.md
new file mode 100644
index 000000000..5dfd540b6
--- /dev/null
+++ b/plugins/pm2/README.md
@@ -0,0 +1,19 @@
+# pm2 plugin
+
+The plugin adds several aliases and completions for common [pm2](http://pm2.keymetrics.io/) commands.
+
+To use it, add `pm2` to the plugins array of your zshrc file:
+```
+plugins=(... pm2)
+```
+
+## Aliases
+
+| Alias | Command |
+|--------|----------------------|
+| p2s | `pm2 start` |
+| p2o | `pm2 stop` |
+| p2d | `pm2 delete` |
+| p2r | `pm2 restart` |
+| p2i | `pm2 list` |
+| p2l | `pm2 logs` |
diff --git a/plugins/pm2/_pm2 b/plugins/pm2/_pm2
new file mode 100644
index 000000000..6f1e89df5
--- /dev/null
+++ b/plugins/pm2/_pm2
@@ -0,0 +1,168 @@
+#!/bin/zsh -f
+#compdef pm2
+#autoload
+
+local -a _1st_arguments
+
+_1st_arguments=(
+ "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"
+ "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"
+ "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"
+ "package:Check & Package TAR type module"
+ "publish:Publish the module you are currently on"
+ "set:sets the specified config <key> <value>"
+ "multiset:multiset eg \"key1 val1 key2 val2\""
+ "get:get value for <key>"
+ "config:get / set module config values"
+ "unset:clears the specified config <key>"
+ "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"
+ "web:launch a health API on 0.0.0.0\:9615"
+ "dump:dump all processes for resurrecting them later"
+ "cleardump:Create empty dump file"
+ "send:send stdin to <pm_id>"
+ "attach:attach stdin/stdout to application identified by <pm_id>"
+ "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. (mode = null or simple)"
+ "reset:reset counters for process"
+ "describe:describe all parameters of a process id"
+ "list:list all processes"
+ "jlist:list all processes in JSON format"
+ "prettylist:print json in a prettified JSON"
+ "monit:launch termcaps monitoring"
+ "imonit:launch legacy termcaps monitoring"
+ "dashboard: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"
+ "examples:display pm2 usage examples"
+)
+
+local -a id_names
+
+_id_names() {
+ local app_list
+ app_list=`pm2 list -m`
+
+ local -a names ids
+ names=(`echo $app_list | grep '+---' | awk '{print $2}'`)
+ ids=(`echo $app_list | grep 'pm2 id' | awk '{print $4}'`)
+
+ if (( ${#ids} > 0 )); then
+ for i in {1..${#ids}}; do
+ id_names+=( "${ids[i]}:${names[i]}" )
+ done
+ fi
+}
+
+_arguments \
+ '(-v --version)'{-v,--version}'[output version]' \
+ '(-h --help)'{-h,--help}'[output usage information]' \
+ '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe "command" _1st_arguments
+ return
+fi
+
+local -a id_comp id_all_comp id_all_files_comp start_options logs_options
+id_comp=('1: :->id_comp')
+id_all_comp=('1: :->id_all_comp')
+id_all_files_comp=('1: :->id_all_files_comp')
+start_options=(
+ '--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]'
+ '--node-version[with --container, set a specific major Node.js version]'
+ '--dockerdaemon[for debugging purpose]'
+ '(-h --help)'{-h,--help}'[output usage information]'
+ $id_all_files_comp
+)
+logs_options=(
+ '--json[json log output]'
+ '--format[formated log output]'
+ '--raw[raw output]'
+ '--err[only shows error output]'
+ '--out[only shows standard output]'
+ '--lines[output the last N lines, instead of the last 15 by default]'
+ '--timestamp[add timestamps (default format YYYY-MM-DD-HH:mm:ss)]'
+ '--nostream[print logs without lauching the log stream]'
+ '(-h --help)'{-h,--help}'[output usage information]'
+ $id_all_comp
+)
+
+case "$words[1]" in
+ start)
+ _arguments $start_options && return 0
+ ;;
+ logs)
+ _arguments $logs_options && return 0
+ ;;
+ stop|restart|delete|reload|reset)
+ _arguments $id_all_comp && return 0
+ ;;
+ env|inspect|monitor|unmonitor|discribe)
+ _arguments $id_comp && return 0
+ ;;
+ deploy|startOrRestart|startOrReload)
+ _files ;;
+esac
+
+case "$state" in
+ id_comp)
+ _id_names
+ _alternative \
+ 'args:app args:(($id_names))'
+ ;;
+ id_all_comp)
+ _id_names
+ id_names+=(all)
+ _alternative \
+ 'args:app args:(($id_names))'
+ ;;
+ id_all_files_comp)
+ _id_names
+ id_names+=(all)
+ _alternative \
+ 'args:app args:(($id_names))' \
+ 'files:filename:_files'
+ ;;
+esac
diff --git a/plugins/pm2/pm2.plugin.zsh b/plugins/pm2/pm2.plugin.zsh
new file mode 100644
index 000000000..f05d8db8b
--- /dev/null
+++ b/plugins/pm2/pm2.plugin.zsh
@@ -0,0 +1,6 @@
+alias p2s='pm2 start'
+alias p2o='pm2 stop'
+alias p2d='pm2 delete'
+alias p2r='pm2 restart'
+alias p2i='pm2 list'
+alias p2l='pm2 logs'
diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md
index d063b55b9..b9ee937b7 100644
--- a/plugins/pyenv/README.md
+++ b/plugins/pyenv/README.md
@@ -1,4 +1,4 @@
-# pyenv
+# pyenv
This plugin looks for [pyenv](https://github.com/pyenv/pyenv), a Simple Python version
management system, and loads it if it's found. It also loads pyenv-virtualenv, a pyenv
@@ -10,6 +10,14 @@ To use it, add `pyenv` to the plugins array in your zshrc file:
plugins=(... pyenv)
```
+## Settings
+
+- `ZSH_PYENV_QUIET`: if set to `true`, the plugin will not print any messages if it
+ finds that `pyenv` is not properly configured.
+
+- `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv
+ when it finds it.
+
## Functions
- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
index 4c75156bd..39897ed16 100644
--- a/plugins/pyenv/pyenv.plugin.zsh
+++ b/plugins/pyenv/pyenv.plugin.zsh
@@ -1,42 +1,96 @@
+pyenv_config_warning() {
+ [[ "$ZSH_PYENV_QUIET" != true ]] || return 0
+
+ local reason="$1"
+ local pyenv_root="${PYENV_ROOT/#$HOME/\$HOME}"
+ cat >&2 <<EOF
+Found pyenv, but it is badly configured ($reason). pyenv might not
+work correctly for non-interactive shells (for example, when run from a script).
+${(%):-"%B%F{yellow}"}
+To fix this message, add these lines to the '.profile' and '.zprofile' files
+in your home directory:
+${(%):-"%f"}
+export PYENV_ROOT="$pyenv_root"
+export PATH="\$PYENV_ROOT/bin:\$PATH"
+eval "\$(pyenv init --path)"
+${(%):-"%F{yellow}"}
+You'll need to restart your user session for the changes to take effect.${(%):-%b%f}
+For more information go to https://github.com/pyenv/pyenv/#installation.
+EOF
+}
+
# This plugin loads pyenv into the current shell and provides prompt info via
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
-# Load pyenv only if command not already available
-command -v pyenv &> /dev/null && FOUND_PYENV=1 || FOUND_PYENV=0
-
-if [[ $FOUND_PYENV -ne 1 ]]; then
- pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv")
- for dir in $pyenvdirs; do
- if [[ -d $dir/bin ]]; then
- export PATH="$PATH:$dir/bin"
- FOUND_PYENV=1
- break
- fi
- done
+# Look for pyenv in $PATH and verify that it's not a part of pyenv-win in WSL
+if ! command -v pyenv &>/dev/null; then
+ FOUND_PYENV=0
+elif [[ "${commands[pyenv]}" = */pyenv-win/* && "$(uname -r)" = *icrosoft* ]]; then
+ FOUND_PYENV=0
+else
+ FOUND_PYENV=1
fi
+# Look for pyenv and try to load it (will only work on interactive shells)
if [[ $FOUND_PYENV -ne 1 ]]; then
+ pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv")
+ for dir in $pyenvdirs; do
+ if [[ -d "$dir/bin" ]]; then
+ FOUND_PYENV=1
+ break
+ fi
+ done
+
+ if [[ $FOUND_PYENV -ne 1 ]]; then
if (( $+commands[brew] )) && dir=$(brew --prefix pyenv 2>/dev/null); then
- if [[ -d $dir/bin ]]; then
- export PATH="$PATH:$dir/bin"
- FOUND_PYENV=1
- fi
+ if [[ -d "$dir/bin" ]]; then
+ FOUND_PYENV=1
+ fi
fi
+ fi
+
+ # If we found pyenv, load it but show a caveat about non-interactive shells
+ if [[ $FOUND_PYENV -eq 1 ]]; then
+ # Configuring in .zshrc only makes pyenv available for interactive shells
+ export PYENV_ROOT="$dir"
+ export PATH="$PYENV_ROOT/bin:$PATH"
+ eval "$(pyenv init --path)"
+
+ # Show warning due to bad pyenv configuration
+ pyenv_config_warning 'pyenv command not found in $PATH'
+ fi
fi
if [[ $FOUND_PYENV -eq 1 ]]; then
- eval "$(pyenv init - zsh)"
- if (( $+commands[pyenv-virtualenv-init] )); then
- eval "$(pyenv virtualenv-init - zsh)"
- fi
- function pyenv_prompt_info() {
- echo "$(pyenv version-name)"
- }
+ if [[ -z "$PYENV_ROOT" ]]; then
+ # This is only for backwards compatibility with users that previously relied
+ # on this plugin exporting it. pyenv itself does not require it to be exported
+ export PYENV_ROOT="$(pyenv root)"
+ fi
+
+ # Add pyenv shims to $PATH if not already added
+ if [[ -z "${path[(Re)$(pyenv root)/shims]}" ]]; then
+ eval "$(pyenv init --path)"
+ pyenv_config_warning 'missing pyenv shims in $PATH'
+ fi
+
+ # Load pyenv
+ eval "$(pyenv init - --no-rehash zsh)"
+
+ # If pyenv-virtualenv exists, load it
+ if [[ "$(pyenv commands)" =~ "virtualenv-init" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
+ eval "$(pyenv virtualenv-init - zsh)"
+ fi
+
+ function pyenv_prompt_info() {
+ echo "$(pyenv version-name)"
+ }
else
- # fallback to system python
- function pyenv_prompt_info() {
- echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')"
- }
+ # Fall back to system python
+ function pyenv_prompt_info() {
+ echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')"
+ }
fi
unset FOUND_PYENV pyenvdirs dir
+unfunction pyenv_config_warning
diff --git a/plugins/python/README.md b/plugins/python/README.md
index 0180218a2..b95ffe679 100644
--- a/plugins/python/README.md
+++ b/plugins/python/README.md
@@ -11,6 +11,7 @@ plugins=(... python)
| Command | Description |
|------------------|---------------------------------------------------------------------------------|
+| `py` | Runs `python` |
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
| `pyfind` | Finds .py files recursively in the current directory |
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh
index c3c1474c1..276eb6f91 100644
--- a/plugins/python/python.plugin.zsh
+++ b/plugins/python/python.plugin.zsh
@@ -1,3 +1,6 @@
+# python command
+alias py='python'
+
# Find python file
alias pyfind='find . -name "*.py"'
diff --git a/plugins/rails/README.md b/plugins/rails/README.md
index 9fb1cecf1..efdb8f8ba 100644
--- a/plugins/rails/README.md
+++ b/plugins/rails/README.md
@@ -21,6 +21,8 @@ plugins=(... rails)
| `rgen`| `rails generate` | Generate boilerplate code |
| `rgm` | `rails generate migration` | Generate a db migration |
| `rp` | `rails plugin` | Run a Rails plugin command |
+| `rr` | `rails routes` | List all defined routes |
+| `rrg` | `rails routes \| grep` | List and filter the defined routes |
| `ru` | `rails runner` | Run Ruby code in the context of Rails |
| `rs` | `rails server` | Launch a web server |
| `rsd` | `rails server --debugger` | Launch a web server with debugger |
@@ -43,8 +45,6 @@ plugins=(... rails)
| `rdsl` | `rake db:schema:load` | Load the database schema |
| `rlc` | `rake log:clear` | Clear Rails logs |
| `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
-| `rr` | `rake routes` | List all defined routes |
-| `rrg` | `rake routes \| grep` | List and filter the defined routes |
| `rt` | `rake test` | Run Rails tests |
| `rmd` | `rake middleware` | Interact with Rails middlewares |
| `rsts` | `rake stats` | Print code statistics |
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index 1fd5f0f86..29b413434 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -46,14 +46,20 @@ alias rdb='rails dbconsole'
alias rgen='rails generate'
alias rgm='rails generate migration'
alias rp='rails plugin'
+alias rr='rails routes'
+alias rrg='rails routes | grep'
alias ru='rails runner'
alias rs='rails server'
alias rsd='rails server --debugger'
alias rsp='rails server --port'
+alias rsb='rails server --bind'
# Rake aliases
alias rdm='rake db:migrate'
+alias rdmr='rake db:migrate:redo'
+alias rdmd='rake db:migrate:down'
alias rdms='rake db:migrate:status'
+alias rdmu='rake db:migrate:up'
alias rdr='rake db:rollback'
alias rdc='rake db:create'
alias rds='rake db:seed'
@@ -65,8 +71,6 @@ alias rdmtc='rake db:migrate db:test:clone'
alias rdsl='rake db:schema:load'
alias rlc='rake log:clear'
alias rn='rake notes'
-alias rr='rake routes'
-alias rrg='rake routes | grep'
alias rt='rake test'
alias rmd='rake middleware'
alias rsts='rake stats'
diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh
index 3c964320a..0f2d366e2 100644
--- a/plugins/rbenv/rbenv.plugin.zsh
+++ b/plugins/rbenv/rbenv.plugin.zsh
@@ -34,7 +34,7 @@ if [[ $FOUND_RBENV -eq 1 ]]; then
}
function current_gemset() {
- echo "$(rbenv gemset active 2>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)"
+ echo "$(rbenv gemset active 2>/dev/null)" | tr ' ' '+'
}
function gems() {
diff --git a/plugins/react-native/react-native.plugin.zsh b/plugins/react-native/react-native.plugin.zsh
index b33dedfed..8323c27bd 100644
--- a/plugins/react-native/react-native.plugin.zsh
+++ b/plugins/react-native/react-native.plugin.zsh
@@ -27,6 +27,9 @@ alias rniosxr='react-native run-ios --simulator "iPhone Xʀ"'
alias rnios11='react-native run-ios --simulator "iPhone 11"'
alias rnios11p='react-native run-ios --simulator "iPhone 11 Pro"'
alias rnios11pm='react-native run-ios --simulator "iPhone 11 Pro Max"'
+alias rnios12='react-native run-ios --simulator "iPhone 12"'
+alias rnios12p='react-native run-ios --simulator "iPhone 12 Pro"'
+alias rnios12pm='react-native run-ios --simulator "iPhone 12 Pro Max"'
# iPad
diff --git a/plugins/rustup/_rustup b/plugins/rustup/_rustup
deleted file mode 100644
index dab33533a..000000000
--- a/plugins/rustup/_rustup
+++ /dev/null
@@ -1,1143 +0,0 @@
-#compdef rustup
-
-autoload -U is-at-least
-
-_rustup() {
- typeset -A opt_args
- typeset -a _arguments_options
- local ret=1
-
- if is-at-least 5.2; then
- _arguments_options=(-s -S -C)
- else
- _arguments_options=(-s -C)
- fi
-
- local context curcontext="$curcontext" state line
- _arguments "${_arguments_options[@]}" \
-'-v[Enable verbose output]' \
-'--verbose[Enable verbose output]' \
-'(-v --verbose)-q[Disable progress output]' \
-'(-v --verbose)--quiet[Disable progress output]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::+toolchain -- release channel (e.g. +stable) or custom toolchain to set override:_files' \
-":: :_rustup_commands" \
-"*::: :->rustup" \
-&& ret=0
- case $state in
- (rustup)
- words=($line[2] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-command-$line[2]:"
- case $line[2] in
- (dump-testament)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(show)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__show_commands" \
-"*::: :->show" \
-&& ret=0
-case $state in
- (show)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-show-command-$line[1]:"
- case $line[1] in
- (active-toolchain)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(home)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(profile)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(keys)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(install)
-_arguments "${_arguments_options[@]}" \
-'--profile=[]: :(minimal default complete)' \
-'--no-self-update[Don'\''t perform self-update when running the `rustup install` command]' \
-'--force[Force an update, even if some components are missing]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(uninstall)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(update)
-_arguments "${_arguments_options[@]}" \
-'--no-self-update[Don'\''t perform self update when running the `rustup update` command]' \
-'--force[Force an update, even if some components are missing]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(check)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(default)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(toolchain)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__toolchain_commands" \
-"*::: :->toolchain" \
-&& ret=0
-case $state in
- (toolchain)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-toolchain-command-$line[1]:"
- case $line[1] in
- (list)
-_arguments "${_arguments_options[@]}" \
-'-v[Enable verbose output with toolchain information]' \
-'--verbose[Enable verbose output with toolchain information]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(update)
-_arguments "${_arguments_options[@]}" \
-'--profile=[]: :(minimal default complete)' \
-'*-c+[Add specific components on installation]' \
-'*--component=[Add specific components on installation]' \
-'*-t+[Add specific targets on installation]' \
-'*--target=[Add specific targets on installation]' \
-'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \
-'--force[Force an update, even if some components are missing]' \
-'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(add)
-_arguments "${_arguments_options[@]}" \
-'--profile=[]: :(minimal default complete)' \
-'*-c+[Add specific components on installation]' \
-'*--component=[Add specific components on installation]' \
-'*-t+[Add specific targets on installation]' \
-'*--target=[Add specific targets on installation]' \
-'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \
-'--force[Force an update, even if some components are missing]' \
-'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(install)
-_arguments "${_arguments_options[@]}" \
-'--profile=[]: :(minimal default complete)' \
-'*-c+[Add specific components on installation]' \
-'*--component=[Add specific components on installation]' \
-'*-t+[Add specific targets on installation]' \
-'*--target=[Add specific targets on installation]' \
-'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \
-'--force[Force an update, even if some components are missing]' \
-'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(remove)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(uninstall)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(link)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-':path:_files' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(target)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__target_commands" \
-"*::: :->target" \
-&& ret=0
-case $state in
- (target)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-target-command-$line[1]:"
- case $line[1] in
- (list)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'--installed[List only installed targets]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(install)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':target -- List of targets to install; "all" installs all available targets:_files' \
-&& ret=0
-;;
-(add)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':target -- List of targets to install; "all" installs all available targets:_files' \
-&& ret=0
-;;
-(uninstall)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':target:_files' \
-&& ret=0
-;;
-(remove)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':target:_files' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(component)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__component_commands" \
-"*::: :->component" \
-&& ret=0
-case $state in
- (component)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-component-command-$line[1]:"
- case $line[1] in
- (list)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'--installed[List only installed components]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(add)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'--target=[]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':component:_files' \
-&& ret=0
-;;
-(remove)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'--target=[]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':component:_files' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(override)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__override_commands" \
-"*::: :->override" \
-&& ret=0
-case $state in
- (override)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-override-command-$line[1]:"
- case $line[1] in
- (list)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(add)
-_arguments "${_arguments_options[@]}" \
-'--path=[Path to the directory]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(set)
-_arguments "${_arguments_options[@]}" \
-'--path=[Path to the directory]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-&& ret=0
-;;
-(remove)
-_arguments "${_arguments_options[@]}" \
-'--path=[Path to the directory]' \
-'--nonexistent[Remove override toolchain for all nonexistent directories]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(unset)
-_arguments "${_arguments_options[@]}" \
-'--path=[Path to the directory]' \
-'--nonexistent[Remove override toolchain for all nonexistent directories]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(run)
-_arguments "${_arguments_options[@]}" \
-'--install[Install the requested toolchain if needed]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \
-':command:_files' \
-&& ret=0
-;;
-(which)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':command:_files' \
-&& ret=0
-;;
-(docs)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'--path[Only print the path to the documentation]' \
-'--alloc[The Rust core allocation and collections library]' \
-'--book[The Rust Programming Language book]' \
-'--cargo[The Cargo Book]' \
-'--core[The Rust Core Library]' \
-'--edition-guide[The Rust Edition Guide]' \
-'--nomicon[The Dark Arts of Advanced and Unsafe Rust Programming]' \
-'--proc_macro[A support library for macro authors when defining new macros]' \
-'--reference[The Rust Reference]' \
-'--rust-by-example[A collection of runnable examples that illustrate various Rust concepts and standard libraries]' \
-'--rustc[The compiler for the Rust programming language]' \
-'--rustdoc[Generate documentation for Rust projects]' \
-'--std[Standard library API documentation]' \
-'--test[Support code for rustc'\''s built in unit-test and micro-benchmarking framework]' \
-'--unstable-book[The Unstable Book]' \
-'--embedded-book[The Embedded Rust Book]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::topic -- Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...:_files' \
-&& ret=0
-;;
-(doc)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'--path[Only print the path to the documentation]' \
-'--alloc[The Rust core allocation and collections library]' \
-'--book[The Rust Programming Language book]' \
-'--cargo[The Cargo Book]' \
-'--core[The Rust Core Library]' \
-'--edition-guide[The Rust Edition Guide]' \
-'--nomicon[The Dark Arts of Advanced and Unsafe Rust Programming]' \
-'--proc_macro[A support library for macro authors when defining new macros]' \
-'--reference[The Rust Reference]' \
-'--rust-by-example[A collection of runnable examples that illustrate various Rust concepts and standard libraries]' \
-'--rustc[The compiler for the Rust programming language]' \
-'--rustdoc[Generate documentation for Rust projects]' \
-'--std[Standard library API documentation]' \
-'--test[Support code for rustc'\''s built in unit-test and micro-benchmarking framework]' \
-'--unstable-book[The Unstable Book]' \
-'--embedded-book[The Embedded Rust Book]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::topic -- Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...:_files' \
-&& ret=0
-;;
-(man)
-_arguments "${_arguments_options[@]}" \
-'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':command:_files' \
-&& ret=0
-;;
-(self)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__self_commands" \
-"*::: :->self" \
-&& ret=0
-case $state in
- (self)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-self-command-$line[1]:"
- case $line[1] in
- (update)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(uninstall)
-_arguments "${_arguments_options[@]}" \
-'-y[]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(upgrade-data)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(set)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-":: :_rustup__set_commands" \
-"*::: :->set" \
-&& ret=0
-case $state in
- (set)
- words=($line[1] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:rustup-set-command-$line[1]:"
- case $line[1] in
- (default-host)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':host_triple:_files' \
-&& ret=0
-;;
-(profile)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-':profile-name:(minimal default complete)' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-;;
-(completions)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::shell:(zsh bash fish powershell elvish)' \
-'::command:(rustup cargo)' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-}
-
-(( $+functions[_rustup_commands] )) ||
-_rustup_commands() {
- local commands; commands=(
- "dump-testament:Dump information about the build" \
-"show:Show the active and installed toolchains or profiles" \
-"install:Update Rust toolchains" \
-"uninstall:Uninstall Rust toolchains" \
-"update:Update Rust toolchains and rustup" \
-"check:Check for updates to Rust toolchains" \
-"default:Set the default toolchain" \
-"toolchain:Modify or query the installed toolchains" \
-"target:Modify a toolchain's supported targets" \
-"component:Modify a toolchain's installed components" \
-"override:Modify directory toolchain overrides" \
-"run:Run a command with an environment configured for a given toolchain" \
-"which:Display which binary will be run for a given command" \
-"doc:Open the documentation for the current toolchain" \
-"man:View the man page for a given command" \
-"self:Modify the rustup installation" \
-"set:Alter rustup settings" \
-"completions:Generate tab-completion scripts for your shell" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup commands' commands "$@"
-}
-(( $+functions[_rustup__show__active-toolchain_commands] )) ||
-_rustup__show__active-toolchain_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup show active-toolchain commands' commands "$@"
-}
-(( $+functions[_rustup__add_commands] )) ||
-_rustup__add_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup add commands' commands "$@"
-}
-(( $+functions[_rustup__component__add_commands] )) ||
-_rustup__component__add_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup component add commands' commands "$@"
-}
-(( $+functions[_rustup__override__add_commands] )) ||
-_rustup__override__add_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup override add commands' commands "$@"
-}
-(( $+functions[_rustup__target__add_commands] )) ||
-_rustup__target__add_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup target add commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__add_commands] )) ||
-_rustup__toolchain__add_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain add commands' commands "$@"
-}
-(( $+functions[_rustup__check_commands] )) ||
-_rustup__check_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup check commands' commands "$@"
-}
-(( $+functions[_rustup__completions_commands] )) ||
-_rustup__completions_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup completions commands' commands "$@"
-}
-(( $+functions[_rustup__component_commands] )) ||
-_rustup__component_commands() {
- local commands; commands=(
- "list:List installed and available components" \
-"add:Add a component to a Rust toolchain" \
-"remove:Remove a component from a Rust toolchain" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup component commands' commands "$@"
-}
-(( $+functions[_rustup__default_commands] )) ||
-_rustup__default_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup default commands' commands "$@"
-}
-(( $+functions[_rustup__set__default-host_commands] )) ||
-_rustup__set__default-host_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup set default-host commands' commands "$@"
-}
-(( $+functions[_rustup__doc_commands] )) ||
-_rustup__doc_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup doc commands' commands "$@"
-}
-(( $+functions[_docs_commands] )) ||
-_docs_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'docs commands' commands "$@"
-}
-(( $+functions[_rustup__docs_commands] )) ||
-_rustup__docs_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup docs commands' commands "$@"
-}
-(( $+functions[_rustup__dump-testament_commands] )) ||
-_rustup__dump-testament_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup dump-testament commands' commands "$@"
-}
-(( $+functions[_rustup__component__help_commands] )) ||
-_rustup__component__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup component help commands' commands "$@"
-}
-(( $+functions[_rustup__help_commands] )) ||
-_rustup__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup help commands' commands "$@"
-}
-(( $+functions[_rustup__override__help_commands] )) ||
-_rustup__override__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup override help commands' commands "$@"
-}
-(( $+functions[_rustup__self__help_commands] )) ||
-_rustup__self__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup self help commands' commands "$@"
-}
-(( $+functions[_rustup__set__help_commands] )) ||
-_rustup__set__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup set help commands' commands "$@"
-}
-(( $+functions[_rustup__show__help_commands] )) ||
-_rustup__show__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup show help commands' commands "$@"
-}
-(( $+functions[_rustup__target__help_commands] )) ||
-_rustup__target__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup target help commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__help_commands] )) ||
-_rustup__toolchain__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain help commands' commands "$@"
-}
-(( $+functions[_rustup__show__home_commands] )) ||
-_rustup__show__home_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup show home commands' commands "$@"
-}
-(( $+functions[_rustup__install_commands] )) ||
-_rustup__install_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup install commands' commands "$@"
-}
-(( $+functions[_rustup__target__install_commands] )) ||
-_rustup__target__install_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup target install commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__install_commands] )) ||
-_rustup__toolchain__install_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain install commands' commands "$@"
-}
-(( $+functions[_rustup__show__keys_commands] )) ||
-_rustup__show__keys_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup show keys commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__link_commands] )) ||
-_rustup__toolchain__link_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain link commands' commands "$@"
-}
-(( $+functions[_rustup__component__list_commands] )) ||
-_rustup__component__list_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup component list commands' commands "$@"
-}
-(( $+functions[_rustup__override__list_commands] )) ||
-_rustup__override__list_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup override list commands' commands "$@"
-}
-(( $+functions[_rustup__target__list_commands] )) ||
-_rustup__target__list_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup target list commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__list_commands] )) ||
-_rustup__toolchain__list_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain list commands' commands "$@"
-}
-(( $+functions[_rustup__man_commands] )) ||
-_rustup__man_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup man commands' commands "$@"
-}
-(( $+functions[_rustup__override_commands] )) ||
-_rustup__override_commands() {
- local commands; commands=(
- "list:List directory toolchain overrides" \
-"set:Set the override toolchain for a directory" \
-"unset:Remove the override toolchain for a directory" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup override commands' commands "$@"
-}
-(( $+functions[_rustup__set__profile_commands] )) ||
-_rustup__set__profile_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup set profile commands' commands "$@"
-}
-(( $+functions[_rustup__show__profile_commands] )) ||
-_rustup__show__profile_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup show profile commands' commands "$@"
-}
-(( $+functions[_rustup__component__remove_commands] )) ||
-_rustup__component__remove_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup component remove commands' commands "$@"
-}
-(( $+functions[_rustup__override__remove_commands] )) ||
-_rustup__override__remove_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup override remove commands' commands "$@"
-}
-(( $+functions[_rustup__remove_commands] )) ||
-_rustup__remove_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup remove commands' commands "$@"
-}
-(( $+functions[_rustup__target__remove_commands] )) ||
-_rustup__target__remove_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup target remove commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__remove_commands] )) ||
-_rustup__toolchain__remove_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain remove commands' commands "$@"
-}
-(( $+functions[_rustup__run_commands] )) ||
-_rustup__run_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup run commands' commands "$@"
-}
-(( $+functions[_rustup__self_commands] )) ||
-_rustup__self_commands() {
- local commands; commands=(
- "update:Download and install updates to rustup" \
-"uninstall:Uninstall rustup." \
-"upgrade-data:Upgrade the internal data format." \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup self commands' commands "$@"
-}
-(( $+functions[_rustup__override__set_commands] )) ||
-_rustup__override__set_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup override set commands' commands "$@"
-}
-(( $+functions[_rustup__set_commands] )) ||
-_rustup__set_commands() {
- local commands; commands=(
- "default-host:The triple used to identify toolchains when not specified" \
-"profile:The default components installed" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup set commands' commands "$@"
-}
-(( $+functions[_rustup__show_commands] )) ||
-_rustup__show_commands() {
- local commands; commands=(
- "active-toolchain:Show the active toolchain" \
-"home:Display the computed value of RUSTUP_HOME" \
-"profile:Show the current profile" \
-"keys:Display the known PGP keys" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup show commands' commands "$@"
-}
-(( $+functions[_rustup__target_commands] )) ||
-_rustup__target_commands() {
- local commands; commands=(
- "list:List installed and available targets" \
-"add:Add a target to a Rust toolchain" \
-"remove:Remove a target from a Rust toolchain" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup target commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain_commands] )) ||
-_rustup__toolchain_commands() {
- local commands; commands=(
- "list:List installed toolchains" \
-"install:Install or update a given toolchain" \
-"uninstall:Uninstall a toolchain" \
-"link:Create a custom toolchain by symlinking to a directory" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'rustup toolchain commands' commands "$@"
-}
-(( $+functions[_rustup__self__uninstall_commands] )) ||
-_rustup__self__uninstall_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup self uninstall commands' commands "$@"
-}
-(( $+functions[_rustup__target__uninstall_commands] )) ||
-_rustup__target__uninstall_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup target uninstall commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__uninstall_commands] )) ||
-_rustup__toolchain__uninstall_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain uninstall commands' commands "$@"
-}
-(( $+functions[_rustup__uninstall_commands] )) ||
-_rustup__uninstall_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup uninstall commands' commands "$@"
-}
-(( $+functions[_rustup__override__unset_commands] )) ||
-_rustup__override__unset_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup override unset commands' commands "$@"
-}
-(( $+functions[_rustup__self__update_commands] )) ||
-_rustup__self__update_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup self update commands' commands "$@"
-}
-(( $+functions[_rustup__toolchain__update_commands] )) ||
-_rustup__toolchain__update_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup toolchain update commands' commands "$@"
-}
-(( $+functions[_rustup__update_commands] )) ||
-_rustup__update_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup update commands' commands "$@"
-}
-(( $+functions[_rustup__self__upgrade-data_commands] )) ||
-_rustup__self__upgrade-data_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup self upgrade-data commands' commands "$@"
-}
-(( $+functions[_rustup__which_commands] )) ||
-_rustup__which_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'rustup which commands' commands "$@"
-}
-
-_rustup "$@" \ No newline at end of file
diff --git a/plugins/rustup/rustup.plugin.zsh b/plugins/rustup/rustup.plugin.zsh
new file mode 100644
index 000000000..c6efc1b13
--- /dev/null
+++ b/plugins/rustup/rustup.plugin.zsh
@@ -0,0 +1,22 @@
+if (( $+commands[rustup] )); then
+ # remove old generated completion file
+ command rm -f "${0:A:h}/_rustup"
+
+ ver="$(rustup --version 2>/dev/null)"
+ ver_file="$ZSH_CACHE_DIR/rustup_version"
+ comp_file="$ZSH_CACHE_DIR/completions/_rustup"
+
+ mkdir -p "${comp_file:h}"
+ (( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
+
+ if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
+ rustup completions zsh >| "$comp_file"
+ echo "$ver" >| "$ver_file"
+ fi
+
+ declare -A _comps
+ autoload -Uz _rustup
+ _comps[rustup]=_rustup
+
+ unset ver ver_file comp_file
+fi
diff --git a/plugins/safe-paste/safe-paste.plugin.zsh b/plugins/safe-paste/safe-paste.plugin.zsh
index 75f1791d7..d443ae8a2 100644
--- a/plugins/safe-paste/safe-paste.plugin.zsh
+++ b/plugins/safe-paste/safe-paste.plugin.zsh
@@ -1,54 +1,100 @@
+# A good summary of the zsh 5.1 Bracketed Paste Mode changes is at:
+# https://archive.zhimingwang.org/blog/2015-09-21-zsh-51-and-bracketed-paste.html
+
+# zsh 5.1 (September 2015) introduced built-in support for Bracketed Paste Mode
+# https://github.com/zsh-users/zsh/blob/68405f31a043bdd5bf338eb06688ed3e1f740937/README#L38-L45
+#
+# zsh 5.1 breaks url-quote-magic and other widgets replacing self-insert
+# zsh-users' bracketed-paste-magic resolves these issues:
+# https://github.com/zsh-users/zsh/blob/f702e17b14d75aa21bff014168fa9048124db286/Functions/Zle/bracketed-paste-magic#L9-L12
+
+# Load bracketed-paste-magic if zsh version is >= 5.1
+if [[ ${ZSH_VERSION:0:3} -ge 5.1 ]]; then
+ set zle_bracketed_paste # Explicitly restore this zsh default
+ autoload -Uz bracketed-paste-magic
+ zle -N bracketed-paste bracketed-paste-magic
+ return ### The rest of this file is NOT executed on zsh version >= 5.1 ###
+fi
+
+######################################################################
+# The rest of this file is ONLY executed if zsh version < 5.1
+######################################################################
+
# Code from Mikael Magnusson: https://www.zsh.org/mla/users/2011/msg00367.html
#
-# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
-# paste mode as documented: https://www.xfree86.org/current/ctlseqs.html
-
-# create a new keymap to use while pasting
-bindkey -N paste
-# make everything in this keymap call our custom widget
-bindkey -R -M paste "^@"-"\M-^?" paste-insert
-# these are the codes sent around the pasted text in bracketed
-# paste mode.
-# do the first one with both -M viins and -M vicmd in vi mode
-bindkey '^[[200~' _start_paste
-bindkey -M paste '^[[201~' _end_paste
-# insert newlines rather than carriage returns when pasting newlines
-bindkey -M paste -s '^M' '^J'
-
-zle -N _start_paste
-zle -N _end_paste
-zle -N zle-line-init _zle_line_init
-zle -N zle-line-finish _zle_line_finish
-zle -N paste-insert _paste_insert
-
-# switch the active keymap to paste mode
-function _start_paste() {
- bindkey -A paste main
+# Requires xterm, urxvt, iTerm2 or any other terminal that supports
+# Bracketed Paste Mode as documented:
+# https://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode
+#
+# For tmux, use: bind ] paste-buffer -p
+#
+# Additional technical details: https://cirw.in/blog/bracketed-paste
+
+# Create a new keymap to use while pasting
+bindkey -N bracketed-paste
+# Make everything in this new keymap enqueue characters for pasting
+bindkey -RM bracketed-paste '\x00-\xFF' bracketed-paste-enqueue
+# These are the codes sent around the pasted text in bracketed paste mode
+bindkey -M main '^[[200~' _bracketed_paste_begin
+bindkey -M bracketed-paste '^[[201~' _bracketed_paste_end
+# Insert newlines rather than carriage returns when pasting newlines
+bindkey -M bracketed-paste -s '^M' '^J'
+
+zle -N _bracketed_paste_begin
+zle -N _bracketed_paste_end
+zle -N bracketed-paste-enqueue _bracketed_paste_enqueue
+
+# Attempt to not clobber zle_line_{init,finish}
+# Use https://github.com/willghatch/zsh-hooks if available
+if typeset -f hooks-add-hook > /dev/null; then
+ hooks-add-hook zle_line_init_hook _bracketed_paste_zle_init
+ hooks-add-hook zle_line_finish_hook _bracketed_paste_zle_finish
+else
+ zle -N zle-line-init _bracketed_paste_zle_init
+ zle -N zle-line-finish _bracketed_paste_zle_finish
+fi
+
+# Switch the active keymap to paste mode
+_bracketed_paste_begin() {
+ # Save the bindkey command to restore the active ("main") keymap
+ # Tokenise the restorative bindkey command into an array
+ _bracketed_paste_restore_keymap=( ${(z)"$(bindkey -lL main)"} )
+ bindkey -A bracketed-paste main
}
-# go back to our normal keymap, and insert all the pasted text in the
-# command line. this has the nice effect of making the whole paste be
+# Go back to our normal keymap, and insert all the pasted text in the
+# command line. This has the nice effect of making the whole paste be
# a single undo/redo event.
-function _end_paste() {
-#use bindkey -v here with vi mode probably. maybe you want to track
-#if you were in ins or cmd mode and restore the right one.
- bindkey -e
- LBUFFER+=$_paste_content
- unset _paste_content
+_bracketed_paste_end() {
+ # Only execute the restore command if it starts with 'bindkey'
+ # Allow for option KSH_ARRAYS being set (indexing starts at 0)
+ if [ ${_bracketed_paste_restore_keymap[@]:0:1} = 'bindkey' ]; then
+ $_bracketed_paste_restore_keymap
+ fi
+ LBUFFER+=$_bracketed_paste_content
+ unset _bracketed_paste_content _bracketed_paste_restore_keymap
}
-function _paste_insert() {
- _paste_content+=$KEYS
+# Append a pasted character to the content which is later inserted as a whole
+_bracketed_paste_enqueue() {
+ _bracketed_paste_content+=$KEYS
}
-function _zle_line_init() {
- # Tell terminal to send escape codes around pastes.
- [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'
+# Run at zle-line-init
+_bracketed_paste_zle_init() {
+ _bracketed_paste_content=''
+ # Tell terminal to send escape codes around pastes
+ if [[ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]]; then
+ printf '\e[?2004h'
+ fi
}
-function _zle_line_finish() {
- # Tell it to stop when we leave zle, so pasting in other programs
- # doesn't get the ^[[200~ codes around the pasted text.
- [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'
+# Run at zle-line-finish
+_bracketed_paste_zle_finish() {
+ # Turn off bracketed paste when we leave ZLE, so pasting in other programs
+ # doesn't get the ^[[200~ codes around the pasted text
+ if [[ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]]; then
+ printf '\e[?2004l'
+ fi
}
diff --git a/plugins/samtools/README.md b/plugins/samtools/README.md
new file mode 100644
index 000000000..f4baf41f7
--- /dev/null
+++ b/plugins/samtools/README.md
@@ -0,0 +1,5 @@
+# Samtools plugin
+
+This plugin adds support for [samtools](http://www.htslib.org/):
+
+* Adds autocomplete options for all samtools sub commands.
diff --git a/plugins/samtools/_samtools b/plugins/samtools/_samtools
new file mode 100644
index 000000000..ddb002ae2
--- /dev/null
+++ b/plugins/samtools/_samtools
@@ -0,0 +1,40 @@
+#compdef samtools
+#autoload
+
+local curcontext="$curcontext" state line ret=1
+local -a _files
+
+_arguments -C \
+ '1: :->cmds' \
+ '2:: :->args' && ret=0
+
+case $state in
+ cmds)
+ _values "samtools command" \
+ "view[SAM<->BAM conversion]" \
+ "sort[sort alignment file]" \
+ "mpileup[multi-way pileup]" \
+ "depth[compute the depth]" \
+ "faidx[index/extract FASTA]" \
+ "tview[text alignment viewer]" \
+ "index[index alignment]" \
+ "idxstats[BAM index stats (r595 or later)]" \
+ "fixmate[fix mate information]" \
+ "flagstat[simple stats]" \
+ "calmd[recalculate MD/NM tags and '=' bases]" \
+ "merge[merge sorted alignments]" \
+ "rmdup[remove PCR duplicates]" \
+ "reheader[replace BAM header]" \
+ "cat[concatenate BAMs]" \
+ "bedcov[read depth per BED region]" \
+ "targetcut[cut fosmid regions (for fosmid pool only)]" \
+ "phase[phase heterozygotes]" \
+ "bamshuf[shuffle and group alignments by name]"
+ ret=0
+ ;;
+ *)
+ _files
+ ;;
+esac
+
+return ret
diff --git a/plugins/scd/README.md b/plugins/scd/README.md
index 8c156da1f..d8535f9f2 100644
--- a/plugins/scd/README.md
+++ b/plugins/scd/README.md
@@ -14,8 +14,9 @@ directory aliases, which appear as named directories in zsh session.
## INSTALLATION NOTES
Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
-shells and is also available as [Vim](https://www.vim.org/) plugin and
-[IPython](https://ipython.org/) extension. For installation details, see
+shells and is also available as Vim plugin
+[scd.vim](https://github.com/pavoljuhas/scd.vim) and
+[IPython](https://ipython.org) extension. For installation details, see
https://github.com/pavoljuhas/smart-change-directory.
## SYNOPSIS
@@ -24,11 +25,31 @@ https://github.com/pavoljuhas/smart-change-directory.
scd [options] [pattern1 pattern2 ...]
```
+## PATTERNS
+
+Patterns may use all zsh [glob operators](
+http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators)
+available with *extendedglob* option. Specified patterns must match
+the absolute path and at least one of them must match in the tail.
+Several special patterns are also recognized as follows:
+
+<dl><dt>
+^PAT</dt><dd>
+ PAT must match at the beginning of the path, for example, "^/home"</dd><dt>
+PAT$</dt><dd>
+ require PAT to match the end of the path, "man$"</dd><dt>
+./</dt><dd>
+ match only subdirectories of the current directory</dd><dt>
+:PAT</dt><dd>
+ require PAT to match over the tail component, ":doc", ":re/doc"</dd>
+</dl>
+
+
## OPTIONS
<dl><dt>
-a, --add</dt><dd>
- add specified directories to the directory index.</dd><dt>
+ add current or specified directories to the directory index.</dd><dt>
--unindex</dt><dd>
remove current or specified directories from the index.</dd><dt>
@@ -42,11 +63,16 @@ scd [options] [pattern1 pattern2 ...]
--unalias</dt><dd>
remove ALIAS definition for the current or specified directory from
- <em>~/.scdalias.zsh</em>.</dd><dt>
+ <em>~/.scdalias.zsh</em>. Use "OLD" to purge aliases to non-existent
+ directories.</dd><dt>
-A, --all</dt><dd>
- include all matching directories. Disregard matching by directory
- alias and filtering of less likely paths.</dd><dt>
+ display all directories even those excluded by patterns in
+ <em>~/.scdignore</em>. Disregard the unique matching for a
+ directory alias and filtering of less likely paths.</dd><dt>
+
+-p, --push</dt><dd>
+ use "pushd" to change to the target directory.</dd><dt>
--list</dt><dd>
show matching directories and exit.</dd><dt>
@@ -58,6 +84,7 @@ scd [options] [pattern1 pattern2 ...]
display this options summary and exit.</dd>
</dl>
+
## Examples
```sh
@@ -83,17 +110,26 @@ scd --alias=xray
scd xray
```
-# FILES
+## FILES
<dl><dt>
~/.scdhistory</dt><dd>
time-stamped index of visited directories.</dd><dt>
~/.scdalias.zsh</dt><dd>
- scd-generated definitions of directory aliases.</dd>
+ scd-generated definitions of directory aliases.</dd><dt>
+
+~/.scdignore</dt><dd>
+ <a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators">
+ glob patterns</a> for paths to be ignored in the scd search, for example,
+ <code>/mnt/backup/*</code>. The patterns are specified one per line
+ and are matched assuming the <em>extendedglob</em> zsh option. Lines
+ starting with "#" are skipped as comments. The .scdignore patterns
+ are not applied in the <em>--all</em> mode.</dd>
</dl>
-# ENVIRONMENT
+
+## ENVIRONMENT
<dl><dt>
SCD_HISTFILE</dt><dd>
diff --git a/plugins/scd/_scd b/plugins/scd/_scd
new file mode 100644
index 000000000..39c7fa463
--- /dev/null
+++ b/plugins/scd/_scd
@@ -0,0 +1,60 @@
+#compdef scd
+#description smart change directory
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+
+local -a indexopts myargs
+indexopts=( --add -a --unindex )
+
+myargs=(
+ # common options
+ "(--help -h)"{--help,-h}"[print help and exit]"
+
+ # options for manipulating directory index
+ - index
+ "(--recursive -r)"{--recursive,-r}"[use recursive --add or --unindex]"
+ "($indexopts)"{--add,-a}"[add specified directories to the index]"
+ "($indexopts)--unindex[remove specified directories from the index]"
+ "*:directory:{ (( ${words[(I)-a|--add|--unindex]} )) && _path_files -/ }"
+
+ # define new directory alias
+ - alias
+ "--alias=[create alias for this or given directory]:directory-alias:()"
+ '1:directory:{ (( words[(I)--alias*] )) && _path_files -/ }'
+
+ # remove definition of directory alias
+ - unalias
+ "--unalias[remove definition of directory alias]"
+ "*::directory alias:->scd-alias-target"
+
+ # act on the directory change
+ - scd
+ "(--all -A)"{--all,-A}"[include less likely and ignored paths]"
+ "--list[print matching directories and exit]"
+ "(--verbose -v)"{--verbose,-v}"[show directory ranking and full paths]"
+ "(--push -p)"{--push,-p}"[change directory with 'pushd']"
+ "1::directory alias:->scd-alias-target"
+ "*:patterns:()"
+)
+
+_arguments -S -C $myargs && ret=0
+
+
+if [[ "$state" == scd-alias-target && -s ~/.scdalias.zsh ]]; then
+ local -a scdaliases
+ scdaliases=( )
+ eval "$(setopt extendedglob
+ phome="(#b)(#s)${HOME}(/*)#(#e)"
+ builtin hash -dr
+ source ~/.scdalias.zsh &&
+ for k v in ${(kv)nameddirs}; do
+ scdaliases+=( $k:${v/${~phome}/"~"${match[1]}} )
+ done
+ complete_unalias=${+opt_args[unalias---unalias]}
+ if (( complete_unalias && ! ${+nameddirs[OLD]} )); then
+ scdaliases+=( 'OLD:all aliases to non-existent paths' )
+ fi
+ typeset -p scdaliases )"
+ _describe -t scdaliases scdalias scdaliases
+fi
diff --git a/plugins/scd/scd b/plugins/scd/scd
index 39b28237d..a7db6c265 100644..100755
--- a/plugins/scd/scd
+++ b/plugins/scd/scd
@@ -1,29 +1,39 @@
#!/bin/zsh -f
emulate -L zsh
+
+local RUNNING_AS_COMMAND=
local EXIT=return
if [[ $(whence -w $0) == *:' 'command ]]; then
- emulate -R zsh
- local RUNNING_AS_COMMAND=1
+ RUNNING_AS_COMMAND=1
EXIT=exit
fi
local DOC='scd -- smart change to a recently used directory
usage: scd [options] [pattern1 pattern2 ...]
-Go to a directory path that contains all fixed string patterns. Prefer
-recent or frequently visited directories as found in the directory index.
+Go to a directory path that matches all patterns. Prefer recent or
+frequently visited directories as found in the directory index.
Display a selection menu in case of multiple matches.
+Special patterns:
+ ^PAT match at the path root, "^/home"
+ PAT$ match paths ending with PAT, "man$"
+ ./ match paths under the current directory
+ :PAT require PAT to span the tail, ":doc", ":re/doc"
+
Options:
- -a, --add add specified directories to the directory index.
+ -a, --add add current or specified directories to the index.
--unindex remove current or specified directories from the index.
-r, --recursive apply options --add or --unindex recursively.
--alias=ALIAS create alias for the current or specified directory and
store it in ~/.scdalias.zsh.
--unalias remove ALIAS definition for the current or specified
directory from ~/.scdalias.zsh.
- -A, --all include all matching directories. Disregard matching by
- directory alias and filtering of less likely paths.
+ Use "OLD" to purge aliases to non-existent directories.
+ -A, --all display all directories even those excluded by patterns
+ in ~/.scdignore. Disregard unique match for a directory
+ alias and filtering of less likely paths.
+ -p, --push use "pushd" to change to the target directory.
--list show matching directories and exit.
-v, --verbose display directory rank in the selection menu.
-h, --help display this message and exit.
@@ -36,18 +46,28 @@ local SCD_MEANLIFE=${SCD_MEANLIFE:-86400}
local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
local SCD_ALIAS=~/.scdalias.zsh
+local SCD_IGNORE=~/.scdignore
-local ICASE a d m p i maxrank threshold
+# Minimum logarithm of probability. Avoids out of range warning in exp().
+local -r MINLOGPROB=-15
+
+# When false, use case-insensitive globbing to fix PWD capitalization.
+local PWDCASECORRECT=true
+if [[ ${OSTYPE} == darwin* ]]; then
+ PWDCASECORRECT=false
+fi
+
+local a d m p i maxrank threshold
local opt_help opt_add opt_unindex opt_recursive opt_verbose
-local opt_alias opt_unalias opt_all opt_list
-local -A drank dalias
+local opt_alias opt_unalias opt_all opt_push opt_list
+local -A drank dalias scdignore
local dmatching
local last_directory
-setopt extendedhistory extendedglob noautonamedirs brace_ccl
+setopt extendedglob noautonamedirs brace_ccl
-# If SCD_SCRIPT is defined make sure the file exists and is empty.
-# This removes any previous old commands.
+# If SCD_SCRIPT is defined make sure that that file exists and is empty.
+# This removes any old previous commands from the SCD_SCRIPT file.
[[ -n "$SCD_SCRIPT" ]] && [[ -s $SCD_SCRIPT || ! -f $SCD_SCRIPT ]] && (
umask 077
: >| $SCD_SCRIPT
@@ -56,13 +76,17 @@ setopt extendedhistory extendedglob noautonamedirs brace_ccl
# process command line options
zmodload -i zsh/zutil
zmodload -i zsh/datetime
-zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \
+zmodload -i zsh/parameter
+zparseopts -D -E -- a=opt_add -add=opt_add -unindex=opt_unindex \
r=opt_recursive -recursive=opt_recursive \
-alias:=opt_alias -unalias=opt_unalias \
- A=opt_all -all=opt_all -list=opt_list \
+ A=opt_all -all=opt_all p=opt_push -push=opt_push -list=opt_list \
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|| $EXIT $?
+# remove the first instance of "--" from positional arguments
+argv[(i)--]=( )
+
if [[ -n $opt_help ]]; then
print $DOC
$EXIT
@@ -71,6 +95,22 @@ fi
# load directory aliases if they exist
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
+# load scd-ignore patterns if available
+if [[ -s $SCD_IGNORE ]]; then
+ setopt noglob
+ <$SCD_IGNORE \
+ while read p; do
+ [[ $p != [\#]* ]] || continue
+ [[ -n $p ]] || continue
+ # expand leading tilde if it has valid expansion
+ if [[ $p == [~]* ]] && ( : ${~p} ) 2>/dev/null; then
+ p=${~p}
+ fi
+ scdignore[$p]=1
+ done
+ setopt glob
+fi
+
# Private internal functions are prefixed with _scd_Y19oug_.
# Clean them up when the scd function returns.
setopt localtraps
@@ -79,9 +119,17 @@ trap 'unfunction -m "_scd_Y19oug_*"' EXIT
# works faster than the (:a) modifier and is compatible with zsh 4.2.6
_scd_Y19oug_abspath() {
set -A $1 ${(ps:\0:)"$(
- unfunction -m "*"; shift
+ setopt pushdsilent
+ unfunction -m "*"
+ unalias -m "*"
+ unset CDPATH
+ shift
for d; do
- cd $d && print -Nr -- $PWD && cd $OLDPWD
+ pushd $d || continue
+ $PWDCASECORRECT &&
+ print -Nr -- $PWD ||
+ print -Nr -- (#i)$PWD
+ popd 2>/dev/null
done
)"}
}
@@ -106,47 +154,76 @@ if [[ -n $opt_alias ]]; then
$EXIT $?
fi
-# undefine directory alias
+# undefine one or more directory aliases
if [[ -n $opt_unalias ]]; then
- if [[ -n $1 && ! -d $1 ]]; then
- print -u2 "'$1' is not a directory."
- $EXIT 1
- fi
- _scd_Y19oug_abspath a ${1:-$PWD}
- a=$(print -rD ${a})
- if [[ $a != [~][^/]## ]]; then
- $EXIT
+ local -U uu
+ local ec=0
+ uu=( ${*:-${PWD}} )
+ if (( ${uu[(I)OLD]} && ${+nameddirs[OLD]} == 0 )); then
+ uu=( ${uu:#OLD} ${(ps:\0:)"$(
+ hash -dr
+ if [[ -r $SCD_ALIAS ]]; then
+ source $SCD_ALIAS
+ fi
+ for a d in ${(kv)nameddirs}; do
+ [[ -d $d ]] || print -Nr -- $a
+ done
+ )"}
+ )
fi
- a=${a#[~]}
- # unalias in the current shell, update alias file if successful
- if unhash -d -- $a 2>/dev/null && [[ -r $SCD_ALIAS ]]; then
+ m=( )
+ for p in $uu; do
+ d=$p
+ if [[ ${+nameddirs[$d]} == 0 && -d $d ]]; then
+ _scd_Y19oug_abspath d $d
+ fi
+ a=${(k)nameddirs[$d]:-${(k)nameddirs[(r)$d]}}
+ if [[ -z $a ]]; then
+ ec=1
+ print -u2 "'$p' is neither a directory alias nor an aliased path."
+ continue
+ fi
+ # unalias in the current shell and remember to update the alias file
+ if unhash -d -- $a 2>/dev/null; then
+ m+=( $a )
+ fi
+ done
+ if [[ $#m != 0 && -r $SCD_ALIAS ]]; then
(
umask 077
hash -dr
source $SCD_ALIAS
- unhash -d -- $a 2>/dev/null &&
+ for a in $m; do
+ unhash -d -- $a 2>/dev/null
+ done
hash -dL >| $SCD_ALIAS
- )
+ ) || ec=$?
fi
- $EXIT $?
+ $EXIT $ec
fi
-# The "compress" function collapses repeated directories to
-# one entry with a time stamp that gives equivalent-probability.
+# The "compress" function collapses repeated directories into
+# a single entry with a time-stamp yielding an equivalent probability.
_scd_Y19oug_compress() {
- awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
- BEGIN { FS = "[:;]"; }
- length($0) < 4096 && $2 > 0 {
+ awk -v epochseconds=$EPOCHSECONDS \
+ -v meanlife=$SCD_MEANLIFE \
+ -v minlogprob=$MINLOGPROB \
+ '
+ BEGIN {
+ FS = "[:;]";
+ pmin = exp(minlogprob);
+ }
+ /^: deleted:0;/ { next; }
+ length($0) < 4096 && $2 > 1000 {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ if (!df) next;
tau = 1.0 * ($2 - epochseconds) / meanlife;
- if (tau < -6.9078) tau = -6.9078;
- prob = exp(tau);
- sub(/^[^;]*;/, "");
- if (NF) {
- dlist[last[$0]] = "";
- dlist[NR] = $0;
- last[$0] = NR;
- ptot[$0] += prob;
- }
+ prob = (tau < minlogprob) ? pmin : exp(tau);
+ dlist[last[df]] = "";
+ dlist[NR] = df;
+ last[df] = NR;
+ ptot[df] += prob;
}
END {
for (i = 1; i <= NR; ++i) {
@@ -157,26 +234,38 @@ _scd_Y19oug_compress() {
}
}
}
- ' $*
+ ' $*
}
-# Rewrite directory index if it is at least 20% oversized
-if [[ -s $SCD_HISTFILE ]] && \
-(( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then
- # compress repeated entries
- m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
- # purge non-existent directories
- m=( ${(f)"$(
- for a in $m; do
- if [[ -d ${a#*;} ]]; then print -r -- $a; fi
- done
- )"}
- )
- # cut old entries if still oversized
- if [[ $#m -gt $SCD_HISTSIZE ]]; then
- m=( ${m[-$SCD_HISTSIZE,-1]} )
- fi
- print -lr -- $m >| ${SCD_HISTFILE}
+# Rewrite directory index if it is at least 20% oversized.
+local curhistsize
+if [[ -z $opt_unindex && -s $SCD_HISTFILE ]] && \
+curhistsize=$(wc -l <$SCD_HISTFILE) && \
+(( $curhistsize > 1.2 * $SCD_HISTSIZE )); then
+ # Compress repeated entries in a background process.
+ (
+ m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
+ # purge non-existent and ignored directories
+ m=( ${(f)"$(
+ for a in $m; do
+ d=${a#*;}
+ [[ -z ${scdignore[(k)$d]} ]] || continue
+ [[ -d $d ]] || continue
+ $PWDCASECORRECT || d=( (#i)${d} )
+ t=${a%%;*}
+ print -r -- "${t};${d}"
+ done
+ )"}
+ )
+ # cut old entries if still oversized
+ if [[ $#m -gt $SCD_HISTSIZE ]]; then
+ m=( ${m[-$SCD_HISTSIZE,-1]} )
+ fi
+ # Checking existence of many directories could have taken a while.
+ # Append any index entries added in meantime.
+ m+=( ${(f)"$(sed "1,${curhistsize}d" $SCD_HISTFILE)"} )
+ print -lr -- $m >| ${SCD_HISTFILE}
+ ) &|
fi
# Determine the last recorded directory
@@ -197,13 +286,8 @@ _scd_Y19oug_record() {
}
if [[ -n $opt_add ]]; then
- for d; do
- if [[ ! -d $d ]]; then
- print -u2 "Directory '$d' does not exist."
- $EXIT 2
- fi
- done
- _scd_Y19oug_abspath m ${*:-$PWD}
+ m=( ${^${argv:-$PWD}}(N-/) )
+ _scd_Y19oug_abspath m ${m}
_scd_Y19oug_record $m
if [[ -n $opt_recursive ]]; then
for d in $m; do
@@ -220,6 +304,7 @@ if [[ -n $opt_unindex ]]; then
if [[ ! -s $SCD_HISTFILE ]]; then
$EXIT
fi
+ argv=( ${argv:-$PWD} )
# expand existing directories in the argument list
for i in {1..$#}; do
if [[ -d ${argv[i]} ]]; then
@@ -227,24 +312,28 @@ if [[ -n $opt_unindex ]]; then
argv[i]=${d}
fi
done
+ # strip trailing slashes, but preserve the root path
+ argv=( ${argv/(#m)?\/##(#e)/${MATCH[1]}} )
m="$(awk -v recursive=${opt_recursive} '
BEGIN {
for (i = 2; i < ARGC; ++i) {
argset[ARGV[i]] = 1;
delete ARGV[i];
}
+ unindex_root = ("/" in argset);
}
1 {
d = $0; sub(/^[^;]*;/, "", d);
if (d in argset) next;
}
recursive {
+ if (unindex_root) exit;
for (a in argset) {
if (substr(d, 1, length(a) + 1) == a"/") next;
}
}
{ print $0 }
- ' $SCD_HISTFILE ${*:-$PWD} )" || $EXIT $?
+ ' $SCD_HISTFILE $* )" || $EXIT $?
: >| ${SCD_HISTFILE}
[[ ${#m} == 0 ]] || print -r -- $m >> ${SCD_HISTFILE}
$EXIT
@@ -252,67 +341,113 @@ fi
# The "action" function is called when there is just one target directory.
_scd_Y19oug_action() {
- cd $1 || return $?
+ local cdcmd=cd
+ [[ -z ${opt_push} ]] || cdcmd=pushd
+ builtin $cdcmd $1 || return $?
if [[ -z $SCD_SCRIPT && -n $RUNNING_AS_COMMAND ]]; then
print -u2 "Warning: running as command with SCD_SCRIPT undefined."
fi
if [[ -n $SCD_SCRIPT ]]; then
- print -r "cd ${(q)1}" >| $SCD_SCRIPT
+ local d=$1
+ if [[ $OSTYPE == cygwin && ${(L)SCD_SCRIPT} == *.bat ]]; then
+ d=$(cygpath -aw .)
+ fi
+ print -r "${cdcmd} ${(qqq)d}" >| $SCD_SCRIPT
fi
}
-# Match and rank patterns to the index file
-# set global arrays dmatching and drank
+# Select and order indexed directories by matching command-line patterns.
+# Set global arrays dmatching and drank.
_scd_Y19oug_match() {
## single argument that is an existing directory or directory alias
if [[ -z $opt_all && $# == 1 ]] && \
- [[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]];
+ [[ -d ${d::=${nameddirs[$1]}} || -d ${d::=$1} ]] && [[ -x $d ]];
then
_scd_Y19oug_abspath dmatching $d
drank[${dmatching[1]}]=1
return
fi
- # ignore case unless there is an argument with an uppercase letter
- [[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)'
- # support "$" as an anchor for the directory name ending
+ # quote brackets when PWD is /Volumes/[C]/
+ local qpwd=${PWD//(#m)[][]/\\${MATCH}}
+
+ # support "./" as an alias for $PWD to match only subdirectories.
+ argv=( ${argv/(#s).\/(#e)/(#s)${qpwd}(|/*)(#e)} )
+
+ # support "./pat" as an alias for $PWD/pat.
+ argv=( ${argv/(#m)(#s).\/?*/(#s)${qpwd}${MATCH#.}} )
+
+ # support "^" as an anchor for the root directory, e.g., "^$HOME".
+ argv=( ${argv/(#m)(#s)\^?*/(#s)${${~MATCH[2,-1]}}} )
+
+ # support "$" as an anchor at the end of directory name.
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
- # calculate rank of all directories in the SCD_HISTFILE and keep it as drank
- # include a dummy entry for splitting of an empty string is buggy
+ # support prefix ":" to match over the tail component.
+ argv=( ${argv/(#m)(#s):?*/${MATCH[2,-1]}[^/]#(#e)} )
+
+ # calculate rank of all directories in SCD_HISTFILE and store it in drank.
+ # include a dummy entry to avoid issues with splitting an empty string.
[[ -s $SCD_HISTFILE ]] && drank=( ${(f)"$(
print -l /dev/null -10
<$SCD_HISTFILE \
- awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
- BEGIN { FS = "[:;]"; }
+ awk -v epochseconds=$EPOCHSECONDS \
+ -v meanlife=$SCD_MEANLIFE \
+ -v minlogprob=$MINLOGPROB \
+ '
+ BEGIN {
+ FS = "[:;]";
+ pmin = exp(minlogprob);
+ }
+ /^: deleted:0;/ {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ delete ptot[df];
+ next;
+ }
length($0) < 4096 && $2 > 0 {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ if (!df) next;
+ dp = df;
+ while (!(dp in ptot)) {
+ ptot[dp] = pmin;
+ sub("//*[^/]*$", "", dp);
+ if (!dp) break;
+ }
+ if ($2 <= 1000) next;
tau = 1.0 * ($2 - epochseconds) / meanlife;
- if (tau < -6.9078) tau = -6.9078;
- prob = exp(tau);
- sub(/^[^;]*;/, "");
- if (NF) ptot[$0] += prob;
+ prob = (tau < minlogprob) ? pmin : exp(tau);
+ ptot[df] += prob;
}
- END { for (di in ptot) { print di; print ptot[di]; } }'
+ END { for (di in ptot) { print di; print ptot[di]; } }
+ '
)"}
)
unset "drank[/dev/null]"
# filter drank to the entries that match all arguments
for a; do
- p=${ICASE}"*(${a})*"
+ p="(#l)*(${a})*"
drank=( ${(kv)drank[(I)${~p}]} )
done
- # require at least one argument matches the directory name
- p=${ICASE}"*(${(j:|:)argv})[^/]#"
+ # require that at least one argument matches in directory tail name.
+ p="(#l)*(${(j:|:)argv})[^/]#"
drank=( ${(kv)drank[(I)${~p}]} )
+ # discard ignored directories
+ if [[ -z ${opt_all} ]]; then
+ for d in ${(k)drank}; do
+ [[ -z ${scdignore[(k)$d]} ]] || unset "drank[$d]"
+ done
+ fi
+
# build a list of matching directories reverse-sorted by their probabilities
dmatching=( ${(f)"$(
- for d p in ${(kv)drank}; do
- print -r -- "$p $d";
- done | sort -grk1 | cut -d ' ' -f 2-
- )"}
+ builtin printf "%s %s\n" ${(Oakv)drank} |
+ /usr/bin/sort -grk1 )"}
)
+ dmatching=( ${dmatching#*[[:blank:]]} )
# do not match $HOME or $PWD when run without arguments
if [[ $# == 0 ]]; then
@@ -320,12 +455,20 @@ _scd_Y19oug_match() {
fi
# keep at most SCD_MENUSIZE of matching and valid directories
+ # mark up any deleted entries in the index
+ local -A isdeleted
m=( )
+ isdeleted=( )
for d in $dmatching; do
[[ ${#m} == $SCD_MENUSIZE ]] && break
- [[ -d $d && -x $d ]] && m+=$d
+ (( ${+isdeleted[$d]} == 0 )) || continue
+ [[ -d $d ]] || { isdeleted[$d]=1; continue }
+ [[ -x $d ]] && m+=$d
done
dmatching=( $m )
+ if [[ -n ${isdeleted} ]]; then
+ print -lr -- ": deleted:0;"${^${(k)isdeleted}} >> $SCD_HISTFILE
+ fi
# find the maximum rank
maxrank=0.0
@@ -343,7 +486,7 @@ _scd_Y19oug_match() {
_scd_Y19oug_match $*
-## process whatever directories that remained
+## process matching directories.
if [[ ${#dmatching} == 0 ]]; then
print -u2 "No matching directory."
$EXIT 1
@@ -367,13 +510,13 @@ if [[ -n $opt_list ]]; then
$EXIT
fi
-## process single directory match
+## handle a single matching directory here.
if [[ ${#dmatching} == 1 ]]; then
_scd_Y19oug_action $dmatching
$EXIT $?
fi
-## here we have multiple matches - display selection menu
+## Here we have multiple matches. Let's use the selection menu.
a=( {a-z} {A-Z} )
a=( ${a[1,${#dmatching}]} )
p=( )
diff --git a/plugins/scd/scd.plugin.zsh b/plugins/scd/scd.plugin.zsh
index 0197c53a1..1a6c18654 100644
--- a/plugins/scd/scd.plugin.zsh
+++ b/plugins/scd/scd.plugin.zsh
@@ -1,19 +1,17 @@
## The scd script should autoload as a shell function.
-autoload scd
+autoload -Uz scd
## If the scd function exists, define a change-directory-hook function
## to record visited directories in the scd index.
if [[ ${+functions[scd]} == 1 ]]; then
- scd_chpwd_hook() { scd --add $PWD }
- autoload add-zsh-hook
- add-zsh-hook chpwd scd_chpwd_hook
+ chpwd_scd() { scd --add $PWD }
+ autoload -Uz add-zsh-hook
+ add-zsh-hook chpwd chpwd_scd
fi
-## Allow scd usage with unquoted wildcard characters such as "*" or "?".
-alias scd='noglob scd'
-
-
## Load the directory aliases created by scd if any.
-if [[ -s ~/.scdalias.zsh ]]; then source ~/.scdalias.zsh; fi
+if [[ -s ~/.scdalias.zsh ]]; then
+ source ~/.scdalias.zsh
+fi
diff --git a/plugins/screen/screen.plugin.zsh b/plugins/screen/screen.plugin.zsh
index 7009e7a91..c1db8ad92 100644
--- a/plugins/screen/screen.plugin.zsh
+++ b/plugins/screen/screen.plugin.zsh
@@ -2,7 +2,7 @@
# of the tab window should be.
if [[ "$TERM" == screen* ]]; then
if [[ $_GET_PATH == '' ]]; then
- _GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^\/home\//~/;s/^~$USER/~/"'
+ _GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^\/home\//~/;s/^~$USERNAME/~/"'
fi
if [[ $_GET_HOST == '' ]]; then
_GET_HOST='echo $HOST | sed "s/\..*//"'
@@ -51,4 +51,4 @@ if [[ "$TERM" == screen* ]]; then
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_PROMPT"
screen_set $tab_title $tab_hardstatus
}
-fi \ No newline at end of file
+fi
diff --git a/plugins/shell-proxy/proxy.py b/plugins/shell-proxy/proxy.py
index 2b62f6cb5..97f4cf873 100755
--- a/plugins/shell-proxy/proxy.py
+++ b/plugins/shell-proxy/proxy.py
@@ -9,8 +9,9 @@ user_proxy = os.environ.get("CONFIG_PROXY", os.path.expandvars("$HOME/.config/pr
def get_http_proxy():
- if "DEFAULT_PROXY" in os.environ:
- return os.environ["DEFAULT_PROXY"]
+ default_proxy = os.environ.get("DEFAULT_PROXY")
+ if default_proxy:
+ return default_proxy
if os.path.isfile(user_proxy):
return check_output(user_proxy).decode("utf-8").strip()
raise Exception("Not found, Proxy configuration")
@@ -30,7 +31,7 @@ def merge(mapping: dict):
class CommandSet:
proxies = make_proxies(get_http_proxy())
aliases = {
- _: "env NAME=%s %s" % (_, ssh_agent)
+ _: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent)
for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")
}
diff --git a/plugins/shell-proxy/shell-proxy.plugin.zsh b/plugins/shell-proxy/shell-proxy.plugin.zsh
index fd0e2fe79..315ade665 100644
--- a/plugins/shell-proxy/shell-proxy.plugin.zsh
+++ b/plugins/shell-proxy/shell-proxy.plugin.zsh
@@ -4,7 +4,7 @@
__PROXY__="${0:A:h}/proxy.py"
proxy() {
- source <("$__PROXY__" "$1")
+ source <(env "DEFAULT_PROXY=$DEFAULT_PROXY" "$__PROXY__" "$1")
}
_proxy() {
diff --git a/plugins/shell-proxy/ssh-agent.py b/plugins/shell-proxy/ssh-agent.py
index 61cf84c0b..4ee24b755 100755
--- a/plugins/shell-proxy/ssh-agent.py
+++ b/plugins/shell-proxy/ssh-agent.py
@@ -6,7 +6,7 @@ import sys
ssh_proxy = os.path.join(os.path.dirname(__file__), "ssh-proxy.py")
argv = [
- os.environ.get("NAME", "ssh"),
+ os.environ.get("__SSH_PROGRAM_NAME__", "ssh"),
"-o",
"ProxyCommand={} %h %p".format(ssh_proxy),
"-o",
diff --git a/plugins/shrink-path/README.md b/plugins/shrink-path/README.md
index 33dc3f8ae..71a242b2c 100644
--- a/plugins/shrink-path/README.md
+++ b/plugins/shrink-path/README.md
@@ -1,43 +1,50 @@
-# A plugin to shrink directory paths for brevity and pretty-printing
+# shrink-path
+A plugin to shrink directory paths for brevity and pretty-printing.
+
+To use it, add `shrink-path` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... shrink-path)
+```
## Examples
For this directory tree:
```
- /home/
- me/
- f o o/ # The prefix f is ambiguous between "f o o" and "f i g".
- bar/
- quux/
- biz/ # The prefix b is ambiguous between bar and biz.
- f i g/
- baz/
+/home/
+ me/
+ f o o/ # The prefix f is ambiguous between "f o o" and "f i g".
+ bar/
+ quux/
+ biz/ # The prefix b is ambiguous between bar and biz.
+ f i g/
+ baz/
```
here are the results of calling `shrink_path <option> /home/me/foo/bar/quux`:
```
- Option Result
- <none> /h/m/f o/ba/q
- -l|--last /h/m/f o/ba/q
- -s|--short /h/m/f/b/q
- -t|--tilde ~/f o/ba/q
- -f|--fish ~/f/b/quux
- -g|--glob /h*/m*/f o*/ba*/q*
- -3 /hom/me/f o/bar/quu
- -e '$' -3 /hom$/me/f o$/bar/quu$
- -q /h/m/f\ o/ba/q
- -g -q /h*/m*/f\ o*/ba*/q*
+Option Result
+<none> /h/m/f o/ba/q
+-l|--last /h/m/f o/ba/q
+-s|--short /h/m/f/b/q
+-t|--tilde ~/f o/ba/q
+-f|--fish ~/f/b/quux
+-g|--glob /h*/m*/f o*/ba*/q*
+-3 /hom/me/f o/bar/quu
+-e '$' -3 /hom$/me/f o$/bar/quu$
+-q /h/m/f\ o/ba/q
+-g -q /h*/m*/f\ o*/ba*/q*
+-x /home/me/foo/bar/quux
```
-
## Usage
For a fish-style working directory in your command prompt, add the following to
your theme or zshrc:
-```
- setopt prompt_subst
- PS1='%n@%m $(shrink_path -f)>'
+```zsh
+setopt prompt_subst
+PS1='%n@%m $(shrink_path -f)>'
```
The following options are available:
@@ -54,17 +61,45 @@ The following options are available:
ellipsis character(s) (defaulting to 1).
-e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.
-q, --quote Quote special characters in the shrunk path
+ -x, --expand Print the full path. This takes precedence over the other options
```
The long options can also be set via zstyle, like
-```
- zstyle :prompt:shrink_path fish yes
+```zsh
+zstyle :prompt:shrink_path fish yes
```
Note: Directory names containing two or more consecutive spaces are not yet
supported.
+## Trick: toggle shrinking with a keyboard shortcut
+
+You can use the `expand` option to disable the path shrinking. You can combine that
+with a key binding widget to toggle path shrinking on and off.
+
+```zsh
+# Toggle off path shrinking
+zstyle ':prompt:shrink_path' expand true
+# Toggle on path shrinking
+zstyle -d ':prompt:shrink_path' expand
+```
+
+Combined with a widget:
+
+```zsh
+# Widget definition
+shrink-path-toggle() {
+ zstyle -t ':prompt:shrink_path' expand \
+ && zstyle -d ':prompt:shrink_path' expand \
+ || zstyle ':prompt:shrink_path' expand true
+ zle reset-prompt
+}
+zle -N shrink-path-toggle
+# Key binding to ALT+SHIFT+S
+bindkey "^[S" shrink-path-toggle
+```
+
## License
Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>
diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh
index f0ed65138..373fd5b05 100644
--- a/plugins/shrink-path/shrink-path.plugin.zsh
+++ b/plugins/shrink-path/shrink-path.plugin.zsh
@@ -45,6 +45,7 @@ shrink_path () {
typeset -i length=1
typeset ellipsis=""
typeset -i quote=0
+ typeset -i expand=0
if zstyle -t ':prompt:shrink_path' fish; then
lastfull=1
@@ -60,6 +61,7 @@ shrink_path () {
zstyle -t ':prompt:shrink_path' tilde && tilde=1
zstyle -t ':prompt:shrink_path' glob && ellipsis='*'
zstyle -t ':prompt:shrink_path' quote && quote=1
+ zstyle -t ':prompt:shrink_path' expand && expand=1
while [[ $1 == -* ]]; do
case $1 in
@@ -85,6 +87,8 @@ shrink_path () {
print ' ellipsis character(s) (defaulting to 1).'
print ' -e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.'
print ' -q, --quote Quote special characters in the shrunk path'
+ print ' -x, --expand Print the full path. This takes precedence over the other options'
+ print ''
print 'The long options can also be set via zstyle, like'
print ' zstyle :prompt:shrink_path fish yes'
return 0
@@ -109,6 +113,9 @@ shrink_path () {
-q|--quote)
quote=1
;;
+ -x|--expand)
+ expand=1
+ ;;
esac
shift
done
@@ -120,6 +127,11 @@ shrink_path () {
[[ -d $dir ]] || return 0
+ if (( expand )) {
+ echo "$dir"
+ return 0
+ }
+
if (( named )) {
for part in ${(k)nameddirs}; {
[[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/#${nameddirs[$part]}/\~$part}
diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
index 0b96d9bb5..1d6914ec6 100644
--- a/plugins/ssh-agent/README.md
+++ b/plugins/ssh-agent/README.md
@@ -9,7 +9,7 @@ To enable it, add `ssh-agent` to your plugins:
plugins=(... ssh-agent)
```
-## Instructions
+## Settings
**IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
@@ -19,12 +19,41 @@ To enable **agent forwarding support** add the following to your zshrc file:
zstyle :omz:plugins:ssh-agent agent-forwarding on
```
-To **load multiple identities** use the `identities` style, For example:
+----
+
+To **NOT load any identities on start** use the `lazy` setting. This is particularly
+useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2),
+since it allows to enter the password only on first use. _NOTE: you can know your
+OpenSSH version with `ssh -V`._
+
+```zsh
+zstyle :omz:plugins:ssh-agent lazy yes
+```
+
+You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command,
+or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1].
+See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2).
+
+----
+
+To **load multiple identities** use the `identities` style (**this has no effect
+if the `lazy` setting is enabled**). For example:
```zsh
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
```
+**NOTE:** the identities may be an absolute path if they are somewhere other than
+`~/.ssh`. For example:
+
+```zsh
+zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_rsa2 ~/.config/ssh/id_github
+# which can be simplified to
+zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github}
+```
+
+----
+
To **set the maximum lifetime of the identities**, use the `lifetime` style.
The lifetime may be specified in seconds or as described in sshd_config(5)
(see _TIME FORMATS_). If left unspecified, the default lifetime is forever.
@@ -33,6 +62,33 @@ The lifetime may be specified in seconds or as described in sshd_config(5)
zstyle :omz:plugins:ssh-agent lifetime 4h
```
+----
+
+To **pass arguments to the `ssh-add` command** that adds the identities on startup,
+use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces:
+
+```zsh
+zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
+```
+
+These will then be passed the the `ssh-add` call as if written directly. The example
+above will turn into:
+
+```zsh
+ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
+```
+
+For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
+
+----
+
+To set an **external helper** to ask for the passwords and possibly store
+them in the system keychain use the `helper` style. For example:
+
+```zsh
+zstyle :omz:plugins:ssh-agent helper ksshaskpass
+```
+
## Credits
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 6ab041c21..c006f1413 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -1,82 +1,105 @@
-typeset _agent_forwarding _ssh_env_cache
+# Get the filename to store/lookup the environment from
+ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
function _start_agent() {
- local lifetime
- zstyle -s :omz:plugins:ssh-agent lifetime lifetime
-
- # start ssh-agent and setup environment
- echo Starting ssh-agent...
- ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache
- chmod 600 $_ssh_env_cache
- . $_ssh_env_cache > /dev/null
+ # Check if ssh-agent is already running
+ if [[ -f "$ssh_env_cache" ]]; then
+ . "$ssh_env_cache" > /dev/null
+
+ {
+ [[ "$USERNAME" = root ]] && command ps ax || command ps x
+ } | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
+ fi
+
+ # Set a maximum lifetime for identities added to ssh-agent
+ local lifetime
+ zstyle -s :omz:plugins:ssh-agent lifetime lifetime
+
+ # start ssh-agent and setup environment
+ echo Starting ssh-agent...
+ ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache"
+ chmod 600 "$ssh_env_cache"
+ . "$ssh_env_cache" > /dev/null
}
function _add_identities() {
- local id line sig lines
- local -a identities loaded_sigs loaded_ids not_loaded
- zstyle -a :omz:plugins:ssh-agent identities identities
-
- # check for .ssh folder presence
- if [[ ! -d $HOME/.ssh ]]; then
- return
- fi
-
- # add default keys if no identities were set up via zstyle
- # this is to mimic the call to ssh-add with no identities
- if [[ ${#identities} -eq 0 ]]; then
- # key list found on `ssh-add` man page's DESCRIPTION section
- for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do
- # check if file exists
- [[ -f "$HOME/.ssh/$id" ]] && identities+=$id
- done
- fi
-
- # get list of loaded identities' signatures and filenames
- if lines=$(ssh-add -l); then
- for line in ${(f)lines}; do
- loaded_sigs+=${${(z)line}[2]}
- loaded_ids+=${${(z)line}[3]}
- done
- fi
-
- # add identities if not already loaded
- for id in $identities; do
- # check for filename match, otherwise try for signature match
- if [[ ${loaded_ids[(I)$HOME/.ssh/$id]} -le 0 ]]; then
- sig="$(ssh-keygen -lf "$HOME/.ssh/$id" | awk '{print $2}')"
- [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+="$HOME/.ssh/$id"
- fi
- done
-
- [[ -n "$not_loaded" ]] && ssh-add ${^not_loaded}
-}
+ local id file line sig lines
+ local -a identities loaded_sigs loaded_ids not_loaded
+ zstyle -a :omz:plugins:ssh-agent identities identities
-# Get the filename to store/lookup the environment from
-_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
+ # check for .ssh folder presence
+ if [[ ! -d "$HOME/.ssh" ]]; then
+ return
+ fi
+
+ # add default keys if no identities were set up via zstyle
+ # this is to mimic the call to ssh-add with no identities
+ if [[ ${#identities} -eq 0 ]]; then
+ # key list found on `ssh-add` man page's DESCRIPTION section
+ for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do
+ # check if file exists
+ [[ -f "$HOME/.ssh/$id" ]] && identities+=($id)
+ done
+ fi
+
+ # get list of loaded identities' signatures and filenames
+ if lines=$(ssh-add -l); then
+ for line in ${(f)lines}; do
+ loaded_sigs+=${${(z)line}[2]}
+ loaded_ids+=${${(z)line}[3]}
+ done
+ fi
+
+ # add identities if not already loaded
+ for id in $identities; do
+ # if id is an absolute path, make file equal to id
+ [[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
+ # check for filename match, otherwise try for signature match
+ if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
+ sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
+ [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
+ fi
+ done
+
+ # abort if no identities need to be loaded
+ if [[ ${#not_loaded} -eq 0 ]]; then
+ return
+ fi
+
+ # pass extra arguments to ssh-add
+ local args
+ zstyle -a :omz:plugins:ssh-agent ssh-add-args args
+
+ # use user specified helper to ask for password (ksshaskpass, etc)
+ local helper
+ zstyle -s :omz:plugins:ssh-agent helper helper
+
+ if [[ -n "$helper" ]]; then
+ if [[ -z "${commands[$helper]}" ]]; then
+ echo "ssh-agent: the helper '$helper' has not been found."
+ else
+ SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null
+ return $?
+ fi
+ fi
+
+ ssh-add "${args[@]}" ${^not_loaded}
+}
# test if agent-forwarding is enabled
-zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
-
-if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
- # Add a nifty symlink for screen/tmux if agent forwarding
- [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
-elif [[ -f "$_ssh_env_cache" ]]; then
- # Source SSH settings, if applicable
- . $_ssh_env_cache > /dev/null
- if [[ $USER == "root" ]]; then
- FILTER="ax"
- else
- FILTER="x"
- fi
- ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || {
- _start_agent
- }
+zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding
+
+# Add a nifty symlink for screen/tmux if agent forwarding
+if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
+ ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
else
- _start_agent
+ _start_agent
fi
-_add_identities
+# Don't add identities if lazy-loading is enabled
+if ! zstyle -t :omz:plugins:ssh-agent lazy; then
+ _add_identities
+fi
-# tidy up after ourselves
-unset _agent_forwarding _ssh_env_cache
+unset agent_forwarding ssh_env_cache
unfunction _start_agent _add_identities
diff --git a/plugins/sublime-merge/README.md b/plugins/sublime-merge/README.md
new file mode 100644
index 000000000..534479179
--- /dev/null
+++ b/plugins/sublime-merge/README.md
@@ -0,0 +1,17 @@
+## sublime-merge
+
+Plugin for Sublime Merge, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
+
+### Requirements
+
+ * [Sublime Merge](https://www.sublimemerge.com)
+
+### Usage
+
+ * If `sm` command is called without an argument, launch Sublime Merge
+
+ * If `sm` is passed a directory, `cd` to it and open the existing git repository in Sublime Merge
+
+ * If `smt` command is called, it is equivalent to `sm .`, opening the existing git repository in the current folder in Sublime Merge
+
+ * If `ssm` command is called, it is like `sudo sm`, opening the git repository in Sublime Merge. Useful for editing system protected repositories. \ No newline at end of file
diff --git a/plugins/sublime-merge/sublime-merge.plugin.zsh b/plugins/sublime-merge/sublime-merge.plugin.zsh
new file mode 100644
index 000000000..15452e61a
--- /dev/null
+++ b/plugins/sublime-merge/sublime-merge.plugin.zsh
@@ -0,0 +1,55 @@
+# Sublime Merge Aliases
+
+() {
+
+ if [[ "$OSTYPE" == linux* ]]; then
+ local _sublime_linux_paths
+ _sublime_linux_paths=(
+ "$HOME/bin/sublime_merge"
+ "/opt/sublime_merge/sublime_merge"
+ "/usr/bin/sublime_merge"
+ "/usr/local/bin/sublime_merge"
+ "/usr/bin/sublime_merge"
+ "/usr/local/bin/smerge"
+ "/usr/bin/smerge"
+ )
+ for _sublime_merge_path in $_sublime_linux_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ sm_run() { $_sublime_merge_path "$@" >/dev/null 2>&1 &| }
+ ssm_run_sudo() {sudo $_sublime_merge_path "$@" >/dev/null 2>&1}
+ alias ssm=ssm_run_sudo
+ alias sm=sm_run
+ break
+ fi
+ done
+ elif [[ "$OSTYPE" = darwin* ]]; then
+ local _sublime_darwin_paths
+ _sublime_darwin_paths=(
+ "/usr/local/bin/smerge"
+ "/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge"
+ "$HOME/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge"
+ )
+ for _sublime_merge_path in $_sublime_darwin_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ subm () { "$_sublime_merge_path" "$@" }
+ alias sm=subm
+ break
+ fi
+ done
+ elif [[ "$OSTYPE" = 'cygwin' ]]; then
+ local sublime_merge_cygwin_paths
+ sublime_merge_cygwin_paths=(
+ "$(cygpath $ProgramW6432/Sublime\ Merge)/sublime_merge.exe"
+ )
+ for _sublime_merge_path in $_sublime_merge_cygwin_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ subm () { "$_sublime_merge_path" "$@" }
+ alias sm=subm
+ break
+ fi
+ done
+ fi
+
+}
+
+alias smt='sm .'
diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
index 179342595..dadf37574 100644
--- a/plugins/sublime/sublime.plugin.zsh
+++ b/plugins/sublime/sublime.plugin.zsh
@@ -17,6 +17,7 @@ alias stn=create_project
if [[ "$OSTYPE" == linux* ]]; then
if [[ "$(uname -r)" = *icrosoft* ]]; then
_sublime_paths=(
+ "$(wslpath -u 'C:\Program Files\Sublime Text\sublime_text.exe' 2>/dev/null)"
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe' 2>/dev/null)"
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe' 2>/dev/null)"
)
@@ -37,9 +38,11 @@ alias stn=create_project
_sublime_paths=(
"/usr/local/bin/subl"
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
+ "/Applications/Sublime Text 4.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
+ "$HOME/Applications/Sublime Text 4.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
)
@@ -50,6 +53,7 @@ alias stn=create_project
)
elif [[ "$OSTYPE" = msys ]]; then
_sublime_paths=(
+ "/c/Program Files/Sublime Text/sublime_text.exe"
"/c/Program Files/Sublime Text 2/subl.exe"
"/c/Program Files/Sublime Text 3/subl.exe"
)
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index f405b025f..e02f88a87 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -9,24 +9,86 @@
# -------
#
# * Dongweiming <ciici123@gmail.com>
+# * Subhaditya Nath <github.com/subnut>
+# * Marc Cornellà <github.com/mcornella>
#
# ------------------------------------------------------------------------------
+__sudo-replace-buffer() {
+ local old=$1 new=$2 space=${2:+ }
+ if [[ ${#LBUFFER} -le ${#old} ]]; then
+ RBUFFER="${space}${BUFFER#$old }"
+ LBUFFER="${new}"
+ else
+ LBUFFER="${new}${space}${LBUFFER#$old }"
+ fi
+}
+
sudo-command-line() {
- [[ -z $BUFFER ]] && zle up-history
- if [[ $BUFFER == sudo\ * ]]; then
- LBUFFER="${LBUFFER#sudo }"
- elif [[ $BUFFER == $EDITOR\ * ]]; then
- LBUFFER="${LBUFFER#$EDITOR }"
- LBUFFER="sudoedit $LBUFFER"
- elif [[ $BUFFER == sudoedit\ * ]]; then
- LBUFFER="${LBUFFER#sudoedit }"
- LBUFFER="$EDITOR $LBUFFER"
- else
- LBUFFER="sudo $LBUFFER"
+ # If line is empty, get the last run command from history
+ [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
+
+ # Save beginning space
+ local WHITESPACE=""
+ if [[ ${LBUFFER:0:1} = " " ]]; then
+ WHITESPACE=" "
+ LBUFFER="${LBUFFER:1}"
+ fi
+
+ # If $EDITOR is not set, just toggle the sudo prefix on and off
+ if [[ -z "$EDITOR" ]]; then
+ case "$BUFFER" in
+ sudoedit\ *) __sudo-replace-buffer "sudoedit" "" ;;
+ sudo\ *) __sudo-replace-buffer "sudo" "" ;;
+ *) LBUFFER="sudo $LBUFFER" ;;
+ esac
+ else
+ # Check if the typed command is really an alias to $EDITOR
+
+ # Get the first part of the typed command
+ local cmd="${${(Az)BUFFER}[1]}"
+ # Get the first part of the alias of the same name as $cmd, or $cmd if no alias matches
+ local realcmd="${${(Az)aliases[$cmd]}[1]:-$cmd}"
+ # Get the first part of the $EDITOR command ($EDITOR may have arguments after it)
+ local editorcmd="${${(Az)EDITOR}[1]}"
+
+ # Note: ${var:c} makes a $PATH search and expands $var to the full path
+ # The if condition is met when:
+ # - $realcmd is '$EDITOR'
+ # - $realcmd is "cmd" and $EDITOR is "cmd"
+ # - $realcmd is "cmd" and $EDITOR is "cmd --with --arguments"
+ # - $realcmd is "/path/to/cmd" and $EDITOR is "cmd"
+ # - $realcmd is "/path/to/cmd" and $EDITOR is "/path/to/cmd"
+ # or
+ # - $realcmd is "cmd" and $EDITOR is "cmd"
+ # - $realcmd is "cmd" and $EDITOR is "/path/to/cmd"
+ # or
+ # - $realcmd is "cmd" and $EDITOR is /alternative/path/to/cmd that appears in $PATH
+ if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \
+ || "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \
+ || builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then
+ editorcmd="$cmd" # replace $editorcmd with the typed command so it matches below
fi
+
+ # Check for editor commands in the typed command and replace accordingly
+ case "$BUFFER" in
+ $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudoedit" ;;
+ \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudoedit" ;;
+ sudoedit\ *) __sudo-replace-buffer "sudoedit" "$EDITOR" ;;
+ sudo\ *) __sudo-replace-buffer "sudo" "" ;;
+ *) LBUFFER="sudo $LBUFFER" ;;
+ esac
+ fi
+
+ # Preserve beginning space
+ LBUFFER="${WHITESPACE}${LBUFFER}"
+
+ # Redisplay edit buffer (compatibility with zsh-syntax-highlighting)
+ zle redisplay
}
+
zle -N sudo-command-line
+
# Defined shortcut keys: [Esc] [Esc]
bindkey -M emacs '\e\e' sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line
diff --git a/plugins/supervisor/supervisor.plugin.zsh b/plugins/supervisor/supervisor.plugin.zsh
index cf1997c5b..f11f0ed3f 100644
--- a/plugins/supervisor/supervisor.plugin.zsh
+++ b/plugins/supervisor/supervisor.plugin.zsh
@@ -1 +1,14 @@
# DECLARION: This plugin was created by hhatto. What I did is just making a portal from https://bitbucket.org/hhatto/zshcompfunc4supervisor.
+
+alias sup='sudo supervisorctl'
+alias supad='sudo supervisorctl add'
+alias supa='sudo supervisorctl avail'
+alias suprl='sudo supervisorctl reload'
+alias suprm='sudo supervisorctl remove'
+alias suprr='sudo supervisorctl reread'
+alias suprs='sudo supervisorctl restart'
+alias sups='sudo supervisorctl status'
+alias supsr='sudo supervisorctl start'
+alias supso='sudo supervisorctl stop'
+alias supt='sudo supervisorctl tail'
+alias supu='sudo supervisorctl update'
diff --git a/plugins/suse/README.md b/plugins/suse/README.md
index b9b069574..06c6d9ef5 100644
--- a/plugins/suse/README.md
+++ b/plugins/suse/README.md
@@ -2,9 +2,9 @@
**Maintainer**: [r-darwish](https://github.com/r-darwish)
- Alias for Zypper according to the official Zypper's alias
+Alias for Zypper according to the official Zypper's alias
- To use it add `suse` to the plugins array in you zshrc file.
+To use it add `suse` to the plugins array in you zshrc file.
```zsh
plugins=(... suse)
@@ -60,6 +60,12 @@ plugins=(... suse)
| zse | `zypper se` | search for packages |
| zwp | `zypper wp` | list all packages providing the specified capability |
+NOTE: `--no-refresh` is passed to zypper for speeding up the calls and avoid errors due to lack
+of root privileges. If you need to refresh the repositories, call `sudo zypper ref` (`zref` alias)
+before runing these aliases.
+
+Related: [#9798](https://github.com/ohmyzsh/ohmyzsh/pull/9798).
+
## Repositories commands
| Alias | Commands | Description |
diff --git a/plugins/suse/suse.plugin.zsh b/plugins/suse/suse.plugin.zsh
index dcfeccb03..56bc6f1c5 100644
--- a/plugins/suse/suse.plugin.zsh
+++ b/plugins/suse/suse.plugin.zsh
@@ -25,16 +25,16 @@ alias zup='sudo zypper up'
alias zpatch='sudo zypper patch'
#Request commands
-alias zif='zypper if'
-alias zpa='zypper pa'
-alias zpatch-info='zypper patch-info'
-alias zpattern-info='zypper pattern-info'
-alias zproduct-info='zypper product-info'
-alias zpch='zypper pch'
-alias zpd='zypper pd'
-alias zpt='zypper pt'
-alias zse='zypper se'
-alias zwp='zypper wp'
+alias zif='zypper --no-refresh if'
+alias zpa='zypper --no-refresh pa'
+alias zpatch-info='zypper --no-refresh patch-info'
+alias zpattern-info='zypper --no-refresh pattern-info'
+alias zproduct-info='zypper --no-refresh product-info'
+alias zpch='zypper --no-refresh pch'
+alias zpd='zypper --no-refresh pd'
+alias zpt='zypper --no-refresh pt'
+alias zse='zypper --no-refresh se'
+alias zwp='zypper --no-refresh wp'
#Repositories commands
alias zar='sudo zypper ar'
diff --git a/plugins/systemadmin/README.md b/plugins/systemadmin/README.md
index edca4d87d..052fc6edc 100644
--- a/plugins/systemadmin/README.md
+++ b/plugins/systemadmin/README.md
@@ -10,17 +10,17 @@ plugins=(... systemadmin)
## Aliases
-| Alias | Command | Description |
-|---------|------------------------------------------------------------------------|--------------------------------------------------------------------|
-| ping | `ping -c 5` | Sends only 5 ICMP Messages |
-| clr | `clear; echo Currently logged in on $TTY, as $USER in directory $PWD.` | Clears the screen and prints the current user, TTY, and directory |
-| path | `print -l $path` | Displays PATH with each entry on a separate line |
-| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
-| psmem | `ps -e -orss=,args= \| sort -b -k1,1n` | Display the processes using the most memory |
-| psmem10 | `ps -e -orss=,args= \| sort -b -k1,1n \| head -10` | Display the top 10 processes using the most memory |
-| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
-| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
-| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
+| Alias | Command | Description |
+|---------|----------------------------------------------------------------------------|--------------------------------------------------------------------|
+| ping | `ping -c 5` | Sends only 5 ICMP Messages |
+| clr | `clear; echo Currently logged in on $TTY, as $USERNAME in directory $PWD.` | Clears the screen and prints the current user, TTY, and directory |
+| path | `print -l $path` | Displays PATH with each entry on a separate line |
+| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
+| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
+| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory |
+| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
+| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
+| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
## Functions
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index ded25c3a9..a77f0069b 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -21,12 +21,12 @@ function retlog() {
}
alias ping='ping -c 5'
-alias clr='clear; echo Currently logged in on $TTY, as $USER in directory $PWD.'
+alias clr='clear; echo Currently logged in on $TTY, as $USERNAME in directory $PWD.'
alias path='print -l $path'
alias mkdir='mkdir -pv'
# get top process eating memory
-alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
-alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
+alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
+alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -10'
# get top process eating cpu if not work try excute : export LC_ALL='C'
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10'
@@ -131,7 +131,8 @@ d0() {
# gather external ip address
geteip() {
- curl -s -S https://icanhazip.com
+ curl -s -S -4 https://icanhazip.com
+ curl -s -S -6 https://icanhazip.com
}
# determine local IP address(es)
diff --git a/plugins/term_tab/README b/plugins/term_tab/README
new file mode 100644
index 000000000..316062e73
--- /dev/null
+++ b/plugins/term_tab/README
@@ -0,0 +1,16 @@
+
+term_tab - 'cwd' for all open zsh sessions
+******************************************
+
+What it does:
+*************
+This plugin allows to complete the 'cwd' of other Zsh sessions. Sounds
+complicated but is rather simple. E.g. if you have three zsh sessions open, in
+each session you are in a different folder, you can hit Ctrl+v in one session
+to show you the current working directory of the other open zsh sessions.
+
+How it works:
+*************
+* It uses 'pidof zsh' to determine all zsh PIDs
+* It reads procfs to get the current working directory of this session
+* Everything is fed into zsh's completion magic
diff --git a/plugins/term_tab/term_tab.plugin.zsh b/plugins/term_tab/term_tab.plugin.zsh
new file mode 100644
index 000000000..1b612df68
--- /dev/null
+++ b/plugins/term_tab/term_tab.plugin.zsh
@@ -0,0 +1,41 @@
+# Copyright (C) 2014 Julian Vetter <death.jester@web.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+function _term_list(){
+ local -a expl
+ local -au dirs
+
+ PREFIX="$IPREFIX$PREFIX"
+ IPREFIX=
+ SUFFIX="$SUFFIX$ISUFFIX"
+ ISUFFIX=
+
+ [[ -o magicequalsubst ]] && compset -P '*='
+
+ case $OSTYPE in
+ solaris*) dirs=( ${(M)${${(f)"$(pgrep -U $UID -x zsh|xargs pwdx)"}:#$$:*}%%/*} ) ;;
+ linux*) dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:A) ) ;;
+ esac
+ dirs=( ${(D)dirs} )
+
+ compstate[pattern_match]='*'
+ _wanted directories expl 'current directory from other shell' \
+ compadd -Q -M "r:|/=* r:|=*" -f -a dirs
+}
+
+zle -C term_list menu-complete _generic
+bindkey "^v" term_list
+zstyle ':completion:term_list::::' completer _term_list
diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
index 471aef24e..9e9f0cdfb 100644
--- a/plugins/terraform/README.md
+++ b/plugins/terraform/README.md
@@ -2,7 +2,7 @@
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
-Current as of Terraform v0.11.7
+Current as of Terraform v0.13
### Requirements
@@ -17,6 +17,7 @@ plugins=(... terraform)
```
* Type `terraform` into your prompt and hit `TAB` to see available completion options
+ * Type `tf` into your prompt as a short alias to `terraform`
### Expanding ZSH prompt with current Terraform workspace name
diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
index e4298f2ab..a19e50670 100644
--- a/plugins/terraform/_terraform
+++ b/plugins/terraform/_terraform
@@ -6,14 +6,16 @@ _terraform_cmds=(
'console:Interactive console for Terraform interpolations'
'destroy:Destroy Terraform-managed infrastructure'
'fmt:Rewrites config files to canonical format'
+ 'force-unlock:Manually unlock the terraform state'
'get:Download and install modules for the configuration'
'graph:Create a visual graph of Terraform resources'
'import:Import existing infrastructure into Terraform'
'init:Initialize a Terraform working directory'
+ 'login:Obtain and save credentials for a remote host'
+ 'logout:Remove locally-stored credentials for a remote host'
'output:Read an output from a state file'
'plan:Generate and show an execution plan'
'providers:Prints a tree of the providers used in the configuration'
- 'push:Upload this Terraform module to Atlas to run'
'refresh:Update local state file against real resources'
'show:Inspect Terraform state or plan'
'state:Advanced state management'
@@ -23,6 +25,7 @@ _terraform_cmds=(
'version:Prints the Terraform version'
'workspace:Workspace management'
'0.12upgrade:Rewrites pre-0.12 module source code for v0.12'
+ '0.13upgrade:Rewrites pre-0.13 module source code for v0.13'
)
__012upgrade() {
@@ -31,45 +34,51 @@ __012upgrade() {
'-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]'
}
+__013upgrade() {
+ _arguments \
+ '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]'
+}
+
__apply() {
_arguments \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-auto-approve[Skip interactive approval of plan before applying.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
+ '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-no-color[If specified, output wil be colorless.]' \
'-parallelism=[(10) Limit the number of parallel resource operations.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
- '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
- '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
- '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
+ '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
+ '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__console() {
_arguments \
'-state=[(terraform.tfstate) Path to read state.]' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
+ '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
+ '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__destroy() {
_arguments \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
+ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-auto-approve[Skip interactive approval before destroying.]' \
'-force[Deprecated: same as auto-approve.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will contain no color.]' \
'-parallelism=[(10) Limit the number of concurrent operations.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
- '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
- '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
- '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
+ '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
+ '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__fmt() {
@@ -81,33 +90,36 @@ __fmt() {
'-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]'
}
+__force_unlock() {
+ _arguments \
+ "-force[Don't ask for input for unlock confirmation.]"
+}
+
__get() {
_arguments \
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
- '-no-color[If specified, output will contain no color.]'
+ '-no-color[Disable text coloring in the output.]'
}
__graph() {
_arguments \
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
- '-no-color[If specified, output will contain no color.]' \
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
}
__import() {
_arguments \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
+ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \
'-allow-missing-config[Allow import when no resource configuration block exists.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will contain no color.]' \
- '-provider=[(provider) Specific provider to use for import. This is used for specifying aliases, such as "aws.eu". Defaults to the normal provider prefix of the resource being imported.]' \
- '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]' \
- '-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
- '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
+ '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
+ '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
+ '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__init() {
@@ -115,80 +127,94 @@ __init() {
'-backend=[(true) Configure the backend for this configuration.]' \
'-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
- '-from-module=[Copy the contents of the given module into the target directory before initialization.]' \
+ '-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \
'-get=[(true) Download any modules for this configuration.]' \
'-get-plugins=[(true) Download any missing plugins for this configuration.]' \
'-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will contain no color.]' \
- '-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]' \
+ '-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
'-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \
'-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]'
}
+__login() {
+ _arguments \
+
+}
+
+__logout() {
+ _arguments \
+
+}
+
__output() {
_arguments \
- '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]' \
- '-no-color[ If specified, output will contain no color.]' \
- '-module=[(name) If specified, returns the outputs for a specific module]' \
+ '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-no-color[If specified, output will contain no color.]' \
'-json[If specified, machine readable output will be printed in JSON format]'
}
__plan() {
_arguments \
- '-destroy[() If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
+ '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
+ '-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
'-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
- '-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is -1, which will expand all.]' \
'-no-color[() If specified, output will contain no color.]' \
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
'-parallelism=[(10) Limit the number of concurrent operations.]' \
'-refresh=[(true) Update state prior to checking for differences.]' \
- '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
- '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' \
+ '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
+ '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__providers() {
- _arguments \
+ local -a __providers_cmds
+ __providers_cmds=(
+ 'mirror:Mirrors the provider plugins needed for the current configuration'
+ 'schema:Prints the schemas of the providers used in the configuration'
+ )
+ _describe -t providers "providers commands" __providers_cmds
+
+}
+__providers_mirror() {
+ _arguments \
+ '-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
+ "*:target_dir:_files -/"
}
-__push() {
+__providers_schema() {
_arguments \
- '-atlas-address=[(url) An alternate address to an Atlas instance. Defaults to https://atlas.hashicorp.com.]' \
- '-upload-modules=[(true) If true (default), then the modules being used are all locked at their current checkout and uploaded completely to Atlas. This prevents Atlas from running terraform get for you.]' \
- '-name=[(name) Name of the infrastructure configuration in Atlas. The format of this is: "username/name" so that you can upload configurations not just to your account but to other accounts and organizations. This setting can also be set in the configuration in the Atlas section.]' \
- '-no-color[Disables output with coloring]' \
- '-overwrite=[(foo) Marks a specific variable to be updated on Atlas. Normally, if a variable is already set in Atlas, Terraform will not send the local value (even if it is different). This forces it to send the local value to Atlas. This flag can be repeated multiple times.]' \
- '-token=[(token) Atlas API token to use to authorize the upload. If blank or unspecified, the ATLAS_TOKEN environmental variable will be used.]' \
- '-var=[("foo=bar") Set the value of a variable for the Terraform configuration.]' \
- '-var-file=[(foo) Set the value of variables using a variable file.]' \
- '-vcs=[(true) If true (default), then Terraform will detect if a VCS is in use, such as Git, and will only upload files that are committed to version control. If no version control system is detected, Terraform will upload all files in path (parameter to the command).]'
+ '-json[]' \
+ '::'
}
__refresh() {
_arguments \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
+ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \
+ '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-no-color[If specified, output will not contain any color.]' \
- '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
- '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
- '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
+ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
+ '*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
}
__show() {
_arguments \
- '-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
+ '-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
'-no-color[If specified, output will not contain any color.]'
}
@@ -199,6 +225,7 @@ __state() {
'mv:Move an item in the state'
'pull:Pull current state and output to stdout'
'push:Update remote state from a local state file'
+ 'replace-provider:Replace provider for resources in the Terraform state'
'rm:Remove instances from the state'
'show:Show a resource in the state'
)
@@ -207,7 +234,7 @@ __state() {
__state_list() {
_arguments \
- '-state=[(path) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
+ '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
"*:address:__statelist"
}
@@ -215,12 +242,12 @@ __state_list() {
__state_mv() {
_arguments \
"-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
- "-backup=[(path) Path where Terraform should write the backup for the original state. This can't be disabled. If not set, Terraform will write it to the same path as the statefile with a \".backup\" extension.]:file:_files" \
- "-backup-out=[(path) Path where Terraform should write the backup for the destination state. This can't be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:file:_files" \
- "-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
- "-lock-timeout=[(seconds) Duration to retry a state lock.]" \
- '-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:file:_files' \
- "-state-out=[(path) Path to the destination state file to write to. If this isn't specified, the source state file will be used. This can be a new or existing path.]:file:_files" \
+ '-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
+ '-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \
+ "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ '-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
"::" \
":source:__statelist" \
":destination: "
@@ -229,26 +256,37 @@ __state_mv() {
__state_push() {
_arguments \
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
- '-lock=[(true|false) Lock the state file when locking is supported.]:lock:(true false)' \
- "-lock-timeout=[(seconds) Duration to retry a state lock.]" \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
"::" \
":destination:_files"
}
+__state_replace_provider() {
+ _arguments \
+ '-auto-approve[Skip interactive approval.]' \
+ '-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
+ "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
+ ":from_provider_fqn:" \
+ ":to_provider_fqn:"
+}
+
__state_rm() {
_arguments \
"-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
- "-backup=[(path) Path where Terraform should write the backup for the original state.]:file:_files" \
- "-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
- "-lock-timeout=[(seconds) Duration to retry a state lock.]" \
- '-state=[(path) Path to the state file to update. Defaults to the current workspace state.]:file:_files' \
+ '-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \
+ "-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ '-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \
"*:address:__statelist"
}
__state_show() {
_arguments \
- '-state=[(path) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
+ '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
"*:address:__statelist"
}
@@ -259,34 +297,36 @@ __statelist() {
__taint() {
_arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
- '-no-color[If specified, output will not contain any color.]' \
- '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
- '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' \
+ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \
"*:address:__statelist"
}
__untaint() {
_arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
- '-no-color[If specified, output will not contain any color.]' \
- '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
- '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]'
+ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"'
}
__validate() {
_arguments \
- '-check-variables=[(true) If set to true (default), the command will check whether all required variables have been specified.]' \
'-no-color[If specified, output will not contain any color.]' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
+ '-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
+ ':dir:_files -/'
+}
+
+__version() {
+ _arguments \
+ '-json[Output the version information as a JSON object.]'
}
__workspace() {
@@ -312,6 +352,8 @@ local -a _command_args
case "$words[1]" in
0.12upgrade)
__012upgrade ;;
+ 0.13upgrade)
+ __013upgrade ;;
apply)
__apply ;;
console)
@@ -320,6 +362,8 @@ case "$words[1]" in
__destroy ;;
fmt)
__fmt;;
+ force-unlock)
+ __force_unlock;;
get)
__get ;;
graph)
@@ -328,14 +372,19 @@ case "$words[1]" in
__import;;
init)
__init ;;
+ login)
+ __login ;;
+ logout)
+ __logout ;;
output)
__output ;;
plan)
__plan ;;
providers)
- __providers ;;
- push)
- __push ;;
+ test $CURRENT -lt 3 && __providers
+ [[ $words[2] = "mirror" ]] && __providers_mirror
+ [[ $words[2] = "schema" ]] && __providers_schema
+ ;;
refresh)
__refresh ;;
show)
@@ -345,6 +394,7 @@ case "$words[1]" in
[[ $words[2] = "list" ]] && __state_list
[[ $words[2] = "mv" ]] && __state_mv
[[ $words[2] = "push" ]] && __state_push
+ [[ $words[2] = "replace-provider" ]] && __state_replace_provider
[[ $words[2] = "rm" ]] && __state_rm
[[ $words[2] = "show" ]] && __state_show
;;
@@ -354,6 +404,8 @@ case "$words[1]" in
__untaint ;;
validate)
__validate ;;
+ version)
+ __version ;;
workspace)
test $CURRENT -lt 3 && __workspace ;;
esac
diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
index d727c1ee0..997241c9a 100644
--- a/plugins/terraform/terraform.plugin.zsh
+++ b/plugins/terraform/terraform.plugin.zsh
@@ -2,8 +2,10 @@ function tf_prompt_info() {
# dont show 'default' workspace in home dir
[[ "$PWD" == ~ ]] && return
# check if in terraform dir
- if [ -d .terraform ]; then
- workspace=$(terraform workspace show 2> /dev/null) || return
+ if [[ -d .terraform && -r .terraform/environment ]]; then
+ workspace=$(cat .terraform/environment) || return
echo "[${workspace}]"
fi
}
+
+alias tf='terraform'
diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
index bd407b316..84f7255ce 100644
--- a/plugins/thefuck/README.md
+++ b/plugins/thefuck/README.md
@@ -2,6 +2,10 @@
[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
+To use it, add thefuck to the plugins array of your zshrc file:
+
+plugins=(... thefuck)
+
## Usage
Press `ESC` twice to correct previous console command.
diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
index b8586c70d..2ab4eb6e2 100644
--- a/plugins/thefuck/thefuck.plugin.zsh
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -5,7 +5,8 @@ if [[ -z $commands[thefuck] ]]; then
fi
# Register alias
-eval "$(thefuck --alias)"
+[[ ! -a $ZSH_CACHE_DIR/thefuck ]] && thefuck --alias > $ZSH_CACHE_DIR/thefuck
+source $ZSH_CACHE_DIR/thefuck
fuck-command-line() {
local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
diff --git a/plugins/timer/README.md b/plugins/timer/README.md
index 321307e59..30b0bd00e 100644
--- a/plugins/timer/README.md
+++ b/plugins/timer/README.md
@@ -3,6 +3,7 @@ This plugin allows to display command's execution time in a very nonintrusive wa
Timer can be tuned by these two variables:
* `TIMER_PRECISION` allows to control number of decimal places (default `1`)
* `TIMER_FORMAT` allows to adjust display format (default `'/%d'`)
+* `TIMER_THRESHOLD` allows to set the minimum execution time that causes the timer to be shown (default `0`)
Sample session:
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
index 728377c5c..b261f71c5 100644
--- a/plugins/timer/timer.plugin.zsh
+++ b/plugins/timer/timer.plugin.zsh
@@ -1,5 +1,8 @@
+zmodload zsh/datetime
+
__timer_current_time() {
- perl -MTime::HiRes=time -e'print time'
+ zmodload zsh/datetime
+ echo $EPOCHREALTIME
}
__timer_format_duration() {
@@ -19,9 +22,11 @@ __timer_display_timer_precmd() {
local cmd_end_time=$(__timer_current_time)
local tdiff=$((cmd_end_time - __timer_cmd_start_time))
unset __timer_cmd_start_time
- local tdiffstr=$(__timer_format_duration ${tdiff})
- local cols=$((COLUMNS - ${#tdiffstr} - 1))
- echo -e "\033[1A\033[${cols}C ${tdiffstr}"
+ if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then
+ local tdiffstr=$(__timer_format_duration ${tdiff})
+ local cols=$((COLUMNS - ${#tdiffstr} - 1))
+ echo -e "\033[1A\033[${cols}C ${tdiffstr}"
+ fi
fi
}
diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
index a53752fb2..989ffd1ff 100644
--- a/plugins/ubuntu/ubuntu.plugin.zsh
+++ b/plugins/ubuntu/ubuntu.plugin.zsh
@@ -15,6 +15,9 @@ alias agli='apt list --installed'
# List available updates only
alias aglu='apt list --upgradable'
+alias acsp='apt-cache showpkg'
+compdef _acsp acsp='apt-cache showpkg'
+
# superuser operations ######################################################
alias afu='sudo apt-file update'
diff --git a/plugins/universalarchive/README.md b/plugins/universalarchive/README.md
new file mode 100644
index 000000000..93a1bd9fc
--- /dev/null
+++ b/plugins/universalarchive/README.md
@@ -0,0 +1,46 @@
+# universalarchive plugin
+
+Lets you compress files by a command `ua <format> <files>`, supporting various
+compression formats (e.g. 7z, tar.gz, lzma, ...).
+
+To enable it, add `universalarchive` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... universalarchive)
+```
+
+## Usage
+
+Run `ua <format> <files>` to compress `<files>` into an archive file using `<format>`.
+For example:
+
+```sh
+ua xz *.html
+```
+
+this command will compress all `.html` files in directory `folder` into `folder.xz`.
+
+This plugin saves you from having to remember which command line arguments compress a file.
+
+## Supported compression formats
+
+| Extension | Description |
+|:-----------------|:-------------------------------|
+| `7z` | 7zip file |
+| `bz2` | Bzip2 file |
+| `gz` | Gzip file |
+| `lzma` | LZMA archive |
+| `lzo` | LZO archive |
+| `rar` | WinRAR archive |
+| `tar` | Tarball |
+| `tbz`/`tar.bz2` | Tarball with bzip2 compression |
+| `tgz`/`tar.gz` | Tarball with gzip compression |
+| `tlz`/`tar.lzma` | Tarball with lzma compression |
+| `txz`/`tar.xz` | Tarball with lzma2 compression |
+| `tZ`/`tar.Z` | Tarball with LZW compression |
+| `xz` | LZMA2 archive |
+| `Z` | Z archive (LZW) |
+| `zip` | Zip archive |
+| `zst` | Zstd archive |
+
+See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information regarding the archive formats.
diff --git a/plugins/universalarchive/_universalarchive b/plugins/universalarchive/_universalarchive
new file mode 100644
index 000000000..17cfd782e
--- /dev/null
+++ b/plugins/universalarchive/_universalarchive
@@ -0,0 +1,6 @@
+#compdef ua
+
+_arguments \
+ "1:archive format:(7z bz2 gz lzma lzo rar tar tar.bz2 tar.gz tar.lzma tar.xz tar.Z tbz tgz tlz txz tZ xz Z zip zst)" \
+ "*:input files:_files" \
+&& return 0
diff --git a/plugins/universalarchive/universalarchive.plugin.zsh b/plugins/universalarchive/universalarchive.plugin.zsh
new file mode 100644
index 000000000..b287c22b2
--- /dev/null
+++ b/plugins/universalarchive/universalarchive.plugin.zsh
@@ -0,0 +1,70 @@
+function ua() {
+ local usage=\
+"Archive files and directories using a given compression algorithm.
+
+Usage: $0 <format> <files>
+Example: $0 tbz PKGBUILD
+
+Supported archive formats are:
+7z, bz2, gz, lzma, lzo, rar, tar, tbz (tar.bz2), tgz (tar.gz),
+tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
+
+ if [[ $# -lt 2 ]]; then
+ print -u2 -- "$usage"
+ return 1
+ fi
+
+ local ext="$1"
+ local input="${2:a}"
+
+ shift
+
+ if [[ ! -e "$input" ]]; then
+ print -u2 -- "$input not found"
+ return 1
+ fi
+
+ # generate output file name
+ local output
+ if [[ $# -gt 1 ]]; then
+ output="${input:h:t}"
+ elif [[ -f "$input" ]]; then
+ output="${input:r:t}"
+ elif [[ -d "$input" ]]; then
+ output="${input:t}"
+ fi
+
+ # if output file exists, generate a random name
+ if [[ -f "${output}.${ext}" ]]; then
+ output=$(mktemp "${output}_XXX") && rm "$output" || return 1
+ fi
+
+ # add extension
+ output="${output}.${ext}"
+
+ # safety check
+ if [[ -f "$output" ]]; then
+ print -u2 -- "output file '$output' already exists. Aborting"
+ return 1
+ fi
+
+ case "$ext" in
+ 7z) 7z u "${output}" "${@}" ;;
+ bz2) bzip2 -vcf "${@}" > "${output}" ;;
+ gz) gzip -vcf "${@}" > "${output}" ;;
+ lzma) lzma -vc -T0 "${@}" > "${output}" ;;
+ lzo) lzop -vc "${@}" > "${output}" ;;
+ rar) rar a "${output}" "${@}" ;;
+ tar) tar -cvf "${output}" "${@}" ;;
+ tbz|tar.bz2) tar -cvjf "${output}" "${@}" ;;
+ tgz|tar.gz) tar -cvzf "${output}" "${@}" ;;
+ tlz|tar.lzma) XZ_OPT=-T0 tar --lzma -cvf "${output}" "${@}" ;;
+ txz|tar.xz) XZ_OPT=-T0 tar -cvJf "${output}" "${@}" ;;
+ tZ|tar.Z) tar -cvZf "${output}" "${@}" ;;
+ xz) xz -vc -T0 "${@}" > "${output}" ;;
+ Z) compress -vcf "${@}" > "${output}" ;;
+ zip) zip -rull "${output}" "${@}" ;;
+ zst) zstd -c -T0 "${@}" > "${output}" ;;
+ *) print -u2 -- "$usage"; return 1 ;;
+ esac
+}
diff --git a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
index 28bf31f91..d7c76c3c9 100644
--- a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
+++ b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
@@ -16,22 +16,17 @@
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
function vagrant_prompt_info() {
- test -d .vagrant && test -f Vagrantfile
- if [[ "$?" == "0" ]]; then
- statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
- statuses=("${(f)statuses}")
+ local vm_states vm_state
+ if [[ -d .vagrant && -f Vagrantfile ]]; then
+ vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"})
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
- for vm_details in $statuses; do
- vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
- if [[ "$vm_state" == "running" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
- elif [[ "$vm_state" == "saved" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
- elif [[ "$vm_state" == "not created" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
- elif [[ "$vm_state" == "poweroff" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
- fi
+ for vm_state in $vm_states; do
+ case "$vm_state" in
+ saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
+ running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
+ poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
+ "not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
+ esac
done
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
fi
diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant
index 3e16dbebf..e88835506 100644
--- a/plugins/vagrant/_vagrant
+++ b/plugins/vagrant/_vagrant
@@ -69,7 +69,7 @@ __box_list ()
__vm_list ()
{
- _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
+ _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9\._-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
_wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null)
}
diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
index 8519a5592..46bb6d070 100644
--- a/plugins/vi-mode/README.md
+++ b/plugins/vi-mode/README.md
@@ -1,34 +1,72 @@
-vi-mode
-=======
+# vi-mode plugin
+
This plugin increase `vi-like` zsh functionality.
+To use it, add `vi-mode` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... vi-mode)
+```
+
+## Settings
+
+- `VI_MODE_RESET_PROMPT_ON_MODE_CHANGE`: controls whether the prompt is redrawn when
+ switching to a different input mode. If this is unset, the mode indicator will not
+ be updated when changing to a different mode.
+ Set it to `true` to enable it. For example:
+
+ ```zsh
+ VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true
+ ```
+
+ The default value is unset, unless `vi_mode_prompt_info` is used, in which case it'll
+ automatically be set to `true`.
+
+- `VI_MODE_SET_CURSOR`: controls whether the cursor style is changed when switching
+ to a different input mode. Set it to `true` to enable it (default: unset):
+
+ ```zsh
+ VI_MODE_SET_CURSOR=true
+ ```
+
+- `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode.
+ See [Mode indicator](#mode-indicator) for details.
+
+## Mode indicator
+
+*Normal mode* is indicated with a red `<<<` mark at the right prompt, when it
+hasn't been defined by theme.
+
+You can change this indicator by setting the `MODE_INDICATOR` variable. This setting
+supports Prompt Expansion sequences. For example:
+
+```zsh
+MODE_INDICATOR="%F{yellow}+%f"
+```
+
+You can also use the `vi_mode_prompt_info` function in your prompt, which will display
+this mode indicator.
+
+## Key bindings
+
Use `ESC` or `CTRL-[` to enter `Normal mode`.
+NOTE: some of these key bindings are set by zsh by default when using a vi-mode keymap.
-History
--------
+### History
- `ctrl-p` : Previous command in history
- `ctrl-n` : Next command in history
- `/` : Search backward in history
- `n` : Repeat the last `/`
+### Vim edition
-Mode indicators
----------------
-
-*Normal mode* is indicated with red `<<<` mark at the right prompt, when it
-wasn't defined by theme.
-
+- `vv` : Edit current command line in Vim
-Vim edition
------------
+NOTE: this used to be bound to `v`. That is now the default (`visual-mode`).
-- `v` : Edit current command line in Vim
-
-
-Movement
---------
+### Movement
- `$` : To the end of the line
- `^` : To the first non-blank character of the line
@@ -46,9 +84,7 @@ Movement
- `;` : Repeat latest f, t, F or T [count] times
- `,` : Repeat latest f, t, F or T in opposite direction
-
-Insertion
----------
+### Insertion
- `i` : Insert text before the cursor
- `I` : Insert text before the first character in the line
@@ -57,9 +93,7 @@ Insertion
- `o` : Insert new command line below the current one
- `O` : Insert new command line above the current one
-
-Delete and Insert
------------------
+### Delete and Insert
- `ctrl-h` : While in *Insert mode*: delete character before the cursor
- `ctrl-w` : While in *Insert mode*: delete word before the cursor
@@ -71,5 +105,23 @@ Delete and Insert
- `C` : Delete to the end of the line and start insert
- `r{char}` : Replace the character under the cursor with {char}
- `R` : Enter replace mode: Each character replaces existing one
-- `x` : Delete [count] characters under and after the cursor
-- `X` : Delete [count] characters before the cursor
+- `x` : Delete `count` characters under and after the cursor
+- `X` : Delete `count` characters before the cursor
+
+## Known issues
+
+### Low `$KEYTIMEOUT`
+
+A low `$KEYTIMEOUT` value (< 15) means that key bindings that need multiple characters,
+like `vv`, will be very difficult to trigger. `$KEYTIMEOUT` controls the number of
+milliseconds that must pass before a key press is read and the appropriate key binding
+is triggered. For multi-character key bindings, the key presses need to happen before
+the timeout is reached, so on low timeouts the key press happens too slow, and therefore
+another key binding is triggered.
+
+We recommend either setting `$KEYTIMEOUT` to a higher value, or remapping the key bindings
+that you want to trigger to a keyboard sequence. For example:
+
+```zsh
+bindkey -M vicmd 'V' edit-command-line # this remaps `vv` to `V` (but overrides `visual-mode`)
+```
diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
index c91ba05ba..dd4afdd8b 100644
--- a/plugins/vi-mode/vi-mode.plugin.zsh
+++ b/plugins/vi-mode/vi-mode.plugin.zsh
@@ -1,32 +1,77 @@
+# Control whether to force a redraw on each mode change.
+#
+# Resetting the prompt on every mode change can cause lag when switching modes.
+# This is especially true if the prompt does things like checking git status.
+#
+# Set to "true" to force the prompt to reset on each mode change.
+# Unset or set to any other value to do the opposite.
+#
+# The default is not to reset, unless we're showing the mode in RPS1.
+typeset -g VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
+# Control whether to change the cursor style on mode change.
+#
+# Set to "true" to change the cursor on each mode change.
+# Unset or set to any other value to do the opposite.
+typeset -g VI_MODE_SET_CURSOR
+
+typeset -g VI_KEYMAP=main
+
+function _vi-mode-set-cursor-shape-for-keymap() {
+ [[ "$VI_MODE_SET_CURSOR" = true ]] || return
+
+ # https://vt100.net/docs/vt510-rm/DECSCUSR
+ local _shape=0
+ case "${1:-${VI_KEYMAP:-main}}" in
+ main) _shape=6 ;; # vi insert: line
+ viins) _shape=6 ;; # vi insert: line
+ isearch) _shape=6 ;; # inc search: line
+ command) _shape=6 ;; # read a command name
+ vicmd) _shape=2 ;; # vi cmd: block
+ visual) _shape=2 ;; # vi visual mode: block
+ viopp) _shape=0 ;; # vi operation pending: blinking block
+ *) _shape=0 ;;
+ esac
+ printf $'\e[%d q' "${_shape}"
+}
+
# Updates editor information when the keymap changes.
function zle-keymap-select() {
# update keymap variable for the prompt
- VI_KEYMAP=$KEYMAP
+ typeset -g VI_KEYMAP=$KEYMAP
- zle reset-prompt
- zle -R
+ if [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" = true ]]; then
+ zle reset-prompt
+ zle -R
+ fi
+ _vi-mode-set-cursor-shape-for-keymap "${VI_KEYMAP}"
}
-
zle -N zle-keymap-select
-function vi-accept-line() {
- VI_KEYMAP=main
- zle accept-line
+# These "echoti" statements were originally set in lib/key-bindings.zsh
+# Not sure the best way to extend without overriding.
+function zle-line-init() {
+ local prev_vi_keymap
+ prev_vi_keymap="${VI_KEYMAP:-}"
+ typeset -g VI_KEYMAP=main
+ [[ "$prev_vi_keymap" != 'main' ]] && [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" = true ]] && zle reset-prompt
+ (( ! ${+terminfo[smkx]} )) || echoti smkx
+ _vi-mode-set-cursor-shape-for-keymap "${VI_KEYMAP}"
}
+zle -N zle-line-init
-zle -N vi-accept-line
-
+function zle-line-finish() {
+ typeset -g VI_KEYMAP=main
+ (( ! ${+terminfo[rmkx]} )) || echoti rmkx
+ _vi-mode-set-cursor-shape-for-keymap default
+}
+zle -N zle-line-finish
bindkey -v
-# use custom accept-line widget to update $VI_KEYMAP
-bindkey -M vicmd '^J' vi-accept-line
-bindkey -M vicmd '^M' vi-accept-line
-
-# allow v to edit the command line (standard behaviour)
+# allow vv to edit the command line (standard behaviour)
autoload -Uz edit-command-line
zle -N edit-command-line
-bindkey -M vicmd 'v' edit-command-line
+bindkey -M vicmd 'vv' edit-command-line
# allow ctrl-p, ctrl-n for navigate history (standard behaviour)
bindkey '^P' up-history
@@ -45,16 +90,56 @@ bindkey '^s' history-incremental-search-forward
bindkey '^a' beginning-of-line
bindkey '^e' end-of-line
+function wrap_clipboard_widgets() {
+ # NB: Assume we are the first wrapper and that we only wrap native widgets
+ # See zsh-autosuggestions.zsh for a more generic and more robust wrapper
+ local verb="$1"
+ shift
+
+ local widget
+ local wrapped_name
+ for widget in "$@"; do
+ wrapped_name="_zsh-vi-${verb}-${widget}"
+ if [ "${verb}" = copy ]; then
+ eval "
+ function ${wrapped_name}() {
+ zle .${widget}
+ printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null || true
+ }
+ "
+ else
+ eval "
+ function ${wrapped_name}() {
+ CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\"
+ zle .${widget}
+ }
+ "
+ fi
+ zle -N "${widget}" "${wrapped_name}"
+ done
+}
+
+wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete
+wrap_clipboard_widgets paste vi-put-{before,after}
+unfunction wrap_clipboard_widgets
+
# if mode indicator wasn't setup by theme, define default
-if [[ "$MODE_INDICATOR" == "" ]]; then
- MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
+if [[ -z "$MODE_INDICATOR" ]]; then
+ MODE_INDICATOR='%B%F{red}<%b<<%f'
fi
function vi_mode_prompt_info() {
+ # If we're using the prompt to display mode info, and we haven't explicitly
+ # disabled "reset prompt on mode change", then set it here.
+ #
+ # We do that here instead of the `if` statement below because the user may
+ # set RPS1/RPROMPT to something else in their custom config.
+ : "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:=true}"
+
echo "${${VI_KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
}
# define right prompt, if it wasn't defined by a theme
-if [[ "$RPS1" == "" && "$RPROMPT" == "" ]]; then
+if [[ -z "$RPS1" && -z "$RPROMPT" ]]; then
RPS1='$(vi_mode_prompt_info)'
fi
diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh
index 010f998d3..b73f9b4da 100644
--- a/plugins/vim-interaction/vim-interaction.plugin.zsh
+++ b/plugins/vim-interaction/vim-interaction.plugin.zsh
@@ -4,8 +4,7 @@
# Derek Wyatt (derek@{myfirstnamemylastname}.org
#
-function callvim
-{
+function callvim {
if [[ $# == 0 ]]; then
cat <<EOH
usage: callvim [-b cmd] [-a cmd] [-n name] [file ... fileN]
@@ -19,10 +18,20 @@ EOH
return 0
fi
- local cmd=""
- local before="<esc>"
- local after=""
- local name="GVIM"
+ # Look up the newest instance or start one
+ local name="$(gvim --serverlist | tail -n 1)"
+ [[ -n "$name" ]] || {
+ # run gvim or exit if it fails
+ gvim || return $?
+
+ # wait for gvim instance to fully load
+ while name=$(gvim --serverlist) && [[ -z "$name" ]]; do
+ sleep 0.1
+ done
+ }
+
+ local before="<esc>" files after cmd
+
while getopts ":b:a:n:" option
do
case $option in
@@ -35,22 +44,20 @@ EOH
esac
done
shift $((OPTIND-1))
- if [[ ${after#:} != $after && ${after%<cr>} == $after ]]; then
- after="$after<cr>"
- fi
- if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
- before="$before<cr>"
- fi
- local files
- if [[ $# -gt 0 ]]; then
- # absolute path of files resolving symlinks (:A) and quoting special chars (:q)
- files=':args! '"${@:A:q}<cr>"
- fi
+
+ # If before or after commands begin with : and don't end with <cr>, append it
+ [[ ${after} = :* && ${after} != *\<cr\> ]] && after+="<cr>"
+ [[ ${before} = :* && ${before} != *\<cr\> ]] && before+="<cr>"
+ # Open files passed (:A means abs path resolving symlinks, :q means quoting special chars)
+ [[ $# -gt 0 ]] && files=':args! '"${@:A:q}<cr>"
+ # Pass the built vim command to gvim
cmd="$before$files$after"
- gvim --servername "$name" --remote-send "$cmd"
- if typeset -f postCallVim > /dev/null; then
- postCallVim
- fi
+
+ # Run the gvim command
+ gvim --servername "$name" --remote-send "$cmd" || return $?
+
+ # Run postCallVim if defined (maybe to bring focus to gvim, see README)
+ (( ! $+functions[postCallVim] )) || postCallVim
}
alias v=callvim
diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh
index e250eb63e..3041475ed 100644
--- a/plugins/virtualenv/virtualenv.plugin.zsh
+++ b/plugins/virtualenv/virtualenv.plugin.zsh
@@ -1,6 +1,6 @@
function virtualenv_prompt_info(){
[[ -n ${VIRTUAL_ENV} ]] || return
- echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}"
+ echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX=]}"
}
# disables prompt mangling in virtual_env/bin/activate
diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
index 88217a7f5..c30216f51 100644
--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
@@ -35,27 +35,19 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
function workon_cwd {
if [[ -z "$WORKON_CWD" ]]; then
local WORKON_CWD=1
- # Check if this is a Git repo
- local GIT_REPO_ROOT=""
- local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)"
- if [[ $? == 0 ]]; then
- GIT_REPO_ROOT="$GIT_TOPLEVEL"
- fi
# Get absolute path, resolving symlinks
local PROJECT_ROOT="${PWD:A}"
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \
- && ! -d "$PROJECT_ROOT/.git" && "$PROJECT_ROOT" != "$GIT_REPO_ROOT" ]]; do
+ && ! -d "$PROJECT_ROOT/.git" ]]; do
PROJECT_ROOT="${PROJECT_ROOT:h}"
done
- if [[ "$PROJECT_ROOT" == "/" ]]; then
- PROJECT_ROOT="."
- fi
+
# Check for virtualenv name override
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
ENV_NAME="$(cat "$PROJECT_ROOT/.venv")"
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
ENV_NAME="$PROJECT_ROOT/.venv"
- elif [[ "$PROJECT_ROOT" != "." ]]; then
+ elif [[ "$PROJECT_ROOT" != "/" ]]; then
ENV_NAME="${PROJECT_ROOT:t}"
else
ENV_NAME=""
@@ -68,14 +60,21 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
fi
if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active
- if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
+ if [[ ! "$VIRTUAL_ENV" -ef "$WORKON_HOME/$ENV_NAME" ]]; then
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
+ else
+ ENV_NAME=""
fi
fi
fi
+ if [[ "$ENV_NAME" == "" && -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
+ # We've just left the repo, deactivate the environment
+ # Note: this only happens if the virtualenv was activated automatically
+ deactivate && unset CD_VIRTUAL_ENV
+ fi
fi
}
diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md
index 469c57ea8..e95ed5d4f 100644
--- a/plugins/vscode/README.md
+++ b/plugins/vscode/README.md
@@ -1,6 +1,6 @@
# VS Code
-This plugin makes interaction between the command line and the VS Code editor easier.
+This plugin provides useful aliases to simplify the interaction between the command line and VS Code or VSCodium editor.
To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
@@ -10,23 +10,37 @@ plugins=(... vscode)
## Requirements
-To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH,
-otherwise you might receive this message: `zsh: command not found: code`.
+This plugin requires to have a flavour of VS Code installed and it's executable available in PATH.
-[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
+You can install either:
+
+* VS Code (code)
+* VS Code Insiders (code-insiders)
+* VSCodium (codium)
+
+### MacOS
+While Linux installations will add the executable to PATH, MacOS users might still have to do this manually:
+
+[For VS Code and VS Code Insiders](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
-> Install 'code' command in PATH
+> Shell Command: Install 'code' command in PATH
-## VS Code Insiders
+[For VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md#how-do-i-open-vscodium-from-the-terminal), open
+the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
+> Shell Command: Install 'codium' command in PATH
-🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.**
+## Using multiple flavours
-But, if you have both Stable and Insiders versions and want to configure the plugin to just use the Insiders version, add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and the `plugins=()` line). This will make the plugin use the Insiders version instead.
+If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can
+manually specify the flavour's executable. Add the following line to the .zshrc file (between the `ZSH_THEME` and the `plugins=()` lines).
+This will make the plugin use your manually defined executable.
```zsh
ZSH_THEME=...
-# Add this line to use code-insiders instead of code
+# Choose between one [code, code-insiders or codium]
+# The following line will make the plugin to open VS Code Insiders
+# Invalid entries will be ignored, no aliases will be added
VSCODE=code-insiders
plugins=(... vscode)
diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh
index 0144e0baa..48d904377 100644
--- a/plugins/vscode/vscode.plugin.zsh
+++ b/plugins/vscode/vscode.plugin.zsh
@@ -1,17 +1,28 @@
-# VScode zsh plugin
+# VS Code (stable / insiders) / VSCodium zsh plugin
# Authors:
# https://github.com/MarsiBarsi (original author)
# https://github.com/babakks
+# https://github.com/SteelShot
-# Use the stable VS Code release, unless the Insiders version is the only
-# available installation
-if ! which code > /dev/null && which code-insiders > /dev/null; then
- : ${VSCODE:=code-insiders}
-else
- : ${VSCODE:=code}
+# Verify if any manual user choice of VS Code exists first.
+if [[ -n "$VSCODE" ]] && ! which $VSCODE &>/dev/null; then
+ echo "'$VSCODE' flavour of VS Code not detected."
+ unset VSCODE
+fi
+
+# Otherwise, try to detect a flavour of VS Code.
+if [[ -z "$VSCODE" ]]; then
+ if which code &>/dev/null; then
+ VSCODE=code
+ elif which code-insiders &>/dev/null; then
+ VSCODE=code-insiders
+ elif which codium &>/dev/null; then
+ VSCODE=codium
+ else
+ return
+ fi
fi
-# Define aliases
alias vsc="$VSCODE ."
alias vsca="$VSCODE --add"
alias vscd="$VSCODE --diff"
diff --git a/plugins/wd/README.md b/plugins/wd/README.md
index a454a6c1e..8791f9f0e 100644
--- a/plugins/wd/README.md
+++ b/plugins/wd/README.md
@@ -2,19 +2,19 @@
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
-`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path.
+`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`.
+Why?
+Because `cd` seems inefficient when the folder is frequently visited or has a long path.
![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
-*NEWS*: If you are not using zsh, check out the c-port, [wd-c](https://github.com/mfaerevaag/wd-c), which works with all shells using wrapper functions.
-
## Setup
-### oh-my-zsh
+### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
-`wd` comes bundled with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)!
+`wd` comes bundled with oh-my-zsh!
-Just add the plugin in your `~/.zshrc` file:
+Just add the plugin in your `.zshrc` file:
```zsh
plugins=(... wd)
@@ -38,11 +38,21 @@ antibody bundle mfaerevaag/wd
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
+1. Install from the AUR
+
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
+2. Then add to your `.zshrc`:
+
+```zsh
+wd() {
+ . /usr/share/wd/wd.sh
+}
+```
+
### [zplug](https://github.com/zplug/zplug)
```zsh
@@ -51,7 +61,9 @@ zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS
### Automatic
-Run either in terminal:
+_Note: automatic install does not provide the manpage. It is also poor security practice to run remote code without first reviewing it, so you ought to look [here](https://github.com/mfaerevaag/wd/blob/master/install.sh)_
+
+Run either command in your terminal:
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
@@ -65,28 +77,33 @@ wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.
### Manual
-* Clone this repo to your liking
+1. Clone this repository on your local machine in a sensible location (if you know what you're doing of course all of this is up to you):
-* Add `wd` function to `.zshrc` (or `.profile` etc.):
+```zsh
+git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
+```
- ```zsh
- wd() {
- . ~/path/to/cloned/repo/wd/wd.sh
- }
- ```
+2. Add `wd` function to `.zshrc` (or `.profile` etc.):
-* Install manpage. From `wd`'s base directory (requires root permissions):
+```zsh
+wd() {
+ . ~/.local/wd/wd.sh
+}
+```
- ```zsh
- cp wd.1 /usr/share/man/man1/wd.1
- chmod 644 /usr/share/man/man1/wd.1
- ```
+3. Install manpage (optional):
- **Note:** when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
+```zsh
+sudo cp ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
+sudo chmod 644 /usr/share/man/man1/wd.1
+```
+
+**Note:** when pulling and updating `wd`, you'll need to repeat step 3 should the manpage change
## Completion
-If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
+If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`.
+E.g. in your `~/.zshrc`:
```zsh
fpath=(~/path/to/wd $fpath)
@@ -102,109 +119,110 @@ rm -f ~/.zcompdump; compinit
* Add warp point to current working directory:
- ```zsh
- wd add foo
- ```
+```zsh
+wd add foo
+```
- If a warp point with the same name exists, use `wd add! foo` to overwrite it.
+If a warp point with the same name exists, use `wd add foo --force` to overwrite it.
- **Note:** a warp point cannot contain colons, or consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
+**Note:** a warp point cannot contain colons, or consist of only spaces and dots.
+The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
- You can omit point name to automatically use the current directory's name instead.
+You can omit point name to automatically use the current directory's name instead.
* From any directory, warp to `foo` with:
- ```zsh
- wd foo
- ```
+```zsh
+wd foo
+```
-* You can also warp to a directory within foo, with autocompletion:
+* You can also warp to a directory within `foo`, with autocompletion:
- ```zsh
- wd foo some/inner/path
- ```
+```zsh
+wd foo some/inner/path
+```
* You can warp back to previous directory and higher, with this dot syntax:
- ```zsh
- wd ..
- wd ...
- ```
+```zsh
+wd ..
+wd ...
+```
- This is a wrapper for the zsh's `dirs` function.
- _You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh))._
+This is a wrapper for the zsh's `dirs` function.
+_You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._
* Remove warp point:
- ```zsh
- wd rm foo
- ```
+```zsh
+wd rm foo
+```
- You can omit point name to use the current directory's name instead.
+You can omit point name to use the current directory's name instead.
-* List all warp points (stored in `~/.warprc`):
+* List all warp points (stored in `~/.warprc` by default):
- ```zsh
- wd list
- ```
+```zsh
+wd list
+```
* List files in given warp point:
- ```zsh
- wd ls foo
- ```
+```zsh
+wd ls foo
+```
* Show path of given warp point:
- ```zsh
- wd path foo
- ```
+```zsh
+wd path foo
+```
* List warp points to current directory, or optionally, path to given warp point:
- ```zsh
- wd show
- ```
+```zsh
+wd show
+```
* Remove warp points to non-existent directories.
- ```zsh
- wd clean
- ```
+```zsh
+wd clean
+```
- Use `wd clean!` to not be prompted with confirmation (force).
+Use `wd clean --force` to not be prompted with confirmation.
* Print usage info:
- ```zsh
- wd help
- ```
+```zsh
+wd help
+```
- The usage will be printed also if you call `wd` with no command
+The usage will be printed also if you call `wd` with no command
* Print the running version of `wd`:
- ```zsh
- wd --version
- ```
+```zsh
+wd --version
+```
* Specifically set the config file (default being `~/.warprc`), which is useful for testing:
- ```zsh
- wd --config ./file <command>
- ```
+```zsh
+wd --config ./file <command>
+```
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
- ```zsh
- wd --debug <command>
- ```
+```zsh
+wd --debug <command>
+```
* Silence all output:
- ```zsh
- wd --quiet <command>
- ```
+```zsh
+wd --quiet <command>
+```
## Configuration
@@ -216,7 +234,7 @@ Defines the path where warp points get stored. Defaults to `$HOME/.warprc`.
## Testing
-`wd` comes with a small test suite, run with [shunit2](https://code.google.com/p/shunit2/). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
+`wd` comes with a small test suite, run with [shunit2](https://github.com/kward/shunit2). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
To run, simply `cd` into the `test` directory and run the `tests.sh`.
@@ -225,15 +243,17 @@ cd ./test
./tests.sh
```
-## License
+## Maintainers
+
+Following @mfaerevaag stepping away from active maintainership of this repository, the following users now are also maintainers of the repo:
-The project is licensed under the [MIT license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
+* @alpha-tango-kilo
-## Contributing
+* @MattLewin
-If you have issues, feedback or improvements, don't hesitate to report it or submit a pull request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. For an explanation on how to run the tests, read the section "Testing" in this README.
+Anyone else contributing is greatly appreciated and will be mentioned in the release notes!
-----
+---
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index 802ed10ee..9085c5b7b 100644
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd
# version
-readonly WD_VERSION=0.4.6
+readonly WD_VERSION=0.5.0
# colors
readonly WD_BLUE="\033[96m"
@@ -71,7 +71,7 @@ wd_print_msg()
wd_print_usage()
{
- cat <<- EOF
+ command cat <<- EOF
Usage: wd [command] [point]
Commands:
@@ -79,8 +79,6 @@ Commands:
<point> <path> Warps to the directory specified by the warp point with path appended
add <point> Adds the current working directory to your warp points
add Adds the current working directory to your warp points with current directory's name
- add! <point> Overwrites existing warp point
- add! Overwrites existing warp point with current directory's name
rm <point> Removes the given warp point
rm Removes the given warp point with current directory's name
show <point> Print path to given warp point
@@ -88,12 +86,13 @@ Commands:
list Print all stored warp points
ls <point> Show files from given warp point (ls)
path <point> Show the path to given warp point (pwd)
- clean! Remove points warping to nonexistent directories
+ clean Remove points warping to nonexistent directories (will prompt unless --force is used)
-v | --version Print version
-d | --debug Exit after execution with exit codes (for testing)
-c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output
+ -f | --force Allows overwriting without warning (for add & clean)
help Show this extremely helpful text
EOF
@@ -103,7 +102,7 @@ wd_exit_fail()
{
local msg=$1
- wd_print_msg $WD_RED $msg
+ wd_print_msg "$WD_RED" "$msg"
WD_EXIT_CODE=1
}
@@ -111,7 +110,7 @@ wd_exit_warn()
{
local msg=$1
- wd_print_msg $WD_YELLOW $msg
+ wd_print_msg "$WD_YELLOW" "$msg"
WD_EXIT_CODE=1
}
@@ -119,7 +118,7 @@ wd_getdir()
{
local name_arg=$1
- point=$(wd_show $name_arg)
+ point=$(wd_show "$name_arg")
dir=${point:28+$#name_arg+7}
if [[ -z $name_arg ]]; then
@@ -162,12 +161,12 @@ wd_warp()
wd_add()
{
- local force=$1
- local point=$2
+ local point=$1
+ local force=$2
if [[ $point == "" ]]
then
- point=$(basename $PWD)
+ point=$(basename "$PWD")
fi
if [[ $point =~ "^[\.]+$" ]]
@@ -176,55 +175,62 @@ wd_add()
elif [[ $point =~ "[[:space:]]+" ]]
then
wd_exit_fail "Warp point should not contain whitespace"
- elif [[ $point == *:* ]]
+ elif [[ $point =~ : ]] || [[ $point =~ / ]]
then
- wd_exit_fail "Warp point cannot contain colons"
- elif [[ ${points[$point]} == "" ]] || $force
+ wd_exit_fail "Warp point contains illegal character (:/)"
+ elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
then
- wd_remove $point > /dev/null
- printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
+ wd_remove "$point" > /dev/null
+ printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> "$WD_CONFIG"
+ if (whence sort >/dev/null); then
+ local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
+ # use 'cat' below to ensure we respect $WD_CONFIG as a symlink
+ command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}"
+ fi
wd_export_static_named_directories
- wd_print_msg $WD_GREEN "Warp point added"
+ wd_print_msg "$WD_GREEN" "Warp point added"
# override exit code in case wd_remove did not remove any points
# TODO: we should handle this kind of logic better
WD_EXIT_CODE=0
else
- wd_exit_warn "Warp point '${point}' already exists. Use 'add!' to overwrite."
+ wd_exit_warn "Warp point '${point}' already exists. Use 'add --force' to overwrite."
fi
}
wd_remove()
{
- local point=$1
+ local point_list=$1
- if [[ $point == "" ]]
+ if [[ "$point_list" == "" ]]
then
- point=$(basename $PWD)
+ point_list=$(basename "$PWD")
fi
- if [[ ${points[$point]} != "" ]]
- then
- local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
- # Copy and delete in two steps in order to preserve symlinks
- if sed -n "/^${point}:.*$/!p" $WD_CONFIG > $config_tmp && cp $config_tmp $WD_CONFIG && rm $config_tmp
+ for point_name in $point_list ; do
+ if [[ ${points[$point_name]} != "" ]]
then
- wd_print_msg $WD_GREEN "Warp point removed"
+ local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
+ # Copy and delete in two steps in order to preserve symlinks
+ if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" > "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp"
+ then
+ wd_print_msg "$WD_GREEN" "Warp point removed"
+ else
+ wd_exit_fail "Something bad happened! Sorry."
+ fi
else
- wd_exit_fail "Something bad happened! Sorry."
+ wd_exit_fail "Warp point was not found"
fi
- else
- wd_exit_fail "Warp point was not found"
- fi
+ done
}
wd_list_all()
{
- wd_print_msg $WD_BLUE "All warp points:"
+ wd_print_msg "$WD_BLUE" "All warp points:"
- entries=$(sed "s:${HOME}:~:g" $WD_CONFIG)
+ entries=$(sed "s:${HOME}:~:g" "$WD_CONFIG")
max_warp_point_length=0
while IFS= read -r line
@@ -237,7 +243,7 @@ wd_list_all()
then
max_warp_point_length=$length
fi
- done <<< $entries
+ done <<< "$entries"
while IFS= read -r line
do
@@ -249,35 +255,35 @@ wd_list_all()
if [[ -z $wd_quiet_mode ]]
then
- printf "%${max_warp_point_length}s -> %s\n" $key $val
+ printf "%${max_warp_point_length}s -> %s\n" "$key" "$val"
fi
fi
- done <<< $entries
+ done <<< "$entries"
}
wd_ls()
{
- wd_getdir $1
- ls ${dir/#\~/$HOME}
+ wd_getdir "$1"
+ ls "${dir/#\~/$HOME}"
}
wd_path()
{
- wd_getdir $1
- echo $(echo $dir | sed "s:${HOME}:~:g")
+ wd_getdir "$1"
+ echo "$(echo "$dir" | sed "s:~:${HOME}:g")"
}
wd_show()
{
local name_arg=$1
# if there's an argument we look up the value
- if [[ ! -z $name_arg ]]
+ if [[ -n $name_arg ]]
then
if [[ -z $points[$name_arg] ]]
then
- wd_print_msg $WD_BLUE "No warp point named $name_arg"
+ wd_print_msg "$WD_BLUE" "No warp point named $name_arg"
else
- wd_print_msg $WD_GREEN "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
+ wd_print_msg "$WD_GREEN" "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
fi
else
# hax to create a local empty array
@@ -285,19 +291,19 @@ wd_show()
wd_matches=()
# do a reverse lookup to check whether PWD is in $points
PWD="${PWD/$HOME/~}"
- if [[ ${points[(r)$PWD]} == $PWD ]]
+ if [[ ${points[(r)$PWD]} == "$PWD" ]]
then
for name in ${(k)points}
do
- if [[ $points[$name] == $PWD ]]
+ if [[ $points[$name] == "$PWD" ]]
then
wd_matches[$(($#wd_matches+1))]=$name
fi
done
- wd_print_msg $WD_BLUE "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
+ wd_print_msg "$WD_BLUE" "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
else
- wd_print_msg $WD_YELLOW "No warp point to $(echo $PWD | sed "s:$HOME:~:")"
+ wd_print_msg "$WD_YELLOW" "No warp point to $(echo "$PWD" | sed "s:$HOME:~:")"
fi
fi
}
@@ -307,7 +313,7 @@ wd_clean() {
local count=0
local wd_tmp=""
- while read line
+ while read -r line
do
if [[ $line != "" ]]
then
@@ -317,33 +323,33 @@ wd_clean() {
if [ -d "${val/#\~/$HOME}" ]
then
- wd_tmp=$wd_tmp"\n"`echo $line`
+ wd_tmp=$wd_tmp"\n"`echo "$line"`
else
- wd_print_msg $WD_YELLOW "Nonexistent directory: ${key} -> ${val}"
+ wd_print_msg "$WD_YELLOW" "Nonexistent directory: ${key} -> ${val}"
count=$((count+1))
fi
fi
- done < $WD_CONFIG
+ done < "$WD_CONFIG"
if [[ $count -eq 0 ]]
then
- wd_print_msg $WD_BLUE "No warp points to clean, carry on!"
+ wd_print_msg "$WD_BLUE" "No warp points to clean, carry on!"
else
- if $force || wd_yesorno "Removing ${count} warp points. Continue? (Y/n)"
+ if [ ! -z "$force" ] || wd_yesorno "Removing ${count} warp points. Continue? (y/n)"
then
- echo $wd_tmp >! $WD_CONFIG
- wd_print_msg $WD_GREEN "Cleanup complete. ${count} warp point(s) removed"
+ echo "$wd_tmp" >! "$WD_CONFIG"
+ wd_print_msg "$WD_GREEN" "Cleanup complete. ${count} warp point(s) removed"
else
- wd_print_msg $WD_BLUE "Cleanup aborted"
+ wd_print_msg "$WD_BLUE" "Cleanup aborted"
fi
fi
}
wd_export_static_named_directories() {
- if [[ -z $WD_SKIP_EXPORT ]]
+ if [[ ! -z $WD_EXPORT ]]
then
- grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read warpdir ; do
- hash -d "$warpdir"
+ command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read -r warpdir ; do
+ hash -d "$warpdir"
done
fi
}
@@ -361,7 +367,8 @@ zparseopts -D -E \
c:=wd_alt_config -config:=wd_alt_config \
q=wd_quiet_mode -quiet=wd_quiet_mode \
v=wd_print_version -version=wd_print_version \
- d=wd_debug_mode -debug=wd_debug_mode
+ d=wd_debug_mode -debug=wd_debug_mode \
+ f=wd_force_mode -force=wd_force_mode
if [[ ! -z $wd_print_version ]]
then
@@ -374,10 +381,10 @@ then
fi
# check if config file exists
-if [ ! -e $WD_CONFIG ]
+if [ ! -e "$WD_CONFIG" ]
then
# if not, create config file
- touch $WD_CONFIG
+ touch "$WD_CONFIG"
else
wd_export_static_named_directories
fi
@@ -392,25 +399,24 @@ do
val=${(j,:,)arr[2,-1]}
points[$key]=$val
-done < $WD_CONFIG
+done < "$WD_CONFIG"
# get opts
-args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,list,ls:,path:,help,show -- $*)
+args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,path:,help,show -- $*)
# check if no arguments were given, and that version is not set
if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
then
wd_print_usage
- # check if config file is writeable
-elif [ ! -w $WD_CONFIG ]
+# check if config file is writeable
+elif [ ! -w "$WD_CONFIG" ]
then
# do nothing
# can't run `exit`, as this would exit the executing shell
wd_exit_fail "\'$WD_CONFIG\' is not writeable."
else
-
# parse rest of options
local wd_o
for wd_o
@@ -418,11 +424,7 @@ else
case "$wd_o"
in
"-a"|"--add"|"add")
- wd_add false $2
- break
- ;;
- "-a!"|"--add!"|"add!")
- wd_add true $2
+ wd_add "$2" "$wd_force_mode"
break
;;
"-e"|"export")
@@ -430,7 +432,8 @@ else
break
;;
"-r"|"--remove"|"rm")
- wd_remove $2
+ # Passes all the arguments as a single string separated by whitespace to wd_remove
+ wd_remove "${@:2}"
break
;;
"-l"|"list")
@@ -438,11 +441,11 @@ else
break
;;
"-ls"|"ls")
- wd_ls $2
+ wd_ls "$2"
break
;;
"-p"|"--path"|"path")
- wd_path $2
+ wd_path "$2"
break
;;
"-h"|"--help"|"help")
@@ -450,19 +453,15 @@ else
break
;;
"-s"|"--show"|"show")
- wd_show $2
+ wd_show "$2"
break
;;
"-c"|"--clean"|"clean")
- wd_clean false
- break
- ;;
- "-c!"|"--clean!"|"clean!")
- wd_clean true
+ wd_clean "$wd_force_mode"
break
;;
*)
- wd_warp $wd_o $2
+ wd_warp "$wd_o" "$2"
break
;;
--)
@@ -494,7 +493,7 @@ unset args
unset points
unset val &> /dev/null # fixes issue #1
-if [[ ! -z $wd_debug_mode ]]
+if [[ -n $wd_debug_mode ]]
then
exit $WD_EXIT_CODE
else
diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md
index 81908fb94..da90f90a0 100644
--- a/plugins/web-search/README.md
+++ b/plugins/web-search/README.md
@@ -41,6 +41,7 @@ Available search contexts are:
| `stackoverflow` | `https://stackoverflow.com/search?q=` |
| `wolframalpha` | `https://wolframalpha.com/input?i=` |
| `archive` | `https://web.archive.org/web/*/` |
+| `scholar` | `https://scholar.google.com/scholar?q=` |
Also there are aliases for bang-searching DuckDuckGo:
@@ -52,3 +53,27 @@ Also there are aliases for bang-searching DuckDuckGo:
| `map` | `!m` |
| `image` | `!i` |
| `ducky` | `!` |
+
+### Custom search engines
+
+If you want to add other search contexts to the plugin, you can use the
+`$ZSH_WEB_SEARCH_ENGINES` variable. Set it before Oh My Zsh is sourced,
+with the following format:
+
+```zsh
+ZSH_WEB_SEARCH_ENGINES=(
+ <context> <URL>
+ <context> <URL>
+)
+```
+
+where `<context>` is the name of the search context, and `<URL>` a URL of
+the same type as the search contexts above. For example, to add `reddit`,
+you'd do:
+
+```zsh
+ZSH_WEB_SEARCH_ENGINES=(reddit "https://www.reddit.com/search/?q=")
+```
+
+These custom search engines will also be turned to aliases, so you can
+both do `web_search reddit <query>` or `reddit <query>`.
diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh
index 326a30745..0a2b8809e 100644
--- a/plugins/web-search/web-search.plugin.zsh
+++ b/plugins/web-search/web-search.plugin.zsh
@@ -6,6 +6,7 @@ function web_search() {
# define search engine URLS
typeset -A urls
urls=(
+ $ZSH_WEB_SEARCH_ENGINES
google "https://www.google.com/search?q="
bing "https://www.bing.com/search?q="
yahoo "https://search.yahoo.com/search?p="
@@ -21,11 +22,12 @@ function web_search() {
stackoverflow "https://stackoverflow.com/search?q="
wolframalpha "https://www.wolframalpha.com/input/?i="
archive "https://web.archive.org/web/*/"
+ scholar "https://scholar.google.com/scholar?q="
)
# check whether the search engine is supported
if [[ -z "$urls[$1]" ]]; then
- echo "Search engine $1 not supported."
+ echo "Search engine '$1' not supported."
return 1
fi
@@ -59,6 +61,7 @@ alias givero='web_search givero'
alias stackoverflow='web_search stackoverflow'
alias wolframalpha='web_search wolframalpha'
alias archive='web_search archive'
+alias scholar='web_search scholar'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'
@@ -67,3 +70,13 @@ alias youtube='web_search duckduckgo \!yt'
alias map='web_search duckduckgo \!m'
alias image='web_search duckduckgo \!i'
alias ducky='web_search duckduckgo \!'
+
+# other search engine aliases
+if [[ ${#ZSH_WEB_SEARCH_ENGINES} -gt 0 ]]; then
+ typeset -A engines
+ engines=($ZSH_WEB_SEARCH_ENGINES)
+ for key in ${(k)engines}; do
+ alias "$key"="web_search $key"
+ done
+ unset engines key
+fi
diff --git a/plugins/wp-cli/README.md b/plugins/wp-cli/README.md
index 43c41eb53..c4993ab4c 100644
--- a/plugins/wp-cli/README.md
+++ b/plugins/wp-cli/README.md
@@ -1,107 +1,109 @@
# WP-CLI
-**Maintainer:** [joshmedeski](https://github.com/joshmedeski)
-
-WordPress Command Line Interface (https://wp-cli.org/)
-
-WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
-
-This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases.
-
-## List of Aliases
-
-### Core
-- wpcc='wp core config'
-- wpcd='wp core download'
-- wpci='wp core install'
-- wpcii='wp core is-installed'
-- wpcmc='wp core multisite-convert'
-- wpcmi='wp core multisite-install'
-- wpcu='wp core update'
-- wpcudb='wp core update-db'
-- wpcvc='wp core verify-checksums'
-
-### Cron
-- wpcre='wp cron event'
-- wpcrs='wp cron schedule'
-- wpcrt='wp cron test'
+The [WordPress CLI](https://wp-cli.org/) is a command-line tool for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
-### Menu
-- wpmc='wp menu create'
-- wpmd='wp menu delete'
-- wpmi='wp menu item'
-- wpml='wp menu list'
-- wpmlo='wp menu location'
+This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases for commonly used commands.
-### Plugin
-- wppa='activate'
-- wppda='deactivate'
-- wppd='delete'
-- wppg='get'
-- wppi='install'
-- wppis='is-installed'
-- wppl='list'
-- wppp='path'
-- wpps='search'
-- wppst='status'
-- wppt='toggle'
-- wppun='uninstall'
-- wppu='update'
+To use it, add `wp-cli` to the plugins array in your zshrc file:
-### Post
-- wppoc='wp post create'
-- wppod='wp post delete'
-- wppoe='wp post edit'
-- wppogen='wp post generate'
-- wppog='wp post get'
-- wppol='wp post list'
-- wppom='wp post meta'
-- wppou='wp post update'
-- wppourl='wp post url'
+```zsh
+plugins=(... wp-cli)
+```
-### Sidebar
-- wpsbl='wp sidebar list'
-
-### Theme
-- wpta='wp theme activate'
-- wptd='wp theme delete'
-- wptdis='wp theme disable'
-- wpte='wp theme enable'
-- wptg='wp theme get'
-- wpti='wp theme install'
-- wptis='wp theme is-installed'
-- wptl='wp theme list'
-- wptm='wp theme mod'
-- wptp='wp theme path'
-- wpts='wp theme search'
-- wptst='wp theme status'
-- wptu='wp theme update'
-
-### User
-- wpuac='wp user add-cap'
-- wpuar='wp user add-role'
-- wpuc='wp user create'
-- wpud='wp user delete'
-- wpugen='wp user generate'
-- wpug='wp user get'
-- wpui='wp user import-csv'
-- wpul='wp user list'
-- wpulc='wp user list-caps'
-- wpum='wp user meta'
-- wpurc='wp user remove-cap'
-- wpurr='wp user remove-role'
-- wpusr='wp user set-role'
-- wpuu='wp user update'
-
-### Widget
-- wpwa='wp widget add'
-- wpwda='wp widget deactivate'
-- wpwd='wp widget delete'
-- wpwl='wp widget list'
-- wpwm='wp widget move'
-- wpwu='wp widget update'
-
-The entire list of wp-cli commands can be found here: https://wp-cli.org/commands/
-
-I only included the commands that are most used. Please feel free to contribute to this project if you want more commands.
+**Maintainer:** [joshmedeski](https://github.com/joshmedeski)
+## Aliases
+
+The entire list of `wp-cli` commands can be found here: https://developer.wordpress.org/cli/commands/
+
+| Alias | Command |
+|-----------|-----------------------------|
+| **Core** |
+| `wpcc` | `wp core config` |
+| `wpcd` | `wp core download` |
+| `wpci` | `wp core install` |
+| `wpcii` | `wp core is-installed` |
+| `wpcmc` | `wp core multisite-convert` |
+| `wpcmi` | `wp core multisite-install` |
+| `wpcu` | `wp core update` |
+| `wpcudb` | `wp core update-db` |
+| `wpcvc` | `wp core verify-checksums` |
+| **Cron** |
+| `wpcre` | `wp cron event` |
+| `wpcrs` | `wp cron schedule` |
+| `wpcrt` | `wp cron test` |
+| **Database** |
+| `wpdbe` | `wp db export` |
+| `wpdbi` | `wp db import` |
+| `wpdbcr` | `wp db create` |
+| `wpdbs` | `wp db search` |
+| `wpdbch` | `wp db check` |
+| `wpdbr` | `wp db repair` |
+| **Menu** |
+| `wpmc` | `wp menu create` |
+| `wpmd` | `wp menu delete` |
+| `wpmi` | `wp menu item` |
+| `wpml` | `wp menu list` |
+| `wpmlo` | `wp menu location` |
+| **Plugin** |
+| `wppa` | `wp plugin activate` |
+| `wppda` | `wp plugin deactivate` |
+| `wppd` | `wp plugin delete` |
+| `wppg` | `wp plugin get` |
+| `wppi` | `wp plugin install` |
+| `wppis` | `wp plugin is-installed` |
+| `wppl` | `wp plugin list` |
+| `wppp` | `wp plugin path` |
+| `wpps` | `wp plugin search` |
+| `wppst` | `wp plugin status` |
+| `wppt` | `wp plugin toggle` |
+| `wppun` | `wp plugin uninstall` |
+| `wppu` | `wp plugin update` |
+| **Post** |
+| `wppoc` | `wp post create` |
+| `wppod` | `wp post delete` |
+| `wppoe` | `wp post edit` |
+| `wppogen` | `wp post generate` |
+| `wppog` | `wp post get` |
+| `wppol` | `wp post list` |
+| `wppom` | `wp post meta` |
+| `wppou` | `wp post update` |
+| `wppourl` | `wp post url` |
+| **Sidebar** |
+| `wpsbl` | `wp sidebar list` |
+| **Theme** |
+| `wpta` | `wp theme activate` |
+| `wptd` | `wp theme delete` |
+| `wptdis` | `wp theme disable` |
+| `wpte` | `wp theme enable` |
+| `wptg` | `wp theme get` |
+| `wpti` | `wp theme install` |
+| `wptis` | `wp theme is-installed` |
+| `wptl` | `wp theme list` |
+| `wptm` | `wp theme mod` |
+| `wptp` | `wp theme path` |
+| `wpts` | `wp theme search` |
+| `wptst` | `wp theme status` |
+| `wptu` | `wp theme update` |
+| **User** |
+| `wpuac` | `wp user add-cap` |
+| `wpuar` | `wp user add-role` |
+| `wpuc` | `wp user create` |
+| `wpud` | `wp user delete` |
+| `wpugen` | `wp user generate` |
+| `wpug` | `wp user get` |
+| `wpui` | `wp user import-csv` |
+| `wpul` | `wp user list` |
+| `wpulc` | `wp user list-caps` |
+| `wpum` | `wp user meta` |
+| `wpurc` | `wp user remove-cap` |
+| `wpurr` | `wp user remove-role` |
+| `wpusr` | `wp user set-role` |
+| `wpuu` | `wp user update` |
+| **Widget** |
+| `wpwa` | `wp widget add` |
+| `wpwda` | `wp widget deactivate` |
+| `wpwd` | `wp widget delete` |
+| `wpwl` | `wp widget list` |
+| `wpwm` | `wp widget move` |
+| `wpwu` | `wp widget update` |
diff --git a/plugins/wp-cli/wp-cli.plugin.zsh b/plugins/wp-cli/wp-cli.plugin.zsh
index 97bed406e..09bdf3260 100644
--- a/plugins/wp-cli/wp-cli.plugin.zsh
+++ b/plugins/wp-cli/wp-cli.plugin.zsh
@@ -2,14 +2,6 @@
# A command line interface for WordPress
# https://wp-cli.org/
-# Cache
-
-# Cap
-
-# CLI
-
-# Comment
-
# Core
alias wpcc='wp core config'
alias wpcd='wp core download'
@@ -27,18 +19,12 @@ alias wpcrs='wp cron schedule'
alias wpcrt='wp cron test'
# Db
-
-# Eval
-
-# Eval-File
-
-# Export
-
-# Help
-
-# Import
-
-# Media
+alias wpdbe='wp db export'
+alias wpdbi='wp db import'
+alias wpdbcr='wp db create'
+alias wpdbs='wp db search'
+alias wpdbch='wp db check'
+alias wpdbr='wp db repair'
# Menu
alias wpmc='wp menu create'
@@ -47,10 +33,6 @@ alias wpmi='wp menu item'
alias wpml='wp menu list'
alias wpmlo='wp menu location'
-# Network
-
-# Option
-
# Plugin
alias wppa='wp plugin activate'
alias wppda='wp plugin deactivate'
@@ -77,25 +59,9 @@ alias wppom='wp post meta'
alias wppou='wp post update'
alias wppourl='wp post url'
-# Rewrite
-
-# Role
-
-# Scaffold
-
-# Search-Replace
-
-# Shell
-
# Sidebar
alias wpsbl='wp sidebar list'
-# Site
-
-# Super-Admin
-
-# Term
-
# Theme
alias wpta='wp theme activate'
alias wptd='wp theme delete'
@@ -111,8 +77,6 @@ alias wpts='wp theme search'
alias wptst='wp theme status'
alias wptu='wp theme update'
-# Transient
-
# User
alias wpuac='wp user add-cap'
alias wpuar='wp user add-role'
@@ -138,9 +102,8 @@ alias wpwm='wp widget move'
alias wpwu='wp widget update'
+# Completion for wp
autoload -U +X bashcompinit && bashcompinit
-# bash completion for the `wp` command
-
_wp_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md
index 05f18a499..9a0d1708d 100644
--- a/plugins/yarn/README.md
+++ b/plugins/yarn/README.md
@@ -11,35 +11,37 @@ plugins=(... yarn)
## Aliases
-| Alias | Command | Description |
-|-------|-------------------------------------------|-------------------------------------------------------------|
-| y | `yarn` | The Yarn command |
-| ya | `yarn add` | Install a package in dependencies (`package.json`) |
-| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) |
-| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
-| yb | `yarn build` | Run the build script defined in `package.json` |
-| ycc | `yarn cache clean` | Clean yarn's global cache of packages |
-| yd | `yarn dev` | Run the dev script defined in `package.json` |
-| yga | `yarn global add` | Install packages globally on your operating system |
-| ygls | `yarn global list` | Lists global installed packages |
-| ygrm | `yarn global remove` | Remove global installed packages from your OS |
-| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version |
-| yh | `yarn help` | Show help for a yarn command |
-| yi | `yarn init` | Interactively creates or updates a package.json file |
-| yin | `yarn install` | Install dependencies defined in `package.json` |
-| yln | `yarn lint` | Run the lint script defined in `package.json` |
-| yls | `yarn list` | List installed packages |
-| yout | `yarn outdated` | Check for outdated package dependencies |
-| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
-| yrm | `yarn remove` | Remove installed packages |
-| yrun | `yarn run` | Run a defined package script |
-| ys | `yarn serve` | Start the dev server |
-| yst | `yarn start` | Run the start script defined in `package.json` |
-| yt | `yarn test` | Run the test script defined in `package.json` |
-| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage |
-| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache |
-| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
-| yup | `yarn upgrade` | Upgrade packages to their latest version |
-| yv | `yarn version` | Update the version of your package |
-| yw | `yarn workspace` | Run a command within a single workspace. |
-| yws | `yarn workspaces` | Run a command within all defined workspaces. |
+| Alias | Command | Description |
+| ----- | ----------------------------------------- | ----------------------------------------------------------------------------- |
+| y | `yarn` | The Yarn command |
+| ya | `yarn add` | Install a package in dependencies (`package.json`) |
+| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) |
+| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
+| yb | `yarn build` | Run the build script defined in `package.json` |
+| ycc | `yarn cache clean` | Clean yarn's global cache of packages |
+| yd | `yarn dev` | Run the dev script defined in `package.json` |
+| yga | `yarn global add` | Install packages globally on your operating system |
+| ygls | `yarn global list` | Lists global installed packages |
+| ygrm | `yarn global remove` | Remove global installed packages from your OS |
+| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version |
+| yh | `yarn help` | Show help for a yarn command |
+| yi | `yarn init` | Interactively creates or updates a package.json file |
+| yin | `yarn install` | Install dependencies defined in `package.json` |
+| yln | `yarn lint` | Run the lint script defined in `package.json` |
+| ylnf | `yarn lint --fix` | Run the lint script defined in `package.json`to automatically fix problems |
+| yls | `yarn list` | List installed packages |
+| yout | `yarn outdated` | Check for outdated package dependencies |
+| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
+| yrm | `yarn remove` | Remove installed packages |
+| yrun | `yarn run` | Run a defined package script |
+| ys | `yarn serve` | Start the dev server |
+| yst | `yarn start` | Run the start script defined in `package.json` |
+| yt | `yarn test` | Run the test script defined in `package.json` |
+| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage |
+| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache |
+| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
+| yuil | `yarn upgrade-interactive --latest` | Prompt for which outdated packages to upgrade to the latest available version |
+| yup | `yarn upgrade` | Upgrade packages to their latest version |
+| yv | `yarn version` | Update the version of your package |
+| yw | `yarn workspace` | Run a command within a single workspace. |
+| yws | `yarn workspaces` | Run a command within all defined workspaces. |
diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn
index 70e783b86..70ed55929 100644
--- a/plugins/yarn/_yarn
+++ b/plugins/yarn/_yarn
@@ -32,15 +32,21 @@
# -------
#
# * Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
+# * Shohei YOSHIDA <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
+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 agains yarn's lock file"
+ "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'
@@ -50,25 +56,30 @@ _commands=(
'install:Install all the dependencies listed within package.json'
'licenses:List licenses for installed packages'
'link:Symlink a package folder during development'
- 'list:List installed packages'
'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'
@@ -76,7 +87,12 @@ _global_commands=(
_yarn_commands_scripts() {
local -a scripts
- scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
+ if [[ -n $opt_args[--cwd] ]]; then
+ scripts=($(cd $opt_args[--cwd] && yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
+ else
+ scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
+ fi
+
_describe 'command or script' _commands -- _global_commands -- scripts
}
@@ -85,7 +101,11 @@ _yarn_scripts() {
local -a scriptNames scriptCommands
local i runJSON
- runJSON=$(yarn run --json 2>/dev/null)
+ if [[ -n $_yarn_run_cwd ]]; then
+ runJSON=$(cd $_yarn_run_cwd && yarn run --json 2>/dev/null)
+ else
+ runJSON=$(yarn run --json 2>/dev/null)
+ fi
# Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
# pattern as a newline. See https://superuser.com/q/307165
binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
@@ -96,7 +116,7 @@ _yarn_scripts() {
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
done
- commands=($scripts $binaries)
+ commands=('env' $scripts $binaries)
_describe 'command' commands
}
@@ -110,6 +130,17 @@ _yarn_commands() {
_describe 'command' _commands -- _global_commands
}
+_yarn_add_files() {
+ if compset -P "(file|link):"; then
+ _files
+ fi
+}
+
+_yarn_workspaces() {
+ local -a workspaces=(${(@f)$(yarn workspaces info |sed -n -e 's/^ "\([^"]*\)": {/\1/p')})
+ _describe 'workspace' workspaces
+}
+
_yarn() {
local context state state_descr line
typeset -A opt_args
@@ -118,37 +149,51 @@ _yarn() {
'(-h --help)'{-h,--help}'[output usage information]' \
'(-V --version)'{-V,--version}'[output the version number]' \
'--verbose[output verbose messages on internal operations]' \
- '--offline[trigger an error if any required dependencies are not available in local cache]' \
- '--prefer-offline[use network only if dependencies are not available in local cache]' \
- '--strict-semver' \
- '--json' \
- "--ignore-scripts[don't run lifecycle scripts]" \
- '--har[save HAR output of network traffic]' \
- '--ignore-platform[ignore platform checks]' \
- '--ignore-engines[ignore engines check]' \
- '--ignore-optional[ignore optional dependencies]' \
- '--force[install and build packages even if they were built before, overwrite lockfile]' \
- '--skip-integrity-check[run install without checking if node_modules is installed]' \
+ '--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
'--check-files[install will verify file tree of packages for consistency]' \
- "--no-bin-links[don't generate bin links when setting up packages]" \
+ '--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]' \
- '(--prod --production)'{--prod,--production} \
- "--no-lockfile[don't read or generate a lockfile]" \
- "--pure-lockfile[don't generate a lockfile]" \
+ '--focus[Focus on a single workspace by installing remote copies of its sibiling 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]" \
- '--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
'--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 -/' \
- '--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
'--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \
- '--no-emoji[disable emoji in output]' \
- '(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
- '--proxy=:host:_hosts' \
- '--https-proxy=:host:_hosts' \
- '--no-progress[disable progress bar]' \
'--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'
@@ -173,18 +218,29 @@ _yarn() {
'(-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]' \
- '*:package-name:'
+ '(--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: :(ls dir clean)'
+ '1: :(list dir clean)' \
+ '*:: :->cache_args'
;;
check)
_arguments \
- '--integrity' \
- '--verify-tree'
+ '--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)
@@ -223,12 +279,13 @@ _yarn() {
list)
_arguments \
- '--depth[Limit the depth of the shown dependencies]:depth'
+ '--depth=[Limit the depth of the shown dependencies]:depth' \
+ '--pattern=[filter the list of dependencies by the pattern]'
;;
owner)
_arguments \
- '1: :(ls add rm)' \
+ '1: :(list add rm)' \
'*:: :->owner_args'
;;
@@ -247,12 +304,22 @@ _yarn() {
'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'
@@ -260,26 +327,33 @@ _yarn() {
tag)
_arguments \
- '1: :(ls add rm)' \
+ '1: :(lists add rm)' \
'*:: :->tag_args'
;;
team)
_arguments \
- '1: :(create destroy add rm ls)' \
+ '1: :(create destroy add rm list)' \
'*:: :->team_args'
;;
upgrade-interactive)
_arguments \
- '--latest:use the version tagged latest in the registry:'
+ '--latest[use the version tagged latest in the registry]'
;;
version)
_arguments \
- '--new-version:version:' \
- '--message:message:' \
- '--no-git-tag-version'
+ '--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)
@@ -287,7 +361,19 @@ _yarn() {
'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
@@ -295,6 +381,12 @@ _yarn() {
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)
@@ -310,6 +402,10 @@ _yarn() {
;;
esac
;;
+ groups_args)
+ local dependency_groups=(devDependencies dependencies optionalDependencies peerDependencies bundledDependencies)
+ _values -s ',' 'groups' $dependency_groups
+ ;;
owner_args)
case $words[1] in
diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
index 9cfcb7539..a4f595c61 100644
--- a/plugins/yarn/yarn.plugin.zsh
+++ b/plugins/yarn/yarn.plugin.zsh
@@ -1,3 +1,10 @@
+# Add yarn bin directory to $PATH if it exists and not in $PATH already
+bindir=$(yarn global bin 2>/dev/null) \
+ && [[ -d "$bindir" ]] \
+ && (( ! ${path[(Ie)$bindir]} )) \
+ && path+=("$bindir")
+unset bindir
+
alias y="yarn"
alias ya="yarn add"
alias yad="yarn add --dev"
@@ -13,6 +20,7 @@ alias yh="yarn help"
alias yi="yarn init"
alias yin="yarn install"
alias yln="yarn lint"
+alias ylnf="yarn lint --fix"
alias yls="yarn list"
alias yout="yarn outdated"
alias yp="yarn pack"
@@ -24,6 +32,7 @@ alias yt="yarn test"
alias ytc="yarn test --coverage"
alias yuc="yarn global upgrade && yarn cache clean"
alias yui="yarn upgrade-interactive"
+alias yuil="yarn upgrade-interactive --latest"
alias yup="yarn upgrade"
alias yv="yarn version"
alias yw="yarn workspace"
diff --git a/plugins/z/README b/plugins/z/README
index 56261cff4..47e54c57a 100644
--- a/plugins/z/README
+++ b/plugins/z/README
@@ -23,6 +23,8 @@ DESCRIPTION
OPTIONS
-c restrict matches to subdirectories of the current directory
+ -e echo the best match, don't cd
+
-h show a brief help message
-l list only
@@ -57,6 +59,8 @@ NOTES
Optionally:
Set $_Z_CMD to change the command name (default z).
Set $_Z_DATA to change the datafile (default $HOME/.z).
+ Set $_Z_MAX_SCORE lower to age entries out faster (default
+ 9000).
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
self.
@@ -64,8 +68,8 @@ NOTES
Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
(These settings should go in .bashrc/.zshrc before the line
added above.)
- Install the provided man page z.1 somewhere like
- /usr/local/man/man1.
+ Install the provided man page z.1 somewhere in your MANPATH,
+ like /usr/local/man/man1.
Aging:
The rank of directories maintained by z undergoes aging based on a sim-
diff --git a/plugins/z/z.1 b/plugins/z/z.1
index d4cac1ac2..182f98176 100644
--- a/plugins/z/z.1
+++ b/plugins/z/z.1
@@ -78,6 +78,9 @@ Set \fB$_Z_CMD\fR to change the command name (default \fBz\fR).
Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR).
.RE
.RS
+Set \fB$_Z_MAX_SCORE\fR lower to age entries out faster (default \fB9000\fR).
+.RE
+.RS
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
.RE
.RS
diff --git a/plugins/z/z.sh b/plugins/z/z.sh
index 5c5771d62..67f504e27 100644
--- a/plugins/z/z.sh
+++ b/plugins/z/z.sh
@@ -10,6 +10,7 @@
# * optionally:
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
+# set $_Z_MAX_SCORE lower to age entries out faster (default 9000).
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
@@ -23,6 +24,8 @@
# * z -l foo # list matches instead of cd
# * z -e foo # echo the best match, don't cd
# * z -c foo # restrict matches to subdirs of $PWD
+# * z -x # remove the current directory from the datafile
+# * z -h # show a brief help message
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
@@ -39,6 +42,8 @@ _z() {
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
_z_dirs () {
+ [ -f "$datafile" ] || return
+
local line
while read line; do
# only count directories
@@ -51,18 +56,21 @@ _z() {
if [ "$1" = "--add" ]; then
shift
- # $HOME isn't worth matching
- [ "$*" = "$HOME" ] && return
+ # $HOME and / aren't worth matching
+ [ "$*" = "$HOME" -o "$*" = '/' ] && return
# don't track excluded directory trees
- local exclude
- for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
- case "$*" in "$exclude*") return;; esac
- done
+ if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then
+ local exclude
+ for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
+ case "$*" in "$exclude"*) return;; esac
+ done
+ fi
# maintain the data file
local tempfile="$datafile.$RANDOM"
- _z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
+ local score=${_Z_MAX_SCORE:-9000}
+ _z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" '
BEGIN {
rank[path] = 1
time[path] = now
@@ -79,7 +87,7 @@ _z() {
count += $2
}
END {
- if( count > 9000 ) {
+ if( count > score ) {
# aging
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
} else for( x in rank ) print x "|" rank[x] "|" time[x]
@@ -138,27 +146,24 @@ _z() {
local cd
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) {
- # relate frequency and time
- dx = t - time
- if( dx < 3600 ) return rank * 4
- if( dx < 86400 ) return rank * 2
- if( dx < 604800 ) return rank / 2
- return rank / 4
+ # relate frequency and time
+ dx = t - time
+ return int(10000 * rank * (3.75/((0.0001 * dx + 1) + 0.25)))
}
function output(matches, best_match, common) {
# list or return the desired directory
if( list ) {
- cmd = "sort -g >&2"
+ if( common ) {
+ printf "%-10s %s\n", "common:", common > "/dev/stderr"
+ }
+ cmd = "sort -n >&2"
for( x in matches ) {
if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
}
- if( common ) {
- printf "%-10s %s\n", "common:", common > "/dev/stderr"
- }
} else {
- if( common ) best_match = common
+ if( common && !typ ) best_match = common
print best_match
}
}
@@ -200,15 +205,22 @@ _z() {
# prefer case sensitive
if( best_match ) {
output(matches, best_match, common(matches))
+ exit
} else if( ibest_match ) {
output(imatches, ibest_match, common(imatches))
+ exit
}
+ exit(1)
}
')"
- [ $? -eq 0 ] && [ "$cd" ] && {
- if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
- }
+ if [ "$?" -eq 0 ]; then
+ if [ "$cd" ]; then
+ if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
+ fi
+ else
+ return $?
+ fi
fi
}
@@ -223,15 +235,11 @@ if type compctl >/dev/null 2>&1; then
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() {
(_z --add "${PWD:a}" &)
- # Reference $RANDOM to refresh its value inside the subshell
- # Otherwise, multiple runs get the same value
: $RANDOM
}
else
_z_precmd() {
(_z --add "${PWD:A}" &)
- # Reference $RANDOM to refresh its value inside the subshell
- # Otherwise, multiple runs get the same value
: $RANDOM
}
fi
diff --git a/plugins/zbell/README.md b/plugins/zbell/README.md
new file mode 100644
index 000000000..1c1c13546
--- /dev/null
+++ b/plugins/zbell/README.md
@@ -0,0 +1,30 @@
+# zbell plugin
+
+This plugin prints a bell character when a command finishes if it has been
+running for longer than a specified duration.
+
+To use it, add `zbell` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... zbell)
+```
+
+## Settings
+
+These settings need to be set in your zshrc file, before Oh My Zsh is sourced.
+
+- `zbell_duration`: duration in seconds after which to consider notifying
+ the end of a command. Default: 15 seconds.
+
+- `zbell_ignore`: if there are programs that you know run long that you
+ don't want to bell after, then add them to the `zbell_ignore` array.
+ By default, `$EDITOR` and `$PAGER` are ignored:
+
+ ```zsh
+ zbell_ignore=($EDITOR $PAGER)
+ ```
+
+## Author
+
+Adapted from an original version by [Jean-Philippe Ouellet](https://github.com/jpouellet).
+Made available under the ISC license.
diff --git a/plugins/zbell/zbell.plugin.zsh b/plugins/zbell/zbell.plugin.zsh
new file mode 100644
index 000000000..6d0416502
--- /dev/null
+++ b/plugins/zbell/zbell.plugin.zsh
@@ -0,0 +1,83 @@
+#!/usr/bin/env zsh
+
+# This script prints a bell character when a command finishes
+# if it has been running for longer than $zbell_duration seconds.
+# If there are programs that you know run long that you don't
+# want to bell after, then add them to $zbell_ignore.
+#
+# This script uses only zsh builtins so its fast, there's no needless
+# forking, and its only dependency is zsh and its standard modules
+#
+# Written by Jean-Philippe Ouellet <jpo@vt.edu>
+# Made available under the ISC license.
+
+# only do this if we're in an interactive shell
+[[ -o interactive ]] || return
+
+# get $EPOCHSECONDS. builtins are faster than date(1)
+zmodload zsh/datetime || return
+
+# make sure we can register hooks
+autoload -Uz add-zsh-hook || return
+
+# make sure we can do regexp replace
+autoload -Uz regexp-replace || return
+
+# initialize zbell_duration if not set
+(( ${+zbell_duration} )) || zbell_duration=15
+
+# initialize zbell_ignore if not set
+(( ${+zbell_ignore} )) || zbell_ignore=($EDITOR $PAGER)
+
+# initialize it because otherwise we compare a date and an empty string
+# the first time we see the prompt. it's fine to have lastcmd empty on the
+# initial run because it evaluates to an empty string, and splitting an
+# empty string just results in an empty array.
+zbell_timestamp=$EPOCHSECONDS
+
+# default notification function
+# $1: command
+# $2: duration in seconds
+zbell_notify() {
+ type notify-send > /dev/null && \
+ notify-send -i terminal "Command completed in ${2}s:" $1
+ print -n "\a"
+}
+
+# right before we begin to execute something, store the time it started at
+zbell_begin() {
+ zbell_timestamp=$EPOCHSECONDS
+ zbell_lastcmd=$1
+}
+
+# when it finishes, if it's been running longer than $zbell_duration,
+# and we dont have an ignored command in the line, then print a bell.
+zbell_end() {
+ local cmd_duration=$(( $EPOCHSECONDS - $zbell_timestamp ))
+ local ran_long=$(( $cmd_duration >= $zbell_duration ))
+
+ local zbell_lastcmd_tmp="$zbell_lastcmd"
+ regexp-replace zbell_lastcmd_tmp '^sudo ' ''
+
+ [[ $zbell_last_timestamp == $zbell_timestamp ]] && return
+
+ [[ $zbell_lastcmd_tmp == "" ]] && return
+
+ zbell_last_timestamp=$zbell_timestamp
+
+ local has_ignored_cmd=0
+ for cmd in ${(s:;:)zbell_lastcmd_tmp//|/;}; do
+ words=(${(z)cmd})
+ util=${words[1]}
+ if (( ${zbell_ignore[(i)$util]} <= ${#zbell_ignore} )); then
+ has_ignored_cmd=1
+ break
+ fi
+ done
+
+ (( ! $has_ignored_cmd && ran_long )) && zbell_notify $zbell_lastcmd $cmd_duration
+}
+
+# register the functions as hooks
+add-zsh-hook preexec zbell_begin
+add-zsh-hook precmd zbell_end
diff --git a/plugins/zoxide/README.md b/plugins/zoxide/README.md
new file mode 100644
index 000000000..f326effe6
--- /dev/null
+++ b/plugins/zoxide/README.md
@@ -0,0 +1,14 @@
+# zoxide plugin
+
+Initializes [zoxide](https://github.com/ajeetdsouza/zoxide), a smarter cd
+command for your terminal.
+
+![Tutorial](https://raw.githubusercontent.com/ajeetdsouza/zoxide/97dc08347d9dbf5b5a4516b79e0ac27366b962ce/contrib/tutorial.webp)
+
+To use it, add `zoxide` to the plugins array in your `.zshrc` file:
+
+```zsh
+plugins=(... zoxide)
+```
+
+**Note:** you have to [install zoxide](https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide) first.
diff --git a/plugins/zoxide/zoxide.plugin.zsh b/plugins/zoxide/zoxide.plugin.zsh
new file mode 100644
index 000000000..e5658b8f0
--- /dev/null
+++ b/plugins/zoxide/zoxide.plugin.zsh
@@ -0,0 +1,5 @@
+if (( $+commands[zoxide] )); then
+ eval "$(zoxide init zsh)"
+else
+ echo '[oh-my-zsh] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide'
+fi
diff --git a/plugins/zsh_reload/README.md b/plugins/zsh_reload/README.md
index d31a827fe..0b2e2a775 100644
--- a/plugins/zsh_reload/README.md
+++ b/plugins/zsh_reload/README.md
@@ -1,23 +1,3 @@
# zsh_reload plugin
-The zsh_reload plugin defines a function to reload the zsh session with
-just a few keystrokes.
-
-To use it, add `zsh_reload` to the plugins array in your zshrc file:
-
-```zsh
-plugins=(... zsh_reload)
-```
-
-## Usage
-
-To reload the zsh session, just run `src`:
-
-```zsh
-$ vim ~/.zshrc # enabled a plugin
-$ src
-re-compiling /home/user/.zshrc.zwc: succeeded
-re-compiling /home/user/.oh-my-zsh/cache/zcomp-host.zwc: succeeded
-
-# you now have a fresh zsh session. happy hacking!
-```
+**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead.
diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
index 83f8da733..6a058ec5e 100644
--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
+++ b/plugins/zsh_reload/zsh_reload.plugin.zsh
@@ -1,12 +1,7 @@
-src() {
- local cache="$ZSH_CACHE_DIR"
- autoload -U compinit zrecompile
- compinit -i -d "$cache/zcomp-$HOST"
-
- for f in ${ZDOTDIR:-~}/.zshrc "$cache/zcomp-$HOST"; do
- zrecompile -p $f && command rm -f $f.zwc.old
- done
+print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."}
+print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"}
- # Use $SHELL if available; remove leading dash if login shell
- [[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
+src() {
+ print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"}
+ omz reload
}