summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig8
-rw-r--r--.github/CODEOWNERS9
-rw-r--r--.github/FUNDING.yml2
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md46
-rw-r--r--.github/ISSUE_TEMPLATE/config.yml8
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md29
-rw-r--r--.github/PULL_REQUEST_TEMPLATE.md19
-rw-r--r--.github/workflows/main.yml36
-rw-r--r--.gitignore4
-rw-r--r--.gitpod.Dockerfile5
-rw-r--r--.gitpod.yml9
-rw-r--r--CODE_OF_CONDUCT.md76
-rw-r--r--CONTRIBUTING.md133
-rw-r--r--LICENSE.txt5
-rw-r--r--README.md147
-rw-r--r--lib/cli.zsh426
-rw-r--r--lib/clipboard.zsh125
-rw-r--r--lib/compfix.zsh2
-rw-r--r--lib/completion.zsh22
-rw-r--r--lib/diagnostics.zsh10
-rw-r--r--lib/directories.zsh10
-rw-r--r--lib/functions.zsh47
-rw-r--r--lib/git.zsh253
-rw-r--r--lib/grep.zsh57
-rw-r--r--lib/history.zsh12
-rw-r--r--lib/key-bindings.zsh107
-rw-r--r--lib/misc.zsh34
-rw-r--r--lib/nvm.zsh9
-rw-r--r--lib/prompt_info_functions.zsh20
-rw-r--r--lib/spectrum.zsh26
-rw-r--r--lib/termsupport.zsh88
-rw-r--r--lib/theme-and-appearance.zsh12
-rw-r--r--oh-my-zsh.sh93
-rw-r--r--plugins/adb/_adb9
-rw-r--r--plugins/alias-finder/README.md46
-rw-r--r--plugins/alias-finder/alias-finder.plugin.zsh47
-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/README.md34
-rw-r--r--plugins/ansible/ansible.plugin.zsh28
-rw-r--r--plugins/apache2-macports/README.md26
-rw-r--r--plugins/arcanist/README.md40
-rw-r--r--plugins/arcanist/arcanist.plugin.zsh18
-rw-r--r--plugins/archlinux/README.md314
-rw-r--r--plugins/archlinux/archlinux.plugin.zsh306
-rw-r--r--plugins/asdf/asdf.plugin.zsh8
-rw-r--r--plugins/autoenv/README.md20
-rw-r--r--plugins/autoenv/autoenv.plugin.zsh60
-rw-r--r--plugins/autojump/README.md2
-rw-r--r--plugins/autojump/autojump.plugin.zsh53
-rw-r--r--plugins/aws/README.md67
-rw-r--r--plugins/aws/aws.plugin.zsh227
-rw-r--r--plugins/battery/README.md11
-rw-r--r--plugins/battery/battery.plugin.zsh182
-rw-r--r--plugins/bazel/README.md5
-rw-r--r--plugins/bazel/_bazel341
-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/README.md3
-rw-r--r--plugins/bower/bower.plugin.zsh2
-rw-r--r--plugins/brew/README.md29
-rw-r--r--plugins/brew/brew.plugin.zsh19
-rw-r--r--plugins/bundler/README.md78
-rw-r--r--plugins/bundler/bundler.plugin.zsh117
-rw-r--r--plugins/bwana/README.md9
-rw-r--r--plugins/bwana/bwana.plugin.zsh13
-rw-r--r--plugins/cake/README.md15
-rw-r--r--plugins/cakephp3/README.md16
-rw-r--r--plugins/cargo/README.md4
-rw-r--r--plugins/cargo/_cargo809
-rw-r--r--plugins/catimg/README.md24
-rw-r--r--plugins/catimg/catimg.plugin.zsh2
-rw-r--r--plugins/catimg/catimg.sh2
-rw-r--r--plugins/chruby/README.md20
-rw-r--r--plugins/chucknorris/README.md28
-rw-r--r--plugins/chucknorris/fortunes/chucknorris2456
-rw-r--r--plugins/cloudapp/README.md26
-rw-r--r--plugins/cloudapp/cloudapp.plugin.zsh6
-rwxr-xr-xplugins/cloudapp/cloudapp.rb60
-rw-r--r--plugins/codeclimate/README.md8
-rw-r--r--plugins/coffee/README.md2
-rw-r--r--plugins/colemak/README.md48
-rw-r--r--plugins/colored-man-pages/README.md32
-rw-r--r--plugins/colored-man-pages/colored-man-pages.plugin.zsh78
-rwxr-xr-xplugins/colored-man-pages/nroff12
-rw-r--r--plugins/colorize/README.md50
-rw-r--r--plugins/colorize/colorize.plugin.zsh116
-rw-r--r--plugins/command-not-found/README.md2
-rw-r--r--plugins/command-not-found/command-not-found.plugin.zsh89
-rw-r--r--plugins/common-aliases/README.md123
-rw-r--r--plugins/common-aliases/common-aliases.plugin.zsh11
-rw-r--r--plugins/compleat/README.md9
-rw-r--r--plugins/composer/README.md32
-rw-r--r--plugins/composer/composer.plugin.zsh42
-rw-r--r--plugins/copybuffer/copybuffer.plugin.zsh4
-rw-r--r--plugins/copyfile/README.md3
-rw-r--r--plugins/cpanm/README.md6
-rw-r--r--plugins/dash/README.md28
-rw-r--r--plugins/dash/dash.plugin.zsh52
-rw-r--r--plugins/debian/README.md85
-rw-r--r--plugins/debian/debian.plugin.zsh118
-rw-r--r--plugins/deno/.gitignore1
-rw-r--r--plugins/deno/README.md18
-rw-r--r--plugins/deno/deno.plugin.zsh23
-rw-r--r--plugins/dircycle/README.md4
-rw-r--r--plugins/direnv/README.md15
-rw-r--r--plugins/direnv/direnv.plugin.zsh16
-rw-r--r--plugins/dirhistory/README.md22
-rw-r--r--plugins/dirhistory/dirhistory.plugin.zsh44
-rw-r--r--plugins/dirpersist/README.md3
-rw-r--r--plugins/dirpersist/dirpersist.plugin.zsh3
-rw-r--r--plugins/django/README.md20
-rw-r--r--plugins/django/django.plugin.zsh5
-rw-r--r--plugins/dnf/README.md14
-rw-r--r--plugins/dnote/README.md51
-rw-r--r--plugins/dnote/_dnote39
-rw-r--r--plugins/docker-compose/README.md39
-rw-r--r--plugins/docker-compose/_docker-compose168
-rw-r--r--plugins/docker-compose/docker-compose.plugin.zsh2
-rw-r--r--plugins/docker/README.md37
-rw-r--r--plugins/docker/_docker41
-rw-r--r--plugins/dotenv/README.md53
-rw-r--r--plugins/dotenv/dotenv.plugin.zsh55
-rw-r--r--plugins/dotnet/README.md23
-rw-r--r--plugins/dotnet/dotnet.plugin.zsh32
-rw-r--r--plugins/drush/README.md83
-rw-r--r--plugins/drush/drush.complete.sh50
-rw-r--r--plugins/drush/drush.plugin.zsh104
-rw-r--r--plugins/eecms/README.md11
-rw-r--r--plugins/emacs/emacs.plugin.zsh10
-rwxr-xr-xplugins/emacs/emacsclient.sh3
-rw-r--r--plugins/emoji-clock/emoji-clock.plugin.zsh2
-rw-r--r--plugins/emotty/README.md39
-rw-r--r--plugins/emotty/emotty.plugin.zsh10
-rw-r--r--plugins/encode64/README.md27
-rw-r--r--plugins/extract/README.md12
-rw-r--r--plugins/extract/_extract2
-rw-r--r--plugins/extract/extract.plugin.zsh15
-rw-r--r--plugins/fabric/README.md2
-rw-r--r--plugins/fabric/_fab (renamed from plugins/fabric/_fabric)19
-rw-r--r--plugins/fabric/fabric.plugin.zsh0
-rw-r--r--plugins/fancy-ctrl-z/README.md6
-rw-r--r--plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh6
-rw-r--r--plugins/fasd/README.md21
-rw-r--r--plugins/fasd/fasd.plugin.zsh24
-rw-r--r--plugins/fastfile/README.md84
-rw-r--r--plugins/fastfile/fastfile.plugin.zsh41
-rw-r--r--plugins/fbterm/README.md10
-rw-r--r--plugins/fd/README.md13
-rw-r--r--plugins/fd/_fd83
-rw-r--r--plugins/fedora/README.md2
-rw-r--r--[l---------]plugins/fedora/fedora.plugin.zsh4
-rw-r--r--plugins/firewalld/README.md (renamed from plugins/firewalld/readme.md)0
-rw-r--r--plugins/flutter/README.md21
-rw-r--r--plugins/flutter/_flutter37
-rw-r--r--plugins/flutter/flutter.plugin.zsh7
-rw-r--r--plugins/forklift/README.md18
-rw-r--r--plugins/forklift/forklift.plugin.zsh19
-rw-r--r--plugins/fossil/fossil.plugin.zsh4
-rw-r--r--plugins/frontend-search/README.md80
-rw-r--r--plugins/frontend-search/_frontend-search.sh65
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh59
-rw-r--r--plugins/fzf/README.md53
-rw-r--r--plugins/fzf/fzf.plugin.zsh227
-rw-r--r--plugins/gas/README.md10
-rw-r--r--plugins/gatsby/README.md7
-rw-r--r--plugins/gatsby/_gatsby24
-rw-r--r--plugins/gcloud/README.md24
-rw-r--r--plugins/gcloud/gcloud.plugin.zsh33
-rw-r--r--plugins/geeknote/README.md16
-rw-r--r--plugins/geeknote/_geeknote267
-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/.gitignore1
-rw-r--r--plugins/gh/README.md23
-rw-r--r--plugins/gh/gh.plugin.zsh13
-rw-r--r--plugins/git-auto-fetch/README.md43
-rw-r--r--plugins/git-auto-fetch/git-auto-fetch.plugin.zsh70
-rw-r--r--plugins/git-escape-magic/README.md16
-rw-r--r--plugins/git-escape-magic/git-escape-magic135
-rw-r--r--plugins/git-escape-magic/git-escape-magic.plugin.zsh9
-rw-r--r--plugins/git-extras/README.md10
-rw-r--r--plugins/git-extras/git-extras.plugin.zsh4
-rw-r--r--plugins/git-flow/README.md13
-rw-r--r--plugins/git-flow/git-flow.plugin.zsh1
-rw-r--r--plugins/git-hubflow/git-hubflow.plugin.zsh12
-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.md66
-rw-r--r--plugins/git-prompt/git-prompt.plugin.zsh22
-rw-r--r--plugins/git-prompt/gitstatus.py42
-rw-r--r--plugins/git-remote-branch/git-remote-branch.plugin.zsh19
-rw-r--r--plugins/git/README.md238
-rw-r--r--plugins/git/git.plugin.zsh145
-rw-r--r--plugins/gitfast/README.md131
-rw-r--r--plugins/gitfast/_git199
-rw-r--r--plugins/gitfast/git-completion.bash2907
-rw-r--r--plugins/gitfast/git-prompt.sh88
-rw-r--r--plugins/gitfast/gitfast.plugin.zsh4
-rwxr-xr-xplugins/gitfast/update8
-rw-r--r--plugins/github/README.md10
-rw-r--r--plugins/github/_hub11
-rw-r--r--plugins/gitignore/gitignore.plugin.zsh2
-rw-r--r--plugins/glassfish/README.md9
-rw-r--r--plugins/glassfish/glassfish.plugin.zsh3
-rw-r--r--plugins/globalias/README.md19
-rw-r--r--plugins/globalias/globalias.plugin.zsh10
-rw-r--r--plugins/gnu-utils/README.md38
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh130
-rw-r--r--plugins/go/README.md2
-rw-r--r--[l---------]plugins/go/go.plugin.zsh4
-rw-r--r--plugins/golang/README.md1
-rw-r--r--plugins/golang/golang.plugin.zsh82
-rw-r--r--plugins/gpg-agent/README.md3
-rw-r--r--plugins/gradle/README.md13
-rw-r--r--[l---------]plugins/gradle/_gradle421
l---------plugins/gradle/_gradlew1
-rw-r--r--plugins/gradle/gradle.plugin.zsh201
-rw-r--r--plugins/grails/README.md55
-rw-r--r--plugins/grc/README.md15
-rw-r--r--plugins/grc/grc.plugin.zsh17
-rw-r--r--plugins/gulp/gulp.plugin.zsh6
-rw-r--r--plugins/hanami/README.md63
-rw-r--r--plugins/hanami/hanami.plugin.zsh6
-rw-r--r--plugins/history-substring-search/README.md175
-rw-r--r--plugins/history-substring-search/history-substring-search.plugin.zsh17
-rw-r--r--plugins/history-substring-search/history-substring-search.zsh510
-rw-r--r--plugins/history/README.md20
-rw-r--r--plugins/history/history.plugin.zsh9
-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/hitokoto/README.md15
-rw-r--r--plugins/hitokoto/hitokoto.plugin.zsh14
-rw-r--r--plugins/homestead/homestead.plugin.zsh2
-rw-r--r--plugins/httpie/README.md22
-rw-r--r--plugins/httpie/_httpie181
-rw-r--r--plugins/httpie/httpie.plugin.zsh38
-rw-r--r--plugins/ionic/README.md30
-rw-r--r--plugins/ionic/ionic.plugin.zsh15
-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/iwhois/README.md24
-rw-r--r--plugins/iwhois/iwhois.plugin.zsh5
-rw-r--r--plugins/jake-node/jake-node.plugin.zsh2
-rw-r--r--plugins/jenv/jenv.plugin.zsh4
-rw-r--r--plugins/jfrog/README.md11
-rw-r--r--plugins/jfrog/jfrog.plugin.zsh10
-rw-r--r--plugins/jhbuild/README.md34
-rw-r--r--plugins/jhbuild/jhbuild.plugin.zsh16
-rw-r--r--plugins/jira/README.md5
-rw-r--r--plugins/jira/_jira1
-rw-r--r--plugins/jira/jira.plugin.zsh36
-rw-r--r--plugins/jruby/README.md21
-rw-r--r--plugins/jsontools/README.md38
-rw-r--r--plugins/jsontools/jsontools.plugin.zsh13
-rw-r--r--plugins/jump/README.md12
-rw-r--r--plugins/jump/jump.plugin.zsh38
-rw-r--r--plugins/keychain/README.md45
-rw-r--r--plugins/keychain/keychain.plugin.zsh32
-rw-r--r--plugins/kitchen/_kitchen2
-rw-r--r--plugins/knife/README.md25
-rw-r--r--plugins/knife/_knife226
-rw-r--r--plugins/knife_ssh/README.md14
-rw-r--r--plugins/knife_ssh/knife_ssh.plugin.zsh8
-rw-r--r--plugins/kube-ps1/README.md233
-rw-r--r--plugins/kube-ps1/kube-ps1.plugin.zsh314
-rw-r--r--plugins/kubectl/README.md44
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh74
-rw-r--r--plugins/lando/LICENSE21
-rw-r--r--plugins/lando/README.md37
-rw-r--r--plugins/lando/lando.plugin.zsh40
-rw-r--r--plugins/laravel/README.md62
-rw-r--r--plugins/laravel/laravel.plugin.zsh38
-rw-r--r--plugins/laravel4/README.md12
-rw-r--r--plugins/laravel5/laravel5.plugin.zsh19
-rw-r--r--plugins/last-working-dir/README.md32
-rw-r--r--plugins/last-working-dir/last-working-dir.plugin.zsh17
-rw-r--r--plugins/lein/README.md9
-rw-r--r--plugins/lighthouse/README.md29
-rw-r--r--plugins/lighthouse/lighthouse.plugin.zsh14
-rw-r--r--plugins/lol/README.md104
-rw-r--r--plugins/lol/lol.plugin.zsh2
-rw-r--r--plugins/lxd/README.md9
-rw-r--r--plugins/lxd/lxd.plugin.zsh26
-rw-r--r--plugins/macports/_port3
-rw-r--r--plugins/magic-enter/README.md17
-rw-r--r--plugins/magic-enter/Readme.md14
-rw-r--r--plugins/magic-enter/magic-enter.plugin.zsh52
-rw-r--r--plugins/man/man.plugin.zsh26
-rw-r--r--plugins/mercurial/README.md96
-rw-r--r--plugins/mercurial/mercurial.plugin.zsh19
-rw-r--r--plugins/meteor/README.md5
-rw-r--r--plugins/microk8s/README.md24
-rw-r--r--plugins/microk8s/microk8s.plugin.zsh82
-rw-r--r--plugins/minikube/minikube.plugin.zsh11
-rw-r--r--plugins/mix-fast/mix-fast.plugin.zsh5
-rw-r--r--plugins/mix/_mix3
-rw-r--r--plugins/mongocli/README.md19
-rw-r--r--plugins/mongocli/mongocli.plugin.zsh4
-rw-r--r--plugins/mvn/README.md57
-rw-r--r--plugins/mvn/mvn.plugin.zsh559
-rw-r--r--plugins/mysql-macports/README.md20
-rw-r--r--plugins/n98-magerun/README.md21
-rw-r--r--plugins/n98-magerun/n98-magerun.plugin.zsh14
-rw-r--r--plugins/ng/README.md37
-rw-r--r--plugins/ng/ng.plugin.zsh5
-rw-r--r--plugins/nmap/README.md54
-rw-r--r--plugins/nmap/nmap.plugin.zsh2
-rw-r--r--plugins/node/README.md9
-rw-r--r--plugins/npm/README.md9
-rw-r--r--plugins/npm/npm.plugin.zsh34
-rw-r--r--plugins/npx/README.md28
-rw-r--r--plugins/nvm/README.md21
-rw-r--r--plugins/nvm/_nvm1
-rw-r--r--plugins/nvm/nvm.plugin.zsh80
-rw-r--r--plugins/nyan/README.md5
-rw-r--r--plugins/nyan/nyan.plugin.zsh10
-rw-r--r--plugins/oc/README.md13
-rw-r--r--plugins/osx/README.md51
-rw-r--r--plugins/osx/_security90
-rw-r--r--plugins/osx/music170
-rw-r--r--plugins/osx/osx.plugin.zsh246
-rw-r--r--plugins/osx/spotify80
-rw-r--r--plugins/otp/README.md22
-rw-r--r--plugins/otp/otp.plugin.zsh45
-rw-r--r--plugins/pass/README.md22
-rw-r--r--plugins/pass/_pass8
-rw-r--r--plugins/paver/README.md12
-rw-r--r--plugins/paver/paver.plugin.zsh6
-rw-r--r--plugins/per-directory-history/README.md71
-rw-r--r--plugins/per-directory-history/per-directory-history.zsh11
-rw-r--r--plugins/percol/README.md4
-rw-r--r--plugins/perl/README.md37
-rw-r--r--plugins/perms/README.md14
-rw-r--r--plugins/phing/README.md9
-rw-r--r--plugins/pip/README.md19
-rw-r--r--plugins/pip/_pip1
-rw-r--r--plugins/pip/pip.plugin.zsh11
-rw-r--r--plugins/pipenv/README.md28
-rw-r--r--plugins/pipenv/pipenv.plugin.zsh44
-rw-r--r--plugins/please/README.md26
-rw-r--r--plugins/please/please.plugin.zsh7
-rw-r--r--plugins/pod/README.md10
-rw-r--r--plugins/pow/README.md21
-rw-r--r--plugins/powder/README.md8
-rw-r--r--plugins/powify/README.md10
-rw-r--r--plugins/profiles/README.md25
-rw-r--r--plugins/pyenv/README.md16
-rw-r--r--plugins/pyenv/pyenv.plugin.zsh13
-rw-r--r--plugins/pylint/README.md7
-rw-r--r--plugins/pylint/pylint.plugin.zsh2
-rw-r--r--plugins/python/README.md2
-rw-r--r--plugins/python/python.plugin.zsh43
-rw-r--r--plugins/rails/README.md82
-rw-r--r--plugins/rails/rails.plugin.zsh12
-rw-r--r--plugins/rake-fast/rake-fast.plugin.zsh2
-rw-r--r--plugins/rake/README.md37
-rw-r--r--plugins/rbenv/README.md26
-rw-r--r--plugins/rbenv/rbenv.plugin.zsh90
-rw-r--r--plugins/rbfu/README.md17
-rw-r--r--plugins/react-native/README.md88
-rw-r--r--plugins/react-native/react-native.plugin.zsh56
-rw-r--r--plugins/rebar/README.md9
-rw-r--r--plugins/redis-cli/README.md15
-rw-r--r--plugins/repo/README.md28
-rw-r--r--plugins/repo/_repo2
-rw-r--r--plugins/repo/repo.plugin.zsh16
-rw-r--r--plugins/ripgrep/README.md13
-rw-r--r--plugins/ripgrep/_ripgrep612
-rw-r--r--plugins/ros/README.md10
-rw-r--r--plugins/ros/_ros64
-rw-r--r--plugins/rust/README.md9
-rw-r--r--plugins/rustup/README.md9
-rw-r--r--plugins/rustup/_rustup1143
-rw-r--r--plugins/rvm/README.md20
-rw-r--r--plugins/safe-paste/README.md9
-rw-r--r--plugins/safe-paste/safe-paste.plugin.zsh128
-rw-r--r--plugins/salt/_salt2
-rw-r--r--plugins/samtools/README.md5
-rw-r--r--plugins/samtools/_samtools40
-rw-r--r--plugins/sbt/README.md10
-rw-r--r--plugins/sbt/_sbt20
-rw-r--r--plugins/sbt/sbt.plugin.zsh10
-rw-r--r--plugins/scala/README.md13
-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/README.md10
-rw-r--r--plugins/screen/screen.plugin.zsh4
-rw-r--r--plugins/sdk/README.md14
-rw-r--r--plugins/sdk/sdk.plugin.zsh58
-rw-r--r--plugins/sfdx/README.md11
-rw-r--r--plugins/sfdx/_sfdx1110
-rw-r--r--plugins/sfffe/README.md17
-rw-r--r--plugins/sfffe/sfffe.plugin.zsh6
-rw-r--r--plugins/shell-proxy/README.md52
-rwxr-xr-xplugins/shell-proxy/proxy.py73
-rw-r--r--plugins/shell-proxy/shell-proxy.plugin.zsh16
-rwxr-xr-xplugins/shell-proxy/ssh-agent.py16
-rwxr-xr-xplugins/shell-proxy/ssh-proxy.py18
-rw-r--r--plugins/shrink-path/README.md88
-rw-r--r--plugins/shrink-path/shrink-path.plugin.zsh64
-rw-r--r--plugins/singlechar/README.md118
-rw-r--r--plugins/singlechar/singlechar.plugin.zsh12
-rw-r--r--plugins/sprunge/README.md32
-rw-r--r--plugins/sprunge/sprunge.plugin.zsh86
-rw-r--r--plugins/ssh-agent/README.md34
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh82
-rw-r--r--plugins/stack/stack.plugin.zsh39
-rw-r--r--plugins/sublime-merge/README.md17
-rw-r--r--plugins/sublime-merge/sublime-merge.plugin.zsh55
-rw-r--r--plugins/sublime/README.md38
-rw-r--r--plugins/sublime/sublime.plugin.zsh193
-rw-r--r--plugins/sudo/README.md22
-rw-r--r--plugins/sudo/sudo.plugin.zsh56
-rw-r--r--plugins/supervisor/README.md13
-rw-r--r--plugins/supervisor/_supervisorctl7
-rw-r--r--plugins/suse/README.md40
-rw-r--r--plugins/suse/suse.plugin.zsh40
-rw-r--r--plugins/svcat/README.md9
-rw-r--r--plugins/svcat/svcat.plugin.zsh6
-rw-r--r--plugins/svn-fast-info/README.md56
-rw-r--r--plugins/svn-fast-info/svn-fast-info.plugin.zsh77
-rw-r--r--plugins/swiftpm/README.md2
-rw-r--r--plugins/swiftpm/_swift225
-rw-r--r--plugins/systemadmin/README.md22
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh13
-rw-r--r--plugins/systemd/README.md41
-rw-r--r--plugins/systemd/systemd.plugin.zsh80
-rw-r--r--plugins/taskwarrior/README.md7
-rw-r--r--plugins/taskwarrior/_task4
-rw-r--r--plugins/term_tab/README16
-rw-r--r--plugins/term_tab/term_tab.plugin.zsh41
-rw-r--r--plugins/terminalapp/terminalapp.plugin.zsh6
-rw-r--r--plugins/terminitor/README.md9
-rw-r--r--plugins/terraform/README.md14
-rw-r--r--plugins/terraform/_terraform288
-rw-r--r--plugins/terraform/terraform.plugin.zsh6
-rw-r--r--plugins/textmate/README.md3
-rw-r--r--plugins/thefuck/README.md6
-rw-r--r--plugins/thefuck/thefuck.plugin.zsh7
-rw-r--r--plugins/themes/_theme3
-rw-r--r--plugins/themes/themes.plugin.zsh45
-rw-r--r--plugins/thor/README.md10
-rw-r--r--plugins/tig/README.md2
-rw-r--r--plugins/timer/README.md18
-rw-r--r--plugins/timer/timer.plugin.zsh35
-rw-r--r--plugins/tmux-cssh/README.md10
-rw-r--r--plugins/tmux-cssh/_tmux-cssh24
-rw-r--r--plugins/tmux/README.md8
-rw-r--r--plugins/tmux/tmux.extra.conf2
-rw-r--r--plugins/tmux/tmux.plugin.zsh16
-rw-r--r--plugins/tmuxinator/README.md12
-rw-r--r--plugins/tmuxinator/_tmuxinator6
-rw-r--r--plugins/torrent/README.md13
-rw-r--r--plugins/transfer/transfer.plugin.zsh4
-rw-r--r--plugins/tugboat/README.md12
-rw-r--r--plugins/ubuntu/README.md68
-rw-r--r--plugins/ubuntu/ubuntu.plugin.zsh102
-rw-r--r--plugins/ufw/README.md18
-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/urltools/README.md8
-rw-r--r--plugins/urltools/urltools.plugin.zsh8
-rw-r--r--plugins/vagrant-prompt/vagrant-prompt.plugin.zsh25
-rw-r--r--plugins/vagrant/README.md30
-rw-r--r--plugins/vagrant/_vagrant13
-rw-r--r--plugins/vagrant/vagrant.plugin.zsh33
-rw-r--r--plugins/vault/README.md19
-rw-r--r--plugins/vi-mode/README.md84
-rw-r--r--plugins/vi-mode/vi-mode.plugin.zsh125
-rw-r--r--plugins/virtualenv/virtualenv.plugin.zsh2
-rw-r--r--plugins/virtualenvwrapper/README.md38
-rw-r--r--plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh93
-rw-r--r--plugins/vscode/README.md44
-rw-r--r--plugins/vscode/vscode.plugin.zsh54
-rw-r--r--plugins/wakeonlan/README.md (renamed from plugins/wakeonlan/README)24
-rw-r--r--plugins/wd/README.md247
-rw-r--r--plugins/wd/_wd.sh17
-rw-r--r--plugins/wd/wd.plugin.zsh7
-rw-r--r--plugins/wd/wd.sh202
-rw-r--r--plugins/web-search/README.md29
-rw-r--r--plugins/web-search/web-search.plugin.zsh23
-rw-r--r--plugins/wp-cli/README.md202
-rw-r--r--plugins/wp-cli/wp-cli.plugin.zsh53
-rw-r--r--plugins/yarn/README.md59
-rw-r--r--plugins/yarn/_yarn34
-rw-r--r--plugins/yarn/yarn.plugin.zsh7
-rw-r--r--plugins/yii/README.md15
-rw-r--r--plugins/yii2/yii2.plugin.zsh2
-rw-r--r--plugins/yum/README.md2
-rw-r--r--plugins/z/README8
-rw-r--r--plugins/z/README.md23
-rw-r--r--plugins/z/z.13
-rw-r--r--plugins/z/z.sh63
-rw-r--r--plugins/zbell/README.md30
-rw-r--r--plugins/zbell/zbell.plugin.zsh83
-rw-r--r--plugins/zeus/README.md106
-rw-r--r--plugins/zeus/zeus.plugin.zsh1
-rw-r--r--plugins/zsh-interactive-cd/README.md23
-rw-r--r--plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh148
-rw-r--r--plugins/zsh-navigation-tools/LICENSE8
-rw-r--r--plugins/zsh-navigation-tools/Makefile35
-rw-r--r--plugins/zsh-navigation-tools/README.md383
-rw-r--r--plugins/zsh-navigation-tools/_n-kill6
-rw-r--r--plugins/zsh-navigation-tools/n-kill4
-rw-r--r--plugins/zsh-navigation-tools/n-list2
-rw-r--r--plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh25
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh16
-rw-r--r--templates/zshrc.zsh-template23
-rw-r--r--themes/3den.zsh-theme2
-rw-r--r--themes/adben.zsh-theme102
-rw-r--r--themes/af-magic.zsh-theme50
-rw-r--r--themes/agnoster.zsh-theme61
-rw-r--r--themes/alanpeabody.zsh-theme14
-rw-r--r--themes/amuse.zsh-theme27
-rw-r--r--themes/arrow.zsh-theme2
-rw-r--r--themes/avit.zsh-theme83
-rw-r--r--themes/awesomepanda.zsh-theme2
-rw-r--r--themes/bira.zsh-theme32
-rw-r--r--themes/candy-kingdom.zsh-theme24
-rw-r--r--themes/cloud.zsh-theme2
-rw-r--r--themes/crcandy.zsh-theme2
-rw-r--r--themes/crunch.zsh-theme10
-rw-r--r--themes/dallas.zsh-theme13
-rw-r--r--themes/dst.zsh-theme2
-rw-r--r--themes/edvardm.zsh-theme2
-rw-r--r--themes/essembeh.zsh-theme60
-rw-r--r--themes/evan.zsh-theme4
-rw-r--r--themes/fino-time.zsh-theme14
-rw-r--r--themes/fino.zsh-theme37
-rw-r--r--themes/fishy.zsh-theme20
-rw-r--r--themes/flazz.zsh-theme2
-rw-r--r--themes/frontcube.zsh-theme5
-rw-r--r--themes/fwalch.zsh-theme2
-rw-r--r--themes/gallifrey.zsh-theme9
-rw-r--r--themes/gallois.zsh-theme19
-rw-r--r--themes/gentoo.zsh-theme30
-rw-r--r--themes/gnzh.zsh-theme12
-rw-r--r--themes/gozilla.zsh-theme2
-rw-r--r--themes/itchy.zsh-theme4
-rw-r--r--themes/jaischeema.zsh-theme10
-rw-r--r--themes/jbergantine.zsh-theme2
-rw-r--r--themes/jnrowe.zsh-theme2
-rw-r--r--themes/jtriley.zsh-theme6
-rw-r--r--themes/kafeitu.zsh-theme2
-rw-r--r--themes/kiwi.zsh-theme4
-rw-r--r--themes/linuxonly.zsh-theme30
l---------[-rw-r--r--]themes/macovsky-ruby.zsh-theme16
-rw-r--r--themes/macovsky.zsh-theme14
-rw-r--r--themes/maran.zsh-theme2
-rw-r--r--themes/mira.zsh-theme20
-rw-r--r--themes/mlh.zsh-theme59
-rw-r--r--themes/muse.zsh-theme43
-rw-r--r--themes/nebirhos.zsh-theme2
-rw-r--r--themes/norm.zsh-theme5
-rw-r--r--themes/obraun.zsh-theme2
-rw-r--r--themes/peepcode.zsh-theme19
-rw-r--r--themes/pure.zsh-theme10
-rw-r--r--themes/pygmalion-virtualenv.zsh-theme53
-rw-r--r--themes/pygmalion.zsh-theme22
-rw-r--r--themes/random.zsh-theme47
-rw-r--r--themes/re5et.zsh-theme2
-rw-r--r--themes/refined.zsh-theme1
-rw-r--r--themes/robbyrussell.zsh-theme4
-rw-r--r--themes/simonoff.zsh-theme6
-rw-r--r--themes/smt.zsh-theme71
-rw-r--r--themes/sunrise.zsh-theme4
-rw-r--r--themes/suvash.zsh-theme15
-rw-r--r--themes/tjkirch.zsh-theme2
-rw-r--r--themes/tjkirch_mod.zsh-theme2
-rw-r--r--themes/trapd00r.zsh-theme10
-rw-r--r--themes/wedisagree.zsh-theme5
-rw-r--r--themes/ys.zsh-theme20
-rwxr-xr-xtools/changelog.sh431
-rw-r--r--tools/check_for_upgrade.sh121
-rwxr-xr-xtools/install.sh379
-rwxr-xr-xtools/theme_chooser.sh1
-rw-r--r--tools/uninstall.sh38
-rwxr-xr-x[-rw-r--r--]tools/upgrade.sh133
593 files changed, 24890 insertions, 10083 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..b5321de59
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,8 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+indent_size = 2
+indent_style = space
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 000000000..1b1340554
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1,9 @@
+# Plugin owners
+plugins/archlinux/ @ratijas
+plugins/aws/ @maksyms
+plugins/genpass/ @atoponce
+plugins/git-lfs/ @hellovietduc
+plugins/gitfast/ @felipec
+plugins/sdk/ @rgoldberg
+plugins/universalarchive/ @Konfekt
+plugins/wp-cli/ @joshmedeski
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..c44bb2475
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: [robbyrussell, mcornella, larson-carter]
+open_collective: ohmyzsh
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 000000000..88a6b814d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,46 @@
+---
+name: Bug report
+about: Create a report to help us improve Oh My Zsh
+labels: 'Bug'
+
+---
+
+<!--
+Fill this out before posting. You can delete irrelevant sections, but
+an issue where no sections have been filled will be deleted without comment.
+-->
+
+**Describe the bug**
+A clear description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior, for example:
+1. Enable this plugin '...'
+2. Run command '...' or try the autocomplete command '...'
+3. See error
+
+**Expected behavior**
+A brief description of what should happen.
+
+**Screenshots and/or Recordings**
+If applicable, add screenshots to help explain your problem.
+You can also record an asciinema session: https://asciinema.org/
+
+**Self Check**
+
+- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)?
+ This can help cut down on filling up issues. We always have a few people
+ online that are in a variety of timezones that are willing to help you!
+
+- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support
+
+**Desktop (please complete the following information):**
+
+ - OS / Distro: [e.g. Arch Linux, macOS]
+ - If on Windows what version of WSL: [e.g. WSL1, WSL2]
+ - Latest ohmyzsh update?: [e.g. Yes/No]
+ - ZSH Version: [e.g. 5.6]
+ - Terminal emulator: [e.g. iTerm2]
+
+**Additional context**
+Add any other context about the problem here. This can be themes, plugins, custom configs.
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..3ddd72a15
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,8 @@
+blank_issues_enabled: true
+contact_links:
+ - name: Support
+ url: https://github.com/ohmyzsh/ohmyzsh/discussions
+ about: Ask the community for support
+ - name: Get help on Discord
+ url: https://discord.gg/ohmyzsh
+ about: Have a quick question? Join the Discord server and ask on the appropriate channel.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 000000000..788f77368
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,29 @@
+---
+name: Feature request
+about: Suggest a feature for Oh My Zsh
+labels: 'Feature'
+
+---
+
+<!--
+Fill this out before posting. You can delete irrelevant sections, but
+an issue where no sections have been filled will be deleted without comment.
+-->
+
+**Is your feature request related to a particular plugin or theme? If so, specify it.**
+The name of the plugin, theme or alias that you would like us to improve. [...]
+
+**Is your feature request related to a problem? Please describe.**
+A description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A description of what you want to happen. [...]
+
+**Describe alternatives you've considered**
+A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
+
+**Additional context**
+Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
+
+**Related Issues**
+Is there any open or closed issues that is related to this feature request? If so please link them below! [...]
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..1abae8913
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,19 @@
+## Standards checklist:
+
+<!-- Fill with an x the ones that apply. Example: [x] -->
+
+- [ ] The PR title is descriptive.
+- [ ] The PR doesn't replicate another PR which is already open.
+- [ ] I have read the contribution guide and followed all the instructions.
+- [ ] The code follows the code style guide detailed in the wiki.
+- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
+- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
+- [ ] The code is stable and I have tested it myself, to the best of my abilities.
+
+## Changes:
+
+- [...]
+
+## Other comments:
+
+...
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 000000000..7ab7efdd6
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,36 @@
+name: CI
+on:
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ branches:
+ - master
+ push:
+ branches:
+ - master
+
+jobs:
+ tests:
+ name: Run tests
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+ steps:
+ - name: Set up git repository
+ uses: actions/checkout@v2
+ - name: Install zsh
+ if: runner.os == 'Linux'
+ run: sudo apt-get update; sudo apt-get install zsh
+ - name: Test installer
+ run: sh ./tools/install.sh
+ - name: Check syntax
+ run: |
+ for file in ./oh-my-zsh.sh \
+ ./lib/*.zsh \
+ ./plugins/*/*.plugin.zsh \
+ ./plugins/*/_* \
+ ./themes/*.zsh-theme; do
+ zsh -n "$file" || return 1
+ done
diff --git a/.gitignore b/.gitignore
index b2022081a..ec24a19bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,8 @@
# custom files
custom/
-!custom/plugins/example
-!custom/example.zsh
# temp files directories
cache/
log/
+*.swp
+.DS_Store
diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile
new file mode 100644
index 000000000..b35c80dfb
--- /dev/null
+++ b/.gitpod.Dockerfile
@@ -0,0 +1,5 @@
+FROM gitpod/workspace-full
+
+RUN sudo apt-get update && \
+ sudo apt-get install -y zsh && \
+ sudo rm -rf /var/lib/apt/lists/*
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 000000000..ccc57242c
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,9 @@
+image:
+ file: .gitpod.Dockerfile
+
+tasks:
+ - init: |
+ export EDITOR="command gp open -w" VISUAL="command gp open -w"
+ cp -f /workspace/ohmyzsh/templates/zshrc.zsh-template ~/.zshrc
+ ln -sf /workspace/ohmyzsh ~/.oh-my-zsh
+ command: exec zsh
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 000000000..20ad1ccee
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,76 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, sex characteristics, gender identity and expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies within all project spaces, and it also applies when
+an individual is representing the project or its community in public spaces.
+Examples of representing a project or community include using an official
+project e-mail address, posting via an official social media account, or acting
+as an appointed representative at an online or offline event. Representation of
+a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at ohmyzsh@planetargon.com. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see
+https://www.contributor-covenant.org/faq
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ac263fd18..4903584ee 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,24 +1,32 @@
# CONTRIBUTING GUIDELINES
-Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged and appreciated.
+Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged, and appreciated.
It is also essential for the development of the project.
+First, please take a moment to review our [code of conduct](CODE_OF_CONDUCT.md).
+
These guidelines are an attempt at better addressing the huge amount of pending
issues and pull requests. Please read them closely.
Foremost, be so kind as to [search](#use-the-search-luke). This ensures any contribution
you would make is not already covered.
-* [Issues](#reporting-issues)
- * [You have a problem](#you-have-a-problem)
- * [You have a suggestion](#you-have-a-suggestion)
-* [Pull Requests](#submitting-pull-requests)
- * [Getting started](#getting-started)
- * [You have a solution](#you-have-a-solution)
- * [You have an addition](#you-have-an-addition)
-* [Information sources (_aka_ search)](#use-the-search-luke)
+<!-- TOC updateonsave:true depthfrom:2 -->
+
+- [Reporting Issues](#reporting-issues)
+ - [You have a problem](#you-have-a-problem)
+ - [You have a suggestion](#you-have-a-suggestion)
+- [Submitting Pull Requests](#submitting-pull-requests)
+ - [Getting started](#getting-started)
+ - [You have a solution](#you-have-a-solution)
+ - [You have an addition](#you-have-an-addition)
+- [Use the Search, Luke](#use-the-search-luke)
+- [Commit Guidelines](#commit-guidelines)
+ - [Format](#format)
+ - [Style](#style)
+- [Volunteer](#volunteer)
-**BONUS:** [Volunteering](#you-have-spare-time-to-volunteer)
+<!-- /TOC -->
## Reporting Issues
@@ -29,7 +37,7 @@ your problem.
If you find one, comment on it so we can know there are more people experiencing it.
-If not, look at the [Troubleshooting](https://github.com/robbyrussell/oh-my-zsh/wiki/Troubleshooting)
+If not, look at the [Troubleshooting](https://github.com/ohmyzsh/ohmyzsh/wiki/Troubleshooting)
page for instructions on how to gather data to better debug your problem.
Then, you can go ahead and create an issue with as much detail as you can provide.
@@ -60,7 +68,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa
You should be familiar with the basics of
[contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork
-[properly set up](https://github.com/robbyrussell/oh-my-zsh/wiki/Contribution-Technical-Practices).
+[properly set up](https://github.com/ohmyzsh/ohmyzsh/wiki/Contribution-Technical-Practices).
You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree.
@@ -83,7 +91,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa
### You have an addition
-Please [do not](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#dont-send-us-your-theme-for-now)
+Please [do not](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#dont-send-us-your-theme-for-now)
send themes for now.
Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests
@@ -107,7 +115,7 @@ to help you check whether a similar contribution to yours already exists. Please
before making any contribution, it avoids duplicates and eases maintenance. Trust me,
that works 90% of the time.
-You can also take a look at the [FAQ](https://github.com/robbyrussell/oh-my-zsh/wiki/FAQ)
+You can also take a look at the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ)
to be sure your contribution has not already come up.
If all fails, your thing has probably not been reported yet, so you can go ahead
@@ -115,9 +123,102 @@ and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-reque
----
-### You have spare time to volunteer
+## Commit Guidelines
+
+Oh My Zsh uses the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
+specification. The automatic changelog tool uses these to automatically generate
+a changelog based on the commit messages. Here's a guide to writing a commit message
+to allow this:
+
+### Format
+
+```
+type(scope)!: subject
+```
+
+- `type`: the type of the commit is one of the following:
+
+ - `feat`: new features.
+ - `fix`: bug fixes.
+ - `docs`: documentation changes.
+ - `refactor`: refactor of a particular code section without introducing
+ new features or bug fixes.
+ - `style`: code style improvements.
+ - `perf`: performance improvements.
+ - `test`: changes to the test suite.
+ - `ci`: changes to the CI system.
+ - `build`: changes to the build system (we don't yet have one so this shouldn't apply).
+ - `chore`: for other changes that don't match previous types. This doesn't appear
+ in the changelog.
+
+- `scope`: section of the codebase that the commit makes changes to. If it makes changes to
+ many sections, or if no section in particular is modified, leave blank without the parentheses.
+ Examples:
+
+ - Commit that changes the `git` plugin:
+ ```
+ feat(git): add alias for `git commit`
+ ```
+
+ - Commit that changes many plugins:
+ ```
+ style: fix inline declaration of arrays
+ ```
+
+ For changes to plugins or themes, the scope should be the plugin or theme name:
+
+ - ✅ `fix(agnoster): commit subject`
+ - ❌ `fix(theme/agnoster): commit subject`
+
+- `!`: this goes after the `scope` (or the `type` if scope is empty), to indicate that the commit
+ introduces breaking changes.
+
+ Optionally, you can specify a message that the changelog tool will display to the user to indicate
+ what's changed and what they can do to deal with it. You can use multiple lines to type this message;
+ the changelog parser will keep reading until the end of the commit message or until it finds an empty
+ line.
+
+ Example (made up):
+
+ ```
+ style(agnoster)!: change dirty git repo glyph
+
+ BREAKING CHANGE: the glyph to indicate when a git repository is dirty has
+ changed from a Powerline character to a standard UTF-8 emoji. You can
+ change it back by setting `ZSH_THEME_DIRTY_GLYPH`.
+
+ Fixes #420
+
+ Co-authored-by: Username <email>
+ ```
+
+- `subject`: a brief description of the changes. This will be displayed in the changelog. If you need
+ to specify other details you can use the commit body but it won't be visible.
+
+ Formatting tricks: the commit subject may contain:
+
+ - Links to related issues or PRs by writing `#issue`. This will be highlighted by the changelog tool:
+ ```
+ feat(archlinux): add support for aura AUR helper (#9467)
+ ```
+
+ - Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by
+ the changelog tool:
+ ```
+ feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)
+ ```
+
+### Style
+
+Try to keep the first commit line short. This is harder to do using this commit style but try to be
+concise and if you need more space, you can use the commit body. Try to make sure that the commit
+subject is clear and precise enough that users will know what change by just looking at the changelog.
+
+----
+
+## Volunteer
Very nice!! :)
-Please have a look at the [Volunteer](https://github.com/robbyrussell/oh-my-zsh/wiki/Volunteers)
+Please have a look at the [Volunteer](https://github.com/ohmyzsh/ohmyzsh/wiki/Volunteers)
page for instructions on where to start and more.
diff --git a/LICENSE.txt b/LICENSE.txt
index 7af38f217..becd6a7bd 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,7 +1,6 @@
-The MIT License (MIT)
+MIT License
-Copyright (c) 2009-2018 Robby Russell and contributors
-See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
+Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index b3651a99c..3ebea91e0 100644
--- a/README.md
+++ b/README.md
@@ -1,51 +1,57 @@
-<p align="center">
- <img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh">
-</p>
+<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
Sounds boring. Let's try again.
-__Oh My Zsh will not make you a 10x developer...but you might feel like one.__
+**Oh My Zsh will not make you a 10x developer...but you may feel like one.**
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
-To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter.
+To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh).
+
+[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
+[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
+[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
+[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
## Getting Started
### Prerequisites
-__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._
-
-* Unix-like operating system (macOS or Linux)
-* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH)
-* `curl` or `wget` should be installed
-* `git` should be installed
+- A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
+- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
+- `curl` or `wget` should be installed
+- `git` should be installed (recommended v2.4.11 or higher)
### Basic Installation
-Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`.
+Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
-#### via curl
+| Method | Command |
+|:----------|:--------------------------------------------------------------------------------------------------|
+| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
+| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
+| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
-```shell
-sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
-```
+#### Manual inspection
-#### via wget
+It's a good idea to inspect the install script from projects you don't yet know. You can do
+that by downloading the install script first, looking through it so everything looks normal,
+then running it:
```shell
-sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
+wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
+sh install.sh
```
## Using Oh My Zsh
### Plugins
-Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available.
+Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
#### Enabling Plugins
@@ -69,13 +75,15 @@ plugins=(
)
```
+_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._
+
#### Using Plugins
-Most plugins (should! we're working on this) include a __README__, which documents how to use them.
+Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
### Themes
-We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out!
+We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out!
#### Selecting a Theme
@@ -91,7 +99,7 @@ To use a different theme, simply change the value to match the name of your desi
```shell
ZSH_THEME="agnoster" # (this is one of the fancy ones)
-# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster
+# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._
@@ -100,11 +108,10 @@ Open up a new terminal window and your prompt should look something like this:
![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
-In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes).
+In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes).
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
-
```shell
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
```
@@ -118,33 +125,79 @@ ZSH_THEME_RANDOM_CANDIDATES=(
)
```
+If you only know which themes you don't like, you can add them similarly to an ignored list:
+
+```shell
+ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
+```
+
+### FAQ
+
+If you have some more questions or issues, you might find a solution in our [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ).
+
## Advanced Topics
If you're the type that likes to get their hands dirty, these sections might resonate.
### Advanced Installation
-Some users may want to change the default path, or manually install Oh My Zsh.
+Some users may want to manually install Oh My Zsh, or change the default path or other settings that
+the installer accepts (these settings are also documented at the top of the install script).
#### Custom Directory
-The default location is `~/.oh-my-zsh` (hidden in your home directory)
+The default location is `~/.oh-my-zsh` (hidden in your home directory, you can access it with `cd ~/.oh-my-zsh`)
+
+If you'd like to change the install directory with the `ZSH` environment variable, either by running
+`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
+like this:
+
+```shell
+ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
+```
+
+#### Unattended install
-If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
+If you're running the Oh My Zsh install script as part of an automated install, you can pass the
+flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
+the default shell, and also won't run `zsh` when the installation has finished.
```shell
-export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
+sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
+```
+
+#### Installing from a forked repository
+
+The install script also accepts these variables to allow installation of a different repository:
+
+- `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set
+ this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
+
+- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository
+ clone. You can use this setting if you want to install from a fork that is not on GitHub (GitLab,
+ Bitbucket...) or if you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`).
+
+ _NOTE: it's incompatible with setting the `REPO` variable. This setting will take precedence._
+
+- `BRANCH` (default: `master`): you can use this setting if you want to change the default branch to be
+ checked out when cloning the repository. This might be useful for testing a Pull Request, or if you
+ want to use a branch other than `master`.
+
+For example:
+
+```shell
+REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
```
#### Manual Installation
-##### 1. Clone the repository:
+##### 1. Clone the repository
```shell
-git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
+git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
```
-##### 2. *Optionally*, backup your existing `~/.zshrc` file:
+##### 2. *Optionally*, backup your existing `~/.zshrc` file
```shell
cp ~/.zshrc ~/.zshrc.orig
@@ -161,9 +214,11 @@ cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
##### 4. Change your default shell
```shell
-chsh -s /bin/zsh
+chsh -s $(which zsh)
```
+You must log out from your user session and log back in to see this change.
+
##### 5. Initialize your new zsh configuration
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
@@ -172,8 +227,10 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
If you have any hiccups installing, here are a few common fixes.
-* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
-* If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
+- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
+switching to `oh-my-zsh`.
+- If you installed manually or changed the install location, check the `ZSH` environment variable in
+`~/.zshrc`.
### Custom Plugins and Themes
@@ -202,7 +259,7 @@ DISABLE_AUTO_UPDATE=true
If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
```shell
-upgrade_oh_my_zsh
+omz update
```
Magic! 🎉
@@ -213,15 +270,19 @@ Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy b
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration.
-## Contributing
+## How do I contribute to Oh My Zsh?
+
+Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md).
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
-We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can.
+We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
+
+See [Contributing](CONTRIBUTING.md) for more details.
### Do NOT send us themes
-We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page.
+We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
## Contributors
@@ -231,14 +292,16 @@ Thank you so much!
## Follow Us
-We're on the social media.
+We're on social media:
-* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
-* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook.
+- [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
+- [Facebook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us.
+- [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh!
+- [Discord](https://discord.gg/ohmyzsh) to chat with us!
## Merchandise
-We have [stickers](https://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](https://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town!
+We have [stickers, shirts, and coffee mugs available](https://shop.planetargon.com/collections/oh-my-zsh?utm_source=github) for you to show off your love of Oh My Zsh. Again, you will become the talk of the town!
## License
diff --git a/lib/cli.zsh b/lib/cli.zsh
new file mode 100644
index 000000000..38e2f72f8
--- /dev/null
+++ b/lib/cli.zsh
@@ -0,0 +1,426 @@
+#!/usr/bin/env zsh
+
+function omz {
+ [[ $# -gt 0 ]] || {
+ _omz::help
+ return 1
+ }
+
+ local command="$1"
+ shift
+
+ # Subcommand functions start with _ so that they don't
+ # appear as completion entries when looking for `omz`
+ (( $+functions[_omz::$command] )) || {
+ _omz::help
+ return 1
+ }
+
+ _omz::$command "$@"
+}
+
+function _omz {
+ local -a cmds subcmds
+ cmds=(
+ 'changelog:Print the changelog'
+ 'help:Usage information'
+ 'plugin:Manage plugins'
+ 'pr:Manage Oh My Zsh Pull Requests'
+ 'theme:Manage themes'
+ 'update:Update Oh My Zsh'
+ )
+
+ if (( CURRENT == 2 )); then
+ _describe 'command' cmds
+ elif (( CURRENT == 3 )); then
+ case "$words[2]" in
+ changelog) local -a refs
+ refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
+ _describe 'command' refs ;;
+ plugin) subcmds=('info:Get plugin information' 'list:List plugins')
+ _describe 'command' subcmds ;;
+ pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
+ _describe 'command' subcmds ;;
+ theme) subcmds=('use:Load a theme' 'list:List themes')
+ _describe 'command' subcmds ;;
+ esac
+ elif (( CURRENT == 4 )); then
+ case "$words[2]::$words[3]" in
+ plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \
+ "$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;;
+ theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
+ "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
+ esac
+ fi
+
+ return 0
+}
+
+compdef _omz omz
+
+## Utility functions
+
+function _omz::confirm {
+ # If question supplied, ask it before reading the answer
+ # NOTE: uses the logname of the caller function
+ if [[ -n "$1" ]]; then
+ _omz::log prompt "$1" "${${functrace[1]#_}%:*}"
+ fi
+
+ # Read one character
+ read -r -k 1
+
+ # If no newline entered, add a newline
+ if [[ "$REPLY" != $'\n' ]]; then
+ echo
+ fi
+}
+
+function _omz::log {
+ # if promptsubst is set, a message with `` or $()
+ # will be run even if quoted due to `print -P`
+ setopt localoptions nopromptsubst
+
+ # $1 = info|warn|error|debug
+ # $2 = text
+ # $3 = (optional) name of the logger
+
+ local logtype=$1
+ local logname=${3:-${${functrace[1]#_}%:*}}
+
+ # Don't print anything if debug is not active
+ if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
+ return
+ fi
+
+ # Choose coloring based on log type
+ case "$logtype" in
+ prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;;
+ debug) print -P "%F{white}$logname%f: $2" ;;
+ info) print -P "%F{green}$logname%f: $2" ;;
+ warn) print -P "%S%F{yellow}$logname%f%s: $2" ;;
+ error) print -P "%S%F{red}$logname%f%s: $2" ;;
+ esac >&2
+}
+
+## User-facing commands
+
+function _omz::help {
+ cat <<EOF
+Usage: omz <command> [options]
+
+Available commands:
+
+ help Print this help message
+ changelog Print the changelog
+ plugin <command> Manage plugins
+ pr <command> Manage Oh My Zsh Pull Requests
+ theme <command> Manage themes
+ update Update Oh My Zsh
+
+EOF
+}
+
+function _omz::changelog {
+ local version=${1:-HEAD} format=${3:-"--text"}
+
+ if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \
+ ! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \
+ ! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then
+ cat <<EOF
+Usage: omz changelog [version]
+
+NOTE: <version> must be a valid branch, tag or commit.
+EOF
+ return 1
+ fi
+
+ "$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
+}
+
+function _omz::plugin {
+ (( $# > 0 && $+functions[_omz::plugin::$1] )) || {
+ cat <<EOF
+Usage: omz plugin <command> [options]
+
+Available commands:
+
+ info <plugin> Get information of a plugin
+ list List all available Oh My Zsh plugins
+
+EOF
+ return 1
+ }
+
+ local command="$1"
+ shift
+
+ _omz::plugin::$command "$@"
+}
+
+function _omz::plugin::info {
+ if [[ -z "$1" ]]; then
+ echo >&2 "Usage: omz plugin info <plugin>"
+ return 1
+ fi
+
+ local readme
+ for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do
+ if [[ -f "$readme" ]]; then
+ (( ${+commands[less]} )) && less "$readme" || cat "$readme"
+ return 0
+ fi
+ done
+
+ if [[ -d "$ZSH_CUSTOM/plugins/$1" || -d "$ZSH/plugins/$1" ]]; then
+ _omz::log error "the '$1' plugin doesn't have a README file"
+ else
+ _omz::log error "'$1' plugin not found"
+ fi
+
+ return 1
+}
+
+function _omz::plugin::list {
+ local -a custom_plugins builtin_plugins
+ custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
+ builtin_plugins=("$ZSH"/plugins/*(-/N:t))
+
+ # If the command is being piped, print all found line by line
+ if [[ ! -t 1 ]]; then
+ print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
+ return
+ fi
+
+ if (( ${#custom_plugins} )); then
+ print -P "%U%BCustom plugins%b%u:"
+ print -l ${(q-)custom_plugins} | column
+ fi
+
+ if (( ${#builtin_plugins} )); then
+ (( ${#custom_plugins} )) && echo # add a line of separation
+
+ print -P "%U%BBuilt-in plugins%b%u:"
+ print -l ${(q-)builtin_plugins} | column
+ fi
+}
+
+function _omz::pr {
+ (( $# > 0 && $+functions[_omz::pr::$1] )) || {
+ cat <<EOF
+Usage: omz pr <command> [options]
+
+Available commands:
+
+ clean Delete all PR branches (ohmyzsh/pull-*)
+ test <PR_number_or_URL> Fetch PR #NUMBER and rebase against master
+
+EOF
+ return 1
+ }
+
+ local command="$1"
+ shift
+
+ _omz::pr::$command "$@"
+}
+
+function _omz::pr::clean {
+ (
+ set -e
+ builtin cd -q "$ZSH"
+
+ # Check if there are PR branches
+ local fmt branches
+ fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)"
+ branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")"
+
+ # Exit if there are no PR branches
+ if [[ -z "$branches" ]]; then
+ _omz::log info "there are no Pull Request branches to remove."
+ return
+ fi
+
+ # Print found PR branches
+ echo "$branches\n"
+ # Confirm before removing the branches
+ _omz::confirm "do you want remove these Pull Request branches? [Y/n] "
+ # Only proceed if the answer is a valid yes option
+ [[ "$REPLY" != [yY$'\n'] ]] && return
+
+ _omz::log info "removing all Oh My Zsh Pull Request branches..."
+ command git branch --list 'ohmyzsh/pull-*' | while read branch; do
+ command git branch -D "$branch"
+ done
+ )
+}
+
+function _omz::pr::test {
+ # Allow $1 to be a URL to the pull request
+ if [[ "$1" = https://* ]]; then
+ 1="${1:t}"
+ fi
+
+ # Check the input
+ if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
+ echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>"
+ return 1
+ fi
+
+ # Save current git HEAD
+ local branch
+ branch=$(builtin cd -q "$ZSH"; git symbolic-ref --short HEAD) || {
+ _omz::log error "error when getting the current git branch. Aborting..."
+ return 1
+ }
+
+
+ # Fetch PR onto ohmyzsh/pull-<PR_NUMBER> branch and rebase against master
+ # If any of these operations fail, undo the changes made
+ (
+ set -e
+ builtin cd -q "$ZSH"
+
+ # Get the ohmyzsh git remote
+ command git remote -v | while read remote url _; do
+ case "$url" in
+ https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
+ git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
+ esac
+ done
+
+ (( $found )) || {
+ _omz::log error "could not found the ohmyzsh git remote. Aborting..."
+ return 1
+ }
+
+ # Fetch pull request head
+ _omz::log info "fetching PR #$1 to ohmyzsh/pull-$1..."
+ command git fetch -f "$remote" refs/pull/$1/head:ohmyzsh/pull-$1 || {
+ _omz::log error "error when trying to fetch PR #$1."
+ return 1
+ }
+
+ # Rebase pull request branch against the current master
+ _omz::log info "rebasing PR #$1..."
+ command git rebase master ohmyzsh/pull-$1 || {
+ command git rebase --abort &>/dev/null
+ _omz::log warn "could not rebase PR #$1 on top of master."
+ _omz::log warn "you might not see the latest stable changes."
+ _omz::log info "run \`zsh\` to test the changes."
+ return 1
+ }
+
+ _omz::log info "fetch of PR #${1} successful."
+ )
+
+ # If there was an error, abort running zsh to test the PR
+ [[ $? -eq 0 ]] || return 1
+
+ # Run zsh to test the changes
+ _omz::log info "running \`zsh\` to test the changes. Run \`exit\` to go back."
+ command zsh -l
+
+ # After testing, go back to the previous HEAD if the user wants
+ _omz::confirm "do you want to go back to the previous branch? [Y/n] "
+ # Only proceed if the answer is a valid yes option
+ [[ "$REPLY" != [yY$'\n'] ]] && return
+
+ (
+ set -e
+ builtin cd -q "$ZSH"
+
+ command git checkout "$branch" -- || {
+ _omz::log error "could not go back to the previous branch ('$branch')."
+ return 1
+ }
+ )
+}
+
+function _omz::theme {
+ (( $# > 0 && $+functions[_omz::theme::$1] )) || {
+ cat <<EOF
+Usage: omz theme <command> [options]
+
+Available commands:
+
+ list List all available Oh My Zsh themes
+ use <theme> Load an Oh My Zsh theme
+
+EOF
+ return 1
+ }
+
+ local command="$1"
+ shift
+
+ _omz::theme::$command "$@"
+}
+
+function _omz::theme::list {
+ local -a custom_themes builtin_themes
+ custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
+ builtin_themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r))
+
+ # If the command is being piped, print all found line by line
+ if [[ ! -t 1 ]]; then
+ print -l ${(q-)custom_themes} ${(q-)builtin_themes}
+ return
+ fi
+
+ if (( ${#custom_themes} )); then
+ print -P "%U%BCustom themes%b%u:"
+ print -l ${(q-)custom_themes} | column
+ fi
+
+ if (( ${#builtin_themes} )); then
+ (( ${#custom_themes} )) && echo # add a line of separation
+
+ print -P "%U%BBuilt-in themes%b%u:"
+ print -l ${(q-)builtin_themes} | column
+ fi
+}
+
+function _omz::theme::use {
+ if [[ -z "$1" ]]; then
+ echo >&2 "Usage: omz theme use <theme>"
+ return 1
+ fi
+
+ # Respect compatibility with old lookup order
+ if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/$1.zsh-theme"
+ elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/themes/$1.zsh-theme"
+ elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
+ source "$ZSH/themes/$1.zsh-theme"
+ else
+ _omz::log error "theme '$1' not found"
+ return 1
+ fi
+}
+
+function _omz::update {
+ local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
+
+ # Run update script
+ if [[ "$1" != --unattended ]]; then
+ ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
+ else
+ ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
+ fi
+
+ # Update last updated file
+ zmodload zsh/datetime
+ echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
+ # Remove update lock if it exists
+ command rm -rf "$ZSH/log/update.lock"
+
+ # Restart the zsh session if there were changes
+ if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
+ # Old zsh versions don't have ZSH_ARGZERO
+ local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
+ # Check whether to run a login shell
+ [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
+ fi
+}
diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
index 2c93d1bb5..122145f15 100644
--- a/lib/clipboard.zsh
+++ b/lib/clipboard.zsh
@@ -3,10 +3,23 @@
# This file has support for doing system clipboard copy and paste operations
# from the command line in a generic cross-platform fashion.
#
-# On OS X and Windows, the main system clipboard or "pasteboard" is used. On other
-# Unix-like OSes, this considers the X Windows CLIPBOARD selection to be the
-# "system clipboard", and the X Windows `xclip` command must be installed.
-
+# This is uses essentially the same heuristic as neovim, with the additional
+# special support for Cygwin.
+# See: https://github.com/neovim/neovim/blob/e682d799fa3cf2e80a02d00c6ea874599d58f0e7/runtime/autoload/provider/clipboard.vim#L55-L121
+#
+# - pbcopy, pbpaste (macOS)
+# - cygwin (Windows running Cygwin)
+# - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
+# - xclip (if $DISPLAY is set)
+# - xsel (if $DISPLAY is set)
+# - lemonade (for SSH) https://github.com/pocke/lemonade
+# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
+# - win32yank (Windows)
+# - tmux (if $TMUX is set)
+#
+# Defines two functions, clipcopy and clippaste, based on the detected platform.
+##
+#
# clipcopy - Copy data to clipboard
#
# Usage:
@@ -15,41 +28,8 @@
#
# clipcopy <file> - copies a file's contents to clipboard
#
-function clipcopy() {
- emulate -L zsh
- local file=$1
- if [[ $OSTYPE == darwin* ]]; then
- if [[ -z $file ]]; then
- pbcopy
- else
- cat $file | pbcopy
- fi
- elif [[ $OSTYPE == cygwin* ]]; then
- if [[ -z $file ]]; then
- cat > /dev/clipboard
- else
- cat $file > /dev/clipboard
- fi
- else
- if (( $+commands[xclip] )); then
- if [[ -z $file ]]; then
- xclip -in -selection clipboard
- else
- xclip -in -selection clipboard $file
- fi
- elif (( $+commands[xsel] )); then
- if [[ -z $file ]]; then
- xsel --clipboard --input
- else
- cat "$file" | xsel --clipboard --input
- fi
- else
- print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
- return 1
- fi
- fi
-}
-
+##
+#
# clippaste - "Paste" data from clipboard to stdout
#
# Usage:
@@ -67,20 +47,61 @@ function clipcopy() {
#
# # Paste to a file
# clippaste > file.txt
-function clippaste() {
+#
+function detect-clipboard() {
emulate -L zsh
- if [[ $OSTYPE == darwin* ]]; then
- pbpaste
- elif [[ $OSTYPE == cygwin* ]]; then
- cat /dev/clipboard
+
+ if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
+ function clipcopy() { pbcopy < "${1:-/dev/stdin}"; }
+ function clippaste() { pbpaste; }
+ elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
+ function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
+ function clippaste() { cat /dev/clipboard; }
+ elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
+ function clipcopy() { wl-copy < "${1:-/dev/stdin}"; }
+ function clippaste() { wl-paste; }
+ elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then
+ function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; }
+ function clippaste() { xclip -out -selection clipboard; }
+ elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then
+ function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; }
+ function clippaste() { xsel --clipboard --output; }
+ elif (( ${+commands[lemonade]} )); then
+ function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; }
+ function clippaste() { lemonade paste; }
+ elif (( ${+commands[doitclient]} )); then
+ function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; }
+ function clippaste() { doitclient wclip -r; }
+ elif (( ${+commands[win32yank]} )); then
+ function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; }
+ function clippaste() { win32yank -o; }
+ elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then
+ function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; }
+ function clippaste() { termux-clipboard-get; }
+ elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
+ function clipcopy() { tmux load-buffer "${1:--}"; }
+ function clippaste() { tmux save-buffer -; }
+ elif [[ $(uname -r) = *icrosoft* ]]; then
+ function clipcopy() { clip.exe < "${1:-/dev/stdin}"; }
+ function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
else
- if (( $+commands[xclip] )); then
- xclip -out -selection clipboard
- elif (( $+commands[xsel] )); then
- xsel --clipboard --output
- else
- print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
- return 1
- fi
+ function _retry_clipboard_detection_or_fail() {
+ local clipcmd="${1}"; shift
+ if detect-clipboard; then
+ "${clipcmd}" "$@"
+ else
+ print "${clipcmd}: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
+ return 1
+ fi
+ }
+ function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; }
+ function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; }
+ return 1
fi
}
+
+# Detect at startup. A non-zero exit here indicates that the dummy clipboards were set,
+# which is not really an error. If the user calls them, they will attempt to redetect
+# (for example, perhaps the user has now installed xclip) and then either print an error
+# or proceed successfully.
+detect-clipboard || true
diff --git a/lib/compfix.zsh b/lib/compfix.zsh
index 68decc1ed..b09b283f2 100644
--- a/lib/compfix.zsh
+++ b/lib/compfix.zsh
@@ -18,7 +18,7 @@ function handle_completion_insecurities() {
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
# If no such directories exist, get us out of here.
- (( ! ${#insecure_dirs} )) && return
+ [[ -z "${insecure_dirs}" ]] && return
# List ownership and permissions of all insecure directories.
print "[oh-my-zsh] Insecure completion-dependent directories detected:"
diff --git a/lib/completion.zsh b/lib/completion.zsh
index c7db2eb7b..ebaab0856 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -32,17 +32,17 @@ zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
if [[ "$OSTYPE" = solaris* ]]; then
- zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
+ zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm"
else
- zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
+ zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w"
fi
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
# Use caching so that commands like apt and dpkg complete are useable
-zstyle ':completion::complete:*' use-cache 1
-zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
+zstyle ':completion:*' use-cache yes
+zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
# Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \
@@ -60,14 +60,16 @@ zstyle '*' single-ignored show
if [[ $COMPLETION_WAITING_DOTS = true ]]; then
expand-or-complete-with-dots() {
- # toggle line-wrapping off and back on again
- [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
- print -Pn "%{%F{red}......%f%}"
- [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
-
+ print -Pn "%F{red}…%f"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
- bindkey "^I" expand-or-complete-with-dots
+ # Set the function as the default tab completion widget
+ bindkey -M emacs "^I" expand-or-complete-with-dots
+ bindkey -M viins "^I" expand-or-complete-with-dots
+ bindkey -M vicmd "^I" expand-or-complete-with-dots
fi
+
+# automatically load bash completion functions
+autoload -U +X bashcompinit && bashcompinit
diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh
index 9c9905e4d..650520797 100644
--- a/lib/diagnostics.zsh
+++ b/lib/diagnostics.zsh
@@ -112,7 +112,7 @@ function _omz_diag_dump_one_big_text() {
command uname -a
builtin echo OSTYPE=$OSTYPE
builtin echo ZSH_VERSION=$ZSH_VERSION
- builtin echo User: $USER
+ builtin echo User: $USERNAME
builtin echo umask: $(umask)
builtin echo
_omz_diag_dump_os_specific_version
@@ -192,19 +192,19 @@ function _omz_diag_dump_one_big_text() {
command ls -ld ~/.oh*
builtin echo
builtin echo oh-my-zsh git state:
- (cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
+ (builtin cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
if [[ $verbose -ge 1 ]]; then
- (cd $ZSH && git reflog --date=default | command grep pull)
+ (builtin cd $ZSH && git reflog --date=default | command grep pull)
fi
builtin echo
if [[ -e $ZSH_CUSTOM ]]; then
local custom_dir=$ZSH_CUSTOM
if [[ -h $custom_dir ]]; then
- custom_dir=$(cd $custom_dir && pwd -P)
+ custom_dir=$(builtin cd $custom_dir && pwd -P)
fi
builtin echo "oh-my-zsh custom dir:"
builtin echo " $ZSH_CUSTOM ($custom_dir)"
- (cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
+ (builtin cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
builtin echo
fi
diff --git a/lib/directories.zsh b/lib/directories.zsh
index 14064b86f..cf87bd7e4 100644
--- a/lib/directories.zsh
+++ b/lib/directories.zsh
@@ -21,7 +21,15 @@ alias 9='cd -9'
alias md='mkdir -p'
alias rd=rmdir
-alias d='dirs -v | head -10'
+
+function d () {
+ if [[ -n $1 ]]; then
+ dirs "$@"
+ else
+ dirs -v | head -10
+ fi
+}
+compdef _dirs d
# List directory contents
alias lsa='ls -lah'
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 4ef8920f6..9cc735196 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -1,16 +1,19 @@
function zsh_stats() {
- fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
+ fc -l 1 \
+ | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
+ | grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
}
function uninstall_oh_my_zsh() {
- env ZSH=$ZSH sh $ZSH/tools/uninstall.sh
+ env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
}
function upgrade_oh_my_zsh() {
- env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
+ echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
+ omz update
}
-function take() {
+function takedir() {
mkdir -p $@ && cd ${@:$#}
}
@@ -21,7 +24,7 @@ function open_command() {
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
- linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || {
+ linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;;
@@ -31,11 +34,30 @@ function open_command() {
;;
esac
- # don't use nohup on OSX
- if [[ "$OSTYPE" == darwin* ]]; then
- ${=open_cmd} "$@" &>/dev/null
+ ${=open_cmd} "$@" &>/dev/null
+}
+
+function takeurl() {
+ data=$(mktemp)
+ curl -L $1 > $data
+ tar xf $data
+ thedir=$(tar tf $data | head -1)
+ rm $data
+ cd $thedir
+}
+
+function takegit() {
+ git clone $1
+ cd $(basename ${1%%.git})
+}
+
+function take() {
+ if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
+ takeurl $1
+ elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
+ takegit $1
else
- nohup ${=open_cmd} "$@" &>/dev/null
+ takedir $1
fi
}
@@ -79,7 +101,7 @@ function try_alias_value() {
# 0 if the variable exists, 3 if it was set
#
function default() {
- test `typeset +m "$1"` && return 0
+ (( $+parameters[$1] )) && return 0
typeset -g "$1"="$2" && return 3
}
@@ -93,8 +115,8 @@ function default() {
# 0 if the env variable exists, 3 if it was set
#
function env_default() {
- env | grep -q "^$1=" && return 0
- export "$1=$2" && return 3
+ [[ ${parameters[$1]} = *-export* ]] && return 0
+ export "$1=$2" && return 3
}
@@ -127,6 +149,7 @@ zmodload zsh/langinfo
# -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() {
emulate -L zsh
+ local -a opts
zparseopts -D -E -a opts r m P
local in_str=$1
diff --git a/lib/git.zsh b/lib/git.zsh
index b92373153..c9363274c 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -1,26 +1,57 @@
-# Outputs current branch info in prompt format
+# The git prompt's git commands are read-only and should not interfere with
+# other processes. This environment variable is equivalent to running with `git
+# --no-optional-locks`, but falls back gracefully for older versions of git.
+# See git(1) for and git-status(1) for a description of that flag.
+#
+# We wrap in a local function instead of exporting the variable directly in
+# order to avoid interfering with manually-run git commands by the user.
+function __git_prompt_git() {
+ GIT_OPTIONAL_LOCKS=0 command git "$@"
+}
+
function git_prompt_info() {
+ # If we are on a folder not tracked by git, get out.
+ # Otherwise, check for hide-info at global and local repository level
+ if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
+ || [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
+ return 0
+ fi
+
local ref
- if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
- ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
- ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
- echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
+ ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
+ || ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
+ || return 0
+
+ # Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
+ local upstream
+ if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then
+ upstream=$(__git_prompt_git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) \
+ && upstream=" -> ${upstream}"
fi
+
+ echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# Checks if working tree is dirty
function parse_git_dirty() {
- local STATUS=''
+ local STATUS
local -a FLAGS
FLAGS=('--porcelain')
- if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
- if [[ $POST_1_7_2_GIT -gt 0 ]]; then
- FLAGS+='--ignore-submodules=dirty'
- fi
- if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
+ if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
+ if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
- STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
+ case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
+ git)
+ # let git decide (this respects per-repo config in .gitmodules)
+ ;;
+ *)
+ # if unset: ignore dirty submodules
+ # other values are passed to --ignore-submodules
+ FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
+ ;;
+ esac
+ STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1)
fi
if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
@@ -32,10 +63,10 @@ function parse_git_dirty() {
# Gets the difference between the local and remote branches
function git_remote_status() {
local remote ahead behind git_remote_status git_remote_status_detailed
- remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
+ remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]]; then
- ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
- behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
+ ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
+ behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
@@ -64,11 +95,11 @@ function git_remote_status() {
# it's not a symbolic ref, but in a Git repo.
function git_current_branch() {
local ref
- ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
+ ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
- ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
+ ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
}
@@ -76,8 +107,8 @@ function git_current_branch() {
# Gets the number of commits ahead from remote
function git_commits_ahead() {
- if command git rev-parse --git-dir &>/dev/null; then
- local commits="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)"
+ if __git_prompt_git rev-parse --git-dir &>/dev/null; then
+ local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
if [[ -n "$commits" && "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
@@ -86,8 +117,8 @@ function git_commits_ahead() {
# Gets the number of commits behind remote
function git_commits_behind() {
- if command git rev-parse --git-dir &>/dev/null; then
- local commits="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)"
+ if __git_prompt_git rev-parse --git-dir &>/dev/null; then
+ local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
if [[ -n "$commits" && "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi
@@ -96,21 +127,21 @@ function git_commits_behind() {
# Outputs if current branch is ahead of remote
function git_prompt_ahead() {
- if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
+ if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}
# Outputs if current branch is behind remote
function git_prompt_behind() {
- if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
+ if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
}
# Outputs if current branch exists on remote or not
function git_prompt_remote() {
- if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
+ if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
@@ -120,102 +151,130 @@ function git_prompt_remote() {
# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
local SHA
- SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
+ SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
# Formats prompt string for current git commit long SHA
function git_prompt_long_sha() {
local SHA
- SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
+ SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
-# Get the status of the working tree
function git_prompt_status() {
- local INDEX STATUS
- INDEX=$(command git status --porcelain -b 2> /dev/null)
- STATUS=""
- if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
- fi
- if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
- elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
- elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
- fi
- if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
- elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
- elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
- elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
- fi
- if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
- fi
- if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
- elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
- elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
- fi
- if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
- STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
- fi
- if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
- fi
- if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
+ [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
+
+ # Maps a git status prefix to an internal constant
+ # This cannot use the prompt constants, as they may be empty
+ local -A prefix_constant_map
+ prefix_constant_map=(
+ '\?\? ' 'UNTRACKED'
+ 'A ' 'ADDED'
+ 'M ' 'ADDED'
+ 'MM ' 'MODIFIED'
+ ' M ' 'MODIFIED'
+ 'AM ' 'MODIFIED'
+ ' T ' 'MODIFIED'
+ 'R ' 'RENAMED'
+ ' D ' 'DELETED'
+ 'D ' 'DELETED'
+ 'UU ' 'UNMERGED'
+ 'ahead' 'AHEAD'
+ 'behind' 'BEHIND'
+ 'diverged' 'DIVERGED'
+ 'stashed' 'STASHED'
+ )
+
+ # Maps the internal constant to the prompt theme
+ local -A constant_prompt_map
+ constant_prompt_map=(
+ 'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
+ 'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
+ 'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
+ 'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
+ 'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
+ 'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
+ 'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
+ 'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
+ 'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
+ 'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
+ )
+
+ # The order that the prompt displays should be added to the prompt
+ local status_constants
+ status_constants=(
+ UNTRACKED ADDED MODIFIED RENAMED DELETED
+ STASHED UNMERGED AHEAD BEHIND DIVERGED
+ )
+
+ local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
+
+ # Don't continue on a catastrophic failure
+ if [[ $? -eq 128 ]]; then
+ return 1
fi
- if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
+
+ # A lookup table of each git status encountered
+ local -A statuses_seen
+
+ if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
+ statuses_seen[STASHED]=1
fi
- if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then
- STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
+
+ local status_lines
+ status_lines=("${(@f)${status_text}}")
+
+ # If the tracking line exists, get and parse it
+ if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
+ local branch_statuses
+ branch_statuses=("${(@s/,/)match}")
+ for branch_status in $branch_statuses; do
+ if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
+ continue
+ fi
+ local last_parsed_status=$prefix_constant_map[$match[1]]
+ statuses_seen[$last_parsed_status]=$match[2]
+ done
fi
- echo $STATUS
-}
-
-# Compares the provided version of git to the version installed and on path
-# Outputs -1, 0, or 1 if the installed version is less than, equal to, or
-# greater than the input version, respectively.
-function git_compare_version() {
- local INPUT_GIT_VERSION INSTALLED_GIT_VERSION i
- INPUT_GIT_VERSION=(${(s/./)1})
- INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null))
- INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]})
-
- for i in {1..3}; do
- if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then
- echo 1
- return 0
+
+ # For each status prefix, do a regex comparison
+ for status_prefix in ${(k)prefix_constant_map}; do
+ local status_constant="${prefix_constant_map[$status_prefix]}"
+ local status_regex=$'(^|\n)'"$status_prefix"
+
+ if [[ "$status_text" =~ $status_regex ]]; then
+ statuses_seen[$status_constant]=1
fi
- if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
- echo -1
- return 0
+ done
+
+ # Display the seen statuses in the order specified
+ local status_prompt
+ for status_constant in $status_constants; do
+ if (( ${+statuses_seen[$status_constant]} )); then
+ local next_display=$constant_prompt_map[$status_constant]
+ status_prompt="$next_display$status_prompt"
fi
done
- echo 0
+
+ echo $status_prompt
}
# Outputs the name of the current user
# Usage example: $(git_current_user_name)
function git_current_user_name() {
- command git config user.name 2>/dev/null
+ __git_prompt_git config user.name 2>/dev/null
}
# Outputs the email of the current user
# Usage example: $(git_current_user_email)
function git_current_user_email() {
- command git config user.email 2>/dev/null
+ __git_prompt_git config user.email 2>/dev/null
}
-# This is unlikely to change so make it all statically assigned
-POST_1_7_2_GIT=$(git_compare_version "1.7.2")
-# Clean up the namespace slightly by removing the checker function
-unfunction git_compare_version
+# Output the name of the root directory of the git repository
+# Usage example: $(git_repo_name)
+function git_repo_name() {
+ local repo_path
+ if repo_path="$(__git_prompt_git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
+ echo ${repo_path:t}
+ fi
+}
diff --git a/lib/grep.zsh b/lib/grep.zsh
index abc1650a1..a725e0f26 100644
--- a/lib/grep.zsh
+++ b/lib/grep.zsh
@@ -1,28 +1,41 @@
-# is x grep argument available?
-grep-flag-available() {
- echo | grep $1 "" >/dev/null 2>&1
-}
+__GREP_CACHE_FILE="$ZSH_CACHE_DIR"/grep-alias
-GREP_OPTIONS=""
+# See if there's a cache file modified in the last day
+__GREP_ALIAS_CACHES=("$__GREP_CACHE_FILE"(Nm-1))
+if [[ -n "$__GREP_ALIAS_CACHES" ]]; then
+ source "$__GREP_CACHE_FILE"
+else
+ grep-flags-available() {
+ command grep "$@" "" &>/dev/null <<< ""
+ }
-# color grep results
-if grep-flag-available --color=auto; then
- GREP_OPTIONS+=" --color=auto"
-fi
+ # Ignore these folders (if the necessary grep flags are available)
+ EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
-# ignore VCS folders (if the necessary grep flags are available)
-VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}"
+ # Check for --exclude-dir, otherwise check for --exclude. If --exclude
+ # isn't available, --color won't be either (they were released at the same
+ # time (v2.5): https://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007
+ if grep-flags-available --color=auto --exclude-dir=.cvs; then
+ GREP_OPTIONS="--color=auto --exclude-dir=$EXC_FOLDERS"
+ elif grep-flags-available --color=auto --exclude=.cvs; then
+ GREP_OPTIONS="--color=auto --exclude=$EXC_FOLDERS"
+ fi
-if grep-flag-available --exclude-dir=.cvs; then
- GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
-elif grep-flag-available --exclude=.cvs; then
- GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
-fi
+ if [[ -n "$GREP_OPTIONS" ]]; then
+ # export grep, egrep and fgrep settings
+ alias grep="grep $GREP_OPTIONS"
+ alias egrep="egrep $GREP_OPTIONS"
+ alias fgrep="fgrep $GREP_OPTIONS"
-# export grep settings
-alias grep="grep $GREP_OPTIONS"
+ # write to cache file if cache directory is writable
+ if [[ -w "$ZSH_CACHE_DIR" ]]; then
+ alias -L grep egrep fgrep >| "$__GREP_CACHE_FILE"
+ fi
+ fi
+
+ # Clean up
+ unset GREP_OPTIONS EXC_FOLDERS
+ unfunction grep-flags-available
+fi
-# clean up
-unset GREP_OPTIONS
-unset VCS_FOLDERS
-unfunction grep-flag-available
+unset __GREP_CACHE_FILE __GREP_ALIAS_CACHES
diff --git a/lib/history.zsh b/lib/history.zsh
index d8bbd41c4..794076904 100644
--- a/lib/history.zsh
+++ b/lib/history.zsh
@@ -6,18 +6,19 @@ function omz_history {
if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file
echo -n >| "$HISTFILE"
- echo >&2 History file deleted. Reload the session to see its effects.
+ fc -p "$HISTFILE"
+ echo >&2 History file deleted.
elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly
builtin fc "$@"
else
# unless a number is provided, show all history events (starting from 1)
- [[ ${@[-1]} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
+ [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
fi
}
# Timestamp format
-case $HIST_STAMPS in
+case ${HIST_STAMPS-} in
"mm/dd/yyyy") alias history='omz_history -f' ;;
"dd.mm.yyyy") alias history='omz_history -E' ;;
"yyyy-mm-dd") alias history='omz_history -i' ;;
@@ -27,8 +28,8 @@ esac
## History file configuration
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
-HISTSIZE=50000
-SAVEHIST=10000
+[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
+[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
## History command configuration
setopt extended_history # record timestamp of command in HISTFILE
@@ -36,5 +37,4 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
-setopt inc_append_history # add commands to HISTFILE in order of execution
setopt share_history # share command history data
diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
index 0e056dc72..aaa73046e 100644
--- a/lib/key-bindings.zsh
+++ b/lib/key-bindings.zsh
@@ -15,56 +15,101 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
zle -N zle-line-finish
fi
-bindkey -e # Use emacs key bindings
+# Use emacs key bindings
+bindkey -e
-bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
-bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
-bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
-if [[ "${terminfo[kpp]}" != "" ]]; then
- bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
+# [PageUp] - Up a line of history
+if [[ -n "${terminfo[kpp]}" ]]; then
+ bindkey -M emacs "${terminfo[kpp]}" up-line-or-history
+ bindkey -M viins "${terminfo[kpp]}" up-line-or-history
+ bindkey -M vicmd "${terminfo[kpp]}" up-line-or-history
fi
-if [[ "${terminfo[knp]}" != "" ]]; then
- bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
+# [PageDown] - Down a line of history
+if [[ -n "${terminfo[knp]}" ]]; then
+ bindkey -M emacs "${terminfo[knp]}" down-line-or-history
+ bindkey -M viins "${terminfo[knp]}" down-line-or-history
+ bindkey -M vicmd "${terminfo[knp]}" down-line-or-history
fi
-# start typing + [Up-Arrow] - fuzzy find history forward
-if [[ "${terminfo[kcuu1]}" != "" ]]; then
+# Start typing + [Up-Arrow] - fuzzy find history forward
+if [[ -n "${terminfo[kcuu1]}" ]]; then
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
- bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
+
+ bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
+ bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
+ bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
-# start typing + [Down-Arrow] - fuzzy find history backward
-if [[ "${terminfo[kcud1]}" != "" ]]; then
+# Start typing + [Down-Arrow] - fuzzy find history backward
+if [[ -n "${terminfo[kcud1]}" ]]; then
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
- bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
+
+ bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
+ bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
+ bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
fi
-if [[ "${terminfo[khome]}" != "" ]]; then
- bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
+# [Home] - Go to beginning of line
+if [[ -n "${terminfo[khome]}" ]]; then
+ bindkey -M emacs "${terminfo[khome]}" beginning-of-line
+ bindkey -M viins "${terminfo[khome]}" beginning-of-line
+ bindkey -M vicmd "${terminfo[khome]}" beginning-of-line
fi
-if [[ "${terminfo[kend]}" != "" ]]; then
- bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
+# [End] - Go to end of line
+if [[ -n "${terminfo[kend]}" ]]; then
+ bindkey -M emacs "${terminfo[kend]}" end-of-line
+ bindkey -M viins "${terminfo[kend]}" end-of-line
+ bindkey -M vicmd "${terminfo[kend]}" end-of-line
fi
-bindkey ' ' magic-space # [Space] - do history expansion
-
-bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
-bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
-
-if [[ "${terminfo[kcbt]}" != "" ]]; then
- bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
+# [Shift-Tab] - move through the completion menu backwards
+if [[ -n "${terminfo[kcbt]}" ]]; then
+ bindkey -M emacs "${terminfo[kcbt]}" reverse-menu-complete
+ bindkey -M viins "${terminfo[kcbt]}" reverse-menu-complete
+ bindkey -M vicmd "${terminfo[kcbt]}" reverse-menu-complete
fi
-bindkey '^?' backward-delete-char # [Backspace] - delete backward
-if [[ "${terminfo[kdch1]}" != "" ]]; then
- bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
+# [Backspace] - delete backward
+bindkey -M emacs '^?' backward-delete-char
+bindkey -M viins '^?' backward-delete-char
+bindkey -M vicmd '^?' backward-delete-char
+# [Delete] - delete forward
+if [[ -n "${terminfo[kdch1]}" ]]; then
+ bindkey -M emacs "${terminfo[kdch1]}" delete-char
+ bindkey -M viins "${terminfo[kdch1]}" delete-char
+ bindkey -M vicmd "${terminfo[kdch1]}" delete-char
else
- bindkey "^[[3~" delete-char
- bindkey "^[3;5~" delete-char
- bindkey "\e[3~" delete-char
+ bindkey -M emacs "^[[3~" delete-char
+ bindkey -M viins "^[[3~" delete-char
+ bindkey -M vicmd "^[[3~" delete-char
+
+ bindkey -M emacs "^[3;5~" delete-char
+ bindkey -M viins "^[3;5~" delete-char
+ bindkey -M vicmd "^[3;5~" delete-char
fi
+# [Ctrl-Delete] - delete whole forward-word
+bindkey -M emacs '^[[3;5~' kill-word
+bindkey -M viins '^[[3;5~' kill-word
+bindkey -M vicmd '^[[3;5~' kill-word
+
+# [Ctrl-RightArrow] - move forward one word
+bindkey -M emacs '^[[1;5C' forward-word
+bindkey -M viins '^[[1;5C' forward-word
+bindkey -M vicmd '^[[1;5C' forward-word
+# [Ctrl-LeftArrow] - move backward one word
+bindkey -M emacs '^[[1;5D' backward-word
+bindkey -M viins '^[[1;5D' backward-word
+bindkey -M vicmd '^[[1;5D' backward-word
+
+
+bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
+bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
+bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
+bindkey ' ' magic-space # [Space] - don't do history expansion
+
+
# Edit the current command line in $EDITOR
autoload -U edit-command-line
zle -N edit-command-line
diff --git a/lib/misc.zsh b/lib/misc.zsh
index f45c10757..a5d3af998 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -1,17 +1,17 @@
-## Load smart urls if available
-# bracketed-paste-magic is known buggy in zsh 5.1.1 (only), so skip it there; see #4434
autoload -Uz is-at-least
-if [[ $ZSH_VERSION != 5.1.1 ]]; then
+
+# *-magic is known buggy in some versions; disable if so
+if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
for d in $fpath; do
- if [[ -e "$d/url-quote-magic" ]]; then
- if is-at-least 5.1; then
- autoload -Uz bracketed-paste-magic
- zle -N bracketed-paste bracketed-paste-magic
- fi
- autoload -Uz url-quote-magic
- zle -N self-insert url-quote-magic
- break
- fi
+ if [[ -e "$d/url-quote-magic" ]]; then
+ if is-at-least 5.1; then
+ autoload -Uz bracketed-paste-magic
+ zle -N bracketed-paste bracketed-paste-magic
+ fi
+ autoload -Uz url-quote-magic
+ zle -N self-insert url-quote-magic
+ break
+ fi
done
fi
@@ -22,20 +22,14 @@ env_default 'PAGER' 'less'
env_default 'LESS' '-R'
## super user alias
-alias _='sudo'
-alias please='sudo'
+alias _='sudo '
## more intelligent acking for ubuntu users
-if which ack-grep &> /dev/null; then
+if (( $+commands[ack-grep] )); then
alias afind='ack-grep -il'
else
alias afind='ack -il'
fi
-# only define LC_CTYPE if undefined
-if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
- export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
-fi
-
# recognize comments
setopt interactivecomments
diff --git a/lib/nvm.zsh b/lib/nvm.zsh
index 4a8b6811e..2fe57a8f4 100644
--- a/lib/nvm.zsh
+++ b/lib/nvm.zsh
@@ -1,9 +1,6 @@
-# get the node.js version
+# get the nvm-controlled node.js version
function nvm_prompt_info() {
- [[ -f "$NVM_DIR/nvm.sh" ]] || return
- local nvm_prompt
- nvm_prompt=$(node -v 2>/dev/null)
- [[ "${nvm_prompt}x" == "x" ]] && return
- nvm_prompt=${nvm_prompt:1}
+ which nvm &>/dev/null || return
+ local nvm_prompt=${$(nvm current)#v}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
}
diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh
index 1d5c23e41..48f033da6 100644
--- a/lib/prompt_info_functions.zsh
+++ b/lib/prompt_info_functions.zsh
@@ -10,9 +10,16 @@
# Dummy implementations that return false to prevent command_not_found
# errors with themes, that implement these functions
# Real implementations will be used when the respective plugins are loaded
-function chruby_prompt_info hg_prompt_info pyenv_prompt_info \
- rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \
- virtualenv_prompt_info jenv_prompt_info {
+function chruby_prompt_info \
+ rbenv_prompt_info \
+ hg_prompt_info \
+ pyenv_prompt_info \
+ svn_prompt_info \
+ vi_mode_prompt_info \
+ virtualenv_prompt_info \
+ jenv_prompt_info \
+ tf_prompt_info \
+{
return 1
}
@@ -22,10 +29,13 @@ function rvm_prompt_info() {
[ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
- [[ "${rvm_prompt}x" == "x" ]] && return 1
- echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
+ [[ -z "${rvm_prompt}" ]] && return 1
+ echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
}
+ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
+
+
# use this to enable users to see their ruby version, no matter which
# version management system they use
function ruby_prompt_info() {
diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh
index 312ab2248..d5c22a8c5 100644
--- a/lib/spectrum.zsh
+++ b/lib/spectrum.zsh
@@ -1,4 +1,3 @@
-#! /bin/zsh
# A script to make using 256 colors in zsh less painful.
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
@@ -6,32 +5,31 @@
typeset -AHg FX FG BG
FX=(
- reset "%{%}"
- bold "%{%}" no-bold "%{%}"
- italic "%{%}" no-italic "%{%}"
- underline "%{%}" no-underline "%{%}"
- blink "%{%}" no-blink "%{%}"
- reverse "%{%}" no-reverse "%{%}"
+ reset "%{%}"
+ bold "%{%}" no-bold "%{%}"
+ italic "%{%}" no-italic "%{%}"
+ underline "%{%}" no-underline "%{%}"
+ blink "%{%}" no-blink "%{%}"
+ reverse "%{%}" no-reverse "%{%}"
)
for color in {000..255}; do
- FG[$color]="%{[38;5;${color}m%}"
- BG[$color]="%{[48;5;${color}m%}"
+ FG[$color]="%{[38;5;${color}m%}"
+ BG[$color]="%{[48;5;${color}m%}"
done
-
-ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
-
# Show all 256 colors with color number
function spectrum_ls() {
+ local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do
- print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
+ print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done
}
# Show all 256 colors where the background is set to specific color
function spectrum_bls() {
+ local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do
- print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
+ print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done
}
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 87d55ee89..33451ef1f 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -10,39 +10,39 @@ function title {
emulate -L zsh
setopt prompt_subst
- [[ "$EMACS" == *term* ]] && return
+ [[ "$INSIDE_EMACS" == *term* ]] && return
# if $2 is unset use $1 as default
# if it is set and empty, leave it as is
: ${2=$1}
case "$TERM" in
- cygwin|xterm*|putty*|rxvt*|ansi)
- print -Pn "\e]2;$2:q\a" # set window name
- print -Pn "\e]1;$1:q\a" # set tab name
+ cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
+ print -Pn "\e]2;${2:q}\a" # set window name
+ print -Pn "\e]1;${1:q}\a" # set tab name
;;
- screen*)
- print -Pn "\ek$1:q\e\\" # set screen hardstatus
+ screen*|tmux*)
+ print -Pn "\ek${1:q}\e\\" # set screen hardstatus
;;
*)
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
- print -Pn "\e]2;$2:q\a" # set window name
- print -Pn "\e]1;$1:q\a" # set tab name
+ print -Pn "\e]2;${2:q}\a" # set window name
+ print -Pn "\e]1;${1:q}\a" # set tab name
else
# Try to use terminfo to set the title
# If the feature is available set title
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
- echoti tsl
- print -Pn "$1"
- echoti fsl
- fi
+ echoti tsl
+ print -Pn "$1"
+ echoti fsl
+ fi
fi
;;
esac
}
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
-ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
+ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
# Avoid duplication of directory in terminals with independent dir display
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
@@ -50,22 +50,52 @@ fi
# Runs before showing the prompt
function omz_termsupport_precmd {
- emulate -L zsh
-
- if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
- return
- fi
-
+ [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
}
# Runs before executing the command
function omz_termsupport_preexec {
+ [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
+
emulate -L zsh
setopt extended_glob
- if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
- return
+ # split command into array of arguments
+ local -a cmdargs
+ cmdargs=("${(z)2}")
+ # if running fg, extract the command from the job description
+ if [[ "${cmdargs[1]}" = fg ]]; then
+ # get the job id from the first argument passed to the fg command
+ local job_id jobspec="${cmdargs[2]#%}"
+ # logic based on jobs arguments:
+ # http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
+ # https://www.zsh.org/mla/users/2007/msg00704.html
+ case "$jobspec" in
+ <->) # %number argument:
+ # use the same <number> passed as an argument
+ job_id=${jobspec} ;;
+ ""|%|+) # empty, %% or %+ argument:
+ # use the current job, which appears with a + in $jobstates:
+ # suspended:+:5071=suspended (tty output)
+ job_id=${(k)jobstates[(r)*:+:*]} ;;
+ -) # %- argument:
+ # use the previous job, which appears with a - in $jobstates:
+ # suspended:-:6493=suspended (signal)
+ job_id=${(k)jobstates[(r)*:-:*]} ;;
+ [?]*) # %?string argument:
+ # use $jobtexts to match for a job whose command *contains* <string>
+ job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
+ *) # %string argument:
+ # use $jobtexts to match for a job whose command *starts with* <string>
+ job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
+ esac
+
+ # override preexec function arguments with job command
+ if [[ -n "${jobtexts[$job_id]}" ]]; then
+ 1="${jobtexts[$job_id]}"
+ 2="${jobtexts[$job_id]}"
+ fi
fi
# cmd name only, or if this is sudo or ssh, the next cmd
@@ -75,8 +105,9 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<'
}
-precmd_functions+=(omz_termsupport_precmd)
-preexec_functions+=(omz_termsupport_preexec)
+autoload -U add-zsh-hook
+add-zsh-hook precmd omz_termsupport_precmd
+add-zsh-hook preexec omz_termsupport_preexec
# Keep Apple Terminal.app's current working directory updated
@@ -90,16 +121,17 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
function update_terminalapp_cwd() {
emulate -L zsh
- # Percent-encode the pathname.
- local URL_PATH="$(omz_urlencode -P $PWD)"
- [[ $? != 0 ]] && return 1
+ # Percent-encode the host and path names.
+ local URL_HOST URL_PATH
+ URL_HOST="$(omz_urlencode -P $HOST)" || return 1
+ URL_PATH="$(omz_urlencode -P $PWD)" || return 1
# Undocumented Terminal.app-specific control sequence
- printf '\e]7;%s\a' "file://$HOST$URL_PATH"
+ printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH"
}
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
- precmd_functions+=(update_terminalapp_cwd)
+ add-zsh-hook precmd update_terminalapp_cwd
# Run once to get initial cwd set
update_terminalapp_cwd
fi
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index 96f34aa81..0b71de372 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -19,7 +19,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
# coreutils, so prefer it to "gls".
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
colorls -G -d . &>/dev/null && alias ls='colorls -G'
- elif [[ "$OSTYPE" == darwin* ]]; then
+ elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then
# this is a good alias, it works by default just using $LSCOLORS
ls -G . &>/dev/null && alias ls='ls -G'
@@ -39,17 +39,21 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
fi
fi
+# enable diff color if possible.
+if command diff --color . . &>/dev/null; then
+ alias diff='diff --color'
+fi
+
setopt auto_cd
setopt multios
setopt prompt_subst
[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
-# Apply theming defaults
-PS1="%n@%m:%~%# "
-
# git theming default: Variables for theming the git info prompt
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
+ZSH_THEME_RUBY_PROMPT_PREFIX="("
+ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index d7c68d35c..16e244be5 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -1,17 +1,15 @@
+# If ZSH is not defined, use the current script's directory.
+[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
+
# Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/
if [[ -z "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="$ZSH/cache"
fi
-# Migrate .zsh-update file to $ZSH_CACHE_DIR
-if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then
- mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update
-fi
-
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
- env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
+ source $ZSH/tools/check_for_upgrade.sh
fi
# Initializes Oh My Zsh
@@ -29,21 +27,13 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
fi
-# Load all of the config files in ~/oh-my-zsh that end in .zsh
-# TIP: Add files you don't want in git to .gitignore
-for config_file ($ZSH/lib/*.zsh); do
- custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
- [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
- source $config_file
-done
-
-
is_plugin() {
local base_dir=$1
local name=$2
- test -f $base_dir/plugins/$name/$name.plugin.zsh \
- || test -f $base_dir/plugins/$name/_$name
+ builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
+ || builtin test -f $base_dir/plugins/$name/_$name
}
+
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
@@ -51,6 +41,8 @@ for plugin ($plugins); do
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
+ else
+ echo "[oh-my-zsh] plugin '$plugin' not found"
fi
done
@@ -67,18 +59,50 @@ if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi
+# Construct zcompdump OMZ metadata
+zcompdump_revision="#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
+zcompdump_fpath="#omz fpath: $fpath"
+
+# Delete the zcompdump file if OMZ zcompdump metadata changed
+if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
+ || ! command grep -q -Fx "$zcompdump_fpath" "$ZSH_COMPDUMP" 2>/dev/null; then
+ command rm -f "$ZSH_COMPDUMP"
+ zcompdump_refresh=1
+fi
+
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
+ source $ZSH/lib/compfix.zsh
# If completion insecurities exist, warn the user
- if ! compaudit &>/dev/null; then
- handle_completion_insecurities
- fi
+ handle_completion_insecurities
# Load only from secure directories
- compinit -i -d "${ZSH_COMPDUMP}"
+ compinit -i -C -d "${ZSH_COMPDUMP}"
else
# If the user wants it, load from all found directories
- compinit -u -d "${ZSH_COMPDUMP}"
+ compinit -u -C -d "${ZSH_COMPDUMP}"
+fi
+
+# Append zcompdump metadata if missing
+if (( $zcompdump_refresh )); then
+ # Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
+ # See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
+ tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
+
+$zcompdump_revision
+$zcompdump_fpath
+EOF
fi
+unset zcompdump_revision zcompdump_fpath zcompdump_refresh
+
+
+# Load all of the config files in ~/oh-my-zsh that end in .zsh
+# TIP: Add files you don't want in git to .gitignore
+for config_file ($ZSH/lib/*.zsh); do
+ custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
+ [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
+ source $config_file
+done
+
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
@@ -95,25 +119,12 @@ done
unset config_file
# Load the theme
-if [[ "$ZSH_THEME" == "random" ]]; then
- if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
- themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
+if [ ! "$ZSH_THEME" = "" ]; then
+ if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
+ source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
+ elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
+ source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
- themes=($ZSH/themes/*zsh-theme)
- fi
- N=${#themes[@]}
- ((N=(RANDOM%N)+1))
- RANDOM_THEME=${themes[$N]}
- source "$RANDOM_THEME"
- echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
-else
- if [ ! "$ZSH_THEME" = "" ]; then
- if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
- source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
- elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
- source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
- else
- source "$ZSH/themes/$ZSH_THEME.zsh-theme"
- fi
+ source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi
diff --git a/plugins/adb/_adb b/plugins/adb/_adb
index e3c20d751..78c457746 100644
--- a/plugins/adb/_adb
+++ b/plugins/adb/_adb
@@ -49,7 +49,12 @@ _arguments \
case "$state" in
specify_device)
_values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \
- {sub(/ +/," ",$0);gsub(":","\\:",$1); printf "%s[%s] ",$1, $NF}'):-""}
+ {sub(/ +/," ",$0); \
+ gsub(":","\\:",$1); \
+ for(i=1;i<=NF;i++) {
+ if($i ~ /model:/) { split($i,m,":") } \
+ else if($i ~ /product:/) { split($i,p,":") } } \
+ printf "%s[%s(%s)] ",$1, p[2], m[2]}'):-""}
return
;;
esac
@@ -59,4 +64,4 @@ if (( CURRENT == 1 )); then
return
fi
-_files \ No newline at end of file
+_files
diff --git a/plugins/alias-finder/README.md b/plugins/alias-finder/README.md
new file mode 100644
index 000000000..409f4b653
--- /dev/null
+++ b/plugins/alias-finder/README.md
@@ -0,0 +1,46 @@
+# alias-finder plugin
+
+This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
+
+To use it, add `alias-finder` to the `plugins` array of your zshrc file:
+```
+plugins=(... alias-finder)
+```
+
+## Usage
+To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this.
+
+## Options
+
+- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input).
+- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input.
+
+## Examples
+```
+$ alias-finder "git pull"
+gl='git pull'
+g=git
+```
+```
+$ alias-finder "web_search google oh my zsh"
+google='web_search google'
+```
+```
+$ alias-finder "git commit -v"
+gc="git commit -v"
+g=git
+```
+```
+$ alias-finder -e "git commit -v"
+gc='git commit -v'
+```
+```
+$ alias-finder -l "git commit -v"
+gc='git commit -v'
+'gc!'='git commit -v --amend'
+gca='git commit -v -a'
+'gca!'='git commit -v -a --amend'
+'gcan!'='git commit -v -a --no-edit --amend'
+'gcans!'='git commit -v -a -s --no-edit --amend'
+'gcn!'='git commit -v --no-edit --amend'
+```
diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh
new file mode 100644
index 000000000..caee9b5a3
--- /dev/null
+++ b/plugins/alias-finder/alias-finder.plugin.zsh
@@ -0,0 +1,47 @@
+alias-finder() {
+ local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd=""
+ for i in $@; do
+ case $i in
+ -e|--exact) exact=true;;
+ -l|--longer) longer=true;;
+ *)
+ if [[ -z $cmd ]]; then
+ cmd=$i
+ else
+ cmd="$cmd $i"
+ fi
+ ;;
+ esac
+ done
+ cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
+ if (( $(wc -l <<< $cmd) == 1 )); then
+ while [[ $cmd != "" ]]; do
+ if [[ $longer = true ]]; then
+ wordStart="'{0,1}"
+ else
+ wordEnd="$"
+ multiWordEnd="'$"
+ fi
+ if [[ $cmd == *" "* ]]; then
+ local finder="'$cmd$multiWordEnd"
+ else
+ local finder=$wordStart$cmd$wordEnd
+ fi
+ alias | grep -E "=$finder"
+ if [[ $exact = true || $longer = true ]]; then
+ break
+ else
+ cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word
+ fi
+ done
+ fi
+}
+
+preexec_alias-finder() {
+ if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
+ alias-finder $1
+ fi
+}
+
+autoload -U add-zsh-hook
+add-zsh-hook preexec preexec_alias-finder
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/README.md b/plugins/ansible/README.md
new file mode 100644
index 000000000..e0e6a19bb
--- /dev/null
+++ b/plugins/ansible/README.md
@@ -0,0 +1,34 @@
+# ansible plugin
+
+## Introduction
+
+The `ansible plugin` adds several aliases for useful [ansible](https://docs.ansible.com/ansible/latest/index.html) commands and [aliases](#aliases).
+
+To use it, add `ansible` to the plugins array of your zshrc file:
+
+```
+plugins=(... ansible)
+```
+
+## Aliases
+
+| Command | Description |
+|:-------------------------------------------|:--------------------------------------------------------------------|
+| `ansible-version` / `aver` | Show the version on ansible installed in this host |
+| `ansible-role-init <role name>` / `arinit` | Creates the Ansible Role as per Ansible Galaxy standard |
+| `a` | command `ansible` |
+| `aconf` | command `ansible-config` |
+| `acon` | command `ansible-console` |
+| `ainv` | command `ansible-inventory` |
+| `aplaybook` | command `ansible-playbook` |
+| `ainv` | command `ansible-inventory` |
+| `adoc` | command `ansible-doc` |
+| `agal` | command `ansible-galaxy` |
+| `apull` | command `ansible-pull` |
+| `aval` | command `ansible-vault` |
+
+## Maintainer
+
+### [Deepankumar](https://github.com/deepan10)
+
+[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin)
diff --git a/plugins/ansible/ansible.plugin.zsh b/plugins/ansible/ansible.plugin.zsh
new file mode 100644
index 000000000..75393b704
--- /dev/null
+++ b/plugins/ansible/ansible.plugin.zsh
@@ -0,0 +1,28 @@
+# Functions
+function ansible-version(){
+ ansible --version
+}
+
+function ansible-role-init(){
+ if ! [ -z $1 ] ; then
+ echo "Ansible Role : $1 Creating...."
+ ansible-galaxy init $1
+ tree $1
+ else
+ echo "Usage : ansible-role-init <role name>"
+ echo "Example : ansible-role-init role1"
+ fi
+}
+
+# Alias
+alias a='ansible '
+alias aconf='ansible-config '
+alias acon='ansible-console '
+alias aver='ansible-version'
+alias arinit='ansible-role-init'
+alias aplaybook='ansible-playbook '
+alias ainv='ansible-inventory '
+alias adoc='ansible-doc '
+alias agal='ansible-galaxy '
+alias apull='ansible-pull '
+alias aval='ansible-vault'
diff --git a/plugins/apache2-macports/README.md b/plugins/apache2-macports/README.md
index 099fc8da3..dbf2e89a2 100644
--- a/plugins/apache2-macports/README.md
+++ b/plugins/apache2-macports/README.md
@@ -1,19 +1,21 @@
-## APACHE2 MACPORTS PLUGIN
+# apache2-macports plugin
+Enables aliases to control a local Apache2 installed via [MacPorts](https://www.macports.org/).
----
+To use it, add `apache2-macports` to the plugins array in your zshrc file:
-### FEATURES
+```zsh
+plugins=(... apache2-macports)
+```
-| Alias | Function | Description |
-|:--------------:|:-------------------------------------------------------------------------------|----------------------:|
-| apache2restart | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart | Restart apache daemon |
-| apache2start | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start | Start apache daemon |
-| apache2stop | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop | Stop apache daemon |
+## Aliases
----
+| Alias | Function | Description |
+|----------------|-----------------------------------------|-----------------------|
+| apache2restart | `sudo /path/to/apache2.wrapper restart` | Restart apache daemon |
+| apache2start | `sudo /path/to/apache2.wrapper start` | Start apache daemon |
+| apache2stop | `sudo /path/to/apache2.wrapper stop` | Stop apache daemon |
-### CONTRIBUTORS
- - Alexander Rinass (alex@rinass.net)
+## Contributors
----
+- Alexander Rinass (alex@rinass.net)
diff --git a/plugins/arcanist/README.md b/plugins/arcanist/README.md
index 4bb8c8090..f49e4344b 100644
--- a/plugins/arcanist/README.md
+++ b/plugins/arcanist/README.md
@@ -1,5 +1,41 @@
## arcanist
-**Maintainer:** [@emzar](https://github.com/emzar)
+This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
-This plugin adds many useful aliases.
+To use it, add `arcanist` to the plugins array of your zshrc file:
+
+```zsh
+plugins=(... arcanist)
+```
+
+## Aliases
+
+| Alias | Command |
+| ------- | ---------------------------------- |
+| ara | `arc amend` |
+| arb | `arc branch` |
+| arco | `arc cover` |
+| arci | `arc commit` |
+| ard | `arc diff` |
+| ardc | `arc diff --create` |
+| ardp | `arc diff --preview` |
+| ardnu | `arc diff --nounit` |
+| ardnupc | `arc diff --nounit --plan-changes` |
+| ardpc | `arc diff --plan-changes` |
+| are | `arc export` |
+| arh | `arc help` |
+| arl | `arc land` |
+| arli | `arc lint` |
+| arls | `arc list` |
+| arpa | `arc patch` |
+
+## Functions
+
+The following functions make copy pasting revision ids from the URL bar of your browser
+easier, as they allow for copy pasting the whole URL. For example: `ardu` accepts
+both `https://arcanist-url.com/<REVISION>` as well as `<REVISION>`.
+
+| Function | Command |
+| ------------------------- | --------------------------------- |
+| ardu [URL or revision_id] | `arc diff --update` [revision_id] |
+| arpa [URL or revision_id] | `arc patch` [revision_id] |
diff --git a/plugins/arcanist/arcanist.plugin.zsh b/plugins/arcanist/arcanist.plugin.zsh
index 3f4eb07f4..88e6713e4 100644
--- a/plugins/arcanist/arcanist.plugin.zsh
+++ b/plugins/arcanist/arcanist.plugin.zsh
@@ -9,13 +9,29 @@ alias arco='arc cover'
alias arci='arc commit'
alias ard='arc diff'
+alias ardc='arc diff --create'
alias ardnu='arc diff --nounit'
alias ardnupc='arc diff --nounit --plan-changes'
alias ardpc='arc diff --plan-changes'
+alias ardp='arc diff --preview' # creates a new diff in the phab interface
alias are='arc export'
alias arh='arc help'
alias arl='arc land'
alias arli='arc lint'
alias arls='arc list'
-alias arpa='arc patch'
+
+#
+# Functions
+# (sorted alphabetically)
+#
+
+ardu() {
+ # Both `ardu https://arcanist-url.com/<REVISION>`, and `ardu <REVISION>` work.
+ arc diff --update "${1:t}"
+}
+
+arpa() {
+ # Both `arpa https://arcanist-url.com/<REVISION>`, and `arpa <REVISION>` work.
+ arc patch "${1:t}"
+}
diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md
index 7ebe8e53d..d6b41ee40 100644
--- a/plugins/archlinux/README.md
+++ b/plugins/archlinux/README.md
@@ -1,146 +1,198 @@
-# Archlinux plugin
+# Arch Linux plugin
+
+This plugin adds some aliases and functions to work with Arch Linux.
+
+To use it, add `archlinux` to the plugins array in your zshrc file:
+
+```zsh
+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 yaourt |
-| 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 -Fs | 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[²](#f2) | `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[²](#f2) | `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[²](#f2) | `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[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages |
+
+#### Yaourt[¹](#f1)
+
+| 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` | Update and refresh local package, ABS and AUR databases |
+| 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[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
+
+#### Yay[¹](#f1)
+
+| 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[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages |
---
+<span id="f1">¹</span>
+Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
+
+<span id="f2">²</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. `yaourt`
+3. `trizen`
+4. `pacaur`
+5. `aura`
+6. `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 e0101c7eb..c94fb8f6c 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'
@@ -149,36 +17,27 @@ alias pacmir='sudo pacman -Syy'
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
alias pacfileupg='sudo pacman -Fy'
-alias pacfiles='pacman -Fs'
+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,135 @@ function pacmansignkeys() {
if (( $+commands[xdg-open] )); then
function pacweb() {
- pkg="$1"
- infos="$(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[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'
+ alias yaupd="yaourt -Sy"
+ alias upgrade='yaourt -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/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh
index 75395c718..c386d57ed 100644
--- a/plugins/asdf/asdf.plugin.zsh
+++ b/plugins/asdf/asdf.plugin.zsh
@@ -1,9 +1,11 @@
# Find where asdf should be installed
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
+ASDF_COMPLETIONS="$ASDF_DIR/completions"
# If not found, check for Homebrew package
-if [[ ! -d $ASDF_DIR ]] && (( $+commands[brew] )); then
+if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
ASDF_DIR="$(brew --prefix asdf)"
+ ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
fi
# Load command
@@ -11,7 +13,7 @@ if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
. "$ASDF_DIR/asdf.sh"
# Load completions
- if [[ -f "$ASDF_DIR/completions/asdf.bash" ]]; then
- . "$ASDF_DIR/completions/asdf.bash"
+ if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
+ . "$ASDF_COMPLETIONS/asdf.bash"
fi
fi
diff --git a/plugins/autoenv/README.md b/plugins/autoenv/README.md
new file mode 100644
index 000000000..5dfb5fbe8
--- /dev/null
+++ b/plugins/autoenv/README.md
@@ -0,0 +1,20 @@
+# Autoenv plugin
+
+This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
+
+To use it, add `autoenv` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... autoenv)
+```
+
+## Functions
+
+* `use_env()`: creates and/or activates a virtualenv. For use in `.env` files.
+ See the source code for details.
+
+## Requirements
+
+In order to make this work, you will need to have the autoenv installed.
+
+More info on the usage and install at [the project's homepage](https://github.com/inishchith/autoenv).
diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
index 3c1b0fafc..bd03cf4b2 100644
--- a/plugins/autoenv/autoenv.plugin.zsh
+++ b/plugins/autoenv/autoenv.plugin.zsh
@@ -1,12 +1,39 @@
-# Activates autoenv or reports its failure
+# Initialization: activate autoenv or report its absence
() {
+local d autoenv_dir install_locations
if ! type autoenv_init >/dev/null; then
- for d (~/.autoenv ~/.local/bin /usr/local/opt/autoenv /usr/local/bin); do
+ # Check if activate.sh is in $PATH
+ if (( $+commands[activate.sh] )); then
+ autoenv_dir="${commands[activate.sh]:h}"
+ fi
+
+ # Locate autoenv installation
+ if [[ -z $autoenv_dir ]]; then
+ install_locations=(
+ ~/.autoenv
+ ~/.local/bin
+ /usr/local/opt/autoenv
+ /usr/local/bin
+ /usr/share/autoenv-git
+ ~/Library/Python/bin
+ )
+ for d ( $install_locations ); do
+ if [[ -e $d/activate.sh ]]; then
+ autoenv_dir=$d
+ break
+ fi
+ done
+ fi
+
+ # Look for Homebrew path as a last resort
+ if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
+ d=$(brew --prefix)/opt/autoenv
if [[ -e $d/activate.sh ]]; then
autoenv_dir=$d
- break
fi
- done
+ fi
+
+ # Complain if autoenv is not installed
if [[ -z $autoenv_dir ]]; then
cat <<END >&2
-------- AUTOENV ---------
@@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED.
END
return 1
fi
+ # Load autoenv
source $autoenv_dir/activate.sh
fi
}
@@ -27,17 +55,17 @@ fi
# It only performs an action if the requested virtualenv is not the current one.
use_env() {
- typeset venv
- venv="$1"
- if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
- if workon | grep -q "$venv"; then
- workon "$venv"
- else
- echo -n "Create virtualenv $venv now? (Yn) "
- read answer
- if [[ "$answer" == "Y" ]]; then
- mkvirtualenv "$venv"
- fi
- fi
+ local venv
+ venv="$1"
+ if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
+ if workon | grep -q "$venv"; then
+ workon "$venv"
+ else
+ echo -n "Create virtualenv $venv now? (Yn) "
+ read answer
+ if [[ "$answer" == "Y" ]]; then
+ mkvirtualenv "$venv"
+ fi
fi
+ fi
}
diff --git a/plugins/autojump/README.md b/plugins/autojump/README.md
index 18ff793cd..750ff56d1 100644
--- a/plugins/autojump/README.md
+++ b/plugins/autojump/README.md
@@ -8,4 +8,4 @@ To use it, add `autojump` to the plugins array in your zshrc file:
plugins=(... autojump)
```
-More info on the usage: https://github.com/wting/autojump
+**Note:** you have to [install autojump](https://github.com/wting/autojump#installation) first.
diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh
index c0af67631..f40b0e931 100644
--- a/plugins/autojump/autojump.plugin.zsh
+++ b/plugins/autojump/autojump.plugin.zsh
@@ -1,23 +1,34 @@
-if [ $commands[autojump] ]; then # check if autojump is installed
- if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
- . $HOME/.autojump/etc/profile.d/autojump.zsh
- elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation
- . $HOME/.autojump/share/autojump/autojump.zsh
- elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation
- . $HOME/.nix-profile/etc/profile.d/autojump.zsh
- elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation
- . /run/current-system/sw/share/autojump/autojump.zsh
- elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
- . /usr/share/autojump/autojump.zsh
- elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
- . /etc/profile.d/autojump.zsh
- elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation
- . /etc/profile.d/autojump.sh
- elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation
- . /usr/local/share/autojump/autojump.zsh
- elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports
- . /opt/local/etc/profile.d/autojump.sh
- elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew
- . `brew --prefix`/etc/autojump.sh
+declare -a autojump_paths
+autojump_paths=(
+ $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
+ $HOME/.autojump/share/autojump/autojump.zsh # manual installation
+ $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
+ /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
+ /usr/share/autojump/autojump.zsh # Debian and Ubuntu package
+ /etc/profile.d/autojump.zsh # manual installation
+ /etc/profile.d/autojump.sh # Gentoo installation
+ /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)
+)
+
+for file in $autojump_paths; do
+ if [[ -f "$file" ]]; then
+ source "$file"
+ found=1
+ break
+ fi
+done
+
+# if no path found, try Homebrew
+if (( ! found && $+commands[brew] )); then
+ file=$(brew --prefix)/etc/profile.d/autojump.sh
+ if [[ -f "$file" ]]; then
+ source "$file"
+ found=1
fi
fi
+
+(( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.'
+
+unset autojump_paths file found
diff --git a/plugins/aws/README.md b/plugins/aws/README.md
index 8a45199b8..011bbd8b4 100644
--- a/plugins/aws/README.md
+++ b/plugins/aws/README.md
@@ -1,8 +1,7 @@
# aws
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
-and a few utilities to manage AWS profiles: a function to change profiles with autocompletion support
-and a function to get the current AWS profile. The current AWS profile is also displayed in `RPROMPT`.
+and a few utilities to manage AWS profiles and display them in the prompt.
To use it, add `aws` to the plugins array in your zshrc file.
@@ -12,9 +11,65 @@ plugins=(... aws)
## Plugin commands
-* `asp <profile>`: Sets `AWS_PROFILE` and `AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
-It also adds it to your RPROMPT.
+* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
+ It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
+ Run `asp` without arguments to clear the profile.
-* `agp`: Gets the current value of `AWS_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.
-* `aws_profiles`: Lists the available profiles in the file referenced in `AWS_CONFIG_FILE` (default: ~/.aws/config). Used to provide completion for the `asp` function.
+* `agp`: gets the current value of `$AWS_PROFILE`.
+
+* `aws_change_access_key`: changes the AWS access key of a profile.
+
+* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
+ Used to provide completion for the `asp` function.
+
+## Plugin options
+
+* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
+ Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
+ see the AWS profile prompt.
+
+## Theme
+
+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_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
+
+### 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 f78e96ce3..e1566b113 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -1,49 +1,206 @@
-_homebrew-installed() {
- type brew &> /dev/null
- _xit=$?
- if [ $_xit -eq 0 ];then
- # ok , we have brew installed
- # speculatively we check default brew prefix
- if [ -h /usr/local/opt/awscli ];then
- _brew_prefix="/usr/local/opt/awscli"
- else
- # ok , it is not default prefix
- # this call to brew is expensive ( about 400 ms ), so at least let's make it only once
- _brew_prefix=$(brew --prefix awscli)
- fi
- return 0
- else
- return $_xit
- fi
+function agp() {
+ echo $AWS_PROFILE
}
-_awscli-homebrew-installed() {
- [ -r $_brew_prefix/libexec/bin/aws_zsh_completer.sh ] &> /dev/null
+# AWS profile selection
+function asp() {
+ if [[ -z "$1" ]]; then
+ unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
+ 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
+
+ export AWS_DEFAULT_PROFILE=$1
+ export AWS_PROFILE=$1
+ export AWS_EB_PROFILE=$1
}
-function agp {
- echo $AWS_PROFILE
+# 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}")
+
+ # 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
+ 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 asp {
- local rprompt=${RPROMPT/<aws:$(agp)>/}
+function aws_change_access_key() {
+ if [[ -z "$1" ]]; then
+ echo "usage: $0 <profile>"
+ return 1
+ fi
- export AWS_DEFAULT_PROFILE=$1
- export AWS_PROFILE=$1
+ 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:"
+ AWS_PAGER="" aws iam list-access-keys
+}
- export RPROMPT="<aws:$AWS_PROFILE>$rprompt"
+function aws_profiles() {
+ [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 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=($(grep profile "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'))
+function _aws_profiles() {
+ reply=($(aws_profiles))
}
-compctl -K aws_profiles asp
+compctl -K _aws_profiles asp acp aws_change_access_key
-if which aws_zsh_completer.sh &>/dev/null; then
- _aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null)
-elif _homebrew-installed && _awscli-homebrew-installed; then
- _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
+# AWS prompt
+function aws_prompt_info() {
+ [[ -z $AWS_PROFILE ]] && return
+ echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
+}
+
+if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
+ RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi
-[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
-unset _aws_zsh_completer_path
+
+# Load awscli completions
+
+# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
+if command -v aws_completer &> /dev/null; then
+ autoload -Uz bashcompinit && bashcompinit
+ complete -C aws_completer aws
+else
+ function _awscli-homebrew-installed() {
+ # check if Homebrew is installed
+ (( $+commands[brew] )) || return 1
+
+ # speculatively check default brew prefix
+ if [ -h /usr/local/opt/awscli ]; then
+ _brew_prefix=/usr/local/opt/awscli
+ else
+ # ok, it is not in the default prefix
+ # this call to brew is expensive (about 400 ms), so at least let's make it only once
+ _brew_prefix=$(brew --prefix awscli)
+ fi
+ }
+
+ # get aws_zsh_completer.sh location from $PATH
+ _aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
+
+ # otherwise check common locations
+ if [[ -z $_aws_zsh_completer_path ]]; then
+ # Homebrew
+ if _awscli-homebrew-installed; then
+ _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
+ # Ubuntu
+ elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
+ _aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
+ # NixOS
+ elif [[ -e "${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh" ]]; then
+ _aws_zsh_completer_path="${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh"
+ # RPM
+ else
+ _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
+ fi
+ fi
+
+ [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
+ unset _aws_zsh_completer_path _brew_prefix
+fi
diff --git a/plugins/battery/README.md b/plugins/battery/README.md
index b7a13a7ec..c2554a36d 100644
--- a/plugins/battery/README.md
+++ b/plugins/battery/README.md
@@ -9,5 +9,14 @@ 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:
```
-RPROMPT='$(battery_pct_prompt)'
+RPROMPT='$(battery_pct_prompt) ...'
+```
+
+## Requirements
+
+On Linux, you must have the `acpi` tool installed on your operating system.
+
+Here's an example of how to install with apt:
+```
+sudo apt-get install acpi
```
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index 8f398cfb3..a525fd7da 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -7,23 +7,22 @@
# Email: neuralsandwich@gmail.com #
# Modified to add support for Apple Mac #
###########################################
+# Author: J (927589452) #
+# Modified to add support for FreeBSD #
+###########################################
-if [[ "$OSTYPE" = darwin* ]] ; then
+if [[ "$OSTYPE" = darwin* ]]; then
- function battery_pct() {
- local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
- typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
- typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
- integer i=$(((currentcapacity/maxcapacity) * 100))
- echo $i
+ function battery_is_charging() {
+ ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
- function plugged_in() {
- [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ]
+ function battery_pct() {
+ pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
function battery_pct_remaining() {
- if plugged_in ; then
+ if battery_is_charging; then
echo "External Power"
else
battery_pct
@@ -32,9 +31,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then
function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
- if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
- timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
- if [ $timeremaining -gt 720 ] ; then
+ if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
+ timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
+ if [ $timeremaining -gt 720 ]; then
echo "::"
else
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
@@ -45,39 +44,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then
}
function battery_pct_prompt () {
- if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
- b=$(battery_pct_remaining)
- if [ $b -gt 50 ] ; then
+ local battery_pct color
+ if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
+ battery_pct=$(battery_pct_remaining)
+ if [[ $battery_pct -gt 50 ]]; then
color='green'
- elif [ $b -gt 20 ] ; then
+ elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
- echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
+ echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else
echo "∞"
fi
}
- function battery_is_charging() {
- [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
- }
-
-elif [[ "$OSTYPE" = linux* ]] ; then
+elif [[ "$OSTYPE" = freebsd* ]]; then
function battery_is_charging() {
- ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
+ [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
}
function battery_pct() {
- if (( $+commands[acpi] )) ; then
- echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
+ if (( $+commands[sysctl] )); then
+ sysctl -n hw.acpi.battery.life
fi
}
function battery_pct_remaining() {
- if [ ! $(battery_is_charging) ] ; then
+ if ! battery_is_charging; then
battery_pct
else
echo "External Power"
@@ -85,76 +81,128 @@ elif [[ "$OSTYPE" = linux* ]] ; then
}
function battery_time_remaining() {
- if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
- echo $(acpi 2>/dev/null | cut -f3 -d ',')
+ local remaining_time
+ remaining_time=$(sysctl -n hw.acpi.battery.time)
+ if [[ $remaining_time -ge 0 ]]; then
+ ((hour = $remaining_time / 60 ))
+ ((minute = $remaining_time % 60 ))
+ printf %02d:%02d $hour $minute
fi
}
function battery_pct_prompt() {
- b=$(battery_pct_remaining)
- if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
- if [ $b -gt 50 ] ; then
+ 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 [ $b -gt 20 ] ; then
+ elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
- echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
- else
- echo "∞"
+ 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'
+ }
+
+ 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:]'
fi
}
-else
- # Empty functions so we don't cause errors in prompts
function battery_pct_remaining() {
+ if ! battery_is_charging; then
+ battery_pct
+ else
+ 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)
+ 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
}
+
+else
+ # Empty functions so we don't cause errors in prompts
+ function battery_is_charging { false }
+ function battery_pct \
+ battery_pct_remaining \
+ battery_time_remaining \
+ battery_pct_prompt { }
fi
function battery_level_gauge() {
- local gauge_slots=${BATTERY_GAUGE_SLOTS:-10};
- local green_threshold=${BATTERY_GREEN_THRESHOLD:-6};
- local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4};
- local color_green=${BATTERY_COLOR_GREEN:-%F{green}};
- local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}};
- local color_red=${BATTERY_COLOR_RED:-%F{red}};
- local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}};
- local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['};
- local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'};
- local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'};
- local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'};
- local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow};
- local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'};
-
- local battery_remaining_percentage=$(battery_pct);
+ local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
+ local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
+ local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
+ local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
+ local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
+ local color_red=${BATTERY_COLOR_RED:-%F{red}}
+ local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
+ local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
+ local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
+ local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
+ local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
+ local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
+ local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
+
+ local battery_remaining_percentage=$(battery_pct)
+ local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
- local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots)));
- local empty=$(($gauge_slots - $filled));
+ filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
+ empty=$(( $gauge_slots - $filled ))
- if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green;
- elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow;
- else local gauge_color=$color_red;
+ if [[ $filled -gt $green_threshold ]]; then
+ gauge_color=$color_green
+ elif [[ $filled -gt $yellow_threshold ]]; then
+ gauge_color=$color_yellow
+ else
+ gauge_color=$color_red
fi
else
- local filled=$gauge_slots;
- local empty=0;
- filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'};
+ filled=$gauge_slots
+ empty=0
+ filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
fi
- local charging=' ' && battery_is_charging && charging=$charging_symbol;
+ local charging=' '
+ battery_is_charging && charging=$charging_symbol
- printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%}
- printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
+ # Charging status and prefix
+ print -n ${charging_color}${charging}${color_reset}${battery_prefix}${gauge_color}
+ # Filled slots
+ [[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
+ # Empty slots
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
- printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%}
+ # Suffix
+ print -n ${color_reset}${battery_suffix}${color_reset}
}
-
-
diff --git a/plugins/bazel/README.md b/plugins/bazel/README.md
new file mode 100644
index 000000000..e5ffe6ea1
--- /dev/null
+++ b/plugins/bazel/README.md
@@ -0,0 +1,5 @@
+## Bazel autocomplete plugin
+
+A copy of the completion script from the
+[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel)
+git repo.
diff --git a/plugins/bazel/_bazel b/plugins/bazel/_bazel
new file mode 100644
index 000000000..827ce545c
--- /dev/null
+++ b/plugins/bazel/_bazel
@@ -0,0 +1,341 @@
+#compdef bazel
+
+# Copyright 2015 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Installation
+# ------------
+#
+# 1. Add this script to a directory on your $fpath:
+# fpath[1,0]=~/.zsh/completion/
+# mkdir -p ~/.zsh/completion/
+# cp scripts/zsh_completion/_bazel ~/.zsh/completion
+#
+# 2. Optionally, add the following to your .zshrc.
+# zstyle ':completion:*' use-cache on
+# zstyle ':completion:*' cache-path ~/.zsh/cache
+#
+# This way, the completion script does not have to parse Bazel's options
+# repeatedly. The directory in cache-path must be created manually.
+#
+# 3. Restart the shell
+#
+# Options
+# -------
+# completion:init:bazel:* cache-lifetime
+# Lifetime for the completion cache (if turned on, default: 1 week)
+
+local curcontext="$curcontext" state line
+
+: ${BAZEL_COMPLETION_PACKAGE_PATH:=%workspace%}
+: ${BAZEL:=bazel}
+_bazel_b() { ${BAZEL} --noblock_for_lock "$@" 2>/dev/null; }
+
+# Default cache lifetime is 1 week
+zstyle -s ":completion:${curcontext}:" cache-lifetime lifetime
+if [[ -z "${lifetime}" ]]; then
+ lifetime=$((60*60*24*7))
+fi
+
+_bazel_cache_policy() {
+ local -a oldp
+ oldp=( "$1"(Nms+${lifetime}) )
+ (( $#oldp ))
+}
+
+_set_cache_policy() {
+ zstyle -s ":completion:*:$curcontext*" cache-policy update_policy
+
+ if [[ -z "$update_policy" ]]; then
+ zstyle ":completion:$curcontext*" cache-policy _bazel_cache_policy
+ fi
+}
+
+# Skips over all global arguments. After invocation, OFFSET contains the
+# position of the bazel command in $words.
+_adapt_subcommand_offset() {
+ OFFSET=2
+ for w in ${words[2,-1]}; do
+ if [[ $w == (#b)-* ]]; then
+ (( OFFSET++ ))
+ else
+ return
+ fi
+ done
+}
+
+# Retrieve the cache but also check that the value is not empty.
+_bazel_safe_retrieve_cache() {
+ _retrieve_cache $1 && [[ ${(P)#2} -gt 0 ]]
+}
+
+# Puts the name of the variable that contains the options for the bazel
+# subcommand handed in as the first argument into the global variable
+# _bazel_cmd_options.
+_bazel_get_options() {
+ local lcmd=$1
+ _bazel_cmd_options=_bazel_${lcmd}_options
+ _bazel_cmd_args=_bazel_${lcmd}_args
+ if [[ ${(P)#_bazel_cmd_options} != 0 ]]; then
+ return
+ fi
+ if _cache_invalid BAZEL_${lcmd}_options || _cache_invalid BAZEL_${lcmd}_args \
+ || ! _bazel_safe_retrieve_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} \
+ || ! _retrieve_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}; then
+ if ! eval "$(_bazel_b help completion)"; then
+ return
+ fi
+ local opts_var
+ if [[ $lcmd == "startup_options" ]]; then
+ opts_var="BAZEL_STARTUP_OPTIONS"
+ else
+ opts_var="BAZEL_COMMAND_${lcmd:u}_FLAGS"
+ fi
+ local -a raw_options
+ if ! eval "raw_options=(\${(@f)$opts_var})"; then
+ return
+ fi
+
+ local -a option_list
+ for opt in $raw_options; do
+ case $opt in
+ --*"={"*)
+ local lst="${${opt##*"={"}%"}"}"
+ local opt="${opt%%=*}="
+ option_list+=("${opt}:string:_values '' ${lst//,/ }") ;;
+ --*=path)
+ option_list+=("${opt%path}:path:_files") ;;
+ --*=label)
+ option_list+=("${opt%label}:target:_bazel_complete_target") ;;
+ --*=*)
+ option_list+=("${opt}:string:") ;;
+ *)
+ option_list+=("$opt") ;;
+ esac
+ done
+
+ local -a cmd_args
+ local cmd_type
+ if eval "cmd_type=\${BAZEL_COMMAND_${lcmd:u}_ARGUMENT}" && [[ -n $cmd_type ]]; then
+ case $cmd_type in
+ label|label-*)
+ cmd_args+=("*::${cmd_type}:_bazel_complete_target_${cmd_type//-/_}") ;;
+ info-key)
+ cmd_args+=('1::key:_bazel_info_key') ;;
+ path)
+ cmd_args+=('1::profile:_path_files') ;;
+ "command|{"*"}")
+ local lst=${${cmd_type#"command|{"}%"}"}
+ cmd_args+=("1::topic:_bazel_help_topic -- ${lst//,/ }") ;;
+ esac
+ fi
+
+ typeset -g "${_bazel_cmd_options}"="${(pj:|:)option_list[*]}"
+ _store_cache BAZEL_${lcmd}_options ${_bazel_cmd_options}
+ typeset -g "${_bazel_cmd_args}"="${(pj:|:)cmd_args[*]}"
+ _store_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}
+ fi
+}
+
+_get_build_targets() {
+ local pkg=$1
+ local rule_re
+ typeset -a completions
+ case $target_type in
+ test)
+ rule_re=".*_test"
+ ;;
+ build)
+ rule_re=".*"
+ ;;
+ bin)
+ rule_re=".*_test|.*_binary"
+ ;;
+ esac
+ completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
+ if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then
+ completions+=(all)
+ fi
+ echo ${completions[*]}
+}
+
+# Returns all packages that match $PREFIX. PREFIX may start with //, in which
+# case the workspace roots are searched. Otherwise, they are completed based on
+# PWD.
+_get_build_packages() {
+ local workspace pfx
+ typeset -a package_roots paths final_paths
+ workspace=$PWD
+ package_roots=(${(ps.:.)BAZEL_COMPLETION_PACKAGE_PATH})
+ package_roots=(${^package_roots//\%workspace\%/$workspace})
+ if [[ "${(e)PREFIX}" == //* ]]; then
+ pfx=${(e)PREFIX[2,-1]}
+ else
+ pfx=${(e)PREFIX}
+ fi
+ paths=(${^package_roots}/${pfx}*(/))
+ for p in ${paths[*]}; do
+ if [[ -f ${p}/BUILD || -f ${p}/BUILD.bazel ]]; then
+ final_paths+=(${p##*/}:)
+ fi
+ final_paths+=(${p##*/}/)
+ done
+ echo ${final_paths[*]}
+}
+
+_package_remove_slash() {
+ if [[ $KEYS == ':' && $LBUFFER == */ ]]; then
+ LBUFFER=${LBUFFER[1,-2]}
+ fi
+}
+
+# Completion function for BUILD targets, called by the completion system.
+_bazel_complete_target() {
+ local expl
+ typeset -a packages targets
+ if [[ "${(e)PREFIX}" != *:* ]]; then
+ # There is no : in the prefix, completion can be either
+ # a package or a target, if the cwd is a package itself.
+ if [[ -f $PWD/BUILD || -f $PWD/BUILD.bazel ]]; then
+ targets=($(_get_build_targets ""))
+ _description build_target expl "BUILD target"
+ compadd "${expl[@]}" -a targets
+ fi
+ packages=($(_get_build_packages))
+ _description build_package expl "BUILD package"
+ # Chop of the leading path segments from the prefix for display.
+ compset -P '*/'
+ compadd -R _package_remove_slash -S '' "${expl[@]}" -a packages
+ else
+ targets=($(_get_build_targets "${${(e)PREFIX}%:*}"))
+ _description build_target expl "BUILD target"
+ # Ignore the current prefix for the upcoming completion, since we only list
+ # the names of the targets, not the full path.
+ compset -P '*:'
+ compadd "${expl[@]}" -a targets
+ fi
+}
+
+_bazel_complete_target_label() {
+ typeset -g target_type=build
+ _bazel_complete_target
+}
+
+_bazel_complete_target_label_test() {
+ typeset -g target_type=test
+ _bazel_complete_target
+}
+
+_bazel_complete_target_label_bin() {
+ typeset -g target_type=bin
+ _bazel_complete_target
+}
+
+### Actual completion commands
+
+_bazel() {
+ _adapt_subcommand_offset
+ if (( CURRENT - OFFSET > 0 )); then
+ # Remember the subcommand name, stored globally so we can access it
+ # from any subsequent function
+ cmd=${words[OFFSET]//-/_}
+
+ # Set the context for the subcommand.
+ curcontext="${curcontext%:*:*}:bazel-$cmd:"
+ _set_cache_policy
+
+ # Narrow the range of words we are looking at to exclude cmd
+ # name and any leading options
+ (( CURRENT = CURRENT - OFFSET + 1 ))
+ shift $((OFFSET - 1)) words
+ # Run the completion for the subcommand
+ _bazel_get_options $cmd
+ _arguments : \
+ ${(Pps:|:)_bazel_cmd_options} \
+ ${(Pps:|:)_bazel_cmd_args}
+ else
+ _set_cache_policy
+ # Start special handling for global options,
+ # which can be retrieved by calling
+ # $ bazel help startup_options
+ _bazel_get_options startup_options
+ _arguments : \
+ ${(Pps:|:)_bazel_cmd_options} \
+ "*:commands:_bazel_commands"
+ fi
+ return
+}
+
+_get_commands() {
+ # bazel_cmd_list is a global (g) array (a)
+ typeset -ga _bazel_cmd_list
+ # Use `bazel help` instead of `bazel help completion` to get command
+ # descriptions.
+ if _bazel_cmd_list=("${(@f)$(_bazel_b help | awk '
+/Available commands/ { command=1; }
+/ [-a-z]+[ \t]+.+/ { if (command) { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" } }
+/^$/ { command=0; }')}"); then
+ _store_cache BAZEL_commands _bazel_cmd_list
+ fi
+}
+
+# Completion function for bazel subcommands, called by the completion system.
+_bazel_commands() {
+ if [[ ${#_bazel_cmd_list} == 0 ]]; then
+ if _cache_invalid BAZEL_commands \
+ || ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
+ _get_commands
+ fi
+ fi
+
+ _describe -t bazel-commands 'Bazel command' _bazel_cmd_list
+}
+
+# Completion function for bazel help options, called by the completion system.
+_bazel_help_topic() {
+ if [[ ${#_bazel_cmd_list} == 0 ]]; then
+ if _cache_invalid BAZEL_commands \
+ || ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
+ _get_commands
+ fi
+ fi
+
+ while [[ $# -gt 0 ]]; do
+ if [[ $1 == -- ]]; then
+ shift
+ break
+ fi
+ shift
+ done
+ _bazel_help_list=($@)
+ _bazel_help_list+=($_bazel_cmd_list)
+ _describe -t bazel-help 'Help topic' _bazel_help_list
+}
+
+# Completion function for bazel info keys, called by the completion system.
+_bazel_info_key() {
+ if [[ ${#_bazel_info_keys_list} == 0 ]]; then
+ if _cache_invalid BAZEL_info_keys \
+ || ! _bazel_safe_retrieve_cache BAZEL_info_keys _bazel_info_keys_list; then
+ typeset -ga _bazel_info_keys_list
+ # Use `bazel help` instead of `bazel help completion` to get info-key
+ # descriptions.
+ if _bazel_info_keys_list=("${(@f)$(_bazel_b help info-keys | awk '
+ { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" }')}"); then
+ _store_cache BAZEL_info_keys _bazel_info_keys_list
+ fi
+ fi
+ fi
+ _describe -t bazel-info 'Key' _bazel_info_keys_list
+}
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/README.md b/plugins/bower/README.md
index 743b6a0ea..8877fbdc5 100644
--- a/plugins/bower/README.md
+++ b/plugins/bower/README.md
@@ -4,7 +4,7 @@ This plugin adds completion for [Bower](https://bower.io/) and a few useful alia
To use it, add `bower` to the plugins array in your zshrc file:
-```
+```zsh
plugins=(... bower)
```
@@ -15,4 +15,3 @@ plugins=(... bower)
| bi | `bower install` | Installs the project dependencies listed in bower.json |
| bl | `bower list` | List local packages and possible updates |
| bs | `bower search` | Finds all packages or a specific package. |
-
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 aab55ea39..bf952bf01 100644
--- a/plugins/brew/README.md
+++ b/plugins/brew/README.md
@@ -3,17 +3,28 @@
The plugin adds several aliases for common [brew](https://brew.sh) commands.
To use it, add `brew` to the plugins array of your zshrc file:
-```
+
+```zsh
plugins=(... brew)
```
## Aliases
-| Alias | Command | Description |
-|--------|----------------------|---------------|
-| brewp | `brew pin` | Pin a specified formulae, preventing them from being upgraded when issuing the brew upgrade <formulae> command. |
-| brews | `brew list -1` | List installed formulae, one entry per line, or the installed files for a given formulae. |
-| brewsp | `brew list --pinned` | Show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. |
-| bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. |
-| bubc | `brew upgrade && brew cleanup` | Upgrade outdated, unpinned brews (with existing install options), then removes stale lock files and outdated downloads for formulae and casks, and removes old versions of installed formulae. |
-| bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. |
+| 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
+
+With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
+brew installation, so we no longer ship it with the brew plugin; now it only has brew
+aliases. If you find that brew completion no longer works, make sure you have your Homebrew
+installation fully up to date.
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index 60b81f8ec..532dd9be7 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -4,19 +4,6 @@ alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc'
-
-if command mkdir "$ZSH_CACHE_DIR/.brew-completion-message" 2>/dev/null; then
- print -P '%F{yellow}'Oh My Zsh brew plugin:
- cat <<-'EOF'
-
- With the advent of their 1.0 release, Homebrew has decided to bundle
- the zsh completion as part of the brew installation, so we no longer
- ship it with the brew plugin; now it only has brew aliases.
-
- If you find that brew completion no longer works, make sure you have
- your Homebrew installation fully up to date.
-
- You will only see this message once.
- EOF
- print -P '%f'
-fi
+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 dc2f17008..7b79cbcdc 100644
--- a/plugins/bundler/README.md
+++ b/plugins/bundler/README.md
@@ -1,52 +1,74 @@
# Bundler
-- adds completion for basic bundler commands
-- adds short aliases for common bundler commands
- - `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`)
-- 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`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
-## Configuration
+`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`.
+
+### 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)
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)
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/robbyrussell/oh-my-zsh/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 668e15d2f..6293dc28a 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -1,11 +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"
+
+## 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
@@ -27,6 +65,7 @@ bundled_commands=(
rainbows
rake
rspec
+ rubocop
shotgun
sidekiq
spec
@@ -51,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" ] && 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/bwana/README.md b/plugins/bwana/README.md
deleted file mode 100644
index 8cbeaa32e..000000000
--- a/plugins/bwana/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Bwana
-
-This plugin provides a function to open `man` pages directly with [Bwana](https://www.bruji.com/bwana/).
-
-To use it add bwana to the plugins array in your zshrc file.
-
-```bash
-plugins=(... bwana)
-```
diff --git a/plugins/bwana/bwana.plugin.zsh b/plugins/bwana/bwana.plugin.zsh
deleted file mode 100644
index b9a04793f..000000000
--- a/plugins/bwana/bwana.plugin.zsh
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Requires https://www.bruji.com/bwana/
-#
-if [[ -e /Applications/Bwana.app ]] ||
- ( system_profiler -detailLevel mini SPApplicationsDataType | grep -q Bwana )
-then
- function man() {
- open "man:$1"
- }
-else
- echo "Bwana lets you read man files in Safari through a man: URI scheme"
- echo "To use it within Zsh, install it from https://www.bruji.com/bwana/"
-fi
diff --git a/plugins/cake/README.md b/plugins/cake/README.md
new file mode 100644
index 000000000..2c2a28053
--- /dev/null
+++ b/plugins/cake/README.md
@@ -0,0 +1,15 @@
+# Cake
+
+This plugin provides completion for [CakePHP](https://cakephp.org/).
+
+To use it add cake to the plugins array in your zshrc file.
+
+```bash
+plugins=(... cake)
+```
+
+## Note
+
+This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory.
+It is regenerated when the Cakefile is newer than the cache file. It is advised that you add the cake file to your
+`.gitignore` files.
diff --git a/plugins/cakephp3/README.md b/plugins/cakephp3/README.md
new file mode 100644
index 000000000..7e8f6640d
--- /dev/null
+++ b/plugins/cakephp3/README.md
@@ -0,0 +1,16 @@
+# cakephp3 plugin
+
+The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html).
+
+To use it, add `cakephp3` to the plugins array of your zshrc file:
+```
+plugins=(... cakephp3)
+```
+
+## Aliases
+
+| Alias | Command |
+|-----------|-------------------------------|
+| c3 | `bin/cake` |
+| c3cache | `bin/cake orm_cache clear` |
+| c3migrate | `bin/cake migrations migrate` |
diff --git a/plugins/cargo/README.md b/plugins/cargo/README.md
index 5fa688d21..31bae4efe 100644
--- a/plugins/cargo/README.md
+++ b/plugins/cargo/README.md
@@ -1,6 +1,6 @@
# cargo
-This plugin adds completion for the Rust build tool [`cargo`](https://github.com/rust-lang/cargo).
+This plugin adds completion for the Rust build tool [`Cargo`](https://github.com/rust-lang/cargo).
To use it, add `cargo` to the plugins array in your zshrc file:
@@ -8,4 +8,4 @@ To use it, add `cargo` to the plugins array in your zshrc file:
plugins=(... cargo)
```
-Updated on October 4th, 2016.
+Updated on March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0).
diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo
index 54e709ca0..ebff99310 100644
--- a/plugins/cargo/_cargo
+++ b/plugins/cargo/_cargo
@@ -1,445 +1,368 @@
#compdef cargo
-typeset -A opt_args
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|b)
+ _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|c)
+ _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|r)
+ _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|t)
+ _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
+}
-_arguments \
- '(- 1 *)'{-h,--help}'[show help message]' \
- '(- 1 *)'{-V,--version}'[show version information]' \
- '(- 1 *)'--list'[list installed commands]' \
- '(- 1 *)'--explain'[Run `rustc --explain CODE`]' \
- '(- 1 *)'{-v,--verbose}'[use verbose output]' \
- '(- 1 *)'--color'[colorization option]' \
- '(- 1 *)'--frozen'[Require Cargo.lock and cache are up to date]' \
- '(- 1 *)'--locked'[Require Cargo.lock is up to date]' \
- '1: :_cargo_cmds' \
- '*:: :->args'
-
-case $state in
- args)
- case $words[1] in
- bench)
- _arguments \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
- "${command_scope_spec[@]}" \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--no-default-features[do not build the default features]' \
- '--no-run[compile but do not run]' \
- '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
- '--target=[target triple]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- build)
- _arguments \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
- "${command_scope_spec[@]}" \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--no-default-features[do not build the default features]' \
- '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
- '--release=[build in release mode]' \
- '--target=[target triple]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- clean)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--release[whether or not to clean release artifacts]' \
- '--target=[target triple(default:all)]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- doc)
- _arguments \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--no-deps[do not build docs for dependencies]' \
- '--no-default-features[do not build the default features]' \
- '--open[open docs in browser after the build]' \
- '(-p, --package)'{-p,--package}'=[package to document]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--release[build artifacts in release mode, with optimizations]' \
- '--target=[build for the target triple]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- fetch)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- generate-lockfile)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- git-checkout)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- 'q(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--reference=[REF]' \
- '--url=[URL]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- help)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '*: :_cargo_cmds' \
- ;;
-
- init)
- _arguments \
- '--bin[use binary template]' \
- '--vcs:initialize a new repo with a given VCS:(git hg none)' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--name=[set the resulting package name]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- install)
- _arguments \
- '--bin=[only install the specified binary]' \
- '--branch=[branch to use when installing from git]' \
- '--color=:colorization option:(auto always never)' \
- '--debug[build in debug mode instead of release mode]' \
- '--example[install the specified example instead of binaries]' \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '--git=[URL from which to install the crate]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
- '--no-default-features[do not build the default features]' \
- '--path=[local filesystem path to crate to install]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--rev=[specific commit to use when installing from git]' \
- '--root=[directory to install packages into]' \
- '--tag=[tag to use when installing from git]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--vers=[version to install from crates.io]' \
- ;;
-
- locate-project)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- ;;
-
- login)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--host=[Host to set the token for]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- metadata)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- "--no-deps[output information only about the root package and don't fetch dependencies]" \
- '--no-default-features[do not include the default feature]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '--format-version=[format version(default: 1)]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- new)
- _arguments \
- '--bin[use binary template]' \
- '--vcs:initialize a new repo with a given VCS:(git hg none)' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--name=[set the resulting package name]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- owner)
- _arguments \
- '(-a, --add)'{-a,--add}'[add owner LOGIN]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--index[registry index]' \
- '(-l, --list)'{-l,--list}'[list owners of a crate]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
- '--token[API token to use when authenticating]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- package)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--no-metadata[ignore warnings about a lack of human-usable metadata]' \
- '--no-verify[do not build to verify contents]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- pkgid)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- publish)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--host=[Host to set the token for]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--no-verify[Do not verify tarball until before publish]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--token[token to use when uploading]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- read-manifest)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- run)
- _arguments \
- '--example=[name of the bin target]' \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--bin=[name of the bin target]' \
- '--no-default-features[do not build the default features]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--release=[build in release mode]' \
- '--target=[target triple]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- '*: :_normal' \
- ;;
-
- rustc)
- _arguments \
- '--color=:colorization option:(auto always never)' \
- '--features=[features to compile for the package]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
- '--manifest-path=[path to the manifest to fetch dependencies for]' \
- '--no-default-features[do not compile default features for the package]' \
- '(-p, --package)'{-p,--package}'=[profile to compile for]' \
- '--profile=[profile to build the selected target for]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--release[build artifacts in release mode, with optimizations]' \
- '--target=[target triple which compiles will be for]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- "${command_scope_spec[@]}" \
- ;;
-
- rustdoc)
- _arguments \
- '--color=:colorization option:(auto always never)' \
- '--features=[space-separated list of features to also build]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
- '--manifest-path=[path to the manifest to document]' \
- '--no-default-features[do not build the `default` feature]' \
- '--open[open the docs in a browser after the operation]' \
- '(-p, --package)'{-p,--package}'=[package to document]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--release[build artifacts in release mode, with optimizations]' \
- '--target=[build for the target triple]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- "${command_scope_spec[@]}" \
- ;;
-
- search)
- _arguments \
- '--color=:colorization option:(auto always never)' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--host=[host of a registry to search in]' \
- '--limit=[limit the number of results]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- ;;
-
- test)
- _arguments \
- '--features=[space separated feature list]' \
- '--all-features[enable all available features]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '--test=[test name]: :_test_names' \
- '--no-default-features[do not build the default features]' \
- '--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]:packages:_get_package_names' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--release[build artifacts in release mode, with optimizations]' \
- '--target=[target triple]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- '1: :_test_names' \
- ;;
-
- uninstall)
- _arguments \
- '--bin=[only uninstall the binary NAME]' \
- '--color=:colorization option:(auto always never)' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
- '--root=[directory to uninstall packages from]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- ;;
-
- update)
- _arguments \
- '--aggressive=[force dependency update]' \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
- '--precise=[update single dependency to PRECISE]: :' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- verify-project)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--manifest-path=[path to manifest]: :_files -/' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- version)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- ;;
-
- yank)
- _arguments \
- '(-h, --help)'{-h,--help}'[show help message]' \
- '--index[registry index]' \
- '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
- '--token[API token to use when authenticating]' \
- '--undo[undo a yank, putting a version back into the index]' \
- '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
- '--color=:colorization option:(auto always never)' \
- '--vers[yank version]' \
- ;;
- 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_cmds(){
-local -a commands;commands=(
-'bench:execute all benchmarks of a local package'
-'build:compile the current project'
-'clean:remove generated artifacts'
-'doc:build package documentation'
-'fetch:fetch package dependencies'
-'generate-lockfile:create lockfile'
-'git-checkout:git checkout'
-'help:get help for commands'
-'init:create new project in current directory'
-'install:install a Rust binary'
-'locate-project:print "Cargo.toml" location'
-'login:login to remote server'
-'metadata:the metadata for a project in json'
-'new:create a new project'
-'owner:manage the owners of a crate on the registry'
-'package:assemble local package into a distributable tarball'
-'pkgid:print a fully qualified package specification'
-'publish:upload package to the registry'
-'read-manifest:print manifest in JSON format'
-'run:run the main binary of the local package'
-'rustc:compile a package and all of its dependencies'
-'rustdoc:build documentation for a package'
-'search:search packages on crates.io'
-'test:execute all unit and tests of a local package'
-'uninstall:remove a Rust binary'
-'update:update dependencies'
-'verify-project:check Cargo.toml'
-'version:show version information'
-'yank:remove pushed file from index'
-)
-_describe 'command' commands
+_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
-_get_package_names()
-{
-}
-
-#TODO:see if it makes sense to have 'locate-project' to have non-json output.
-#strips package name from json stuff
-_locate_manifest(){
-local manifest=`cargo locate-project 2>/dev/null`
-regexp-replace manifest '\{"root":"|"\}' ''
-echo $manifest
+_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
-_get_names_from_array()
-{
- local -a filelist;
- local manifest=$(_locate_manifest)
+_cargo_names_from_array() {
+ # strip json from the path
+ local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
if [[ -z $manifest ]]; then
return 0
fi
@@ -449,52 +372,36 @@ _get_names_from_array()
local in_block=false
local block_name=$1
names=()
- while read line
- do
+ while read -r line; do
if [[ $last_line == "[[$block_name]]" ]]; then
in_block=true
else
- if [[ $last_line =~ '.*\[\[.*' ]]; then
+ if [[ $last_line =~ '\s*\[\[.*' ]]; then
in_block=false
fi
fi
if [[ $in_block == true ]]; then
- if [[ $line =~ '.*name.*=' ]]; then
- regexp-replace line '^.*name *= *|"' ""
- names+=$line
+ 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
+ done < "$manifest"
+ _describe "$block_name" names
}
#Gets the test names from the manifest file
-_test_names()
-{
- _get_names_from_array "test"
+_cargo_test_names() {
+ _cargo_names_from_array "test"
}
#Gets the bench names from the manifest file
-_benchmark_names()
-{
- _get_names_from_array "bench"
+_cargo_benchmark_names() {
+ _cargo_names_from_array "bench"
}
-# These flags are mutally 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.
-set command_scope_spec
-command_scope_spec=(
- '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
- '(--bench --bin --test --lib)--example=[example name]'
- '(--bench --example --test --lib)--bin=[binary name]'
- '(--bench --bin --example --test)--lib=[library name]'
- '(--bench --bin --example --lib)--test=[test name]'
-)
-
-
_cargo
diff --git a/plugins/catimg/README.md b/plugins/catimg/README.md
index 2fc28a1c6..8f2688050 100644
--- a/plugins/catimg/README.md
+++ b/plugins/catimg/README.md
@@ -2,27 +2,15 @@
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
-## Requirements
-
-- `convert` (ImageMagick)
-
-## Enabling the plugin
+To use it, add `catimg` to the plugins array in your zshrc file:
-1. Open your `.zshrc` file and add `catimg` in the plugins section:
+```zsh
+plugins=(... catimg)
+```
- ```zsh
- plugins=(
- # all your enabled plugins
- catimg
- )
- ```
-
-2. Reload the source file or restart your Terminal session:
+## Requirements
- ```console
- $ source ~/.zshrc
- $
- ```
+- `convert` (ImageMagick)
## Functions
diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh
index 5f58ecde3..ca46444cc 100644
--- a/plugins/catimg/catimg.plugin.zsh
+++ b/plugins/catimg/catimg.plugin.zsh
@@ -4,7 +4,7 @@
# #
# Ouput the content of an image to the stdout using the 256 colors of the #
# terminal. #
-# Github: https://github.com/posva/catimg #
+# GitHub: https://github.com/posva/catimg #
################################################################################
diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh
index 83ccf6a95..713a03291 100644
--- a/plugins/catimg/catimg.sh
+++ b/plugins/catimg/catimg.sh
@@ -4,7 +4,7 @@
# #
# Ouput the content of an image to the stdout using the 256 colors of the #
# terminal. #
-# Github: https://github.com/posva/catimg #
+# GitHub: https://github.com/posva/catimg #
################################################################################
function help() {
diff --git a/plugins/chruby/README.md b/plugins/chruby/README.md
new file mode 100644
index 000000000..d373006a5
--- /dev/null
+++ b/plugins/chruby/README.md
@@ -0,0 +1,20 @@
+# chruby plugin
+
+This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the
+current Ruby version, and completion and a prompt function to display the Ruby version.
+Supports brew and manual installation of chruby.
+
+To use it, add `chruby` to the plugins array in your zshrc file:
+```zsh
+plugins=(... chruby)
+```
+
+## Usage
+
+If you'd prefer to specify an explicit path to load chruby from
+you can set variables like so:
+
+```
+zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
+zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
+```
diff --git a/plugins/chucknorris/README.md b/plugins/chucknorris/README.md
index be7b97e24..35f989180 100644
--- a/plugins/chucknorris/README.md
+++ b/plugins/chucknorris/README.md
@@ -1,6 +1,6 @@
# chucknorris
-Chuck Norris fortunes plugin for oh-my-zsh
+Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
@@ -10,11 +10,31 @@ To use it add `chucknorris` to the plugins array in you zshrc file.
plugins=(... chucknorris)
```
-
-Depends on fortune (and cowsay if using chuck_cow) being installed (available via homebrew, apt, ...). Perfectly suitable as MOTD.
-
+## Usage
| Command | Description |
| ----------- | ------------------------------- |
| `chuck` | Print random Chuck Norris quote |
| `chuck_cow` | Print quote in cowthink |
+
+Example: output of `chuck_cow`:
+
+```
+Last login: Fri Jan 30 23:12:26 on ttys001
+ ______________________________________
+( When Chuck Norris plays Monopoly, it )
+( affects the actual world economy. )
+ --------------------------------------
+ o ^__^
+ o (oo)\_______
+ (__)\ )\/\
+ ||----w |
+ || ||
+```
+
+## Requirements
+
+- `fortune`
+- `cowsay` if using `chuck_cow`
+
+Available via homebrew, apt, ...
diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris
index 2a13b060f..0ddb6c03b 100644
--- a/plugins/chucknorris/fortunes/chucknorris
+++ b/plugins/chucknorris/fortunes/chucknorris
@@ -1,2544 +1,560 @@
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-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.
-%
-There is no chin behind Chuck Norris' beard. There is only another fist.
-%
-Chuck Norris does not teabag the ladies. He potato-sacks them.
-%
-Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
+King Kong climbed the Empire State building in fear of Chuck Norris who was downstairs at the time.
%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
+"2012" is code for, Chuck Norris when he is pissed.
%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
+"The Big Chuck Norris Roundhouse-Kick Theory"
%
-Chuck Norris uses pepper spray to spice up his steaks.
+"The wind cries Chuck Norris"
%
-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.
+"Walker Texas Ranger: The Movie 3-D" was considered by Warner Brothers; however the technology to create the visual effects will never be possible.
%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+Abraham Lincoln didn't die because he was shot, Chuck Norris roundhouse-kicked so fast his foot went back in time and killed Abraham Lincoln.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
+Achievement Unlocked: Chuck Norris of Death
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+After Chuck counted to infinity the first time, he vowed to count to infinity a second time....by counting the bodies of those previously roundhoused.
%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+Aliens fear that Chuck Norris might abduct them.
%
-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.
+An angry glare from Chuck Norris is known to kill on the spot.
%
-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.
+Behind every successful man is Chuck Norris.
%
-The quickest way to a man's heart is with Chuck Norris' fist.
+Beware of dogs... Dogs, beware of Chuck Norris.
%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
+Bruce Lee didn't defeat Chuck Norris. Chuck hit Bruce with a Delayed roundhouse kick that was so fast that Lee only felt the impact a year later!
%
CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Chuck Norris can win in a top spinning tournament with a cube
-%
-Beware of dogs... Dogs, beware of Chuck Norris.
-%
-Chuck Norris can dig a hole in air.
-%
-The apple falls far from the tree, when a roundhouse kick is taken to the trunk.
+Casinos pay Chuck Norris not to play at anything or wish anyone good luck.
%
Chuck Norris - the new standard.
%
-Chuck Norris told me to put this here.
-%
-Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
-%
-Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic
-%
-When Chuck Norris goes to rodeos, bulls ride him.
+Chuck Norris CAN balance the light-switch between ON and OFF.
%
-Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
+Chuck Norris CAN believe it's not butter.
%
-The meaning of life is Chuck Norris
+Chuck Norris CAN spell with an I before E even after C.
%
-Chuck Norris is the meaning of life. Too bad he's also the meaning of death.
+Chuck Norris can play the theme from the Twilight Zone with his beard.
%
-If God doesn't know, Chuck does
+Chuck Norris can power solar panels. At night.
%
-Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
+Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel.
%
-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.
+Chuck Norris bowled a 301 after constructing another pin out of his beard hair.
%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
+Chuck Norris burnt a fire proof vest, UNDERWATER!
%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
+Chuck Norris can French kiss his elbow.
%
-Chuck Norris does not sleep. He waits.
+Chuck Norris can bake in a freezer.
%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
+Chuck Norris can defuse a bomb by cutting the wrong wire.
%
-Chuck Norris is the reason why Waldo is hiding.
+Chuck Norris can dig a hole in air.
%
-Chuck Norris counted to infinity - twice.
+Chuck Norris can divide by zero.
%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
+Chuck Norris can do a regime change with a roundhouse kick.
%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
+Chuck Norris can fit 10 gallons of water in a 5 gallon bucket.
%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
+Chuck Norris can grill a popsicle.
%
Chuck Norris can lead a horse to water AND make it drink.
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-When God said "Let there be light!", Chuck Norris said "Only for half the day
-%
-Chuck Norris went up the creek without a paddle... or a canoe
-%
-Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf.
-%
-Chuck Norris found the hay in the needle stack.
-%
-Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach.
-%
-Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives
-%
-The planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller.
-%
-Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
+Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord".
%
-Chuck Norris Can Play the Theme from the Twilight Zone with His Beard
-%
-Chuck Norris pees Adamantium
-%
-The Beatles are on iTunes because Chuck Norris bought a Mac.
-%
-Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet
-%
-Chuck Norris yells at Drill Sergeants
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
+Chuck Norris can milk an alligator.
%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
+Chuck Norris can play the death waltz with his chin.
%
-If at first you don't succeed, you're not Chuck Norris.
+Chuck Norris can roundhouse kick someone through a window without breaking the glass.
%
-If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass.
+Chuck Norris can roundhouse-kick round houses into squares.
%
-Chuck Norris can lead a horse to water AND make it drink.
+Chuck Norris can rub two fires together and make a stick!
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
+Chuck Norris can see in 3D with just one eye.
%
Chuck Norris can slam a revolving door.
%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-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 can terminate a repeating decimal.
%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
+Chuck Norris can turn toast back into bread.
%
Chuck Norris can win a game of Connect Four in only three moves.
%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.?
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-There is no such thing as being hard its called the Chuck Norris factor.
-%
-When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section.
-%
-Chuck Norris can shoot a person 28 times with an unloaded gun.
-%
-Chuck Norris' personal airplane is called Air Force Chuck
-%
-The letters in Chuck Norris cannot be unscrambled.
-%
-Cops don't need a badges in their wallets but only a picture of Chuck Norris.
-%
-Chuck Norris was the reason why the Great Wall of China was constructed. It failed miserably.
-%
-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.
-%
-The red phone in the oval office...Rings directly to Chuck Norris Cell Phone
-%
-The only way sharks will come near CN underwater is when CN is inside of a cage.
-%
-Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee.
-%
-If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
-%
-"2012" is code for, Chuck Norris when he is pissed.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
+Chuck Norris can win in a top spinning tournament with a cube.
%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
+Chuck Norris can't perform Hadoukens, he IS a Hadouken.
%
-Chuck Norris is the reason why Waldo is hiding.
+Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
%
Chuck Norris counted to infinity - twice.
%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
+Chuck Norris created Heavy Metal when he was upset.
%
Chuck Norris does not get frostbite. Chuck Norris bites frost.
%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
+Chuck Norris does not have a cell phone because he hears everything.
%
-Chuck Norris can win a game of Connect Four in only three moves.
+Chuck Norris does not sleep. He waits.
%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
+Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
+Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
+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 wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-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."
-%
-The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them.
+Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it.
%
-Chuck Norris once had a pet monkey........his name was KING KONG
-%
-Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord"
-%
-Simon doesn't say...Chuck Norris says.
-%
-When does Chuck Norris run out of shotgun bullets?.....whenever he wants to.
-%
-The only sure things are Death and Taxes, and when Chuck Norris goes to work for the IRS, they'll be the same thing.
-%
-Chuck Norris' first job was as a paperboy. There were no survivors.
+Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
%
-Chuck Norris can turn toast back into bread
+Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
%
-Chuck Norris started Chuck Norris.
+Chuck Norris doesn't let it go.
%
-Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming
+Chuck Norris doesn't like Mudkipz.
%
-Chuck Norris killed Kemper
+Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
%
-Did you here about the boy who cried Chuck Norris?
+Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
%
-Chuck Norris can't perform Hadoukens, he IS a Hadouken
+Chuck Norris doesn't need air, he is air.
%
-Behind every successful man is Chuck Norris
+Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses.
%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
+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.
%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-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.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
+Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
+Chuck Norris doesn't eat salad, he eats vegetarians.
%
-The chief export of Chuck Norris is Pain.
+Chuck Norris doesn't wash his clothes, he disembowels them.
%
-Chuck Norris has two speeds. Walk, and Kill.
+Chuck Norris doesn't wear a watch. HE decides what time it is.
%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
+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 is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+Chuck Norris drowned a man ON LAND.
%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+Chuck Norris fed the Hunger Games.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
+Chuck Norris found the hay in the needle stack.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+Chuck Norris found the last digit of pi.
%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife.
%
-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.
+Chuck Norris has a battle cruiser AND a car.
%
-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.
+Chuck Norris has killed the Dead Sea.
%
-The quickest way to a man's heart is with Chuck Norris' fist.
+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.
%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death
-%
-Chuck Norris doesn't read. He just stares at the book until he gets the information he wants.
-%
-Why didn't the chicken cross the road? Because Chuck Norris got to it first.
-%
-When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000.
-%
-Chuck Norris can milk an alligator
-%
-Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it
-%
-Chuck Norris once proved p^~p by induction on his beard hairs.
-%
-The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon.
-%
-Chuck Norris can bake in a Freezer.
-%
-Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick.
-%
-Chuck Norris once had a weak moment, just to know what it felt like.
-%
-Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima?
-%
-Chuck Norris has made a 148 break a snooker.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
+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 the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
+Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick.
%
-Chuck Norris drives an ice cream truck covered in human skulls.
+Chuck Norris is entitled to his own facts.
%
Chuck Norris is my Homeboy.
%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
+Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
%
-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 is so hard, he uses diamonds as stress balls.
%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+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.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
+Chuck Norris is the ghost in paranormal activity.
%
-Chuck Norris can win a game of Connect Four in only three moves.
+Chuck Norris is the life of parties he doesn't attend.
%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
+Chuck Norris is the meaning of life. Too bad he's also the meaning of death.
%
Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
-%
-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".
-%
-Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you.
-%
-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.
-%
-The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live.
-%
-Only Chuck Norris can win the mind game, 'cause he never minds.
-%
-Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning.
-%
-Bruce Lee didn't defeat Chuck Norris. Chuck hit Bruce with a Delayed roundhouse kick that was so fast that Lee only felt the impact a year later!
-%
-Chuck Norris doesn't need a bulletproof vest to be bulletproof
-%
-When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just give him stacks of money.
-%
-Merlin was Chuck Norris' assistant.
-%
-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.
-%
-Those who ignore history, are doomed by Chuck Norris.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
+Chuck Norris is the only one who can tear a facebook page!
%
-Chuck Norris does not sleep. He waits.
+Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth.
%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
+Chuck Norris is the reason tumbleweeds tumble.
%
Chuck Norris is the reason why Waldo is hiding.
%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+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 is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
+Chuck Norris made a statue bleed.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+Chuck Norris made the big bang just by clicking his fingers.
%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+Chuck Norris never trains, because he's 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.
+Chuck Norris once cried just to see what it was like. The end result was the creation of life.
%
-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.
+Chuck Norris once cut a knife with a stick of butter.
%
-The quickest way to a man's heart is with Chuck Norris' fist.
+Chuck Norris once got a 200 yard punt return.
%
-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 once had a pet monkey named KING KONG.
%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
+Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives.
%
-Chuck Norris can win a game of Connect Four in only three moves.
+Chuck Norris once had a weak moment, just to know what it felt like.
%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
+Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade.
%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
+Chuck Norris once proved p^~p by induction on his beard hairs.
%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
+Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill.
%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
+Chuck Norris once round-house kicked a salesman. Over the phone.
%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
+Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet.
%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
+Chuck Norris once thought he was wrong. He was, however, mistaken.
%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
+Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
+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."
%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Some kids pee their name in snow. Chuck Norris pees his name in concrete.
-%
-The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.”
-%
-Chuck Norris created Heavy Metal when he was upset
-%
-Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag.
+Chuck Norris owns all number 1 pencils.
%
-When things go bump in the night.... it's Chuck Norris
+Chuck Norris pees Adamantium.
%
-Chuck Norris fed the Hunger Games
+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 had a knife thrown at him............ the knife didn't impale him, he impaled the knife
-%
-Chuck Norris doesn't let it go.
-%
-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.
-%
-Whatever Chuck Norris wants, it will instantly appear.
-%
-Chuck Norris once cut a knife with a stick of butter.
-%
-Chuck Norris shops at Sam's Club, but leaves without having his receipt checked
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
+Chuck Norris played the game of thrones and won.
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
+Chuck Norris protects his bodyguards.
%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
+Chuck Norris rolled a 20 on a 6 sided die.
%
-Guns don't kill people. Chuck Norris kills people.
+Chuck Norris roundhouse kicks people in the face first and asks questions later.
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
+Chuck Norris sent a BBM to an iPhone.
%
-The chief export of Chuck Norris is Pain.
+Chuck Norris shops at Sam's Club, but leaves without having his receipt checked.
%
-Chuck Norris has two speeds. Walk, and Kill.
+Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick!
%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
+Chuck Norris started Chuck Norris.
%
-Chuck Norris drives an ice cream truck covered in human skulls.
+Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury.
%
-Chuck Norris is my Homeboy.
+Chuck Norris told me to put this here.
%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
+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.
%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese.
+Chuck Norris was heard in a soundproof room!
%
-One glance from Chuck Norris and snow turns itself yellow.
+Chuck Norris was once turned down for American Idol. When Simon was questioned about it, he replied "I'm retiring after this season". I wonder why?
%
-Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
+Chuck Norris was originally in Mortal Kombat, but that version was deleted because no one can beat Chuck Norris in a fight.
%
Chuck Norris was the image used for Papa Smurf.
%
-Chuck Norris is so scary he makes Sharks swim backwards away from him
-%
-When Chuck Norris tosses a coin, it lands on both head and tail.
-%
-Chuck Norris found the last digit of pie
-%
-Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel
-%
-James Bond has a license to kill. He got it from Chuck Norris.
-%
-Chuck Norris is Chuck Norris
-%
-"The Big Chuck Norris Roundhouse-Kick Theory"
-%
-That's not an eclipse....that's the sun hiding from Chuck Norris.
-%
-Chuck Norris doesn't like Mudkipz
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
+Chuck Norris was the reason why the Great Wall of China was constructed. It failed miserably.
%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
+Chuck Norris was what Willis was talking about.
%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
+Chuck Norris wasn't born on his birthday.
%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
+Chuck Norris watched the first steps on the moon... from his summer home on Mars.
%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
+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.
%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Chuck Norris doesn’t eat salad, he eats vegetarians
-%
-Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
-%
-Chuck Norris wasn't born on his birthday
-%
-One time a test cheated on Chuck Norris.
-%
-Chuck Norris won a stepdance contest by standing on his hands
-%
-Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white.
-%
-When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
-%
-Chuck Norris is the life of parties he dosen't attend
-%
-Chuck Norris can rub two fires together and make a stick!
-%
-Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris.
-%
-Chuck Norris rolled a 20 on a 6 sided die.
-%
-When chuck Norris was in school, he made his PE teacher run laps.
-%
Chuck Norris wins NASCAR races with all right turns.
%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
+Chuck Norris won a stepdance contest by standing on his hands.
%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
+Chuck Norris yells at drill Sergeants.
%
-Chuck Norris is the reason why Waldo is hiding.
+Chuck Norris' dog picks up after him.
%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
+Chuck Norris' films are factual documentaries.
%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
+Chuck Norris' first job was as a paperboy. There were no survivors.
%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
+Chuck Norris' glass is never half full or half empty. It stays full even after he takes a drink.
%
Chuck Norris' hand is the only hand that can beat a Royal Flush.
%
-Chuck Norris can lead a horse to water AND make it drink.
+Chuck Norris' personal airplane is called Air Force Chuck.
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
+Chuck Norris. Enough said.
%
-Chuck Norris can slam a revolving door.
+Chuck Norris: even Naruto can't believe it.
%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
+Chuck Norris can make sour milk turn fresh.
%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
+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.
%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
+Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth.
%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
+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.
%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-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 is overra...
-%
-Chuck Norris was originally in Mortal Kombat, but that version was deleted because no one can beat Chuck Norris in a fight.
-%
-Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead...
-%
-Chunk Norris can make sour milk turn fresh
-%
-There is no limbo, only a world that doesn't know of Chuck Norris
-%
-Chuck Norris CAN believe it's not butter
+Did you hear about the boy who cried Chuck Norris?
%
Dog the Bounty Hunter can't track Chuck Norris down.
%
-Abraham Lincoln didn't die because he was shot, Chuck Norris roundhouse-kicked so fast his foot went back in time and killed Abraham Lincoln.
-%
-When Chuck Norris inhales helium, his voice doesn't change.
-%
-When Chuck Norris drinks water, the water automatically pasteurized.
-%
-Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill
-%
-Chuck Norris can play the death waltz with his chin.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
+Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon.
%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
+Earth's rotation is purely governed by the direction that Chuck Norris is walking.
%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
+Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming.
%
-Chuck Norris can lead a horse to water AND make it drink.
+Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
+Every phobia known to man has a phobia of Chuck Norris.
%
-Chuck Norris can slam a revolving door.
+Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
+Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
+Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
+Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
%
-If you spell Chuck Norris in Scrabble, you win. Forever.
+Ghosts can see Chuck Norris.
%
Guns don't kill people. Chuck Norris kills people.
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
+How much wood could a woodchuck chuck if a woodchuck could chuck wood? No woodchuck could chuck Chuck's wood!
%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass.
%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
+If God doesn't know, Chuck does.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+If Goliath listened to Chuck Norris, he would have won.
%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+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.
%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
+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.
%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win?
-%
-Chuck Norris once round-house kicked a salesman. Over the phone.
-%
-Chuck Norris can grill a popsicle
-%
-Chuck Norris' films are factual documentaries.
-%
-Casinos pay Chuck Norris not to play at anything or wish anyone good luck.
-%
-Chuck Norris once got a 200 yard punt return
-%
-Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
-%
-An angry glare from Chuck Norris is known to kill on the spot.
-%
-Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
-%
-When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris.
-%
-Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon.
-%
-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.
-%
-After Chuck counted to infinity the first time, he vowed to count to infinity a second time....by counting the bodies of those previously roundhoused.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
+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.
%
-Guns don't kill people. Chuck Norris kills people.
+In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese.
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
+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.
%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
+In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
+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."
%
-Chuck Norris uses pepper spray to spice up his steaks.
+James Bond has a license to kill. He got it from Chuck Norris.
%
-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.
+Jedis are now taught to use the "Chuck".
%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+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.
%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
+May the Force be with Chuck Norris... for its own good.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+Merlin was Chuck Norris' assistant.
%
Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
+Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
+Chuck Norris' keyboard has no control key. Chuck Norris is always in control.
%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
+Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store.
%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in 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
-%
-Chuck Norris played the game of thrones and won
-%
-Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses
-%
-Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
-%
-Chuck Norris once won the tour de france riding a " big wheel"
-%
-May the Force be with Chuck Norris... for it's own good.
-%
-Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade
-%
-During the Civil War Chuck Norris was a slave, his master would often beg him for mercy
-%
-Chuck Norris' glass is never half full or half empty. It stays full even after he takes a drink.
-%
- King Kong climbed the Empire State building in fear of Chuck Norris who was downstairs at the time.
-%
-Chuck Norris can French kiss his elbow.
-%
-Chuck Norris never trains, because he's Chuck Norris.
-%
-Every phobia known to man has a phobia of Chuck Norris
+One glance from Chuck Norris and snow turns itself yellow.
%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
+One time a test cheated on Chuck Norris.
%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
+Only Chuck Norris can win the mind game, 'cause he never minds.
%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
+Only Chuck Norris is stronger than an Altoid.
%
Outer space exists because it's afraid to be on the same planet with Chuck Norris.
%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
+Ozzy Osbourne once accidentally bit the head off a live bat - Chuck Norris once deliberately bit the head off a live pterodactyl.
%
-Chuck Norris can slam a revolving door.
+Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face.
%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
+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.
%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
+Simon doesn't say... Chuck Norris says.
%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
+Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you.
%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
+Some kids pee their name in snow. Chuck Norris pees his name in concrete.
%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
+Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag.
%
Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store.
-%
-Chuck Norris Can Power Solar Panels. At Night.
-%
-When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
-%
-Chuck Norris is so hard, he uses diamonds as stress balls.
-%
-Chuck Norris can roundhouse kick someone through a window without breaking the glass
-%
-Chuck Norris. Enough said.
-%
-The letters in Chuck Norris cannot be unscrambled.
-%
-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 was heard in a soundproof room!
-%
-Chuck Norris can see in 3D with just one eye.
-%
-Chuck Norris owns all number 1 pencils.
-%
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face.
%
-Chuck Norris doesn’t brew up tea. He sucks the bag.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
+Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
%
-Chuck Norris uses pepper spray to spice up his steaks.
+That's not an eclipse. That's the sun hiding from Chuck Norris.
%
-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.
+The Beatles are on iTunes because Chuck Norris bought a Mac.
%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
+The Earth is made up of two-thirds water and one-third Chuck Norris.
%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norris roundhouse kicked it into the Sun.
%
The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-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
-%
-Chuck Norris made a statue bleed.
-%
-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.
-%
-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 kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened.
-%
-Chuck Norris can roundhouse-kick round houses into squares.
-%
-Chuck Norris is allowed two carry-ons.
-%
-Chuck Norris can divide by zero.
-%
-Chuck Norris does not have a cell phone because he hears everything
-%
-Chuck Norris isn't appropriate...appropriate isn't Chuck Norris
-%
-Earth's rotation is purely governed by the direction that Chuck Norris is walking.
-%
-Chuck Norris drowned a man ON LAND.
-%
-The Jone's are trying to keep up with Chuck Norris
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
+The Joneses are trying to keep up with Chuck Norris.
%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
+The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.”
%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
+The answer to life, the universe and everything isn't 42. It's Chuck Norris.
%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
+The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk.
%
-Chuck Norris can lead a horse to water AND make it drink.
+The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live.
%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
+The chief export of Chuck Norris is pain.
%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
+The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
%
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
+The letters in Chuck Norris cannot be unscrambled.
%
-Chuck Norris bowled a 301 after constructing another pin out of his beard hair
+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.
%
-Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
-%
-There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
-%
-Chuck Norris' dog pick up after him.
-%
-Jedis are now taught to use the "Chuck"
-%
-Chuck Norris dosent carry a list. He always knows what to do.
-%
-When Chuck Norris performs a roundhouse kick, he's actually measuring the circumference of the universe.
-%
-Walker: Texas Ranger went into syndication before the first episode was shot.
-%
-Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
-%
-"Walker Texas Ranger: The Movie 3-D" was considered by Warner Brothers; however the technology to create the visual effects will never be possible.
-%
-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."
-%
-Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+The only sure things are Death and Taxes, and when Chuck Norris goes to work for the IRS, they'll be the same thing.
%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+The only way sharks will come near CN underwater is when CN is inside of a cage.
%
-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.
+The only word that rhymes with orange is Chuck Norris.
%
-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.
+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.
%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
+The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon.
%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Aliens fear that Chuck Norris might abduct them.
+The red phone in the oval office rings directly to Chuck Norris' cell phone.
%
-Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick!
+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.
%
-How much wood could a woodchuck chuck if a woodchuck could chuck wood? No woodchuck could chuck Chuck's wood!
+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.
%
-Chuck Norris can do a regime change with a roundhouse kick.
-%
-Chuck Norris CAN spell with an I before E even after C.
-%
-Ghosts can see Chuck Norris
-%
-The answer to life, the universe and everything isnt 42. It's Chuck Norris.
-%
-When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
-%
-Chuck Norris once thought he was wrong. He was, however, mistaken.
-%
-Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming
-%
-"The wind cries Chuck Norris"
-%
-Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
+The truth hurts, doesn't it? Chuck Norris' truth kills.
%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
+There is no chin behind Chuck Norris' beard. There is only another fist.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+There is no limbo, only a world that doesn't know of Chuck Norris.
%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
%
-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.
+There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live.
%
-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.
+This one time at band camp... BAM! Chuck Norris.
%
-The quickest way to a man's heart is with Chuck Norris' fist.
+Those who ignore history, are doomed by Chuck Norris.
%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
+Trick me once, shame on you, trick Chuck Norris.. rest in peace.
%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
+Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
%
-Chuck Norris can win a game of Connect Four in only three moves.
+Walker: Texas Ranger went into syndication before the first episode was shot.
%
What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Chuck Norris: even Naruto can't believe it
-%
-Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket
-%
-Chuck Norris roundhouse kicks people in the face first and asks questions later.
-%
-Chuck Norris is the only one who can tear a facebook page!
-%
-Chuck Norris doesn't need air, he is air
-%
-Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal.
-%
-Achievement Unlocked: Chuck Norris of Death
-%
-Chuck Norris is the ghost in paranormal activity.
-%
-Chuck Norris can't get fired by Donald Trump
-%
-Ozzy Osbourne once accidentally bit the head off a live bat - Chuck Norris once deliberately bit the head off a live pterodactyl.
-%
-Note to self: Don’t be the cashier to tell Chuck Norris his coupons have expired.
-%
-Chuck Norris was what Willis was talking about.
-%
-Chuck Norris is entitiled to his own facts.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
+Whatever Chuck Norris wants, it will instantly appear.
%
-Chuck Norris counted to infinity - twice.
+When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
+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.
%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
+When Chuck Norris drinks water, the water automatically pasteurized.
%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
+When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just give him stacks of money.
%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
+When Chuck Norris goes to rodeos, bulls ride him.
%
-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."
+When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section.
%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
+When Chuck Norris inhales helium, his voice doesn't change.
%
-While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
+When Chuck Norris performs a roundhouse kick, he's actually measuring the circumference of the universe.
%
When Chuck Norris played the card game War with a friend, France surrendered.
%
-If Goliath listened to Chuck Norris he would have won.
-%
-Chuck Norris can defuse bomb even if he cut the wrong wire
-%
-Chuck Norris sleeps in Seattle.
-%
-Chuck Norris shot a man with a knife
-%
-The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
-%
-Chuck Norris CAN balance the light-switch between ON and OFF.
-%
-If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else!
-%
-In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
-%
-Chuck Norris is the reason tumbleweeds tumble
-%
-The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norris roundhouse kicked it into the Sun.
-%
-Chuck Norris can terminate a repeating decimal.
-%
-When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
-%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
+When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
%
-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.
+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.
%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
-%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
-%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
-%
-Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury
-%
-The only word that rhymes with orange is Chuck Norris
-%
-Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should
-%
-gmail@chucknorris.com
-%
-Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month
-%
-Chuck Norris has killed the Dead Sea
+When Chuck Norris tosses a coin, it lands on both heads and tails.
%
-On the keyboard there is no control button because Chuck Norris is always in control.
+When God said "Let there be light!", Chuck Norris said "Only for half the day."
%
-The truth hurts dosen't it, Chuck Norris' truth kills.
+When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens.
%
-Chuck Norris sent a BBM to an iphone.
+When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
%
-When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens.
+When chuck Norris was in school, he made his PE teacher run laps.
%
-Chuck Norris once cried just to see what it was like. The end result was the creation of life.
+When does Chuck Norris run out of shotgun bullets? whenever he wants to.
%
-Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth
+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.
%
-Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-Outer space exists because it's afraid to be on the same planet with Chuck Norris.
-%
-Chuck Norris does not sleep. He waits.
-%
-Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
-%
-Chuck Norris is the reason why Waldo is hiding.
-%
-Chuck Norris counted to infinity - twice.
-%
-There is no chin behind Chuck Norris’ beard. There is only another fist.
-%
-When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
-%
-Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
-%
-Chuck Norris' hand is the only hand that can beat a Royal Flush.
-%
-Chuck Norris can lead a horse to water AND make it drink.
-%
-Chuck Norris doesn’t wear a watch. HE decides what time it is.
-%
-Chuck Norris can slam a revolving door.
-%
-Chuck Norris does not get frostbite. Chuck Norris bites frost.
-%
-Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
-%
-Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
-%
-If you spell Chuck Norris in Scrabble, you win. Forever.
-%
-Guns don't kill people. Chuck Norris kills people.
-%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-The chief export of Chuck Norris is Pain.
-%
-Chuck Norris has two speeds. Walk, and Kill.
-%
-The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
-%
-Chuck Norris drives an ice cream truck covered in human skulls.
-%
-Chuck Norris is my Homeboy.
-%
-Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
-%
-Chuck Norris uses pepper spray to spice up his steaks.
-%
-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.
-%
-Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
-%
-Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
-%
-The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
-%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
-%
-Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
-%
-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.
-%
-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.
-%
-The quickest way to a man's heart is with Chuck Norris' fist.
-%
-Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
-%
-CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
-%
-Chuck Norris can win a game of Connect Four in only three moves.
-%
-What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
-%
-Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
+When things go bump in the night, it's Chuck Norris
%
-Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
+While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
%
-Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
-%
-Chuck Norris doesn’t wash his clothes, he disembowels them.
-%
-A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
-%
-Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
-%
-Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
-%
-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."
-%
-Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
-%
-Only Chuck Norris is stronger than an Altoid.
-%
-Chuck Norris has a battlecruiser AND a car.
-%
-Chuck Norris burnt a fire proof vest, UNDERWATER!
-%
-Chuck Norris was once turned down for American Idol. When Simon was questioned about it, he replied "I'm retiring after this season". I wonder why?
-%
-Chuck Norris doesn't cheat death, he beats it fair and square.
-%
-When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact .
-%
-Chuck Norris made the big bang just by clicking his fingers
-%
-Trick me once, shame on you, trick Chuck Norris.....rest in peace.
-%
-Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face.
-%
-This one time at band camp... BAM! Chuck Norris.
-%
-Chuck Norris protects his body guards.
+Why didn't the chicken cross the road? Because Chuck Norris got to it first.
%
-Chuck Norris watched the first steps on the moon... From his summer home on Mars
+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.
%
-The Earth is made up of two-thirds water and one-third Chuck Norris.
+http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
%
diff --git a/plugins/cloudapp/README.md b/plugins/cloudapp/README.md
new file mode 100644
index 000000000..ef304edc2
--- /dev/null
+++ b/plugins/cloudapp/README.md
@@ -0,0 +1,26 @@
+# CloudApp plugin
+
+## The CloudApp API is deprecated, so the plugin will be removed shortly
+
+[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
index 99252f690..a4d92a080 100644
--- a/plugins/cloudapp/cloudapp.plugin.zsh
+++ b/plugins/cloudapp/cloudapp.plugin.zsh
@@ -1,2 +1,4 @@
-#!/bin/zsh
-alias cloudapp=$ZSH/plugins/cloudapp/cloudapp.rb
+print -Pn "%F{yellow}"
+print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will"
+print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list."
+print -Pn "%f"
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/codeclimate/README.md b/plugins/codeclimate/README.md
new file mode 100644
index 000000000..0d712ac63
--- /dev/null
+++ b/plugins/codeclimate/README.md
@@ -0,0 +1,8 @@
+# codeclimate plugin
+
+This plugin adds autocompletion for the [`codeclimate` CLI](https://github.com/codeclimate/codeclimate).
+
+To use it, add `codeclimate` to the plugins array in your zshrc file:
+```zsh
+plugins=(... codeclimate)
+```
diff --git a/plugins/coffee/README.md b/plugins/coffee/README.md
index d6cd074d3..2baade844 100644
--- a/plugins/coffee/README.md
+++ b/plugins/coffee/README.md
@@ -1,4 +1,4 @@
-## Coffeescript Plugin
+# Coffeescript Plugin
This plugin provides aliases for quickly compiling and previewing your
coffeescript code.
diff --git a/plugins/colemak/README.md b/plugins/colemak/README.md
new file mode 100644
index 000000000..4da4bc126
--- /dev/null
+++ b/plugins/colemak/README.md
@@ -0,0 +1,48 @@
+# Colemak plugin
+
+This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps)
+for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position:
+
+![Colemak layout on a US keyboard](https://colemak.com/wiki/images/6/6c/Colemak2.png)
+
+To use it, add it to the plugins array in your `~/.zshrc` file:
+
+```
+plugins=(... colemak)
+```
+
+You will also need to enable `vi` mode, so add another line to `~/.zshrc`:
+```
+bindkey -v
+```
+
+Restart your shell and hit the `<ESC>` key to activate `vicmd` (navigation) mode,
+and start navigating `zsh` with your new keybindings!
+
+## Key bindings for vicmd
+
+| Old | New | Binding | Description |
+|------------|------------|---------------------------|----------------------------------------------------|
+| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line |
+| `j` | `n` | down-line-or-history | Move one line down or command history forwards |
+| `k` | `e` | up-line-or-history | Move one line up or command history backwards |
+| `l` | `i` | vi-forward-char | Move one character to the right |
+| `n` | `k` | vi-repeat-search | Repeat command search forwards |
+| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards |
+| `i` | `u` | vi-insert | Enter insert mode |
+| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode |
+| `<none>` | `l` | vi-undo-change | Undo change |
+| `J` | `N` | vi-join | Join the current line with the next one |
+| `e` | `j` | vi-forward-word-end | Move to the end of the next word |
+| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word |
+
+## Key bindings for less
+
+| Keyboard shortcut | `less` key binding |
+|-------------------|--------------------|
+| `n` | forw-line |
+| `e` | back-line |
+| `k` | repeat-search |
+| `ESC`+`k` | repeat-search-all |
+| `K` | reverse-search |
+| `ESC`+`K` | reverse-search-all |
diff --git a/plugins/colored-man-pages/README.md b/plugins/colored-man-pages/README.md
new file mode 100644
index 000000000..4cbf64d3e
--- /dev/null
+++ b/plugins/colored-man-pages/README.md
@@ -0,0 +1,32 @@
+# Colored man pages plugin
+
+This plugin adds colors to man pages.
+
+To use it, add `colored-man-pages` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... colored-man-pages)
+```
+
+It will also automatically colorize man pages displayed by `dman` or `debman`,
+from [`debian-goodies`](https://packages.debian.org/stable/debian-goodies).
+
+You can also try to color other pages by prefixing the respective command with `colored`:
+
+```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 1bea536e0..37faed672 100644
--- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh
+++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
@@ -1,32 +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
-
-function man() {
- 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" \
- man "$@"
+# 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() {
+ 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 "$@"
}
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 c006071f9..405bb6d39 100644
--- a/plugins/colorize/README.md
+++ b/plugins/colorize/README.md
@@ -2,17 +2,55 @@
With this plugin you can syntax-highlight file contents of over 300 supported languages and other text formats.
-To use it, add colorize to the plugins array of your zshrc file:
+Colorize will highlight the content based on the filename extension. If it can't find a syntax-highlighting
+method for a given extension, it will try to find one by looking at the file contents. If no highlight method
+is found it will just cat the file normally, without syntax highlighting.
+
+## Setup
+
+To use it, add colorize to the plugins array of your `~/.zshrc` file:
```
plugins=(... colorize)
```
-## Usage
+## Configuration
+
+### Requirements
+
+This plugin requires that at least one of the following tools is installed:
+
+* [Chroma](https://github.com/alecthomas/chroma)
+* [Pygments](https://pygments.org/download/)
+
+### Colorize tool
+
+Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable:
+
+```
+ZSH_COLORIZE_TOOL=chroma
+```
-* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided). If no arguments are passed it will colorize the standard input or stdin.
+### Styles
-Colorize will highlight the content based on the filename extension. If it can't find a syntax-highlighting method for a given extension, it will try to find one by looking at the file contents. If no highlight method is found it will just cat the file normally, without syntax highlighting.
+Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable:
+
+```
+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
-## Requirements
+* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
+ If no files are passed it will colorize the standard input.
-You have to install Pygments first: [pygments.org](http://pygments.org/download/)
+* `cless [less-options] <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and open less.
+ If no files are passed it will colorize the standard input.
+ The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope.
diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
index 8eede9a94..8ea98f80a 100644
--- a/plugins/colorize/colorize.plugin.zsh
+++ b/plugins/colorize/colorize.plugin.zsh
@@ -1,28 +1,114 @@
-# easier alias to use the plugin
-alias ccat='colorize_via_pygmentize'
+# Easier alias to use the plugin
+alias ccat="colorize_cat"
+alias cless="colorize_less"
-colorize_via_pygmentize() {
- if ! (( $+commands[pygmentize] )); then
- echo "package 'Pygments' is not installed!"
+# '$0:A' gets the absolute path of this file
+ZSH_COLORIZE_PLUGIN_PATH=$0:A
+
+colorize_check_requirements() {
+ local -a available_tools
+ available_tools=("chroma" "pygmentize")
+
+ if [ -z "$ZSH_COLORIZE_TOOL" ]; then
+ if (( $+commands[pygmentize] )); then
+ ZSH_COLORIZE_TOOL="pygmentize"
+ elif (( $+commands[chroma] )); then
+ ZSH_COLORIZE_TOOL="chroma"
+ else
+ echo "Neither 'pygments' nor 'chroma' is installed!" >&2
+ return 1
+ fi
+ fi
+
+ if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
+ echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
+ return 1
+ elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
+ echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
return 1
fi
+}
+
+colorize_cat() {
+ if ! colorize_check_requirements; then
+ return 1
+ fi
+
+ # If the environment variable ZSH_COLORIZE_STYLE
+ # is set, use that theme instead. Otherwise,
+ # use the default.
+ if [ -z "$ZSH_COLORIZE_STYLE" ]; then
+ # Both pygmentize & chroma support 'emacs'
+ ZSH_COLORIZE_STYLE="emacs"
+ fi
- # pygmentize stdin if no arguments passed
+ # Use stdin if no arguments have been passed.
if [ $# -eq 0 ]; then
- pygmentize -g
+ if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
+ pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
+ else
+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
+ fi
return $?
fi
- # guess lexer from file extension, or
- # guess it from file contents if unsuccessful
+ # Guess lexer from file extension, or guess it from file contents if unsuccessful.
local FNAME lexer
- for FNAME in $@
- do
- lexer=$(pygmentize -N "$FNAME")
- if [[ $lexer != text ]]; then
- pygmentize -l "$lexer" "$FNAME"
+ for FNAME in "$@"; do
+ if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
+ lexer=$(pygmentize -N "$FNAME")
+ if [[ $lexer != text ]]; then
+ pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
+ else
+ pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
+ fi
else
- pygmentize -g "$FNAME"
+ chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
fi
done
}
+
+# The less option 'F - Forward forever; like "tail -f".' will not work in this implementation
+# caused by the lack of the ability to follow the file within pygmentize.
+colorize_less() {
+ if ! colorize_check_requirements; then
+ return 1
+ fi
+
+ _cless() {
+ # LESS="-R $LESS" enables raw ANSI colors, while maintain already set options.
+ local LESS="-R $LESS"
+
+ # This variable tells less to pipe every file through the specified command
+ # (see the man page of less INPUT PREPROCESSOR).
+ # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
+ # the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
+ # Therefore we must source this file to make colorize_cat available in the
+ # preprocessor without the interactive mode.
+ # `2>/dev/null` will suppress the error for large files 'broken pipe' of the python
+ # script pygmentize, which will show up if less has not fully "loaded the file"
+ # (e.g. when not scrolled to the bottom) while already the next file will be displayed.
+ local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
+ ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
+ colorize_cat %s 2> /dev/null'"
+
+ # LESSCLOSE will be set to prevent any errors by executing a user script
+ # which assumes that his LESSOPEN has been executed.
+ local LESSCLOSE=""
+
+ LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" command less "$@"
+ }
+
+ if [ -t 0 ]; then
+ _cless "$@"
+ else
+ # The input is not associated with a terminal, therefore colorize_cat will
+ # colorize this input and pass it to less.
+ # Less has now to decide what to use. If any files have been provided, less
+ # will ignore the input by default, otherwise the colorized input will be used.
+ # If files have been supplied and the input has been redirected, this will
+ # lead to unnecessary overhead, but retains the ability to use the less options
+ # without checking for them inside this script.
+ colorize_cat | _cless "$@"
+ fi
+}
diff --git a/plugins/command-not-found/README.md b/plugins/command-not-found/README.md
index df62d1f07..f267f0c89 100644
--- a/plugins/command-not-found/README.md
+++ b/plugins/command-not-found/README.md
@@ -27,5 +27,7 @@ It works out of the box with the command-not-found packages for:
- [Arch Linux](https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found)
- [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 ba1262de6..3ec13429c 100644
--- a/plugins/command-not-found/command-not-found.plugin.zsh
+++ b/plugins/command-not-found/command-not-found.plugin.zsh
@@ -1,33 +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
- }
-fi
+## Platforms with a built-in command-not-found handler init file
-# OSX command-not-found support
-# https://github.com/Homebrew/homebrew-command-not-found
-if type brew &> /dev/null; then
- if brew command command-not-found-init > /dev/null 2>&1; then
- eval "$(brew command-not-found-init)";
+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
+
+# 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
+
+# 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
new file mode 100644
index 000000000..b6f34cb54
--- /dev/null
+++ b/plugins/common-aliases/README.md
@@ -0,0 +1,123 @@
+# Common Aliases Plugin
+
+This plugin creates helpful shortcut aliases for many commonly used commands.
+
+To use it add `common-aliases` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... common-aliases)
+```
+
+## Aliases
+
+### ls command
+
+| Alias | Command | Description |
+|-------|---------------|--------------------------------------------------------------------------------|
+| l | `ls -lFh` | List files as a long list, show size, type, human-readable |
+| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable |
+| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable |
+| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable |
+| ll | `ls -l` | List files as a long list |
+| ldot | `ls -ld .*` | List dot files as a long list |
+| lS | `ls -1FSsh` | List files showing only size and name sorted by size |
+| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) |
+| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) |
+
+### File handling
+
+| Alias | Command | Description |
+|-------|-----------------------|------------------------------------------------------------------------------------|
+| rm | `rm -i` | Remove a file |
+| cp | `cp -i` | Copy a file |
+| mv | `mv -i` | Move a file |
+| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
+| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
+| duf | `du -sh` | Display the size of files in current location in human-readable form |
+| t | `tail -f` | Shorthand for tail which outputs the last part of a file |
+
+### find and grep
+
+| Alias | Command | Description |
+|-------|-----------------------------------------------------|-----------------------------------------|
+| 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 |
+|-----------|---------------------|-------------------------------------------------------------|
+| h | `history` | Lists all recently used commands |
+| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands |
+| help | `man` | Opens up the man page for a command |
+| p | `ps -f` | Displays currently executing processes |
+| sortnr | `sort -n -r` | Used to sort the lines of a text file |
+| unexport | `unset` | Used to unset an environment variable |
+
+## Global aliases
+
+These aliases are expanded in any position in the command line, meaning you can use them even at the
+end of the command you've typed. Examples:
+
+Quickly pipe to less:
+```zsh
+$ ls -l /var/log L
+# will run
+$ ls -l /var/log | less
+```
+Silences stderr output:
+```zsh
+$ find . -type f NE
+# will run
+$ find . -type f 2>/dev/null
+```
+
+| Alias | Command | Description |
+|-------|-----------------------------|-------------------------------------------------------------|
+| H | `\| head` | Pipes output to head which outputs the first part of a file |
+| T | `\| tail` | Pipes output to tail which outputs the last part of a file |
+| G | `\| grep` | Pipes output to grep to search for some word |
+| L | `\| less` | Pipes output to less, useful for paging |
+| M | `\| most` | Pipes output to more, useful for paging |
+| LL | `2>&1 \| less` | Writes stderr to stdout and passes it to less |
+| CA | `2>&1 \| cat -A` | Writes stderr to stdout and passes it to cat |
+| NE | `2 > /dev/null` | Silences stderr |
+| NUL | `> /dev/null 2>&1` | Silences both stdout and stderr |
+| P | `2>&1\| pygmentize -l pytb` | Writes stderr to stdout and passes it to pygmentize |
+
+## File extension aliases
+
+These are special aliases that are triggered when a file name is passed as the command. For example,
+if the pdf file extension is aliased to `acroread` (a popular Linux pdf reader), when running `file.pdf`
+that file will be open with `acroread`.
+
+### Reading Docs
+
+| Alias | Command | Description |
+|-------|-------------|-------------------------------------|
+| pdf | `acroread` | Opens up a document using acroread |
+| ps | `gv` | Opens up a .ps file using gv |
+| dvi | `xdvi` | Opens up a .dvi file using xdvi |
+| chm | `xchm` | Opens up a .chm file using xchm |
+| djvu | `djview` | Opens up a .djvu file using djview |
+
+### Listing files inside a packed file
+
+| Alias | Command | Description |
+|---------|-------------|-------------------------------------|
+| zip | `unzip -l` | Lists files inside a .zip file |
+| rar | `unrar l` | Lists files inside a .rar file |
+| tar | `tar tf` | Lists files inside a .tar file |
+| tar.gz | `echo` | Lists files inside a .tar.gz file |
+| ace | `unace l` | Lists files inside a .ace file |
+
+### Some other features
+
+- Opens urls in terminal using browser specified by the variable `$BROWSER`
+- Opens C, C++, Tex and text files using editor specified by the variable `$EDITOR`
+- Opens images using image viewer specified by the variable `$XIVIEWER`
+- Opens videos and other media using mplayer
diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
index 785a09c63..4e5ff848f 100644
--- a/plugins/common-aliases/common-aliases.plugin.zsh
+++ b/plugins/common-aliases/common-aliases.plugin.zsh
@@ -13,7 +13,7 @@ alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt'
-alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file
+alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file
alias grep='grep --color'
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
@@ -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'
@@ -50,19 +50,20 @@ alias mv='mv -i'
# zsh is able to auto-do some kungfoo
# depends on the SUFFIX :)
+autoload -Uz is-at-least
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/compleat/README.md b/plugins/compleat/README.md
new file mode 100644
index 000000000..af0e383be
--- /dev/null
+++ b/plugins/compleat/README.md
@@ -0,0 +1,9 @@
+# compleat plugin
+
+This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion.
+
+To use it, add compleat to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... compleat)
+```
diff --git a/plugins/composer/README.md b/plugins/composer/README.md
index 2b4bae579..7a5f7256e 100644
--- a/plugins/composer/README.md
+++ b/plugins/composer/README.md
@@ -12,18 +12,20 @@ plugins=(... composer)
## Aliases
-| Alias | Command | Description |
-| ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- |
-| `c` | composer | Starts composer |
-| `csu` | composer self-update | Updates composer to the latest version |
-| `cu` | composer update | Updates composer dependencies and `composer.lock` file |
-| `cr` | composer require | Adds new packages to `composer.json` |
-| `crm` | composer remove | Removes packages from `composer.json` |
-| `ci` | composer install | Resolves and installs dependencies from `composer.json` |
-| `ccp` | composer create-project | Create new project from an existing package |
-| `cdu` | composer dump-autoload | Updates the autoloader |
-| `cdo` | composer dump-autoload --optimize-autoloader | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
-| `cgu` | composer global update | Allows update command to run on COMPOSER_HOME directory |
-| `cgr` | composer global require | Allows require command to run on COMPOSER_HOME directory |
-| `cgrm` | composer global remove | Allows remove command to run on COMPOSER_HOME directory |
-| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
+| Alias | Command | Description |
+| ------ | ------------------------------------------- | --------------------------------------------------------------------------------------- |
+| `c` | `composer` | Starts composer |
+| `csu` | `composer self-update` | Updates composer to the latest version |
+| `cu` | `composer update` | Updates composer dependencies and `composer.lock` file |
+| `cr` | `composer require` | Adds new packages to `composer.json` |
+| `crm` | `composer remove` | Removes packages from `composer.json` |
+| `ci` | `composer install` | Resolves and installs dependencies from `composer.json` |
+| `ccp` | `composer create-project` | Create new project from an existing package |
+| `cdu` | `composer dump-autoload` | Updates the autoloader |
+| `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
+| `cgu` | `composer global update` | Allows update command to run on COMPOSER_HOME directory |
+| `cgr` | `composer global require` | Allows require command to run on COMPOSER_HOME directory |
+| `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME directory |
+| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
+| `co` | `composer outdated` | Shows a list of installed packages with available updates |
+| `cod` | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies |
diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
index 634961023..218a13e5f 100644
--- a/plugins/composer/composer.plugin.zsh
+++ b/plugins/composer/composer.plugin.zsh
@@ -15,20 +15,16 @@ _composer_get_required_list () {
}
_composer () {
- local curcontext="$curcontext" state line
- typeset -A opt_args
- _arguments \
- '1: :->command'\
- '*: :->args'
-
- case $state in
- command)
- compadd $(_composer_get_command_list)
- ;;
- *)
- compadd $(_composer_get_required_list)
- ;;
- esac
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ _arguments \
+ '*:: :->subcmds'
+
+ if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then
+ compadd $(_composer_get_command_list)
+ else
+ compadd $(_composer_get_required_list)
+ fi
}
compdef _composer composer
@@ -43,17 +39,31 @@ alias crm='composer remove'
alias ci='composer install'
alias ccp='composer create-project'
alias cdu='composer dump-autoload'
-alias cdo='composer dump-autoload --optimize-autoloader'
+alias cdo='composer dump-autoload -o'
alias cgu='composer global update'
alias cgr='composer global require'
alias cgrm='composer global remove'
+alias co='composer outdated'
+alias cod='composer outdated --direct'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
- export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null)
+ autoload -Uz _store_cache _retrieve_cache _cache_invalid
+
+ _retrieve_cache composer
+
+ if [[ -z $__composer_bin_dir ]]; then
+ __composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
+ _store_cache composer __composer_bin_dir
+ fi
+
+ # Add Composer's global binaries to PATH
+ export PATH="$PATH:$__composer_bin_dir"
+
+ unset __composer_bin_dir
else
[ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin
[ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin
diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh
index cc205d40f..483ed5a5f 100644
--- a/plugins/copybuffer/copybuffer.plugin.zsh
+++ b/plugins/copybuffer/copybuffer.plugin.zsh
@@ -1,9 +1,9 @@
# copy the active line from the command line buffer
-# onto the system clipboard (requires clipcopy plugin)
+# onto the system clipboard
copybuffer () {
if which clipcopy &>/dev/null; then
- echo $BUFFER | clipcopy
+ printf "%s" "$BUFFER" | clipcopy
else
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
fi
diff --git a/plugins/copyfile/README.md b/plugins/copyfile/README.md
index 53138ad06..a110b83fe 100644
--- a/plugins/copyfile/README.md
+++ b/plugins/copyfile/README.md
@@ -3,7 +3,8 @@
Puts the contents of a file in your system clipboard so you can paste it anywhere.
To use, add `copyfile` to your plugins array:
-```
+
+```zsh
plugins=(... copyfile)
```
diff --git a/plugins/cpanm/README.md b/plugins/cpanm/README.md
index 3803e3e00..13e93d0a5 100644
--- a/plugins/cpanm/README.md
+++ b/plugins/cpanm/README.md
@@ -1,9 +1,9 @@
# Cpanm
This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminus) ([docs](https://metacpan.org/pod/App::cpanminus)).
-
+
To use it add cpanm to the plugins array in your zshrc file.
-
- ```bash
+
+```zsh
plugins=(... cpanm)
```
diff --git a/plugins/dash/README.md b/plugins/dash/README.md
new file mode 100644
index 000000000..0ca3e4e44
--- /dev/null
+++ b/plugins/dash/README.md
@@ -0,0 +1,28 @@
+# Dash plugin
+
+This plugin adds command line functionality for [Dash](https://kapeli.com/dash),
+an API Documentation Browser for macOS. This plugin requires Dash to be installed
+to work.
+
+To use it, add `dash` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... dash)
+```
+
+## Usage
+
+- Open and switch to the dash application.
+```
+dash
+```
+
+- Query for something in dash app: `dash query`
+```
+dash golang
+```
+
+- You can optionally provide a keyword: `dash [keyword:]query`
+```
+dash python:tuple
+```
diff --git a/plugins/dash/dash.plugin.zsh b/plugins/dash/dash.plugin.zsh
index b00d4877e..ace2e33c1 100644
--- a/plugins/dash/dash.plugin.zsh
+++ b/plugins/dash/dash.plugin.zsh
@@ -35,36 +35,30 @@ _dash() {
if [[ "$locator" == "platform" ]]; then
# Since these are the only special cases right now, let's not do the
# expensive processing unless we have to
- if [[ "$keyword" == "python" || "$keyword" == "java" || \
- "$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
+ if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
- if [[ "$keyword" == "python" ]]; then
- if [[ "$docsetName" == "Python 2" ]]; then
- keyword="python2"
- elif [[ "$docsetName" == "Python 3" ]]; then
- keyword="python3"
- fi
- elif [[ "$keyword" == "java" ]]; then
- if [[ "$docsetName" == "Java SE7" ]]; then
- keyword="java7"
- elif [[ "$docsetName" == "Java SE6" ]]; then
- keyword="java6"
- elif [[ "$docsetName" == "Java SE8" ]]; then
- keyword="java8"
- fi
- elif [[ "$keyword" == "qt" ]]; then
- if [[ "$docsetName" == "Qt 5" ]]; then
- keyword="qt5"
- elif [[ "$docsetName" == "Qt 4" ]]; then
- keyword="qt4"
- elif [[ "$docsetName" == "Qt" ]]; then
- keyword="qt4"
- fi
- elif [[ "$keyword" == "cocos2d" ]]; then
- if [[ "$docsetName" == "Cocos3D" ]]; then
- keyword="cocos3d"
- fi
- fi
+ case "$keyword" in
+ python)
+ case "$docsetName" in
+ "Python 2") keyword="python2" ;;
+ "Python 3") keyword="python3" ;;
+ esac ;;
+ java)
+ case "$docsetName" in
+ "Java SE7") keyword="java7" ;;
+ "Java SE6") keyword="java6" ;;
+ "Java SE8") keyword="java8" ;;
+ esac ;;
+ qt)
+ case "$docsetName" in
+ "Qt 5") keyword="qt5" ;;
+ "Qt 4"|Qt) keyword="qt4" ;;
+ esac ;;
+ cocos2d)
+ case "$docsetName" in
+ Cocos3D) keyword="cocos3d" ;;
+ esac ;;
+ esac
fi
fi
diff --git a/plugins/debian/README.md b/plugins/debian/README.md
new file mode 100644
index 000000000..922d68cb3
--- /dev/null
+++ b/plugins/debian/README.md
@@ -0,0 +1,85 @@
+# debian
+
+This plugin provides Debian-related aliases and functions for zsh.
+
+To use it add `debian` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... debian)
+```
+
+## Settings
+
+- `$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.
+
+## Common Aliases
+
+| Alias | Command | Description |
+| ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- |
+| `age` | `apt-get` | Command line tool for handling packages |
+| `api` | `aptitude` | Same functionality as `apt-get`, provides extra options |
+| `acs` | `apt-cache search` | Command line tool for searching apt software package cache |
+| `aps` | `aptitude search` | Searches installed packages using aptitude |
+| `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format |
+| `afs` | `apt-file search --regexp` | Search file in packages |
+| `asrc` | `apt-get source` | Fetch source packages through `apt-get` |
+| `app` | `apt-cache policy` | Displays priority of package sources |
+
+## Superuser Operations Aliases
+
+| Alias | Command | Description |
+| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
+| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files |
+| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages |
+| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files |
+| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages |
+| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages |
+| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies |
+| `afu` | `sudo apt-file update` | Update the files in packages |
+| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
+| `ai` | `sudo $apt_pref install` | Command-line tool to install package |
+| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line |
+| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files |
+| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files |
+| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list |
+| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
+| `di` | `sudo dpkg -i` | Install all .deb files in the current directory |
+| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use |
+
+## Aliases - Commands using `su`
+
+| Alias | Command |
+| ----- | --------------------------------------------------------- |
+| `aac` | `su -ls "$apt_pref autoclean" root` |
+| `ac` | `su -ls "$apt_pref clean" root` |
+| `ad` | `su -lc "$apt_pref update" root` |
+| `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` |
+| `adu` | `su -lc "$apt_pref update && aptitude dist-upgrade" root` |
+| `afu` | `su -lc "apt-file update"` |
+| `au` | `su -lc "$apt_pref $apt_upgr" root` |
+| `dia` | `su -lc "dpkg -i ./*.deb" root` |
+
+## Miscellaneous Aliases
+
+| Alias | Command | Description |
+| --------- | ---------------------------------------------- | ------------------------------ |
+| `allpkgs` | `aptitude search -F "%p" --disable-columns ~i` | Display all installed packages |
+| `mydeb` | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package |
+
+## Functions
+
+| Function | Description |
+| ------------------- | --------------------------------------------------------------- |
+| `apt-copy` | Create a simple script that can be used to 'duplicate' a system |
+| `apt-history` | Displays apt history for a command |
+| `kerndeb` | Builds kernel packages |
+| `apt-list-packages` | List packages by size |
+
+## Authors
+
+- [@AlexBio](https://github.com/AlexBio)
+- [@dbb](https://github.com/dbb)
+- [@Mappleconfusers](https://github.com/Mappleconfusers)
diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
index 654b692d2..bde97cd30 100644
--- a/plugins/debian/debian.plugin.zsh
+++ b/plugins/debian/debian.plugin.zsh
@@ -1,25 +1,21 @@
-# Authors:
-# https://github.com/AlexBio
-# https://github.com/dbb
-# https://github.com/Mappleconfusers
-#
-# Debian-related zsh aliases and functions for zsh
-
-# 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 [[ -e $( which -p apt 2>&1 ) ]]; then
- apt_pref='apt'
- apt_upgr='upgrade'
-elif [[ -e $( which -p aptitude 2>&1 ) ]]; then
- apt_pref='aptitude'
- apt_upgr='safe-upgrade'
-else
- apt_pref='apt-get'
- apt_upgr='upgrade'
+
+if [[ -z $apt_pref || -z $apt_upgr ]]; 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'
+ fi
fi
# Use sudo by default if it's installed
-if [[ -e $( which -p sudo 2>&1 ) ]]; then
+if [[ -e $commands[sudo] ]]; then
use_sudo=1
fi
@@ -32,8 +28,7 @@ alias api='aptitude'
# Some self-explanatory aliases
alias acs="apt-cache search"
alias aps='aptitude search'
-alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \
- --no-gui --disable-columns search" # search package
+alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search"
# apt-file
alias afs='apt-file search --regexp'
@@ -46,60 +41,59 @@ alias app='apt-cache policy'
# superuser operations ######################################################
if [[ $use_sudo -eq 1 ]]; then
# commands using sudo #######
- alias aac='sudo $apt_pref autoclean'
- alias abd='sudo $apt_pref build-dep'
- alias ac='sudo $apt_pref clean'
- alias ad='sudo $apt_pref update'
- alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr'
- alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade'
- alias afu='sudo apt-file update'
- alias au='sudo $apt_pref $apt_upgr'
- alias ai='sudo $apt_pref install'
+ alias aac="sudo $apt_pref autoclean"
+ alias abd="sudo $apt_pref build-dep"
+ alias ac="sudo $apt_pref clean"
+ alias ad="sudo $apt_pref update"
+ alias adg="sudo $apt_pref update && sudo $apt_pref $apt_upgr"
+ alias adu="sudo $apt_pref update && sudo $apt_pref dist-upgrade"
+ alias afu="sudo apt-file update"
+ alias au="sudo $apt_pref $apt_upgr"
+ alias ai="sudo $apt_pref install"
# Install all packages given on the command line while using only the first word of each line:
# acs ... | ail
- alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install'
- alias ap='sudo $apt_pref purge'
- alias ar='sudo $apt_pref remove'
+ alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install"
+ alias ap="sudo $apt_pref purge"
+ alias ar="sudo $apt_pref remove"
# apt-get only
- alias ads='sudo apt-get dselect-upgrade'
+ alias ads="sudo apt-get dselect-upgrade"
# Install all .deb files in the current directory.
# Warning: you will need to put the glob in single quotes if you use:
# glob_subst
- alias dia='sudo dpkg -i ./*.deb'
- alias di='sudo dpkg -i'
+ alias dia="sudo dpkg -i ./*.deb"
+ 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 #########
else
- alias aac='su -ls \'$apt_pref autoclean\' root'
- abd() {
+ alias aac="su -ls '$apt_pref autoclean' root"
+ function abd() {
cmd="su -lc '$apt_pref build-dep $@' root"
print "$cmd"
eval "$cmd"
}
- alias ac='su -ls \'$apt_pref clean\' root'
- alias ad='su -lc \'$apt_pref update\' root'
- alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root'
- alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root'
- alias afu='su -lc "apt-file update"'
- alias ag='su -lc \'$apt_pref $apt_upgr\' root'
- ai() {
+ alias ac="su -ls '$apt_pref clean' root"
+ alias ad="su -lc '$apt_pref update' root"
+ alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root"
+ alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
+ alias afu="su -lc '$apt-file update'"
+ alias au="su -lc '$apt_pref $apt_upgr' root"
+ function ai() {
cmd="su -lc 'aptitude -P install $@' root"
print "$cmd"
eval "$cmd"
}
- ap() {
+ function ap() {
cmd="su -lc '$apt_pref -P purge $@' root"
print "$cmd"
eval "$cmd"
}
- ar() {
+ function ar() {
cmd="su -lc '$apt_pref -P remove $@' root"
print "$cmd"
eval "$cmd"
@@ -111,8 +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 ################################################################
@@ -121,16 +114,16 @@ fi
# Registers a compdef for $1 that calls $apt_pref with the commands $2
# To do that it creates a new completion function called _apt_pref_$2
#
-apt_pref_compdef() {
+function apt_pref_compdef() {
local f fb
f="_apt_pref_${2}"
eval "function ${f}() {
- shift words;
- service=\"\$apt_pref\";
- words=(\"\$apt_pref\" '$2' \$words);
- ((CURRENT++))
- test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
+ shift words;
+ service=\"\$apt_pref\";
+ words=(\"\$apt_pref\" '$2' \$words);
+ ((CURRENT++))
+ test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
}"
compdef "$f" "$1"
@@ -141,7 +134,7 @@ apt_pref_compdef abd "build-dep"
apt_pref_compdef ac "clean"
apt_pref_compdef ad "update"
apt_pref_compdef afu "update"
-apt_pref_compdef ag "$apt_upgr"
+apt_pref_compdef au "$apt_upgr"
apt_pref_compdef ai "install"
apt_pref_compdef ail "install"
apt_pref_compdef ap "purge"
@@ -158,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# Functions #################################################################
# create a simple script that can be used to 'duplicate' a system
-apt-copy() {
+function apt-copy() {
print '#!/bin/sh'"\n" > apt-copy.sh
cmd='$apt_pref install'
@@ -180,7 +173,7 @@ apt-copy() {
# apt-history rollback
# apt-history list
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
-apt-history () {
+function apt-history() {
case "$1" in
install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
@@ -209,11 +202,11 @@ apt-history () {
}
# Kernel-package building shortcut
-kerndeb () {
+function kerndeb() {
# temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
- appendage='-custom' # this shows up in $ (uname -r )
+ appendage='-custom' # this shows up in $(uname -r )
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
make-kpkg clean
@@ -223,10 +216,9 @@ kerndeb () {
}
# List packages by size
-function apt-list-packages {
+function apt-list-packages() {
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
grep -v deinstall | \
sort -n | \
awk '{print $1" "$2}'
}
-
diff --git a/plugins/deno/.gitignore b/plugins/deno/.gitignore
new file mode 100644
index 000000000..cba5b03e8
--- /dev/null
+++ b/plugins/deno/.gitignore
@@ -0,0 +1 @@
+_deno
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..a37b3bec4
--- /dev/null
+++ b/plugins/deno/deno.plugin.zsh
@@ -0,0 +1,23 @@
+# 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
+ if [[ ! -f $ZSH_CACHE_DIR/deno_version ]] \
+ || [[ "$(deno --version)" != "$(< "$ZSH_CACHE_DIR/deno_version")" ]] \
+ || [[ ! -f $ZSH/plugins/deno/_deno ]]; then
+ deno completions zsh > $ZSH/plugins/deno/_deno
+ deno --version > $ZSH_CACHE_DIR/deno_version
+ fi
+ autoload -Uz _deno
+ _comps[deno]=_deno
+fi
diff --git a/plugins/dircycle/README.md b/plugins/dircycle/README.md
index 3ac162f05..3c9b3a96f 100644
--- a/plugins/dircycle/README.md
+++ b/plugins/dircycle/README.md
@@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br
)
```
-2. Reload the source file or restart your Terminal session:
+2. Restart the shell or restart your Terminal session:
```console
- $ source ~/.zshrc
+ $ exec zsh
$
```
diff --git a/plugins/direnv/README.md b/plugins/direnv/README.md
new file mode 100644
index 000000000..8deaf38bb
--- /dev/null
+++ b/plugins/direnv/README.md
@@ -0,0 +1,15 @@
+# direnv plugin
+
+This plugin creates the [Direnv](https://direnv.net/) hook.
+
+To use it, add `direnv` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... direnv)
+```
+
+## Requirements
+
+In order to make this work, you will need to have the direnv installed.
+
+More info on the usage and install: https://github.com/direnv/direnv
diff --git a/plugins/direnv/direnv.plugin.zsh b/plugins/direnv/direnv.plugin.zsh
new file mode 100644
index 000000000..5e32c4c23
--- /dev/null
+++ b/plugins/direnv/direnv.plugin.zsh
@@ -0,0 +1,16 @@
+# Don't continue if direnv is not found
+command -v direnv &>/dev/null || return
+
+_direnv_hook() {
+ trap -- '' SIGINT;
+ eval "$(direnv export zsh)";
+ trap - SIGINT;
+}
+typeset -ag precmd_functions;
+if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
+ precmd_functions=( _direnv_hook ${precmd_functions[@]} )
+fi
+typeset -ag chpwd_functions;
+if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then
+ chpwd_functions=( _direnv_hook ${chpwd_functions[@]} )
+fi
diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md
index 511f2be17..223650727 100644
--- a/plugins/dirhistory/README.md
+++ b/plugins/dirhistory/README.md
@@ -7,6 +7,7 @@ To use it, add `dirhistory` to the plugins array in your zshrc file:
```zsh
plugins=(... dirhistory)
```
+
## Keyboard Shortcuts
| Shortcut | Description |
@@ -15,3 +16,24 @@ plugins=(... dirhistory)
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> |
| <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 |
+
+## 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.
+
+Also, navigate directory **hierarchy** using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented). ALT-UP moves to higher hierarchy (shortcut for 'cd ..'). ALT-DOWN moves into the first directory found in alphabetical order (useful to navigate long empty directories e.g. java packages)
+
+For example, if the shell was started, and the following commands were entered:
+
+```shell
+cd ~
+cd /usr
+cd share
+cd doc
+```
+
+Then entering ALT-LEFT at the prompt would change directory from /usr/share/doc to /usr/share, then if pressed again to /usr/, then ~. If ALT-RIGHT were pressed the directory would be changed to /usr/ again.
+
+After that, ALT-DOWN will probably go to /usr/bin (depends on your /usr structure), ALT-UP will return to /usr, then ALT-UP will get you to /
+
+**Currently the max history size is 30**. The navigation should work for xterm, PuTTY xterm mode, GNU screen, and on MAC with alternate keys as mentioned above.
diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
index 239915e48..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
#
@@ -53,7 +53,8 @@ function push_future() {
}
# Called by zsh when directory changes
-chpwd_functions+=(chpwd_dirhistory)
+autoload -U add-zsh-hook
+add-zsh-hook chpwd chpwd_dirhistory
function chpwd_dirhistory() {
push_past $PWD
# If DIRHISTORY_CD is not set...
@@ -107,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:
@@ -135,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
@@ -159,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:
@@ -184,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/dirpersist/README.md b/plugins/dirpersist/README.md
index 9880bc563..792fb4bfe 100644
--- a/plugins/dirpersist/README.md
+++ b/plugins/dirpersist/README.md
@@ -1,6 +1,7 @@
# Dirpersist plugin
-This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file.
+This plugin keeps a running tally of the previous 20 unique directories in the `$HOME/.zdirs` file.
+When you cd to a new directory, it is prepended to the beginning of the file.
To use it, add `dirpersist` to the plugins array in your zshrc file:
diff --git a/plugins/dirpersist/dirpersist.plugin.zsh b/plugins/dirpersist/dirpersist.plugin.zsh
index 616e2c3c6..daadc3850 100644
--- a/plugins/dirpersist/dirpersist.plugin.zsh
+++ b/plugins/dirpersist/dirpersist.plugin.zsh
@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi
-chpwd_functions+=(chpwd_dirpersist)
+autoload -U add-zsh-hook
+add-zsh-hook chpwd chpwd_dirpersist
chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack
diff --git a/plugins/django/README.md b/plugins/django/README.md
index 415f6b7ea..1740e55e5 100644
--- a/plugins/django/README.md
+++ b/plugins/django/README.md
@@ -34,23 +34,3 @@ runfcgi -- run this project as a fastcgi
runserver -- start a lightweight web server for development
...
```
-
-If you want to see the options available for a specific command, try:
-
-```zsh
-$> python manage.py makemessages (press <TAB> here)
-```
-
-And that would result in:
-
-```zsh
---all -a -- re-examine all code and templates
---domain -d -- domain of the message files (default: "django")
---extensions -e -- file extension(s) to examine (default: ".html")
---help -- display help information
---locale -l -- locale to process (default: all)
---pythonpath -- directory to add to the Python path
---settings -- python path to settings module
-...
-```
-
diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh
index 29a51d29d..c2d00c171 100644
--- a/plugins/django/django.plugin.zsh
+++ b/plugins/django/django.plugin.zsh
@@ -154,7 +154,7 @@ _managepy-makemessages(){
"--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
"--no-wrap[Don't break long message lines into several lines.]" \
"--no-location[Don't write '#: filename:line' lines.]" \
- '--no-obsolete[emove obsolete message strings.]' \
+ '--no-obsolete[Remove obsolete message strings.]' \
'--keep-pot[Keep .pot file after making messages.]' \
$nul_args && ret=0
}
@@ -374,7 +374,8 @@ _managepy-commands() {
_applist() {
local line
local -a apps
- _call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\
+ _call_program help-command "python -c \"import sys; del sys.path[0];\\
+ import os.path as op, re, django.conf;\\
bn=op.basename(op.abspath(op.curdir));[sys\\
.stdout.write(str(re.sub(r'^%s\.(.*?)$' %
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
diff --git a/plugins/dnf/README.md b/plugins/dnf/README.md
index f9ef496fa..dc0d1e0a0 100644
--- a/plugins/dnf/README.md
+++ b/plugins/dnf/README.md
@@ -1,10 +1,14 @@
-## Description
+# dnf plugin
-This plugin makes `dnf` usage easier by adding aliases for the most
-common commands.
+This plugin makes `dnf` usage easier by adding aliases for the most common commands.
-`dnf` is the new package manager for RPM-based distributions, which
-replaces `yum`.
+`dnf` is the new package manager for RPM-based distributions, which replaces `yum`.
+
+To use it, add `dnf` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... dnf)
+```
## Aliases
diff --git a/plugins/dnote/README.md b/plugins/dnote/README.md
new file mode 100644
index 000000000..e1b9b7044
--- /dev/null
+++ b/plugins/dnote/README.md
@@ -0,0 +1,51 @@
+# Dnote Plugin
+
+This plugin adds auto-completion for [Dnote](https://dnote.io) project.
+
+To use it, add `dnote` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(dnote)
+```
+
+## Usage
+
+At the basic level, this plugin completes all Dnote commands.
+
+```zsh
+$ dnote a(press <TAB> here)
+```
+
+would result in:
+
+```zsh
+$ dnote add
+```
+
+For some commands, this plugin dynamically suggests matching book names.
+
+For instance, if you have three books that begin with 'j': 'javascript', 'job', 'js',
+
+```zsh
+$ dnote view j(press <TAB> here)
+```
+
+would result in:
+
+```zsh
+$ dnote v j
+javascript job js
+```
+
+As another example,
+
+```zsh
+$ dnote edit ja(press <TAB> here)
+```
+
+would result in:
+
+
+```zsh
+$ dnote v javascript
+``````
diff --git a/plugins/dnote/_dnote b/plugins/dnote/_dnote
new file mode 100644
index 000000000..c8b33486a
--- /dev/null
+++ b/plugins/dnote/_dnote
@@ -0,0 +1,39 @@
+#compdef dnote
+
+local -a _1st_arguments
+
+_1st_arguments=(
+ 'add:add a new note'
+ 'view:list books, notes, or view a content'
+ 'edit:edit a note or a book'
+ 'remove:remove a note or a book'
+ 'find:find notes by keywords'
+ 'sync:sync data with the server'
+ 'login:login to the dnote server'
+ 'logout:logout from the dnote server'
+ 'version:print the current version'
+ 'help:get help about any command'
+)
+
+get_booknames() {
+ local names=$(dnote view --name-only)
+ local -a ret
+
+ while read -r line; do
+ ret+=("${line}")
+ done <<< "$names"
+
+ echo "$ret"
+}
+
+if (( CURRENT == 2 )); then
+ _describe -t commands "dnote subcommand" _1st_arguments
+ return
+elif (( CURRENT == 3 )); then
+ case "$words[2]" in
+ v|view|a|add)
+ _alternative \
+ "names:book names:($(get_booknames))"
+ esac
+fi
+
diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md
index 07a87bc81..13f3c2cea 100644
--- a/plugins/docker-compose/README.md
+++ b/plugins/docker-compose/README.md
@@ -4,26 +4,29 @@ This plugin provides completion for [docker-compose](https://docs.docker.com/com
aliases for frequent docker-compose commands.
To use it, add docker-compose to the plugins array of your zshrc file:
-```
+
+```zsh
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 c0a54cced..808b068a3 100644
--- a/plugins/docker-compose/_docker-compose
+++ b/plugins/docker-compose/_docker-compose
@@ -23,7 +23,7 @@ __docker-compose_all_services_in_compose_file() {
local already_selected
local -a services
already_selected=$(echo $words | tr " " "|")
- __docker-compose_q config --services \
+ __docker-compose_q ps --services "$@" \
| grep -Ev "^(${already_selected})$"
}
@@ -31,125 +31,42 @@ __docker-compose_all_services_in_compose_file() {
__docker-compose_services_all() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
- services=$(__docker-compose_all_services_in_compose_file)
+ services=$(__docker-compose_all_services_in_compose_file "$@")
_alternative "args:services:($services)" && ret=0
return ret
}
-# All services that have an entry with the given key in their docker-compose.yml section
-__docker-compose_services_with_key() {
- local already_selected
- local -a buildable
- already_selected=$(echo $words | tr " " "|")
- # flatten sections to one line, then filter lines containing the key and return section name.
- __docker-compose_q config \
- | sed -n -e '/^services:/,/^[^ ]/p' \
- | sed -n 's/^ //p' \
- | awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \
- | grep " \+$1:" \
- | cut -d: -f1 \
- | grep -Ev "^(${already_selected})$"
-}
-
# All services that are defined by a Dockerfile reference
__docker-compose_services_from_build() {
[[ $PREFIX = -* ]] && return 1
- integer ret=1
- buildable=$(__docker-compose_services_with_key build)
- _alternative "args:buildable services:($buildable)" && ret=0
-
- return ret
+ __docker-compose_services_all --filter source=build
}
# All services that are defined by an image
__docker-compose_services_from_image() {
[[ $PREFIX = -* ]] && return 1
- integer ret=1
- pullable=$(__docker-compose_services_with_key image)
- _alternative "args:pullable services:($pullable)" && ret=0
-
- return ret
-}
-
-__docker-compose_get_services() {
- [[ $PREFIX = -* ]] && return 1
- integer ret=1
- local kind
- declare -a running paused stopped lines args services
-
- docker_status=$(docker ps > /dev/null 2>&1)
- if [ $? -ne 0 ]; then
- _message "Error! Docker is not running."
- return 1
- fi
-
- kind=$1
- shift
- [[ $kind =~ (stopped|all) ]] && args=($args -a)
-
- lines=(${(f)"$(_call_program commands docker $docker_options ps $args)"})
- services=(${(f)"$(_call_program commands docker-compose 2>/dev/null $compose_options ps -q)"})
-
- # Parse header line to find columns
- local i=1 j=1 k header=${lines[1]}
- declare -A begin end
- while (( j < ${#header} - 1 )); do
- i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
- j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
- k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
- begin[${header[$i,$((j-1))]}]=$i
- end[${header[$i,$((j-1))]}]=$k
- done
- lines=(${lines[2,-1]})
-
- # Container ID
- local line s name
- local -a names
- for line in $lines; do
- if [[ ${services[@]} == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then
- names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}})
- for name in $names; do
- s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
- s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"
- s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
- if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
- stopped=($stopped $s)
- else
- if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = *\(Paused\)* ]]; then
- paused=($paused $s)
- fi
- running=($running $s)
- fi
- done
- fi
- done
-
- [[ $kind =~ (running|all) ]] && _describe -t services-running "running services" running "$@" && ret=0
- [[ $kind =~ (paused|all) ]] && _describe -t services-paused "paused services" paused "$@" && ret=0
- [[ $kind =~ (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped "$@" && ret=0
-
- return ret
+ __docker-compose_services_all --filter source=image
}
__docker-compose_pausedservices() {
[[ $PREFIX = -* ]] && return 1
- __docker-compose_get_services paused "$@"
+ __docker-compose_services_all --filter status=paused
}
__docker-compose_stoppedservices() {
[[ $PREFIX = -* ]] && return 1
- __docker-compose_get_services stopped "$@"
+ __docker-compose_services_all --filter status=stopped
}
__docker-compose_runningservices() {
[[ $PREFIX = -* ]] && return 1
- __docker-compose_get_services running "$@"
+ __docker-compose_services_all --filter status=running
}
__docker-compose_services() {
[[ $PREFIX = -* ]] && return 1
- __docker-compose_get_services all "$@"
+ __docker-compose_services_all
}
__docker-compose_caching_policy() {
@@ -196,9 +113,12 @@ __docker-compose_subcommand() {
$opts_help \
"*--build-arg=[Set build-time variables for one service.]:<varname>=<value>: " \
'--force-rm[Always remove intermediate containers.]' \
- '--memory[Memory limit for the build container.]' \
+ '(--quiet -q)'{--quiet,-q}'[Curb build output]' \
+ '(--memory -m)'{--memory,-m}'[Memory limit for the build container.]' \
'--no-cache[Do not use cache when building the image.]' \
'--pull[Always attempt to pull a newer version of the image.]' \
+ '--compress[Compress the build context using gzip.]' \
+ '--parallel[Build images in parallel.]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
(bundle)
@@ -213,7 +133,8 @@ __docker-compose_subcommand() {
'(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \
'--resolve-image-digests[Pin image tags to digests.]' \
'--services[Print the service names, one per line.]' \
- '--volumes[Print the volume names, one per line.]' && ret=0
+ '--volumes[Print the volume names, one per line.]' \
+ '--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
;;
(create)
_arguments \
@@ -222,11 +143,12 @@ __docker-compose_subcommand() {
$opts_no_recreate \
$opts_no_build \
"(--no-build)--build[Build images before creating containers.]" \
- '*:services:__docker-compose_services_all' && ret=0
+ '*:services:__docker-compose_services' && ret=0
;;
(down)
_arguments \
$opts_help \
+ $opts_timeout \
"--rmi[Remove images. Type must be one of: 'all': Remove all images used by any service. 'local': Remove only images that don't have a custom tag set by the \`image\` field.]:type:(all local)" \
'(-v --volumes)'{-v,--volumes}"[Remove named volumes declared in the \`volumes\` section of the Compose file and anonymous volumes attached to containers.]" \
$opts_remove_orphans && ret=0
@@ -235,16 +157,18 @@ __docker-compose_subcommand() {
_arguments \
$opts_help \
'--json[Output events as a stream of json objects]' \
- '*:services:__docker-compose_services_all' && ret=0
+ '*:services:__docker-compose_services' && ret=0
;;
(exec)
_arguments \
$opts_help \
'-d[Detached mode: Run command in the background.]' \
'--privileged[Give extended privileges to the process.]' \
- '(-u --user)'{-u,--user=}'[Run the command as this user.]:username:_users' \
+ '(-u --user)'{-u,--user=}'[Run the command as this user.]:username:_users' \
'-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \
'--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \
+ '*'{-e,--env}'[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
+ '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
'(-):running services:__docker-compose_runningservices' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
@@ -252,12 +176,12 @@ __docker-compose_subcommand() {
(help)
_arguments ':subcommand:__docker-compose_commands' && ret=0
;;
- (images)
- _arguments \
- $opts_help \
- '-q[Only display IDs]' \
- '*:services:__docker-compose_services_all' && ret=0
- ;;
+ (images)
+ _arguments \
+ $opts_help \
+ '-q[Only display IDs]' \
+ '*:services:__docker-compose_services' && ret=0
+ ;;
(kill)
_arguments \
$opts_help \
@@ -271,7 +195,7 @@ __docker-compose_subcommand() {
$opts_no_color \
'--tail=[Number of lines to show from the end of the logs for each container.]:number of lines: ' \
'(-t --timestamps)'{-t,--timestamps}'[Show timestamps]' \
- '*:services:__docker-compose_services_all' && ret=0
+ '*:services:__docker-compose_services' && ret=0
;;
(pause)
_arguments \
@@ -290,12 +214,16 @@ __docker-compose_subcommand() {
_arguments \
$opts_help \
'-q[Only display IDs]' \
- '*:services:__docker-compose_services_all' && ret=0
+ '--filter KEY=VAL[Filter services by a property]:<filtername>=<value>:' \
+ '*:services:__docker-compose_services' && ret=0
;;
(pull)
_arguments \
$opts_help \
'--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \
+ '--no-parallel[Disable parallel pulling]' \
+ '(-q --quiet)'{-q,--quiet}'[Pull without printing progress information]' \
+ '--include-deps[Also pull services declared as dependencies]' \
'*:services:__docker-compose_services_from_image' && ret=0
;;
(push)
@@ -317,6 +245,7 @@ __docker-compose_subcommand() {
$opts_no_deps \
'-d[Detached mode: Run container in the background, print new container name.]' \
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
+ '*'{-l,--label}'[KEY=VAL Add or override a label (can be used multiple times)]:label KEY=VAL: ' \
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
'--name=[Assign a name to the container]:name: ' \
'(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \
@@ -326,6 +255,7 @@ __docker-compose_subcommand() {
'(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \
'(-v --volume)*'{-v,--volume=}'[Bind mount a volume]:volume: ' \
'(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
+ "--use-aliases[Use the services network aliases in the network(s) the container connects to]" \
'(-):services:__docker-compose_services' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
@@ -369,8 +299,10 @@ __docker-compose_subcommand() {
"(--no-build)--build[Build images before starting containers.]" \
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. 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' \
$opts_remove_orphans \
- '*:services:__docker-compose_services_all' && ret=0
+ '*:services:__docker-compose_services' && ret=0
;;
(version)
_arguments \
@@ -409,8 +341,11 @@ _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:' \
- '--verbose[Show more output]' \
+ "--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]' \
'(-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:' \
@@ -421,7 +356,7 @@ _docker-compose() {
'(-): :->command' \
'(-)*:: :->option-or-argument' && ret=0
- local -a relevant_compose_flags relevant_docker_flags compose_options docker_options
+ local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=(
"--file" "-f"
@@ -435,6 +370,10 @@ _docker-compose() {
"--skip-hostname-check"
)
+ relevant_compose_repeatable_flags=(
+ "--file" "-f"
+ )
+
relevant_docker_flags=(
"--host" "-H"
"--tls"
@@ -452,9 +391,18 @@ _docker-compose() {
fi
fi
if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then
- compose_options+=$k
- if [[ -n "$opt_args[$k]" ]]; then
- compose_options+=$opt_args[$k]
+ if [[ -n "${relevant_compose_repeatable_flags[(r)$k]}" ]]; then
+ values=("${(@s/:/)opt_args[$k]}")
+ for value in $values
+ do
+ compose_options+=$k
+ compose_options+=$value
+ done
+ else
+ compose_options+=$k
+ if [[ -n "$opt_args[$k]" ]]; then
+ compose_options+=$opt_args[$k]
+ fi
fi
fi
done
diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh
index 9ffe1edf6..85e03d343 100644
--- a/plugins/docker-compose/docker-compose.plugin.zsh
+++ b/plugins/docker-compose/docker-compose.plugin.zsh
@@ -18,9 +18,11 @@ alias dcrm='docker-compose rm'
alias dcr='docker-compose run'
alias dcstop='docker-compose stop'
alias dcup='docker-compose up'
+alias dcupb='docker-compose up --build'
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'
+alias dck='docker-compose kill'
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index e91798485..fab7aa8f1 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -1,5 +1,34 @@
-## Docker autocomplete plugin
+# Docker plugin
-A copy of the completion script from the
-[docker/cli](https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker)
-git repo.
+This plugin adds auto-completion for [docker](https://www.docker.com/).
+
+To use it add `docker` to the plugins array in your zshrc file.
+
+```zsh
+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 31b83c777..7fe204313 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -1,6 +1,6 @@
#compdef docker dockerd
#
-# zsh completion for docker (https://docker.com)
+# zsh completion for docker (http://docker.com)
#
# version: 0.3.0
# github: https://github.com/felixr/docker-zsh-completion
@@ -9,6 +9,7 @@
# - Felix Riedel
# - Steve Durrheimer
# - Vincent Bernat
+# - Rohan Verma
#
# license:
#
@@ -604,6 +605,7 @@ __docker_container_subcommand() {
"($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: "
"($help)*--cap-add=[Add Linux capabilities]:capability: "
"($help)*--cap-drop=[Drop Linux capabilities]:capability: "
+ "($help)--cgroupns=[Cgroup namespace mode to use]:cgroup namespace mode: "
"($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: "
"($help)--cidfile=[Write the container ID to the file]:CID file:_files"
"($help)--cpus=[Number of CPUs (default 0.000)]:cpus: "
@@ -617,11 +619,13 @@ __docker_container_subcommand() {
"($help)*--dns=[Custom DNS servers]:DNS server: "
"($help)*--dns-option=[Custom DNS options]:DNS option: "
"($help)*--dns-search=[Custom DNS search domains]:DNS domains: "
+ "($help)*--domainname=[Container NIS domain name]:domainname:_hosts"
"($help)*"{-e=,--env=}"[Environment variables]:environment variable: "
"($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]"
@@ -675,6 +679,7 @@ __docker_container_subcommand() {
"($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: "
"($help)--memory-reservation=[Memory soft limit]:Memory limit: "
"($help)--memory-swap=[Total memory limit with swap]:Memory limit: "
+ "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]"
"($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)"
)
opts_help=("(: -)--help[Print usage]")
@@ -746,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]" \
@@ -787,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)
@@ -800,7 +806,7 @@ __docker_container_subcommand() {
"($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \
"($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \
"($help)--no-trunc[Do not truncate output]" \
- "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
+ "($help -q --quiet)"{-q,--quiet}"[Only show container IDs]" \
"($help -s --size)"{-s,--size}"[Display total file sizes]" \
"($help)--since=[Show only containers created since...]:containers:__docker_complete_containers" && ret=0
;;
@@ -831,7 +837,7 @@ __docker_container_subcommand() {
_arguments $(__docker_arguments) \
$opts_help \
"($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \
- "($help -)*:containers:__docker_complete_containers_ids" && ret=0
+ "($help -)*:containers:__docker_complete_containers" && ret=0
;;
(rm)
local state
@@ -1014,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
@@ -1023,7 +1030,7 @@ __docker_image_subcommand() {
$opts_help \
"($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \
"($help)--no-trunc[Do not truncate output]" \
- "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
+ "($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \
"($help -)*: :__docker_complete_images" && ret=0
;;
(import)
@@ -1055,7 +1062,7 @@ __docker_image_subcommand() {
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \
"($help)--format=[Pretty-print images using a Go template]:template: " \
"($help)--no-trunc[Do not truncate output]" \
- "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
+ "($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \
"($help -): :__docker_complete_repositories" && ret=0
;;
(prune)
@@ -1075,6 +1082,7 @@ __docker_image_subcommand() {
(push)
_arguments $(__docker_arguments) \
$opts_help \
+ "($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \
"($help)--disable-content-trust[Skip image signing]" \
"($help -): :__docker_complete_images" && ret=0
;;
@@ -1285,7 +1293,7 @@ __docker_network_subcommand() {
"($help)--no-trunc[Do not truncate the output]" \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \
"($help)--format=[Pretty-print networks using a Go template]:template: " \
- "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0
+ "($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0
;;
(prune)
_arguments $(__docker_arguments) \
@@ -1953,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: "
@@ -1965,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: "
@@ -2007,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" \
@@ -2030,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
;;
@@ -2213,8 +2225,7 @@ __docker_stack_subcommand() {
(deploy|up)
_arguments $(__docker_arguments) \
$opts_help \
- "($help)--bundle-file=[Path to a Distributed Application Bundle file]:dab:_files -g \"*.dab\"" \
- "($help -c --compose-file)"{-c=,--compose-file=}"[Path to a Compose file]:compose file:_files -g \"*.(yml|yaml)\"" \
+ "($help -c --compose-file)"{-c=,--compose-file=}"[Path to a Compose file, or '-' to read from stdin]:compose file:_files -g \"*.(yml|yaml)\"" \
"($help)--with-registry-auth[Send registry authentication details to Swarm agents]" \
"($help -):stack:__docker_complete_stacks" && ret=0
;;
@@ -2285,6 +2296,9 @@ __docker_swarm_subcommand() {
$opts_help \
"($help)--advertise-addr=[Advertised address]:ip\:port: " \
"($help)--data-path-addr=[Data path IP or interface]:ip " \
+ "($help)--data-path-port=[Data Path Port]:port " \
+ "($help)--default-addr-pool=[Default address pool]" \
+ "($help)--default-addr-pool-mask-length=[Default address pool subnet mask length]" \
"($help)--autolock[Enable manager autolocking]" \
"($help)--availability=[Availability of the node]:availability:(active drain pause)" \
"($help)--cert-expiry=[Validity period for node certificates]:duration: " \
@@ -2632,6 +2646,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: " \
@@ -2664,6 +2680,7 @@ __docker_subcommand() {
"($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \
"($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \
"($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \
+ "($help)--max-download-attempts[Set the max download attempts for each pull]" \
"($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \
"($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
"($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \
@@ -2779,7 +2796,7 @@ __docker_subcommand() {
$opts_help \
"($help -p --password)"{-p=,--password=}"[Password]:password: " \
"($help)--password-stdin[Read password from stdin]" \
- "($help -u --user)"{-u=,--user=}"[Username]:username: " \
+ "($help -u --username)"{-u=,--username=}"[Username]:username: " \
"($help -)1:server: " && ret=0
;;
(logout)
diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md
index e880e9d69..ab9d329f6 100644
--- a/plugins/dotenv/README.md
+++ b/plugins/dotenv/README.md
@@ -4,9 +4,7 @@ Automatically load your project ENV variables from `.env` file when you `cd` int
Storing configuration in the environment is one of the tenets of a [twelve-factor app](https://www.12factor.net). Anything that is likely to change between deployment environments, such as resource handles for databases or credentials for external services, should be extracted from the code into environment variables.
-## Installation
-
-Just add the plugin to your `.zshrc`:
+To use it, add `dotenv` to the plugins array in your zshrc file:
```sh
plugins=(... dotenv)
@@ -17,21 +15,69 @@ plugins=(... dotenv)
Create `.env` file inside your project root directory and put your ENV variables there.
For example:
+
```sh
export AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a
export SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f
export MONGO_URI=mongodb://127.0.0.1:27017
export PORT=3001
```
+
`export` is optional. This format works as well:
+
```sh
AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a
SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f
MONGO_URI=mongodb://127.0.0.1:27017
PORT=3001
```
+
You can even mix both formats, although it's probably a bad idea.
+## Settings
+
+### ZSH_DOTENV_FILE
+
+You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`.
+If the variable isn't set, the plugin will default to use `.env`.
+For example, this will make the plugin look for files named `.dotenv` and load them:
+
+```zsh
+# in ~/.zshrc, before Oh My Zsh is sourced:
+ZSH_DOTENV_FILE=.dotenv
+```
+
+### ZSH_DOTENV_PROMPT
+
+Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmation message.
+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_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, **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.
+
+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
+```
+
+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
**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only.
@@ -41,5 +87,6 @@ You can even mix both formats, although it's probably a bad idea.
This plugin only sources the `.env` file. Nothing less, nothing more. It doesn't do any checks. It's designed to be the fastest and simplest option. You're responsible for the `.env` file content. You can put some code (or weird symbols) there, but do it on your own risk. `dotenv` is the basic tool, yet it does the job.
If you need more advanced and feature-rich ENV management, check out these awesome projects:
+
* [direnv](https://github.com/direnv/direnv)
* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv)
diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
index b701b5596..24f285df5 100644
--- a/plugins/dotenv/dotenv.plugin.zsh
+++ b/plugins/dotenv/dotenv.plugin.zsh
@@ -1,15 +1,50 @@
+## Settings
+
+# Filename of the dotenv file to look for
+: ${ZSH_DOTENV_FILE:=.env}
+
+# 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 .env ]]; then
- # test .env syntax
- zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2
-
- if [[ -o a ]]; then
- source .env
- else
- set -a
- source .env
- set +a
+ if [[ -f $ZSH_DOTENV_FILE ]]; then
+ 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 grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
+ return;
+ fi
+
+ # 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/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
fi
}
diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md
new file mode 100644
index 000000000..7554b4e3c
--- /dev/null
+++ b/plugins/dotnet/README.md
@@ -0,0 +1,23 @@
+# .NET Core CLI plugin
+
+This plugin provides completion and useful aliases for [.NET Core CLI](https://dotnet.microsoft.com/).
+
+To use it, add `dotnet` to the plugins array in your zshrc file.
+
+```
+plugins=(... dotnet)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|-------|------------------|-------------------------------------------------------------------|
+| dn | dotnet new | Create a new .NET project or file. |
+| dr | dotnet run | Build and run a .NET project output. |
+| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
+| dw | dotnet watch | Watch for source file changes and restart the dotnet command. |
+| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. |
+| ds | dotnet sln | Modify Visual Studio solution files. |
+| da | dotnet add | Add a package or reference to a .NET project. |
+| dp | dotnet pack | Create a NuGet package. |
+| dng | dotnet nuget | Provides additional NuGet commands. |
diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh
new file mode 100644
index 000000000..6bd4b7af8
--- /dev/null
+++ b/plugins/dotnet/dotnet.plugin.zsh
@@ -0,0 +1,32 @@
+# This scripts is copied from (MIT License):
+# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh
+
+_dotnet_zsh_complete()
+{
+ local completions=("$(dotnet complete "$words")")
+
+ # If the completion list is empty, just continue with filename selection
+ if [ -z "$completions" ]
+ then
+ _arguments '*::arguments: _normal'
+ return
+ fi
+
+ # This is not a variable assigment, don't remove spaces!
+ _values = "${(ps:\n:)completions}"
+}
+
+compdef _dotnet_zsh_complete dotnet
+
+# Aliases bellow are here for backwards compatibility
+# added by Shaun Tabone (https://github.com/xontab)
+
+alias dn='dotnet new'
+alias dr='dotnet run'
+alias dt='dotnet test'
+alias dw='dotnet watch'
+alias dwr='dotnet watch run'
+alias ds='dotnet sln'
+alias da='dotnet add'
+alias dp='dotnet pack'
+alias dng='dotnet nuget'
diff --git a/plugins/drush/README.md b/plugins/drush/README.md
new file mode 100644
index 000000000..df7b82bdd
--- /dev/null
+++ b/plugins/drush/README.md
@@ -0,0 +1,83 @@
+# Drush
+
+## Description
+This plugin offers aliases and functions to make the work with drush easier and more productive.
+
+To enable it, add the `drush` to your `plugins` array in `~/.zshrc`:
+
+```
+plugins=(... drush)
+```
+
+## Aliases
+| Alias | Description | Command |
+|-------|-----------------------------------------------------------------------|-----------------------------|
+| dr | Display drush help | drush |
+| drca | Clear all drupal caches. | drush cc all |
+| drcb | Clear block cache. | drush cc block |
+| drcg | Clear registry cache. | drush cc registry |
+| drcj | Clear css-js cache. | drush cc css-js |
+| drcm | Clear menu cache. | drush cc menu |
+| drcml | Clear module-list cache. | drush cc module-list |
+| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron |
+| drct | Clear theme-registry cache. | drush cc theme-registry |
+| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views |
+| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql|
+| drf | Display features status | drush features |
+| drfr | Revert a feature module on your site. | drush features-revert -y |
+| drfu | Update a feature module on your site. | drush features-update -y |
+| drfra | Revert all enabled feature module on your site. | drush features-revert-all |
+| drif | Flush all derived images. | drush image-flush --all |
+| drpm | Show a list of available modules. | drush pm-list --type=module |
+| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status |
+| drup | Apply any database updates required (as with running update.php). | drush updatedb |
+| drups | List any pending database updates. | drush updatedb-status |
+| drv | Show drush version. | drush version |
+| drvd | Delete a variable. | drush variable-del |
+| drvg | Get a list of some or all site variables and values. | drush variable-get |
+| drvs | Set a variable. | drush variable-set |
+
+## Functions
+
+### dren
+Download and enable one or more extensions (modules or themes).
+Must be invoked with one or more parameters. e.g.:
+`dren devel` or `dren devel module_filter views`
+
+### drf
+Edit drushrc, site alias, and Drupal settings.php files.
+Can be invoked with one or without parameters. e.g.:
+`drf 1`
+
+### dris
+Disable one or more extensions (modules or themes)
+Must be invoked with one or more parameters. e.g.:
+`dris devel` or `dris devel module_filter views`
+
+### drpu
+Uninstall one or more modules.
+Must be invoked with one or more parameters. e.g.:
+`drpu devel` or `drpu devel module_filter views`
+
+### drnew
+Creates a brand new drupal website.
+Note: As soon as the installation is complete, drush will print a username and a random password into the terminal:
+```
+Installation complete. User name: admin User password: cf7t8yqNEm
+```
+
+## Additional features
+
+### Autocomplete
+The [completion script for drush](https://github.com/drush-ops/drush/blob/8.0.1/drush.complete.sh) comes enabled with this plugin.
+So, it is possible to type a command:
+```
+drush sql
+```
+
+And as soon as the tab key is pressed, the script will display the available commands:
+```
+drush sql
+sqlc sql-conf sql-create sql-dump sql-query sql-sanitize
+sql-cli sql-connect sql-drop sqlq sqlsan sql-sync
+```
diff --git a/plugins/drush/drush.complete.sh b/plugins/drush/drush.complete.sh
new file mode 100644
index 000000000..38b882ec3
--- /dev/null
+++ b/plugins/drush/drush.complete.sh
@@ -0,0 +1,50 @@
+# BASH completion script for Drush.
+#
+# Place this in your /etc/bash_completion.d/ directory or source it from your
+# ~/.bash_completion or ~/.bash_profile files. Alternatively, source
+# examples/example.bashrc instead, as it will automatically find and source
+# this file.
+#
+# If you're using ZSH instead of BASH, add the following to your ~/.zshrc file
+# and source it.
+#
+# autoload bashcompinit
+# bashcompinit
+# source /path/to/your/drush.complete.sh
+
+# Ensure drush is available.
+which drush > /dev/null || alias drush &> /dev/null || return
+
+__drush_ps1() {
+ f="${TMPDIR:-/tmp/}/drush-env-${USER}/drush-drupal-site-$$"
+ if [ -f $f ]
+ then
+ __DRUPAL_SITE=$(cat "$f")
+ else
+ __DRUPAL_SITE="$DRUPAL_SITE"
+ fi
+
+ # Set DRUSH_PS1_SHOWCOLORHINTS to a non-empty value and define a
+ # __drush_ps1_colorize_alias() function for color hints in your Drush PS1
+ # prompt. See example.prompt.sh for an example implementation.
+ if [ -n "${__DRUPAL_SITE-}" ] && [ -n "${DRUSH_PS1_SHOWCOLORHINTS-}" ]; then
+ __drush_ps1_colorize_alias
+ fi
+
+ [[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE"
+}
+
+# Completion function, uses the "drush complete" command to retrieve
+# completions for a specific command line COMP_WORDS.
+_drush_completion() {
+ # Set IFS to newline (locally), since we only use newline separators, and
+ # need to retain spaces (or not) after completions.
+ local IFS=$'\n'
+ # The '< /dev/null' is a work around for a bug in php libedit stdin handling.
+ # Note that libedit in place of libreadline in some distributions. See:
+ # https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
+ COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) )
+}
+
+# Register our completion function. We include common short aliases for Drush.
+complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush7 drush8 drush.php
diff --git a/plugins/drush/drush.plugin.zsh b/plugins/drush/drush.plugin.zsh
new file mode 100644
index 000000000..8a20d79f2
--- /dev/null
+++ b/plugins/drush/drush.plugin.zsh
@@ -0,0 +1,104 @@
+# Drush support.
+
+function dren() {
+ drush en $@ -y
+}
+
+function dris() {
+ drush pm-disable $@ -y
+}
+
+function drpu() {
+ drush pm-uninstall $@ -y
+}
+
+function drf() {
+ if [[ $1 == "" ]] then
+ drush core-config
+ else
+ drush core-config --choice=$1
+ fi
+}
+
+function drfi() {
+ if [[ $1 == "fields" ]]; then
+ drush field-info fields
+ elif [[ $1 == "types" ]]; then
+ drush field-info types
+ else
+ drush field-info
+ fi
+}
+
+function drnew() {
+
+ cd ~
+ echo "Website's name: "
+ read WEBSITE_NAME
+
+ HOST=http://$(hostname -i)/
+
+ if [[ $WEBSITE_NAME == "" ]] then
+ MINUTES=$(date +%M:%S)
+ WEBSITE_NAME="Drupal-$MINUTES"
+ echo "Your website will be named: $WEBSITE_NAME"
+ fi
+
+ drush dl drupal --drupal-project-rename=$WEBSITE_NAME
+
+ echo "Type your localhost directory: (Leave empty for /var/www/html/)"
+ read DIRECTORY
+
+ if [[ $DIRECTORY == "" ]] then
+ DIRECTORY="/var/www/html/"
+ fi
+
+ echo "Moving to $DIRECTORY$WEBSITE_NAME"
+ sudo mv $WEBSITE_NAME $DIRECTORY
+ cd $DIRECTORY$WEBSITE_NAME
+
+ echo "Database's user: "
+ read DATABASE_USR
+ echo "Database's password: "
+ read -s DATABASE_PWD
+ echo "Database's name for your project: "
+ read DATABASE
+
+ DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE"
+ drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME
+
+ open_command $HOST$WEBSITE_NAME
+ echo "Done"
+
+}
+
+# Aliases, sorted alphabetically.
+alias dr="drush"
+alias drca="drush cc all" # Deprecated for Drush 8
+alias drcb="drush cc block" # Deprecated for Drush 8
+alias drcg="drush cc registry" # Deprecated for Drush 8
+alias drcj="drush cc css-js"
+alias drcm="drush cc menu"
+alias drcml="drush cc module-list"
+alias drcr="drush core-cron"
+alias drct="drush cc theme-registry"
+alias drcv="drush cc views"
+alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql"
+alias drf="drush features"
+alias drfr="drush features-revert -y"
+alias drfu="drush features-update -y"
+alias drfra="drush features-revert-all"
+alias drif="drush image-flush --all"
+alias drpm="drush pm-list --type=module"
+alias drst="drush core-status"
+alias drup="drush updatedb"
+alias drups="drush updatedb-status"
+alias drv="drush version"
+alias drvd="drush variable-del"
+alias drvg="drush variable-get"
+alias drvs="drush variable-set"
+
+# Enable drush autocomplete support
+autoload bashcompinit
+bashcompinit
+source $(dirname $0)/drush.complete.sh
diff --git a/plugins/eecms/README.md b/plugins/eecms/README.md
new file mode 100644
index 000000000..c53835521
--- /dev/null
+++ b/plugins/eecms/README.md
@@ -0,0 +1,11 @@
+# eecms plugin
+
+This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine).
+
+To use it, add `eecms` to the plugins array of your `.zshrc` file:
+```
+plugins=(... eecms)
+```
+
+It also adds the alias `eecms` which finds the eecms file in the current project
+and runs it with php.
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index db0ab13af..0b602d12a 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -26,6 +26,16 @@ if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
# 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
# Write to standard output the path to the file
# opened in the current buffer.
diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
index 26b28d495..04a2c2afd 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -20,7 +20,8 @@ _emacsfun()
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
if [ "$#" -ge "2" -a "$2" = "-" ]
then
- tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)"
+ tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
+ || mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
cat - > "$tempfile"
_emacsfun --no-wait $tempfile
else
diff --git a/plugins/emoji-clock/emoji-clock.plugin.zsh b/plugins/emoji-clock/emoji-clock.plugin.zsh
index 0a55528f0..bdd606f89 100644
--- a/plugins/emoji-clock/emoji-clock.plugin.zsh
+++ b/plugins/emoji-clock/emoji-clock.plugin.zsh
@@ -2,7 +2,7 @@
# FILE: emoji-clock.plugin.zsh
# DESCRIPTION: The current time with half hour accuracy as an emoji symbol.
# Inspired by Andre Torrez' "Put A Burger In Your Shell"
-# http://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
+# https://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
# VERSION: 1.0.0
# -----------------------------------------------------------------------------
diff --git a/plugins/emotty/README.md b/plugins/emotty/README.md
new file mode 100644
index 000000000..ee571705a
--- /dev/null
+++ b/plugins/emotty/README.md
@@ -0,0 +1,39 @@
+# emotty plugin
+
+This plugin returns an emoji for the current $TTY number so it can be used
+in a prompt.
+
+To use it, add emotty to the plugins array in your zshrc file:
+```
+plugins=(... emotty)
+```
+
+**NOTE:** it requires the [emoji plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/emoji).
+
+## Usage
+
+The function `emotty` displays an emoji from the current character set (default: `emoji`), based
+on the number associated to the `$TTY`.
+
+There are different sets of emoji characters available, to choose a different
+set, set `$emotty_set` to the name of the set you would like to use, e.g.:
+```
+emotty_set=nature
+```
+
+### Character Sets
+
+- emoji
+- loral
+- love
+- nature
+- stellar
+- zodiac
+
+Use the `display_emotty` function to list the emojis in the current character set, or
+the character set passed as the first argument. For example:
+
+```
+$ display_emotty zodiac
+<list of all the emojis in the zodiac character set>
+```
diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh
index b0d24c322..4511275d6 100644
--- a/plugins/emotty/emotty.plugin.zsh
+++ b/plugins/emotty/emotty.plugin.zsh
@@ -25,8 +25,14 @@ emotty_default_set=emoji
function emotty() {
# Use emotty set defined by user, fallback to default
local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]}
- # Parse $TTY number, normalizing it to an emotty set index
- (( tty = (${TTY##/dev/tty} % ${#${=emotty}}) + 1 ))
+
+ # Parse tty number via prompt expansion. %l equals:
+ # - N if tty = /dev/ttyN
+ # - pts/N if tty = /dev/pts/N
+ local tty=${${(%):-%l}##pts/}
+ # Normalize it to an emotty set index
+ (( tty = (tty % ${#${=emotty}}) + 1 ))
+
local character_name=${${=emotty}[tty]}
echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
}
diff --git a/plugins/encode64/README.md b/plugins/encode64/README.md
index 9850da85f..86320cffb 100644
--- a/plugins/encode64/README.md
+++ b/plugins/encode64/README.md
@@ -1,6 +1,12 @@
# encode64
-Alias plugin for encoding or decoding using `base64` command
+Alias plugin for encoding or decoding using `base64` command.
+
+To use it, add `encode64` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... encode64)
+```
## Functions and Aliases
@@ -9,23 +15,6 @@ Alias plugin for encoding or decoding using `base64` command
| `encode64` | `e64` | Encodes given data to base64 |
| `decode64` | `d64` | Decodes given data from base64 |
-## Enabling plugin
-
-1. Edit your `.zshrc` file and add `encode64` to the list of plugins:
-
- ```sh
- plugins=(
- # ...other enabled plugins
- encode64
- )
- ```
-
-2. Restart your terminal session or reload configuration by running:
-
- ```sh
- source ~/.zshrc
- ```
-
## Usage and examples
### Encoding
@@ -64,6 +53,6 @@ Alias plugin for encoding or decoding using `base64` command
```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 c6bdd36dd..f2e6ad1d1 100644
--- a/plugins/extract/README.md
+++ b/plugins/extract/README.md
@@ -19,28 +19,40 @@ plugins=(... extract)
| `7z` | 7zip file |
| `Z` | Z archive (LZW) |
| `apk` | Android app file |
+| `aar` | Android library file |
| `bz2` | Bzip2 file |
| `deb` | Debian package |
+| `ear` | Enterprise Application aRchive |
| `gz` | Gzip file |
+| `ipa` | iOS app package |
| `ipsw` | iOS firmware file |
| `jar` | Java Archive |
+| `lrz` | LRZ archive |
+| `lz4` | LZ4 archive |
| `lzma` | LZMA archive |
| `rar` | WinRAR archive |
+| `rpm` | RPM package |
| `sublime-package` | Sublime Text package |
| `tar` | Tarball |
| `tar.bz2` | Tarball with bzip2 compression |
| `tar.gz` | Tarball with gzip compression |
+| `tar.lrz` | Tarball with lrzip compression |
+| `tar.lz` | Tarball with lzip compression |
+| `tar.lz4` | Tarball with lz4 compression |
| `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression |
+| `tar.zst` | Tarball with zstd compression |
| `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression |
| `tlz` | Tarball with lzma compression |
| `txz` | Tarball with lzma2 compression |
+| `tzst` | Tarball with zstd compression |
| `war` | Web Application archive (Java-based) |
| `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive |
| `zip` | Zip archive |
+| `zst` | Zstandard file (zstd) |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
more information regarding archive formats.
diff --git a/plugins/extract/_extract b/plugins/extract/_extract
index 3baefa339..267c4d4e1 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|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \
+ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|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 4c72ce870..e390e2dcc 100644
--- a/plugins/extract/extract.plugin.zsh
+++ b/plugins/extract/extract.plugin.zsh
@@ -40,14 +40,24 @@ extract() {
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" ;;
- (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$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|*.whl) unzip "$1" -d $extract_dir ;;
+ (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.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"
@@ -58,6 +68,7 @@ extract() {
cd ..; rm *.tar.* debian-binary
cd ..
;;
+ (*.zst) unzstd "$1" ;;
(*)
echo "extract: '$1' cannot be extracted" >&2
success=1
diff --git a/plugins/fabric/README.md b/plugins/fabric/README.md
index cf0fa81f4..f121d2ed8 100644
--- a/plugins/fabric/README.md
+++ b/plugins/fabric/README.md
@@ -4,6 +4,6 @@ This plugin provides completion for [Fabric](https://www.fabfile.org/).
To use it add fabric to the plugins array in your zshrc file.
-```bash
+```zsh
plugins=(... fabric)
```
diff --git a/plugins/fabric/_fabric b/plugins/fabric/_fab
index 9628e1224..9102dadef 100644
--- a/plugins/fabric/_fabric
+++ b/plugins/fabric/_fab
@@ -4,10 +4,19 @@
local curcontext=$curcontext state line
declare -A opt_args
-declare target_list
-target_list=(`fab --shortlist 2>/dev/null`)
+declare -a target_list
+target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
+ if (NF == 0 || NR == 1) next
+ if (NF < 2) print $1
+ else {
+ docstring=substr($0, index($0,$2))
+ gsub(":", "\\:", docstring)
+ print $1":"docstring
+ }
+}')}")
-_targets() {
+_fab_targets() {
+ [[ -n "$target_list" ]] || return
_describe -t commands "fabric targets" target_list
}
@@ -28,7 +37,7 @@ _arguments -w -S -C \
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
- "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \
+ "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
levels)
_describe -t commands "output levels" output_levels;;
*)
- _targets;;
+ _fab_targets;;
esac
return
diff --git a/plugins/fabric/fabric.plugin.zsh b/plugins/fabric/fabric.plugin.zsh
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/plugins/fabric/fabric.plugin.zsh
diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md
index a7670fa2c..f1b1dfa5c 100644
--- a/plugins/fancy-ctrl-z/README.md
+++ b/plugins/fancy-ctrl-z/README.md
@@ -1,10 +1,10 @@
# Use Ctrl-Z to switch back to Vim
-I frequently need to execute random command in my shell. To achieve it I pause
+I frequently need to execute random commands in my shell. To achieve it I pause
Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
-The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back
+The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back
to Vim. I could not find a solution, so I developed one on my own that
-works wonderfully with ZSH
+works wonderfully with ZSH.
Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
diff --git a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
index 8ab297913..82b968894 100644
--- a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
+++ b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
@@ -1,10 +1,10 @@
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
- zle accept-line
+ zle accept-line -w
else
- zle push-input
- zle clear-screen
+ zle push-input -w
+ zle clear-screen -w
fi
}
zle -N fancy-ctrl-z
diff --git a/plugins/fasd/README.md b/plugins/fasd/README.md
new file mode 100644
index 000000000..a5c74e5b8
--- /dev/null
+++ b/plugins/fasd/README.md
@@ -0,0 +1,21 @@
+# fasd
+
+[`Fasd`](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells.
+
+To use it, add `fasd` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... fasd)
+```
+
+## Installation
+
+Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
+
+## Aliases
+
+| Alias | Command | Description |
+|-------|-------------------------------------------|-------------------------------------------------------------|
+| v | `fasd -f -e "$EDITOR"` | List frequent/recent files matching the given filename. |
+| o | `fasd -a -e xdg-open` | List frequent/recent files and directories matching. |
+| j | `fasd_cd -d -i` | cd with interactive selection |
diff --git a/plugins/fasd/fasd.plugin.zsh b/plugins/fasd/fasd.plugin.zsh
index 36a0428a7..6538d097e 100644
--- a/plugins/fasd/fasd.plugin.zsh
+++ b/plugins/fasd/fasd.plugin.zsh
@@ -1,12 +1,16 @@
-if [ $commands[fasd] ]; then # check if fasd is installed
- fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache"
- if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
- fasd --init auto >| "$fasd_cache"
- fi
- source "$fasd_cache"
- unset fasd_cache
+# check if fasd is installed
+if (( ! ${+commands[fasd]} )); then
+ return
+fi
- alias v="f -e \"$EDITOR\""
- alias o='a -e xdg-open'
- alias j='zz'
+fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache"
+if [[ "$commands[fasd]" -nt "$fasd_cache" || ! -s "$fasd_cache" ]]; then
+ fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install \
+ zsh-wcomp zsh-wcomp-install >| "$fasd_cache"
fi
+source "$fasd_cache"
+unset fasd_cache
+
+alias v='f -e "$EDITOR"'
+alias o='a -e xdg-open'
+alias j='zz'
diff --git a/plugins/fastfile/README.md b/plugins/fastfile/README.md
new file mode 100644
index 000000000..37f5b2f53
--- /dev/null
+++ b/plugins/fastfile/README.md
@@ -0,0 +1,84 @@
+# Fastfile plugin
+
+This plugin adds a way to reference certain files or folders used frequently using
+a global alias or shortcut.
+
+To use it, add `fastfile` to the plugins array in your zshrc file:
+```zsh
+plugins=(... fastfile)
+```
+
+## Usage
+
+Example: you access folder `/code/project/backend/database` very frequently.
+
+First, generate a shortcut with the name `pjdb`:
+```zsh
+$ fastfile pjdb /code/project/backend/database
+```
+
+Next time you want to access it, use `§pjdb`. For example:
+```zsh
+$ cd §pjdb
+$ subl §pjdb
+```
+where § is the fastfile prefix (see [below](#options) for how to change).
+
+**Note:** shortcuts with spaces in the name are assigned a global alias
+where the spaces have been substituted with underscores (`_`). For example:
+a shortcut named `"hello world"` corresponds with `§hello_world`.
+
+
+## Functions
+
+- `fastfile <shortcut_name> <path/to/file/or/folder>`: generate a shortcut.
+
+- `fastfile_print <shortcut_name>`: prints a shortcut, with the format
+ `<prefix><shortcut_name> -> <shortcut_path>`.
+
+- `fastfile_ls`: lists all shortcuts.
+
+- `fastfile_rm <shortcut_name> `: remove a shortcut.
+
+- `fastfile_sync`: generates the global aliases for the shortcuts.
+
+
+### Internal functions
+
+- `fastfile_resolv <shortcut_name>`: resolves the location of the shortcut
+ file, i.e., the file in the fastfile directory where the shortcut path
+ is stored.
+
+- `fastfile_get <shortcut_name>`: get the real path of the shortcut.
+
+
+## Aliases
+
+| Alias | Function |
+|--------|------------------|
+| ff | `fastfile` |
+| ffp | `fastfile_print` |
+| ffrm | `fastfile_rm` |
+| ffls | `fastfile_ls` |
+| ffsync | `fastfile_sync` |
+
+
+## Options
+
+These are options you can set to change certain parts of the plugin. To change
+them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
+For example: `fastfile_var_prefix='@'`.
+
+- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
+ created global aliases.
+ **Default:** `§` (section sign), easy to type in a german keyboard via the combination
+ [`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
+ or using `⌥ Option`+`6` in macOS.
+
+- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
+ with a trailing slash.
+ **Default:** `$HOME/.fastfile/`.
+
+## Author
+
+- [Karolin Varner](https://github.com/koraa)
diff --git a/plugins/fastfile/fastfile.plugin.zsh b/plugins/fastfile/fastfile.plugin.zsh
index 775e9483e..ccbbce3b2 100644
--- a/plugins/fastfile/fastfile.plugin.zsh
+++ b/plugins/fastfile/fastfile.plugin.zsh
@@ -1,21 +1,11 @@
-################################################################################
-# FILE: fastfile.plugin.zsh
-# DESCRIPTION: oh-my-zsh plugin file.
-# AUTHOR: Michael Varner (musikmichael@web.de)
-# VERSION: 1.0.0
-#
-# This plugin adds the ability to on the fly generate and access file shortcuts.
-#
-################################################################################
-
###########################
-# Settings
+# Settings
# These can be overwritten any time.
# If they are not set yet, they will be
# overwritten with their default values
-default fastfile_dir "${HOME}/.fastfile/"
+default fastfile_dir "${HOME}/.fastfile"
default fastfile_var_prefix "§"
###########################
@@ -33,7 +23,7 @@ default fastfile_var_prefix "§"
function fastfile() {
test "$2" || 2="."
file=$(readlink -f "$2")
-
+
test "$1" || 1="$(basename "$file")"
name=$(echo "$1" | tr " " "_")
@@ -51,7 +41,7 @@ function fastfile() {
# Arguments:
# 1. name - The name of the shortcut
# STDOUT:
-# The path
+# The path to the shortcut file
#
function fastfile_resolv() {
echo "${fastfile_dir}${1}"
@@ -88,12 +78,12 @@ function fastfile_print() {
# (=> fastfle_print) for each shortcut
#
function fastfile_ls() {
- for f in "${fastfile_dir}"/*; do
- file=`basename "$f"` # To enable simpler handeling of spaces in file names
- varkey=`echo "$file" | tr " " "_"`
+ for f in "${fastfile_dir}"/*(NF); do
+ file=`basename "$f"` # To enable simpler handeling of spaces in file names
+ varkey=`echo "$file" | tr " " "_"`
- # Special format for colums
- echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
+ # Special format for colums
+ echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
done | column -t -s "|"
}
@@ -102,7 +92,6 @@ function fastfile_ls() {
#
# Arguments:
# 1. name - The name of the shortcut (default: name of the file)
-# 2. file - The file or directory to make the shortcut for
# STDOUT:
# => fastfle_print
#
@@ -115,11 +104,11 @@ function fastfile_rm() {
# Generate the aliases for the shortcuts
#
function fastfile_sync() {
- for f in "${fastfile_dir}"/*; do
- file=`basename "$f"` # To enable simpler handeling of spaces in file names
- varkey=`echo "$file" | tr " " "_"`
+ for f in "${fastfile_dir}"/*(NF); do
+ file=`basename "$f"` # To enable simpler handeling of spaces in file names
+ varkey=`echo "$file" | tr " " "_"`
- alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
+ alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
done
}
@@ -133,6 +122,6 @@ alias ffls=fastfile_ls
alias ffsync=fastfile_sync
##################################
-# Init
+# Init
-fastfile_sync \ No newline at end of file
+fastfile_sync
diff --git a/plugins/fbterm/README.md b/plugins/fbterm/README.md
new file mode 100644
index 000000000..70ce56da8
--- /dev/null
+++ b/plugins/fbterm/README.md
@@ -0,0 +1,10 @@
+# fbterm
+
+This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm)
+if on a real TTY (`/dev/tty*`).
+
+To use it, add `fbterm` to the plugins array of your zshrc file:
+
+```zsh
+plugins=(... fbterm)
+```
diff --git a/plugins/fd/README.md b/plugins/fd/README.md
new file mode 100644
index 000000000..aabd624b8
--- /dev/null
+++ b/plugins/fd/README.md
@@ -0,0 +1,13 @@
+# fd
+
+This plugin adds completion for the file search tool [`fd`](https://github.com/sharkdp/fd), also known as `fd-find`.
+
+To use it, add `fd` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... fd)
+```
+
+Completion is taken from the fd release [`7.3.0`](https://github.com/sharkdp/fd/releases/tag/v7.3.0).
+
+Updated on Febrary 13th, 2019.
diff --git a/plugins/fd/_fd b/plugins/fd/_fd
new file mode 100644
index 000000000..7a4c38753
--- /dev/null
+++ b/plugins/fd/_fd
@@ -0,0 +1,83 @@
+#compdef fd fdfind
+
+autoload -U is-at-least
+
+_fd() {
+ 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[@]}" \
+'-d+[Set maximum search depth (default: none)]' \
+'--max-depth=[Set maximum search depth (default: none)]' \
+'--maxdepth=[See --max-depth]' \
+'*-t+[Filter by type: file (f), directory (d), symlink (l),
+executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \
+'*--type=[Filter by type: file (f), directory (d), symlink (l),
+executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \
+'*-e+[Filter by file extension]' \
+'*--extension=[Filter by file extension]' \
+'-x+[Execute a command for each search result]' \
+'--exec=[Execute a command for each search result]' \
+'(-x --exec)-X+[Execute a command with all search results at once]' \
+'(-x --exec)--exec-batch=[Execute a command with all search results at once]' \
+'*-E+[Exclude entries that match the given glob pattern]' \
+'*--exclude=[Exclude entries that match the given glob pattern]' \
+'*--ignore-file=[Add a custom ignore-file in .gitignore format]' \
+'-c+[When to use colors: never, *auto*, always]: :(never auto always)' \
+'--color=[When to use colors: never, *auto*, always]: :(never auto always)' \
+'-j+[Set number of threads to use for searching & executing]' \
+'--threads=[Set number of threads to use for searching & executing]' \
+'*-S+[Limit results based on the size of files.]' \
+'*--size=[Limit results based on the size of files.]' \
+'--max-buffer-time=[the time (in ms) to buffer, before streaming to the console]' \
+'--changed-within=[Filter by file modification time (newer than)]' \
+'--changed-before=[Filter by file modification time (older than)]' \
+'*--search-path=[(hidden)]' \
+'-H[Search hidden files and directories]' \
+'--hidden[Search hidden files and directories]' \
+'-I[Do not respect .(git|fd)ignore files]' \
+'--no-ignore[Do not respect .(git|fd)ignore files]' \
+'--no-ignore-vcs[Do not respect .gitignore files]' \
+'*-u[Alias for no-ignore and/or hidden]' \
+'-s[Case-sensitive search (default: smart case)]' \
+'--case-sensitive[Case-sensitive search (default: smart case)]' \
+'-i[Case-insensitive search (default: smart case)]' \
+'--ignore-case[Case-insensitive search (default: smart case)]' \
+'-F[Treat the pattern as a literal string]' \
+'--fixed-strings[Treat the pattern as a literal string]' \
+'-a[Show absolute instead of relative paths]' \
+'--absolute-path[Show absolute instead of relative paths]' \
+'-L[Follow symbolic links]' \
+'--follow[Follow symbolic links]' \
+'-p[Search full path (default: file-/dirname only)]' \
+'--full-path[Search full path (default: file-/dirname only)]' \
+'-0[Separate results by the null character]' \
+'--print0[Separate results by the null character]' \
+'--show-errors[Enable display of filesystem errors]' \
+'-h[Prints help information]' \
+'--help[Prints help information]' \
+'-V[Prints version information]' \
+'--version[Prints version information]' \
+'::pattern -- the search pattern, a regular expression (optional):_files' \
+'::path -- the root directory for the filesystem search (optional):_files' \
+&& ret=0
+
+}
+
+(( $+functions[_fd_commands] )) ||
+_fd_commands() {
+ local commands; commands=(
+
+ )
+ _describe -t commands 'fd commands' commands "$@"
+}
+
+_fd "$@"
diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md
index 6594799b3..85d8d7dea 100644
--- a/plugins/fedora/README.md
+++ b/plugins/fedora/README.md
@@ -1 +1 @@
-The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead.
+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
index 16a214313..226506c05 120000..100644
--- a/plugins/fedora/fedora.plugin.zsh
+++ b/plugins/fedora/fedora.plugin.zsh
@@ -1 +1,3 @@
-../dnf/dnf.plugin.zsh \ No newline at end of file
+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/firewalld/readme.md b/plugins/firewalld/README.md
index 8b5bc74d4..8b5bc74d4 100644
--- a/plugins/firewalld/readme.md
+++ b/plugins/firewalld/README.md
diff --git a/plugins/flutter/README.md b/plugins/flutter/README.md
new file mode 100644
index 000000000..be419144f
--- /dev/null
+++ b/plugins/flutter/README.md
@@ -0,0 +1,21 @@
+## Flutter plugin
+
+The Flutter plugin provides completion and useful aliases
+
+To use it, add flutter to the plugins array of your zshrc file:
+
+```
+plugins=(... flutter)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+| :--------- | :--------------------- | :------------------------------------------------------------------------- |
+| `fl` | `flutter` | Shorthand for flutter command |
+| `flr` | `flutter run` | Runs flutter app |
+| `fldoc` | `flutter doctor` | Runs flutter doctor |
+| `flb` | `flutter build` | Build flutter application |
+| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory |
+| `flget` | `flutter packages get` | Installs dependencies |
+| `flc` | `flutter clean` | Cleans flutter porject |
diff --git a/plugins/flutter/_flutter b/plugins/flutter/_flutter
new file mode 100644
index 000000000..ab6ce4265
--- /dev/null
+++ b/plugins/flutter/_flutter
@@ -0,0 +1,37 @@
+#compdef flutter
+#autoload
+
+local -a _1st_arguments
+_1st_arguments=(
+ "analyze":"Analyze the project's Dart code."
+ "assemble":"Assemble and build flutter resources."
+ "attach":"Attach to a running application."
+ "build":"Flutter build commands."
+ "channel":"List or switch flutter channels."
+ "clean":"Delete the build/ and .dart_tool/ directories."
+ "config":"Configure Flutter settings."
+ "create":"Create a new Flutter project."
+ "devices":"List all connected devices."
+ "doctor":"Show information about the installed tooling."
+ "drive":"Runs Flutter Driver tests for the current project."
+ "emulators":"List, launch and create emulators."
+ "format":" Format one or more dart files."
+ "help":"Display help information for flutter."
+ "install":"Install a Flutter app on an attached device."
+ "logs":"Show log output for running Flutter apps."
+ "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
+ "precache":"Populates the Flutter tool's cache of binary artifacts."
+ "pub":"Commands for managing Flutter packages."
+ "run":"Run your Flutter app on an attached device."
+ "screenshot":"Take a screenshot from a connected device."
+ "test":"Run Flutter unit tests for the current project."
+ "upgrade":"Upgrade your copy of Flutter."
+ "version":"List or switch flutter versions."
+)
+
+_arguments -C '*:: :->subcmds'
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "flutter command" _1st_arguments
+ return
+fi
diff --git a/plugins/flutter/flutter.plugin.zsh b/plugins/flutter/flutter.plugin.zsh
new file mode 100644
index 000000000..01c4c9f5f
--- /dev/null
+++ b/plugins/flutter/flutter.plugin.zsh
@@ -0,0 +1,7 @@
+alias fl="flutter"
+alias flr="flutter run"
+alias fldoc="flutter doctor"
+alias flb="flutter build"
+alias flattach="flutter attach"
+alias flget="flutter packages get"
+alias flc="flutter clean"
diff --git a/plugins/forklift/README.md b/plugins/forklift/README.md
index 6c4ce1e81..7dfd8bf95 100644
--- a/plugins/forklift/README.md
+++ b/plugins/forklift/README.md
@@ -1,15 +1,23 @@
-## forklift
+# forklift
Plugin for ForkLift, an FTP application for OS X.
-### Requirements
+To use it, add `forklift` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... forklift)
+```
+
+## Requirements
* [ForkLift](https://binarynights.com/)
-### Usage
+## Usage
-<code>fl [*file_or_folder*]</code>
+`fl [<file_or_folder>]`
* If `fl` is called without arguments then the current folder is opened in ForkLift. This is equivalent to `fl .`.
-* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift. If called with a non-directory file as the argument, then the file's parent directory is opened.
+* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift
+
+* If `fl` is called with a non-directory file as the argument, then the file's parent directory is opened.
diff --git a/plugins/forklift/forklift.plugin.zsh b/plugins/forklift/forklift.plugin.zsh
index 274c4a822..85889481b 100644
--- a/plugins/forklift/forklift.plugin.zsh
+++ b/plugins/forklift/forklift.plugin.zsh
@@ -1,6 +1,7 @@
# Open folder in ForkLift.app or ForkLift2.app from console
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
# Updated to support ForkLift 2 and ForkLift 3 by Johan Kaving
+# Updated to support ForkLift from Setapp by Paul Rudkin
#
# Usage:
# fl [<folder>]
@@ -26,6 +27,13 @@ function fl {
try
tell application "Finder"
+ set forkLiftSetapp to name of application file id "com.binarynights.forklift-setapp"
+ end tell
+ on error err_msg number err_num
+ set forkLiftSetapp to null
+ end try
+ try
+ tell application "Finder"
set forkLift3 to name of application file id "com.binarynights.ForkLift-3"
end tell
on error err_msg number err_num
@@ -46,7 +54,12 @@ function fl {
set forkLift to null
end try
- if forkLift3 is not null and application forkLift3 is running then
+ if forkLiftSetapp is not null and application forkLiftSetapp is running then
+ tell application forkLiftSetapp
+ activate
+ set forkLiftVersion to version
+ end tell
+ else if forkLift3 is not null and application forkLift3 is running then
tell application forkLift3
activate
set forkLiftVersion to version
@@ -62,7 +75,9 @@ function fl {
set forkLiftVersion to version
end tell
else
- if forkLift3 is not null then
+ if forkLiftSetapp is not null then
+ set appName to forkLiftSetapp
+ else if forkLift3 is not null then
set appName to forkLift3
else if forkLift2 is not null then
set appName to forkLift2
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/README.md b/plugins/frontend-search/README.md
index f06e79102..050058931 100644
--- a/plugins/frontend-search/README.md
+++ b/plugins/frontend-search/README.md
@@ -1,9 +1,8 @@
-## Introduction ##
+## Introduction
> Searches for your frontend web development made easier
-
-## Installation ##
+## Installation
Open your `~/.zshrc` file and enable the `frontend-search` plugin:
@@ -13,53 +12,64 @@ plugins=( ... frontend-search)
```
-
-## Usage ##
+## Usage
You can use the frontend-search plugin in these two forms:
-* `frontend <context> <term> [more terms if you want]`
-* `<context> <term> [more terms if you want]`
+- `frontend <context> <term> [more terms if you want]`
+- `<context> <term> [more terms if you want]`
For example, these two are equivalent:
```zsh
-$ frontend angularjs dependency injection
-$ angularjs dependency injection
+$ angular dependency injection
+# Will turn into ...
+$ frontend angular dependency injection
```
Available search contexts are:
-| context | URL |
-|---------------|--------------------------------------------------------------------------|
-| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
-| aurajs | `http://aurajs.com/api/#stq=` |
-| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` |
-| bootsnipp | `https://bootsnipp.com/search?q=` |
-| caniuse | `https://caniuse.com/#search=` |
-| codepen | `https://codepen.io/search?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:` |
-| emberjs | `https://emberjs.com/api/#stp=1&stq=` |
-| fontello | `http://fontello.com/#search=` |
-| html5please | `http://html5please.com/#` |
-| jquery | `https://api.jquery.com/?s=` |
-| lodash | `https://devdocs.io/lodash/index#` |
-| mdn | `https://developer.mozilla.org/search?q=` |
-| npmjs | `https://www.npmjs.com/search?q=` |
-| qunit | `https://api.qunitjs.com/?s=` |
-| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
-| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
-| stackoverflow | `https://stackoverflow.com/search?q=` |
-| unheap | `http://www.unheap.com/?s=` |
+| context | URL |
+| ------------- | --------------------------------------------------------------------------- |
+| angular | `https://angular.io/?search=` |
+| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
+| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` |
+| bootsnipp | `https://bootsnipp.com/search?q=` |
+| bundlephobia | `https://bundlephobia.com/result?p=` |
+| caniuse | `https://caniuse.com/#search=` |
+| codepen | `https://codepen.io/search?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:` |
+| emberjs | `https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=` |
+| flowtype | `https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=` |
+| fontello | `http://fontello.com/#search=` |
+| github | `https://github.com/search?q=` |
+| html5please | `https://html5please.com/#` |
+| jestjs | `https://www.google.com/search?as_sitesearch=jestjs.io&as_q=` |
+| jquery | `https://api.jquery.com/?s=` |
+| lodash | `https://devdocs.io/lodash/index#` |
+| mdn | `https://developer.mozilla.org/search?q=` |
+| nodejs | `https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=` |
+| npmjs | `https://www.npmjs.com/search?q=` |
+| packagephobia | `https://packagephobia.now.sh/result?p=` |
+| qunit | `https://api.qunitjs.com/?s=` |
+| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
+| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
+| stackoverflow | `https://stackoverflow.com/search?q=` |
+| typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` |
+| unheap | `http://www.unheap.com/?s=` |
+| vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` |
If you want to have another context, open an Issue and tell us!
+## Fallback search behaviour
+
+The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced.
## Author
**Wilson Mendes (willmendesneto)**
-+ <https://plus.google.com/+WilsonMendes>
-+ <https://twitter.com/willmendesneto>
-+ <https://github.com/willmendesneto>
+
+- <https://twitter.com/willmendesneto>
+- <https://github.com/willmendesneto>
diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh
index 9aad76f76..15f8d239d 100644
--- a/plugins/frontend-search/_frontend-search.sh
+++ b/plugins/frontend-search/_frontend-search.sh
@@ -17,27 +17,35 @@ function _frontend() {
frontend_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
commands=(
- 'jquery: Search in jQuery website'
- 'mdn: Search in MDN website'
- 'compassdoc: Search in COMPASS website'
- 'html5please: Search in HTML5 Please website'
+ 'angular: Search in Angular.io website'
+ 'angularjs: Search in docs.angularjs.org website'
+ 'bem: Search in BEM website'
+ 'bootsnipp: Search in bootsnipp website'
+ 'bundlephobia: Search in Bundlephobia website'
'caniuse: Search in Can I Use website'
- 'aurajs: Search in AuraJs website'
+ 'codepen: Search in codepen website'
+ 'compassdoc: Search in COMPASS website'
+ 'cssflow: Search in cssflow website'
'dartlang: Search in Dart website'
+ 'emberjs: Search in Ember website'
+ 'flowtype: Search in Flowtype website'
+ 'fontello: Search in fontello website'
+ 'github: Search in GitHub website'
+ 'html5please: Search in HTML5 Please website'
+ 'jestjs: Search in Jest website'
+ 'jquery: Search in jQuery website'
'lodash: Search in Lo-Dash website'
+ 'mdn: Search in MDN website'
+ 'nodejs: Search in NodeJS website'
+ 'npmjs: Search in NPMJS website'
+ 'packagephobia: Search in Packagephobia website'
'qunit: Search in Qunit website'
- 'fontello: Search in fontello website'
- 'bootsnipp: Search in bootsnipp website'
- 'cssflow: Search in cssflow website'
- 'codepen: Search in codepen website'
- 'unheap: Search in unheap website'
- 'bem: Search in BEM website'
- 'smacss: Search in SMACSS website'
- 'angularjs: Search in Angular website'
'reactjs: Search in React website'
- 'emberjs: Search in Ember website'
+ 'smacss: Search in SMACSS website'
'stackoverflow: Search in StackOverflow website'
- 'npmjs: Search in NPMJS website'
+ 'typescript: Search in TypeScript website'
+ 'unheap: Search in unheap website'
+ 'vuejs: Search in VueJS website'
)
_arguments -C \
@@ -66,9 +74,6 @@ function _frontend() {
caniuse)
_describe -t points "Warp points" frontend_points && ret=0
;;
- aurajs)
- _describe -t points "Warp points" frontend_points && ret=0
- ;;
dartlang)
_describe -t points "Warp points" frontend_points && ret=0
;;
@@ -81,6 +86,9 @@ function _frontend() {
fontello)
_describe -t points "Warp points" frontend_points && ret=0
;;
+ github)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
bootsnipp)
_describe -t points "Warp points" frontend_points && ret=0
;;
@@ -114,6 +122,27 @@ function _frontend() {
npmjs)
_describe -t points "Warp points" frontend_points && ret=0
;;
+ bundlephobia)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
+ packagephobia)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
+ flowtype)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
+ typescript)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
+ vuejs)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
+ nodejs)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
+ jestjs)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
esac
;;
esac
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index 14877fb0d..4517e21a8 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -1,24 +1,43 @@
+alias angular='frontend angular'
alias angularjs='frontend angularjs'
-alias aurajs='frontend aurajs'
alias bem='frontend bem'
alias bootsnipp='frontend bootsnipp'
+alias bundlephobia='frontend bundlephobia'
alias caniuse='frontend caniuse'
alias codepen='frontend codepen'
alias compassdoc='frontend compassdoc'
alias cssflow='frontend cssflow'
alias dartlang='frontend dartlang'
alias emberjs='frontend emberjs'
+alias flowtype='frontend flowtype'
alias fontello='frontend fontello'
+alias github='frontend github'
alias html5please='frontend html5please'
+alias jestjs='frontend jestjs'
alias jquery='frontend jquery'
alias lodash='frontend lodash'
alias mdn='frontend mdn'
+alias nodejs='frontend nodejs'
alias npmjs='frontend npmjs'
+alias packagephobia='frontend packagephobia'
alias qunit='frontend qunit'
alias reactjs='frontend reactjs'
alias smacss='frontend smacss'
alias stackoverflow='frontend stackoverflow'
+alias typescript='frontend typescript'
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"
+}
function frontend() {
emulate -L zsh
@@ -26,27 +45,35 @@ function frontend() {
# define search context URLS
typeset -A urls
urls=(
- angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
- aurajs 'http://aurajs.com/api/#stq='
- bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
+ angular 'https://angular.io/?search='
+ angularjs $(_frontend_fallback 'angularjs.org')
+ bem $(_frontend_fallback 'bem.info')
bootsnipp 'https://bootsnipp.com/search?q='
+ bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search='
codepen 'https://codepen.io/search?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:'
- emberjs 'https://emberjs.com/api/#stp=1&stq='
+ emberjs $(_frontend_fallback 'emberjs.com/')
+ flowtype $(_frontend_fallback 'flow.org/en/docs/')
fontello 'http://fontello.com/#search='
- html5please 'http://html5please.com/#'
+ github 'https://github.com/search?q='
+ html5please 'https://html5please.com/#'
+ jestjs $(_frontend_fallback 'jestjs.io')
jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q='
+ nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
npmjs 'https://www.npmjs.com/search?q='
+ packagephobia 'https://packagephobia.now.sh/result?p='
qunit 'https://api.qunitjs.com/?s='
- reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
- smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
+ reactjs $(_frontend_fallback 'reactjs.org/')
+ smacss $(_frontend_fallback 'smacss.com')
stackoverflow 'https://stackoverflow.com/search?q='
+ typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
unheap 'http://www.unheap.com/?s='
+ vuejs $(_frontend_fallback 'vuejs.org')
)
# show help for command list
@@ -57,9 +84,9 @@ function frontend() {
print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
print -P "and %Ucontext%u is one of the following:"
print -P ""
- print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
- print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
- print -P " qunit, reactjs, smacss, stackoverflow, unheap"
+ print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
+ print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
+ print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
print -P ""
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
print -P ""
@@ -73,17 +100,17 @@ function frontend() {
echo ""
echo "Valid contexts are:"
echo ""
- echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, "
- echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
- echo " qunit, reactjs, smacss, stackoverflow, unheap"
+ echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
+ echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
+ echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
echo ""
return 1
fi
# build search url:
- # join arguments passed with '+', then append to search context URL
+ # join arguments passed with '%20', then append to search context URL
# TODO substitute for proper urlencode method
- url="${urls[$1]}${(j:+:)@[2,-1]}"
+ url="${urls[$1]}${(j:%20:)@[2,-1]}"
echo "Opening $url ..."
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 27e2d9246..a979fe222 100644
--- a/plugins/fzf/fzf.plugin.zsh
+++ b/plugins/fzf/fzf.plugin.zsh
@@ -1,57 +1,174 @@
-test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
-
-if [[ -z "${fzf_base}" ]]; then
- fzfdirs=(
- "${HOME}/.fzf"
- "/usr/local/opt/fzf"
- "/usr/share/fzf"
- )
- for dir in ${fzfdirs}; do
- if [[ -d "${dir}" ]]; then
- fzf_base="${dir}"
- break
- fi
- done
-
- if [[ -z "${fzf_base}" ]]; then
- if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
- if [[ -d "${dir}" ]]; then
- fzf_base="${dir}"
- fi
- fi
- fi
-fi
+function setup_using_base_dir() {
+ local fzf_base fzf_shell fzfdirs dir
-if [[ -n "${fzf_base}" ]]; then
-
- # Fix fzf shell directory for Archlinux package
- if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then
- fzf_shell="${fzf_base}"
- else
- fzf_shell="${fzf_base}/shell"
- fi
-
- # Setup fzf
- # ---------
- if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
- export PATH="$PATH:$fzf_base/bin"
- fi
-
- # Auto-completion
- # ---------------
- if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
- [[ $- == *i* ]] && 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
-
-else
- 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
-fi
+ test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
+
+ if [[ -z "${fzf_base}" ]]; then
+ 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"
+ )
+ for dir in ${fzfdirs}; do
+ if [[ -d "${dir}" ]]; then
+ fzf_base="${dir}"
+ break
+ fi
+ done
+
+ if [[ -z "${fzf_base}" ]]; then
+ if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
+ if [[ -d "${dir}" ]]; then
+ fzf_base="${dir}"
+ fi
+ fi
+ fi
+ fi
+
+ if [[ ! -d "${fzf_base}" ]]; then
+ return 1
+ 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
+
+ # Setup fzf binary path
+ if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then
+ export PATH="$PATH:$fzf_base/bin"
+ fi
+
+ # 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() {
+ 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
+
+ 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 [[ -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
+ fi
-unset fzf_base fzf_shell dir fzfdirs
+ 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() {
+ 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
+}
+
+# Indicate to user that fzf installation not found if nothing worked
+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/gas/README.md b/plugins/gas/README.md
new file mode 100644
index 000000000..47b3fb9df
--- /dev/null
+++ b/plugins/gas/README.md
@@ -0,0 +1,10 @@
+# Gas plugin
+
+This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command,
+a utility to manage Git authors.
+
+To use it, add `gas` to the plugins array of your zshrc file:
+
+```zsh
+plugins=(... gas)
+```
diff --git a/plugins/gatsby/README.md b/plugins/gatsby/README.md
new file mode 100644
index 000000000..36846a228
--- /dev/null
+++ b/plugins/gatsby/README.md
@@ -0,0 +1,7 @@
+# gatsby autocomplete plugin
+
+* Adds autocomplete options for all gatsby commands.
+
+## Requirements
+
+In order to make this work, you will need to have gatsby set up in your path.
diff --git a/plugins/gatsby/_gatsby b/plugins/gatsby/_gatsby
new file mode 100644
index 000000000..66eb02f00
--- /dev/null
+++ b/plugins/gatsby/_gatsby
@@ -0,0 +1,24 @@
+#compdef gatsby
+#autoload
+
+# in order to make this work, you will need to have gatsby
+# https://www.gatsbyjs.org/
+
+local -a _1st_arguments
+_1st_arguments=(
+'develop:Start development server. Watches files, rebuilds, and hot reloads if something changes'
+'build:Build a Gatsby project.'
+'serve:Serve previously built Gatsby site.'
+'info:Get environment information for debugging and issue reporting'
+'clean:Wipe the local gatsby environment including built assets and cache'
+'repl:Get a node repl with context of Gatsby environment, see (add docs link here)'
+'new: [rootPath] [starter] Create new Gatsby project.'
+'telemetry:Enable or disable Gatsby anonymous analytics collection.'
+)
+
+_arguments -C '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "gatsby subcommand" _1st_arguments
+ return
+fi
diff --git a/plugins/gcloud/README.md b/plugins/gcloud/README.md
new file mode 100644
index 000000000..e7ce0e0f1
--- /dev/null
+++ b/plugins/gcloud/README.md
@@ -0,0 +1,24 @@
+# gcloud
+
+This plugin provides completion support for the
+[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/).
+
+To use it, add `gcloud` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... gcloud)
+```
+
+It relies on you having installed the SDK using one of the supported options
+listed [here](https://cloud.google.com/sdk/install).
+
+## Plugin Options
+
+* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have
+your GCloud SDK installed in a non-standard location. The plugin will use this
+as the base for your SDK if it finds it set already.
+
+* If you do not have a `python2` in your `PATH` you'll also need to set the
+`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is
+used by the SDK to call a compatible interpreter when you run one of the
+SDK commands.
diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh
new file mode 100644
index 000000000..c7aebe697
--- /dev/null
+++ b/plugins/gcloud/gcloud.plugin.zsh
@@ -0,0 +1,33 @@
+#####################################################
+# gcloud plugin for oh-my-zsh #
+# Author: Ian Chesal (github.com/ianchesal) #
+#####################################################
+
+if [[ -z "${CLOUDSDK_HOME}" ]]; then
+ search_locations=(
+ "$HOME/google-cloud-sdk"
+ "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
+ "/usr/share/google-cloud-sdk"
+ "/snap/google-cloud-sdk/current"
+ "/usr/lib64/google-cloud-sdk/"
+ "/opt/google-cloud-sdk"
+ )
+
+ for gcloud_sdk_location in $search_locations; do
+ if [[ -d "${gcloud_sdk_location}" ]]; then
+ CLOUDSDK_HOME="${gcloud_sdk_location}"
+ break
+ fi
+ done
+fi
+
+if (( ${+CLOUDSDK_HOME} )); then
+ if (( ! $+commands[gcloud] )); then
+ # Only source this if GCloud isn't already on the path
+ if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
+ source "${CLOUDSDK_HOME}/path.zsh.inc"
+ fi
+ fi
+ source "${CLOUDSDK_HOME}/completion.zsh.inc"
+ export CLOUDSDK_HOME
+fi
diff --git a/plugins/geeknote/README.md b/plugins/geeknote/README.md
index 3f2353112..95b3aa7dd 100644
--- a/plugins/geeknote/README.md
+++ b/plugins/geeknote/README.md
@@ -1,12 +1,10 @@
-## ZSH-Geeknote
+# Geeknote plugin
-[Geeknote](https://github.com/VitaliyRodnenko/geeknote) plugin for oh-my-zsh.
+This plugin provides autocompletion for [Geeknote](https://github.com/VitaliyRodnenko/geeknote)
+and an alias for `geeknote` called `gn`.
-Plugins provides:
+To use it, add `geeknote` to the plugins array in your zshrc file:
-- auto completion of commands and their options
-- alias `gn`
-
-You can find information how to install Geeknote and it's available commands on the [project website](http://www.geeknote.me/).
-
-Maintainer : Ján Koščo ([@s7anley](https://twitter.com/s7anley))
+```zsh
+plugins=( ... geeknote ...)
+```
diff --git a/plugins/geeknote/_geeknote b/plugins/geeknote/_geeknote
index cf1a187d2..a34be59b1 100644
--- a/plugins/geeknote/_geeknote
+++ b/plugins/geeknote/_geeknote
@@ -1,136 +1,157 @@
#compdef geeknote
-# --------------- ------------------------------------------------------------
-# Name : _geeknote
-# Synopsis : zsh completion for geeknote
-# Author : Ján Koščo <3k.stanley@gmail.com>
-# HomePage : http://www.geeknote.me
-# Version : 0.1
-# Tag : [ shell, zsh, completion, evernote ]
-# Copyright : © 2014 by Ján Koščo,
-# Released under current GPL license.
-# --------------- ------------------------------------------------------------
+
+# Geeknote Autocomplete plugin for Zsh
+# Requires: Geeknote installed
+# Author : Ján Koščo (@s7anley)
+
+__login() {
+ # no arguments
+}
+
+__logout() {
+ _arguments \
+ '--force[Do not ask about logging out.]'
+}
+
+__settings() {
+ _arguments \
+ "--editor+[Set the editor, which use to edit and create notes.]::"
+}
+
+__create() {
+ _arguments \
+ '--title+[The note title.]::' \
+ '--content+[The note content.]::' \
+ '--tags+[One tag or the list of tags which will be added to the note.]::' \
+ '--notebook+[Set the notebook where to save note.]::' \
+ '--resource+[Add a resource to the note.]::'
+}
+
+__edit() {
+ _arguments \
+ '--note+[The name or ID from the previous search of a note to edit.]::' \
+ '--title+[Set new title of the note.]::' \
+ '--content+[Set new content of the note.]::' \
+ '--tags+[Set new list o tags for the note.]::' \
+ '--notebook+[Assign new notebook for the note.]::' \
+ '--resource+[Add a resource to the note.]::'
+}
+
+__find() {
+ _arguments \
+ '--search+[Text to search.]::' \
+ '--tags+[Notes with which tag/tags to search.]::' \
+ '--notebook+[In which notebook search the note.]::' \
+ '--date+[Set date in format dd.mm.yyyy or date range dd.mm.yyyy-dd.mm.yyyy.]::' \
+ '--count+[How many notes show in the result list.]::' \
+ '--with-url[Add direct url of each note in results to Evernote web-version.]' \
+ '--content-search[Search by content, not by title.]' \
+ '--exact-entry[Search for exact entry of the request.]'
+}
+
+__show() {
+ _arguments \
+ '--note+[The name or ID from the previous search of a note to show.]::' \
+ '--raw[Show the raw note body.]'
+}
+
+__remove() {
+ _arguments \
+ '--note+[The name or ID from the previous search of a note to remove.]::' \
+ '--force[Do not ask about removing.]'
+}
+
+__notebook-list() {
+ # no arguments
+}
+
+__notebook-create() {
+ _arguments \
+ '--title+[Set the title of new notebook.]::'
+}
+
+__notebook-edit() {
+ _arguments \
+ '--title+[Set the title of new notebook.]::' \
+ '--notebook+[The name of a notebook to rename.]::'
+}
+
+__tag-list() {
+ # no arguments
+}
+
+__tag-create() {
+ _arguments \
+ '--title+[Set the title of new tag.]::'
+}
+
+__tag-edit() {
+ _arguments \
+ '--tagname+[The name of a tag to rename.]::' \
+ '--title+[Set the new name of tag.]::'
+}
+
+__user() {
+ _arguments \
+ '--full[Show full information.]'
+}
local -a _1st_arguments
_1st_arguments=(
- 'login'
- 'logout'
- 'settings'
- 'create'
- 'edit'
- 'find'
- 'show'
- 'remove'
- 'notebook-list'
- 'notebook-create'
- 'notebook-edit'
- 'tag-list'
- 'tag-create'
- 'tag-edit'
- 'tag-remove'
- 'gnsync'
- 'user'
+ 'login':'Authorize in Evernote.'
+ 'logout':'Logout from Evernote.'
+ 'settings':'Show and edit current settings.'
+ 'create':'Create note in Evernote.'
+ 'edit':'Edit note in Evernote.'
+ 'find':'Search notes in Evernote.'
+ 'show':'Output note in the terminal.'
+ 'remove':'Remove note from Evernote.'
+ 'notebook-list':'Show the list of existing notebooks in your Evernote.'
+ 'notebook-create':'Create new notebook.'
+ 'notebook-edit':'Edit/rename notebook.'
+ 'tag-list':'Show the list of existing tags in your Evernote.'
+ 'tag-create':'Create new tag.'
+ 'tag-edit':'Edit/rename tag.'
+ 'user':'Show information about active user.'
)
_arguments '*:: :->command'
if (( CURRENT == 1 )); then
- _describe -t commands "geeknote command" _1st_arguments
- return
+ _describe -t commands "geeknote command" _1st_arguments
+ return
fi
local -a _command_args
case "$words[1]" in
- user)
- _command_args=(
- '(--full)--full' \
- )
- ;;
- logout)
- _command_args=(
- '(--force)--force' \
- )
- ;;
- settings)
- _command_args=(
- '(--editor)--editor' \
- )
- ;;
- create)
- _command_args=(
- '(-t|--title)'{-t,--title}'[note title]' \
- '(-c|--content)'{-c,--content}'[note content]' \
- '(-tg|--tags)'{-tg,--tags}'[one tag or the list of tags which will be added to the note]' \
- '(-nb|--notebook)'{-nb,--notebook}'[name of notebook where to save note]' \
- )
- ;;
- edit)
- _command_args=(
- '(-n|--note)'{-n,--note}'[name or ID from the previous search of a note to edit]' \
- '(-t|--title)'{-t,--title}'[note title]' \
- '(-c|--content)'{-c,--content}'[note content]' \
- '(-tg|--tags)'{-tg,--tags}'[one tag or the list of tags which will be added to the note]' \
- '(-nb|--notebook)'{-nb,--notebook}'[name of notebook where to save note]' \
- )
- ;;
- remove)
- _command_args=(
- '(-n|--note)'{-n,--note}'[name or ID from the previous search of a note to edit]' \
- '(--force)--force' \
- )
- ;;
- show)
- _command_args=(
- '(-n|--note)'{-n,--note}'[name or ID from the previous search of a note to edit]' \
- )
- ;;
- find)
- _command_args=(
- '(-s|--search)'{-s,--search}'[text to search]' \
- '(-tg|--tags)'{-tg,--tags}'[notes with which tag/tags to search]' \
- '(-nb|--notebook)'{-nb,--notebook}'[in which notebook search the note]' \
- '(-d|--date)'{-d,--date}'[date in format dd.mm.yyyy or date range dd.mm.yyyy-dd.mm.yyyy]' \
- '(-cn|--count)'{-cn,--count}'[how many notes show in the result list]' \
- '(-uo|--url-only)'{-uo,--url-only}'[add direct url of each note in results to Evernote web-version]' \
- '(-ee|--exact-entry)'{-ee,--exact-entry}'[search for exact entry of the request]' \
- '(-cs|--content-search)'{-cs,--content-search}'[search by content, not by title]' \
- )
- ;;
- notebook-create)
- _command_args=(
- '(-t|--title)'{-t,--title}'[notebook title]' \
- )
- ;;
- notebook-edit)
- _command_args=(
- '(-nb|--notebook)'{-nb,--notebook}'[name of notebook to rename]' \
- '(-t|--title)'{-t,--title}'[new notebook title]' \
- )
- ;;
- notebook-remove)
- _command_args=(
- '(-nb|--notebook)'{-nb,--notebook}'[name of notebook to remove]' \
- '(--force)--force' \
- )
- ;;
- tag-create)
- _command_args=(
- '(-t|--title)'{-t,--title}'[title of tag]' \
- )
- ;;
- tag-edit)
- _command_args=(
- '(-tgn|--tagname)'{-tgn,--tagname}'[tag to edit]' \
- '(-t|--title)'{-t,--title}'[new tag name]' \
- )
- ;;
- tag-remove)
- _command_args=(
- '(-tgn|--tagname)'{-tgn,--tagname}'[tag to remove]' \
- '(--force)--force' \
- )
- ;;
- esac
-
-_arguments \
- $_command_args \
- && return 0
+ login)
+ __login ;;
+ logout)
+ __logout ;;
+ settings)
+ __settings ;;
+ create)
+ __create ;;
+ edit)
+ __edit ;;
+ find)
+ __find ;;
+ show)
+ __show ;;
+ remove)
+ __remove ;;
+ notebook-list)
+ __notebook-list ;;
+ notebook-create)
+ __notebook-create ;;
+ notebook-edit)
+ __notebook-edit ;;
+ tag-list)
+ __tag-list ;;
+ tag-create)
+ __tag-create ;;
+ tag-edit)
+ __tag-edit ;;
+ user)
+ __user ;;
+esac
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/.gitignore b/plugins/gh/.gitignore
new file mode 100644
index 000000000..fa1244ab5
--- /dev/null
+++ b/plugins/gh/.gitignore
@@ -0,0 +1 @@
+_gh
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..8e055ec35
--- /dev/null
+++ b/plugins/gh/gh.plugin.zsh
@@ -0,0 +1,13 @@
+# Autocompletion for the GitHub CLI (gh).
+
+if (( $+commands[gh] )); then
+ if [[ ! -r "$ZSH_CACHE_DIR/gh_version" \
+ || "$(gh --version)" != "$(< "$ZSH_CACHE_DIR/gh_version")"
+ || ! -f "$ZSH/plugins/gh/_gh" ]]; then
+ gh completion --shell zsh > $ZSH/plugins/gh/_gh
+ gh --version > $ZSH_CACHE_DIR/gh_version
+ fi
+ autoload -Uz _gh
+ _comps[gh]=_gh
+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 1d20bc04b..0da84f2f5 100644
--- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
+++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
@@ -1,27 +1,61 @@
-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 {
- (`git rev-parse --is-inside-work-tree 2>/dev/null` &&
- dir=`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 fetch --all &>! $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 disabled
+ if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; 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)
+ GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
+ command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG"
+ ) &|
}
function git-auto-fetch {
- `git rev-parse --is-inside-work-tree 2>/dev/null` || return
- guard="`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
}
-eval "override-git-auto-fetch-$(declare -f zle-line-init)"
+# zle-line-init widget (don't redefine if already defined)
+(( ! ${+functions[_git-auto-fetch_zle-line-init]} )) || return 0
-function zle-line-init () {
- git-fetch-all
- override-git-auto-fetch-zle-line-init
-}
-zle -N zle-line-init
+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-escape-magic/README.md b/plugins/git-escape-magic/README.md
new file mode 100644
index 000000000..7fefed39d
--- /dev/null
+++ b/plugins/git-escape-magic/README.md
@@ -0,0 +1,16 @@
+# Git Escape Magic
+
+This plugin is copied from the original at
+https://github.com/knu/zsh-git-escape-magic. All credit for the
+functionality enabled by this plugin should go to @knu.
+
+An excerpt from that project's readme explains its purpose.
+
+> It eliminates the need for manually escaping those meta-characters. The zle function it provides is context aware and recognizes the characteristics of each subcommand of git. Every time you type one of these meta-characters on a git command line, it automatically escapes the meta-character with a backslash as necessary and as appropriate.
+
+## Usage
+
+To use this plugin, add it to your list of plugins in your `.zshrc` file.
+
+**NOTE**: If you use url-quote-magic, it must be included before this
+plugin runs to prevent any conflicts.
diff --git a/plugins/git-escape-magic/git-escape-magic b/plugins/git-escape-magic/git-escape-magic
new file mode 100644
index 000000000..94a8d7b0f
--- /dev/null
+++ b/plugins/git-escape-magic/git-escape-magic
@@ -0,0 +1,135 @@
+# -*- mode: sh -*-
+#
+# git-escape-magic - zle tweak for git command line arguments
+#
+# Copyright (c) 2011, 2012, 2014 Akinori MUSHA
+# Licensed under the 2-clause BSD license.
+#
+# This tweak eliminates the need for manually escaping shell
+# meta-characters such as [~^{}] that are used for specifying a git
+# object (commit or tree). Every time you type one of these
+# characters on a git command line, it is automatically escaped with a
+# backslash as necessary and as appropriate.
+#
+# If you want to use this with url-quote-magic, make sure to enable it
+# first.
+#
+# Usage:
+# autoload -Uz git-escape-magic
+# git-escape-magic
+#
+
+git-escape-magic.self-insert() {
+ emulate -L zsh
+ setopt extendedglob
+ local self_insert_function
+ zstyle -s ':git-escape-magic' self-insert-function self_insert_function
+
+ if [[ "$KEYS" == [{}~^]* ]] && {
+ local qkey="${(q)KEYS}"
+ [[ "$KEYS" != "$qkey" ]]
+ } && {
+ local lbuf="$LBUFFER$qkey"
+ [[ "${(Q)LBUFFER}$KEYS" == "${(Q)lbuf}" ]]
+ } && {
+ local -a words
+ words=("${(@Q)${(z)lbuf}}")
+ [[ "$words[(i)(*/|)git(|-[^/]##)]" -le $#words ]]
+ }
+ then
+ local i
+ i="$words[(I)([;(){\&]|\&[\&\!]|\|\||[=<>]\(*)]"
+ if [[ $i -gt 0 ]]; then
+ shift $((i-1)) words
+ if [[ "$words[1]" == [\=\<\>]\(* ]]; then
+ words[1]="${words[1]#[=<>]\(}"
+ else
+ [[ "$words[1]" == \; && $words[2] == (then|else|elif|do) ]] && shift words
+ shift words
+ fi
+ fi
+ while [[ "$words[1]" == (if|while|until|\!) ]]; do
+ shift words
+ done
+ while [[ "$words[1]" == [A-Za-z_][A-Za-z0-9_]#=* ]]; do
+ shift words
+ done
+ [[ "$words[1]" == (*/|)git(|-[^/]##) ]] && {
+ local subcommand
+ subcommand="${words[1]##*/git-}"
+ if [[ -z "$subcommand" ]]; then
+ shift words
+ subcommand="$words[1]"
+ fi
+ [[ $#words -ge 2 ]]
+ } &&
+ case "$subcommand" in
+ # commands that may take pathspec but never take refspec with [{}~^]
+ (add|rm|am|apply|check-attr|checkout-index|clean|clone|config|diff-files|hash-object|help|index-pack|mailinfo|mailsplit|merge-file|merge-index|mergetool|mktag|mv|pack-objects|pack-redundant|relink|send-email|show-index|show-ref|stage|status|verify-pack)
+ false ;;
+ # commands that may take pathspec but rarely take refspec with [{}~^]
+ (for-each-ref|grep|ls-files|update-index)
+ false ;;
+ (archive|ls-tree)
+ ! [[ $#words -ge 3 &&
+ "$words[-2]" == [^-]* ]] ;;
+ (diff-tree)
+ ! [[ $#words -ge 4 &&
+ "$words[-2]" == [^-]* &&
+ "$words[-3]" == [^-]* ]] ;;
+ (*)
+ [[ $words[(i)--] -gt $#words ]] ;;
+ esac &&
+ case "${words[-1]%%"$KEYS"}" in
+ (*[@^])
+ [[ "$KEYS" == [{~^]* ]] ;;
+ (*[@^]\{[^}]##)
+ [[ "$KEYS" == \}* ]] ;;
+ (?*)
+ [[ "$KEYS" == [~^]* ]] ;;
+ (*)
+ false ;;
+ esac &&
+ LBUFFER="$LBUFFER\\"
+ fi
+
+ zle "$self_insert_function"
+}
+
+git-escape-magic.on() {
+ emulate -L zsh
+ local self_insert_function="${$(zle -lL | awk \
+ '$1=="zle"&&$2=="-N"&&$3=="self-insert"{print $4;exit}'):-.self-insert}"
+
+ [[ "$self_insert_function" == git-escape-magic.self-insert ]] &&
+ return 0
+
+ # For url-quote-magic which does not zle -N itself
+ zle -la "$self_insert_function" || zle -N "$self_insert_function"
+
+ zstyle ':git-escape-magic' self-insert-function "$self_insert_function"
+
+ zle -A git-escape-magic.self-insert self-insert
+ return 0
+}
+
+git-escape-magic.off() {
+ emulate -L zsh
+ local self_insert_function
+ zstyle -s ':git-escape-magic' self-insert-function self_insert_function
+
+ [[ -n "$self_insert_function" ]] &&
+ zle -A "$self_insert_function" self-insert
+ return 0
+}
+
+zle -N git-escape-magic.self-insert
+zle -N git-escape-magic.on
+zle -N git-escape-magic.off
+
+git-escape-magic() {
+ git-escape-magic.on
+}
+
+[[ -o kshautoload ]] || git-escape-magic "$@"
+
diff --git a/plugins/git-escape-magic/git-escape-magic.plugin.zsh b/plugins/git-escape-magic/git-escape-magic.plugin.zsh
new file mode 100644
index 000000000..c021ea707
--- /dev/null
+++ b/plugins/git-escape-magic/git-escape-magic.plugin.zsh
@@ -0,0 +1,9 @@
+# Automatically detect and escape zsh globbing meta-characters when used with
+# git refspec characters like `[^~{}]`. NOTE: This must be loaded _after_
+# url-quote-magic.
+#
+# This trick is detailed at https://github.com/knu/zsh-git-escape-magic and is
+# what allowed this plugin to exist.
+
+autoload -Uz git-escape-magic
+git-escape-magic
diff --git a/plugins/git-extras/README.md b/plugins/git-extras/README.md
index 987f0d800..2adc9d477 100644
--- a/plugins/git-extras/README.md
+++ b/plugins/git-extras/README.md
@@ -2,10 +2,16 @@
This plugin provides completion definitions for some of the commands defined by [git-extras](https://github.com/tj/git-extras).
-## Setup notes
+To use it, add `git-extras` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... git-extras)
+```
+
+## Setup notes
The completions work by augmenting the `_git` completion provided by `zsh`. This only works with the `zsh`-provided `_git`, not the `_git` provided by `git` itself. If you have both `zsh` and `git` installed, you need to make sure that the `zsh`-provided `_git` takes precedence.
### OS X Homebrew Setup
-On OS X with Homebrew, you need to install `git` with `brew install git --without-completions`. Otherwise, `git`'s `_git` will take precedence, and you won't see the completions for `git-extras` commands.
+**NOTE:** this no longer works on current Homebrew distributions of git. ~~On OS X with Homebrew, you need to install `git` with `brew install git --without-completions`. Otherwise, `git`'s `_git` will take precedence, and you won't see the completions for `git-extras` commands.~~
diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh
index ef6c35988..b86d7c5b6 100644
--- a/plugins/git-extras/git-extras.plugin.zsh
+++ b/plugins/git-extras/git-extras.plugin.zsh
@@ -454,9 +454,9 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
extras:'awesome git utilities' \
feature:'create/merge feature branch' \
force-clone:'overwrite local repositories with clone' \
- fork:'fork a repo on github' \
+ fork:'fork a repo on GitHub' \
fresh-branch:'create fresh branches' \
- gh-pages:'create the github pages branch' \
+ gh-pages:'create the GitHub pages branch' \
graft:'merge and destroy a given branch' \
guilt:'calculate change between two revisions' \
ignore-io:'get sample gitignore file' \
diff --git a/plugins/git-flow/README.md b/plugins/git-flow/README.md
index 5d8049e3b..9c25dec83 100644
--- a/plugins/git-flow/README.md
+++ b/plugins/git-flow/README.md
@@ -1,18 +1,15 @@
# Git-Flow plugin
-This plugin adds completion and aliases for the `git-flow` command. More information
-at https://github.com/nvie/gitflow.
+This plugin adds completion and aliases for the [`git-flow` command](https://github.com/nvie/gitflow).
-Enable git-flow plugin in your zshrc file:
-```
+To use it, add `git-flow` to the plugins array in your zshrc file:
+
+```zsh
plugins=(... git-flow)
```
## Aliases
-More information about `git-flow` commands:
-https://github.com/nvie/gitflow/wiki/Command-Line-Arguments
-
| Alias | Command | Description |
|---------|----------------------------|----------------------------------------|
| `gfl` | `git flow` | Git-Flow command |
@@ -30,3 +27,5 @@ https://github.com/nvie/gitflow/wiki/Command-Line-Arguments
| `gflfp` | `git flow feature publish` | Publish feature: `gflfp <name>` |
| `gflhf` | `git flow hotfix finish` | Finish hotfix: `gflhf <version>` |
| `gflrf` | `git flow release finish` | Finish release: `gflrf <version>` |
+
+[More information about `git-flow` commands](https://github.com/nvie/gitflow/wiki/Command-Line-Arguments).
diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh
index eab969d8a..916cd5693 100644
--- a/plugins/git-flow/git-flow.plugin.zsh
+++ b/plugins/git-flow/git-flow.plugin.zsh
@@ -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-hubflow/git-hubflow.plugin.zsh b/plugins/git-hubflow/git-hubflow.plugin.zsh
index 05479f7e6..50d7b23ce 100644
--- a/plugins/git-hubflow/git-hubflow.plugin.zsh
+++ b/plugins/git-hubflow/git-hubflow.plugin.zsh
@@ -75,8 +75,8 @@ __git-hf-release ()
'finish:Finish a release branch.'
'list:List all your release branches. (Alias to `git hf release`)'
'cancel:Cancel release'
- 'push:Push release to github'
- 'pull:Pull release from github'
+ 'push:Push release to GitHub'
+ 'pull:Pull release from GitHub'
'track:Track release'
)
_describe -t commands 'git hf release' subcommands
@@ -133,8 +133,8 @@ __git-hf-hotfix ()
'list:List all your hotfix branches. (Alias to `git hf hotfix`)'
'publish:Publish the hotfix branch.'
'track:Track the hotfix branch.'
- 'pull:Pull the hotfix from github.'
- 'push:Push the hotfix to github.'
+ 'pull:Pull the hotfix from GitHub.'
+ 'push:Push the hotfix to GitHub.'
'cancel:Cancel the hotfix.'
)
_describe -t commands 'git hf hotfix' subcommands
@@ -195,8 +195,8 @@ __git-hf-feature ()
'diff:Diff'
'rebase:Rebase feature branch against develop'
'checkout:Checkout feature'
- 'pull:Pull feature branch from github'
- 'push:Push feature branch to github'
+ 'pull:Pull feature branch from GitHub'
+ 'push:Push feature branch to GitHub'
'cancel:Cancel feature'
)
_describe -t commands 'git hf feature' subcommands
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
new file mode 100644
index 000000000..c6610fa94
--- /dev/null
+++ b/plugins/git-prompt/README.md
@@ -0,0 +1,66 @@
+# git-prompt plugin
+
+A `zsh` prompt that displays information about the current git repository. In particular:
+the branch name, difference with remote branch, number of files staged or changed, etc.
+
+To use it, add `git-prompt` to the plugins array in your zshrc file:
+
+```zsh
+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:
+
+- `(master↑3|✚1)`: on branch `master`, ahead of remote by 3 commits, 1 file changed but not staged
+- `(status|●2)`: on branch `status`, 2 files staged
+- `(master|✚7…)`: on branch `master`, 7 files changed, some files untracked
+- `(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
+
+By default, the general appearance of the prompt is:
+
+```
+(<branch><branch tracking>|<local status>)
+```
+
+The symbols are as follows:
+
+### Local Status Symbols
+
+| Symbol | Meaning |
+|--------|--------------------------------|
+| ✔ | repository clean |
+| ●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
+
+| Symbol | Meaning |
+|--------|---------------------------------------------------------------|
+| ↑n | ahead of remote by `n` commits |
+| ↓n | behind remote by `n` commits |
+| ↓m↑n | branches diverged: other by `m` commits, yours by `n` commits |
+
+## Customisation
+
+- Set the variable `ZSH_THEME_GIT_PROMPT_CACHE` to any value in order to enable caching.
+- You may also change a number of variables (whose name start with `ZSH_THEME_GIT_PROMPT_`)
+ to change the appearance of the prompt. Take a look at the bottom of the [plugin file](git-prompt.plugin.zsh)`
+ to see what variables are available.
+
+
+**Enjoy!**
diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh
index 2776f297f..a4c952471 100644
--- a/plugins/git-prompt/git-prompt.plugin.zsh
+++ b/plugins/git-prompt/git-prompt.plugin.zsh
@@ -1,6 +1,3 @@
-# ZSH Git Prompt Plugin from:
-# https://github.com/olivierverdier/zsh-git-prompt
-
__GIT_PROMPT_DIR="${0:A:h}"
## Hook function definitions
@@ -23,9 +20,10 @@ function precmd_update_git_vars() {
fi
}
-chpwd_functions+=(chpwd_update_git_vars)
-precmd_functions+=(precmd_update_git_vars)
-preexec_functions+=(preexec_update_git_vars)
+autoload -U add-zsh-hook
+add-zsh-hook chpwd chpwd_update_git_vars
+add-zsh-hook precmd precmd_update_git_vars
+add-zsh-hook preexec preexec_update_git_vars
## Function definitions
@@ -42,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() {
@@ -65,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_STASHED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STASHED$GIT_STASHED%{${reset_color}%}"
fi
- if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then
+ if [ "$GIT_CLEAN" -eq "1" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
@@ -85,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 a4d07cde6..786274a71 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -1,36 +1,44 @@
#!/usr/bin/env python
from __future__ import print_function
+import os
import sys
import re
-import shlex
from subprocess import Popen, PIPE, check_output
def get_tagname_or_hash():
"""return tagname if exists else hash"""
- cmd = 'git log -1 --format="%h%d"'
- output = check_output(shlex.split(cmd)).decode('utf-8').strip()
- hash_, tagname = None, None
# get hash
- m = re.search('\(.*\)$', output)
- if m:
- hash_ = output[:m.start()-1]
+ hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
+ hash_ = check_output(hash_cmd).decode('utf-8').strip()
+
# get tagname
- m = re.search('tag: .*[,\)]', output)
- if m:
- tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
+ tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
+ tags = check_output(tags_cmd).decode('utf-8').split()
- if tagname:
- return tagname.replace(' ', '')
+ if tags:
+ return tags[0] + ('+' if len(tags) > 1 else '')
elif 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
-po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE)
+po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE)
stdout, sterr = po.communicate()
if po.returncode != 0:
sys.exit(0) # Not a git repository
@@ -72,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),
@@ -80,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-remote-branch/git-remote-branch.plugin.zsh b/plugins/git-remote-branch/git-remote-branch.plugin.zsh
deleted file mode 100644
index 6c5ab8f70..000000000
--- a/plugins/git-remote-branch/git-remote-branch.plugin.zsh
+++ /dev/null
@@ -1,19 +0,0 @@
-_git_remote_branch() {
- ref=$(git symbolic-ref HEAD 2> /dev/null)
- if [[ -n $ref ]]; then
- if (( CURRENT == 2 )); then
- # first arg: operation
- compadd create publish rename delete track
- elif (( CURRENT == 3 )); then
- # second arg: remote branch name
- remotes=`git remote | tr '\n' '|' | sed "s/\|$//g"`
- compadd `git branch -r | grep -v HEAD | sed "s/$remotes\///" | sed "s/ //g"`
- elif (( CURRENT == 4 )); then
- # third arg: remote name
- compadd `git remote`
- fi
- else;
- _files
- fi
-}
-compdef _git_remote_branch grb
diff --git a/plugins/git/README.md b/plugins/git/README.md
index 76da2a8ae..93c9cc915 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -1,10 +1,238 @@
-## git
+# git plugin
-**Maintainer:** [@ncanceill](https://github.com/ncanceill)
+The git plugin provides many [aliases](#aliases) and a few useful [functions](#functions).
-This plugin adds many useful aliases and functions.
+To use it, add `git` to the plugins array in your zshrc file:
-### Usage
+```zsh
+plugins=(... git)
+```
-See the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git) for a list of aliases and functions provided by the plugin.
+## Aliases
+| Alias | Command |
+|:---------------------|:---------------------------------------------------------------------------------------------------------------------------------|
+| g | git |
+| ga | git add |
+| gaa | git add --all |
+| gapa | git add --patch |
+| gau | git add --update |
+| gav | git add --verbose |
+| gap | git apply |
+| gapt | git apply --3way |
+| gb | git branch |
+| gba | git branch -a |
+| gbd | git branch -d |
+| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d |
+| gbD | git branch -D |
+| gbl | git blame -b -w |
+| gbnm | git branch --no-merged |
+| gbr | git branch --remote |
+| gbs | git bisect |
+| gbsb | git bisect bad |
+| gbsg | git bisect good |
+| gbsr | git bisect reset |
+| gbss | git bisect start |
+| gc | git commit -v |
+| gc! | git commit -v --amend |
+| gcn! | git commit -v --no-edit --amend |
+| gca | git commit -v -a |
+| gca! | git commit -v -a --amend |
+| 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 |
+| gclean | git clean -id |
+| gpristine | git reset --hard && git clean -dffx |
+| gcm | git checkout $(git_main_branch) |
+| gcd | git checkout develop |
+| gcmsg | git commit -m |
+| gco | git checkout |
+| gcount | git shortlog -sn |
+| gcp | git cherry-pick |
+| gcpa | git cherry-pick --abort |
+| gcpc | git cherry-pick --continue |
+| gcs | git commit -S |
+| gd | git diff |
+| gdca | git diff --cached |
+| gdcw | git diff --cached --word-diff |
+| gdct | git describe --tags $(git rev-list --tags --max-count=1) |
+| gds | git diff --staged |
+| gdt | git diff-tree --no-commit-id --name-only -r |
+| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)&ast;.lock" |
+| gdv | git diff -w $@ \| view - |
+| gdw | git diff --word-diff |
+| gf | git fetch |
+| gfa | git fetch --all --prune |
+| gfg | git ls-files \| grep |
+| gfo | git fetch origin |
+| gg | git gui citool |
+| gga | git gui citool --amend |
+| ggf | git push --force origin $(current_branch) |
+| ggfl | git push --force-with-lease origin $(current_branch) |
+| ggl | git pull origin $(current_branch) |
+| ggp | git push origin $(current_branch) |
+| ggpnp | ggl && ggp |
+| ggpull | git pull origin "$(git_current_branch)" |
+| ggpur | ggu |
+| ggpush | git push origin "$(git_current_branch)" |
+| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
+| ggu | git pull --rebase origin $(current_branch) |
+| gpsup | git push --set-upstream origin $(git_current_branch) |
+| 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 $(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 |
+| glgg | git log --graph |
+| 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 |
+| 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 |
+| glog | git log --oneline --decorate --graph |
+| gloga | git log --oneline --decorate --graph --all |
+| glp | git log --pretty=\<format\> |
+| gm | git merge |
+| gmom | git merge origin/$(git_main_branch) |
+| gmt | git mergetool --no-prompt |
+| gmtvim | 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 |
+| gra | git remote add |
+| grb | git rebase |
+| grba | git rebase --abort |
+| grbc | git rebase --continue |
+| grbd | git rebase develop |
+| grbi | git rebase -i |
+| grbm | git rebase $(git_main_branch) |
+| grbo | git rebase --onto |
+| grbs | git rebase --skip |
+| grev | git revert |
+| grh | git reset |
+| grhh | git reset --hard |
+| groh | git reset origin/$(git_current_branch) --hard |
+| grm | git rm |
+| grmc | git rm --cached |
+| grmv | git remote rename |
+| grrm | git remote remove |
+| 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 |
+| grv | git remote -v |
+| gsb | git status -sb |
+| gsd | git svn dcommit |
+| gsh | git show |
+| gsi | git submodule init |
+| gsps | git show --pretty=short --show-signature |
+| gsr | git svn rebase |
+| gss | git status -s |
+| gst | git status |
+| gsta | git stash push |
+| gsta | git stash save |
+| gstaa | git stash apply |
+| gstc | git stash clear |
+| gstd | git stash drop |
+| gstl | git stash list |
+| gstp | git stash pop |
+| gsts | git stash show --text |
+| gstu | git stash --include-untracked |
+| gstall | git stash --all |
+| gsu | git submodule update |
+| gsw | git switch |
+| gswc | git switch -c |
+| gts | git tag -s |
+| gtv | git tag \| sort -V |
+| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
+| gunignore | git update-index --no-assume-unchanged |
+| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 |
+| gup | git pull --rebase |
+| gupv | git pull --rebase -v |
+| gupa | git pull --rebase --autostash |
+| gupav | git pull --rebase --autostash -v |
+| 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 |
+| gamc | git am --continue |
+| gams | git am --skip |
+| 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.
+
+| Alias | Command | Modification |
+| :----- | :----------------------------------------------------- | :----------------------------------------------------- |
+| gap | `git add --patch` | new alias `gapa` |
+| gcl | `git config --list` | new alias `gcf` |
+| gdc | `git diff --cached` | new alias `gdca` |
+| gdt | `git difftool` | no replacement |
+| ggpull | `git pull origin $(current_branch)` | new alias `ggl` (`ggpull` still exists for now though) |
+| ggpur | `git pull --rebase origin $(current_branch)` | new alias `ggu` (`ggpur` still exists for now though) |
+| ggpush | `git push origin $(current_branch)` | new alias `ggp` (`ggpush` still exists for now though) |
+| gk | `gitk --all --branches` | now aliased to `gitk --all --branches` |
+| glg | `git log --stat --max-count = 10` | now aliased to `git log --stat --color` |
+| glgg | `git log --graph --max-count = 10` | now aliased to `git log --graph --color` |
+| gwc | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch` |
+
+## Functions
+
+### 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 |
+| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
+
+### Work in Progress (WIP)
+
+These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it.
+
+| Command | Description |
+|:-----------------|:------------------------------------------------|
+| work_in_progress | Echoes a warning if the current branch is a wip |
+| gwip | Commit wip branch |
+| gunwip | Uncommit wip branch |
+
+### Deprecated functions
+
+| Command | Description | Reason |
+|:-----------------------|:----------------------------------------|:----------------------------------------------------------------|
+| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) |
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 45a706173..a364b6162 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -1,6 +1,6 @@
-# Query/use custom command for `git`.
-zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
-: ${_omz_git_git_cmd:=git}
+# Git version checking
+autoload -Uz is-at-least
+git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
#
# Functions
@@ -13,19 +13,15 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
function current_branch() {
git_current_branch
}
-# The list of remotes
-function current_repository() {
- if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
- return
- fi
- echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
-}
+
# Pretty log messages
function _git_log_prettily(){
if ! [ -z $1 ]; then
git log --pretty=$1
fi
}
+compdef _git _git_log_prettily=git-log
+
# Warn if the current branch is a WIP
function work_in_progress() {
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
@@ -33,6 +29,19 @@ 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 branch
+ for branch in main trunk; do
+ if command git show-ref -q --verify refs/heads/$branch; then
+ echo $branch
+ return
+ fi
+ done
+ echo master
+}
+
#
# Aliases
# (sorted alphabetically)
@@ -46,11 +55,12 @@ alias gapa='git add --patch'
alias gau='git add --update'
alias gav='git add --verbose'
alias gap='git apply'
+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|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
+alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbD='git branch -D'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
@@ -70,17 +80,18 @@ 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'
alias gcl='git clone --recurse-submodules'
-alias gclean='git clean -fd'
-alias gpristine='git reset --hard && git clean -dfx'
-alias gcm='git checkout master'
+alias gclean='git clean -id'
+alias gpristine='git reset --hard && git clean -dffx'
+alias gcm='git checkout $(git_main_branch)'
alias gcd='git checkout develop'
alias gcmsg='git commit -m'
alias gco='git checkout'
alias gcount='git shortlog -sn'
-compdef _git gcount
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
@@ -89,35 +100,43 @@ alias gcs='git commit -S'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
-alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
+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 gdw='git diff --word-diff'
-gdv() { git diff -w "$@" | view - }
+function gdnolock() {
+ git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
+}
+compdef _git gdnolock=git-diff
+
+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'
-function gfg() { git ls-files | grep $@ }
-compdef _grep gfg
+alias gfg='git ls-files | grep'
alias gg='git gui citool'
alias gga='git gui citool --amend'
-ggf() {
+function ggf() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}"
}
-ggfl() {
-[[ "$#" != 1 ]] && local b="$(git_current_branch)"
-git push --force-with-lease origin "${b:=$1}"
-}
compdef _git ggf=git-checkout
+function ggfl() {
+ [[ "$#" != 1 ]] && local b="$(git_current_branch)"
+ git push --force-with-lease origin "${b:=$1}"
+}
+compdef _git ggfl=git-checkout
-ggl() {
+function ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
@@ -127,7 +146,7 @@ ggl() {
}
compdef _git ggl=git-checkout
-ggp() {
+function ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
@@ -137,7 +156,7 @@ ggp() {
}
compdef _git ggp=git-checkout
-ggpnp() {
+function ggpnp() {
if [[ "$#" == 0 ]]; then
ggl && ggp
else
@@ -146,20 +165,15 @@ ggpnp() {
}
compdef _git ggpnp=git-checkout
-ggu() {
+function ggu() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}"
}
compdef _git ggu=git-checkout
alias ggpur='ggu'
-compdef _git ggpur=git-checkout
-
-alias ggpull='git pull origin $(git_current_branch)'
-compdef _git ggpull=git-checkout
-
-alias ggpush='git push origin $(git_current_branch)'
-compdef _git ggpush=git-checkout
+alias ggpull='git pull origin "$(git_current_branch)"'
+alias ggpush='git push origin "$(git_current_branch)"'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gpsup='git push --set-upstream origin $(git_current_branch)'
@@ -168,13 +182,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'
-compdef _git git-svn-dcommit-push=git
+alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
alias gk='\gitk --all --branches'
-compdef _git gk='gitk'
alias gke='\gitk --all $(git log -g --pretty=%h)'
-compdef _git gke='gitk'
alias gl='git pull'
alias glg='git log --stat'
@@ -191,13 +202,12 @@ alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgr
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily"
-compdef _git glp=git-log
alias gm='git merge'
-alias gmom='git merge origin/master'
+alias gmom='git merge origin/$(git_main_branch)'
alias gmt='git mergetool --no-prompt'
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
-alias gmum='git merge upstream/master'
+alias gmum='git merge upstream/$(git_main_branch)'
alias gma='git merge --abort'
alias gp='git push'
@@ -205,7 +215,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'
-compdef _git gpoat=git-push
+alias gpr='git pull --rebase'
alias gpu='git push upstream'
alias gpv='git push -v'
@@ -216,16 +226,22 @@ alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbd='git rebase develop'
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'
alias grhh='git reset --hard'
+alias groh='git reset origin/$(git_current_branch) --hard'
alias grm='git rm'
alias grmc='git rm --cached'
alias grmv='git remote rename'
alias grrm='git remote remove'
+alias grs='git restore'
alias grset='git remote set-url'
-alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
+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'
alias grv='git remote -v'
@@ -238,18 +254,27 @@ alias gsps='git show --pretty=short --show-signature'
alias gsr='git svn rebase'
alias gss='git status -s'
alias gst='git status'
-alias gsta='git stash save'
+
+# use the default stash push on git 2.13 and newer
+is-at-least 2.13 "$git_version" \
+ && alias gsta='git stash push' \
+ || alias gsta='git stash save'
+
alias gstaa='git stash apply'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'
+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 gts='git tag -s'
alias gtv='git tag | sort -V'
+alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl'
alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
@@ -257,7 +282,29 @@ 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 -m "--wip-- [skip ci]"'
+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]"'
+
+alias gam='git am'
+alias gamc='git am --continue'
+alias gams='git am --skip'
+alias gama='git am --abort'
+alias gamscp='git am --show-current-patch'
+
+function grename() {
+ if [[ -z "$1" || -z "$2" ]]; then
+ echo "Usage: $0 old_branch new_branch"
+ return 1
+ fi
+
+ # Rename branch locally
+ git branch -m "$1" "$2"
+ # Rename branch in origin remote
+ if git push origin :"$1"; then
+ git push --set-upstream origin "$2"
+ fi
+}
+
+unset git_version
diff --git a/plugins/gitfast/README.md b/plugins/gitfast/README.md
index c3073709e..fed4b120a 100644
--- a/plugins/gitfast/README.md
+++ b/plugins/gitfast/README.md
@@ -1,6 +1,6 @@
# Gitfast plugin
-This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version..
+This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version.
To use it, add `gitfast` to the plugins array in your zshrc file:
@@ -10,129 +10,6 @@ plugins=(... gitfast)
## Aliases
-| Alias | Command |
-| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
-| g | `git` |
-| ga | `git add` |
-| gaa | `git add --all` |
-| gapa | `git add --patch` |
-| gau | `git add --update` |
-| gb | `git branch` |
-| gba | `git branch -a` |
-| gbd | `git branch -d` |
-| gbda | `git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d` |
-| gbl | `git blame -b -w` |
-| gbnm | `git branch --no-merged` |
-| gbr | `git branch --remote` |
-| gbs | `git bisect` |
-| gbsb | `git bisect bad` |
-| gbsg | `git bisect good` |
-| gbsr | `git bisect reset` |
-| gbss | `git bisect start` |
-| gc | `git commit -v` |
-| gc! | `git commit -v --amend` |
-| gca | `git commit -v -a` |
-| gca! | `git commit -v -a --amend` |
-| gcam | `git commit -a -m` |
-| gcan! | `git commit -v -a --no-edit --amend` |
-| gcans! | `git commit -v -a -s --no-edit --amend` |
-| gcb | `git checkout -b` |
-| gcd | `git checkout develop` |
-| gcf | `git config --list` |
-| gcl | `git clone --recursive` |
-| gclean | `git clean -fd` |
-| gcm | `git checkout master` |
-| gcmsg | `git commit -m` |
-| gcn! | `git commit -v --no-edit --amend` |
-| gco | `git checkout` |
-| gcount | `git shortlog -sn` |
-| gcp | `git cherry-pick` |
-| gcpa | `git cherry-pick --abort` |
-| gcpc | `git cherry-pick --continue` |
-| gcs | `git commit -S` |
-| gcsm | `git commit -s -m` |
-| gd | `git diff` |
-| gdca | `git diff --cached` |
-| gdct | `` git describe --tags `git rev-list --tags --max-count=1` `` |
-| gdt | `git diff-tree --no-commit-id --name-only -r` |
-| gdw | `git diff --word-diff` |
-| gf | `git fetch` |
-| gfa | `git fetch --all --prune` |
-| gfo | `git fetch origin` |
-| gg | `git gui citool` |
-| gga | `git gui citool --amend` |
-| ggpull | `git pull origin $(git_current_branch)` |
-| ggpur | `ggu` |
-| ggpush | `git push origin $(git_current_branch)` |
-| ggsup | `git branch --set-upstream-to=origin/$(git_current_branch)` |
-| 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)` |
-| gl | `git pull` |
-| glg | `git log --stat` |
-| glgg | `git log --graph` |
-| glgga | `git log --graph --decorate --all` |
-| glgm | `git log --graph --max-count=10` |
-| glgp | `git log --stat -p` |
-| glo | `git log --oneline --decorate` |
-| glog | `git log --oneline --decorate --graph` |
-| gloga | `git log --oneline --decorate --graph --all` |
-| glol | `git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit` |
-| glola | `git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --all` |
-| glp | `_git_log_prettily` |
-| glum | `git pull upstream master` |
-| 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` |
-| gp | `git push` |
-| gpd | `git push --dry-run` |
-| gpoat | `git push origin --all && git push origin --tags` |
-| gpristine | `git reset --hard && git clean -dfx` |
-| gpsup | `git push --set-upstream origin $(git_current_branch)` |
-| gpu | `git push upstream` |
-| gpv | `git push -v` |
-| gr | `git remote` |
-| gra | `git remote add` |
-| grb | `git rebase` |
-| grba | `git rebase --abort` |
-| grbc | `git rebase --continue` |
-| grbi | `git rebase -i` |
-| grbm | `git rebase master` |
-| grbs | `git rebase --skip` |
-| grh | `git reset HEAD` |
-| grhh | `git reset HEAD --hard` |
-| grmv | `git remote rename` |
-| grrm | `git remote remove` |
-| grset | `git remote set-url` |
-| grt | `cd $(git rev-parse --show-toplevel || echo ".")` |
-| gru | `git reset --` |
-| grup | `git remote update` |
-| grv | `git remote -v` |
-| gsb | `git status -sb` |
-| gsd | `git svn dcommit` |
-| gsi | `git submodule init` |
-| gsps | `git show --pretty=short --show-signature` |
-| gsr | `git svn rebase` |
-| gss | `git status -s` |
-| gst | `git status` |
-| gsta | `git stash save` |
-| gstaa | `git stash apply` |
-| gstc | `git stash clear` |
-| gstd | `git stash drop` |
-| gstl | `git stash list` |
-| gstp | `git stash pop` |
-| gsts | `git stash show --text` |
-| gsu | `git submodule update` |
-| gts | `git tag -s` |
-| gtv | `git tag | sort -V` |
-| gunignore | `git update-index --no-assume-unchanged` |
-| gunwip | `git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1` |
-| gup | `git pull --rebase` |
-| gupv | `git pull --rebase -v` |
-| 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 -m "--wip-- [skip ci]"` |
+An earlier version of the plugin also loaded the git plugin. If you want to keep those
+aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
+as well.
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
index 6d1b4ecc7..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.sh
+# 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,50 +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_nl ()
{
emulate -L zsh
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+ IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
}
-__gitcomp_nl_append ()
+__gitcomp_file ()
{
emulate -L zsh
- local IFS=$'\n'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+ compadd -f -p "${2-}" -- ${(f)1} && _ret=0
}
-__gitcomp_file ()
+__gitcomp_direct ()
+{
+ __gitcomp_nl "$1" "" "" ""
+}
+
+__gitcomp_file_direct ()
+{
+ __gitcomp_file "$1" ""
+}
+
+__gitcomp_nl_append ()
+{
+ __gitcomp_nl "$@"
+}
+
+__gitcomp_direct_append ()
+{
+ __gitcomp_direct "$@"
+}
+
+_git_zsh ()
+{
+ __gitcomp "v1.2"
+}
+
+__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 ()
@@ -99,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
}
@@ -131,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
}
@@ -141,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 ()
@@ -157,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
@@ -191,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[@]} )
@@ -218,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 8ce6b5c5f..4497a294f 100644
--- a/plugins/gitfast/git-completion.bash
+++ b/plugins/gitfast/git-completion.bash
@@ -28,27 +28,58 @@
# completion style. For example '!f() { : git commit ; ... }; f' will
# 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
+# 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').
-case "$COMP_WORDBREAKS" in
-*:*) : great ;;
-*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
-esac
+# 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
+ # we already know where it is
+ return
+ fi
+
+ if [ -n "${__git_C_args-}" ]; then
+ __git_repo_path="$(git "${__git_C_args[@]}" \
+ ${__git_dir:+--git-dir="$__git_dir"} \
+ rev-parse --absolute-git-dir 2>/dev/null)"
+ elif [ -n "${__git_dir-}" ]; then
+ test -d "$__git_dir" &&
+ __git_repo_path="$__git_dir"
+ elif [ -n "${GIT_DIR-}" ]; then
+ test -d "${GIT_DIR-}" &&
+ __git_repo_path="$GIT_DIR"
+ elif [ -d .git ]; then
+ __git_repo_path=.git
+ else
+ __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)"
+ fi
+}
+# Deprecated: use __git_find_repo_path() and $__git_repo_path instead
# __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo
__gitdir ()
{
if [ -z "${1-}" ]; then
- if [ -n "${__git_dir-}" ]; then
- echo "$__git_dir"
- elif [ -n "${GIT_DIR-}" ]; then
- test -d "${GIT_DIR-}" || return 1
- echo "$GIT_DIR"
- elif [ -d .git ]; then
- echo .git
- else
- git rev-parse --git-dir 2>/dev/null
- fi
+ __git_find_repo_path || return 1
+ echo "$__git_repo_path"
elif [ -d "$1/.git" ]; then
echo "$1/.git"
else
@@ -56,6 +87,78 @@ __gitdir ()
fi
}
+# Runs git with all the options given as argument, respecting any
+# '--git-dir=<path>' and '-C <path>' options present on the command line
+__git ()
+{
+ git ${__git_C_args:+"${__git_C_args[@]}"} \
+ ${__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+
@@ -75,8 +178,7 @@ __gitdir ()
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# The latest version of this software can be obtained here:
#
@@ -185,6 +287,33 @@ _get_comp_words_by_ref ()
}
fi
+# Fills the COMPREPLY array with prefiltered words without any additional
+# processing.
+# 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 ()
+{
+ local IFS=$'\n'
+
+ 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[@]}
@@ -213,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"
@@ -231,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 ()
@@ -254,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:
@@ -273,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
@@ -283,11 +611,13 @@ __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
- fi 2>/dev/null
+ __git -C "$1" -c core.quotePath=false ls-files \
+ --exclude-standard $2 -- "${3//\\/\\\\}*"
+ fi
}
@@ -297,101 +627,332 @@ __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 dir="$(__gitdir)" root="${2-.}" file
+ local root="$2" match="$3"
- if [ -d "$dir" ]; then
- __git_ls_files_helper "$root" "$1" |
- while read -r file; do
- case "$file" in
- ?*/*) echo "${file%%/*}" ;;
- *) echo "$file" ;;
- esac
- done | sort | uniq
- fi
+ __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.
+# 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_heads ()
{
- local dir="$(__gitdir)"
- if [ -d "$dir" ]; then
- git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
- refs/heads
- return
- fi
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
+ "refs/heads/$cur_*" "refs/heads/$cur_*/**"
}
-__git_tags ()
+# 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 dir="$(__gitdir)"
- if [ -d "$dir" ]; then
- git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
- refs/tags
- return
- fi
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
+ "refs/remotes/$cur_*" "refs/remotes/$cur_*/**"
}
-# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
-# presence of 2nd argument means use the guess heuristic employed
-# by checkout for tracking branches
+# Lists tags from the local repository.
+# Accepts the same positional parameters as __git_heads() above.
+__git_tags ()
+{
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
+ "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).
+# Can be the name of a configured remote, a path, or a URL.
+# 2: In addition to local refs, list unique branches from refs/remotes/ for
+# 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
+# 3: A prefix to be added to each listed ref (optional).
+# 4: List only refs matching this word (optional; list all refs if unset or
+# empty).
+# 5: A suffix to be appended to each listed ref (optional; ignored, if set
+# but empty).
+#
+# Use __git_complete_refs() instead.
__git_refs ()
{
- local i hash dir="$(__gitdir "${1-}")" track="${2-}"
+ local i hash dir track="${2-}"
+ local list_refs_from=path remote="${1-}"
local format refs
- if [ -d "$dir" ]; then
- case "$cur" in
+ local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}"
+ local match="${4-}"
+ local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
+
+ __git_find_repo_path
+ dir="$__git_repo_path"
+
+ if [ -z "$remote" ]; then
+ if [ -z "$dir" ]; then
+ return
+ fi
+ else
+ if __git_is_configured_remote "$remote"; then
+ # configured remote takes precedence over a
+ # local directory with the same name
+ list_refs_from=remote
+ elif [ -d "$remote/.git" ]; then
+ dir="$remote/.git"
+ elif [ -d "$remote" ]; then
+ dir="$remote"
+ else
+ list_refs_from=url
+ fi
+ fi
+
+ if [ "$list_refs_from" = path ]; then
+ if [[ "$cur_" == ^* ]]; then
+ pfx="$pfx^"
+ fer_pfx="$fer_pfx^"
+ cur_=${cur_#^}
+ match=${match#^}
+ fi
+ case "$cur_" in
refs|refs/*)
format="refname"
- refs="${cur%/*}"
+ refs=("$match*" "$match*/**")
track=""
;;
*)
- for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
- if [ -e "$dir/$i" ]; then echo $i; fi
+ for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
+ case "$i" in
+ $match*)
+ if [ -e "$dir/$i" ]; then
+ echo "$pfx$i$sfx"
+ fi
+ ;;
+ esac
done
- format="refname:short"
- refs="refs/tags refs/heads refs/remotes"
+ format="refname:strip=2"
+ refs=("refs/tags/$match*" "refs/tags/$match*/**"
+ "refs/heads/$match*" "refs/heads/$match*/**"
+ "refs/remotes/$match*" "refs/remotes/$match*/**")
;;
esac
- git --git-dir="$dir" for-each-ref --format="%($format)" \
- $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
- local ref entry
- git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
- "refs/remotes/" | \
- while read -r entry; do
- eval "$entry"
- ref="${ref#*/}"
- if [[ "$ref" == "$cur"* ]]; then
- echo "$ref"
- fi
- done | sort | uniq -u
+ __git_dwim_remote_heads "$pfx" "$match" "$sfx"
fi
return
fi
- case "$cur" in
+ case "$cur_" in
refs|refs/*)
- git ls-remote "$dir" "$cur*" 2>/dev/null | \
+ __git ls-remote "$remote" "$match*" | \
while read -r hash i; do
case "$i" in
*^{}) ;;
- *) echo "$i" ;;
+ *) echo "$pfx$i$sfx" ;;
esac
done
;;
*)
- echo "HEAD"
- git for-each-ref --format="%(refname:short)" -- \
- "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
+ if [ "$list_refs_from" = remote ]; then
+ case "HEAD" in
+ $match*) echo "${pfx}HEAD$sfx" ;;
+ esac
+ __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
+ "refs/remotes/$remote/$match*" \
+ "refs/remotes/$remote/$match*/**"
+ else
+ local query_symref
+ case "HEAD" in
+ $match*) query_symref="HEAD" ;;
+ esac
+ __git ls-remote "$remote" $query_symref \
+ "refs/tags/$match*" "refs/heads/$match*" \
+ "refs/remotes/$match*" |
+ while read -r hash i; do
+ case "$i" in
+ *^{}) ;;
+ refs/*) echo "$pfx${i#refs/*/}$sfx" ;;
+ *) echo "$pfx$i$sfx" ;; # symbolic refs
+ esac
+ done
+ fi
;;
esac
}
+# Completes refs, short and long, local and remote, symbolic and pseudo.
+#
+# 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.
+# --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= dwim= pfx= cur_="$cur" sfx=" " mode="refs"
+
+ while test $# != 0; do
+ case "$1" in
+ --remote=*) remote="${1##--remote=}" ;;
+ --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
+
+ # 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)
+# Deprecated: use __git_complete_fetch_refspecs() instead.
__git_refs2 ()
{
local i
@@ -400,11 +961,29 @@ __git_refs2 ()
done
}
+# Completes refspecs for fetching from a remote repository.
+# 1: The remote repository.
+# 2: A prefix to be added to each listed refspec (optional).
+# 3: The ref to be completed as a refspec instead of the current word to be
+# completed (optional)
+# 4: A suffix to be appended to each listed refspec instead of the default
+# space (optional).
+__git_complete_fetch_refspecs ()
+{
+ local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }"
+
+ __gitcomp_direct "$(
+ for i in $(__git_refs "$remote" "" "" "$cur_") ; do
+ echo "$pfx$i:$i$sfx"
+ done
+ )"
+}
+
# __git_refs_remotes requires 1 argument (to pass to ls-remote)
__git_refs_remotes ()
{
local i hash
- git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
+ __git ls-remote "$1" 'refs/heads/*' | \
while read -r hash i; do
echo "$i:refs/remotes/$1/${i#refs/heads/}"
done
@@ -412,14 +991,26 @@ __git_refs_remotes ()
__git_remotes ()
{
- local d="$(__gitdir)"
- test -d "$d/remotes" && ls -1 "$d/remotes"
- git --git-dir="$d" remote
+ __git_find_repo_path
+ test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
+ __git remote
+}
+
+# Returns true if $1 matches the name of a configured remote, false otherwise.
+__git_is_configured_remote ()
+{
+ local remote
+ for remote in $(__git_remotes); do
+ if [ "$remote" = "$1" ]; then
+ return 0
+ fi
+ done
+ return 1
}
__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/.*://
@@ -429,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
@@ -438,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
@@ -451,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
@@ -468,56 +1070,25 @@ __git_complete_revlist_file ()
*) pfx="$ref:$pfx" ;;
esac
- __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
- | 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_%...*}..."
cur_="${cur_#*...}"
- __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
;;
*..*)
pfx="${cur_%..*}.."
cur_="${cur_#*..}"
- __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
;;
*)
- __gitcomp_nl "$(__git_refs)"
- ;;
- 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}/"
+ __git_complete_refs
;;
esac
-
- __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
}
__git_complete_file ()
@@ -541,6 +1112,7 @@ __git_complete_remote_or_refspec ()
i="${words[c]}"
case "$i" in
--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
+ -d|--delete) [ "$cmd" = "push" ] && lhs=0 ;;
--all)
case "$cmd" in
push) no_complete_refspec=1 ;;
@@ -550,6 +1122,7 @@ __git_complete_remote_or_refspec ()
*) ;;
esac
;;
+ --multiple) no_complete_refspec=1; break ;;
-*) ;;
*) remote="$i"; break ;;
esac
@@ -580,23 +1153,23 @@ __git_complete_remote_or_refspec ()
case "$cmd" in
fetch)
if [ $lhs = 1 ]; then
- __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
+ __git_complete_fetch_refspecs "$remote" "$pfx" "$cur_"
else
- __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
fi
;;
pull|remote)
if [ $lhs = 1 ]; then
- __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
+ __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
else
- __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
fi
;;
push)
if [ $lhs = 1 ]; then
- __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
else
- __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
+ __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
fi
;;
esac
@@ -609,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,
@@ -746,7 +1213,7 @@ __git_compute_porcelain_commands ()
__git_get_config_variables ()
{
local section="$1" i IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do
+ for i in $(__git config --name-only --get-regexp "^$section\..*"); do
echo "${i#$section.}"
done
}
@@ -756,46 +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 --git-dir="$(__gitdir)" \
- 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
@@ -803,6 +1299,84 @@ __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
+# $2: long option name including =
+# $3: list of possible values
+# $4: config string (optional)
+#
+# example:
+# result="$(__git_get_option_value "-d" "--do-something=" \
+# "yes no" "core.doSomething")"
+#
+# result is then either empty (no option set) or "yes" or "no"
+#
+# __git_get_option_value requires 3 arguments
+__git_get_option_value ()
+{
+ local c short_opt long_opt val
+ local result= values config_key word
+
+ short_opt="$1"
+ long_opt="$2"
+ values="$3"
+ config_key="$4"
+
+ ((c = $cword - 1))
+ while [ $c -ge 0 ]; do
+ word="${words[c]}"
+ for val in $values; do
+ if [ "$short_opt$val" = "$word" ] ||
+ [ "$long_opt$val" = "$word" ]; then
+ result="$val"
+ break 2
+ fi
+ done
+ ((c--))
+ done
+
+ if [ -n "$config_key" ] && [ -z "$result" ]; then
+ result="$(__git config "$config_key")"
+ fi
+
+ echo "$result"
+}
+
__git_has_doubledash ()
{
local c=1
@@ -853,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 ()
{
- local dir="$(__gitdir)"
- if [ -d "$dir"/rebase-apply ]; then
- __gitcomp "--skip --continue --resolved --abort"
+ __git_find_repo_path
+ if [ -d "$__git_repo_path"/rebase-apply ]; then
+ __gitcomp "$__git_am_inprogress_options"
return
fi
case "$cur" in
@@ -866,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
}
@@ -885,13 +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
- "
+ __gitcomp_builtin apply
return
esac
}
@@ -899,16 +1474,21 @@ _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
- "
+ __gitcomp_builtin add
return
esac
- # XXX should we check for --update and --all options ?
- __git_complete_index_file "--others --modified --directory --no-empty-directory"
+ local complete_opt="--others --modified --directory --no-empty-directory"
+ if test -n "$(__git_find_on_cmdline "-u --update")"
+ then
+ complete_opt="--modified"
+ fi
+ __git_complete_index_file "$complete_opt"
}
_git_archive ()
@@ -923,10 +1503,7 @@ _git_archive ()
return
;;
--*)
- __gitcomp "
- --format= --list --verbose
- --prefix= --remote= --exec=
- "
+ __gitcomp_builtin archive "--format= --list --verbose --prefix= --worktree-attributes"
return
;;
esac
@@ -940,7 +1517,8 @@ _git_bisect ()
local subcommands="start bad good skip reset visualize replay log run"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
- if [ -f "$(__gitdir)"/BISECT_START ]; then
+ __git_find_repo_path
+ if [ -f "$__git_repo_path"/BISECT_START ]; then
__gitcomp "$subcommands"
else
__gitcomp "replay start"
@@ -950,13 +1528,15 @@ _git_bisect ()
case "$subcommand" in
bad|good|reset|skip|start)
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
;;
*)
;;
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"
@@ -964,29 +1544,24 @@ _git_branch ()
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- -d|-m) only_local_ref="y" ;;
- -r) has_r="y" ;;
+ -d|--delete|-m|--move) only_local_ref="y" ;;
+ -r|--remotes) has_r="y" ;;
esac
((c++))
done
case "$cur" in
--set-upstream-to=*)
- __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}"
+ __git_complete_refs --cur="${cur##--set-upstream-to=}"
;;
--*)
- __gitcomp "
- --color --no-color --verbose --abbrev= --no-abbrev
- --track --no-track --contains --merged --no-merged
- --set-upstream-to= --edit-description --list
- --unset-upstream
- "
+ __gitcomp_builtin branch
;;
*)
if [ $only_local_ref = "y" -a $has_r = "n" ]; then
- __gitcomp_nl "$(__git_heads)"
+ __gitcomp_direct "$(__git_heads "" "$cur" " ")"
else
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
fi
;;
esac
@@ -1012,50 +1587,114 @@ _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
- "
+ __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=1
- if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
- track=''
+ # 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
- __gitcomp_nl "$(__git_refs '' $track)"
;;
esac
}
-_git_cherry ()
-{
- __gitcomp_nl "$(__git_refs)"
-}
+__git_sequencer_inprogress_options="--continue --quit --abort --skip"
+
+__git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
_git_cherry_pick ()
{
- local dir="$(__gitdir)"
- if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
- __gitcomp "--continue --quit --abort"
+ __git_find_repo_path
+ if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
+ __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"
;;
*)
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
;;
esac
}
@@ -1064,7 +1703,7 @@ _git_clean ()
{
case "$cur" in
--*)
- __gitcomp "--dry-run --quiet"
+ __gitcomp_builtin clean
return
;;
esac
@@ -1075,34 +1714,32 @@ _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
- --branch
- "
+ __gitcomp_builtin clone
return
;;
esac
}
+__git_untracked_file_modes="all no normal"
+
_git_commit ()
{
case "$prev" in
-c|-C)
- __gitcomp_nl "$(__git_refs)" "" "${cur}"
+ __git_complete_refs
return
;;
esac
@@ -1115,27 +1752,19 @@ _git_commit ()
;;
--reuse-message=*|--reedit-message=*|\
--fixup=*|--squash=*)
- __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
+ __git_complete_refs --cur="${cur#*=}"
return
;;
--untracked-files=*)
- __gitcomp "all no normal" "" "${cur##--untracked-files=}"
+ __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
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=
- "
+ __gitcomp_builtin commit
return
esac
- if git rev-parse --verify --quiet HEAD >/dev/null; then
+ if __git rev-parse --verify --quiet HEAD >/dev/null; then
__git_complete_index_file "--committable"
else
# This is the first commit
@@ -1147,22 +1776,28 @@ _git_describe ()
{
case "$cur" in
--*)
- __gitcomp "
- --all --tags --contains --abbrev= --candidates=
- --exact-match --debug --long --match --always
- "
+ __gitcomp_builtin describe
return
esac
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
}
__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
+ --find-copies-harder --ignore-cr-at-eol
--text --ignore-space-at-eol --ignore-space-change
--ignore-all-space --ignore-blank-lines --exit-code
--quiet --ext-diff --no-ext-diff
@@ -1173,6 +1808,9 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative
--diff-algorithm=
+ --submodule --submodule= --ignore-submodules
+ --indent-heuristic --no-indent-heuristic
+ --textconv --no-textconv
"
_git_diff ()
@@ -1184,6 +1822,18 @@ _git_diff ()
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
return
;;
+ --submodule=*)
+ __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
@@ -1196,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 ()
@@ -1209,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
@@ -1222,11 +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=
-"
-
_git_fetch ()
{
case "$cur" in
@@ -1234,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 ()
@@ -1260,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
- "
+ __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
@@ -1296,8 +1933,43 @@ _git_gitk ()
_gitk
}
-__git_match_ctag() {
- awk "/^${1//\//\\/}/ { print \$1 }" "$2"
+# Lists matching symbol names from a tag (as in ctags) file.
+# 1: List symbol names matching this word.
+# 2: The tag file to list symbol names from.
+# 3: A prefix to be added to each listed symbol name (optional).
+# 4: A suffix to be appended to each listed symbol name (optional).
+__git_match_ctag () {
+ awk -v pfx="${3-}" -v sfx="${4-}" "
+ /^${1//\//\\/}/ { print pfx \$1 sfx }
+ " "$2"
+}
+
+# Complete symbol names from a tag file.
+# Usage: __git_complete_symbol [<option>]...
+# --tags=<file>: The tag file to list symbol names from instead of the
+# default "tags".
+# --pfx=<prefix>: A prefix to be added to each symbol name.
+# --cur=<word>: The current symbol name to be completed. Defaults to
+# the current word to be completed.
+# --sfx=<suffix>: A suffix to be appended to each symbol name instead
+# of the default space.
+__git_complete_symbol () {
+ local tags=tags pfx="" cur_="${cur-}" sfx=" "
+
+ while test $# != 0; do
+ case "$1" in
+ --tags=*) tags="${1##--tags=}" ;;
+ --pfx=*) pfx="${1##--pfx=}" ;;
+ --cur=*) cur_="${1##--cur=}" ;;
+ --sfx=*) sfx="${1##--sfx=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ if test -r "$tags"; then
+ __gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")"
+ fi
}
_git_grep ()
@@ -1306,50 +1978,34 @@ _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
- "
+ __gitcomp_builtin grep
return
;;
esac
case "$cword,$prev" in
2,*|*,-*)
- if test -r tags; then
- __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
- return
- fi
+ __git_complete_symbol && return
;;
esac
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
}
_git_help ()
{
case "$cur" in
--*)
- __gitcomp "--all --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 gitk glossary hooks ignore modules
- namespaces repository-layout 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 ()
@@ -1362,7 +2018,7 @@ _git_init ()
return
;;
--*)
- __gitcomp "--quiet --bare --template= --shared --shared="
+ __gitcomp_builtin init
return
;;
esac
@@ -1372,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
@@ -1390,11 +2040,24 @@ _git_ls_files ()
_git_ls_remote ()
{
+ case "$cur" in
+ --*)
+ __gitcomp_builtin ls-remote
+ return
+ ;;
+ esac
__gitcomp_nl "$(__git_remotes)"
}
_git_ls_tree ()
{
+ case "$cur" in
+ --*)
+ __gitcomp_builtin ls-tree
+ return
+ ;;
+ esac
+
__git_complete_file
}
@@ -1421,18 +2084,31 @@ __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 ()
{
__git_has_doubledash && return
+ __git_find_repo_path
- local g="$(git rev-parse --git-dir 2>/dev/null)"
local merge=""
- if [ -f "$g/MERGE_HEAD" ]; then
+ if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
merge="--merge"
fi
+ case "$prev,$cur" in
+ -L,:*:*)
+ return # fall back to Bash filename completion
+ ;;
+ -L,:*)
+ __git_complete_symbol --cur="${cur#:}" --sfx=":"
+ return
+ ;;
+ -G,*|-S,*)
+ __git_complete_symbol
+ return
+ ;;
+ esac
case "$cur" in
--pretty=*|--format=*)
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
@@ -1447,6 +2123,18 @@ _git_log ()
__gitcomp "full short no" "" "${cur##--decorate=}"
return
;;
+ --diff-algorithm=*)
+ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
+ return
+ ;;
+ --submodule=*)
+ __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
+ return
+ ;;
+ --no-walk=*)
+ __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
+ return
+ ;;
--*)
__gitcomp "
$__git_log_common_options
@@ -1454,44 +2142,55 @@ _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
;;
+ -L:*:*)
+ return # fall back to Bash filename completion
+ ;;
+ -L:*)
+ __git_complete_symbol --cur="${cur#-L:}" --sfx=":"
+ return
+ ;;
+ -G*)
+ __git_complete_symbol --pfx="-G" --cur="${cur#-G}"
+ return
+ ;;
+ -S*)
+ __git_complete_symbol --pfx="-S" --cur="${cur#-S}"
+ return
+ ;;
esac
__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"
+ __gitcomp_builtin merge
return
esac
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
}
_git_mergetool ()
@@ -1502,7 +2201,7 @@ _git_mergetool ()
return
;;
--*)
- __gitcomp "--tool="
+ __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
return
;;
esac
@@ -1512,18 +2211,18 @@ _git_merge_base ()
{
case "$cur" in
--*)
- __gitcomp "--octopus --independent --is-ancestor --fork-point"
+ __gitcomp_builtin merge-base
return
;;
esac
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
}
_git_mv ()
{
case "$cur" in
--*)
- __gitcomp "--dry-run"
+ __gitcomp_builtin mv
return
;;
esac
@@ -1537,52 +2236,40 @@ _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
--ref)
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
;;
*)
__gitcomp "$subcommands --ref"
;;
esac
;;
- add,--reuse-message=*|append,--reuse-message=*|\
- add,--reedit-message=*|append,--reedit-message=*)
- __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
+ *,--reuse-message=*|*,--reedit-message=*)
+ __git_complete_refs --cur="${cur#*=}"
;;
- add,--*|append,--*)
- __gitcomp '--file= --message= --reedit-message=
- --reuse-message='
- ;;
- copy,--*)
- __gitcomp '--stdin'
- ;;
- prune,--*)
- __gitcomp '--dry-run --verbose'
+ *,--*)
+ __gitcomp_builtin notes_$subcommand
;;
- prune,*)
+ prune,*|get-ref,*)
+ # this command does not take a ref, do not complete it
;;
*)
case "$prev" in
-m|-F)
;;
*)
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
;;
esac
;;
@@ -1599,18 +2286,15 @@ _git_pull ()
return
;;
--*)
- __gitcomp "
- --rebase --no-rebase
- $__git_merge_options
- $__git_fetch_options
- "
+ __gitcomp_builtin pull
+
return
;;
esac
__git_complete_remote_or_refspec
}
-__git_push_recurse_submodules="check on-demand"
+__git_push_recurse_submodules="check on-demand only"
__git_complete_force_with_lease ()
{
@@ -1620,10 +2304,10 @@ __git_complete_force_with_lease ()
--*=)
;;
*:*)
- __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}"
+ __git_complete_refs --cur="${cur_#*:}"
;;
*)
- __gitcomp_nl "$(__git_refs)" "" "$cur_"
+ __git_complete_refs --cur="$cur_"
;;
esac
}
@@ -1654,26 +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 ()
{
- local dir="$(__gitdir)"
- if [ -f "$dir"/rebase-merge/interactive ]; then
- __gitcomp "--continue --skip --abort --edit-todo"
+ __git_find_repo_path
+ if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
+ __gitcomp "$__git_rebase_interactive_inprogress_options"
return
- elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort"
+ elif [ -d "$__git_repo_path"/rebase-apply ] || \
+ [ -d "$__git_repo_path"/rebase-merge ]; then
+ __gitcomp "$__git_rebase_inprogress_options"
return
fi
__git_complete_strategy && return
@@ -1682,23 +2379,17 @@ _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
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
}
_git_reflog ()
@@ -1709,7 +2400,7 @@ _git_reflog ()
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
else
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
fi
}
@@ -1720,9 +2411,7 @@ _git_send_email ()
{
case "$prev" in
--to|--cc|--bcc|--from)
- __gitcomp "
- $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
- "
+ __gitcomp "$(__git send-email --dump-aliases)"
return
;;
esac
@@ -1752,22 +2441,20 @@ _git_send_email ()
return
;;
--to=*|--cc=*|--bcc=*|--from=*)
- __gitcomp "
- $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
- " "" "${cur#--*=}"
+ __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}"
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
@@ -1779,6 +2466,103 @@ _git_stage ()
_git_add
}
+_git_status ()
+{
+ local complete_opt
+ local untracked_state
+
+ case "$cur" in
+ --ignore-submodules=*)
+ __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
+ return
+ ;;
+ --untracked-files=*)
+ __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
+ return
+ ;;
+ --column=*)
+ __gitcomp "
+ always never auto column row plain dense nodense
+ " "" "${cur##--column=}"
+ return
+ ;;
+ --*)
+ __gitcomp_builtin status
+ return
+ ;;
+ esac
+
+ untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
+ "$__git_untracked_file_modes" "status.showUntrackedFiles")"
+
+ case "$untracked_state" in
+ no)
+ # --ignored option does not matter
+ complete_opt=
+ ;;
+ all|normal|*)
+ complete_opt="--cached --directory --no-empty-directory --others"
+
+ if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
+ complete_opt="$complete_opt --ignored --exclude=*"
+ fi
+ ;;
+ esac
+
+ __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
@@ -1798,492 +2582,371 @@ __git_config_get_set_variables ()
c=$((--c))
done
- git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null
+ __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)
- __gitcomp_nl "$(__git_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 --git-dir="$(__gitdir)" \
- for-each-ref --format='%(refname):%(refname)' \
- refs/heads)"
+ __gitcomp_nl "$(__git for-each-ref \
+ --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#*.}"
- __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
- __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
+ __gitcomp_direct "$(__git_heads "$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.commitBeforeMerge
- advice.detachedHead
- advice.implicitIdentity
- advice.pushNonFastForward
- advice.resolveConflict
- advice.statusHints
- alias.
- am.keepcr
- 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.nobranch
- color.status.unmerged
- color.status.untracked
- color.status.updated
- color.ui
- commit.status
- commit.template
- core.abbrev
- core.askpass
- core.attributesfile
- core.autocrlf
- core.bare
- core.bigFileThreshold
- core.compression
- core.createObject
- core.deltaBaseCacheLimit
- core.editor
- core.eol
- core.excludesfile
- core.fileMode
- core.fsyncobjectfiles
- core.gitProxy
- core.ignoreStat
- core.ignorecase
- core.logAllRefUpdates
- core.loosecompression
- core.notesRef
- core.packedGitLimit
- core.packedGitWindowSize
- core.pager
- core.preferSymlinkRefs
- core.preloadindex
- core.quotepath
- core.repositoryFormatVersion
- core.safecrlf
- core.sharedRepository
- core.sparseCheckout
- core.symlinks
- core.trustctime
- core.untrackedCache
- core.warnAmbiguousRefs
- core.whitespace
- core.worktree
- 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.headers
- format.numbered
- format.pretty
- format.signature
- format.signoff
- format.subjectprefix
- format.suffix
- format.thread
- format.to
- gc.
- gc.aggressiveWindow
- gc.auto
- gc.autopacklimit
- gc.packrefs
- gc.pruneexpire
- gc.reflogexpire
- gc.reflogexpireunreachable
- gc.rerereresolved
- gc.rerereunresolved
- 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.validate
- 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 ()
{
- local subcommands="add rename remove set-head set-branches set-url show prune update"
+ local subcommands="
+ add rename remove set-head set-branches
+ get-url set-url show prune update
+ "
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
- __gitcomp "$subcommands"
+ case "$cur" in
+ --*)
+ __gitcomp_builtin remote
+ ;;
+ *)
+ __gitcomp "$subcommands"
+ ;;
+ esac
return
fi
- case "$subcommand" in
- rename|remove|set-url|show|prune)
- __gitcomp_nl "$(__git_remotes)"
+ case "$subcommand,$cur" in
+ add,--*)
+ __gitcomp_builtin remote_add
+ ;;
+ add,*)
;;
- set-head|set-branches)
+ set-head,--*)
+ __gitcomp_builtin remote_set-head
+ ;;
+ set-branches,--*)
+ __gitcomp_builtin remote_set-branches
+ ;;
+ set-head,*|set-branches,*)
__git_complete_remote_or_refspec
;;
- update)
- __gitcomp "$(__git_get_config_variables "remotes")"
+ update,--*)
+ __gitcomp_builtin remote_update
+ ;;
+ update,*)
+ __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
+ ;;
+ set-url,--*)
+ __gitcomp_builtin remote_set-url
+ ;;
+ get-url,--*)
+ __gitcomp_builtin remote_get-url
+ ;;
+ prune,--*)
+ __gitcomp_builtin remote_prune
;;
*)
+ __gitcomp_nl "$(__git_remotes)"
;;
esac
}
_git_replace ()
{
- __gitcomp_nl "$(__git_refs)"
+ case "$cur" in
+ --format=*)
+ __gitcomp "short medium long" "" "${cur##--format=}"
+ return
+ ;;
+ --*)
+ __gitcomp_builtin replace
+ return
+ ;;
+ esac
+ __git_complete_refs
+}
+
+_git_rerere ()
+{
+ local subcommands="clear forget diff remaining status gc"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if test -z "$subcommand"
+ then
+ __gitcomp "$subcommands"
+ return
+ fi
}
_git_reset ()
@@ -2292,34 +2955,60 @@ _git_reset ()
case "$cur" in
--*)
- __gitcomp "--merge --mixed --hard --soft --patch"
+ __gitcomp_builtin reset
return
;;
esac
- __gitcomp_nl "$(__git_refs)"
+ __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 ()
{
- local dir="$(__gitdir)"
- if [ -f "$dir"/REVERT_HEAD ]; then
- __gitcomp "--continue --quit --abort"
+ __git_find_repo_path
+ if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
+ __gitcomp "$__git_revert_inprogress_options"
return
fi
+ __git_complete_strategy && return
case "$cur" in
--*)
- __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
+ __gitcomp_builtin revert "" \
+ "$__git_revert_inprogress_options"
return
;;
esac
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
}
_git_rm ()
{
case "$cur" in
--*)
- __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
+ __gitcomp_builtin rm
return
;;
esac
@@ -2336,7 +3025,7 @@ _git_shortlog ()
__gitcomp "
$__git_log_common_options
$__git_log_shortlog_options
- --numbered --summary
+ --numbered --summary --email
"
return
;;
@@ -2358,9 +3047,22 @@ _git_show ()
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
return
;;
+ --submodule=*)
+ __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
@@ -2373,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='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"
@@ -2403,6 +3129,9 @@ _git_stash ()
esac
else
case "$subcommand,$cur" in
+ push,--*)
+ __gitcomp "$save_opts --message"
+ ;;
save,--*)
__gitcomp "$save_opts"
;;
@@ -2412,18 +3141,21 @@ _git_stash ()
drop,--*)
__gitcomp "--quiet"
;;
+ list,--*)
+ __gitcomp "--name-status --oneline --patch-with-stat"
+ ;;
show,--*|branch,--*)
;;
branch,*)
if [ $cword -eq 3 ]; then
- __gitcomp_nl "$(__git_refs)";
+ __git_complete_refs
else
- __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+ __gitcomp_nl "$(__git stash list \
| sed -n -e 's/:.*//p')"
fi
;;
show,*|apply,*|drop,*|pop,*)
- __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+ __gitcomp_nl "$(__git stash list \
| sed -n -e 's/:.*//p')"
;;
*)
@@ -2436,11 +3168,12 @@ _git_submodule ()
{
__git_has_doubledash && return
- local subcommands="add status init deinit update summary foreach sync"
- if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
+ 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
--*)
- __gitcomp "--quiet --cached"
+ __gitcomp "--quiet"
;;
*)
__gitcomp "$subcommands"
@@ -2448,6 +3181,36 @@ _git_submodule ()
esac
return
fi
+
+ case "$subcommand,$cur" in
+ add,--*)
+ __gitcomp "--branch --force --name --reference --depth"
+ ;;
+ status,--*)
+ __gitcomp "--cached --recursive"
+ ;;
+ deinit,--*)
+ __gitcomp "--force --all"
+ ;;
+ update,--*)
+ __gitcomp "
+ --init --remote --no-fetch
+ --recommend-shallow --no-recommend-shallow
+ --force --rebase --merge --reference --depth --recursive --jobs
+ "
+ ;;
+ set-branch,--*)
+ __gitcomp "--default --branch"
+ ;;
+ summary,--*)
+ __gitcomp "--cached --files --summary-limit"
+ ;;
+ foreach,--*|sync,--*)
+ __gitcomp "--recursive"
+ ;;
+ *)
+ ;;
+ esac
}
_git_svn ()
@@ -2468,14 +3231,15 @@ _git_svn ()
--no-metadata --use-svm-props --use-svnsync-props
--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="
--template= --shared= --trunk= --tags=
--branches= --stdlayout --minimize-url
--no-metadata --use-svm-props --use-svnsync-props
- --rewrite-root= --prefix= --use-log-author
- --add-author-from $remote_opts
+ --rewrite-root= --prefix= $remote_opts
"
local cmt_opts="
--edit --rmdir --find-copies-harder --copy-similarity=
@@ -2554,8 +3318,8 @@ _git_tag ()
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- -d|-v)
- __gitcomp_nl "$(__git_tags)"
+ -d|--delete|-v|--verify)
+ __gitcomp_direct "$(__git_tags "" "$cur" " ")"
return
;;
-f)
@@ -2570,21 +3334,17 @@ _git_tag ()
;;
-*|tag)
if [ $f = 1 ]; then
- __gitcomp_nl "$(__git_tags)"
+ __gitcomp_direct "$(__git_tags "" "$cur" " ")"
fi
;;
*)
- __gitcomp_nl "$(__git_refs)"
+ __git_complete_refs
;;
esac
case "$cur" in
--*)
- __gitcomp "
- --list --delete --verify --annotate --message --file
- --sign --cleanup --local-user --force --column --sort
- --contains --points-at
- "
+ __gitcomp_builtin tag
;;
esac
}
@@ -2594,9 +3354,135 @@ _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 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"
+ ;;
+ *,--*)
+ __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
+ ;;
+ -*) # 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
+}
+
__git_main ()
{
- local i c=1 command __git_dir
+ local i c=1 command __git_dir __git_repo_path
+ local __git_C_args C_args_count=0
while [ $c -lt $cword ]; do
i="${words[c]}"
@@ -2606,13 +3492,32 @@ __git_main ()
--bare) __git_dir="." ;;
--help) command="help"; break ;;
-c|--work-tree|--namespace) ((c++)) ;;
+ -C) __git_C_args[C_args_count++]=-C
+ ((c++))
+ __git_C_args[C_args_count++]="${words[c]}"
+ ;;
-*) ;;
*) command="$i"; break ;;
esac
((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)
+ __git_complete_config_variable_name_and_value
+ return
+ ;;
+ --namespace)
+ # we don't support completing these options' arguments
+ return
+ ;;
+ esac
case "$cur" in
--*) __gitcomp "
--paginate
@@ -2631,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 && $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
}
@@ -2652,9 +3561,11 @@ __gitk_main ()
{
__git_has_doubledash && return
- local g="$(__gitdir)"
+ local __git_repo_path
+ __git_find_repo_path
+
local merge=""
- if [ -f "$g/MERGE_HEAD" ]; then
+ if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
merge="--merge"
fi
case "$cur" in
@@ -2670,67 +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_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
@@ -2752,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
@@ -2771,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 0da14eee9..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
@@ -82,12 +91,14 @@
# contains relative to newer annotated tag (v1.6.3.2~35)
# branch relative to newer tag or branch (master~4)
# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
+# tag relative to any older tag (v1.6.3.1-13-gdd42c2f)
# default exactly matching tag
#
# 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
@@ -277,11 +288,43 @@ __git_ps1_colorize_gitstring ()
r="$c_clear$r"
}
+# Helper function to read the first line of a file into a variable.
+# __git_eread requires 2 arguments, the file path and the name of the
+# variable, in that order.
__git_eread ()
{
- local f="$1"
- shift
- test -r "$f" && read "$@" <"$f"
+ 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)
@@ -355,8 +398,8 @@ __git_ps1 ()
# incorrect.)
#
local ps1_expanded=yes
- [ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
- [ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no
+ [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
+ [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
local repo_info rev_parse_exit_code
repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
@@ -368,7 +411,7 @@ __git_ps1 ()
return $exit
fi
- local short_sha
+ local short_sha=""
if [ "$rev_parse_exit_code" = "0" ]; then
short_sha="${repo_info##*$'\n'}"
repo_info="${repo_info%$'\n'*}"
@@ -388,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=""
@@ -396,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
@@ -415,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
@@ -443,6 +487,8 @@ __git_ps1 ()
git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
+ (tag)
+ git describe --tags HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
@@ -463,6 +509,7 @@ __git_ps1 ()
local i=""
local s=""
local u=""
+ local h=""
local c=""
local p=""
@@ -495,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
@@ -515,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/gitfast.plugin.zsh b/plugins/gitfast/gitfast.plugin.zsh
index dba1b1315..7b6b67e92 100644
--- a/plugins/gitfast/gitfast.plugin.zsh
+++ b/plugins/gitfast/gitfast.plugin.zsh
@@ -1,6 +1,4 @@
-dir=$(dirname $0)
-source $dir/../git/git.plugin.zsh
-source $dir/git-prompt.sh
+source "${0:A:h}/git-prompt.sh"
function git_prompt_info() {
dirty="$(parse_git_dirty)"
diff --git a/plugins/gitfast/update b/plugins/gitfast/update
new file mode 100755
index 000000000..5311065a1
--- /dev/null
+++ b/plugins/gitfast/update
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+url="https://raw.githubusercontent.com/felipec/git-completion"
+version="1.2"
+
+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/github/README.md b/plugins/github/README.md
index 2b66e390f..70b863f64 100644
--- a/plugins/github/README.md
+++ b/plugins/github/README.md
@@ -1,4 +1,4 @@
-# github
+# github plugin
This plugin supports working with GitHub from the command line. It provides a few things:
@@ -6,7 +6,7 @@ This plugin supports working with GitHub from the command line. It provides a fe
* Completion for the `github` Ruby gem.
* Convenience functions for working with repos and URLs.
-### Functions
+### Functions
* `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub
* `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub
@@ -14,13 +14,13 @@ This plugin supports working with GitHub from the command line. It provides a fe
* `git.io` - Shortens a URL using [git.io](https://git.io)
-## Installation
+## Installation
[Hub](https://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ.
The [`github` Ruby gem](https://github.com/defunkt/github-gem) needs to be installed if you want to use it.
-### Configuration
+### Configuration
These settings affect `github`'s behavior.
@@ -35,7 +35,7 @@ These settings affect `github`'s behavior.
See `man hub` for more details.
-### Homebrew installation note
+### Homebrew installation note
If you have installed `hub` using Homebrew, its completions may not be on your `$FPATH` if you are using the system `zsh`. Homebrew installs `zsh` completion definitions to `/usr/local/share/zsh/site-functions`, which will be on `$FPATH` for the Homebrew-installed `zsh`, but not for the system `zsh`. If you want it to work with the system `zsh`, add this to your `~/.zshrc` before it sources `oh-my-zsh.sh`.
diff --git a/plugins/github/_hub b/plugins/github/_hub
index 1833a9c09..209a3df9e 100644
--- a/plugins/github/_hub
+++ b/plugins/github/_hub
@@ -58,6 +58,7 @@ __hub_setup_zsh_fns () {
- set1 \
'-m[message]' \
'-F[file]' \
+ '--no-edit[use first commit message for pull request title/description]' \
'-a[user]' \
'-M[milestone]' \
'-l[labels]' \
@@ -84,11 +85,15 @@ __hub_setup_zsh_fns () {
hub_commands=(
alias:'show shell instructions for wrapping git'
pull-request:'open a pull request on GitHub'
+ pr:'list or checkout a GitHub pull request'
+ issue:'list or create a GitHub issue'
+ release:'list or create a GitHub release'
fork:'fork origin repo on GitHub'
create:'create new repo on GitHub for the current project'
+ delete:'delete a GitHub repo'
browse:'browse the project on GitHub'
compare:'open GitHub compare view'
- ci-status:'lookup commit in GitHub Status API'
+ ci-status:'show status of GitHub checks for a commit'
sync:'update local branches from upstream'
)
_describe -t hub-commands 'hub command' hub_commands && ret=0
@@ -111,8 +116,12 @@ __hub_setup_bash_fns () {
cat <<-EOF
alias
pull-request
+pr
+issue
+release
fork
create
+delete
browse
compare
ci-status
diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh
index 15e38d3b7..a687f5cce 100644
--- a/plugins/gitignore/gitignore.plugin.zsh
+++ b/plugins/gitignore/gitignore.plugin.zsh
@@ -1,4 +1,4 @@
-function gi() { curl -fL https://www.gitignore.io/api/${(j:,:)@} }
+function gi() { curl -fLw '\n' https://www.gitignore.io/api/"${(j:,:)@}" }
_gitignoreio_get_command_list() {
curl -sfL https://www.gitignore.io/api/list | tr "," "\n"
diff --git a/plugins/glassfish/README.md b/plugins/glassfish/README.md
new file mode 100644
index 000000000..1f4a8be34
--- /dev/null
+++ b/plugins/glassfish/README.md
@@ -0,0 +1,9 @@
+# glassfish
+
+The glassfish plugin adds completion for the `asadmin` utility, a command to manage
+[Oracle GlassFish](https://docs.oracle.com/cd/E18930_01/html/821-2416/giobi.html) servers.
+
+To use it, add `glassfish` to the plugins array in your zshrc file:
+```zsh
+plugins=(... glassfish)
+```
diff --git a/plugins/glassfish/glassfish.plugin.zsh b/plugins/glassfish/glassfish.plugin.zsh
index fde2edb2a..e69de29bb 100644
--- a/plugins/glassfish/glassfish.plugin.zsh
+++ b/plugins/glassfish/glassfish.plugin.zsh
@@ -1,3 +0,0 @@
-# if there is a user named 'glassfish' on the system, we'll assume
-# that is the user asadmin should be run as
-# grep -e '^glassfish' /etc/passwd > /dev/null && alias asadmin='sudo -u glassfish asadmin' \ No newline at end of file
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/README.md b/plugins/gnu-utils/README.md
new file mode 100644
index 000000000..f5fa81e2f
--- /dev/null
+++ b/plugins/gnu-utils/README.md
@@ -0,0 +1,38 @@
+# gnu-utils plugin
+
+This plugin binds GNU coreutils to their default names, so that you don't have
+to call them using their prefixed name, which starts with `g`. This is useful
+in systems which don't have GNU coreutils installed by default, mainly macOS
+or FreeBSD, which use BSD coreutils.
+
+To use it, add `gnu-utils` to the plugins array in your zshrc file:
+```zsh
+plugins=(... gnu-utils)
+```
+
+The plugin works by changing the path that the command hash points to, so
+instead of `ls` pointing to `/bin/ls`, it points to wherever `gls` is
+installed.
+
+Since `hash -rf` or `rehash` refreshes the command hashes, it also wraps
+`hash` and `rehash` so that the coreutils binding is always done again
+after calling these two commands.
+
+Look at the source code of the plugin to see which GNU coreutils are tried
+to rebind. Open an issue if there are some missing.
+
+## Other methods
+
+The plugin also documents two other ways to do this:
+
+1. Using a function wrapper, such that, for example, there exists a function
+named `ls` which calls `gls` instead. Since functions have a higher preference
+than commands, this ends up calling the GNU coreutil. It has also a higher
+preference over shell builtins (`gecho` is called instead of the builtin `echo`).
+
+2. Using an alias. This has an even higher preference than functions, but they
+could be overridden because of a user setting.
+
+## Author
+
+- [Sorin Ionescu](https://github.com/sorin-ionescu).
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index b66e25d7f..23e00c295 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -5,79 +5,79 @@
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
+# Detect if GNU coreutils are installed by looking for gwhoami
+if [[ ! -x "${commands[gwhoami]}" ]]; then
+ return
+fi
-if [[ -x "${commands[gwhoami]}" ]]; then
- __gnu_utils() {
- emulate -L zsh
- local gcmds
- local gcmd
- local cmd
- local prefix
+__gnu_utils() {
+ emulate -L zsh
+ local gcmds
+ local gcmd
+ local cmd
+ local prefix
- # coreutils
- gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod'
- 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate'
- 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand'
- 'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid'
- 'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum'
- 'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc'
- 'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd'
- 'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum'
- 'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort'
- 'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest'
- 'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname'
- 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
- 'gwhoami' 'gyes')
+ # coreutils
+ gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod'
+ 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate'
+ 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand'
+ 'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid'
+ 'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum'
+ 'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc'
+ 'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd'
+ 'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum'
+ 'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort'
+ 'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest'
+ 'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname'
+ 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
+ 'gwhoami' 'gyes')
- # findutils
- gcmds+=('gfind' 'gxargs' 'glocate')
+ # findutils
+ gcmds+=('gfind' 'gxargs' 'glocate')
- # Not part of either coreutils or findutils, installed separately.
- gcmds+=('gsed' 'gtar' 'gtime')
+ # Not part of either coreutils or findutils, installed separately.
+ gcmds+=('gsed' 'gtar' 'gtime' 'gmake')
- for gcmd in "${gcmds[@]}"; do
- #
- # This method allows for builtin commands to be primary but it's
- # lost if hash -r or rehash -f is executed. Thus, those two
- # functions have to be wrapped.
- #
- (( ${+commands[$gcmd]} )) && hash ${gcmd[2,-1]}=${commands[$gcmd]}
+ for gcmd in "${gcmds[@]}"; do
+ # Do nothing if the command isn't found
+ (( ${+commands[$gcmd]} )) || continue
+
+ # This method allows for builtin commands to be primary but it's
+ # lost if hash -r or rehash -f is executed. Thus, those two
+ # functions have to be wrapped.
+ #
+ hash ${gcmd[2,-1]}=${commands[$gcmd]}
- #
- # This method generates wrapper functions.
- # It will override shell builtins.
- #
- # (( ${+commands[$gcmd]} )) && \
- # eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }"
+ # This method generates wrapper functions.
+ # It will override shell builtins.
+ #
+ # eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }"
- #
- # This method is inflexible since the aliases are at risk of being
- # overridden resulting in the BSD coreutils being called.
- #
- # (( ${+commands[$gcmd]} )) && \
- # alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
- done
+ # This method is inflexible since the aliases are at risk of being
+ # overridden resulting in the BSD coreutils being called.
+ #
+ # alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
+ done
- return 0
- }
- __gnu_utils;
+ return 0
+}
+__gnu_utils
- function hash() {
- if [[ "$*" =~ "-(r|f)" ]]; then
- builtin hash "$@"
- __gnu_utils
- else
- builtin hash "$@"
- fi
- }
+function hash() {
+ if [[ "$*" =~ "-(r|f)" ]]; then
+ builtin hash "$@"
+ __gnu_utils
+ else
+ builtin hash "$@"
+ fi
+}
- function rehash() {
- if [[ "$*" =~ "-f" ]]; then
- builtin rehash "$@"
- __gnu_utils
- else
- builtin rehash "$@"
- fi
- }
-fi
+function rehash() {
+ if [[ "$*" =~ "-f" ]]; then
+ builtin rehash "$@"
+ __gnu_utils
+ else
+ builtin rehash "$@"
+ fi
+}
diff --git a/plugins/go/README.md b/plugins/go/README.md
index 6ce6f4ee2..bf43b9feb 100644
--- a/plugins/go/README.md
+++ b/plugins/go/README.md
@@ -1 +1 @@
-The go plugin is deprecated. Use the [golang plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/golang) instead.
+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
index cf943e2e1..da7c87cfd 120000..100644
--- a/plugins/go/go.plugin.zsh
+++ b/plugins/go/go.plugin.zsh
@@ -1 +1,3 @@
-../golang/golang.plugin.zsh \ No newline at end of file
+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 72845b2a1..0a1b43c30 100644
--- a/plugins/golang/README.md
+++ b/plugins/golang/README.md
@@ -21,6 +21,7 @@ plugins=(... golang)
| gog | `go get` | Downloads packages and then installs them to $GOPATH |
| goi | `go install` | Compiles and installs packages to $GOPATH |
| gol | `go list` | Lists Go packages |
+| gom | `go mod` | Access to operations on modules |
| gop | `cd $GOPATH` | Takes you to $GOPATH |
| gopb | `cd $GOPATH/bin` | Takes you to $GOPATH/bin |
| gops | `cd $GOPATH/src` | Takes you to $GOPATH/src |
diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
index 919c98629..398bd966f 100644
--- a/plugins/golang/golang.plugin.zsh
+++ b/plugins/golang/golang.plugin.zsh
@@ -28,6 +28,7 @@ __go_tool_complete() {
'help[display help]'
'install[compile and install packages and dependencies]'
'list[list packages]'
+ 'mod[modules maintenance]'
'run[compile and run Go program]'
'test[test packages]'
'tool[run specified go tool]'
@@ -40,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]'
@@ -83,7 +84,7 @@ __go_tool_complete() {
"-x[print remove commands as it executes them]" \
"*:importpaths:__go_packages"
;;
- fix|fmt|list|vet)
+ fix|fmt|vet)
_alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"'
;;
install)
@@ -124,8 +125,84 @@ __go_tool_complete() {
"-memprofilerate[set heap profiling rate]:number" \
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
;;
+ list)
+ _arguments -s -w : \
+ "-f[alternative format for the list]:format" \
+ "-json[print data in json format]" \
+ "-compiled[set CompiledGoFiles to the Go source files presented to the compiler]" \
+ "-deps[iterate over not just the named packages but also all their dependencies]" \
+ "-e[change the handling of erroneous packages]" \
+ "-export[set the Export field to the name of a file containing up-to-date export information for the given package]" \
+ "-find[identify the named packages but not resolve their dependencies]" \
+ "-test[report not only the named packages but also their test binaries]" \
+ "-m[list modules instead of packages]" \
+ "-u[adds information about available upgrades]" \
+ "-versions[set the Module's Versions field to a list of all known versions of that module]:number" \
+ "*:importpaths:__go_packages"
+ ;;
+ mod)
+ typeset -a mod_commands
+ mod_commands+=(
+ 'download[download modules to local cache]'
+ 'edit[edit go.mod from tools or scripts]'
+ 'graph[print module requirement graph]'
+ 'init[initialize new module in current directory]'
+ 'tidy[add missing and remove unused modules]'
+ 'vendor[make vendored copy of dependencies]'
+ 'verify[verify dependencies have expected content]'
+ 'why[explain why packages or modules are needed]'
+ )
+ if (( CURRENT == 3 )); then
+ _values 'go mod commands' ${mod_commands[@]} "help[display help]"
+ return
+ fi
+ case ${words[3]} in
+ help)
+ _values 'go mod commands' ${mod_commands[@]}
+ ;;
+ download)
+ _arguments -s -w : \
+ "-json[print a sequence of JSON objects standard output]" \
+ "*:flags"
+ ;;
+ edit)
+ _arguments -s -w : \
+ "-fmt[reformat the go.mod file]" \
+ "-module[change the module's path]" \
+ "-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
+ "-dropreplace[=old{@v}=new{@v} drop a replacement of the given module path and version pair]:name" \
+ "-go[={version} set the expected Go language version]:number" \
+ "-print[print the final go.mod in its text format]" \
+ "-json[print the final go.mod file in JSON format]" \
+ "*:flags"
+ ;;
+ graph)
+ ;;
+ init)
+ ;;
+ tidy)
+ _arguments -s -w : \
+ "-v[print information about removed modules]" \
+ "*:flags"
+ ;;
+ vendor)
+ _arguments -s -w : \
+ "-v[print the names of vendored]" \
+ "*:flags"
+ ;;
+ verify)
+ ;;
+ why)
+ _arguments -s -w : \
+ "-m[treats the arguments as a list of modules and finds a path to any package in each of the modules]" \
+ "-vendor[exclude tests of dependencies]" \
+ "*:importpaths:__go_packages"
+ ;;
+ esac
+ ;;
help)
_values "${commands[@]}" \
+ 'environment[show Go environment variables available]' \
'gopath[GOPATH environment variable]' \
'packages[description of package lists]' \
'remote[remote import path syntax]' \
@@ -188,6 +265,7 @@ alias gofa='go fmt ./...'
alias gog='go get'
alias goi='go install'
alias gol='go list'
+alias gom='go mod'
alias gop='cd $GOPATH'
alias gopb='cd $GOPATH/bin'
alias gops='cd $GOPATH/src'
diff --git a/plugins/gpg-agent/README.md b/plugins/gpg-agent/README.md
index a9711f923..9c1e6d2cc 100644
--- a/plugins/gpg-agent/README.md
+++ b/plugins/gpg-agent/README.md
@@ -3,6 +3,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:
-```
+
+```zsh
plugins=(... gpg-agent)
```
diff --git a/plugins/gradle/README.md b/plugins/gradle/README.md
index 215503c81..3756db0dc 100644
--- a/plugins/gradle/README.md
+++ b/plugins/gradle/README.md
@@ -1,4 +1,4 @@
-## Gradle Plugin
+# Gradle plugin
This plugin adds completions and aliases for [Gradle](https://gradle.org/).
@@ -10,9 +10,15 @@ plugins=(... gradle)
## Usage
-This plugin creates an alias `gradle` which is used to determine whether the current working directory has a gradlew file. If gradlew is present it will be used otherwise `gradle` is used directly. Gradle tasks can be executed directly without regard for whether it is `gradle` or `gradlew`
+This plugin creates a function called `gradle-or-gradlew`, which is aliased
+to `gradle`, which is used to determine whether the current project directory
+has a gradlew file. If `gradlew` is present it will be used, otherwise `gradle`
+is used instead. Gradle tasks can be executed directly without regard for
+whether it is `gradle` or `gradlew`. It also supports being called from
+any directory inside the root project directory.
Examples:
+
```zsh
gradle test
gradle build
@@ -20,4 +26,5 @@ gradle build
## Completion
-The completion provided for this plugin caches the parsed tasks into a file named `.gradletasknamecache` in the current working directory, so you might want to add that to your `.gitignore` file so that it's not accidentally committed.
+This plugin uses [the completion from the Gradle project](https://github.com/gradle/gradle-completion),
+which is distributed under the MIT license.
diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle
index 80723f2fc..e77b23cdb 120000..100644
--- a/plugins/gradle/_gradle
+++ b/plugins/gradle/_gradle
@@ -1 +1,420 @@
-gradle.plugin.zsh \ No newline at end of file
+#compdef gradle gradlew gw
+#
+# Taken from https://github.com/gradle/gradle-completion
+# Copyright (c) 2017 Eric Wendelin
+#
+# 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.
+# Terms
+
+__gradle-set-project-root-dir() {
+ local dir=`pwd`
+ project_root_dir=`pwd`
+ while [[ $dir != '/' ]]; do
+ if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then
+ project_root_dir=$dir
+ return 0
+ fi
+ dir="$(dirname "$dir")"
+ done
+ return 1
+}
+
+__gradle-init-cache-dir() {
+ cache_dir="$HOME/.gradle/completion"
+ mkdir -p $cache_dir
+}
+
+__gradle-set-settings-file() {
+ # In order of precedence: --settings-file=filename, settings.gradle, settings.gradle.kts
+
+ local default_gradle_settings_file="$project_root_dir/settings.gradle"
+ if [[ ! -f $default_gradle_settings_file ]]; then
+ default_gradle_settings_file="$project_root_dir/settings.gradle.kts"
+ fi
+ gradle_settings_file=${${(v)opt_args[(i)-c|--settings-file]}:-$default_gradle_settings_file}
+}
+
+__gradle-set-build-file() {
+ __gradle-set-settings-file
+ # In order of precedence: --build-file=filename, rootProject.buildFileName, build.gradle, build.gradle.kts
+
+ local default_gradle_build_file_name="build.gradle"
+ if [[ -r $gradle_settings_file ]]; then
+ default_gradle_build_file_name=${$(grep "^rootProject\.buildFileName" $gradle_settings_file | \
+ sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")}
+
+ default_gradle_build_file_name="${default_gradle_build_file:-build.gradle}"
+ fi
+
+ local default_gradle_build_file="$project_root_dir/$default_gradle_build_file_name"
+ if [[ ! -f $default_gradle_build_file ]]; then
+ default_gradle_build_file="$project_root_dir/build.gradle.kts"
+ fi
+
+ # If a build file is specified after '-b' or '--build-file', use this file.
+ gradle_build_file=${${(v)opt_args[(i)-b|--build-file]}:-$default_gradle_build_file}
+}
+
+__gradle-set-cache-name() {
+ # Cache name is constructed from the absolute path of the build file.
+ cache_name=${${gradle_build_file:a}//[^[:alnum:]]/_}
+}
+
+__gradle-set-files-checksum() {
+ # Cache MD5 sum of all Gradle scripts and modified timestamps
+ if builtin command -v md5 > /dev/null; then
+ gradle_files_checksum=( $(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)") )
+ elif builtin command -v md5sum > /dev/null; then
+ gradle_files_checksum=( $(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}') )
+ else
+ _message 'Cannot generate completions as neither md5 nor md5sum exist on \$PATH'
+ return 1
+ fi
+}
+
+__gradle-generate-script-cache() {
+ # Invalidate cache after 3 weeks by default
+ local cache_ttl_mins=${$(echo $GRADLE_CACHE_TTL_MINUTES):-30240}
+ local script_exclude_pattern=${$(echo $GRADLE_COMPLETION_EXCLUDE_PATTERN):-"/(.git|build|integTest|samples|templates|smokeTest|testFixtures|out)/"}
+ if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then
+ zle -R "Generating Gradle build script cache"
+ # Cache all Gradle scripts
+ local -a gradle_build_scripts
+ gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") )
+ printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
+ fi
+}
+
+__gradle-generate-tasks-cache() {
+ __gradle-set-files-checksum
+
+ # Use Gradle wrapper when it exists.
+ local gradle_cmd="gradle"
+ if [[ -x "$project_root_dir/gradlew" ]]; then
+ gradle_cmd="$project_root_dir/gradlew"
+ fi
+
+ zle -R "Generating Gradle task cache from $gradle_build_file"
+
+ # Run gradle to retrieve possible tasks and 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 --console plain -q tasks --all 2>/dev/null)"
+ else
+ 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
+ for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do
+ if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
+ local task_name="${match[1]}"
+ local task_description="${match[3]}"
+ # Completion for subproject tasks with ':' prefix
+ if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]; then
+ gradle_all_tasks+="${task_name//:/\\:}:$task_description\n\\:${task_name//:/\\:}:$task_description\n"
+ subproject_tasks+="${match[2]}\n"
+ else
+ gradle_all_tasks+="${task_name//:/\\:}:$task_description\n"
+ root_tasks+="$task_name\n"
+ fi
+ fi
+ done
+
+ # subproject tasks can be referenced implicitly from root project
+ if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then
+ local -a implicit_tasks
+ implicit_tasks=( $(comm -23 <(echo $subproject_tasks | sort) <(echo $root_tasks | sort)) )
+ for task in $(printf "%s\n" "${implicit_tasks[@]}"); do
+ gradle_all_tasks+="$task\n"
+ done
+ fi
+
+ echo $gradle_all_tasks >| $cache_dir/$gradle_files_checksum
+ echo $gradle_files_checksum >| $cache_dir/$cache_name.md5
+}
+
+__gradle-completion-init() {
+ local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
+ __gradle-init-cache-dir
+ __gradle-set-project-root-dir
+ __gradle-set-build-file
+ if [[ -f $gradle_build_file ]]; then
+ __gradle-set-cache-name
+ __gradle-generate-script-cache
+ __gradle-set-files-checksum
+ __gradle-generate-tasks-cache
+ fi
+ return 0
+}
+
+__gradle_tasks() {
+ local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
+
+ __gradle-init-cache-dir
+ __gradle-set-project-root-dir
+ __gradle-set-build-file
+ if [[ -f $gradle_build_file ]]; then
+ __gradle-set-cache-name
+ __gradle-generate-script-cache
+ __gradle-set-files-checksum
+
+ # The cache key is md5 sum of all gradle scripts, so it's valid if it exists.
+ if [[ -f $cache_dir/$cache_name.md5 ]]; then
+ local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
+ local -a cached_tasks
+ if [[ -z $cur ]]; then
+ cached_tasks=(${(f)"$(cat $cache_dir/$cached_checksum)"})
+ else
+ cached_tasks=(${(f)"$(grep "^${cur//:/\\\\:}" $cache_dir/$cached_checksum)"})
+ fi
+ _describe 'all tasks' cached_tasks && ret=0
+ else
+ __gradle-generate-tasks-cache
+ fi
+
+ # Regenerate tasks cache in the background
+ if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum || $(wc -c < $cache_dir/$gradle_files_checksum) -le 1 ]]; then
+ $(__gradle-generate-tasks-cache 1>&2 2>/dev/null &)
+ fi
+ else
+ _describe 'built-in tasks' '(
+ "buildEnvironment:Displays all buildscript dependencies declared in root project."
+ "components:Displays the components produced by root project."
+ "dependencies:Displays all dependencies declared in root project."
+ "dependencyInsight:Displays the insight into a specific dependency in root project."
+ "dependentComponents:Displays the dependent components of components in root project."
+ "help:Displays a help message."
+ "init:Initializes a new Gradle build."
+ "model:Displays the configuration model of root project."
+ "projects:Displays the sub-projects of root project."
+ "properties:Displays the properties of root project."
+ "tasks:Displays the tasks runnable from root project."
+ "wrapper:Generates Gradle wrapper files."
+ )' && ret=0
+ fi
+}
+
+__gradle_subcommand() {
+ integer ret=1
+
+ case "$words[1]" in
+ (dependencies)
+ _arguments \
+ '--configuration=[The configuration to generate the report for.]:dependency configuration:_gradle_dependency_configurations' && ret=0
+ ;;
+ (dependencyInsight)
+ _arguments \
+ '--dependency=[Shows the details of given dependency.]' \
+ '--configuration=[Looks for the dependency in given configuration.]:dependency configuration:_gradle_dependency_configurations' && ret=0
+ ;;
+ (help)
+ _arguments \
+ '--task[The task to show help for.]' && ret=0
+ ;;
+ (init)
+ _arguments \
+ '--dsl=[DSL to be used in generated scripts.]:dsl:(groovy kotlin)' \
+ '--package=[Package for the generated source.]' \
+ '--project-name=[Name of the generated project.]' \
+ '--test-framework=[Test framework to be used.]:test framework:(junit kotlintest scalatest spock testng)' \
+ '--type=[Project type to generate.]:project type:(basic cpp-application cpp-library groovy-application groovy-library java-application java-library kotlin-application kotlin-library pom scala-library)' && ret=0
+ ;;
+ (tasks)
+ _arguments \
+ '--all[List all tasks, including subproject tasks.]' \
+ '--group=[Show tasks only from given task group.]' && ret=0
+ ;;
+ (test)
+ _arguments -C \
+ '--debug-jvm[Enable debugging for the test process. The process is started suspended and listening on port 5005. Requires the "java" plugin.]' \
+ '--fail-fast[Stops test execution after the first failed test. Requires the "java" plugin.]' \
+ '--tests=[Sets test class or method name to be included, * is supported. Requires the "java" plugin.]' \
+ '(-)*:: :->task-or-option' && ret=0
+ ;;
+ (wrapper)
+ _arguments \
+ '--distribution-type=[Binary-only or all with docs and sources]:*:distribution type:(bin all)' \
+ '--gradle-version=[Set Gradle version for wrapper]' \
+ '--gradle-distribution-sha256-sum=[SHA-256 checksum]' \
+ '--gradle-distribution-url=[Set Gradle distribution URL]' && ret=0
+ ;;
+ (*)
+ _arguments -C \
+ {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \
+ '(--no-build-cache)--build-cache[Enable the Gradle build cache.]' \
+ {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \
+ {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \
+ {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle' \
+ '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \
+ '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \
+ '--continue[Continues task execution after a task failure.]' \
+ '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \
+ '-Dorg.gradle.caching=[Set true to enable Gradle build cache.]:enable build cache:(true false)' \
+ '-Dorg.gradle.console=[Set type of console output to generate.]:console output type:(plain auto rich verbose)' \
+ '-Dorg.gradle.daemon.debug=[Set true to debug Gradle Daemon.]:enable daemon debug:(true false)' \
+ '-Dorg.gradle.daemon.idletimeout=[Kill Gradle Daemon after # idle millis.]' \
+ '-Dorg.gradle.debug=[Set true to debug Gradle Client.]' \
+ '-Dorg.gradle.jvmargs=[Set JVM arguments.]' \
+ '-Dorg.gradle.java.home=[Set JDK home dir.]' \
+ '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \
+ '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:enable parallel build:(true false)' \
+ '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
+ '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \
+ '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \
+ '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \
+ '(--no-daemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \
+ '--foreground[Starts the Gradle daemon in the foreground.]' \
+ {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:file:_directories' \
+ \*--include-build'[Includes the specified build in the composite.]:file:_directories' \
+ \*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle' \
+ '(-d --debug -w --warn -q --quiet)'{-i,--info}'[Set log level to info.]' \
+ '--max-workers[Set the maximum number of concurrent workers that Gradle may use.]:number workers' \
+ {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \
+ '--no-color[Do not use color in the console output. (Removed in Gradle 3.0)]' \
+ '(--build-cache)--no-build-cache[Do not use the Gradle build cache.]' \
+ '(--configure-on-demand)--no-configure-on-demand[Disables configuration on demand.]' \
+ '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \
+ '(--parallel)--no-parallel[Disables parallel execution to build projects.]' \
+ '(--scan)--no-scan[Do not create a build scan.]' \
+ '--offline[The build should operate without accessing network resources.]' \
+ \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):' \
+ {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories' \
+ '(--no-parallel)--parallel[Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]' \
+ '--profile[Profiles build execution time and generates a report in the <build_dir>/reports/profile directory.]' \
+ '--priority[Set priority for Gradle worker processes.]:priority:(low normal)' \
+ '--project-cache-dir[Specifies the project-specific cache directory.]:cache directory:_directories' \
+ '(-d --debug -w --warn -i --info)'{-q,--quiet}'[Log errors only.]' \
+ '--recompile-scripts[Force build script recompiling.]' \
+ '--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)' \
+ '--refresh-dependencies[Refresh the state of dependencies.]' \
+ '--rerun-tasks[Ignore previously cached task results.]' \
+ '(--no-scan)--scan[Create a build scan.]' \
+ '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \
+ '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \
+ '--system-prop[system property (prop=val)]' \
+ {-t,--continuous}'[Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.]' \
+ {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \
+ '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \
+ '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \
+ '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \
+ '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \
+ {-x,--exclude-task}'[Specify a task to be excluded from execution.]' && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+(( $+functions[_gradle_dependency_configurations] )) ||
+_gradle_dependency_configurations() {
+ local configurations
+ configurations=(
+ 'compileClasspath'
+ 'runtimeClasspath'
+ 'testCompileClasspath'
+ 'testRuntimeClasspath'
+ )
+ _describe -t 'dependency configurations' "dependency configuration" configurations
+}
+
+_gradle() {
+ local cur=${words[CURRENT]}
+ local curcontext="$curcontext" state
+ integer ret=1
+ typeset -A opt_args
+
+ _arguments -C \
+ '(-)'{-\?,-h,--help}'[Shows a help message.]' \
+ {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \
+ '(--no-build-cache)--build-cache[Enable the Gradle build cache.]' \
+ {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \
+ {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \
+ {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle:->argument-expected' \
+ '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \
+ '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \
+ '--continue[Continues task execution after a task failure.]' \
+ '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \
+ '-Dorg.gradle.caching=[Set true to enable Gradle build cache.]' \
+ '-Dorg.gradle.console=[Set type of console output to generate.]:console output type:(plain auto rich verbose)' \
+ '-Dorg.gradle.daemon.debug=[Set true to debug Gradle Daemon.]' \
+ '-Dorg.gradle.daemon.idletimeout=[Kill Gradle Daemon after # idle millis.]' \
+ '-Dorg.gradle.debug=[Set true to debug Gradle Client.]' \
+ '-Dorg.gradle.jvmargs=[Set JVM arguments.]' \
+ '-Dorg.gradle.java.home=[Set JDK home dir.]' \
+ '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \
+ '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:(true false)' \
+ '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
+ '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \
+ '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \
+ '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \
+ '(--no-daemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \
+ '--foreground[Starts the Gradle daemon in the foreground.]' \
+ {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:home directory:_directories:->argument-expected' \
+ '(-)--gui[Launches the Gradle GUI. (Removed in Gradle 4.0)]' \
+ \*--include-build'[Includes the specified build in the composite.]:file:_directories:->argument-expected' \
+ \*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle:->argument-expected' \
+ '(-d --debug -w --warn -q --quiet)'{-i,--info}'[Set log level to info.]' \
+ '--max-workers[Set the maximum number of concurrent workers that Gradle may use.]:number workers:->argument-expected' \
+ {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \
+ '--no-color[Do not use color in the console output. (Removed in Gradle 3.0)]' \
+ '(--build-cache)--no-build-cache[Do not use the Gradle build cache.]' \
+ '(--configure-on-demand)--no-configure-on-demand[Disables configuration on demand.]' \
+ '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \
+ '(--parallel)--no-parallel[Disables parallel execution to build projects.]' \
+ '(--scan)--no-scan[Do not create a build scan.]' \
+ '--offline[The build should operate without accessing network resources.]' \
+ \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):->argument-expected' \
+ {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories:->argument-expected' \
+ '(--no-parallel)--parallel[Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]' \
+ '--priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
+ '--profile[Profiles build execution time and generates a report in the <build_dir>/reports/profile directory.]' \
+ '--project-cache-dir=[Specifies the project-specific cache directory.]:cache directory:_directories:->argument-expected' \
+ '(-d --debug -w --warn -i --info)'{-q,--quiet}'[Log errors only.]' \
+ '--recompile-scripts[Force build script recompiling.]' \
+ '--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)' \
+ '--refresh-dependencies[Refresh the state of dependencies.]' \
+ '--rerun-tasks[Ignore previously cached task results.]' \
+ '(--no-scan)--scan[Create a build scan.]' \
+ '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \
+ '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \
+ '(-)--status[Shows status of running and recently stopped Gradle Daemons.]' \
+ '(-)--stop[Stops all Gradle daemons.]' \
+ '--system-prop[system property (prop=val)]' \
+ {-t,--continuous}'[Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.]' \
+ {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \
+ '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \
+ '(-)'{-v,--version}'[Print version info.]' \
+ '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \
+ '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \
+ '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \
+ {-x,--exclude-task}'[Specify a task to be excluded from execution.]' \
+ '(-)*:: :->task-or-option' && ret=0
+
+ if [[ $words[CURRENT] != -* && $state != "argument-expected" ]]; then
+ __gradle_tasks && ret=0
+ else
+ curcontext=${curcontext%:*:*}:gradle-$words[1]:
+ __gradle_subcommand && ret=0
+ fi
+
+ return ret
+}
+
+_gradle "$@"
diff --git a/plugins/gradle/_gradlew b/plugins/gradle/_gradlew
deleted file mode 120000
index 80723f2fc..000000000
--- a/plugins/gradle/_gradlew
+++ /dev/null
@@ -1 +0,0 @@
-gradle.plugin.zsh \ No newline at end of file
diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
index 8df62c2e2..5bca364d1 100644
--- a/plugins/gradle/gradle.plugin.zsh
+++ b/plugins/gradle/gradle.plugin.zsh
@@ -1,183 +1,26 @@
-##############################################################################
-# A descriptive listing of core Gradle commands
-############################################################################
-
-gradle-or-gradlew() {
- if [ -f ./gradlew ] ; then
- echo "executing gradlew instead of gradle";
- ./gradlew "$@";
- else
- gradle "$@";
- fi
-}
-
-alias gradle=gradle-or-gradlew;
-
-function _gradle_core_commands() {
- local ret=1 state
- _arguments ':subcommand:->subcommand' && ret=0
-
- case $state in
- subcommand)
- subcommands=(
- "properties:Display all project properties"
- "tasks:Calculate and display all tasks"
- "dependencies:Calculate and display all dependencies"
- "projects:Discover and display all sub-projects"
- "build:Build the project"
- "help:Display help"
- )
- _describe -t subcommands 'gradle subcommands' subcommands && ret=0
- esac
-
- return ret
-}
-
-function _gradle_arguments() {
- _arguments -C \
- '-a[Do not rebuild project dependencies]' \
- '-b[Specifies the build file]' \
- '-c[Specifies the settings file]' \
- '-d[Log at the debug level]' \
- '-g[Specifies the Gradle user home directory]' \
- '-h[Shows a help message]' \
- '-i[Set log level to INFO]' \
- '-m[Runs the build with all task actions disabled]' \
- '-p[Specifies the start directory for Gradle]' \
- '-q[Log errors only]' \
- '-s[Print out the stacktrace also for user exceptions]' \
- '-t[Continuous mode. Automatically re-run build after changes]' \
- '-u[Don''t search in parent directories for a settings.gradle file]' \
- '-v[Prints Gradle version info]' \
- '-x[Specify a task to be excluded]' \
- '-D[Set a system property]' \
- '-I[Specifies an initialization script]' \
- '-P[Sets a project property of the root project]' \
- '-S[Print out the full (very verbose) stacktrace]' \
- '--build-file[Specifies the build file]' \
- '--configure-on-demand[Only relevant projects are configured]' \
- '--console[Type of console output to generate (plain, auto, or rich)]' \
- '--continue[Continues task execution after a task failure]' \
- '--continuous[Continuous mode. Automatically re-run build after changes]' \
- '--daemon[Use the Gradle Daemon]' \
- '--debug[Log at the debug level]' \
- '--dry-run[Runs the build with all task actions disabled]' \
- '--exclude-task[Specify a task to be excluded]' \
- '--full-stacktrace[Print out the full (very verbose) stacktrace]' \
- '--gradle-user-home[Specifies the Gradle user home directory]' \
- '--gui[Launches the Gradle GUI app (Deprecated)]' \
- '--help[Shows a help message]' \
- '--include-build[Run the build as a composite, including the specified build]' \
- '--info[Set log level to INFO]' \
- '--init-script[Specifies an initialization script]' \
- '--max-workers[Set the maximum number of workers that Gradle may use]' \
- '--no-daemon[Do not use the Gradle Daemon]' \
- '--no-rebuild[Do not rebuild project dependencies]' \
- '--no-search-upwards[Don''t search in parent directories for a settings.gradle file]' \
- '--offline[Build without accessing network resources]' \
- '--parallel[Build projects in parallel]' \
- '--profile[Profile build time and create report]' \
- '--project-cache-dir[Specifies the project-specific cache directory]' \
- '--project-dir[Specifies the start directory for Gradle]' \
- '--project-prop[Sets a project property of the root project]' \
- '--quiet[Log errors only]' \
- '--recompile-scripts[Forces scripts to be recompiled, bypassing caching]' \
- '--refresh-dependencies[Refresh the state of dependencies]' \
- '--rerun-task[Specifies that any task optimization is ignored]' \
- '--settings-file[Specifies the settings file]' \
- '--stacktrace[Print out the stacktrace also for user exceptions]' \
- '--status[Print Gradle Daemon status]' \
- '--stop[Stop all Gradle Daemons]' \
- '--system-prop[Set a system property]' \
- '--version[Prints Gradle version info]' \
- '*::command:->command' \
- && return 0
-}
-
-
-##############################################################################
-# Examine the build.gradle file to see if its timestamp has changed;
-# and if so, regenerate the .gradle_tasks cache file
-############################################################################
-_gradle_does_task_list_need_generating () {
- [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache || build.gradle.kts -nt .gradletasknamecache ]]
-}
-
-##############
-# Parse the tasks from `gradle(w) tasks --all` and return them to the calling function.
-# All lines in the output from gradle(w) that are between /^-+$/ and /^\s*$/
-# are considered to be tasks. If and when gradle adds support for listing tasks
-# for programmatic parsing, this method can be deprecated.
-##############
-_gradle_parse_tasks () {
- lines_might_be_tasks=false
- task_name_buffer=""
- while read -r line; do
- if [[ $line =~ ^-+$ ]]; then
- lines_might_be_tasks=true
- # Empty buffer, because it contains items that are not tasks
- task_name_buffer=""
- elif [[ $line =~ ^\s*$ ]]; then
- if [[ "$lines_might_be_tasks" = true ]]; then
- # If a newline is found, echo the buffer to the calling function
- while read -r task; do
- echo $task | awk '/[a-zA-Z0-9:-]+/ {print $1}'
- done <<< "$task_name_buffer"
- # Empty buffer, because we are done with the tasks
- task_name_buffer=""
- fi
- lines_might_be_tasks=false
- elif [[ "$lines_might_be_tasks" = true ]]; then
- task_name_buffer="${task_name_buffer}\n${line}"
- fi
- done <<< "$1"
-}
-
-
-##############
-# Gradle tasks from subprojects are allowed to be executed without specifying
-# the subproject; that task will then be called on all subprojects.
-# gradle(w) tasks --all only lists tasks per subproject, but when autocompleting
-# we often want to be able to run a specific task on all subprojects, e.g.
-# "gradle clean".
-# This function uses the list of tasks from "gradle tasks --all", and for each
-# line grabs everything after the last ":" and combines that output with the original
-# output. The combined list is returned as the result of this function.
-##############
-_gradle_parse_and_extract_tasks () {
- # All tasks
- tasks=$(_gradle_parse_tasks "$1")
- # Task name without sub project(s) prefix
- simple_tasks=$(echo $tasks | awk 'BEGIN { FS = ":" } { print $NF }')
- echo "$tasks\n$simple_tasks"
-}
-
-##############################################################################
-# Discover the gradle tasks by running "gradle tasks --all"
-############################################################################
-_gradle_tasks () {
- if [[ -f build.gradle || -f build.gradle.kts ]]; then
- _gradle_arguments
- if _gradle_does_task_list_need_generating; then
- _gradle_parse_and_extract_tasks "$(gradle tasks --all)" > .gradletasknamecache
- fi
- compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache)
- fi
-}
-
-_gradlew_tasks () {
- if [[ -f build.gradle || -f build.gradle.kts ]]; then
- _gradle_arguments
- if _gradle_does_task_list_need_generating; then
- _gradle_parse_and_extract_tasks "$(./gradlew tasks --all)" > .gradletasknamecache
+# Looks for a gradlew file in the current working directory
+# or any of its parent directories, and executes it if found.
+# Otherwise it will call gradle directly.
+function gradle-or-gradlew() {
+ # find project root
+ # taken from https://github.com/gradle/gradle-completion
+ local dir="$PWD" project_root="$PWD"
+ while [[ "$dir" != / ]]; do
+ if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then
+ project_root="$dir"
+ break
fi
- compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache)
+ dir="${dir:h}"
+ done
+
+ # if gradlew found, run it instead of gradle
+ if [[ -f "$project_root/gradlew" ]]; then
+ echo "executing gradlew instead of gradle"
+ "$project_root/gradlew" "$@"
+ else
+ command gradle "$@"
fi
}
-
-##############################################################################
-# Register the completions against the gradle and gradlew commands
-############################################################################
-compdef _gradle_tasks gradle
-compdef _gradlew_tasks gradlew
+alias gradle=gradle-or-gradlew
+compdef _gradle gradle-or-gradlew
diff --git a/plugins/grails/README.md b/plugins/grails/README.md
index 64b4a9f07..5d9ebd77d 100644
--- a/plugins/grails/README.md
+++ b/plugins/grails/README.md
@@ -14,58 +14,3 @@ It looks for scripts in the following paths:
- `~/.grails/scripts`
- `./scripts`
- `./plugins/*/scripts`
-
-## Grails Commands
-- `add-proxy`
-- `alias`
-- `bootstrap`
-- `bug-report`
-- `clean`
-- `clean-all`
-- `clear-proxy`
-- `compile`
-- `console`
-- `create-app`
-- `create-controller`
-- `create-domain-class`
-- `create-filters`
-- `create-integration-test`
-- `create-multi-project-build`
-- `create-plugin`
-- `create-pom`
-- `create-script`
-- `create-service`
-- `create-tag-lib`
-- `create-unit-test`
-- `dependency-report`
-- `doc`
-- `help`
-- `init`
-- `install-app-templates`
-- `install-dependency`
-- `install-plugin`
-- `install-templates`
-- `integrate-with`
-- `interactive`
-- `list-plugin-updates`
-- `list-plugins`
-- `migrate-docs`
-- `package`
-- `package-plugin`
-- `plugin-info`
-- `refresh-dependencies`
-- `remove-proxy`
-- `run-app`
-- `run-script`
-- `run-war`
-- `set-grails-version`
-- `set-proxy`
-- `set-version`
-- `shell`
-- `stats`
-- `stop-app`
-- `test-app`
-- `uninstall-plugin`
-- `url-mappings-report`
-- `war`
-- `wrapper`
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/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh
index 2b3105135..6234302c5 100644
--- a/plugins/gulp/gulp.plugin.zsh
+++ b/plugins/gulp/gulp.plugin.zsh
@@ -11,7 +11,7 @@
#
# André König
-# Github: https://github.com/akoenig
+# GitHub: https://github.com/akoenig
# Twitter: https://twitter.com/caiifr
#
@@ -19,11 +19,11 @@
# Grabs all available tasks from the `gulpfile.js`
# in the current directory.
#
-function $$gulp_completion {
+function _gulp_completion {
compls=$(gulp --tasks-simple 2>/dev/null)
completions=(${=compls})
compadd -- $completions
}
-compdef $$gulp_completion gulp
+compdef _gulp_completion gulp
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/history-substring-search/README.md b/plugins/history-substring-search/README.md
index 7fb0fa0b6..6d8b56425 100644
--- a/plugins/history-substring-search/README.md
+++ b/plugins/history-substring-search/README.md
@@ -1,25 +1,44 @@
-zsh-history-substring-search
-==============================================================================
+# zsh-history-substring-search
This is a clean-room implementation of the [Fish shell][1]'s history search
-feature, where you can type in any part of any previously entered command
-and press the UP and DOWN arrow keys to cycle through the matching commands.
-You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same.
+feature, where you can type in any part of any command from history and then
+press chosen keys, such as the UP and DOWN arrows, to cycle through matches.
-[1]: https://fishshell.com
-[2]: https://www.zsh.org/mla/users/2009/msg00818.html
-[3]: https://sourceforge.net/projects/fizsh/
+[1]: http://fishshell.com
+[2]: http://www.zsh.org/mla/users/2009/msg00818.html
+[3]: http://sourceforge.net/projects/fizsh/
[4]: https://github.com/robbyrussell/oh-my-zsh/pull/215
[5]: https://github.com/zsh-users/zsh-history-substring-search
[6]: https://github.com/zsh-users/zsh-syntax-highlighting
-------------------------------------------------------------------------------
+
Requirements
------------------------------------------------------------------------------
* [ZSH](http://zsh.sourceforge.net) 4.3 or newer
+Install
------------------------------------------------------------------------------
+
+Using the [Homebrew]( https://brew.sh ) package manager:
+
+ brew install zsh-history-substring-search
+ echo 'source /usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
+
+Using [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh):
+
+1. Clone this repository in oh-my-zsh's plugins directory:
+
+ git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
+
+2. Activate the plugin in `~/.zshrc`:
+
+ plugins=( [plugins...] history-substring-search)
+
+3. Source `~/.zshrc` to take changes into account:
+
+ source ~/.zshrc
+
Usage
------------------------------------------------------------------------------
@@ -33,117 +52,147 @@ Usage
% source zsh-syntax-highlighting.zsh
% source zsh-history-substring-search.zsh
-2. Bind keyboard shortcuts to this script's functions:
+2. Bind keyboard shortcuts to this script's functions.
+
+ Users typically bind their UP and DOWN arrow keys to this script, thus:
+ * Run `cat -v` in your favorite terminal emulator to observe key codes.
+      (**NOTE:** In some cases, `cat -v` shows the wrong key codes. If the
+ key codes shown by `cat -v` don't work for you, press `<C-v><UP>` and
+ `<C-v><DOWN>` at your ZSH command line prompt for correct key codes.)
+ * Press the UP arrow key and observe what is printed in your terminal.
+ * Press the DOWN arrow key and observe what is printed in your terminal.
+ * Press the Control and C keys simultaneously to terminate the `cat -v`.
+ * Use your observations from the previous steps to create key bindings.
+ For example, if you observed `^[[A` for UP and `^[[B` for DOWN, then:
+
+ bindkey '^[[A' history-substring-search-up
+ bindkey '^[[B' history-substring-search-down
- # bind UP and DOWN arrow keys
- zmodload zsh/terminfo
- bindkey "$terminfo[kcuu1]" history-substring-search-up
- bindkey "$terminfo[kcud1]" history-substring-search-down
+ However, if the observed values don't work, you can try using terminfo:
- # bind UP and DOWN arrow keys (compatibility fallback
- # for Ubuntu 12.04, Fedora 21, and MacOSX 10.9 users)
- bindkey '^[[A' history-substring-search-up
- bindkey '^[[B' history-substring-search-down
+ bindkey "$terminfo[kcuu1]" history-substring-search-up
+ bindkey "$terminfo[kcud1]" history-substring-search-down
- # bind P and N for EMACS mode
- bindkey -M emacs '^P' history-substring-search-up
- bindkey -M emacs '^N' history-substring-search-down
+ You might also want to bind the Control-P/N keys for use in EMACS mode:
- # bind k and j for VI mode
- bindkey -M vicmd 'k' history-substring-search-up
- bindkey -M vicmd 'j' history-substring-search-down
+ bindkey -M emacs '^P' history-substring-search-up
+ bindkey -M emacs '^N' history-substring-search-down
+
+ You might also want to bind the `k` and `j` keys for use in VI mode:
+
+ bindkey -M vicmd 'k' history-substring-search-up
+ bindkey -M vicmd 'j' history-substring-search-down
3. Type any part of any previous command and then:
- * Press the UP arrow key to select the nearest command that (1) contains
- your query and (2) is older than the current command in the command
- history.
+ * Press the `history-substring-search-up` key, which was configured in
+ step 2 above, to select the nearest command that (1) contains your query
+ and (2) is also older than the current command in your command history.
- * Press the DOWN arrow key to select the nearest command that (1)
- contains your query and (2) is newer than the current command in the
- command history.
+ * Press the `history-substring-search-down` key, which was configured in
+ step 2 above, to select the nearest command that (1) contains your query
+ and (2) is also newer than the current command in your command history.
- * Press ^U (the Control and U keys simultaneously) to abort the search.
+ * Press `^U` the Control and U keys simultaneously to abort the search.
4. If a matching command spans more than one line of text, press the LEFT
arrow key to move the cursor away from the end of the command, and then:
- * Press the UP arrow key to move the cursor to the line above. When the
- cursor reaches the first line of the command, pressing the UP arrow
- key again will cause this script to perform another search.
+ * Press the `history-substring-search-up` key, which was configured in
+ step 2 above, to move the cursor to the line above the cursored line.
+ When the cursor reaches the first line of the command, pressing the
+ `history-substring-search-up` key again will cause this script to
+ perform another search.
+
+ * Press the `history-substring-search-down` key, which was configured in
+ step 2 above, to move the cursor to the line below the cursored line.
+ When the cursor reaches the last line of the command, pressing the
+ `history-substring-search-down` key, which was configured in step 2
+ above, again will cause this script to perform another search.
- * Press the DOWN arrow key to move the cursor to the line below. When
- the cursor reaches the last line of the command, pressing the DOWN
- arrow key again will cause this script to perform another search.
-------------------------------------------------------------------------------
Configuration
------------------------------------------------------------------------------
This script defines the following global variables. You may override their
default values only after having loaded this script into your ZSH session.
-* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND is a global variable that defines
+* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND` is a global variable that defines
how the query should be highlighted inside a matching command. Its default
value causes this script to highlight using bold, white text on a magenta
background. See the "Character Highlighting" section in the zshzle(1) man
page to learn about the kinds of values you may assign to this variable.
-* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND is a global variable that
+* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND` is a global variable that
defines how the query should be highlighted when no commands in the
history match it. Its default value causes this script to highlight using
bold, white text on a red background. See the "Character Highlighting"
section in the zshzle(1) man page to learn about the kinds of values you
may assign to this variable.
-* HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS is a global variable that defines
+* `HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS` is a global variable that defines
how the command history will be searched for your query. Its default value
causes this script to perform a case-insensitive search. See the "Globbing
Flags" section in the zshexpn(1) man page to learn about the kinds of
values you may assign to this variable.
-To always receive _unique_ search results, use `setopt HIST_IGNORE_ALL_DUPS`.
-Alternatively, use `setopt HIST_FIND_NO_DUPS` which makes this plugin skip
-duplicate _adjacent_ search results as you cycle through them---however, this
-does not guarantee that search results are unique: if your search results were
-"Dog", "Dog", "HotDog", "Dog", then cycling them gives "Dog", "HotDog", "Dog".
-Notice that the "Dog" search result appeared twice as you cycled through them!
-If you wish to avoid this limitation, then use `setopt HIST_IGNORE_ALL_DUPS`.
+* `HISTORY_SUBSTRING_SEARCH_FUZZY` is a global variable that defines
+ how the command history will be searched for your query. If set to a non-empty
+ value, causes this script to perform a fuzzy search by words, matching in
+ given order e.g. `ab c` will match `*ab*c*`
+
+* `HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE` is a global variable that defines
+ whether all search results returned are _unique_. If set to a non-empty
+ value, then only unique search results are presented. This behaviour is off
+ by default. An alternative way to ensure that search results are unique is
+ to use `setopt HIST_IGNORE_ALL_DUPS`. If this configuration variable is off
+ and `setopt HIST_IGNORE_ALL_DUPS` is unset, then `setopt HIST_FIND_NO_DUPS`
+ is still respected and it makes this script skip duplicate _adjacent_ search
+ results as you cycle through them, but this does not guarantee that search
+ results are unique: if your search results were "Dog", "Dog", "HotDog",
+ "Dog", then cycling them gives "Dog", "HotDog", "Dog". Notice that the "Dog"
+ search result appeared twice as you cycled through them. If you wish to
+ receive globally unique search results only once, then use this
+ configuration variable, or use `setopt HIST_IGNORE_ALL_DUPS`.
+
-------------------------------------------------------------------------------
History
------------------------------------------------------------------------------
-This script was originally written by [Peter Stephenson][2], who published it
-to the ZSH users mailing list (thereby making it public domain) in September
-2009. It was later revised by Guido van Steen and released under the BSD
-license (see below) as part of [the fizsh project][3] in January 2011.
+* September 2009: [Peter Stephenson][2] originally wrote this script and it
+ published to the zsh-users mailing list.
+
+* January 2011: Guido van Steen (@guidovansteen) revised this script and
+ released it under the 3-clause BSD license as part of [fizsh][3], the
+ Friendly Interactive ZSHell.
+
+* January 2011: Suraj N. Kurapati (@sunaku) extracted this script from
+ [fizsh][3] 1.0.1, refactored it heavily, and finally repackaged it as an
+ [oh-my-zsh plugin][4] and as an independently loadable [ZSH script][5].
-It was later extracted from fizsh release 1.0.1, refactored heavily, and
-repackaged as both an [oh-my-zsh plugin][4] and as an independently loadable
-[ZSH script][5] by Suraj N. Kurapati in 2011.
+* July 2011: Guido van Steen, Suraj N. Kurapati, and Sorin Ionescu
+ (@sorin-ionescu) [further developed it][4] with Vincent Guerci (@vguerci).
-It was [further developed][4] by Guido van Steen, Suraj N. Kurapati, Sorin
-Ionescu, and Vincent Guerci in 2011.
+* March 2016: Geza Lore (@gezalore) greatly refactored it in pull request #55.
------------------------------------------------------------------------------
Oh My Zsh Distribution Notes
------------------------------------------------------------------------------
-What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search
+What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search
as an OMZ module inside the Oh My Zsh distribution.
-The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at
+The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at
https://github.com/zsh-users/zsh-history-substring-search.
This downstream copy was last updated from the following upstream commit:
- SHA: 2c295432175990c1bb4e90bc13f609daa67a25d6
- Commit date: 2015-09-28 10:47:34 -0700
+ SHA: 0f80b8eb3368b46e5e573c1d91ae69eb095db3fb
+ Commit date: 2019-05-12 17:35:54 -0700
Everything above this section is a copy of the original upstream's README, so things
may differ slightly when you're using this inside OMZ. In particular, you do not
-need to set up key bindings for the up and down arrows yourself in `~/.zshrc`; the OMZ
+need to set up key bindings for the up and down arrows yourself in `~/.zshrc`; the OMZ
plugin does that for you. You may still want to set up additional emacs- or vi-specific
bindings as mentioned above.
diff --git a/plugins/history-substring-search/history-substring-search.plugin.zsh b/plugins/history-substring-search/history-substring-search.plugin.zsh
index 7883a65f3..d2c749bc3 100644
--- a/plugins/history-substring-search/history-substring-search.plugin.zsh
+++ b/plugins/history-substring-search/history-substring-search.plugin.zsh
@@ -1,20 +1,9 @@
-# This file integrates the zsh-history-substring-search script into oh-my-zsh.
-
-source "${0:r:r}.zsh"
-
-if test "$CASE_SENSITIVE" = true; then
- unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS
-fi
-
-if test "$DISABLE_COLOR" = true; then
- unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
-fi
+0=${(%):-%N}
+source ${0:A:h}/history-substring-search.zsh
# Bind terminal-specific up and down keys
-# Bind in both emacs and vi modes so it works in both, and is not
-# sensitive to whether this is loaded before or after the vi-mode plugin
+
if [[ -n "$terminfo[kcuu1]" ]]; then
bindkey -M emacs "$terminfo[kcuu1]" history-substring-search-up
bindkey -M viins "$terminfo[kcuu1]" history-substring-search-up
diff --git a/plugins/history-substring-search/history-substring-search.zsh b/plugins/history-substring-search/history-substring-search.zsh
index 3b8afd317..a791cc4da 100644
--- a/plugins/history-substring-search/history-substring-search.zsh
+++ b/plugins/history-substring-search/history-substring-search.zsh
@@ -6,6 +6,8 @@
# Copyright (c) 2011 Suraj N. Kurapati
# Copyright (c) 2011 Sorin Ionescu
# Copyright (c) 2011 Vincent Guerci
+# Copyright (c) 2016 Geza Lore
+# Copyright (c) 2017 Bengt Brodersen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -38,12 +40,30 @@
##############################################################################
#-----------------------------------------------------------------------------
-# configuration variables
+# declare global configuration variables
#-----------------------------------------------------------------------------
-HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
-HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
-HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
+typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
+typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
+typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
+typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=''
+typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY=''
+
+#-----------------------------------------------------------------------------
+# declare internal global variables
+#-----------------------------------------------------------------------------
+
+typeset -g BUFFER MATCH MBEGIN MEND CURSOR
+typeset -g _history_substring_search_refresh_display
+typeset -g _history_substring_search_query_highlight
+typeset -g _history_substring_search_result
+typeset -g _history_substring_search_query
+typeset -g -a _history_substring_search_query_parts
+typeset -g -a _history_substring_search_raw_matches
+typeset -g -i _history_substring_search_raw_match_index
+typeset -g -a _history_substring_search_matches
+typeset -g -i _history_substring_search_match_index
+typeset -g -A _history_substring_search_unique_filter
#-----------------------------------------------------------------------------
# the main ZLE widgets
@@ -180,62 +200,104 @@ _history-substring-search-begin() {
_history_substring_search_query_highlight=
#
- # Continue using the previous $_history_substring_search_result by default,
- # unless the current query was cleared or a new/different query was entered.
+ # If the buffer is the same as the previously displayed history substring
+ # search result, then just keep stepping through the match list. Otherwise
+ # start a new search.
#
- if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then
- #
- # For the purpose of highlighting we will also keep
- # a version without doubly-escaped meta characters.
- #
- _history_substring_search_query=$BUFFER
+ if [[ -n $BUFFER && $BUFFER == ${_history_substring_search_result:-} ]]; then
+ return;
+ fi
+ #
+ # Clear the previous result.
+ #
+ _history_substring_search_result=''
+
+ if [[ -z $BUFFER ]]; then
#
- # $BUFFER contains the text that is in the command-line currently.
- # we put an extra "\\" before meta characters such as "\(" and "\)",
- # so that they become "\\\(" and "\\\)".
+ # If the buffer is empty, we will just act like up-history/down-history
+ # in ZSH, so we do not need to actually search the history. This should
+ # speed things up a little.
#
- _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH}
+ _history_substring_search_query=
+ _history_substring_search_query_parts=()
+ _history_substring_search_raw_matches=()
+ else
#
- # Find all occurrences of the search query in the history file.
- #
- # (k) returns the "keys" (history index numbers) instead of the values
- # (Oa) reverses the order, because (R) returns results reversed.
+ # For the purpose of highlighting we keep a copy of the original
+ # query string.
#
- _history_substring_search_matches=(${(kOa)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})
+ _history_substring_search_query=$BUFFER
#
- # Define the range of values that $_history_substring_search_match_index
- # can take: [0, $_history_substring_search_matches_count_plus].
+ # compose search pattern
#
- _history_substring_search_matches_count=$#_history_substring_search_matches
- _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 ))
- _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 ))
+ if [[ -n $HISTORY_SUBSTRING_SEARCH_FUZZY ]]; then
+ #
+ # `=` split string in arguments
+ #
+ _history_substring_search_query_parts=(${=_history_substring_search_query})
+ else
+ _history_substring_search_query_parts=(${==_history_substring_search_query})
+ fi
#
- # If $_history_substring_search_match_index is equal to
- # $_history_substring_search_matches_count_plus, this indicates that we
- # are beyond the beginning of $_history_substring_search_matches.
+ # Escape and join query parts with wildcard character '*' as seperator
+ # `(j:CHAR:)` join array to string with CHAR as seperator
#
- # If $_history_substring_search_match_index is equal to 0, this indicates
- # that we are beyond the end of $_history_substring_search_matches.
+ local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
+
#
- # If we have initially pressed "up" we have to initialize
- # $_history_substring_search_match_index to
- # $_history_substring_search_matches_count_plus so that it will be
- # decreased to $_history_substring_search_matches_count.
+ # Find all occurrences of the search pattern in the history file.
#
- # If we have initially pressed "down" we have to initialize
- # $_history_substring_search_match_index to
- # $_history_substring_search_matches_count so that it will be increased to
- # $_history_substring_search_matches_count_plus.
+ # (k) returns the "keys" (history index numbers) instead of the values
+ # (R) returns values in reverse older, so the index of the youngest
+ # matching history entry is at the head of the list.
#
- if [[ $WIDGET == history-substring-search-down ]]; then
- _history_substring_search_match_index=$_history_substring_search_matches_count
- else
- _history_substring_search_match_index=$_history_substring_search_matches_count_plus
- fi
+ _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${search_pattern}]})
+ fi
+
+ #
+ # In order to stay as responsive as possible, we will process the raw
+ # matches lazily (when the user requests the next match) to choose items
+ # that need to be displayed to the user.
+ # _history_substring_search_raw_match_index holds the index of the last
+ # unprocessed entry in _history_substring_search_raw_matches. Any items
+ # that need to be displayed will be added to
+ # _history_substring_search_matches.
+ #
+ # We use an associative array (_history_substring_search_unique_filter) as
+ # a 'set' data structure to ensure uniqueness of the results if desired.
+ # If an entry (key) is in the set (non-empty value), then we have already
+ # added that entry to _history_substring_search_matches.
+ #
+ _history_substring_search_raw_match_index=0
+ _history_substring_search_matches=()
+ _history_substring_search_unique_filter=()
+
+ #
+ # If $_history_substring_search_match_index is equal to
+ # $#_history_substring_search_matches + 1, this indicates that we
+ # are beyond the end of $_history_substring_search_matches and that we
+ # have also processed all entries in
+ # _history_substring_search_raw_matches.
+ #
+ # If $#_history_substring_search_match_index is equal to 0, this indicates
+ # that we are beyond the beginning of $_history_substring_search_matches.
+ #
+ # If we have initially pressed "up" we have to initialize
+ # $_history_substring_search_match_index to 0 so that it will be
+ # incremented to 1.
+ #
+ # If we have initially pressed "down" we have to initialize
+ # $_history_substring_search_match_index to 1 so that it will be
+ # decremented to 0.
+ #
+ if [[ $WIDGET == history-substring-search-down ]]; then
+ _history_substring_search_match_index=1
+ else
+ _history_substring_search_match_index=0
fi
}
@@ -255,16 +317,21 @@ _history-substring-search-end() {
_zsh_highlight
# highlight the search query inside the command line
- if [[ -n $_history_substring_search_query_highlight && -n $_history_substring_search_query ]]; then
- #
- # The following expression yields a variable $MBEGIN, which
- # indicates the begin position + 1 of the first occurrence
- # of _history_substring_search_query_escaped in $BUFFER.
- #
- : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)}
- local begin=$(( MBEGIN - 1 ))
- local end=$(( begin + $#_history_substring_search_query ))
- region_highlight+=("$begin $end $_history_substring_search_query_highlight")
+ if [[ -n $_history_substring_search_query_highlight ]]; then
+ # highlight first matching query parts
+ local highlight_start_index=0
+ local highlight_end_index=0
+ local query_part
+ for query_part in $_history_substring_search_query_parts; do
+ local escaped_query_part=${query_part//(#m)[\][()|\\*?#<>~^]/\\$MATCH}
+ # (i) get index of pattern
+ local query_part_match_index="${${BUFFER:$highlight_start_index}[(i)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${escaped_query_part}]}"
+ if [[ $query_part_match_index -le ${#BUFFER:$highlight_start_index} ]]; then
+ highlight_start_index=$(( $highlight_start_index + $query_part_match_index ))
+ highlight_end_index=$(( $highlight_start_index + ${#query_part} ))
+ region_highlight+=("$(($highlight_start_index - 1)) $(($highlight_end_index - 1)) $_history_substring_search_query_highlight")
+ fi
+ done
fi
# For debugging purposes:
@@ -378,12 +445,143 @@ _history-substring-search-down-history() {
return 1
}
+_history_substring_search_process_raw_matches() {
+ #
+ # Process more outstanding raw matches and append any matches that need to
+ # be displayed to the user to _history_substring_search_matches.
+ # Return whether there were any more results appended.
+ #
+
+ #
+ # While we have more raw matches. Process them to see if there are any more
+ # matches that need to be displayed to the user.
+ #
+ while [[ $_history_substring_search_raw_match_index -lt $#_history_substring_search_raw_matches ]]; do
+ #
+ # Move on to the next raw entry and get its history index.
+ #
+ _history_substring_search_raw_match_index+=1
+ local index=${_history_substring_search_raw_matches[$_history_substring_search_raw_match_index]}
+
+ #
+ # If HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set to a non-empty value,
+ # then ensure that only unique matches are presented to the user.
+ # When HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history,
+ # so in this case we do not need to do anything.
+ #
+ if [[ ! -o HIST_IGNORE_ALL_DUPS && -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then
+ #
+ # Get the actual history entry at the new index, and check if we have
+ # already added it to _history_substring_search_matches.
+ #
+ local entry=${history[$index]}
+
+ if [[ -z ${_history_substring_search_unique_filter[$entry]} ]]; then
+ #
+ # This is a new unique entry. Add it to the filter and append the
+ # index to _history_substring_search_matches.
+ #
+ _history_substring_search_unique_filter[$entry]=1
+ _history_substring_search_matches+=($index)
+
+ #
+ # Indicate that we did find a match.
+ #
+ return 0
+ fi
+
+ else
+ #
+ # Just append the new history index to the processed matches.
+ #
+ _history_substring_search_matches+=($index)
+
+ #
+ # Indicate that we did find a match.
+ #
+ return 0
+ fi
+
+ done
+
+ #
+ # We are beyond the end of the list of raw matches. Indicate that no
+ # more matches are available.
+ #
+ return 1
+}
+
+_history-substring-search-has-next() {
+ #
+ # Predicate function that returns whether any more older matches are
+ # available.
+ #
+
+ if [[ $_history_substring_search_match_index -lt $#_history_substring_search_matches ]]; then
+ #
+ # We did not reach the end of the processed list, so we do have further
+ # matches.
+ #
+ return 0
+
+ else
+ #
+ # We are at the end of the processed list. Try to process further
+ # unprocessed matches. _history_substring_search_process_raw_matches
+ # returns whether any more matches were available, so just return
+ # that result.
+ #
+ _history_substring_search_process_raw_matches
+ return $?
+ fi
+}
+
+_history-substring-search-has-prev() {
+ #
+ # Predicate function that returns whether any more younger matches are
+ # available.
+ #
+
+ if [[ $_history_substring_search_match_index -gt 1 ]]; then
+ #
+ # We did not reach the beginning of the processed list, so we do have
+ # further matches.
+ #
+ return 0
+
+ else
+ #
+ # We are at the beginning of the processed list. We do not have any more
+ # matches.
+ #
+ return 1
+ fi
+}
+
+_history-substring-search-found() {
+ #
+ # A match is available. The index of the match is held in
+ # $_history_substring_search_match_index
+ #
+ # 1. Make $BUFFER equal to the matching history entry.
+ #
+ # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+ # to highlight the current buffer.
+ #
+ BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
+ _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+}
+
_history-substring-search-not-found() {
#
- # Nothing matched the search query, so put it back into the $BUFFER while
- # highlighting it accordingly so the user can revise it and search again.
+ # No more matches are available.
+ #
+ # 1. Make $BUFFER equal to $_history_substring_search_query so the user can
+ # revise it and search again.
+ #
+ # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
+ # to highlight the current buffer.
#
- _history_substring_search_old_buffer=$BUFFER
BUFFER=$_history_substring_search_query
_history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
}
@@ -392,91 +590,84 @@ _history-substring-search-up-search() {
_history_substring_search_refresh_display=1
#
- # Highlight matches during history-substring-up-search:
+ # Select history entry during history-substring-down-search:
#
- # The following constants have been initialized in
+ # The following variables have been initialized in
# _history-substring-search-up/down-search():
#
- # $_history_substring_search_matches is the current list of matches
- # $_history_substring_search_matches_count is the current number of matches
- # $_history_substring_search_matches_count_plus is the current number of matches + 1
- # $_history_substring_search_matches_count_sans is the current number of matches - 1
+ # $_history_substring_search_matches is the current list of matches that
+ # need to be displayed to the user.
# $_history_substring_search_match_index is the index of the current match
+ # that is being displayed to the user.
#
# The range of values that $_history_substring_search_match_index can take
- # is: [0, $_history_substring_search_matches_count_plus]. A value of 0
- # indicates that we are beyond the end of
+ # is: [0, $#_history_substring_search_matches + 1]. A value of 0
+ # indicates that we are beyond the beginning of
# $_history_substring_search_matches. A value of
- # $_history_substring_search_matches_count_plus indicates that we are beyond
- # the beginning of $_history_substring_search_matches.
+ # $#_history_substring_search_matches + 1 indicates that we are beyond
+ # the end of $_history_substring_search_matches and that we have also
+ # processed all entries in _history_substring_search_raw_matches.
+ #
+ # If $_history_substring_search_match_index equals
+ # $#_history_substring_search_matches and
+ # $_history_substring_search_raw_match_index is not greater than
+ # $#_history_substring_search_raw_matches, then we need to further process
+ # $_history_substring_search_raw_matches to see if there are any more
+ # entries that need to be displayed to the user.
#
# In _history-substring-search-up-search() the initial value of
- # $_history_substring_search_match_index is
- # $_history_substring_search_matches_count_plus. This value is set in
- # _history-substring-search-begin(). _history-substring-search-up-search()
- # will initially decrease it to $_history_substring_search_matches_count.
+ # $_history_substring_search_match_index is 0. This value is set in
+ # _history-substring-search-begin(). _history-substring-search-up-search()
+ # will initially increment it to 1.
#
- if [[ $_history_substring_search_match_index -ge 2 ]]; then
- #
- # Highlight the next match:
- #
- # 1. Decrease the value of $_history_substring_search_match_index.
- #
- # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- # to highlight the current buffer.
- #
- (( _history_substring_search_match_index-- ))
- BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
- _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- elif [[ $_history_substring_search_match_index -eq 1 ]]; then
- #
- # We will move beyond the end of $_history_substring_search_matches:
- #
- # 1. Decrease the value of $_history_substring_search_match_index.
- #
- # 2. Save the current buffer in $_history_substring_search_old_buffer,
- # so that it can be retrieved by
- # _history-substring-search-down-search() later.
+ if [[ $_history_substring_search_match_index -gt $#_history_substring_search_matches ]]; then
#
- # 3. Make $BUFFER equal to $_history_substring_search_query.
+ # We are beyond the end of $_history_substring_search_matches. This
+ # can only happen if we have also exhausted the unprocessed matches in
+ # _history_substring_search_raw_matches.
#
- # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
- # to highlight the current buffer.
+ # 1. Update display to indicate search not found.
#
- (( _history_substring_search_match_index-- ))
_history-substring-search-not-found
+ return
+ fi
- elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then
- #
- # We were beyond the beginning of $_history_substring_search_matches but
- # UP makes us move back to $_history_substring_search_matches:
- #
- # 1. Decrease the value of $_history_substring_search_match_index.
+ if _history-substring-search-has-next; then
#
- # 2. Restore $BUFFER from $_history_substring_search_old_buffer.
+ # We do have older matches.
#
- # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- # to highlight the current buffer.
+ # 1. Move index to point to the next match.
+ # 2. Update display to indicate search found.
#
- (( _history_substring_search_match_index-- ))
- BUFFER=$_history_substring_search_old_buffer
- _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+ _history_substring_search_match_index+=1
+ _history-substring-search-found
else
#
- # We are at the beginning of history and there are no further matches.
+ # We do not have older matches.
#
+ # 1. Move the index beyond the end of
+ # _history_substring_search_matches.
+ # 2. Update display to indicate search not found.
+ #
+ _history_substring_search_match_index+=1
_history-substring-search-not-found
- return
fi
#
# When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from
# history should be matched, make sure the new and old results are different.
- # But when HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history.
#
- if [[ ! -o HIST_IGNORE_ALL_DUPS && -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then
+ # However, if the HIST_IGNORE_ALL_DUPS shell option, or
+ # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a
+ # unique history, so in this case we do not need to do anything.
+ #
+ if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then
+ return
+ fi
+
+ if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then
#
# Repeat the current search so that a different (unique) match is found.
#
@@ -488,92 +679,75 @@ _history-substring-search-down-search() {
_history_substring_search_refresh_display=1
#
- # Highlight matches during history-substring-up-search:
+ # Select history entry during history-substring-down-search:
#
- # The following constants have been initialized in
+ # The following variables have been initialized in
# _history-substring-search-up/down-search():
#
- # $_history_substring_search_matches is the current list of matches
- # $_history_substring_search_matches_count is the current number of matches
- # $_history_substring_search_matches_count_plus is the current number of matches + 1
- # $_history_substring_search_matches_count_sans is the current number of matches - 1
+ # $_history_substring_search_matches is the current list of matches that
+ # need to be displayed to the user.
# $_history_substring_search_match_index is the index of the current match
+ # that is being displayed to the user.
#
# The range of values that $_history_substring_search_match_index can take
- # is: [0, $_history_substring_search_matches_count_plus]. A value of 0
- # indicates that we are beyond the end of
+ # is: [0, $#_history_substring_search_matches + 1]. A value of 0
+ # indicates that we are beyond the beginning of
# $_history_substring_search_matches. A value of
- # $_history_substring_search_matches_count_plus indicates that we are beyond
- # the beginning of $_history_substring_search_matches.
+ # $#_history_substring_search_matches + 1 indicates that we are beyond
+ # the end of $_history_substring_search_matches and that we have also
+ # processed all entries in _history_substring_search_raw_matches.
#
# In _history-substring-search-down-search() the initial value of
- # $_history_substring_search_match_index is
- # $_history_substring_search_matches_count. This value is set in
- # _history-substring-search-begin().
- # _history-substring-search-down-search() will initially increase it to
- # $_history_substring_search_matches_count_plus.
+ # $_history_substring_search_match_index is 1. This value is set in
+ # _history-substring-search-begin(). _history-substring-search-down-search()
+ # will initially decrement it to 0.
#
- if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then
- #
- # Highlight the next match:
- #
- # 1. Increase $_history_substring_search_match_index by 1.
- #
- # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- # to highlight the current buffer.
- #
- (( _history_substring_search_match_index++ ))
- BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
- _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then
- #
- # We will move beyond the beginning of $_history_substring_search_matches:
- #
- # 1. Increase $_history_substring_search_match_index by 1.
+ if [[ $_history_substring_search_match_index -lt 1 ]]; then
#
- # 2. Save the current buffer in $_history_substring_search_old_buffer, so
- # that it can be retrieved by _history-substring-search-up-search()
- # later.
+ # We are beyond the beginning of $_history_substring_search_matches.
#
- # 3. Make $BUFFER equal to $_history_substring_search_query.
+ # 1. Update display to indicate search not found.
#
- # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
- # to highlight the current buffer.
- #
- (( _history_substring_search_match_index++ ))
_history-substring-search-not-found
+ return
+ fi
- elif [[ $_history_substring_search_match_index -eq 0 ]]; then
- #
- # We were beyond the end of $_history_substring_search_matches but DOWN
- # makes us move back to the $_history_substring_search_matches:
+ if _history-substring-search-has-prev; then
#
- # 1. Increase $_history_substring_search_match_index by 1.
+ # We do have younger matches.
#
- # 2. Restore $BUFFER from $_history_substring_search_old_buffer.
+ # 1. Move index to point to the previous match.
+ # 2. Update display to indicate search found.
#
- # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
- # to highlight the current buffer.
- #
- (( _history_substring_search_match_index++ ))
- BUFFER=$_history_substring_search_old_buffer
- _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+ _history_substring_search_match_index+=-1
+ _history-substring-search-found
else
#
- # We are at the end of history and there are no further matches.
+ # We do not have younger matches.
+ #
+ # 1. Move the index beyond the beginning of
+ # _history_substring_search_matches.
+ # 2. Update display to indicate search not found.
#
+ _history_substring_search_match_index+=-1
_history-substring-search-not-found
- return
fi
#
# When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from
# history should be matched, make sure the new and old results are different.
- # But when HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history.
#
- if [[ ! -o HIST_IGNORE_ALL_DUPS && -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then
+ # However, if the HIST_IGNORE_ALL_DUPS shell option, or
+ # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a
+ # unique history, so in this case we do not need to do anything.
+ #
+ if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then
+ return
+ fi
+
+ if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then
#
# Repeat the current search so that a different (unique) match is found.
#
diff --git a/plugins/history/README.md b/plugins/history/README.md
index dd9286894..a9d480f46 100644
--- a/plugins/history/README.md
+++ b/plugins/history/README.md
@@ -1,15 +1,17 @@
-## history
+# history plugin
Provides a couple of convenient aliases for using the `history` command to examine your command line history.
-### Requirements
+To use it, add `history` to the plugins array in your zshrc file:
-* None.
+```zsh
+plugins=(... history)
+```
-### Usage
+## Aliases
-* If `h` is called, your command history is listed. Equivalent to using `history`
-
-* If `hsi` is called with an argument, a **case insensitive** `grep` search is performed on your command history, looking for commands that match the argument provided
-
-* If `hsi` is called without an argument you will help on `grep` arguments \ No newline at end of file
+| Alias | Command | Description |
+|-------|----------------------|------------------------------------------------------------------|
+| `h` | `history` | Prints your command history |
+| `hs` | `history \| grep` | Use grep to search your command history |
+| `hsi` | `history \| grep -i` | Use grep to do a case-insensitive search of your command history |
diff --git a/plugins/history/history.plugin.zsh b/plugins/history/history.plugin.zsh
index 0f4aa4b10..9cee48fe4 100644
--- a/plugins/history/history.plugin.zsh
+++ b/plugins/history/history.plugin.zsh
@@ -1,8 +1,3 @@
alias h='history'
-
-function hs
-{
- history | grep $*
-}
-
-alias hsi='hs -i'
+alias hs='history | grep'
+alias hsi='history | grep -i'
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/hitokoto/README.md b/plugins/hitokoto/README.md
new file mode 100644
index 000000000..3a8758f56
--- /dev/null
+++ b/plugins/hitokoto/README.md
@@ -0,0 +1,15 @@
+# hitokoto plugin
+
+Displays a random quote taken from [hitokoto.cn](https://v1.hitokoto.cn/)
+
+Created by [Sinrimin](https://github.com/sinrimin)
+
+## Usage
+
+Add the plugin to the plugins array in your zshrc file and restart zsh:
+
+```zsh
+plugins=(... hitokoto)
+```
+
+Then, run `hitokoto` to get a new random quote.
diff --git a/plugins/hitokoto/hitokoto.plugin.zsh b/plugins/hitokoto/hitokoto.plugin.zsh
new file mode 100644
index 000000000..8646ebf3b
--- /dev/null
+++ b/plugins/hitokoto/hitokoto.plugin.zsh
@@ -0,0 +1,14 @@
+if ! (( $+commands[curl] )); then
+ echo "hitokoto plugin needs curl to work" >&2
+ return
+fi
+
+function hitokoto {
+ emulate -L zsh
+ Q=$(curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | jq -j '.hitokoto+"\t"+.from')
+
+ TXT=$(echo "$Q" | awk -F '\t' '{print $1}')
+ WHO=$(echo "$Q" | awk -F '\t' '{print $2}')
+
+ [[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”"
+}
diff --git a/plugins/homestead/homestead.plugin.zsh b/plugins/homestead/homestead.plugin.zsh
index cdbc564e4..ea2803d77 100644
--- a/plugins/homestead/homestead.plugin.zsh
+++ b/plugins/homestead/homestead.plugin.zsh
@@ -1,6 +1,6 @@
# Homestead basic command completion
_homestead_get_command_list () {
- homestead --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }'
+ homestead --no-ansi | sed -E "1,/(Available|Common) commands/d" | awk '/^ +[a-z]+/ { print $1 }'
}
_homestead () {
diff --git a/plugins/httpie/README.md b/plugins/httpie/README.md
index 56aa6a8ca..40d60c47d 100644
--- a/plugins/httpie/README.md
+++ b/plugins/httpie/README.md
@@ -1,6 +1,20 @@
-## HTTPie
-**Maintainer:** [lululau](https://github.com/lululau)
+# HTTPie plugin
+
+This plugin adds completion for [HTTPie](https://httpie.org), a command line HTTP
+client, a friendlier cURL replacement.
+
+To use it, add `httpie` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... httpie)
+```
-This plugin adds completion for HTTPie, which is a command line HTTP client, a user-friendly cURL replacement.
+It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions).
-[HTTPie Homepage](https://httpie.org)
+## Aliases
+
+| Alias | Command |
+| ------------ | ---------------------------------------------------------------- |
+| `https` | `http --default-scheme=https` |
+
+**Maintainer:** [lululau](https://github.com/lululau)
diff --git a/plugins/httpie/_httpie b/plugins/httpie/_httpie
new file mode 100644
index 000000000..4d702ef60
--- /dev/null
+++ b/plugins/httpie/_httpie
@@ -0,0 +1,181 @@
+#compdef http
+# ------------------------------------------------------------------------------
+# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the zsh-users nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# Completion script for httpie 0.7.2 (http://httpie.org)
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Akira Maeda <https://github.com/glidenote>
+# * Valodim <https://github.com/Valodim>
+# * Claus Klingberg <https://github.com/cjk>
+#
+# ------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# ------------------------------------------------------------------------------
+
+_httpie_params () {
+
+ local ret=1 expl
+
+ # or a url
+ if (( CURRENT <= NORMARG+1 )) && [[ $words[NORMARG] != *:* ]] ; then
+ _httpie_urls && ret=0
+
+ # regular param, if we already have a url
+ elif (( CURRENT > NORMARG )); then
+
+ # if the suffix is precisely : this is shorthand for a header
+ if [[ -prefix ':' ]]; then
+ PREFIX=
+ SUFFIX=:
+ fi
+
+ # if we are in front of a : (possibly due to the PREFIX move before)
+ if [[ -suffix ':' ]]; then
+
+ # this is rather buggy with normal tab behavior :\
+ compstate[insert]=menu
+ _wanted http_header expl 'HTTP Header' \
+ compadd -s ':' -S '' -- Content-Type Cookie && return 0
+ fi
+
+ # ignore all prefix stuff
+ compset -P '(#b)([^:@=]#)'
+ local name=$match[1]
+
+ if compset -P '='; then
+ _message "$name data field value"
+ elif compset -P '@'; then
+ _files
+ elif compset -P ':=@'; then
+ _files
+ elif compset -P ':='; then
+ _message "$name raw json data"
+ elif compset -P '=='; then
+ _message "$name url parameter value"
+ elif compset -P ':'; then
+ _message "$name header content"
+ else
+ typeset -a ops
+ ops=(
+ '=:data field'
+ '\::header'
+ '==:request parameter'
+ '@:data file field'
+ '\:=:raw json field'
+ '\:=@:raw json field file path'
+ )
+ _describe -t httpparams "parameter types" ops -Q -S ''
+ fi
+
+ ret=0
+
+ fi
+
+ # first arg may be a request method
+ (( CURRENT == NORMARG )) &&
+ _wanted http_method expl 'Request Method' \
+ compadd GET POST PUT DELETE HEAD OPTIONS TRACE CONNECT PATCH LINK UNLINK && ret=0
+
+ return $ret
+
+}
+
+_httpie_urls() {
+
+ local ret=1
+
+ if ! [[ -prefix [-+.a-z0-9]#:// ]]; then
+ local expl
+ compset -S '[^:/]*' && compstate[to_end]=''
+ _wanted url-schemas expl 'URL schema' compadd -S '' http:// https:// && ret=0
+ else
+ _urls && ret=0
+ fi
+
+ return $ret
+
+}
+
+_httpie_printflags () {
+
+ local ret=1
+
+ # not sure why this is necessary, but it will complete "-pH" style without it
+ [[ $IPREFIX == "-p" ]] && IPREFIX+=" "
+
+ compset -P '(#b)([a-zA-Z]#)'
+
+ local -a flags
+ [[ $match[1] != *H* ]] && flags+=( "H:request headers" )
+ [[ $match[1] != *B* ]] && flags+=( "B:request body" )
+ [[ $match[1] != *h* ]] && flags+=( "h:response headers" )
+ [[ $match[1] != *b* ]] && flags+=( "b:response body" )
+
+ _describe -t printflags "print flags" flags -S '' && ret=0
+
+ return $ret
+
+}
+
+integer NORMARG
+
+_arguments -n -C -s \
+ '(-j --json -f)'{-j,--json}'[Data items from the command line are serialized as a JSON object.]' \
+ '(-f --form -j)'{-f,--form}'[Data items from the command line are serialized as form fields.]' \
+ '--pretty=[Controls output processing.]:output format:(all colors format none)' \
+ '(-s --style)'{-s,--style}'=[Output coloring style]:STYLE:(autumn borland bw colorful default emacs friendly fruity manni monokai murphy native pastie perldoc ttr solarized tango trac vim vs)' \
+ '(-p --print)'{-p,--print}'=[String specifying what the output should contain]:print flags:_httpie_printflags' \
+ '(-v --verbose)'{-v,--verbose}'[Print the whole request as well as the response.]' \
+ '(-p -h --headers)'{-h,--headers}'[Print only the response headers.]' \
+ '(-p -b --body)'{-b,--body}'[Print only the response body.]' \
+ '(-S --stream)'{-S,--stream}'[Always stream the output by line, i.e., behave like `tail -f`.]' \
+ '(-o --output)'{-o,--output}'=[Save output to FILE.]:output file:_files' \
+ '(-d --download)'{-d,--download}'=[Do not print the response body to stdout.]' \
+ '(-c --continue)'{-c,--continue}'[Resume an interrupted download.]' \
+ '(--session-read-only)--session=[Create, or reuse and update a session.]:session name (or path)' \
+ '(--session)--session-read-only=[Create or read a session without updating it form the request/response exchange.]:session name (or path)' \
+ '(-a --auth)'{-a,--auth}'=[If only the username is provided (-a username)]:USER\:PASS' \
+ '--auth-type=[The authentication mechanism to be used. Defaults to "basic".]:AUTH-TYPE:(basic digest)' \
+ '--proxy=[String mapping protocol to the URL of the proxy.]:PROXY' \
+ '--follow[Allow full redirects.]' \
+ "--verify=[Enable or disable verification of ssl certificates.]:verify certificate:(yes no)" \
+ '--allow-redirects[Set this flag if full redirects are allowed (e.g. re-POST-ing of data at new ``Location``)]' \
+ '--timeout=[Float describes the timeout of the request (Use socket.setdefaulttimeout() as fallback).]:timeout (seconds)' \
+ '--check-status[This flag instructs HTTPie to also check the HTTP status code and exit with an error if the status indicates one.]' \
+ '--ignore-stdin[Do not attempt to read stdin.]' \
+ '(- *)--help[show help message.]' \
+ "(- *)--version[show program's version number and exit.]" \
+ '--traceback[Prints exception traceback should one occur.]' \
+ '--debug[Prints exception traceback should one occur and other information useful for debugging HTTPie itself.]' \
+ '*:args:_httpie_params' && return 0
diff --git a/plugins/httpie/httpie.plugin.zsh b/plugins/httpie/httpie.plugin.zsh
index 68ead6c67..088a1f1cf 100644
--- a/plugins/httpie/httpie.plugin.zsh
+++ b/plugins/httpie/httpie.plugin.zsh
@@ -1,33 +1,7 @@
-function _httpie_completion() {
- _arguments -C \
- '(- 1 *)--version[display version information]' \
- '(-j|--json)'{-j,--json}'[(default) Data items from the command line are serialized as a JSON object]' \
- '(-f|--form)'{-f,--form}'[Data items from the command line are serialized as form fields]' \
- '(--pretty)--pretty[<all,colors,format,none> Controls output processing]:options' \
- '(-s|--style)'{-s,--style}'[Output coloring style]' \
- '(-p|--print)'{-p,--print}'[String specifying what the output should contain: H(request headers), B(request body), h(response headers), b(response body)]' \
- '(-v|--verbose)'{-v,--verbose}'[Print the whole request as well as the response. Shortcut for --print=HBbh.]' \
- '(-h|--headers)'{-h,--headers}'[Print only the response headers. Shortcut for --print=h]' \
- '(-b|--body)'{-b,--body}'[Print only the response body. Shortcut for --print=b]' \
- '(-S|--stream)'{-S,--stream}'[Always stream the output by line, i.e., behave like `tail -f'"'"']' \
- '(-o|--output)'{-o,--output}'[Save output to FILE]:file:_files' \
- '(-d|--download)'{-d,--download}'[Do not print the response body to stdout. Rather, download it and store it in a file. The filename is guessed unless specified with --output filename. This action is similar to the default behaviour of wget.]' \
- '(-c|--continue)'{-c,--continue}'[Resume an interrupted download. Note that the --output option needs to be specified as well.]' \
- '(--session)--session[Create, or reuse and update a session. Within a session, custom headers, auth credential, as well as any cookies sent by the server persist between requests]:file:_files' \
- '(--session-read-only)--session-read-only[Create or read a session without updating it form the request/response exchange]:file:_files' \
- '(-a|--auth)'{-a,--auth}'[<USER:PASS> If only the username is provided (-a username), HTTPie will prompt for the password]' \
- '(--auth-type)--auth-type[<basic, digest> The authentication mechanism to be used. Defaults to "basic".]' \
- '(--proxy)--proxy[<PROTOCOL:PROXY_URL> String mapping protocol to the URL of the proxy]' \
- '(--follow)--follow[Set this flag if full redirects are allowed (e.g. re-POST-ing of data at new Location).]' \
- '(--verify)--verify[<VERIFY> Set to "no" to skip checking the host'"'"'s SSL certificate. You can also pass the path to a CA_BUNDLE file for private certs. You can also set the REQUESTS_CA_BUNDLE environment variable. Defaults to "yes".]' \
- '(--timeout)--timeout[<SECONDS> The connection timeout of the request in seconds. The default value is 30 seconds]' \
- '(--check-status)--check-status[By default, HTTPie exits with 0 when no network or other fatal errors occur. This flag instructs HTTPie to also check the HTTP status code and exit with an error if the status indicates one.]' \
- '(--ignore-stdin)--ignore-stdin[Do not attempt to read stdin]' \
- '(--help)--help[Show this help message and exit]' \
- '(--traceback)--traceback[Prints exception traceback should one occur]' \
- '(--debug)--debug[Prints exception traceback should one occur, and also other information that is useful for debugging HTTPie itself and for reporting bugs]' \
- '1: :->cmds' \
- '*: :->args' && ret=0
-}
+#
+# Aliases
+# (sorted alphabetically)
+#
+
+alias https='http --default-scheme=https'
-compdef _httpie_completion http \ No newline at end of file
diff --git a/plugins/ionic/README.md b/plugins/ionic/README.md
new file mode 100644
index 000000000..3ec4fc8b7
--- /dev/null
+++ b/plugins/ionic/README.md
@@ -0,0 +1,30 @@
+# Ionic plugin
+
+This plugin adds completion for the [Ionic CLI](https://ionicframework.com/docs/cli),
+as well as some aliases for common Ionic commands.
+
+To use it, add `ionic` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... ionic)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|-------|--------------------------------------|------------------------------------------------------------------|
+| iv | `ionic --version` | Check Ionic version |
+| ih | `ionic --help` | Ionic help command |
+| ist | `ionic start` | Create a new project |
+| ii | `ionic info` | Print system/environment info |
+| is | `ionic serve` | Start a local dev server for app dev/testing |
+| icba | `ionic cordova build android` | Build web assets and prepare app for android platform targets |
+| icbi | `ionic cordova build ios` | Build web assets and prepare app for ios platform targets |
+| icra | `ionic cordova run android` | Run an Ionic project on a connected android device |
+| icri | `ionic cordova run ios` | Run an Ionic project on a connected ios device |
+| icrsa | `ionic cordova resources android` | Automatically create icon and splash screen resources for android|
+| icrsi | `ionic cordova resources ios` | Automatically create icon and splash screen resources for ios |
+| icpaa | `ionic cordova platform add android` | Add Cordova android platform targets |
+| icpai | `ionic cordova platform add ios` | Add Cordova ios platform targets |
+| icpra | `ionic cordova platform rm android` | Remove Cordova platform targets |
+| icpri | `ionic cordova platform rm ios` | Remove Cordova platform targets |
diff --git a/plugins/ionic/ionic.plugin.zsh b/plugins/ionic/ionic.plugin.zsh
new file mode 100644
index 000000000..cf388af1b
--- /dev/null
+++ b/plugins/ionic/ionic.plugin.zsh
@@ -0,0 +1,15 @@
+alias iv="ionic --version"
+alias ih="ionic --help"
+alias ist="ionic start"
+alias ii="ionic info"
+alias is="ionic serve"
+alias icba="ionic cordova build android"
+alias icbi="ionic cordova build ios"
+alias icra="ionic cordova run android"
+alias icri="ionic cordova run ios"
+alias icrsa="ionic cordova resources android"
+alias icrsi="ionic cordova resources ios"
+alias icpaa="ionic cordova platform add android"
+alias icpai="ionic cordova platform add ios"
+alias icpra="ionic cordova platform rm android"
+alias icpri="ionic cordova platform rm ios"
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/iwhois/README.md b/plugins/iwhois/README.md
deleted file mode 100644
index 1626b8524..000000000
--- a/plugins/iwhois/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# iwhois
-
-Provides a whois command with a more accurate and up-to-date list of whois servers
-using CNAMES, via [whois.geek.nz](https://github.com/iwantmyname/whois.geek.nz).
-
-To use it, add iwhois to the plugins array of your zshrc file:
-```
-plugins=(... iwhois)
-```
-
-### Usage
-
-The plugin defines the function `iwhois` that takes a domain name as an argument:
-
-```
-$ iwhois github.com
- Domain Name: GITHUB.COM
- Registry Domain ID: 1264983250_DOMAIN_COM-VRSN
- Registrar WHOIS Server: whois.markmonitor.com
- Registrar URL: http://www.markmonitor.com
- Updated Date: 2017-06-26T16:02:39Z
- Creation Date: 2007-10-09T18:20:50Z
- ...
-```
diff --git a/plugins/iwhois/iwhois.plugin.zsh b/plugins/iwhois/iwhois.plugin.zsh
deleted file mode 100644
index 22a75eec1..000000000
--- a/plugins/iwhois/iwhois.plugin.zsh
+++ /dev/null
@@ -1,5 +0,0 @@
-function iwhois() {
- resolver="whois.geek.nz"
- tld=`echo ${@: -1} | awk -F "." '{print $NF}'`
- whois -h ${tld}.${resolver} "$@" ;
-}
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/jenv/jenv.plugin.zsh b/plugins/jenv/jenv.plugin.zsh
index 14c586be9..946ce18a5 100644
--- a/plugins/jenv/jenv.plugin.zsh
+++ b/plugins/jenv/jenv.plugin.zsh
@@ -1,4 +1,4 @@
-jenvdirs=("$HOME/.jenv" "/usr/local/jenv" "/opt/jenv")
+jenvdirs=("$HOME/.jenv" "/usr/local/bin/jenv" "/usr/local/jenv" "/opt/jenv")
FOUND_JENV=0
for jenvdir in $jenvdirs; do
@@ -15,7 +15,7 @@ if [[ $FOUND_JENV -eq 0 ]]; then
fi
if [[ $FOUND_JENV -eq 1 ]]; then
- export PATH="${jenvdir}/bin:$PATH"
+ (( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH"
eval "$(jenv init - zsh)"
function jenv_prompt_info() { jenv version-name 2>/dev/null }
diff --git a/plugins/jfrog/README.md b/plugins/jfrog/README.md
new file mode 100644
index 000000000..1d858620b
--- /dev/null
+++ b/plugins/jfrog/README.md
@@ -0,0 +1,11 @@
+# JFrog CLI
+
+This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli).
+
+JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs.
+
+To use it, add `jfrog` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... jfrog)
+```
diff --git a/plugins/jfrog/jfrog.plugin.zsh b/plugins/jfrog/jfrog.plugin.zsh
new file mode 100644
index 000000000..064ffa2db
--- /dev/null
+++ b/plugins/jfrog/jfrog.plugin.zsh
@@ -0,0 +1,10 @@
+_jfrog() {
+ local -a opts
+ opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
+ _describe 'values' opts
+ if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then
+ _files
+ fi
+}
+
+compdef _jfrog jfrog \ No newline at end of file
diff --git a/plugins/jhbuild/README.md b/plugins/jhbuild/README.md
index 910526966..3220e0daf 100644
--- a/plugins/jhbuild/README.md
+++ b/plugins/jhbuild/README.md
@@ -1,4 +1,34 @@
-## JHBuild
+# JHBuild
+
+This plugin adds some [JHBuild](https://developer.gnome.org/jhbuild/) aliases.
+
+To use it, add `jhbuild` to the plugins array of your zshrc file:
+
+```zsh
+plugins=(... jhbuild)
+```
+
**Maintainer:** [Miguel Vaello](https://github.com/miguxbe)
-This plugin adds some jhbuild aliases and increase the completion function provided by zsh.
+## Aliases
+
+| Alias | Command |
+|---------|---------------------------|
+| `jh` | `jhbuild` |
+| `jhb` | `jhbuild build` |
+| `jhbo` | `jhbuild buildone` |
+| `jhckb` | `jhbuild checkbranches` |
+| `jhckm` | `jhbuild checkmodulesets` |
+| `jhi` | `jhbuild info` |
+| `jhl` | `jhbuild list` |
+| `jhc` | `jhbuild clean` |
+| `jhco` | `jhbuild cleanone` |
+| `jhm` | `jhbuild make` |
+| `jhr` | `jhbuild run` |
+| `jhrd` | `jhbuild rdepends` |
+| `jhsd` | `jhbuild sysdeps` |
+| `jhu` | `jhbuild update` |
+| `jhuo` | `jhbuild updateone` |
+| `jhun` | `jhbuild uninstall` |
+| `jhsh` | `jhbuild shell` |
+| `jht` | `jhbuild tinderbox` |
diff --git a/plugins/jhbuild/jhbuild.plugin.zsh b/plugins/jhbuild/jhbuild.plugin.zsh
index fed1bc9fc..416745d27 100644
--- a/plugins/jhbuild/jhbuild.plugin.zsh
+++ b/plugins/jhbuild/jhbuild.plugin.zsh
@@ -1,5 +1,6 @@
-# Aliases
-#
+# JHBuild Aliases
+
+# Base
alias jh='jhbuild'
# Build
alias jhb='jhbuild build'
@@ -7,12 +8,14 @@ alias jhbo='jhbuild buildone'
# Checks
alias jhckb='jhbuild checkbranches'
alias jhckm='jhbuild checkmodulesets'
-# Info & list
+# Info & List
alias jhi='jhbuild info'
alias jhl='jhbuild list'
# Clean
alias jhc='jhbuild clean'
alias jhco='jhbuild cleanone'
+# Make
+alias jhm='jhbuild make'
# Run
alias jhr='jhbuild run'
# Depends
@@ -23,6 +26,7 @@ alias jhu='jhbuild update'
alias jhuo='jhbuild updateone'
# Uninstall
alias jhun='jhbuild uninstall'
-
-
-
+# Shell
+alias jhsh='jhbuild shell'
+# Tinderbox
+alias jht='jhbuild tinderbox'
diff --git a/plugins/jira/README.md b/plugins/jira/README.md
index a934ae68c..a5633af77 100644
--- a/plugins/jira/README.md
+++ b/plugins/jira/README.md
@@ -19,9 +19,14 @@ jira # performs the default action
jira new # opens a new issue
jira dashboard # opens your JIRA dashboard
+jira tempo # opens your JIRA Tempo
jira reported [username] # queries for issues reported by a user
jira assigned [username] # queries for issues assigned to a user
+jira myissues # queries for you own issues
jira branch # opens an existing issue matching the current branch name
+ # The branch name may have prefixes ending in "/": "feature/MP-1234",
+ # and also suffixes starting with "_": "MP-1234_fix_dashboard"
+ # In both these cases, the issue opened will be "MP-1234"
jira ABC-123 # opens an existing issue
jira ABC-123 m # opens an existing issue for adding a comment
```
diff --git a/plugins/jira/_jira b/plugins/jira/_jira
index d64614233..1ac3eeda3 100644
--- a/plugins/jira/_jira
+++ b/plugins/jira/_jira
@@ -5,6 +5,7 @@ local -a _1st_arguments
_1st_arguments=(
'new:create a new issue'
'dashboard:open the dashboard'
+ 'tempo:open the tempo'
'reported:search for issues reported by a user'
'assigned:search for issues assigned to a user'
'branch:open the issue named after the git branch of the current directory'
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index 052481a60..22807e0ae 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -43,7 +43,10 @@ function jira() {
echo "Opening new issue"
open_command "${jira_url}/secure/CreateIssue!default.jspa"
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
- _jira_query $@
+ _jira_query ${@:-$action}
+ elif [[ "$action" == "myissues" ]]; then
+ echo "Opening my issues"
+ open_command "${jira_url}/issues/?filter=-1"
elif [[ "$action" == "dashboard" ]]; then
echo "Opening dashboard"
if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
@@ -51,6 +54,9 @@ function jira() {
else
open_command "${jira_url}/secure/Dashboard.jspa"
fi
+ elif [[ "$action" == "tempo" ]]; then
+ echo "Opening tempo"
+ open_command "${jira_url}/secure/Tempo.jspa"
elif [[ "$action" == "dumpconfig" ]]; then
echo "JIRA_URL=$jira_url"
echo "JIRA_PREFIX=$jira_prefix"
@@ -60,25 +66,33 @@ function jira() {
else
# Anything that doesn't match a special action is considered an issue name
# but `branch` is a special case that will parse the current git branch
+ local issue_arg issue
if [[ "$action" == "branch" ]]; then
- local issue_arg=$(git rev-parse --abbrev-ref HEAD)
- local issue="${jira_prefix}${issue_arg}"
+ # Get name of the branch
+ issue_arg=$(git rev-parse --abbrev-ref HEAD)
+ # Strip prefixes like feature/ or bugfix/
+ issue_arg=${issue_arg##*/}
+ # Strip suffixes starting with _
+ issue_arg=(${(s:_:)issue_arg})
+ issue_arg=${issue_arg[1]}
+ if [[ "$issue_arg" = ${jira_prefix}* ]]; then
+ issue="${issue_arg}"
+ else
+ issue="${jira_prefix}${issue_arg}"
+ fi
else
- local issue_arg=$action
- local issue="${jira_prefix}${issue_arg}"
+ issue_arg=${(U)action}
+ issue="${jira_prefix}${issue_arg}"
fi
- local url_fragment=''
+
+ local url_fragment
if [[ "$2" == "m" ]]; then
url_fragment="#add-comment"
echo "Add comment to issue #$issue"
else
echo "Opening issue #$issue"
fi
- if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
- open_command "${jira_url}/issues/${issue}${url_fragment}"
- else
- open_command "${jira_url}/browse/${issue}${url_fragment}"
- fi
+ open_command "${jira_url}/browse/${issue}${url_fragment}"
fi
}
diff --git a/plugins/jruby/README.md b/plugins/jruby/README.md
new file mode 100644
index 000000000..821a46d5e
--- /dev/null
+++ b/plugins/jruby/README.md
@@ -0,0 +1,21 @@
+# JRuby plugin
+
+This plugin adds aliases for [JRuby](https://www.jruby.org/).
+
+To use it, add `jruby` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... jruby)
+```
+
+## Requirements
+
+This plugin assumes you already have jruby installed and available in your [path](https://www.jruby.org/getting-started).
+
+## Aliases
+
+| Alias | Command |
+| ------------ | ---------------------------------------------------------------- |
+| `jrspec` | `jruby --debug -S rspec --debug` |
+| `jprofile` | `jruby --profile.api -S rspec` |
+| `jexec` | `jruby -S` |
diff --git a/plugins/jsontools/README.md b/plugins/jsontools/README.md
index 4faf58b98..1fa2b8eed 100644
--- a/plugins/jsontools/README.md
+++ b/plugins/jsontools/README.md
@@ -2,41 +2,47 @@
Handy command line tools for dealing with json data.
-## Tools
+To use it, add `jsontools` to the plugins array in your zshrc file:
-- **pp_json** - pretty prints json
-- **is_json** - returns true if valid json; false otherwise
-- **urlencode_json** - returns a url encoded string for the given json
-- **urldecode_json** - returns decoded json for the given url encoded string
+```zsh
+plugins=(... jsontools)
+```
## Usage
-Usage is simple...just take your json data and pipe it into the appropriate jsontool.
-```sh
-<json data> | <jsontools tool>
-```
-## Examples
-##### pp_json
+Usage is simple... just take your json data and pipe it into the appropriate jsontool:
+
+- `pp_json`: pretty prints json.
+- `is_json`: returns true if valid json; false otherwise.
+- `urlencode_json`: returns a url encoded string for the given json.
+- `urldecode_json`: returns decoded json for the given url encoded string.
+
+### Examples
+
+- **pp_json**:
```sh
# curl json data and pretty print the results
curl https://coderwall.com/bobwilliams.json | pp_json
```
-##### is_json
+- **is_json**:
+
```sh
-# pretty print the contents of an existing json file
+# Validate if file's content conforms to a valid JSON schema
less data.json | is_json
```
-##### urlencode_json
+- **urlencode_json**:
+
```sh
# json data directly from the command line
echo '{"b":2, "a":1}' | urlencode_json
```
-##### urldecode_json
+- **urldecode_json**:
+
```sh
# url encoded string to decode
echo '%7B%22b%22:2,%20%22a%22:1%7D%0A' | urldecode_json
-``` \ No newline at end of file
+```
diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh
index 20d5eb1c9..912c83509 100644
--- a/plugins/jsontools/jsontools.plugin.zsh
+++ b/plugins/jsontools/jsontools.plugin.zsh
@@ -11,9 +11,10 @@ if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METH
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 -mjson.tool'
+ 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 "
-import json, sys;
+import sys; del sys.path[0];
+import json;
try:
json.loads(sys.stdin.read())
except ValueError, e:
@@ -22,11 +23,13 @@ else:
print True
sys.exit(0)"'
alias urlencode_json='python -c "
-import urllib, json, sys;
+import sys; del sys.path[0];
+import urllib, json;
print urllib.quote_plus(sys.stdin.read())
sys.exit(0)"'
alias urldecode_json='python -c "
-import urllib, json, sys;
+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
@@ -36,4 +39,4 @@ elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_MET
alias urldecode_json='ruby -e "require \"uri\"; puts URI.unescape(STDIN.read)"'
fi
-unset JSONTOOLS_METHOD \ No newline at end of file
+unset JSONTOOLS_METHOD
diff --git a/plugins/jump/README.md b/plugins/jump/README.md
index ed6415289..1b0ce68c0 100644
--- a/plugins/jump/README.md
+++ b/plugins/jump/README.md
@@ -17,3 +17,15 @@ plugins=(... jump)
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
| `unmark <mark-name>` | Remove the given mark |
| `marks` | List the existing marks and the directories they point to |
+
+## Key bindings
+
+Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark.
+For example, with a mark named `mymark` pointing to `/path/to/my/mark`:
+```zsh
+$ cp /tmp/file mymark<C-g>
+```
+will become:
+```zsh
+$ cp /tmp/file /path/to/my/mark
+```
diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
index a19a86022..c2da1144e 100644
--- a/plugins/jump/jump.plugin.zsh
+++ b/plugins/jump/jump.plugin.zsh
@@ -9,49 +9,51 @@
export MARKPATH=$HOME/.marks
jump() {
- cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
+ builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
}
mark() {
- if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then
- MARK=$(basename "$PWD")
+ if [[ $# -eq 0 || "$1" = "." ]]; then
+ MARK=${PWD:t}
else
MARK="$1"
fi
- if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
- mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK"
+ if read -q "?Mark $PWD as ${MARK}? (y/n) "; then
+ command mkdir -p "$MARKPATH"
+ command ln -sfn "$PWD" "$MARKPATH/$MARK"
fi
}
unmark() {
- rm -i "$MARKPATH/$1"
+ LANG= command rm -i "$MARKPATH/$1"
}
marks() {
- for link in $MARKPATH/*(@); do
+ local link max=0
+ for link in $MARKPATH/{,.}*(@N); do
+ if [[ ${#link:t} -gt $max ]]; then
+ max=${#link:t}
+ fi
+ done
+ local printf_markname_template="$(printf -- "%%%us " "$max")"
+ for link in $MARKPATH/{,.}*(@N); do
local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color"
- printf "%s\t" $markname
- printf -- "-> %s \t\n" $markpath
+ printf -- "$printf_markname_template" "$markname"
+ printf -- "-> %s\n" "$markpath"
done
}
_completemarks() {
- if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
- reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g'))
- else
- if readlink -e "${MARKPATH}"/* &>/dev/null; then
- reply=($(ls "${MARKPATH}"))
- fi
- fi
+ reply=("${MARKPATH}"/{,.}*(@N:t))
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
_mark_expansion() {
- setopt extendedglob
+ setopt localoptions extendedglob
autoload -U modify-current-argument
- modify-current-argument '$(readlink "$MARKPATH/$ARG")'
+ modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")'
}
zle -N _mark_expansion
bindkey "^g" _mark_expansion
diff --git a/plugins/keychain/README.md b/plugins/keychain/README.md
new file mode 100644
index 000000000..c603f6790
--- /dev/null
+++ b/plugins/keychain/README.md
@@ -0,0 +1,45 @@
+# keychain plugin
+
+This plugin starts automatically [`keychain`](https://www.funtoo.org/Keychain)
+to set up and load whichever credentials you want for both gpg and ssh
+connections.
+
+To enable it, add `keychain` to your plugins:
+
+```zsh
+plugins=(... keychain)
+```
+
+**NOTE**: It is HIGHLY recommended to also enable the `gpg-agent` plugin.
+
+## Instructions
+
+**IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
+
+**To adjust the agents** that keychain manages, use the `agents` style as
+shown below. By default, only the `gpg` agent is managed.
+
+```zsh
+zstyle :omz:plugins:keychain agents gpg,ssh
+```
+
+To **load multiple identities** use the `identities` style, For example:
+
+```zsh
+zstyle :omz:plugins:keychain identities id_ed25519 id_github 2C5879C2
+```
+
+**To pass additional options** to the `keychain` program, use the
+`options` style; for example:
+
+```zsh
+zstyle :omz:plugins:keychain options --quiet
+```
+
+## Credits
+
+Based on code from the `ssh-agent` plugin.
+
+## References
+
+- [Keychain](https://www.funtoo.org/Keychain)
diff --git a/plugins/keychain/keychain.plugin.zsh b/plugins/keychain/keychain.plugin.zsh
new file mode 100644
index 000000000..f122f7982
--- /dev/null
+++ b/plugins/keychain/keychain.plugin.zsh
@@ -0,0 +1,32 @@
+(( $+commands[keychain] )) || return
+
+# Define SHORT_HOST if not defined (%m = host name up to first .)
+SHORT_HOST=${SHORT_HOST:-${(%):-%m}}
+
+function {
+ local agents
+ local -a identities
+ local -a options
+ local _keychain_env_sh
+ local _keychain_env_sh_gpg
+
+ # load agents to start.
+ zstyle -s :omz:plugins:keychain agents agents
+
+ # load identities to manage.
+ zstyle -a :omz:plugins:keychain identities identities
+
+ # load additional options
+ zstyle -a :omz:plugins:keychain options options
+
+ # start keychain...
+ keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
+
+ # Get the filenames to store/lookup the environment from
+ _keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
+ _keychain_env_sh_gpg="$HOME/.keychain/$SHORT_HOST-sh-gpg"
+
+ # Source environment settings.
+ [ -f "$_keychain_env_sh" ] && . "$_keychain_env_sh"
+ [ -f "$_keychain_env_sh_gpg" ] && . "$_keychain_env_sh_gpg"
+}
diff --git a/plugins/kitchen/_kitchen b/plugins/kitchen/_kitchen
index 29a3125e4..d93d93d78 100644
--- a/plugins/kitchen/_kitchen
+++ b/plugins/kitchen/_kitchen
@@ -67,7 +67,7 @@ _kitchen() {
_kitchen_commands() {
local commands
- commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ [].*# \(.*\)$/\1:\2/p')}")
+ commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ A-Z[].*# \(.*\)$/\1:\2/p')}")
_describe -t commands 'kitchen commands' commands
}
diff --git a/plugins/knife/README.md b/plugins/knife/README.md
new file mode 100644
index 000000000..b167f1655
--- /dev/null
+++ b/plugins/knife/README.md
@@ -0,0 +1,25 @@
+# knife plugin
+
+This plugin adds completion for [knife](https://docs.chef.io/knife.html), a command-line tool
+to interact with [Chef](https://chef.io), a platform to automate and manage infrastructure via
+code.
+
+To use it, add `knife` to the plugins array in your zshrc file:
+```zsh
+plugins=(... knife)
+```
+
+## Options
+
+- `KNIFE_RELATIVE_PATH`: if set to `true`, the completion script will look for local cookbooks
+ under the `cookbooks` folder in the chef root directory. It has preference over the other two
+ options below. **Default:** empty.
+
+- `KNIFE_COOKBOOK_PATH`: if set, it points to the folder that contains local cookbooks, for
+ example: `/path/to/my/chef/cookbooks`. **Default:** `cookbook_path` field in `knife.rb`
+ (see below).
+
+- `KNIFE_CONF_PATH`: variable pointing to the `knife.rb` configuration file, for example
+ `/path/to/my/.chef/knife.rb`. Only used if `$KNIFE_COOKBOOK_PATH` isn't set. If it exists,
+ `$PWD/.chef/knife.rb` is used instead. Otherwise, if it's set, its value is used.
+ **Default**: `$HOME/.chef/knife.rb`.
diff --git a/plugins/knife/_knife b/plugins/knife/_knife
index 0d61ff15c..09757ebaa 100644
--- a/plugins/knife/_knife
+++ b/plugins/knife/_knife
@@ -3,13 +3,13 @@
# You can override the path to knife.rb and your cookbooks by setting
# KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb
# KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks
-# If you want your local cookbooks path to be calculated relative to where you are then
+# If you want your local cookbooks path to be calculated relative to where you are then
# set the below option
-# KNIFE_RELATIVE_PATH=true
+# KNIFE_RELATIVE_PATH=true
# Read around where these are used for more detail.
# These flags should be available everywhere according to man knife
-knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes )
+knife_general_flags=(--help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes)
# knife has a very special syntax, some example calls are:
# knife status
@@ -25,183 +25,200 @@ _knife() {
typeset -A opt_args
cloudproviders=(bluebox ec2 rackspace slicehost terremark)
_arguments \
- '1: :->knifecmd'\
- '2: :->knifesubcmd'\
+ '1: :->knifecmd' \
+ '2: :->knifesubcmd' \
'3: :->knifesubcmd2' \
'4: :->knifesubcmd3' \
'5: :->knifesubcmd4' \
'6: :->knifesubcmd5'
-
+
case $state in
knifecmd)
- compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search ssh status upload vault windows $cloudproviders
- ;;
+ compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search solo ssh status upload vault windows $cloudproviders
+ ;;
knifesubcmd)
case $words[2] in
- (bluebox|ec2|rackspace|slicehost|terremark)
+ bluebox|ec2|rackspace|slicehost|terremark)
compadd "$@" server images
- ;;
+ ;;
client)
compadd -Q "$@" "bulk delete" list create show delete edit reregister
- ;;
+ ;;
configure)
compadd "$@" client
- ;;
+ ;;
cookbook)
compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload
- ;;
+ ;;
diff)
_arguments '*:file or directory:_files -g "*"'
- ;;
+ ;;
environment)
compadd -Q "$@" list create delete edit show "from file"
- ;;
+ ;;
node)
- compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
- ;;
+ compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
+ ;;
recipe)
- compadd "$@" list
- ;;
+ compadd "$@" list
+ ;;
role)
compadd -Q "$@" "bulk delete" create delete edit "from file" list show
- ;;
+ ;;
+ solo)
+ compadd "$@" bootstrap clean cook init prepare
+ ;;
upload)
- _arguments '*:file or directory:_files -g "*"'
- ;;
+ _arguments '*:file or directory:_files -g "*"'
+ ;;
vault)
compadd -Q "$@" create decrypt delete edit remove "rotate all keys" "rotate keys" show update
- ;;
+ ;;
windows)
compadd "$@" bootstrap
- ;;
+ ;;
*)
- _arguments '2:Subsubcommands:($(_knife_options1))'
+ _arguments '2:Subsubcommands:($(_knife_options1))'
+ ;;
esac
- ;;
- knifesubcmd2)
+ ;;
+ knifesubcmd2)
case $words[3] in
- server)
+ server)
compadd "$@" list create delete
- ;;
- images)
+ ;;
+ images)
compadd "$@" list
- ;;
- site)
+ ;;
+ site)
compadd "$@" vendor show share search download list unshare
- ;;
- (show|delete|edit)
- _arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))'
- ;;
- (upload|test)
- _arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)'
- ;;
+ ;;
+ show|delete|edit)
+ _arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))'
+ ;;
+ upload|test)
+ _arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)'
+ ;;
list)
- compadd -a "$@" knife_general_flags
- ;;
+ compadd -a "$@" knife_general_flags
+ ;;
bag)
compadd -Q "$@" show edit list "from file" create delete
- ;;
+ ;;
+ bootstrap|clean|cook|prepare)
+ compadd "$@" nodes/*.json(N:t:r)
+ ;;
+ init)
+ compadd "$@" ./*(/N:t)
+ ;;
*)
_arguments '3:Subsubcommands:($(_knife_options2))'
+ ;;
esac
- ;;
- knifesubcmd3)
- case $words[3] in
- show)
- case $words[2] in
- cookbook)
- versioncomp=1
- _arguments '4:Cookbookversions:($(_cookbook_versions) latest)'
- ;;
- (node|client|role)
- compadd "$@" --attribute
- esac
- esac
- case $words[4] in
- (show|edit)
- _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
;;
- file)
+ knifesubcmd3)
+ case $words[3] in
+ show)
+ case $words[2] in
+ cookbook)
+ versioncomp=1
+ _arguments '4:Cookbookversions:($(_cookbook_versions) latest)'
+ ;;
+ node|client|role)
+ compadd "$@" --attribute
+ ;;
+ esac
+ ;;
+ esac
+ case $words[4] in
+ show|edit)
+ _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
+ ;;
+ file)
case $words[2] in
environment)
_arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/environments"'
- ;;
+ ;;
node)
_arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/nodes"'
- ;;
+ ;;
role)
_arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/roles"'
- ;;
+ ;;
*)
_arguments '*:Subsubcommands:($(_knife_options3))'
- esac
- ;;
- list)
- compadd -a "$@" knife_general_flags
- ;;
- *)
- _arguments '*:Subsubcommands:($(_knife_options3))'
- esac
- ;;
- knifesubcmd4)
- if (( versioncomp > 0 )); then
- compadd "$@" attributes definitions files libraries providers recipes resources templates
- else
- case $words[5] in
- file)
- _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
;;
- *) _arguments '*:Subsubcommands:($(_knife_options2))'
esac
- fi
- ;;
- knifesubcmd5)
- case $words[5] in
- file)
- _arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"'
+ ;;
+ list)
+ compadd -a "$@" knife_general_flags
+ ;;
+ *)
+ _arguments '*:Subsubcommands:($(_knife_options3))'
+ ;;
+ esac
+ ;;
+ knifesubcmd4)
+ if ((versioncomp > 0)); then
+ compadd "$@" attributes definitions files libraries providers recipes resources templates
+ else
+ case $words[5] in
+ file)
+ _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
;;
- *)
- _arguments '*:Subsubcommands:($(_knife_options3))'
+ *) _arguments '*:Subsubcommands:($(_knife_options2))' ;;
esac
- esac
+ fi
+ ;;
+ knifesubcmd5)
+ case $words[5] in
+ file)
+ _arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"'
+ ;;
+ *)
+ _arguments '*:Subsubcommands:($(_knife_options3))'
+ ;;
+ esac
+ ;;
+ esac
}
# Helper functions to provide the argument completion for several depths of commands
_knife_options1() {
- ( for line in $( knife $words[2] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
+ (for line in $(knife $words[2] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
}
_knife_options2() {
- ( for line in $( knife $words[2] $words[3] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
+ (for line in $(knife $words[2] $words[3] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
}
_knife_options3() {
- ( for line in $( knife $words[2] $words[3] $words[4] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
+ (for line in $(knife $words[2] $words[3] $words[4] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
}
# The chef_x_remote functions use knife to get a list of objects of type x on the server
_chef_roles_remote() {
- (knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_clients_remote() {
- (knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_nodes_remote() {
- (knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_cookbooks_remote() {
- (knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_sitecookbooks_remote() {
- (knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_data_bags_remote() {
- (knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_environments_remote() {
@@ -210,14 +227,14 @@ _chef_environments_remote() {
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
_chef_cookbooks_local() {
- if [ $KNIFE_RELATIVE_PATH ]; then
+ if [ $KNIFE_RELATIVE_PATH ]; then
local cookbook_path="$(_chef_root)/cookbooks"
- else
+ else
local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
if [ -f ./.chef/knife.rb ]; then
knife_rb="./.chef/knife.rb"
fi
- local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )}
+ local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/')}
fi
(for i in $cookbook_path; do ls $i; done)
}
@@ -227,12 +244,11 @@ _cookbook_versions() {
(knife cookbook show $words[4] | grep -v $words[4] | grep -v -E '\]|\[|\{|\}' | sed 's/ //g' | sed 's/"//g')
}
-# Searches up from current directory to find the closest folder that has a .chef folder
-# Useful for the knife upload/from file commands
-_chef_root () {
+# Searches up from current directory to find the closest folder that has a .chef folder
+# Useful for the knife upload/from file commands
+_chef_root() {
directory="$PWD"
- while [ $directory != '/' ]
- do
+ while [ $directory != '/' ]; do
test -e "$directory/.chef" && echo "$directory" && return
directory="${directory:h}"
done
diff --git a/plugins/knife_ssh/README.md b/plugins/knife_ssh/README.md
new file mode 100644
index 000000000..cb836b7f3
--- /dev/null
+++ b/plugins/knife_ssh/README.md
@@ -0,0 +1,14 @@
+# knife_ssh plugin
+
+This plugin adds a `knife_ssh` function as well as completion for it, to allow
+connecting via ssh to servers managed with [Chef](https://www.chef.io/).
+
+To use it, add `knife_ssh` to the plugins array in your zshrc file:
+```zsh
+plugins=(... knife_ssh)
+```
+
+The plugin creates a cache of the Chef node list via `knife`, and stores it
+in `$HOME/.knife_comp~`, when first triggering knife_ssh completion.
+
+**Requirements:** `knife` has to be installed.
diff --git a/plugins/knife_ssh/knife_ssh.plugin.zsh b/plugins/knife_ssh/knife_ssh.plugin.zsh
index 7fdd42a1e..dc425a33e 100644
--- a/plugins/knife_ssh/knife_ssh.plugin.zsh
+++ b/plugins/knife_ssh/knife_ssh.plugin.zsh
@@ -1,17 +1,17 @@
function knife_ssh() {
- grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
+ grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~
ssh $(knife node show $1 | awk '/IP:/{print $2}')
}
_knife_ssh() {
if hash knife 2>/dev/null; then
if [[ ! -f ~/.knife_comp~ ]]; then
- echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
+ echo "\nGenerating ~/.knife_comp~..." >&2
knife node list > ~/.knife_comp~
fi
- compadd $(<~/.knife_comp~)
+ compadd $(< ~/.knife_comp~)
else
- echo "Could not find knife" > /dev/stderr;
+ echo "Could not find knife" >&2
fi
}
diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md
index fcb73cd2d..b08997b0f 100644
--- a/plugins/kube-ps1/README.md
+++ b/plugins/kube-ps1/README.md
@@ -1,81 +1,238 @@
-# Kubernetes prompt for zsh
+kube-ps1: Kubernetes prompt for bash and zsh
+============================================
-A Kubernetes zsh prompt that displays the current cluster cluster
-and the namespace.
+A script that lets you add the current Kubernetes context and namespace
+configured on `kubectl` to your Bash/Zsh prompt strings (i.e. the `$PS1`).
-Inspired by several tools used to simplify usage of kubectl
+Inspired by several tools used to simplify usage of `kubectl`.
-NOTE: If you are not using zsh, check out [kube-ps1](https://github.com/jonmosco/kube-ps1)
-designed for bash as well as zsh.
+## Installing
+
+### MacOS
+
+Homebrew package manager:
+
+```
+$ brew update
+$ brew install kube-ps1
+```
+### From Source
+
+1. Clone this repository
+2. Source the kube-ps1.sh in your `~/.zshrc` or your `~/.bashrc`
+
+### Arch Linux
+AUR Package available at [https://aur.archlinux.org/packages/kube-ps1/](https://aur.archlinux.org/packages/kube-ps1/).
+
+#### Zsh
+```sh
+source /path/to/kube-ps1.sh
+PROMPT='$(kube_ps1)'$PROMPT
+```
+#### Bash
+```sh
+source /path/to/kube-ps1.sh
+PS1='[\u@\h \W $(kube_ps1)]\$ '
+```
+
+### Zsh Plugin Managers
+
+#### Using [zplugin](https://github.com/zdharma/zplugin)
+
+Update `.zshrc` with:
+```sh
+zplugin light jonmosco/kube-ps1
+PROMPT='$(kube_ps1)'$PROMPT
+```
## Requirements
-The default prompt assumes you have the kubectl command line utility installed. It
-can be obtained here:
+The default prompt assumes you have the `kubectl` command line utility installed.
+Official installation instructions and binaries are available:
[Install and Set up kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
-If using this with OpenShift, the oc tool needs installed. It can be obtained from here:
+If using this with OpenShift, the `oc` tool needs installed. It can be obtained
+from brew ports:
+
+```
+brew install openshift-cli
+```
+or the source can be downloaded:
[OC Client Tools](https://www.openshift.org/download.html)
+Set the binary to `oc` with the following environment variable:
+
+```
+KUBE_PS1_BINARY=oc
+```
+
+If neither binary is available, the prompt will print the following:
+
+```
+(<symbol>|BINARY-N/A:N/A)
+```
+
## Helper utilities
-There are several great tools that make using kubectl very enjoyable.
+There are several great tools that make using kubectl very enjoyable:
-[kubectx and kubenx](https://github.com/ahmetb/kubectx) are great for
+- [`kubectx` and `kubens`](https://github.com/ahmetb/kubectx) are great for
fast switching between clusters and namespaces.
+## Tmux port
+
+I have begun porting kube-ps1 to tmux as a status line plugin. If you prefer
+tmux, and like the functionality provided by kube-ps1, checkout the
+[kube-tmux](https://github.com/jonmosco/kube-tmux) project
+
## Prompt Structure
-The prompt layout is:
+The default prompt layout is:
```
-(<symbol>|<cluster>:<namespace>)
+(<symbol>|<context>:<namespace>)
```
-## Enabling
-
-In order to use kube-ps1 with Oh My Zsh, you'll need to enable them in the
-.zshrc file. You'll find the zshrc file in your $HOME directory. Open it with
-your favorite text editor and you'll see a spot to list all the plugins you
-want to load.
+If the current-context is not set, kube-ps1 will return the following:
-```shell
-vim $HOME/.zshrc
```
-
-Add kube-ps1 to the list of enabled plugins:
-
-```shell
-plugins=(
- git
- kube-ps1
-)
+(<symbol>|N/A:N/A)
```
-## Colors
+## Enabling/Disabling
-Blue was used as the prefix to match the Kubernetes color as closely as
-possible. Red was chosen as the cluster name to stand out, and cyan
-for the namespace. These can of course be changed.
+If you want to stop showing Kubernetes status on your prompt string temporarily
+run `kubeoff`. To disable the prompt for all shell sessions, run `kubeoff -g`.
+You can enable it again in the current shell by running `kubeon`, and globally
+with `kubeon -g`.
+
+```
+kubeon : turn on kube-ps1 status for this shell. Takes precedence over
+ global setting for current session
+kubeon -g : turn on kube-ps1 status globally
+kubeoff : turn off kube-ps1 status for this shell. Takes precedence over
+ global setting for current session
+kubeoff -g : turn off kube-ps1 status globally
+```
## Customization
-The default settings can be overridden in ~/.zshrc
+The default settings can be overridden in `~/.bashrc` or `~/.zshrc` by setting
+the following environment variables:
| Variable | Default | Meaning |
| :------- | :-----: | ------- |
| `KUBE_PS1_BINARY` | `kubectl` | Default Kubernetes binary |
+| `KUBE_PS1_NS_ENABLE` | `true` | Display the namespace. If set to `false`, this will also disable `KUBE_PS1_DIVIDER` |
| `KUBE_PS1_PREFIX` | `(` | Prompt opening character |
| `KUBE_PS1_SYMBOL_ENABLE` | `true ` | Display the prompt Symbol. If set to `false`, this will also disable `KUBE_PS1_SEPARATOR` |
| `KUBE_PS1_SYMBOL_DEFAULT` | `⎈ ` | Default prompt symbol. Unicode `\u2388` |
| `KUBE_PS1_SYMBOL_USE_IMG` | `false` | ☸️ , Unicode `\u2638` as the prompt symbol |
-| `KUBE_PS1_NS_ENABLE` | `true` | Display the namespace. If set to `false`, this will also disable `KUBE_PS1_DIVIDER` |
-| `KUBE_PS1_SEPERATOR` | `\|` | Separator between symbol and cluster name |
-| `KUBE_PS1_DIVIDER` | `:` | Separator between cluster and namespace |
+| `KUBE_PS1_SEPARATOR` | &#124; | Separator between symbol and context name |
+| `KUBE_PS1_DIVIDER` | `:` | Separator between context and namespace |
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
+| `KUBE_PS1_CLUSTER_FUNCTION` | No default, must be user supplied | Function to customize how cluster is displayed |
+| `KUBE_PS1_NAMESPACE_FUNCTION` | No default, must be user supplied | Function to customize how namespace is displayed |
+
+For terminals that do not support UTF-8, the symbol will be replaced with the
+string `k8s`.
+
+To disable a feature, set it to an empty string:
+
+```
+KUBE_PS1_SEPARATOR=''
+```
+
+## Colors
+
+The default colors are set with the following environment variables:
+
+| Variable | Default | Meaning |
+| :------- | :-----: | ------- |
+| `KUBE_PS1_SYMBOL_COLOR` | `blue` | Set default color of the Kubernetes symbol |
+| `KUBE_PS1_CTX_COLOR` | `red` | Set default color of the context |
+| `KUBE_PS1_NS_COLOR` | `cyan` | Set default color of the namespace |
+| `KUBE_PS1_BG_COLOR` | `null` | Set default color of the prompt background |
+
+Blue was used for the default symbol to match the Kubernetes color as closely
+as possible. Red was chosen as the context name to stand out, and cyan for the
+namespace.
+
+Set the variable to an empty string if you do not want color for each
+prompt section:
+
+```
+KUBE_PS1_CTX_COLOR=''
+```
+
+Names are usable for the following colors:
+
+```
+black, red, green, yellow, blue, magenta, cyan
+```
+
+256 colors are available by specifying the numerical value as the variable
+argument.
+
+## Customize display of cluster name and namespace
+
+You can change how the cluster name and namespace are displayed using the
+`KUBE_PS1_CLUSTER_FUNCTION` and `KUBE_PS1_NAMESPACE_FUNCTION` variables
+respectively.
+
+For the following examples let's assume the following:
+
+cluster name: `sandbox.k8s.example.com`
+namespace: `alpha`
+
+If you're using domain style cluster names, your prompt will get quite long
+very quickly. Let's say you only want to display the first portion of the
+cluster name (`sandbox`), you could do that by adding the following:
+
+```sh
+function get_cluster_short() {
+ echo "$1" | cut -d . -f1
+}
+
+KUBE_PS1_CLUSTER_FUNCTION=get_cluster_short
+```
+
+The same pattern can be followed to customize the display of the namespace.
+Let's say you would prefer the namespace to be displayed in all uppercase
+(`ALPHA`), here's one way you could do that:
+
+```sh
+function get_namespace_upper() {
+ echo "$1" | tr '[:lower:]' '[:upper:]'
+}
+
+export KUBE_PS1_NAMESPACE_FUNCTION=get_namespace_upper
+```
+
+In both cases, the variable is set to the name of the function, and you must have defined the function in your shell configuration before kube_ps1 is called. The function must accept a single parameter and echo out the final value.
+
+### Bug Reports and shell configuration
+
+Due to the vast ways of customizing the shell, please try the prompt with a
+minimal configuration before submitting a bug report.
+
+This can be done as follows for each shell before loading kube-ps1:
+
+Bash:
+```bash
+bash --norc
+```
+
+Zsh:
+```bash
+zsh -f
+or
+zsh --no-rcs
+```
## Contributors
-Jared Yanovich
+* [Ahmet Alp Balkan](https://github.com/ahmetb)
+* Jared Yanovich
diff --git a/plugins/kube-ps1/kube-ps1.plugin.zsh b/plugins/kube-ps1/kube-ps1.plugin.zsh
index df7277a26..9e77cbc19 100644
--- a/plugins/kube-ps1/kube-ps1.plugin.zsh
+++ b/plugins/kube-ps1/kube-ps1.plugin.zsh
@@ -1,16 +1,15 @@
-#!/bin/zsh
+#!/bin/bash
# Kubernetes prompt helper for bash/zsh
-# ported to oh-my-zsh
# Displays current context and namespace
-# Copyright 2018 Jon Mosco
+# Copyright 2019 Jon Mosco
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# https://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,34 +20,150 @@
# Debug
[[ -n $DEBUG ]] && set -x
-setopt PROMPT_SUBST
-autoload -U add-zsh-hook
-add-zsh-hook precmd _kube_ps1_update_cache
-zmodload zsh/stat
-zmodload zsh/datetime
-
# Default values for the prompt
-# Override these values in ~/.zshrc
+# Override these values in ~/.zshrc or ~/.bashrc
KUBE_PS1_BINARY="${KUBE_PS1_BINARY:-kubectl}"
KUBE_PS1_SYMBOL_ENABLE="${KUBE_PS1_SYMBOL_ENABLE:-true}"
-KUBE_PS1_SYMBOL_DEFAULT="${KUBE_PS1_SYMBOL_DEFAULT:-\u2388 }"
+KUBE_PS1_SYMBOL_DEFAULT=${KUBE_PS1_SYMBOL_DEFAULT:-$'\u2388 '}
KUBE_PS1_SYMBOL_USE_IMG="${KUBE_PS1_SYMBOL_USE_IMG:-false}"
KUBE_PS1_NS_ENABLE="${KUBE_PS1_NS_ENABLE:-true}"
+KUBE_PS1_CONTEXT_ENABLE="${KUBE_PS1_CONTEXT_ENABLE:-true}"
+KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}"
KUBE_PS1_SEPARATOR="${KUBE_PS1_SEPARATOR-|}"
KUBE_PS1_DIVIDER="${KUBE_PS1_DIVIDER-:}"
-KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}"
KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}"
+KUBE_PS1_SYMBOL_COLOR="${KUBE_PS1_SYMBOL_COLOR-blue}"
+KUBE_PS1_CTX_COLOR="${KUBE_PS1_CTX_COLOR-red}"
+KUBE_PS1_NS_COLOR="${KUBE_PS1_NS_COLOR-cyan}"
+KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}"
+KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
+KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
KUBE_PS1_LAST_TIME=0
+KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}"
+KUBE_PS1_NAMESPACE_FUNCTION="${KUBE_PS1_NAMESPACE_FUNCTION}"
+
+# Determine our shell
+if [ "${ZSH_VERSION-}" ]; then
+ KUBE_PS1_SHELL="zsh"
+elif [ "${BASH_VERSION-}" ]; then
+ KUBE_PS1_SHELL="bash"
+fi
+
+_kube_ps1_init() {
+ [[ -f "${KUBE_PS1_DISABLE_PATH}" ]] && KUBE_PS1_ENABLED=off
+
+ case "${KUBE_PS1_SHELL}" in
+ "zsh")
+ _KUBE_PS1_OPEN_ESC="%{"
+ _KUBE_PS1_CLOSE_ESC="%}"
+ _KUBE_PS1_DEFAULT_BG="%k"
+ _KUBE_PS1_DEFAULT_FG="%f"
+ setopt PROMPT_SUBST
+ autoload -U add-zsh-hook
+ add-zsh-hook precmd _kube_ps1_update_cache
+ zmodload -F zsh/stat b:zstat
+ zmodload zsh/datetime
+ ;;
+ "bash")
+ _KUBE_PS1_OPEN_ESC=$'\001'
+ _KUBE_PS1_CLOSE_ESC=$'\002'
+ _KUBE_PS1_DEFAULT_BG=$'\033[49m'
+ _KUBE_PS1_DEFAULT_FG=$'\033[39m'
+ [[ $PROMPT_COMMAND =~ _kube_ps1_update_cache ]] || PROMPT_COMMAND="_kube_ps1_update_cache;${PROMPT_COMMAND:-:}"
+ ;;
+ esac
+}
+
+_kube_ps1_color_fg() {
+ local KUBE_PS1_FG_CODE
+ case "${1}" in
+ black) KUBE_PS1_FG_CODE=0;;
+ red) KUBE_PS1_FG_CODE=1;;
+ green) KUBE_PS1_FG_CODE=2;;
+ yellow) KUBE_PS1_FG_CODE=3;;
+ blue) KUBE_PS1_FG_CODE=4;;
+ magenta) KUBE_PS1_FG_CODE=5;;
+ cyan) KUBE_PS1_FG_CODE=6;;
+ white) KUBE_PS1_FG_CODE=7;;
+ # 256
+ [0-9]|[1-9][0-9]|[1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-6]) KUBE_PS1_FG_CODE="${1}";;
+ *) KUBE_PS1_FG_CODE=default
+ esac
+
+ if [[ "${KUBE_PS1_FG_CODE}" == "default" ]]; then
+ KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}"
+ return
+ elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
+ KUBE_PS1_FG_CODE="%F{$KUBE_PS1_FG_CODE}"
+ elif [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then
+ if tput setaf 1 &> /dev/null; then
+ KUBE_PS1_FG_CODE="$(tput setaf ${KUBE_PS1_FG_CODE})"
+ elif [[ $KUBE_PS1_FG_CODE -ge 0 ]] && [[ $KUBE_PS1_FG_CODE -le 256 ]]; then
+ KUBE_PS1_FG_CODE="\033[38;5;${KUBE_PS1_FG_CODE}m"
+ else
+ KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}"
+ fi
+ fi
+ echo ${_KUBE_PS1_OPEN_ESC}${KUBE_PS1_FG_CODE}${_KUBE_PS1_CLOSE_ESC}
+}
+
+_kube_ps1_color_bg() {
+ local KUBE_PS1_BG_CODE
+ case "${1}" in
+ black) KUBE_PS1_BG_CODE=0;;
+ red) KUBE_PS1_BG_CODE=1;;
+ green) KUBE_PS1_BG_CODE=2;;
+ yellow) KUBE_PS1_BG_CODE=3;;
+ blue) KUBE_PS1_BG_CODE=4;;
+ magenta) KUBE_PS1_BG_CODE=5;;
+ cyan) KUBE_PS1_BG_CODE=6;;
+ white) KUBE_PS1_BG_CODE=7;;
+ # 256
+ [0-9]|[1-9][0-9]|[1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-6]) KUBE_PS1_BG_CODE="${1}";;
+ *) KUBE_PS1_BG_CODE=$'\033[0m';;
+ esac
+
+ if [[ "${KUBE_PS1_BG_CODE}" == "default" ]]; then
+ KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_BG}"
+ return
+ elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
+ KUBE_PS1_BG_CODE="%K{$KUBE_PS1_BG_CODE}"
+ elif [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then
+ if tput setaf 1 &> /dev/null; then
+ KUBE_PS1_BG_CODE="$(tput setab ${KUBE_PS1_BG_CODE})"
+ elif [[ $KUBE_PS1_BG_CODE -ge 0 ]] && [[ $KUBE_PS1_BG_CODE -le 256 ]]; then
+ KUBE_PS1_BG_CODE="\033[48;5;${KUBE_PS1_BG_CODE}m"
+ else
+ KUBE_PS1_BG_CODE="${DEFAULT_BG}"
+ fi
+ fi
+ echo ${OPEN_ESC}${KUBE_PS1_BG_CODE}${CLOSE_ESC}
+}
_kube_ps1_binary_check() {
- command -v "$1" >/dev/null
+ command -v $1 >/dev/null
}
_kube_ps1_symbol() {
[[ "${KUBE_PS1_SYMBOL_ENABLE}" == false ]] && return
- KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
- KUBE_PS1_SYMBOL_IMG="\u2638 "
+ case "${KUBE_PS1_SHELL}" in
+ bash)
+ if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388 ' != "\\u2388 " ]]; then
+ KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
+ # KUBE_PS1_SYMBOL=$'\u2388 '
+ KUBE_PS1_SYMBOL_IMG=$'\u2638 '
+ else
+ KUBE_PS1_SYMBOL=$'\xE2\x8E\x88 '
+ KUBE_PS1_SYMBOL_IMG=$'\xE2\x98\xB8 '
+ fi
+ ;;
+ zsh)
+ KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
+ KUBE_PS1_SYMBOL_IMG="\u2638 ";;
+ *)
+ KUBE_PS1_SYMBOL="k8s"
+ esac
if [[ "${KUBE_PS1_SYMBOL_USE_IMG}" == true ]]; then
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_IMG}"
@@ -68,22 +183,24 @@ _kube_ps1_file_newer_than() {
local file=$1
local check_time=$2
- zmodload -e "zsh/stat"
- if [[ "$?" -eq 0 ]]; then
- mtime=$(stat +mtime "${file}")
+ if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
+ mtime=$(zstat +mtime "${file}")
elif stat -c "%s" /dev/null &> /dev/null; then
# GNU stat
- mtime=$(stat -c %Y "${file}")
+ mtime=$(stat -L -c %Y "${file}")
else
# BSD stat
- mtime=$(stat -f %m "$file")
+ mtime=$(stat -L -f %m "$file")
fi
[[ "${mtime}" -gt "${check_time}" ]]
}
_kube_ps1_update_cache() {
- KUBECONFIG="${KUBECONFIG:=$HOME/.kube/config}"
+ local return_code=$?
+
+ [[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
+
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
# No ability to fetch context/namespace; display N/A.
KUBE_PS1_CONTEXT="BINARY-N/A"
@@ -108,40 +225,147 @@ _kube_ps1_update_cache() {
return
fi
done
+
+ return $return_code
}
-_kube_ps1_get_context_ns() {
+_kube_ps1_get_context() {
+ if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
+ KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
+ # Set namespace to 'N/A' if it is not defined
+ KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}"
- # Set the command time
- KUBE_PS1_LAST_TIME=$EPOCHSECONDS
+ if [[ ! -z "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
+ KUBE_PS1_CONTEXT=$($KUBE_PS1_CLUSTER_FUNCTION $KUBE_PS1_CONTEXT)
+ fi
+ fi
+}
- KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
- if [[ -z "${KUBE_PS1_CONTEXT}" ]]; then
- KUBE_PS1_CONTEXT="N/A"
- KUBE_PS1_NAMESPACE="N/A"
- return
- elif [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
+_kube_ps1_get_ns() {
+ if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
KUBE_PS1_NAMESPACE="$(${KUBE_PS1_BINARY} config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)"
# Set namespace to 'default' if it is not defined
KUBE_PS1_NAMESPACE="${KUBE_PS1_NAMESPACE:-default}"
+
+ if [[ ! -z "${KUBE_PS1_NAMESPACE_FUNCTION}" ]]; then
+ KUBE_PS1_NAMESPACE=$($KUBE_PS1_NAMESPACE_FUNCTION $KUBE_PS1_NAMESPACE)
+ fi
fi
}
+_kube_ps1_get_context_ns() {
+ # Set the command time
+ if [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then
+ if ((BASH_VERSINFO[0] >= 4 && BASH_VERSINFO[1] >= 2)); then
+ KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
+ else
+ KUBE_PS1_LAST_TIME=$(date +%s)
+ fi
+ elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
+ KUBE_PS1_LAST_TIME=$EPOCHSECONDS
+ fi
+
+ _kube_ps1_get_context
+ _kube_ps1_get_ns
+}
+
+# Set kube-ps1 shell defaults
+_kube_ps1_init
+
+_kubeon_usage() {
+ cat <<"EOF"
+Toggle kube-ps1 prompt on
+
+Usage: kubeon [-g | --global] [-h | --help]
+
+With no arguments, turn off kube-ps1 status for this shell instance (default).
+
+ -g --global turn on kube-ps1 status globally
+ -h --help print this message
+EOF
+}
+
+_kubeoff_usage() {
+ cat <<"EOF"
+Toggle kube-ps1 prompt off
+
+Usage: kubeoff [-g | --global] [-h | --help]
+
+With no arguments, turn off kube-ps1 status for this shell instance (default).
+
+ -g --global turn off kube-ps1 status globally
+ -h --help print this message
+EOF
+}
+
+kubeon() {
+ if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
+ _kubeon_usage
+ elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then
+ rm -f -- "${KUBE_PS1_DISABLE_PATH}"
+ elif [[ "$#" -ne 0 ]]; then
+ echo -e "error: unrecognized flag ${1}\\n"
+ _kubeon_usage
+ return
+ fi
+
+ KUBE_PS1_ENABLED=on
+}
+
+kubeoff() {
+ if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
+ _kubeoff_usage
+ elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then
+ mkdir -p -- "$(dirname "${KUBE_PS1_DISABLE_PATH}")"
+ touch -- "${KUBE_PS1_DISABLE_PATH}"
+ elif [[ $# -ne 0 ]]; then
+ echo "error: unrecognized flag ${1}" >&2
+ _kubeoff_usage
+ return
+ fi
+
+ KUBE_PS1_ENABLED=off
+}
+
# Build our prompt
-kube_ps1 () {
- local reset_color="%f"
- local blue="%F{blue}"
- local red="%F{red}"
- local cyan="%F{cyan}"
-
- KUBE_PS1="${reset_color}$KUBE_PS1_PREFIX"
- KUBE_PS1+="${blue}$(_kube_ps1_symbol)"
- KUBE_PS1+="${reset_color}$KUBE_PS1_SEPERATOR"
- KUBE_PS1+="${red}$KUBE_PS1_CONTEXT${reset_color}"
- KUBE_PS1+="$KUBE_PS1_DIVIDER"
- KUBE_PS1+="${cyan}$KUBE_PS1_NAMESPACE${reset_color}"
- KUBE_PS1+="$KUBE_PS1_SUFFIX"
+kube_ps1() {
+ [[ "${KUBE_PS1_ENABLED}" == "off" ]] && return
+ [[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return
- echo "${KUBE_PS1}"
+ local KUBE_PS1
+ local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"
+
+ # Background Color
+ [[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="$(_kube_ps1_color_bg ${KUBE_PS1_BG_COLOR})"
+
+ # Prefix
+ [[ -n "${KUBE_PS1_PREFIX}" ]] && KUBE_PS1+="${KUBE_PS1_PREFIX}"
+
+ # Symbol
+ KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_SYMBOL_COLOR)$(_kube_ps1_symbol)${KUBE_PS1_RESET_COLOR}"
+
+ if [[ -n "${KUBE_PS1_SEPARATOR}" ]] && [[ "${KUBE_PS1_SYMBOL_ENABLE}" == true ]]; then
+ KUBE_PS1+="${KUBE_PS1_SEPARATOR}"
+ fi
+
+ # Context
+ if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
+ KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_CTX_COLOR)${KUBE_PS1_CONTEXT}${KUBE_PS1_RESET_COLOR}"
+ fi
+ # Namespace
+ if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
+ if [[ -n "${KUBE_PS1_DIVIDER}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
+ KUBE_PS1+="${KUBE_PS1_DIVIDER}"
+ fi
+ KUBE_PS1+="$(_kube_ps1_color_fg ${KUBE_PS1_NS_COLOR})${KUBE_PS1_NAMESPACE}${KUBE_PS1_RESET_COLOR}"
+ fi
+
+ # Suffix
+ [[ -n "${KUBE_PS1_SUFFIX}" ]] && KUBE_PS1+="${KUBE_PS1_SUFFIX}"
+
+ # Close Background color if defined
+ [[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_BG}${_KUBE_PS1_CLOSE_ESC}"
+
+ echo "${KUBE_PS1}"
}
diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
index a93a9339e..f6651c8cd 100644
--- a/plugins/kubectl/README.md
+++ b/plugins/kubectl/README.md
@@ -14,6 +14,7 @@ plugins=(... kubectl)
| Alias | Command | Description |
|:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------|
| k | `kubectl` | The kubectl command |
+| kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
| kaf | `kubectl apply -f` | Apply a YML file |
| keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
| | | **Manage configuration quickly to switch contexts between local, dev and staging** |
@@ -21,6 +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
| | | **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 |
@@ -31,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 |
@@ -46,6 +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 --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 |
@@ -67,6 +71,7 @@ plugins=(... kubectl)
| kdeld | `kubectl delete deployment` | Delete the deployment |
| ksd | `kubectl scale deployment` | Scale a deployment |
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
+| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
| | | **Rollout management** |
| kgrs | `kubectl get rs` | To see the ReplicaSet `rs` created by the deployment |
| krh | `kubectl rollout history` | Check the revisions of this deployment |
@@ -86,3 +91,40 @@ 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** |
+| 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` | 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 |
+| kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
+| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
+| 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 c8fd5b19f..b79b7c941 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
@@ -13,6 +13,9 @@ fi
# This command is used a LOT both below and in daily life
alias k=kubectl
+# Execute a kubectl command against all namespaces
+alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'
+
# Apply a YML file
alias kaf='kubectl apply -f'
@@ -25,12 +28,16 @@ alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
alias kccc='kubectl config current-context'
+# List all contexts
+alias kcgc='kubectl config get-contexts'
+
# General aliases
alias kdel='kubectl delete'
alias kdelf='kubectl delete -f'
# Pod management.
alias kgp='kubectl get pods'
+alias kgpa='kubectl get pods --all-namespaces'
alias kgpw='kgp --watch'
alias kgpwide='kgp -o wide'
alias kep='kubectl edit pods'
@@ -41,8 +48,12 @@ alias kgpall='k 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'
alias kgsw='kgs --watch'
alias kgswide='kgs -o wide'
alias kes='kubectl edit svc'
@@ -51,6 +62,7 @@ alias kdels='kubectl delete svc'
# Ingress management
alias kgi='kubectl get ingress'
+alias kgia='kubectl get ingress --all-namespaces'
alias kei='kubectl edit ingress'
alias kdi='kubectl describe ingress'
alias kdeli='kubectl delete ingress'
@@ -60,20 +72,24 @@ 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 --current --namespace'
# ConfigMap management
alias kgcm='kubectl get configmaps'
+alias kgcma='kubectl get configmaps --all-namespaces'
alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap'
# Secret management
alias kgsec='kubectl get secret'
+alias kgseca='kubectl get secret --all-namespaces'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret'
# Deployment management.
alias kgd='kubectl get deployment'
+alias kgda='kubectl get deployment --all-namespaces'
alias kgdw='kgd --watch'
alias kgdwide='kgd -o wide'
alias ked='kubectl edit deployment'
@@ -81,12 +97,26 @@ alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'
+kres(){
+ kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S)
+}
# Rollout management.
alias kgrs='kubectl get rs'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'
+# Statefulset management.
+alias kgss='kubectl get statefulset'
+alias kgssa='kubectl get statefulset --all-namespaces'
+alias kgssw='kgss --watch'
+alias kgsswide='kgss -o wide'
+alias kess='kubectl edit statefulset'
+alias kdss='kubectl describe statefulset'
+alias kdelss='kubectl delete statefulset'
+alias ksss='kubectl scale statefulset'
+alias krsss='kubectl rollout status statefulset'
+
# Port forwarding
alias kpf="kubectl port-forward"
@@ -96,7 +126,13 @@ alias kgaa='kubectl get all --all-namespaces'
# Logs
alias kl='kubectl logs'
+alias kl1h='kubectl logs --since 1h'
+alias kl1m='kubectl logs --since 1m'
+alias kl1s='kubectl logs --since 1s'
alias klf='kubectl logs -f'
+alias klf1h='kubectl logs --since 1h -f'
+alias klf1m='kubectl logs --since 1m -f'
+alias klf1s='kubectl logs --since 1s -f'
# File copy
alias kcp='kubectl cp'
@@ -106,3 +142,39 @@ alias kgno='kubectl get nodes'
alias keno='kubectl edit node'
alias kdno='kubectl describe node'
alias kdelno='kubectl delete node'
+
+# PVC management.
+alias kgpvc='kubectl get pvc'
+alias kgpvca='kubectl get pvc --all-namespaces'
+alias kgpvcw='kgpvc --watch'
+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/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..aa74c9924
--- /dev/null
+++ b/plugins/lando/lando.plugin.zsh
@@ -0,0 +1,40 @@
+# Settings
+: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
+: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
+
+# Enable multiple commands with lando.
+function artisan \
+ composer \
+ drush \
+ gulp \
+ npm \
+ 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/laravel/README.md b/plugins/laravel/README.md
index 067c1e9fb..95f590191 100644
--- a/plugins/laravel/README.md
+++ b/plugins/laravel/README.md
@@ -1,19 +1,57 @@
-# Laravel plugin
+# Laravel
This plugin adds aliases and autocompletion for Laravel [Artisan](https://laravel.com/docs/artisan) and [Bob](http://daylerees.github.io/laravel-bob/) command-line interfaces.
-**NOTE:** completion might not work for recent Laravel versions since it hasn't been updated since 2012.
-In that case, check out plugins `laravel4` and `laravel5`.
-
-To use it, add `laravel` to the plugins array in your zshrc file:
-
-```zsh
+```
plugins=(... laravel)
```
-## Aliases
+| Alias | Description |
+|:-:|:-:|
+| `artisan` | `php artisan` |
+| `pas` | `php artisan serve` |
+
+## Database
+
+| Alias | Description |
+|:-:|:-:|
+| `pam` | `php artisan migrate` |
+| `pamf` | `php artisan migrate:fresh` |
+| `pamfs` | `php artisan migrate:fresh --seed` |
+| `pamr` | `php artisan migrate:rollback` |
+| `pads` | `php artisan db:seed` |
+
+## Makers
+
+| Alias | Description |
+|:-:|:-:|
+| `pamm` | `php artisan make:model` |
+| `pamc` | `php artisan make:controller` |
+| `pams` | `php artisan make:seeder` |
+| `pamt` | `php artisan make:test` |
+| `pamfa` | `php artisan make:factory` |
+| `pamp` | `php artisan make:policy` |
+| `pame` | `php artisan make:event` |
+| `pamj` | `php artisan make:job` |
+| `paml` | `php artisan make:listener` |
+| `pamn` | `php artisan make:notification` |
+
+## Clears
+
+| Alias | Description |
+|:-:|:-:|
+| `pacac` | `php artisan cache:clear` |
+| `pacoc` | `php artisan config:clear` |
+| `pavic` | `php artisan view:clear` |
+| `paroc` | `php artisan route:clear` |
+
+## Queues
-| Alias | Command | Description |
-|-----------|--------------------------|----------------------|
-| artisan | `php artisan` | Main Artisan command |
-| bob | `php artisan bob::build` | Main Bob command |
+| Alias | Description |
+|:-:|:-:|
+| `paqf` | `php artisan queue:failed` |
+| `paqft` | `php artisan queue:failed-table` |
+| `paql` | `php artisan queue:listen` |
+| `paqr` | `php artisan queue:retry` |
+| `paqt` | `php artisan queue:table` |
+| `paqw` | `php artisan queue:work` |
diff --git a/plugins/laravel/laravel.plugin.zsh b/plugins/laravel/laravel.plugin.zsh
index ed932ee89..a8382d3c9 100644
--- a/plugins/laravel/laravel.plugin.zsh
+++ b/plugins/laravel/laravel.plugin.zsh
@@ -1,3 +1,41 @@
#!zsh
alias artisan='php artisan'
alias bob='php artisan bob::build'
+
+# Development
+alias pas='php artisan serve'
+
+# Database
+alias pam='php artisan migrate'
+alias pamf='php artisan migrate:fresh'
+alias pamfs='php artisan migrate:fresh --seed'
+alias pamr='php artisan migrate:rollback'
+alias pads='php artisan db:seed'
+
+# Makers
+alias pamm='php artisan make:model'
+alias pamc='php artisan make:controller'
+alias pams='php artisan make:seeder'
+alias pamt='php artisan make:test'
+alias pamfa='php artisan make:factory'
+alias pamp='php artisan make:policy'
+alias pame='php artisan make:event'
+alias pamj='php artisan make:job'
+alias paml='php artisan make:listener'
+alias pamn='php artisan make:notification'
+alias pampp='php artisan make:provider'
+
+
+# Clears
+alias pacac='php artisan cache:clear'
+alias pacoc='php artisan config:clear'
+alias pavic='php artisan view:clear'
+alias paroc='php artisan route:clear'
+
+# queues
+alias paqf='php artisan queue:failed'
+alias paqft='php artisan queue:failed-table'
+alias paql='php artisan queue:listen'
+alias paqr='php artisan queue:retry'
+alias paqt='php artisan queue:table'
+alias paqw='php artisan queue:work'
diff --git a/plugins/laravel4/README.md b/plugins/laravel4/README.md
index c945601f7..97a6a7899 100644
--- a/plugins/laravel4/README.md
+++ b/plugins/laravel4/README.md
@@ -10,9 +10,9 @@ plugins=(... laravel4)
## Aliases
-| Alias | Command | Description |
-|-----------|-------------------------------------------|-------------------------------------------------------------|
-| la4 | `php artisan` | Main Artisan command |
-| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files |
-| la4cache | `php artisan cache:clear` | Flush the application cache |
-| la4routes | `php artisan routes` | List all registered routes |
+| Alias | Command | Description |
+|-----------|-----------------------------|-------------------------------------|
+| la4 | `php artisan` | Main Artisan command |
+| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files |
+| la4cache | `php artisan cache:clear` | Flush the application cache |
+| la4routes | `php artisan routes` | List all registered routes |
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 4cc4acab6..b5cc55828 100644
--- a/plugins/last-working-dir/README.md
+++ b/plugins/last-working-dir/README.md
@@ -1,9 +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 a `lwd` function to jump to the last working directory.
-Adds `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 53bb19e46..905a02a70 100644
--- a/plugins/last-working-dir/last-working-dir.plugin.zsh
+++ b/plugins/last-working-dir/last-working-dir.plugin.zsh
@@ -2,18 +2,21 @@
typeset -g ZSH_LAST_WORKING_DIRECTORY
# Updates the last directory once directory is changed
-chpwd_functions+=(chpwd_last_working_dir)
+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/lein/README.md b/plugins/lein/README.md
new file mode 100644
index 000000000..0c4119663
--- /dev/null
+++ b/plugins/lein/README.md
@@ -0,0 +1,9 @@
+# Leiningen plugin
+
+This plugin adds completions for the [Leiningen](https://leiningen.org/) Clojure build tool.
+
+To use it, add `lein` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... lein)
+```
diff --git a/plugins/lighthouse/README.md b/plugins/lighthouse/README.md
new file mode 100644
index 000000000..55587b20e
--- /dev/null
+++ b/plugins/lighthouse/README.md
@@ -0,0 +1,29 @@
+# Lighthouse plugin
+
+This plugin adds commands to manage [Lighthouse](https://lighthouseapp.com/).
+
+To use it, add `lighthouse` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... lighthouse)
+```
+
+## Commands
+
+* `open_lighthouse_ticket <issue>` (alias: `lho`):
+
+ Opens the URL to the issue passed as an argument. To use it, add a `.lighthouse-url`
+ file in your directory with the URL to the individual project.
+
+ Example:
+
+ ```console
+ $ cat .lighthouse-url
+ https://rails.lighthouseapp.com/projects/8994
+
+ $ lho 23
+ Opening ticket #23
+ # The browser goes to https://rails.lighthouseapp.com/projects/8994/tickets/23
+ ```
+
+See a demo: http://screencast.com/t/ZDgwNDUwNT
diff --git a/plugins/lighthouse/lighthouse.plugin.zsh b/plugins/lighthouse/lighthouse.plugin.zsh
index 4a47b6010..3fca2bf4f 100644
--- a/plugins/lighthouse/lighthouse.plugin.zsh
+++ b/plugins/lighthouse/lighthouse.plugin.zsh
@@ -1,16 +1,12 @@
-# To use: add a .lighthouse file into your directory with the URL to the
-# individual project. For example:
-# https://rails.lighthouseapp.com/projects/8994
-# Example usage: https://screencast.com/t/ZDgwNDUwNT
open_lighthouse_ticket () {
if [ ! -f .lighthouse-url ]; then
echo "There is no .lighthouse-url file in the current directory..."
- return 0;
- else
- lighthouse_url=$(cat .lighthouse-url);
- echo "Opening ticket #$1";
- open_command "$lighthouse_url/tickets/$1";
+ return 0
fi
+
+ lighthouse_url=$(cat .lighthouse-url)
+ echo "Opening ticket #$1"
+ open_command "$lighthouse_url/tickets/$1"
}
alias lho='open_lighthouse_ticket'
diff --git a/plugins/lol/README.md b/plugins/lol/README.md
index b0e54f575..ea6b0c3b8 100644
--- a/plugins/lol/README.md
+++ b/plugins/lol/README.md
@@ -1,67 +1,55 @@
# lol
-Plugin for adding catspeak aliases, because why not
+Plugin for adding catspeak aliases, because why not.
-## Enabling the plugin
+To use it, add `lol` to the plugins array in your zshrc file:
-1. Open your `.zshrc` file and add `lol` in the plugins section:
-
- ```zsh
- plugins=(
- # all your enabled plugins
- lol
- )
- ```
-
-2. Reload the source file or restart your Terminal session:
-
- ```console
- $ source ~/.zshrc
- $
- ```
+```zsh
+plugins=(... lol)
+```
## Aliases
-| Alias | Command |
-| ------------ | ---------------------------------------------------------------- |
-| `:3` | `echo` |
-| `alwayz` | `tail -f` |
-| `bringz` | `git pull` |
-| `btw` | `nice` |
-| `byes` | `exit` |
-| `chicken` | `git add` |
-| `cya` | `reboot` |
-| `donotwant` | `rm` |
-| `dowant` | `cp` |
-| `gimmeh` | `touch` |
-| `gtfo` | `mv` |
-| `hackzor` | `git init` |
-| `hai` | `cd` |
-| `icanhas` | `mkdir` |
-| `ihasbucket` | `df -h` |
-| `iminurbase` | `finger` |
-| `inur` | `locate` |
-| `invisible` | `cat` |
-| `iz` | `ls` |
-| `kthxbai` | `halt` |
-| `letcat` | `git checkout` |
-| `moar` | `more` |
-| `nomnom` | `killall` |
-| `nomz` | `ps aux` |
-| `nowai` | `chmod` |
-| `oanward` | `git commit -m` |
-| `obtw` | `nohup` |
-| `onoz` | `cat /var/log/errors.log` |
-| `ooanward` | `git commit -am` |
-| `plz` | `pwd` |
-| `pwned` | `ssh` |
-| `rtfm` | `man` |
-| `rulz` | `git push` |
-| `tldr` | `less` |
-| `violenz` | `git rebase` |
-| `visible` | `echo` |
-| `wtf` | `dmesg` |
-| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` |
+| Alias | Command |
+| ------------ | --------------------------------------------------------------- |
+| `:3` | `echo` |
+| `alwayz` | `tail -f` |
+| `bringz` | `git pull` |
+| `btw` | `nice` |
+| `byes` | `exit` |
+| `chicken` | `git add` |
+| `cya` | `reboot` |
+| `donotwant` | `rm` |
+| `dowant` | `cp` |
+| `gimmeh` | `touch` |
+| `gtfo` | `mv` |
+| `hackzor` | `git init` |
+| `hai` | `cd` |
+| `icanhas` | `mkdir` |
+| `ihasbucket` | `df -h` |
+| `iminurbase` | `finger` |
+| `inur` | `locate` |
+| `invisible` | `cat` |
+| `iz` | `ls` |
+| `kthxbai` | `halt` |
+| `letcat` | `git checkout` |
+| `moar` | `more` |
+| `nomnom` | `killall` |
+| `nomz` | `ps aux` |
+| `nowai` | `chmod` |
+| `oanward` | `git commit -m` |
+| `obtw` | `nohup` |
+| `onoz` | `cat /var/log/errors.log` |
+| `ooanward` | `git commit -am` |
+| `plz` | `pwd` |
+| `pwned` | `ssh` |
+| `rtfm` | `man` |
+| `rulz` | `git push` |
+| `tldr` | `less` |
+| `violenz` | `git rebase` |
+| `visible` | `echo` |
+| `wtf` | `dmesg` |
+| `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` |
## Usage Examples
@@ -78,6 +66,6 @@ nowai u=r,go= some.file
# ssh root@catserver.org
pwned root@catserver.org
-# git commit -m "$(curl -s https://whatthecommit.com/index.txt)"
+# git commit -m "$(curl -s http://whatthecommit.com/index.txt)"
yolo
```
diff --git a/plugins/lol/lol.plugin.zsh b/plugins/lol/lol.plugin.zsh
index 585f96e4f..3c30259a1 100644
--- a/plugins/lol/lol.plugin.zsh
+++ b/plugins/lol/lol.plugin.zsh
@@ -45,7 +45,7 @@ alias bringz='git pull'
alias chicken='git add'
alias oanward='git commit -m'
alias ooanward='git commit -am'
-alias yolo='git commit -m "$(curl -s https://whatthecommit.com/index.txt)"'
+alias yolo='git commit -m "$(curl -s http://whatthecommit.com/index.txt)"'
alias letcat='git checkout'
alias violenz='git rebase'
diff --git a/plugins/lxd/README.md b/plugins/lxd/README.md
new file mode 100644
index 000000000..cea45e31c
--- /dev/null
+++ b/plugins/lxd/README.md
@@ -0,0 +1,9 @@
+# lxd
+
+This plugin provides completion for [lxd](https://linuxcontainers.org/lxd/), as well as aliases
+for frequent lxc commands.
+
+To use it add `lxd` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... lxd)
diff --git a/plugins/lxd/lxd.plugin.zsh b/plugins/lxd/lxd.plugin.zsh
new file mode 100644
index 000000000..a6a074252
--- /dev/null
+++ b/plugins/lxd/lxd.plugin.zsh
@@ -0,0 +1,26 @@
+_lxc_get_command_list () {
+ $_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
+}
+
+_lxc_get_subcommand_list () {
+ $_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
+}
+
+_lxc () {
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ _arguments \
+ '1: :->command'\
+ '*: :->args'
+
+ case $state in
+ command)
+ compadd $(_lxc_get_command_list)
+ ;;
+ *)
+ compadd $(_lxc_get_subcommand_list)
+ ;;
+ esac
+}
+
+compdef _lxc lxc
diff --git a/plugins/macports/_port b/plugins/macports/_port
index 06d7fb426..897598a46 100644
--- a/plugins/macports/_port
+++ b/plugins/macports/_port
@@ -41,6 +41,9 @@ subcmds=(
'patch'
'pkg'
'provides'
+'rdependents'
+'rdeps'
+'reclaim'
'rpmpackage'
'search'
'selfupdate'
diff --git a/plugins/magic-enter/README.md b/plugins/magic-enter/README.md
new file mode 100644
index 000000000..78514c67d
--- /dev/null
+++ b/plugins/magic-enter/README.md
@@ -0,0 +1,17 @@
+## Magic Enter plugin
+
+This plugin makes your enter key magical, by binding commonly used commands to it.
+
+To use it, add `magic-enter` to the plugins array in your zshrc file. You can set the
+commands to be run in your .zshrc, before the line containing plugins. If no command
+is specified in a git directory, `git status` is executed; in other directories, `ls`.
+
+```zsh
+# defaults
+MAGIC_ENTER_GIT_COMMAND='git status -u .'
+MAGIC_ENTER_OTHER_COMMAND='ls -lh .'
+
+plugins=(... magic-enter)
+```
+
+**Maintainer:** [@dufferzafar](https://github.com/dufferzafar)
diff --git a/plugins/magic-enter/Readme.md b/plugins/magic-enter/Readme.md
deleted file mode 100644
index b401ab415..000000000
--- a/plugins/magic-enter/Readme.md
+++ /dev/null
@@ -1,14 +0,0 @@
-## Magic Enter
-
-**Maintainer:** [@dufferzafar](https://github.com/dufferzafar)
-
-Makes your enter key magical, by binding commonly used commands to it.
-
-You can set the commands to be run in your .zshrc, before the line containing plugins!
-
-```bash
-MAGIC_ENTER_GIT_COMMAND='git status -u .'
-MAGIC_ENTER_OTHER_COMMAND='ls -lh .'
-
-plugins=(magic-enter)
-```
diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh
index 8e1859678..55b893535 100644
--- a/plugins/magic-enter/magic-enter.plugin.zsh
+++ b/plugins/magic-enter/magic-enter.plugin.zsh
@@ -1,24 +1,38 @@
-# Bind quick stuff to enter!
-#
-# Pressing enter in a git directory runs `git status`
-# in other directories `ls`
-magic-enter () {
+# 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 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 ."
+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 [[ -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
+ 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
-bindkey "^M" 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
+
+zle -N accept-line _magic-enter_accept-line
diff --git a/plugins/man/man.plugin.zsh b/plugins/man/man.plugin.zsh
index 94aa4918d..dcba613ae 100644
--- a/plugins/man/man.plugin.zsh
+++ b/plugins/man/man.plugin.zsh
@@ -13,15 +13,25 @@
# ------------------------------------------------------------------------------
man-command-line() {
- [[ -z $BUFFER ]] && zle up-history
- [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER"
+ # if there is no command typed, use the last command
+ [[ -z "$BUFFER" ]] && zle up-history
+
+ # if typed command begins with man, do nothing
+ [[ "$BUFFER" = man\ * ]] && return
+
+ # get command and possible subcommand
+ # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
+ local -a args
+ args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
+
+ # check if man page exists for command and first argument
+ if man "${args[1]}-${args[2]}" >/dev/null 2>&1; then
+ BUFFER="man $args"
+ else
+ BUFFER="man ${args[1]}"
+ fi
}
+
zle -N man-command-line
# Defined shortcut keys: [Esc]man
bindkey "\e"man man-command-line
-
-
-# ------------------------------------------------------------------------------
-# Also, you might want to use man-preview included in 'osx' plugin
-# just substitute "man" in the function with "man-preview" after you included OS X in
-# the .zshrc
diff --git a/plugins/mercurial/README.md b/plugins/mercurial/README.md
index f42212d68..80ea2de31 100644
--- a/plugins/mercurial/README.md
+++ b/plugins/mercurial/README.md
@@ -1,60 +1,66 @@
# Mercurial plugin
-### Usage
-Update .zshrc:
-1. Add name to the list of plugins, e.g. `plugins=(... mercurial ...)`
- (that is pretty obvious).
-2. Switch to a theme which uses `hg_prompt_info`.
+This plugin adds some handy aliases for using Mercurial as well as a few
+utility and prompt functions that can be used in a theme.
- Or, customize the `$PROMPT` variable of your current theme to contain current folder mercurial repo info. This can be done by putting a custom version of the theme in `$ZSH_CUSTOM` or by changing `$PROMPT` in `.zshrc` after loading the theme.
+To use it, add `mercurial` to the plugins array in your zshrc file:
- The `robbyrussell` theme is used by default, so you need to modify `$PROMPT` var by adding `$(hg_prompt_info)` after `$(git_prompt_info)`, so it looks like this:
+```zsh
+plugins=(... mercurial)
+```
- ```zsh
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
- ```
+## Aliases
-3. Initialize additional vars used in plugin. So in short put next in **.zshrc**:
+| Alias | Command |
+|--------|-------------------------------------------------------------------------------------------------------------|
+| `hga` | `hg add` |
+| `hgc` | `hg commit` |
+| `hgca` | `hg commit --amend` |
+| `hgb` | `hg branch` |
+| `hgba` | `hg branches` |
+| `hgbk` | `hg bookmarks` |
+| `hgco` | `hg checkout` |
+| `hgd` | `hg diff` |
+| `hged` | `hg diffmerge` |
+| `hgp` | `hg push` |
+| `hgs` | `hg status` |
+| `hgsl` | `hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"` |
+| `hgun` | `hg resolve --list` |
+| `hgi` | `hg incoming` |
+| `hgl` | `hg pull -u` |
+| `hglr` | `hg pull --rebase` |
+| `hgo` | `hg outgoing` |
- ```
- ZSH_THEME_HG_PROMPT_PREFIX="%{$fg_bold[magenta]%}hg:(%{$fg[red]%}"
- ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}"
- ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[magenta]%}) %{$fg[yellow]%}✗%{$reset_color%}"
- ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})"
- ```
+## Prompt usage
-### What's inside?
-#### Adds handy aliases:
-###### general
-* `hgc` - `hg commit`
-* `hgb` - `hg branch`
-* `hgba` - `hg branches`
-* `hgbk` - `hg bookmarks`
-* `hgco` - `hg checkout`
-* `hgd` - `hg diff`
-* `hged` - `hg diffmerge`
+- Switch to a theme which uses `hg_prompt_info`
-###### pull and update
-* `hgi` - `hg incoming`
-* `hgl` - `hg pull -u`
-* `hglr` - `hg pull --rebase`
-* `hgo` - `hg outgoing`
-* `hgp` - `hg push`
-* `hgs` - `hg status`
-* `hgsl` - `hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"`
+- Or customize the `$PROMPT` variable of your current theme to contain current folder mercurial repo info.
+ This can be done by putting a custom version of the theme in `$ZSH_CUSTOM` or by changing `$PROMPT` in
+ `.zshrc` after loading the theme.
-###### this is the 'git commit --amend' equivalent
-* `hgca` - `hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip`
+ For example, for the `robbyrussell` theme you need to modify `$PROMPT` var by adding `$(hg_prompt_info)`
+ after `$(git_prompt_info)`, so it looks like this:
-###### list unresolved files (since hg does not list unmerged files in the status command)
-* `hgun` - `hg resolve --list`
+ ```zsh
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+ ```
-#### Displays repo branch and directory status in prompt
-This is the same as git plugin does.
+You can also redefine additional vars used in the plugin (after Oh My Zsh is sourced):
-**Note**: Additional changes to **.zshrc**, or using a theme designed to use `hg_prompt_info`, are required in order for this to work.
+```zsh
+ZSH_THEME_HG_PROMPT_PREFIX="%{$fg_bold[magenta]%}hg:(%{$fg[red]%}"
+ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[magenta]%}) %{$fg[yellow]%}✗%{$reset_color%}"
+ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})"
+```
-### Mantainers
-[ptrv](https://github.com/ptrv) - original creator
+### Display repo branch and directory status in prompt
-[oshybystyi](https://github.com/oshybystyi) - created this README and know how most of code works
+This is the same as git plugin does. **Note**: additional changes to `.zshrc`, or using a theme designed
+to use `hg_prompt_info`, are required in order for this to work.
+
+## Mantainers
+
+- [ptrv](https://github.com/ptrv): original creator
+- [oshybystyi](https://github.com/oshybystyi)
diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh
index 58bc571a0..a50dcb523 100644
--- a/plugins/mercurial/mercurial.plugin.zsh
+++ b/plugins/mercurial/mercurial.plugin.zsh
@@ -1,23 +1,22 @@
-# Mercurial
+# aliases
alias hga='hg add'
alias hgc='hg commit'
+alias hgca='hg commit --amend'
alias hgb='hg branch'
alias hgba='hg branches'
alias hgbk='hg bookmarks'
alias hgco='hg checkout'
alias hgd='hg diff'
alias hged='hg diffmerge'
+alias hgp='hg push'
+alias hgs='hg status'
+alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"'
+alias hgun='hg resolve --list'
# pull and update
alias hgi='hg incoming'
alias hgl='hg pull -u'
alias hglr='hg pull --rebase'
alias hgo='hg outgoing'
-alias hgp='hg push'
-alias hgs='hg status'
-alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" '
-alias hgca='hg commit --amend'
-# list unresolved files (since hg does not list unmerged files in the status command)
-alias hgun='hg resolve --list'
function in_hg() {
if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then
@@ -64,3 +63,9 @@ function hgic() {
function hgoc() {
hg outgoing "$@" | grep "changeset" | wc -l
}
+
+function hg_get_bookmark_name() {
+ if [ $(in_hg) ]; then
+ echo $(hg id -B)
+ fi
+}
diff --git a/plugins/meteor/README.md b/plugins/meteor/README.md
index 4bee87f8f..f7c43b7bd 100644
--- a/plugins/meteor/README.md
+++ b/plugins/meteor/README.md
@@ -1,9 +1,10 @@
-## Introduction
+# meteor plugin
-The [meteor plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/meteor) provides many
+The [meteor plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/meteor) provides many
[useful aliases](#aliases) as well as completion for the `meteor` command.
Enable it by adding `meteor` to the plugins array in your zshrc file:
+
```zsh
plugins=(... meteor)
```
diff --git a/plugins/microk8s/README.md b/plugins/microk8s/README.md
new file mode 100644
index 000000000..2b4ea206f
--- /dev/null
+++ b/plugins/microk8s/README.md
@@ -0,0 +1,24 @@
+# MicroK8s plugin
+
+This plugin provides completion and useful aliases for [MicroK8s](https://microk8s.io/).
+
+To use it, add `microk8s` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... microk8s)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|-------|------------------|----------------------------------------------------------------------------------------------------------|
+| mco | microk8s.config | Shows the Kubernetes config file. |
+| mct | microk8s.ctr | Interact with containerd CLI. |
+| mdi | microk8s.disable | Disables an addon. |
+| me | microk8s.enable | Enables an addon. |
+| mh | microk8s.helm | Interact with Helm CLI. |
+| mis | microk8s.istio | Interact with Istio CLI. |
+| mk | microk8s.kubectl | Interact with Kubernetes CLI. |
+| msp | microk8s.stop | Stops all Kubernetes services. |
+| mst | microk8s.start | Starts MicroK8s after it is being stopped. |
+| msts | microk8s.status | Provides an overview of the MicroK8s state (running / not running) as well as the set of enabled addons. | \ No newline at end of file
diff --git a/plugins/microk8s/microk8s.plugin.zsh b/plugins/microk8s/microk8s.plugin.zsh
new file mode 100644
index 000000000..048a9ab83
--- /dev/null
+++ b/plugins/microk8s/microk8s.plugin.zsh
@@ -0,0 +1,82 @@
+# ---------------------------------------------------------- #
+# Aliases and Completions for MicroK8s (https://microk8s.io) #
+# Author: Shaun Tabone (https://github.com/xontab) #
+# ---------------------------------------------------------- #
+
+# Helper function to cache and load completions
+_microk8s_cache_completion() {
+ local cache="${ZSH_CACHE_DIR}/microk8s_$(echo $1)_completion"
+ if [[ ! -f $cache ]]; then
+ $2 $cache
+ fi
+
+ [[ -f $cache ]] && source $cache
+}
+
+# ---------------------------------------------------------- #
+# microk8s.enable #
+# ALIAS: me #
+# ---------------------------------------------------------- #
+_microk8s_enable_get_command_list() {
+ microk8s.enable --help | tail -n +7 | awk '{$1=$1;print}'
+}
+
+_microk8s_enable() {
+ compadd -X "MicroK8s Addons" $(_microk8s_enable_get_command_list)
+}
+
+compdef _microk8s_enable microk8s.enable
+alias me='microk8s.enable'
+
+# ---------------------------------------------------------- #
+# microk8s.disable #
+# ALIAS: mdi #
+# ---------------------------------------------------------- #
+_microk8s_disable_get_command_list() {
+ microk8s.disable --help | tail -n +7 | awk '{$1=$1;print}'
+}
+
+_microk8s_disable() {
+ compadd -X "MicroK8s Addons" $(_microk8s_disable_get_command_list)
+}
+
+compdef _microk8s_disable microk8s.disable
+alias mdi='microk8s.disable'
+
+# ---------------------------------------------------------- #
+# microk8s.kubectl #
+# ALIAS: mk #
+# ---------------------------------------------------------- #
+_microk8s_kubectl_completion() {
+ if [ $commands[microk8s.kubectl] ]; then
+ microk8s.kubectl 2>/dev/null >/dev/null && microk8s.kubectl completion zsh | sed 's/__start_kubectl kubectl/__start_kubectl microk8s.kubectl/g' >$1
+ fi
+}
+
+_microk8s_cache_completion 'kubectl' _microk8s_kubectl_completion
+
+alias mk='microk8s.kubectl'
+
+# ---------------------------------------------------------- #
+# microk8s.helm #
+# ALIAS: mh #
+# ---------------------------------------------------------- #
+_microk8s_helm_completion() {
+ if [ $commands[microk8s.helm] ]; then
+ microk8s.helm completion zsh | sed 's/__start_helm helm/__start_helm microk8s.helm/g' >$1
+ fi
+}
+
+_microk8s_cache_completion 'helm' _microk8s_helm_completion
+
+alias mh='microk8s.helm'
+
+# ---------------------------------------------------------- #
+# Other Aliases #
+# ---------------------------------------------------------- #
+alias mco='microk8s.config'
+alias mct='microk8s.ctr'
+alias mis='microk8s.istio'
+alias mst='microk8s.start'
+alias msts='microk8s.status'
+alias msp='microk8s.stop'
diff --git a/plugins/minikube/minikube.plugin.zsh b/plugins/minikube/minikube.plugin.zsh
index d8ebe79af..e87abceaf 100644
--- a/plugins/minikube/minikube.plugin.zsh
+++ b/plugins/minikube/minikube.plugin.zsh
@@ -1,6 +1,13 @@
# Autocompletion for Minikube.
#
+if (( $+commands[minikube] )); then
+ __MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion"
-if [ $commands[minikube] ]; then
- source <(minikube completion zsh)
+ if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then
+ minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE
+ fi
+
+ [[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_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/mix/_mix b/plugins/mix/_mix
index 61fa1cf25..c0fe68c91 100644
--- a/plugins/mix/_mix
+++ b/plugins/mix/_mix
@@ -34,6 +34,7 @@ _1st_arguments=(
'firmware:Nerves - Build a firmware image for the selected target platform'
'firmware.burn:Nerves - Writes the generated firmware image to an attached SDCard or file'
'firmware.image:Nerves - Create a firmware image file that can be copied byte-for-byte'
+ 'format:Formats the given files and patterns'
'help:Print help information for tasks'
'hex:Print hex help information'
'hex.config:Read or update hex config'
@@ -92,7 +93,7 @@ __task_list ()
local expl
declare -a tasks
- tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.presence phx.gen.schema phx.gen.secret phx.new phx.new.ecto phx.new.web phx.routes phx.server run test)
+ tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build format help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.presence phx.gen.schema phx.gen.secret phx.new phx.new.ecto phx.new.web phx.routes phx.server run test)
_wanted tasks expl 'help' compadd $tasks
}
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 986ac84a4..815dfd57c 100644
--- a/plugins/mvn/README.md
+++ b/plugins/mvn/README.md
@@ -1,34 +1,61 @@
-## Introduction
+# mvn plugin
-The [mvn plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/mvn) provides many
-[useful aliases](#aliases) as well as completion for the `mvn` command.
+The mvn plugin provides many [useful aliases](#aliases) as well as completion for
+the [Apache Maven](https://maven.apache.org/) command (`mvn`).
Enable it by adding `mvn` to the plugins array in your zshrc file:
+
```zsh
plugins=(... mvn)
```
## Aliases
+The plugin aliases mvn to a function that calls `mvnw` (the [Maven Wrapper](https://github.com/takari/maven-wrapper))
+if it's found, or the mvn command otherwise.
+
| Alias | Command |
|:---------------------|:------------------------------------------------|
-| `mvncie` | `mvn clean install eclipse:eclipse` |
+| `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` |
| `mvnci` | `mvn clean install` |
+| `mvncie` | `mvn clean install eclipse:eclipse` |
+| `mvncini` | `mvn clean initialize` |
| `mvncist` | `mvn clean install -DskipTests` |
| `mvncisto` | `mvn clean install -DskipTests --offline` |
-| `mvne` | `mvn eclipse:eclipse` |
-| `mvncv` | `mvn clean verify` |
-| `mvnd` | `mvn deploy` |
-| `mvnp` | `mvn package` |
-| `mvnc` | `mvn clean` |
| `mvncom` | `mvn compile` |
+| `mvncp` | `mvn clean package` |
| `mvnct` | `mvn clean test` |
-| `mvnt` | `mvn test` |
-| `mvnag` | `mvn archetype:generate` |
-| `mvn-updates` | `mvn versions:display-dependency-updates` |
-| `mvntc7` | `mvn tomcat7:run` |
-| `mvnjetty` | `mvn jetty:run` |
+| `mvncv` | `mvn clean verify` |
+| `mvncvst` | `mvn clean verify -DskipTests` |
+| `mvnd` | `mvn deploy` |
+| `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` |
| `mvnsrc` | `mvn dependency:sources` |
-| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
+| `mvnt` | `mvn test` |
+| `mvntc` | `mvn tomcat:run` |
+| `mvntc7` | `mvn tomcat7:run` |
+| `mvn-updates` | `mvn versions:display-dependency-updates` |
+
+## mvn-color
+
+It's a function that wraps the mvn command to colorize it's output. You can use it in place
+of the `mvn` command. For example: instead of `mvn test`, use `mvn-color test`.
+
+Since [Maven 3.5.0](https://maven.apache.org/docs/3.5.0/release-notes.html) the mvn command
+has colored output, so this function will be soon removed from the plugin.
+
+### Known bugs
+
+It has a bug where it will swallow mvn prompts for user input, _e.g._ when using
+`archetype:generate`. See [#5052](https://github.com/ohmyzsh/ohmyzsh/issues/5052).
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index f367fecce..27d63a6f9 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -1,292 +1,335 @@
-# mvn-color based on https://gist.github.com/1027800
-BOLD=$(tput bold)
-UNDERLINE_ON=$(tput smul)
-UNDERLINE_OFF=$(tput rmul)
-TEXT_BLACK=$(tput setaf 0)
-TEXT_RED=$(tput setaf 1)
-TEXT_GREEN=$(tput setaf 2)
-TEXT_YELLOW=$(tput setaf 3)
-TEXT_BLUE=$(tput setaf 4)
-TEXT_MAGENTA=$(tput setaf 5)
-TEXT_CYAN=$(tput setaf 6)
-TEXT_WHITE=$(tput setaf 7)
-BACKGROUND_BLACK=$(tput setab 0)
-BACKGROUND_RED=$(tput setab 1)
-BACKGROUND_GREEN=$(tput setab 2)
-BACKGROUND_YELLOW=$(tput setab 3)
-BACKGROUND_BLUE=$(tput setab 4)
-BACKGROUND_MAGENTA=$(tput setab 5)
-BACKGROUND_CYAN=$(tput setab 6)
-BACKGROUND_WHITE=$(tput setab 7)
-RESET_FORMATTING=$(tput sgr0)
-
-# if found an executable ./mvnw file execute it otherwise execute orignal mvn
+# Calls ./mvnw if found, otherwise execute the original mvn
mvn-or-mvnw() {
- if [ -x ./mvnw ] ; then
- echo "executing mvnw instead of mvn"
- ./mvnw "$@";
+ if [ -x ./mvnw ]; then
+ echo "executing mvnw instead of mvn"
+ ./mvnw "$@"
else
- mvn "$@";
+ command mvn "$@"
fi
}
-# Wrapper function for Maven's mvn command.
+# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
mvn-color() {
- (
- # 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/\(\[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"
-# Override the mvn command with the colorized one.
-#alias mvn="mvn-color"
+ # Make sure formatting is reset
+ echo -ne "${RESET_FORMATTING}"
+ )
+}
-# either use orignal mvn oder the mvn wrapper
+# either use orignal 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)
+alias 'mvn!'='mvn -f $(git rev-parse --show-toplevel 2>/dev/null || echo ".")/pom.xml'
+
# aliases
-alias mvncie='mvn clean install eclipse:eclipse'
+alias mvnag='mvn archetype:generate'
+alias mvnboot='mvn spring-boot:run'
+alias mvnc='mvn clean'
+alias mvncd='mvn clean deploy'
+alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
alias mvnci='mvn clean install'
+alias mvncie='mvn clean install eclipse:eclipse'
+alias mvncini='mvn clean initialize'
alias mvncist='mvn clean install -DskipTests'
alias mvncisto='mvn clean install -DskipTests --offline'
-alias mvne='mvn eclipse:eclipse'
-alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
-alias mvncv='mvn clean verify'
-alias mvnd='mvn deploy'
-alias mvnp='mvn package'
-alias mvnc='mvn clean'
alias mvncom='mvn compile'
+alias mvncp='mvn clean package'
alias mvnct='mvn clean test'
-alias mvnt='mvn test'
-alias mvnag='mvn archetype:generate'
-alias mvn-updates='mvn versions:display-dependency-updates'
-alias mvntc7='mvn tomcat7:run'
-alias mvntc='mvn tomcat:run'
-alias mvnjetty='mvn jetty:run'
-alias mvnboot='mvn spring-boot:run'
+alias mvncv='mvn clean verify'
+alias mvncvst='mvn clean verify -DskipTests'
+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 mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
+alias mvnt='mvn test'
+alias mvntc='mvn tomcat:run'
+alias mvntc7='mvn tomcat7:run'
+alias mvn-updates='mvn versions:display-dependency-updates'
-function listMavenCompletions {
- reply=(
- # common lifecycle
- clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site
+function listMavenCompletions {
+ 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
- # 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
+ # 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/')
- # 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
+ # if <parent> is present but not defined, assume ../pom.xml
+ if [[ -z "$new_file" ]]; then
+ new_file="../pom.xml"
+ fi
- # 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
+ # if file doesn't exist break
+ file="${file:h}/${new_file}"
+ if ! [[ -e "$file" ]]; then
+ break
+ fi
- # 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
+ POM_FILES+=("${file:A}")
+ done
- # eclipse
- eclipse:clean eclipse:eclipse
- # idea
- idea:clean idea:idea
+ # 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
- # 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
+ # List modules
+ modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
- # 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
+ reply=(
+ # common lifecycle
+ clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
- # 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
-
- # 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="
+ # integration testing
+ pre-integration-test integration-test
- # 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
+ # 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
- 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)
- );
+ # 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
+compctl -K listMavenCompletions mvn mvnw
+compctl -K listMavenCompletions mvn-color
compctl -K listMavenCompletions mvn-or-mvnw
-
diff --git a/plugins/mysql-macports/README.md b/plugins/mysql-macports/README.md
new file mode 100644
index 000000000..ff4fb3a34
--- /dev/null
+++ b/plugins/mysql-macports/README.md
@@ -0,0 +1,20 @@
+# MySQL-Macports plugin
+
+This plugin adds aliases for some of the commonly used [MySQL](https://www.mysql.com/) commands when installed using [MacPorts](https://www.macports.org/) on macOS.
+
+To use it, add `mysql-macports` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... mysql-macports)
+```
+
+For instructions on how to install MySQL using MacPorts, read the [MacPorts wiki](https://trac.macports.org/wiki/howto/MySQL/).
+
+## Aliases
+
+| Alias | Command | Description |
+| ------------ | ------------------------------------ | ------------------------------------------ |
+| mysqlstart | `sudo /path/to/mysql.server start` | Start the MySQL server. |
+| mysqlstop | `sudo /path/to/mysql.server stop` | Stop the MySQL server. |
+| mysqlrestart | `sudo /path/to/mysql.server restart` | Restart the MySQL server. |
+| mysqlstatus | `mysqladmin5 -u root -p ping` | Check whether the MySQL server is running. |
diff --git a/plugins/n98-magerun/README.md b/plugins/n98-magerun/README.md
new file mode 100644
index 000000000..b0abe4747
--- /dev/null
+++ b/plugins/n98-magerun/README.md
@@ -0,0 +1,21 @@
+# n98-magerun plugin
+
+The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time.
+
+The [n98-magerun plugin](https://github.com/netz98/n98-magerun) provides many
+[useful aliases](#aliases) as well as completion for the `n98-magerun` command.
+
+Enable it by adding `n98-magerun` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... n98-magerun)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+| --------- | -------------------------------------------------- | --------------------------------------------------------------------------------- |
+| n98 | `n98-magerun.phar` | The N98-Magerun phar-file (Version 1) |
+| n98-2 | `n98-magerun2.phar` | The N98-Magerun phar-file (Version 2) |
+| mage-get | `wget https://files.magerun.net/n98-magerun.phar` | Download the latest stable N98-Magerun phar-file from the file-server (Version 1) |
+| mage2-get | `wget https://files.magerun.net/n98-magerun2.phar` | Download the latest stable N98-Magerun phar-file from the file-server (Version 2) |
diff --git a/plugins/n98-magerun/n98-magerun.plugin.zsh b/plugins/n98-magerun/n98-magerun.plugin.zsh
index bfcf27b98..d79aee7eb 100644
--- a/plugins/n98-magerun/n98-magerun.plugin.zsh
+++ b/plugins/n98-magerun/n98-magerun.plugin.zsh
@@ -2,7 +2,8 @@
# FILE: n98-magerun.plugin.zsh
# DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin
# AUTHOR: Andrew Dwyer (andrewrdwyer at gmail dot com)
-# VERSION: 1.0.0
+# AUTHOR: Jisse Reitsma (jisse at yireo dot com)
+# VERSION: 1.1.0
# ------------------------------------------------------------------------------
# n98-magerun basic command completion
@@ -24,11 +25,18 @@ _n98_magerun () {
compdef _n98_magerun n98-magerun.phar
compdef _n98_magerun n98-magerun
+compdef _n98_magerun n98-magerun2.phar
+compdef _n98_magerun n98-magerun2
# Aliases
alias n98='n98-magerun.phar'
alias mage='n98-magerun.phar'
-alias magefl='n98-magerun.phar cache:flush'
+alias magerun='n98-magerun.phar'
+
+alias n98-2='n98-magerun2.phar'
+alias mage2='n98-magerun2.phar'
+alias magerun2='n98-magerun2.phar'
# Install n98-magerun into the current directory
-alias mage-get='wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar'
+alias mage-get='wget https://files.magerun.net/n98-magerun.phar'
+alias mage2-get='wget https://files.magerun.net/n98-magerun2.phar'
diff --git a/plugins/ng/README.md b/plugins/ng/README.md
index 86ad64041..29ac15aa4 100644
--- a/plugins/ng/README.md
+++ b/plugins/ng/README.md
@@ -1,37 +1,10 @@
-## NG Plugin
+# ng plugin
-This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng)
- adds completion support for Angular's CLI (named ng).
+This plugin adds autocompletion support for [Angular's CLI](https://github.com/angular/angular-cli)
+(named `ng`).
-Ng is hosted on [ng home](https://github.com/catull/angular-cli)
-
-It is used to generate Angular 2 app "stubs", build those apps, configure them,
-test them, lint them etc.
-
-Ahem, "stubs" is not what Angular engineers refer to the items ng can generate
-for you.
-
-"Stubs" can be any one of:
-- class
-- component
-- directive
-- enum
-- module
-- pipe
-- route
-- service
-
-At the moment, `ng completion` creates a very rough completion for Zsh and
-Bash.
-
-It is missing most of the options and a few arguments.
-In future, this plugin may be shortened to simply being
+To use it, add `ng` to the plugins array of your zshrc file:
```zsh
-eval `ng completion`
+plugins=(... ng)
```
-
-There is hope this materialises in the 21st century.
-
-### CONTRIBUTOR
- - Carlo Dapor ([catull](https://github.com/catull))
diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh
index b802bf617..44102e2a6 100644
--- a/plugins/ng/ng.plugin.zsh
+++ b/plugins/ng/ng.plugin.zsh
@@ -1,4 +1,3 @@
-
ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test update v version -h --help'
_ng_completion () {
@@ -73,9 +72,7 @@ _ng_completion () {
;;
esac
- setopt shwordsplit
- reply=($opts)
- unset shwordsplit
+ reply=(${=opts})
}
compctl -K _ng_completion ng
diff --git a/plugins/nmap/README.md b/plugins/nmap/README.md
index 5cd646277..0a60068c2 100644
--- a/plugins/nmap/README.md
+++ b/plugins/nmap/README.md
@@ -1,37 +1,27 @@
-# Nmap aliases plugin
+# Nmap plugin
-Adds some useful aliases for nmap similar to the profiles in zenmap.
+Adds some useful aliases for [Nmap](https://nmap.org/) similar to the profiles in zenmap.
-Nmap options are:
- * -sS - TCP SYN scan
- * -v - verbose
- * -T1 - timing of scan. Options are paranoid (0), sneaky (1), polite (2), normal (3), aggressive (4), and insane (5)
- * -sF - FIN scan (can sneak through non-stateful firewalls)
- * -PE - ICMP echo discovery probe
- * -PP - timestamp discovery probe
- * -PY - SCTP init ping
- * -g - use given number as source port
- * -A - enable OS detection, version detection, script scanning, and traceroute (aggressive)
- * -O - enable OS detection
- * -sA - TCP ACK scan
- * -F - fast scan
- * --script=vulscan - also access vulnerabilities in target
+To use it, add `nmap` to the plugins array in your zshrc file:
-## Aliases explained
+```zsh
+plugins=(... nmap)
+```
- * nmap_open_ports - Scan for open ports on target
- * nmap_list_interfaces - List all network interfaces on host where the command runs
- * nmap_slow - Slow scan that avoids to spam the targets logs
- * nmap_fin - Scan to see if hosts are up with TCP FIN scan
- * nmap_full - Aggressive full scan that scans all ports, tries to determine OS and service versions
- * nmap_check_for_firewall - TCP ACK scan to check for firewall existence
- * nmap_ping_through_firewall - Host discovery with SYN and ACK probes instead of just pings to avoid firewall
- restrictions
- * nmap_fast - Fast scan of the top 300 popular ports
- * nmap_detect_versions - Detects versions of services and OS, runs on all ports
- * nmap_check_for_vulns - Uses vulscan script to check target services for vulnerabilities
- * nmap_full_udp - Same as full but via UDP
- * nmap_traceroute - Try to traceroute using the most common ports
- * nmap_full_with_scripts - Same as nmap_full but also runs all the scripts
- * nmap_web_safe_osscan - Little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking.
+## Aliases
+- `nmap_open_ports`: scan for open ports on target.
+- `nmap_list_interfaces`: list all network interfaces on host where the command runs.
+- `nmap_slow`: slow scan that avoids to spam the targets logs.
+- `nmap_fin`: scan to see if hosts are up with TCP FIN scan.
+- `nmap_full`: aggressive full scan that scans all ports, tries to determine OS and service versions.
+- `nmap_check_for_firewall`: TCP ACK scan to check for firewall existence.
+- `nmap_ping_through_firewall`: host discovery with SYN and ACK probes instead of just pings to avoid firewall restrictions.
+- `nmap_fast`: fast scan of the top 300 popular ports.
+- `nmap_detect_versions`: detects versions of services and OS, runs on all ports.
+- `nmap_check_for_vulns`: uses vulscan script to check target services for vulnerabilities.
+- `nmap_full_udp`: same as full but via UDP.
+- `nmap_traceroute`: try to traceroute using the most common ports.
+- `nmap_full_with_scripts`: same as nmap_full but also runs all the scripts.
+- `nmap_web_safe_osscan`: little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking.
+- `nmap_ping_scan`: ICMP scan for active hosts.
diff --git a/plugins/nmap/nmap.plugin.zsh b/plugins/nmap/nmap.plugin.zsh
index 8c691bdaa..406870f00 100644
--- a/plugins/nmap/nmap.plugin.zsh
+++ b/plugins/nmap/nmap.plugin.zsh
@@ -29,4 +29,4 @@ alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443
alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
-
+alias nmap_ping_scan="nmap -n -sP"
diff --git a/plugins/node/README.md b/plugins/node/README.md
index c392dc0bf..911b6693b 100644
--- a/plugins/node/README.md
+++ b/plugins/node/README.md
@@ -1,16 +1,19 @@
# node plugin
+This plugin adds `node-docs` function that opens specific section in [Node.js](https://nodejs.org)
+documentation (depending on the installed version).
+
To use it, add `node` to the plugins array of your zshrc file:
+
```zsh
plugins=(... node)
```
-This plugin adds `node-docs` function that open specific section in [Node.js](https://nodejs.org) documentation (depending on the installed version).
-For example:
+## Usage
```zsh
# Opens https://nodejs.org/docs/latest-v10.x/api/fs.html
$ node-docs fs
# Opens https://nodejs.org/docs/latest-v10.x/api/path.html
-$ node-docs path
+$ node-docs path
```
diff --git a/plugins/npm/README.md b/plugins/npm/README.md
index 202e2b0a4..47d153619 100644
--- a/plugins/npm/README.md
+++ b/plugins/npm/README.md
@@ -1,9 +1,10 @@
-## npm plugin
+# npm plugin
The npm plugin provides completion as well as adding many useful aliases.
To use it, add npm to the plugins array of your zshrc file:
-```
+
+```zsh
plugins=(... npm)
```
@@ -14,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 |
@@ -24,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 f62174a4f..f7d6d3939 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -1,14 +1,16 @@
(( $+commands[npm] )) && {
- __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
-
- if [[ ! -f $__NPM_COMPLETION_FILE ]]; then
- npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null
- [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE
- fi
-
- [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE
-
- unset __NPM_COMPLETION_FILE
+ rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
+
+ _npm_completion() {
+ local si=$IFS
+ compadd -- $(COMP_CWORD=$((CURRENT-1)) \
+ COMP_LINE=$BUFFER \
+ COMP_POINT=0 \
+ npm completion -- "${words[@]}" \
+ 2>/dev/null)
+ IFS=$si
+ }
+ compdef _npm_completion npm
}
# Install dependencies globally
@@ -25,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"'
@@ -32,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"
@@ -55,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..700613085 100644
--- a/plugins/nvm/README.md
+++ b/plugins/nvm/README.md
@@ -1,9 +1,28 @@
# 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` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`.
+
+- **`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 b/plugins/nvm/_nvm
index 1eec48b0a..e292a8d8c 100644
--- a/plugins/nvm/_nvm
+++ b/plugins/nvm/_nvm
@@ -8,6 +8,7 @@ _1st_arguments=(
'help:show help'
'--version:print out the latest released version of nvm'
'install:download and install a version in <node|iojs|node version number>'
+ 'install-latest-npm:download and install the latest npm version'
'uninstall:uninstall a version'
'use:modify PATH to use <version>. Uses .nvmrc if available'
'exec:run <command> on <version>. Uses .nvmrc if available'
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 9dde3a266..1e9b26e7a 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -1,5 +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
-# Load nvm if it exists
-[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
+# 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 {
+ unfunction node npm yarn
+ nvm use default
+ command "$0" "$@"
+ }
+fi
+
+# 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/nyan/README.md b/plugins/nyan/README.md
deleted file mode 100644
index 592941824..000000000
--- a/plugins/nyan/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Nyan plugin
-
-This plugin adds a command to display [Nyan Cat](https://en.wikipedia.org/wiki/Nyan_Cat) right inside your terminal.
-
-**Plugin is deprecated**. Check [official repo](https://github.com/klange/nyancat) for more information. \ No newline at end of file
diff --git a/plugins/nyan/nyan.plugin.zsh b/plugins/nyan/nyan.plugin.zsh
deleted file mode 100644
index c21c784d9..000000000
--- a/plugins/nyan/nyan.plugin.zsh
+++ /dev/null
@@ -1,10 +0,0 @@
-print -Pn '%F{yellow}'
-cat >&2 <<-EOD
- nyan plugin:
- The nyancat server used by this plugin was shut down due to increased
- bandwidth costs, so the nyan plugin no longer works. You can get the
- same functionality in some distributions by installing the nyancat package,
- or you can compile it yourself.
- See https://github.com/klange/nyancat for more information.
-EOD
-print -Pn '%f'
diff --git a/plugins/oc/README.md b/plugins/oc/README.md
new file mode 100644
index 000000000..deae9b2d0
--- /dev/null
+++ b/plugins/oc/README.md
@@ -0,0 +1,13 @@
+# OC - OpenShift CLI
+
+This plugin provides autocompletion for [OC](https://docs.openshift.com/container-platform/3.7/cli_reference/index.html) commands, building, managing and updating operations.
+
+To use it, add `oc` to the plugins array of your zshrc file:
+
+```bash
+plugins=(... oc)
+```
+
+## Contributors
+
++ [kevinkirkup](https://github.com/kevinkirkup) - Plugin Author
diff --git a/plugins/osx/README.md b/plugins/osx/README.md
index 3559dee02..ecc9327d0 100644
--- a/plugins/osx/README.md
+++ b/plugins/osx/README.md
@@ -1,8 +1,6 @@
# OSX plugin
-## Description
-
-This plugin provides a few utilities to make it more enjoyable on OSX.
+This plugin provides a few utilities to make it more enjoyable on macOS (previously named OSX).
To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`:
@@ -12,13 +10,37 @@ plugins=(... osx)
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
+## Commands
+
+| Command | Description |
+| :-------------- | :---------------------------------------------------- |
+| `tab` | Open the current directory in a new tab |
+| `split_tab` | Split the current terminal tab horizontally |
+| `vsplit_tab` | Split the current terminal tab vertically |
+| `ofd` | Open the current directory in a Finder window |
+| `pfd` | Return the path of the frontmost Finder window |
+| `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 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
This application makes use of the following third party scripts:
[shpotify](https://github.com/hnarayanan/shpotify)
-Copyright (c) 2012–2017 [Harish Narayanan](https://harishnarayanan.org/).
+Copyright (c) 2012–2019 [Harish Narayanan](https://harishnarayanan.org/).
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -38,24 +60,3 @@ 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.
-
-
-## Commands
-
-| Command | Description |
-| :-------------- | :-------------------------------------------------- |
-| `tab` | Open the current directory in a new tab |
-| `split_tab` | Split the current terminal tab horizontally |
-| `vsplit_tab` | Split the current terminal tab vertically |
-| `ofd` | Open the current directory in a Finder window |
-| `pfd` | Return the path of the frontmost Finder window |
-| `pfs` | Return the current Finder selection |
-| `cdf` | `cd` to the current Finder directory |
-| `pushdf` | `pushd` to the current Finder 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` | Control iTunes. Use `itunes -h` for usage details |
-| `spotify` | Control Spotify and search by artist, album, track… |
-| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
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 6a4b6eec4..7842e9f73 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,21 +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
EOF
-
else
- echo "tab: unsupported terminal app: $the_app"
- false
-
+ echo "$0: unsupported terminal app: $the_app" >&2
+ return 1
fi
}
@@ -68,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
@@ -78,24 +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
+ end tell
+ delay 1
+ keystroke "${command} \n"
+ end tell
EOF
-
else
echo "$0: unsupported terminal app: $the_app" >&2
- false
-
+ return 1
fi
}
@@ -118,31 +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
+ 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
}
@@ -168,6 +199,21 @@ 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 &
}
@@ -181,109 +227,13 @@ function vncviewer() {
open vnc://$@
}
-# iTunes control function
-function itunes() {
- 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)
- opt="set sound volume to $1" #$1 Due to the shift
- ;;
- playlist)
- # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
-if [[ ! -z "$playlist" ]]; then
- osascript -e 'tell application "iTunes"' -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 "iTunes" to player state as string'`
- if [[ "$state" = "playing" ]]; then
- currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'`
- currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'`
- echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
- else
- echo "iTunes 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: itunes 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: itunes <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\tSet the volume, takes an argument from 0 to 100"
- echo "\tplaying|status\tShow what song is currently playing in iTunes."
- 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 \"iTunes\" to $opt"
+# Remove .DS_Store files recursively in a directory, default .
+function rmdsstore() {
+ find "${@:-.}" -type f -name .DS_Store -delete
}
-# 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"
+# Music / iTunes control function
+source "${0:h:A}/music"
-# Remove .DS_Store files recursively in a directory, default .
-rmdsstore() {
- find "${@:-.}" -type f -name .DS_Store -delete
-}
+# Spotify control function
+source "${0:h:A}/spotify"
diff --git a/plugins/osx/spotify b/plugins/osx/spotify
index 2ab98d3a0..663215a74 100644
--- a/plugins/osx/spotify
+++ b/plugins/osx/spotify
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
function spotify() {
-# Copyright (c) 2012--2017 Harish Narayanan <mail@harishnarayanan.org>
+# Copyright (c) 2012--2019 Harish Narayanan <mail@harishnarayanan.org>
#
# Contains numerous helpful contributions from Jorge Colindres, Thomas
# Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin
@@ -70,7 +70,7 @@ showHelp () {
echo;
echo " next # Skips to the next song in a playlist.";
echo " prev # Returns to the previous song in a playlist.";
- echo " replay # Replays the current track from the begining.";
+ echo " replay # Replays the current track from the beginning.";
echo " pos <time> # Jumps to a time (in secs) in the current song.";
echo " pause # Pauses (or resumes) Spotify playback.";
echo " stop # Stops playback.";
@@ -82,6 +82,9 @@ showHelp () {
echo " vol [show] # Shows the current Spotify volume.";
echo;
echo " status # Shows the current player status.";
+ echo " status artist # Shows the currently playing artist.";
+ echo " status album # Shows the currently playing album.";
+ echo " status track # Shows the currently playing track.";
echo;
echo " share # Displays the current song's Spotify URL and URI."
echo " share url # Displays the current song's Spotify URL and copies it to the clipboard."
@@ -99,12 +102,21 @@ cecho(){
echo $bold$green"$1"$reset;
}
+showArtist() {
+ echo `osascript -e 'tell application "Spotify" to artist of current track as string'`;
+}
+
+showAlbum() {
+ echo `osascript -e 'tell application "Spotify" to album of current track as string'`;
+}
+
+showTrack() {
+ echo `osascript -e 'tell application "Spotify" to name of current track as string'`;
+}
+
showStatus () {
state=`osascript -e 'tell application "Spotify" to player state as string'`;
cecho "Spotify is currently $state.";
- artist=`osascript -e 'tell application "Spotify" to artist of current track as string'`;
- album=`osascript -e 'tell application "Spotify" to album of current track as string'`;
- track=`osascript -e 'tell application "Spotify" to name of current track as string'`;
duration=`osascript -e 'tell application "Spotify"
set durSec to (duration of current track / 1000) as text
set tM to (round (durSec / 60) rounding down) as text
@@ -128,14 +140,19 @@ showStatus () {
end tell
return nowAt'`;
- echo -e $reset"Artist: $artist\nAlbum: $album\nTrack: $track \nPosition: $position / $duration";
+ echo -e $reset"Artist: $(showArtist)\nAlbum: $(showAlbum)\nTrack: $(showTrack) \nPosition: $position / $duration";
}
if [ $# = 0 ]; then
showHelp;
else
+ if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then
+ echo "The Spotify application must be installed."
+ return 1
+ fi
+
if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then
- osascript -e 'tell application "Spotify" to activate'
+ osascript -e 'tell application "Spotify" to activate' || return 1
sleep 2
fi
fi
@@ -153,14 +170,14 @@ while [ $# -gt 0 ]; do
if [ -z "${CLIENT_ID}" ]; then
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
showAPIHelp;
- exit 1;
+ return 1
fi
if [ -z "${CLIENT_SECRET}" ]; then
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
showAPIHelp;
- exit 1;
+ return 1
fi
- SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n");
+ SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
SPOTIFY_PLAY_URI="";
getAccessToken() {
@@ -177,7 +194,7 @@ while [ $# -gt 0 ]; do
cecho "Autorization failed, please check ${USER_CONFG_FILE}"
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
showAPIHelp
- exit 1
+ return 1
fi
SPOTIFY_ACCESS_TOKEN=$( \
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
@@ -218,18 +235,18 @@ while [ $# -gt 0 ]; do
results=$( \
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
- | grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \
+ | grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
)
count=$( \
- echo "$results" | grep -c "spotify:user" \
+ echo "$results" | grep -c "spotify:playlist" \
)
if [ "$count" -gt 0 ]; then
random=$(( $RANDOM % $count));
SPOTIFY_PLAY_URI=$( \
- echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
+ echo "$results" | awk -v random="$random" '/spotify:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
)
fi;;
@@ -290,7 +307,7 @@ while [ $# -gt 0 ]; do
"quit" ) cecho "Quitting Spotify.";
osascript -e 'tell application "Spotify" to quit';
- exit 1 ;;
+ break ;;
"next" ) cecho "Going to next track." ;
osascript -e 'tell application "Spotify" to next track';
@@ -341,7 +358,7 @@ while [ $# -gt 0 ]; do
echo " vol down # Decreases the volume by 10%.";
echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
echo " vol # Shows the current Spotify volume.";
- break
+ return 1
fi
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
@@ -360,7 +377,25 @@ while [ $# -gt 0 ]; do
break ;;
"status" )
- showStatus;
+ if [ $# != 1 ]; then
+ # There are additional arguments, a status subcommand
+ case $2 in
+ "artist" )
+ showArtist;
+ break ;;
+
+ "album" )
+ showAlbum;
+ break ;;
+
+ "track" )
+ showTrack;
+ break ;;
+ esac
+ else
+ # status is the only param
+ showStatus;
+ fi
break ;;
"info" )
@@ -423,16 +458,21 @@ while [ $# -gt 0 ]; do
cecho "Spotify URI: $uri";
echo -n $uri | pbcopy
fi
- break;;
+ break ;;
"pos" )
cecho "Adjusting Spotify play position."
osascript -e "tell application \"Spotify\" to set player position to $2";
- break;;
+ break ;;
- "help" | * )
+ "help" )
showHelp;
break ;;
+
+ * )
+ showHelp;
+ return 1 ;;
+
esac
done
}
diff --git a/plugins/otp/README.md b/plugins/otp/README.md
new file mode 100644
index 000000000..8331fd02b
--- /dev/null
+++ b/plugins/otp/README.md
@@ -0,0 +1,22 @@
+# otp plugin
+
+This plugin allows you to create one-time passwords using [`oathtool`](https://www.nongnu.org/oath-toolkit/man-oathtool.html),
+able to replace MFA devices. The oathtool key is kept in a GPG-encrypted file so the codes
+can only be generated by a user able to decrypt it.
+
+To use it, add `otp` to the plugins array in your zshrc file:
+```zsh
+plugins=(... otp)
+```
+
+Provided aliases:
+
+- `otp_add_device`: creates a new encrypted storage for an oathtool key and stores it
+ on the disk. For encrypting the key, it will ask for a GPG user ID (your GPG key's
+ email address). Then the OTP key needs to be pasted, followed by a CTRL+D character
+ inserted on an empty line.
+
+- `ot`: generates a MFA code based on the given key and copies it to the clipboard
+ (on Linux it relies on xsel, on MacOS X it uses pbcopy instead).
+
+The plugin uses `$HOME/.otp` to store its internal files.
diff --git a/plugins/otp/otp.plugin.zsh b/plugins/otp/otp.plugin.zsh
new file mode 100644
index 000000000..8be125c93
--- /dev/null
+++ b/plugins/otp/otp.plugin.zsh
@@ -0,0 +1,45 @@
+export OTP_HOME=~/.otp
+mkdir -p $OTP_HOME
+
+function ot () {
+ if ! command -v oathtool > /dev/null 2>&1; then
+ echo "Note: you need to install oathtool or oath-toolkit, depending on your OS or distribution."
+ return 1
+ fi
+
+ if ! command -v gpg > /dev/null 2>&1; then
+ echo "Note: you need to install gpg and create an ID using 'gpg --gen-key', unless you have one already."
+ return 1
+ fi
+
+ COPY_CMD='true'
+
+ if [[ -z "$1" ]]; then
+ echo "usage: $0 <profile.name>"
+ return 1
+ elif [ ! -f $OTP_HOME/$1.otp.asc ]; then
+ echo "missing profile $1, you might need to create it first using otp_add_device"
+ return 1
+ else
+ totpkey=$(gpg --decrypt $OTP_HOME/$1.otp.asc)
+ oathtool --totp --b $totpkey | tee /dev/stderr | clipcopy
+ fi
+}
+
+function otp_add_device () {
+ if [[ "x$1" == "x" ]] then
+ echo "usage: $0 <profile.name>"
+ return 1
+ else
+ echo "Enter an email address attached to your GPG private key, then paste the secret configuration key followed by ^D"
+
+ rm -f $OTP_HOME/$1.otp.asc
+ gpg --armor --encrypt --output $OTP_HOME/$1.otp.asc /dev/stdin
+ fi
+}
+
+function otp_devices () {
+ reply=($(find $OTP_HOME -name \*.otp.asc | xargs basename -s .otp.asc))
+}
+
+compctl -K otp_devices ot
diff --git a/plugins/pass/README.md b/plugins/pass/README.md
new file mode 100644
index 000000000..2b0704981
--- /dev/null
+++ b/plugins/pass/README.md
@@ -0,0 +1,22 @@
+# pass
+
+This plugin provides completion for the [pass](https://www.passwordstore.org/) password manager.
+
+To use it, add `pass` to the plugins array in your zshrc file.
+
+```
+plugins=(... pass)
+```
+
+## Configuration
+
+### Multiple repositories
+
+If you use multiple repositories, you can configure completion like this:
+```zsh
+compdef _pass workpass
+zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
+workpass() {
+ PASSWORD_STORE_DIR=$HOME/work/pass pass $@
+}
+```
diff --git a/plugins/pass/_pass b/plugins/pass/_pass
index 5f3b8f541..75f3feb4f 100644
--- a/plugins/pass/_pass
+++ b/plugins/pass/_pass
@@ -18,6 +18,14 @@
# PASSWORD_STORE_DIR=$HOME/work/pass pass $@
# }
+# If you use multiple repositories, you can configure completion like this:
+#
+# compdef _pass workpass
+# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
+# workpass() {
+# PASSWORD_STORE_DIR=$HOME/work/pass pass $@
+# }
+
_pass () {
local cmd
diff --git a/plugins/paver/README.md b/plugins/paver/README.md
new file mode 100644
index 000000000..c38d898ba
--- /dev/null
+++ b/plugins/paver/README.md
@@ -0,0 +1,12 @@
+# Paver
+
+This plugin adds completion for the `paver` command-line tool of [Paver](https://pythonhosted.org/Paver/).
+
+To use it, add `paver` to the plugins array of your zshrc file:
+```zsh
+plugins=(... paver)
+```
+
+The completion function creates a cache of paver tasks with the name `.paver_tasks`,
+in the current working directory. It regenerates that cache when the `pavement.py`
+changes.
diff --git a/plugins/paver/paver.plugin.zsh b/plugins/paver/paver.plugin.zsh
index 40bdbd12f..7e70ea37c 100644
--- a/plugins/paver/paver.plugin.zsh
+++ b/plugins/paver/paver.plugin.zsh
@@ -1,7 +1,7 @@
_paver_does_target_list_need_generating () {
- [ ! -f .paver_targets ] && return 0;
- [ pavement.py -nt .paver_targets ] && return 0;
- return 1;
+ [ ! -f .paver_targets ] && return 0
+ [ pavement.py -nt .paver_targets ] && return 0
+ return 1
}
_paver () {
diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md
index ea445d329..69854aa38 100644
--- a/plugins/per-directory-history/README.md
+++ b/plugins/per-directory-history/README.md
@@ -1,55 +1,48 @@
-[Per-Directory-History][6]
-=========================
+per-directory-history plugin
+----------------------------
-Per directory history for zsh, as well as global history, and the
-ability to toggle between them with ^G.
+This plugin adds per-directory history for zsh, as well as a global history,
+and the ability to toggle between them with a keyboard shortcut. This is a
+bundle of the [official plugin by @jimhester][5].
-This is a implementation of per directory history for zsh, some
-implementations of which exist in bash[1][],[2][]. It also implements
-a per-directory-history-toggle-history function to change from using the
-directory history to using the global history. In both cases the history is
-always saved to both the global history and the directory history, so the
-toggle state will not effect the saved histories. Being able to switch
-between global and directory histories on the fly is a novel feature as far
-as I am aware.
+To use it, add `per-directory-history` to the plugins array in your zshrc file:
-This is a standalone repository for the script, however it is also included in
-[oh-my-zsh][4] as a plugin.
+```zsh
+plugins=(... per-directory-history)
+```
-----------------------------------------------------------------------------
-Usage
-----------------------------------------------------------------------------
+This is an implementation of per-directory history for zsh, some implementations
+of which exist in bash[1][],[2][]. It also implements a toggle-history function
+to change from using the directory history to using the global history. In both
+cases the history is always saved to both the global history and the directory
+history, so the toggle state will not effect the saved histories. Being able to
+switch between global and directory histories on the fly is a novel feature.
-1. Load this script into your interactive ZSH session:
+## Usage
- % source zsh-per-directory-history.zsh
+The default mode is per directory history, interact with your history as normal.
-2. The default mode if per directory history, interact with your history as normal.
+Press ^G (the <kbd>Control</kbd> and <kbd>G</kbd> keys simultaneously) to toggle
+between local and global histories. If you would prefer a different shortcut to
+toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
-3. Press ^G (the Control and G keys simultaneously) to toggle between local
- and global histories. If you would prefer a different shortcut to toggle
- set the PER_DIRECTORY_HISTORY_TOGGLE environment variable.
+## Configuration
--------------------------------------------------------------------------------
-Configuration
--------------------------------------------------------------------------------
+* `HISTORY_BASE` is a global variable that defines the base directory in which the
+ directory histories are stored (default `$HOME/.directory_history`).
+* `per-directory-history-toggle-history` is the function to toggle between local
+ and global histories.
+* `PER_DIRECTORY_HISTORY_TOGGLE` is the key binding used to run the toggle-history
+ function above (default `^G`)
-* HISTORY_BASE a global variable that defines the base directory in which the
- directory histories are stored
-* per-directory-history-toggle-history is the function to toggle the history
-
--------------------------------------------------------------------------------
-History
--------------------------------------------------------------------------------
+## History
The idea/inspiration for a per directory history is from [Stewart MacArthur][1]
-and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The
-implementation is by [Jim Hester][5] in September 2012.
+and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The
+implementation is by [Jim Hester][4] in September 2012.
[1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
[2]: http://dieter.plaetinck.be/per_directory_bash
[3]: https://www.zsh.org/mla/users/1997/msg00226.html
-[4]: https://github.com/robbyrussell/oh-my-zsh
-[5]: http://jimhester.com
-[6]: https://github.com/jimhester/per-directory-history
-
+[4]: https://jimhester.com
+[5]: https://github.com/jimhester/per-directory-history
diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh
index 53ad963e7..41de2f91d 100644
--- a/plugins/per-directory-history/per-directory-history.zsh
+++ b/plugins/per-directory-history/per-directory-history.zsh
@@ -26,7 +26,7 @@
#
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
# [2]: http://dieter.plaetinck.be/per_directory_bash
-# [3]: https://www.zsh.org/mla/users/1997/msg00226.html
+# [3]: http://www.zsh.org/mla/users/1997/msg00226.html
#
################################################################################
#
@@ -109,8 +109,13 @@ function _per-directory-history-change-directory() {
}
function _per-directory-history-addhistory() {
- print -Sr -- "${1%%$'\n'}"
- fc -p $_per_directory_history_directory
+ # respect hist_ignore_space
+ if [[ -o hist_ignore_space ]] && [[ "$1" == \ * ]]; then
+ true
+ else
+ print -Sr -- "${1%%$'\n'}"
+ fc -p $_per_directory_history_directory
+ fi
}
diff --git a/plugins/percol/README.md b/plugins/percol/README.md
index b262e414e..ec5de4f86 100644
--- a/plugins/percol/README.md
+++ b/plugins/percol/README.md
@@ -1,6 +1,6 @@
## percol
-Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh)
+Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh)
### Requirements
@@ -8,7 +8,7 @@ Provides some useful function to make [percol](https://github.com/mooz/percol) w
pip install percol
```
-And [jump](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
+And [jump](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
### Usage
diff --git a/plugins/perl/README.md b/plugins/perl/README.md
new file mode 100644
index 000000000..dd9b7dc75
--- /dev/null
+++ b/plugins/perl/README.md
@@ -0,0 +1,37 @@
+# Perl
+
+This plugin adds [perl](https://www.perl.org/) useful aliases/functions.
+
+To use it, add `perl` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... perl)
+```
+
+## Aliases
+
+| Aliases | Command | Description |
+| :------------ | :----------------- | :------------------------------------- |
+| pbi | `perlbrew install` | Install specific perl version |
+| pbl | `perlbrew list` | List all perl version installed |
+| pbo | `perlbrew off` | Go back to the system perl |
+| pbs | `perlbrew switch` | Turn it back on |
+| pbu | `perlbrew use` | Use specific version of perl |
+| pd | `perldoc` | Show the perl documentation |
+| ple | `perl -wlne` | Use perl like awk/sed |
+| latest-perl | `curl ...` | Show the latest stable release of Perl |
+
+## Functions
+
+* `newpl`: creates a basic Perl script file and opens it with $EDITOR.
+
+* `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>`
+ Looks for `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
+
+* `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]`
+ Lets you work with pipes or files (if no `<filename>` provided, use stdin).
+
+## Requirements
+
+In order to make this work, you will need to have perl installed.
+More info on the usage and install: https://www.perl.org/get.html
diff --git a/plugins/perms/README.md b/plugins/perms/README.md
index 324b3f3cc..ae7a36b9d 100644
--- a/plugins/perms/README.md
+++ b/plugins/perms/README.md
@@ -1,9 +1,15 @@
-## Perms
+# Perms plugin
-Plugin to handle some unix filesystem permissions quickly
+Plugin to handle some unix filesystem permissions quickly.
-### Usage
+To use it, add `perms` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... perms)
+```
+
+## Usage
* `set755` recursively sets all given directories (default to .) to octal 755.
* `set644` recursively sets all given files (default to .) to octal 644.
-* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases.
+* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases.
diff --git a/plugins/phing/README.md b/plugins/phing/README.md
new file mode 100644
index 000000000..84d1d182d
--- /dev/null
+++ b/plugins/phing/README.md
@@ -0,0 +1,9 @@
+# Phing plugin
+
+This plugin adds autocompletion for [`phing`](https://github.com/phingofficial/phing) targets.
+
+To use it, add `phing` to the plugins array of your `.zshrc` file:
+
+```zsh
+plugins=(... phing)
+```
diff --git a/plugins/pip/README.md b/plugins/pip/README.md
new file mode 100644
index 000000000..f07b5c058
--- /dev/null
+++ b/plugins/pip/README.md
@@ -0,0 +1,19 @@
+# pip plugin
+
+This plugin adds completion for [pip](https://pip.pypa.io/en/latest/),
+the Python package manager.
+
+To use it, add `pip` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... pip)
+```
+
+## pip cache
+
+The pip plugin caches the names of available pip packages from the PyPI index.
+To trigger the caching process, try to complete `pip install`,
+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`.
diff --git a/plugins/pip/_pip b/plugins/pip/_pip
index 607f68e58..a5adead4a 100644
--- a/plugins/pip/_pip
+++ b/plugins/pip/_pip
@@ -89,6 +89,7 @@ case "$words[1]" in
if [[ "$state" == packages ]]; then
_pip_all
_wanted piplist expl 'packages' compadd -a piplist
+ _files -g "*.(tar.gz|whl)"
fi ;;
uninstall)
_pip_installed
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh
index d7236b02a..a46e7658c 100644
--- a/plugins/pip/pip.plugin.zsh
+++ b/plugins/pip/pip.plugin.zsh
@@ -9,8 +9,12 @@
# If you would like to clear your cache, go ahead and do a
# "zsh-pip-clear-cache".
-ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
-ZSH_PIP_INDEXES=(https://pypi.python.org/simple/)
+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() {
rm $ZSH_PIP_CACHE_FILE
@@ -29,9 +33,10 @@ zsh-pip-cache-packages() {
if [[ ! -f $ZSH_PIP_CACHE_FILE ]]; then
echo -n "(...caching package index...)"
tmp_cache=/tmp/zsh_tmp_cache
+ touch $tmp_cache
for index in $ZSH_PIP_INDEXES ; do
# well... I've already got two problems
- curl $index 2>/dev/null | \
+ curl -L $index 2>/dev/null | \
zsh-pip-clean-packages \
>> $tmp_cache
done
diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md
new file mode 100644
index 000000000..ab1c1e442
--- /dev/null
+++ b/plugins/pipenv/README.md
@@ -0,0 +1,28 @@
+# Pipenv
+
+## Installation
+In your `.zshrc` file, add `pipenv` to the plugins section
+
+```
+plugins=(... pipenv ...)
+```
+
+## Features
+This plugin provides some features to simplify the use of Pipenv while working on ZSH.
+- Adds completion for pipenv
+- Auto activates and deactivates pipenv shell
+- Adds short aliases for common pipenv commands
+ - `pch` is aliased to `pipenv check`
+ - `pcl` is aliased to `pipenv clean`
+ - `pgr` is aliased to `pipenv graph`
+ - `pi` is aliased to `pipenv install`
+ - `pidev` is aliased to `pipenv install --dev`
+ - `pl` is aliased to `pipenv lock`
+ - `po` is aliased to `pipenv open`
+ - `prun` is aliased to `pipenv run`
+ - `psh` is aliased to `pipenv shell`
+ - `psy` is aliased to `pipenv sync`
+ - `pu` is aliased to `pipenv uninstall`
+ - `pwh` is aliased to `pipenv --where`
+ - `pvenv` is aliased to `pipenv --venv`
+ - `ppy` is aliased to `pipenv --py`
diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh
new file mode 100644
index 000000000..4be61a920
--- /dev/null
+++ b/plugins/pipenv/pipenv.plugin.zsh
@@ -0,0 +1,44 @@
+# Pipenv completion
+_pipenv() {
+ eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
+}
+compdef _pipenv pipenv
+
+# Automatic pipenv shell activation/deactivation
+_togglePipenvShell() {
+ # deactivate shell if Pipfile doesn't exist and not in a subdir
+ if [[ ! -f "$PWD/Pipfile" ]]; then
+ if [[ "$PIPENV_ACTIVE" == 1 ]]; then
+ if [[ "$PWD" != "$pipfile_dir"* ]]; then
+ exit
+ fi
+ fi
+ fi
+
+ # activate the shell if Pipfile exists
+ if [[ "$PIPENV_ACTIVE" != 1 ]]; then
+ if [[ -f "$PWD/Pipfile" ]]; then
+ export pipfile_dir="$PWD"
+ pipenv shell
+ fi
+ fi
+}
+autoload -U add-zsh-hook
+add-zsh-hook chpwd _togglePipenvShell
+_togglePipenvShell
+
+# Aliases
+alias pch="pipenv check"
+alias pcl="pipenv clean"
+alias pgr="pipenv graph"
+alias pi="pipenv install"
+alias pidev="pipenv install --dev"
+alias pl="pipenv lock"
+alias po="pipenv open"
+alias prun="pipenv run"
+alias psh="pipenv shell"
+alias psy="pipenv sync"
+alias pu="pipenv uninstall"
+alias pwh="pipenv --where"
+alias pvenv="pipenv --venv"
+alias ppy="pipenv --py"
diff --git a/plugins/please/README.md b/plugins/please/README.md
new file mode 100644
index 000000000..89bfbf105
--- /dev/null
+++ b/plugins/please/README.md
@@ -0,0 +1,26 @@
+# please plugin
+
+[Please](https://please.build) is a cross-language build system with an emphasis on
+high performance, extensibility and reproduceability. It supports a number of popular
+languages and can automate nearly any aspect of your build process.
+
+This plugin adds autocomplete and major aliases for `plz`, the command line tool for
+Please.
+
+To use it, add `please` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... please)
+```
+
+## Aliases
+
+| Alias | Command |
+|-------|-------------|
+| `pb` | `plz build` |
+| `pt` | `plz test` |
+| `pw` | `plz watch` |
+
+## Maintainer
+
+[@thought-machine](https://github.com/thought-machine)
diff --git a/plugins/please/please.plugin.zsh b/plugins/please/please.plugin.zsh
new file mode 100644
index 000000000..0f58307ab
--- /dev/null
+++ b/plugins/please/please.plugin.zsh
@@ -0,0 +1,7 @@
+if (( $+commands[plz] )); then
+ source <(plz --completion_script)
+fi
+
+alias pb='plz build'
+alias pt='plz test'
+alias pw='plz watch'
diff --git a/plugins/pod/README.md b/plugins/pod/README.md
new file mode 100644
index 000000000..0a3cc7a36
--- /dev/null
+++ b/plugins/pod/README.md
@@ -0,0 +1,10 @@
+# pod
+
+This plugin adds completion for [`CocoaPods`](https://cocoapods.org/).
+CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
+
+To use it, add `pod` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... pod)
+```
diff --git a/plugins/pow/README.md b/plugins/pow/README.md
new file mode 100644
index 000000000..1f8a9d136
--- /dev/null
+++ b/plugins/pow/README.md
@@ -0,0 +1,21 @@
+# pow plugin
+
+This plugin adds completion and commands for [pow](http://pow.cx/), a
+zero-configuration Rack server for macOS.
+
+To use it, add pow to the plugins array of your zshrc file:
+
+```sh
+plugins=(... pow)
+```
+
+## Commands
+
+- `kapow` will restart an app.
+
+ ```bash
+ kapow myapp
+ ```
+
+- `kaput` will show the standard output from any pow app.
+- `repow` will restart the pow process.
diff --git a/plugins/powder/README.md b/plugins/powder/README.md
new file mode 100644
index 000000000..a83b1f2d3
--- /dev/null
+++ b/plugins/powder/README.md
@@ -0,0 +1,8 @@
+# Powder
+
+This plugin provides completion for [powder](https://github.com/powder-rb/powder/).
+
+To use it, add powder to the plugins array of your zshrc file:
+```
+plugins=(... powder)
+```
diff --git a/plugins/powify/README.md b/plugins/powify/README.md
new file mode 100644
index 000000000..fd58b860e
--- /dev/null
+++ b/plugins/powify/README.md
@@ -0,0 +1,10 @@
+# powify plugin
+
+This plugin adds autocompletion for [powify](https://github.com/sethvargo/powify),
+an easy-to-use wrapper for Basecamp's [pow](https://github.com/basecamp/pow).
+
+To use it, add powify to the plugins array of your zshrc file:
+
+```sh
+plugins=(... powify)
+```
diff --git a/plugins/profiles/README.md b/plugins/profiles/README.md
new file mode 100644
index 000000000..5aa1918e2
--- /dev/null
+++ b/plugins/profiles/README.md
@@ -0,0 +1,25 @@
+# profiles plugin
+
+This plugin allows you to create separate configuration files for zsh based
+on your long hostname (including the domain).
+
+To use it, add profiles to the plugins array of your zshrc file:
+
+```sh
+plugins=(... profiles)
+```
+
+It takes your `$HOST` variable and looks for files named according to the
+domain parts in `$ZSH_CUSTOM/profiles/` directory.
+
+For example, for `HOST=host.domain.com`, it will try to load the following files,
+in this order:
+
+```text
+$ZSH_CUSTOM/profiles/com
+$ZSH_CUSTOM/profiles/domain.com
+$ZSH_CUSTOM/profiles/host.domain.com
+```
+
+This means that if there are conflicting settings on those files, the one to take
+precedence will be the last applied, i.e. the one in host.domain.com.
diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md
new file mode 100644
index 000000000..d063b55b9
--- /dev/null
+++ b/plugins/pyenv/README.md
@@ -0,0 +1,16 @@
+# 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
+plugin to manage virtualenv, if it's found.
+
+To use it, add `pyenv` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... pyenv)
+```
+
+## Functions
+
+- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python
+ version, if pyenv wasn't found.
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
index dbc7da472..82ba6ff8c 100644
--- a/plugins/pyenv/pyenv.plugin.zsh
+++ b/plugins/pyenv/pyenv.plugin.zsh
@@ -1,10 +1,15 @@
# This plugin loads pyenv into the current shell and provides prompt info via
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
-FOUND_PYENV=$+commands[pyenv]
+# Load pyenv only if command not already available
+if command -v pyenv &> /dev/null && [[ "$(uname -r)" != *icrosoft* ]]; then
+ FOUND_PYENV=1
+else
+ FOUND_PYENV=0
+fi
if [[ $FOUND_PYENV -ne 1 ]]; then
- pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv")
+ 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"
@@ -24,7 +29,7 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
fi
if [[ $FOUND_PYENV -eq 1 ]]; then
- eval "$(pyenv init - zsh)"
+ eval "$(pyenv init - --no-rehash zsh)"
if (( $+commands[pyenv-virtualenv-init] )); then
eval "$(pyenv virtualenv-init - zsh)"
fi
@@ -38,4 +43,4 @@ else
}
fi
-unset FOUND_PYENV dir
+unset FOUND_PYENV pyenvdirs dir
diff --git a/plugins/pylint/README.md b/plugins/pylint/README.md
index 8c1de88ba..31710d8a2 100644
--- a/plugins/pylint/README.md
+++ b/plugins/pylint/README.md
@@ -1,6 +1,7 @@
-# pylint
+# pylint
-This plugin adds code analysis for python through [Pylint](https://www.pylint.org/).
+This plugin adds aliases and autocompletion for [Pylint](https://www.pylint.org/),
+the Python code style checking tool.
To use it, add `pylint` to the plugins array in your zshrc file:
@@ -12,4 +13,4 @@ plugins=(... pylint)
| Alias | Command | Description |
| -------------| -------------------- | -------------------------------------------------------------------------------------------------------------------------|
-| pylint-quick | `pylint --reports=n` | Displays a set of reports each one focusing on a particular aspect of the project, default set `no` for multiple reports | |
+| pylint-quick | `pylint --reports=n` | Displays a set of reports each one focusing on a particular aspect of the project, default set `no` for multiple reports |
diff --git a/plugins/pylint/pylint.plugin.zsh b/plugins/pylint/pylint.plugin.zsh
index 57c7c0ac5..14cea5bef 100644
--- a/plugins/pylint/pylint.plugin.zsh
+++ b/plugins/pylint/pylint.plugin.zsh
@@ -1,3 +1 @@
-# Aliases
alias pylint-quick='pylint --reports=n'
-compdef _pylint-quick pylint-quick='pylint --reports=n'
diff --git a/plugins/python/README.md b/plugins/python/README.md
index 2d955c5cb..0180218a2 100644
--- a/plugins/python/README.md
+++ b/plugins/python/README.md
@@ -11,6 +11,8 @@ plugins=(... python)
| Command | Description |
|------------------|---------------------------------------------------------------------------------|
+| `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 |
| `pygrep <text>` | Looks for `text` in .py files |
+| `pyuserpaths` | Add --user site-packages to PYTHONPATH, for all installed python versions. |
diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh
index f754ea261..276eb6f91 100644
--- a/plugins/python/python.plugin.zsh
+++ b/plugins/python/python.plugin.zsh
@@ -1,15 +1,50 @@
+# python command
+alias py='python'
+
# Find python file
alias pyfind='find . -name "*.py"'
-# Remove python compiled byte-code and mypy cache in either current directory or in a
-# list of specified directories
+# Remove python compiled byte-code and mypy/pytest cache in either the current
+# directory or in a list of specified directories (including sub directories).
function pyclean() {
ZSH_PYCLEAN_PLACES=${*:-'.'}
find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
- find ${ZSH_PYCLEAN_PLACES} -type d -name ".mypy_cache" -delete
+ find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
+ find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
+}
+
+# Add the user installed site-packages paths to PYTHONPATH, only if the
+# directory exists. Also preserve the current PYTHONPATH value.
+# Feel free to autorun this when .zshrc loads.
+function pyuserpaths() {
+ local targets=("python2" "python3") # bins
+
+ # Get existing interpreters.
+ local interps=()
+ for target in $targets; do
+ [ `command -v $target` ] && interps+=($target)
+ done
+
+ # Check for a non-standard install directory.
+ local user_base="${HOME}/.local"
+ [ $PYTHONUSERBASE ] && user_base=$PYTHONUSERBASE
+
+ # Add version specific paths, if:
+ # it exists in the filesystem;
+ # it isn't in PYTHONPATH already.
+ for interp in $interps; do
+ # Get minor release version.
+ local ver=`$interp -V 2>&1`
+ ver=`echo ${ver:7} | cut -d '.' -f 1,2` # The patch version is variable length, truncate it.
+
+ local site_pkgs="${user_base}/lib/python${ver}/site-packages"
+ [[ -d $site_pkgs && ! $PYTHONPATH =~ $site_pkgs ]] && export PYTHONPATH=${site_pkgs}:$PYTHONPATH
+ done
}
# Grep among .py files
-alias pygrep='grep --include="*.py"'
+alias pygrep='grep -nr --include="*.py"'
+# Run proper IPython regarding current virtualenv (if any)
+alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
diff --git a/plugins/rails/README.md b/plugins/rails/README.md
new file mode 100644
index 000000000..efdb8f8ba
--- /dev/null
+++ b/plugins/rails/README.md
@@ -0,0 +1,82 @@
+# Rails
+
+This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and [Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
+
+To use it, add `rails` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... rails)
+```
+
+## List of Aliases
+
+### Rails aliases
+
+| Alias | Command | Description |
+|-------|----------------------------|----------------------------------------------------|
+| `rc` | `rails console` | Interact with your Rails app from the CLI |
+| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data |
+| `rd` | `rails destroy` | Undo a generate operation |
+| `rdb` | `rails dbconsole` | Interact with your db from the console |
+| `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 |
+| `rsp` | `rails server --port` | Launch a web server and specify the listening port |
+
+### Rake aliases
+
+| Alias | Command | Description |
+|---------|---------------------------------|--------------------------------------------------------|
+| `rdm` | `rake db:migrate` | Run pending db migrations |
+| `rdms` | `rake db:migrate:status` | Show current db migration status |
+| `rdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
+| `rdr` | `rake db:rollback` | Roll back the last migration |
+| `rdc` | `rake db:create` | Create the database |
+| `rds` | `rake db:seed` | Seed the database |
+| `rdd` | `rake db:drop` | Delete the database |
+| `rdrs` | `rake db:reset` | Delete the database and set it up again |
+| `rdtc` | `rake db:test:clone` | Clone the database into the test database |
+| `rdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database |
+| `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 |
+| `rt` | `rake test` | Run Rails tests |
+| `rmd` | `rake middleware` | Interact with Rails middlewares |
+| `rsts` | `rake stats` | Print code statistics |
+
+### Utility aliases
+
+| Alias | Command | Description |
+|-----------|-------------------------------|------------------------------------------------|
+| `devlog` | `tail -f log/development.log` | Show and follow changes to the development log |
+| `prodlog` | `tail -f log/production.log` | Show and follow changes to the production log |
+| `testlog` | `tail -f log/test.log` | Show and follow changes to the test log |
+
+### Environment settings
+
+| Alias | Command | Description |
+|-------|-------------------------|---------------------------------|
+| `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development |
+| `REP` | `RAILS_ENV=production` | Sets `RAILS_ENV` to production |
+| `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test |
+
+These are global aliases. Use in combination with a command or just run them
+separately. For example: `REP rake db:migrate` will migrate the production db.
+
+### Legacy stuff
+
+| Alias | Command |
+|---------|------------------------------------|
+| `sstat` | `thin --stats "/thin/stats" start` |
+| `sg` | `ruby script/generate` |
+| `sd` | `ruby script/destroy` |
+| `sp` | `ruby script/plugin` |
+| `sr` | `ruby script/runner` |
+| `ssp` | `ruby script/spec` |
+| `sc` | `ruby script/console` |
+| `sd` | `ruby script/server --debugger` |
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index eb3f30360..29b413434 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -17,7 +17,7 @@ function _rake_command () {
bin/stubs/rake $@
elif [ -e "bin/rake" ]; then
bin/rake $@
- elif type bundle &> /dev/null && [ -e "Gemfile" ]; then
+ elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
bundle exec rake $@
else
command rake $@
@@ -43,17 +43,23 @@ alias rc='rails console'
alias rcs='rails console --sandbox'
alias rd='rails destroy'
alias rdb='rails dbconsole'
-alias rg='rails generate'
+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/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh
index ca80d86e1..19dab154b 100644
--- a/plugins/rake-fast/rake-fast.plugin.zsh
+++ b/plugins/rake-fast/rake-fast.plugin.zsh
@@ -20,7 +20,7 @@ _tasks_changed () {
}
_rake_generate () {
- rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
+ rake --silent --tasks | cut -d " " -f 2 | sed 's/\[.*\]//g' > .rake_tasks
}
_rake () {
diff --git a/plugins/rake/README.md b/plugins/rake/README.md
new file mode 100644
index 000000000..e888c0785
--- /dev/null
+++ b/plugins/rake/README.md
@@ -0,0 +1,37 @@
+# Rake plugin
+
+This plugin adds support for [rake](https://ruby.github.io/rake/), the Ruby
+build tool or Ruby Make.
+
+To use it, add `rake` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... rake)
+```
+
+## Aliases
+
+The plugin aliases the rake command so you can pass arguments when invoking rake tasks
+without having to escape the brackets, i.e., you can run
+```
+rake namespace:task['argument']
+```
+instead of having to do
+```
+rake namespace:task\['argument'\]
+```
+
+| Alias | Command | Description |
+|--------|--------------------------------|-----------------------------------------------|
+| rake | `noglob rake` | Allows unescaped square brackets |
+| brake | `noglob bundle exec rake` | Same as above but call rake using bundler |
+| srake | `noglob sudo rake` | Same as rake but using sudo |
+| sbrake | `noglob sudo bundle exec rake` | Same as above but using both sudo and bundler |
+
+## Jim Weirich
+
+The plugin also aliases `rake` to [`jimweirich`](https://github.com/jimweirich), author of Rake
+and big time contributor to the Ruby open source community. He passed away in 2014:
+
+> Thank you Jim for everything you contributed to the Ruby and open source community
+> over the years. We will miss you dearly. — [**@robbyrussell**](https://github.com/ohmyzsh/ohmyzsh/commit/598a9c6f990756386517d66b6bcf77e53791e905)
diff --git a/plugins/rbenv/README.md b/plugins/rbenv/README.md
new file mode 100644
index 000000000..43a2e93ac
--- /dev/null
+++ b/plugins/rbenv/README.md
@@ -0,0 +1,26 @@
+# rbenv plugin
+
+The primary job of this plugin is to provide `rbenv_prompt_info` which can be added to your theme to include Ruby
+version and gemset information into your prompt.
+
+Some functionality of this plugin will not work unless you also have the rbenv plugin *gemset* installed.
+https://github.com/jf/rbenv-gemset
+
+To use it, add `rbenv` to the plugins array in your zshrc file:
+```zsh
+plugins=(... rbenv)
+```
+
+## Alias
+
+| Alias | Command | Description |
+|----------------|---------------------|----------------------------------|
+| rubies | `rbenv versions` | List the installed Ruby versions |
+| gemsets | `rbenv gemset list` | List the existing gemsets |
+
+## Functions
+
+* `current_ruby`: The version of Ruby currently being used.
+* `current_gemset`: The name of the current gemset.
+* `gems`: Lists installed gems with enhanced formatting and color.
+* `rbenv_prompt_info`: For adding information to your prompt. Format: `<ruby version>@<current gemset>`.
diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh
index 7430e9625..0f2d366e2 100644
--- a/plugins/rbenv/rbenv.plugin.zsh
+++ b/plugins/rbenv/rbenv.plugin.zsh
@@ -1,60 +1,68 @@
-_homebrew-installed() {
- type brew &> /dev/null
-}
-
-FOUND_RBENV=0
-rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
-if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then
- rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}")
- unset rbenv_homebrew_path
- if [[ $RBENV_ROOT = '' ]]; then
- RBENV_ROOT="$HOME/.rbenv"
- fi
+# This plugin loads rbenv into the current shell and provides prompt info via
+# the 'rbenv_prompt_info' function.
+
+FOUND_RBENV=$+commands[rbenv]
+
+if [[ $FOUND_RBENV -ne 1 ]]; then
+ rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
+ for dir in $rbenvdirs; do
+ if [[ -d $dir/bin ]]; then
+ export PATH="$dir/bin:$PATH"
+ FOUND_RBENV=1
+ break
+ fi
+ done
fi
-for rbenvdir in "${rbenvdirs[@]}" ; do
- if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then
- FOUND_RBENV=1
- if [[ $RBENV_ROOT = '' ]]; then
- RBENV_ROOT=$rbenvdir
+if [[ $FOUND_RBENV -ne 1 ]]; then
+ if (( $+commands[brew] )) && dir=$(brew --prefix rbenv 2>/dev/null); then
+ if [[ -d $dir/bin ]]; then
+ export PATH="$dir/bin:$PATH"
+ FOUND_RBENV=1
+ fi
fi
- export RBENV_ROOT
- export PATH=${rbenvdir}/bin:$PATH
+fi
+
+if [[ $FOUND_RBENV -eq 1 ]]; then
eval "$(rbenv init --no-rehash - zsh)"
alias rubies="rbenv versions"
alias gemsets="rbenv gemset list"
function current_ruby() {
- echo "$(rbenv version-name)"
+ echo "$(rbenv version-name)"
}
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 {
- local rbenv_path=$(rbenv prefix)
- gem list $@ | sed -E \
- -e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
- -e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
- -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
- -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
+ function gems() {
+ local rbenv_path=$(rbenv prefix)
+ gem list $@ | sed -E \
+ -e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
+ -e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
+ -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
+ -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
}
function rbenv_prompt_info() {
- if [[ -n $(current_gemset) ]] ; then
- echo "$(current_ruby)@$(current_gemset)"
- else
- echo "$(current_ruby)"
- fi
+ local ruby=$(current_ruby) gemset=$(current_gemset)
+ echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}"
+ [[ -n "$gemset" ]] && echo -n "${ruby}@${gemset}" || echo -n "${ruby}"
+ echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
+ }
+else
+ alias rubies="ruby -v"
+ function gemsets() { echo "not supported" }
+ function current_ruby() { echo "not supported" }
+ function current_gemset() { echo "not supported" }
+ function gems() { echo "not supported" }
+ function rbenv_prompt_info() {
+ echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}"
+ echo -n "system: $(ruby -v | cut -f-2 -d ' ')"
+ echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
}
- fi
-done
-unset rbenvdir
-
-if [ $FOUND_RBENV -eq 0 ] ; then
- alias rubies='ruby -v'
- function gemsets() { echo 'not supported' }
- function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" }
fi
+
+unset FOUND_RBENV rbenvdirs dir
diff --git a/plugins/rbfu/README.md b/plugins/rbfu/README.md
new file mode 100644
index 000000000..f1f9fa2f7
--- /dev/null
+++ b/plugins/rbfu/README.md
@@ -0,0 +1,17 @@
+# rbfu plugin
+
+This plugin starts [rbfu](https://github.com/hmans/rbfu), a minimal Ruby version
+manager, and adds some useful functions.
+
+To use it, add `rbfu` to the plugins array in your zshrc file:
+```zsh
+plugins=(... rbfu)
+```
+
+**Note: `rbfu` is deprecated and should no longer be used.**
+
+## Functions
+
+- `rbfu-rubies`: lists all installed rubies available to rbfu.
+
+- `rvm_prompt_info`: shows the Ruby version being used with rbfu.
diff --git a/plugins/react-native/README.md b/plugins/react-native/README.md
index d1fce0fc2..d0a53b8d7 100644
--- a/plugins/react-native/README.md
+++ b/plugins/react-native/README.md
@@ -11,28 +11,66 @@ plugins=(... react-native)
## Aliases
-| Alias | React Native command |
-| :------------ | :------------------------------------------------- |
-| **rn** | `react-native` |
-| **rns** | `react-native start` |
-| **rnlink** | `react-native link` |
-| _App testing_ |
-| **rnand** | `react-native run-android` |
-| **rnios** | `react-native run-ios` |
-| **rnios4s** | `react-native run-ios --simulator "iPhone 4s"` |
-| **rnios5** | `react-native run-ios --simulator "iPhone 5"` |
-| **rnios5s** | `react-native run-ios --simulator "iPhone 5s"` |
-| **rnios6** | `react-native run-ios --simulator "iPhone 6"` |
-| **rnios6s** | `react-native run-ios --simulator "iPhone 6s"` |
-| **rnios7** | `react-native run-ios --simulator "iPhone7"` |
-| **rnios7p** | `react-native run-ios --simulator "iPhone 7 Plus"` |
-| **rnios8** | `react-native run-ios --simulator "iPhone 8"` |
-| **rnios8p** | `react-native run-ios --simulator "iPhone 8 Plus"` |
-| **rniosse** | `react-native run-ios --simulator "iPhone SE"` |
-| **rniosx** | `react-native run-ios --simulator "iPhone X"` |
-| **rniosxs** | `react-native run-ios --simulator "iPhone XS"` |
-| **rniosxsm** | `react-native run-ios --simulator "iPhone XS Max"` |
-| **rniosxr** | `react-native run-ios --simulator "iPhone XR"` |
-| _Logging_ |
-| **rnland** | `react-native log-android` |
-| **rnlios** | `react-native log-ios` |
+| Alias | React Native command |
+| :------------ | :------------------------------------------------- |
+| **rn** | `react-native` |
+| **rns** | `react-native start` |
+| **rnlink** | `react-native link` |
+| _Logging_ | |
+| **rnland** | `react-native log-android` |
+| **rnlios** | `react-native log-ios` |
+| _App Testing_ | |
+| **rnand** | `react-native run-android` |
+| **rnios** | `react-native run-ios` |
+| _iPhone_ | |
+| **rnios4s** | `react-native run-ios --simulator "iPhone 4s"` |
+| **rnios5** | `react-native run-ios --simulator "iPhone 5"` |
+| **rnios5s** | `react-native run-ios --simulator "iPhone 5s"` |
+| **rnios6** | `react-native run-ios --simulator "iPhone 6"` |
+| **rnios6s** | `react-native run-ios --simulator "iPhone 6s"` |
+| **rnios6p** | `react-native run-ios --simulator "iPhone 6 Plus"` |
+| **rnios6sp** | `react-native run-ios --simulator "iPhone 6s Plus"` |
+| **rnios7** | `react-native run-ios --simulator "iPhone 7"` |
+| **rnios7p** | `react-native run-ios --simulator "iPhone 7 Plus"` |
+| **rnios8** | `react-native run-ios --simulator "iPhone 8"` |
+| **rnios8p** | `react-native run-ios --simulator "iPhone 8 Plus"` |
+| **rniosse** | `react-native run-ios --simulator "iPhone SE"` |
+| **rniosx** | `react-native run-ios --simulator "iPhone X"` |
+| **rniosxs** | `react-native run-ios --simulator "iPhone Xs"` |
+| **rniosxsm** | `react-native run-ios --simulator "iPhone Xs Max"` |
+| **rniosxr** | `react-native run-ios --simulator "iPhone Xʀ"` |
+| **rnios11** | `react-native run-ios --simulator "iPhone 11"` |
+| **rnios11p** | `react-native run-ios --simulator "iPhone 11 Pro"` |
+| **rnios11pm** | `react-native run-ios --simulator "iPhone 11 Pro Max"` |
+| _iPad_ | |
+| **rnipad2** | `react-native run-ios --simulator "iPad 2"` |
+| **rnipad5** | `react-native run-ios --simulator "iPad (5th generation)"` |
+| **rnipad6** | `react-native run-ios --simulator "iPad (6th generation)"` |
+| **rnipadr** | `react-native run-ios --simulator "iPad Retina"` |
+| **rnipada** | `react-native run-ios --simulator "iPad Air"` |
+| **rnipada2** | `react-native run-ios --simulator "iPad Air 2"` |
+| **rnipada3** | `react-native run-ios --simulator "iPad Air (3rd generation)"` |
+| **rnipadm2** | `react-native run-ios --simulator "iPad mini 2"` |
+| **rnipadm3** | `react-native run-ios --simulator "iPad mini 3"` |
+| **rnipadm4** | `react-native run-ios --simulator "iPad mini 4"` |
+| **rnipadm5** | `react-native run-ios --simulator "iPad mini (5th generation)"` |
+| **rnipadp9** | `react-native run-ios --simulator "iPad Pro (9.7-inch)"` |
+| **rnipadp12** | `react-native run-ios --simulator "iPad Pro (12.9-inch)"` |
+| **rnipadp122** | `react-native run-ios --simulator "iPad Pro (12.9-inch) (2nd generation)"` |
+| **rnipadp10** | `react-native run-ios --simulator "iPad Pro (10.5-inch)"` |
+| **rnipad11** | `react-native run-ios --simulator "iPad Pro (11-inch)"` |
+| **rnipad123** | `react-native run-ios --simulator "iPad Pro (12.9-inch) (3rd generation)"` |
+| _Apple TV_ | |
+| **rnatv** | `react-native run-ios --simulator "Apple TV"` |
+| **rnatv4k** | `react-native run-ios --simulator "Apple TV 4K"` |
+| **rnatv4k1080**| `react-native run-ios --simulator "Apple TV 4K (at 1080p)"` |
+| **rnipad123** | `react-native run-ios --simulator "iPad Pro (12.9-inch) (3rd generation)"` |
+| _Apple Watch_ | |
+| **rnaw38** | `react-native run-ios --simulator "Apple Watch - 38mm"` |
+| **rnaw42** | `react-native run-ios --simulator "Apple Watch - 42mm"` |
+| **rnaws238** | `react-native run-ios --simulator "Apple Watch Series 2 - 38mm"` |
+| **rnaws242** | `react-native run-ios --simulator "Apple Watch Series 2 - 42mm"` |
+| **rnaws338** | `react-native run-ios --simulator "Apple Watch Series 3 - 38mm"` |
+| **rnaws342** | `react-native run-ios --simulator "Apple Watch Series 3 - 42mm"` |
+| **rnaws440** | `react-native run-ios --simulator "Apple Watch Series 4 - 40mm"` |
+| **rnaws444** | `react-native run-ios --simulator "Apple Watch Series 4 - 44mm"` |
diff --git a/plugins/react-native/react-native.plugin.zsh b/plugins/react-native/react-native.plugin.zsh
index 220aa2dce..8323c27bd 100644
--- a/plugins/react-native/react-native.plugin.zsh
+++ b/plugins/react-native/react-native.plugin.zsh
@@ -1,23 +1,67 @@
+# React Native
alias rn='react-native'
alias rns='react-native start'
alias rnlink='react-native link'
-
+alias rnland='react-native log-android'
+alias rnlios='react-native log-ios'
alias rnand='react-native run-android'
alias rnios='react-native run-ios'
+
+# iPhone
alias rnios4s='react-native run-ios --simulator "iPhone 4s"'
alias rnios5='react-native run-ios --simulator "iPhone 5"'
alias rnios5s='react-native run-ios --simulator "iPhone 5s"'
alias rnios6='react-native run-ios --simulator "iPhone 6"'
+alias rnios6p='react-native run-ios --simulator "iPhone 6 Plus"'
alias rnios6s='react-native run-ios --simulator "iPhone 6s"'
+alias rnios6sp='react-native run-ios --simulator "iPhone 6s Plus"'
alias rnios7='react-native run-ios --simulator "iPhone 7"'
alias rnios7p='react-native run-ios --simulator "iPhone 7 Plus"'
alias rnios8='react-native run-ios --simulator "iPhone 8"'
alias rnios8p='react-native run-ios --simulator "iPhone 8 Plus"'
alias rniosse='react-native run-ios --simulator "iPhone SE"'
alias rniosx='react-native run-ios --simulator "iPhone X"'
-alias rniosxs='react-native run-ios --simulator "iPhone XS"'
-alias rniosxsm='react-native run-ios --simulator "iPhone XS Max"'
-alias rniosxr='react-native run-ios --simulator "iPhone XR"'
+alias rniosxs='react-native run-ios --simulator "iPhone Xs"'
+alias rniosxsm='react-native run-ios --simulator "iPhone Xs Max"'
+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"'
-alias rnland='react-native log-android'
-alias rnlios='react-native log-ios'
+
+# iPad
+alias rnipad2='react-native run-ios --simulator "iPad 2"'
+alias rnipad5='react-native run-ios --simulator "iPad (5th generation)"'
+alias rnipad6='react-native run-ios --simulator "iPad (6th generation)"'
+alias rnipadr='react-native run-ios --simulator "iPad Retina"'
+alias rnipada='react-native run-ios --simulator "iPad Air"'
+alias rnipada2='react-native run-ios --simulator "iPad Air 2"'
+alias rnipada3='react-native run-ios --simulator "iPad Air (3rd generation)"'
+alias rnipadm2='react-native run-ios --simulator "iPad mini 2"'
+alias rnipadm3='react-native run-ios --simulator "iPad mini 3"'
+alias rnipadm4='react-native run-ios --simulator "iPad mini 4"'
+alias rnipadm5='react-native run-ios --simulator "iPad mini (5th generation)"'
+alias rnipadp9='react-native run-ios --simulator "iPad Pro (9.7-inch)"'
+alias rnipadp12='react-native run-ios --simulator "iPad Pro (12.9-inch)"'
+alias rnipadp122='react-native run-ios --simulator "iPad Pro (12.9-inch) (2nd generation)"'
+alias rnipadp10='react-native run-ios --simulator "iPad Pro (10.5-inch)"'
+alias rnipad11='react-native run-ios --simulator "iPad Pro (11-inch)"'
+alias rnipad123='react-native run-ios --simulator "iPad Pro (12.9-inch) (3rd generation)"'
+
+# Apple TV
+alias rnatv='react-native run-ios --simulator "Apple TV"'
+alias rnatv4k='react-native run-ios --simulator "Apple TV 4K"'
+alias rnatv4k1080='react-native run-ios --simulator "Apple TV 4K (at 1080p)"'
+
+# Apple Watch
+alias rnaw38='react-native run-ios --simulator "Apple Watch - 38mm"'
+alias rnaw42='react-native run-ios --simulator "Apple Watch - 42mm"'
+alias rnaws238='react-native run-ios --simulator "Apple Watch Series 2 - 38mm"'
+alias rnaws242='react-native run-ios --simulator "Apple Watch Series 2 - 42mm"'
+alias rnaws338='react-native run-ios --simulator "Apple Watch Series 3 - 38mm"'
+alias rnaws342='react-native run-ios --simulator "Apple Watch Series 3 - 42mm"'
+alias rnaws440='react-native run-ios --simulator "Apple Watch Series 4 - 40mm"'
+alias rnaws444='react-native run-ios --simulator "Apple Watch Series 4 - 44mm"'
diff --git a/plugins/rebar/README.md b/plugins/rebar/README.md
new file mode 100644
index 000000000..456ba45c7
--- /dev/null
+++ b/plugins/rebar/README.md
@@ -0,0 +1,9 @@
+# rebar plugin
+
+This plugin adds completions for the [rebar](https://www.rebar3.org/) Erlang build tool.
+
+To use it, add `rebar` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... rebar)
+```
diff --git a/plugins/redis-cli/README.md b/plugins/redis-cli/README.md
new file mode 100644
index 000000000..bb6e94a0f
--- /dev/null
+++ b/plugins/redis-cli/README.md
@@ -0,0 +1,15 @@
+# Redis-CLI
+
+This plugin adds [redis-cli](https://redis.io/topics/rediscli) completion, based off of Homebrew completion.
+
+To use it, add `redis-cli` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... redis-cli)
+```
+
+## Requirements
+
+In order to make this work, you will need to have redis installed.
+
+More info on the usage and install: https://redis.io/topics/quickstart
diff --git a/plugins/repo/README.md b/plugins/repo/README.md
index 4d9366adf..6abd23319 100644
--- a/plugins/repo/README.md
+++ b/plugins/repo/README.md
@@ -1,7 +1,25 @@
-## repo
-**Maintainer:** [Stibbons](https://github.com/Stibbons)
+# repo plugin
-This plugin mainly add support automatic completion for the repo command line tool:
-https://code.google.com/p/git-repo/
+This plugin mainly adds some aliases and support for automatic completion for
+the [repo command line tool](https://code.google.com/p/git-repo/).
-* `r` aliases `repo`
+To use it, add `repo` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... repo)
+```
+
+## Aliases
+
+| Alias | Command |
+|---------|----------------------------------------|
+| `r` | `repo` |
+| `rra` | `repo rebase --auto-stash` |
+| `rs` | `repo sync` |
+| `rsrra` | `repo sync ; repo rebase --auto-stash` |
+| `ru` | `repo upload` |
+| `rst` | `repo status` |
+| `rsto` | `repo status -o` |
+| `rfa` | `repo forall -c` |
+| `rfap` | `repo forall -p -c` |
+| `rinf` | `repo info` |
diff --git a/plugins/repo/_repo b/plugins/repo/_repo
index 59e39c954..db0ecd14d 100644
--- a/plugins/repo/_repo
+++ b/plugins/repo/_repo
@@ -1,6 +1,5 @@
#compdef repo
-
__git_apply_whitespace_strategies ()
{
declare -a strategies
@@ -269,4 +268,3 @@ __repo_projects_or_all()
_repo "$@"
return $?
-
diff --git a/plugins/repo/repo.plugin.zsh b/plugins/repo/repo.plugin.zsh
index 33f4195c7..f098993f8 100644
--- a/plugins/repo/repo.plugin.zsh
+++ b/plugins/repo/repo.plugin.zsh
@@ -1,18 +1,10 @@
-# Aliases
alias r='repo'
-compdef _repo r=repo
-
alias rra='repo rebase --auto-stash'
-compdef _repo rra='repo rebase --auto-stash'
-
alias rs='repo sync'
-compdef _repo rs='repo sync'
-
alias rsrra='repo sync ; repo rebase --auto-stash'
-compdef _repo rsrra='repo sync ; repo rebase --auto-stash'
-
alias ru='repo upload'
-compdef _repo ru='repo upload'
-
alias rst='repo status'
-compdef _repo rst='repo status'
+alias rsto='repo status -o'
+alias rfa='repo forall -c'
+alias rfap='repo forall -p -c'
+alias rinf='repo info'
diff --git a/plugins/ripgrep/README.md b/plugins/ripgrep/README.md
new file mode 100644
index 000000000..937f73c81
--- /dev/null
+++ b/plugins/ripgrep/README.md
@@ -0,0 +1,13 @@
+# ripgrep
+
+This plugin adds completion for the text search tool [`ripgrep`](https://github.com/BurntSushi/ripgrep), also known as `rg`.
+
+To use it, add `ripgrep` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... ripgrep)
+```
+
+Completion is taken from the ripgrep release [`11.0.2`](https://github.com/BurntSushi/ripgrep/releases/tag/11.0.2).
+
+Updated on August 16th, 2019.
diff --git a/plugins/ripgrep/_ripgrep b/plugins/ripgrep/_ripgrep
new file mode 100644
index 000000000..d7dcfd64a
--- /dev/null
+++ b/plugins/ripgrep/_ripgrep
@@ -0,0 +1,612 @@
+#compdef rg
+
+##
+# zsh completion function for ripgrep
+#
+# Run ci/test_complete.sh after building to ensure that the options supported by
+# this function stay in synch with the `rg` binary.
+#
+# For convenience, a completion reference guide is included at the bottom of
+# this file.
+#
+# Originally based on code from the zsh-users project — see copyright notice
+# below.
+
+_rg() {
+ local curcontext=$curcontext no='!' descr ret=1
+ local -a context line state state_descr args tmp suf
+ local -A opt_args
+
+ # ripgrep has many options which negate the effect of a more common one — for
+ # example, `--no-column` to negate `--column`, and `--messages` to negate
+ # `--no-messages`. There are so many of these, and they're so infrequently
+ # used, that some users will probably find it irritating if they're completed
+ # indiscriminately, so let's not do that unless either the current prefix
+ # matches one of those negation options or the user has the `complete-all`
+ # style set. Note that this prefix check has to be updated manually to account
+ # for all of the potential negation options listed below!
+ if
+ # We also want to list all of these options during testing
+ [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] ||
+ # (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode)
+ [[ $PREFIX$SUFFIX == --[imnp]* ]] ||
+ zstyle -t ":complete:$curcontext:*" complete-all
+ then
+ no=
+ fi
+
+ # We make heavy use of argument groups here to prevent the option specs from
+ # growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
+ # them out below if necessary. This makes the exclusions inaccurate on those
+ # older versions, but oh well — it's not that big a deal
+ args=(
+ + '(exclusive)' # Misc. fully exclusive options
+ '(: * -)'{-h,--help}'[display help information]'
+ '(: * -)'{-V,--version}'[display version information]'
+ '(: * -)'--pcre2-version'[print the version of PCRE2 used by ripgrep, if available]'
+
+ + '(buffered)' # buffering options
+ '--line-buffered[force line buffering]'
+ $no"--no-line-buffered[don't force line buffering]"
+ '--block-buffered[force block buffering]'
+ $no"--no-block-buffered[don't force block buffering]"
+
+ + '(case)' # Case-sensitivity options
+ {-i,--ignore-case}'[search case-insensitively]'
+ {-s,--case-sensitive}'[search case-sensitively]'
+ {-S,--smart-case}'[search case-insensitively if pattern is all lowercase]'
+
+ + '(context-a)' # Context (after) options
+ '(context-c)'{-A+,--after-context=}'[specify lines to show after each match]:number of lines'
+
+ + '(context-b)' # Context (before) options
+ '(context-c)'{-B+,--before-context=}'[specify lines to show before each match]:number of lines'
+
+ + '(context-c)' # Context (combined) options
+ '(context-a context-b)'{-C+,--context=}'[specify lines to show before and after each match]:number of lines'
+
+ + '(column)' # Column options
+ '--column[show column numbers for matches]'
+ $no"--no-column[don't show column numbers for matches]"
+
+ + '(count)' # Counting options
+ {-c,--count}'[only show count of matching lines for each file]'
+ '--count-matches[only show count of individual matches for each file]'
+
+ + '(encoding)' # Encoding options
+ {-E+,--encoding=}'[specify text encoding of files to search]: :_rg_encodings'
+ $no'--no-encoding[use default text encoding]'
+
+ + file # File-input options
+ '(1)*'{-f+,--file=}'[specify file containing patterns to search for]: :_files'
+
+ + '(file-match)' # Files with/without match options
+ '(stats)'{-l,--files-with-matches}'[only show names of files with matches]'
+ '(stats)--files-without-match[only show names of files without matches]'
+
+ + '(file-name)' # File-name options
+ {-H,--with-filename}'[show file name for matches]'
+ {-I,--no-filename}"[don't show file name for matches]"
+
+ + '(file-system)' # File system options
+ "--one-file-system[don't descend into directories on other file systems]"
+ $no'--no-one-file-system[descend into directories on other file systems]'
+
+ + '(fixed)' # Fixed-string options
+ {-F,--fixed-strings}'[treat pattern as literal string instead of regular expression]'
+ $no"--no-fixed-strings[don't treat pattern as literal string]"
+
+ + '(follow)' # Symlink-following options
+ {-L,--follow}'[follow symlinks]'
+ $no"--no-follow[don't follow symlinks]"
+
+ + glob # File-glob options
+ '*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob'
+ '*--iglob=[include/exclude files matching specified case-insensitive glob]:glob'
+
+ + '(glob-case-insensitive)' # File-glob case sensitivity options
+ '--glob-case-insensitive[treat -g/--glob patterns case insensitively]'
+ $no'--no-glob-case-insensitive[treat -g/--glob patterns case sensitively]'
+
+ + '(heading)' # Heading options
+ '(pretty-vimgrep)--heading[show matches grouped by file name]'
+ "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
+
+ + '(hidden)' # Hidden-file options
+ '--hidden[search hidden files and directories]'
+ $no"--no-hidden[don't search hidden files and directories]"
+
+ + '(hybrid)' # hybrid regex options
+ '--auto-hybrid-regex[dynamically use PCRE2 if necessary]'
+ $no"--no-auto-hybrid-regex[don't dynamically use PCRE2 if necessary]"
+
+ + '(ignore)' # Ignore-file options
+ "(--no-ignore-global --no-ignore-parent --no-ignore-vcs --no-ignore-dot)--no-ignore[don't respect ignore files]"
+ $no'(--ignore-global --ignore-parent --ignore-vcs --ignore-dot)--ignore[respect ignore files]'
+
+ + '(ignore-file-case-insensitive)' # Ignore-file case sensitivity options
+ '--ignore-file-case-insensitive[process ignore files case insensitively]'
+ $no'--no-ignore-file-case-insensitive[process ignore files case sensitively]'
+
+ + '(ignore-global)' # Global ignore-file options
+ "--no-ignore-global[don't respect global ignore files]"
+ $no'--ignore-global[respect global ignore files]'
+
+ + '(ignore-parent)' # Parent ignore-file options
+ "--no-ignore-parent[don't respect ignore files in parent directories]"
+ $no'--ignore-parent[respect ignore files in parent directories]'
+
+ + '(ignore-vcs)' # VCS ignore-file options
+ "--no-ignore-vcs[don't respect version control ignore files]"
+ $no'--ignore-vcs[respect version control ignore files]'
+
+ + '(ignore-dot)' # .ignore-file options
+ "--no-ignore-dot[don't respect .ignore files]"
+ $no'--ignore-dot[respect .ignore files]'
+
+ + '(json)' # JSON options
+ '--json[output results in JSON Lines format]'
+ $no"--no-json[don't output results in JSON Lines format]"
+
+ + '(line-number)' # Line-number options
+ {-n,--line-number}'[show line numbers for matches]'
+ {-N,--no-line-number}"[don't show line numbers for matches]"
+
+ + '(line-terminator)' # Line-terminator options
+ '--crlf[use CRLF as line terminator]'
+ $no"--no-crlf[don't use CRLF as line terminator]"
+ '(text)--null-data[use NUL as line terminator]'
+
+ + '(max-columns-preview)' # max column preview options
+ '--max-columns-preview[show preview for long lines (with -M)]'
+ $no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
+
+ + '(max-depth)' # Directory-depth options
+ '--max-depth=[specify max number of directories to descend]:number of directories'
+ '!--maxdepth=:number of directories'
+
+ + '(messages)' # Error-message options
+ '(--no-ignore-messages)--no-messages[suppress some error messages]'
+ $no"--messages[don't suppress error messages affected by --no-messages]"
+
+ + '(messages-ignore)' # Ignore-error message options
+ "--no-ignore-messages[don't show ignore-file parse error messages]"
+ $no'--ignore-messages[show ignore-file parse error messages]'
+
+ + '(mmap)' # mmap options
+ '--mmap[search using memory maps when possible]'
+ "--no-mmap[don't search using memory maps]"
+
+ + '(multiline)' # Multiline options
+ {-U,--multiline}'[permit matching across multiple lines]'
+ $no'(multiline-dotall)--no-multiline[restrict matches to at most one line each]'
+
+ + '(multiline-dotall)' # Multiline DOTALL options
+ '(--no-multiline)--multiline-dotall[allow "." to match newline (with -U)]'
+ $no"(--no-multiline)--no-multiline-dotall[don't allow \".\" to match newline (with -U)]"
+
+ + '(only)' # Only-match options
+ {-o,--only-matching}'[show only matching part of each line]'
+
+ + '(passthru)' # Pass-through options
+ '(--vimgrep)--passthru[show both matching and non-matching lines]'
+ '!(--vimgrep)--passthrough'
+
+ + '(pcre2)' # PCRE2 options
+ {-P,--pcre2}'[enable matching with PCRE2]'
+ $no'(pcre2-unicode)--no-pcre2[disable matching with PCRE2]'
+
+ + '(pcre2-unicode)' # PCRE2 Unicode options
+ $no'(--no-pcre2 --no-pcre2-unicode)--pcre2-unicode[enable PCRE2 Unicode mode (with -P)]'
+ '(--no-pcre2 --pcre2-unicode)--no-pcre2-unicode[disable PCRE2 Unicode mode (with -P)]'
+
+ + '(pre)' # Preprocessing options
+ '(-z --search-zip)--pre=[specify preprocessor utility]:preprocessor utility:_command_names -e'
+ $no'--no-pre[disable preprocessor utility]'
+
+ + pre-glob # Preprocessing glob options
+ '*--pre-glob[include/exclude files for preprocessing with --pre]'
+
+ + '(pretty-vimgrep)' # Pretty/vimgrep display options
+ '(heading)'{-p,--pretty}'[alias for --color=always --heading -n]'
+ '(heading passthru)--vimgrep[show results in vim-compatible format]'
+
+ + regexp # Explicit pattern options
+ '(1 file)*'{-e+,--regexp=}'[specify pattern]:pattern'
+
+ + '(replace)' # Replacement options
+ {-r+,--replace=}'[specify string used to replace matches]:replace string'
+
+ + '(sort)' # File-sorting options
+ '(threads)--sort=[sort results in ascending order (disables parallelism)]:sort method:((
+ none\:"no sorting"
+ path\:"sort by file path"
+ modified\:"sort by last modified time"
+ accessed\:"sort by last accessed time"
+ created\:"sort by creation time"
+ ))'
+ '(threads)--sortr=[sort results in descending order (disables parallelism)]:sort method:((
+ none\:"no sorting"
+ path\:"sort by file path"
+ modified\:"sort by last modified time"
+ accessed\:"sort by last accessed time"
+ created\:"sort by creation time"
+ ))'
+ '!(threads)--sort-files[sort results by file path (disables parallelism)]'
+
+ + '(stats)' # Statistics options
+ '(--files file-match)--stats[show search statistics]'
+ $no"--no-stats[don't show search statistics]"
+
+ + '(text)' # Binary-search options
+ {-a,--text}'[search binary files as if they were text]'
+ "--binary[search binary files, don't print binary data]"
+ $no"--no-binary[don't search binary files]"
+ $no"(--null-data)--no-text[don't search binary files as if they were text]"
+
+ + '(threads)' # Thread-count options
+ '(sort)'{-j+,--threads=}'[specify approximate number of threads to use]:number of threads'
+
+ + '(trim)' # Trim options
+ '--trim[trim any ASCII whitespace prefix from each line]'
+ $no"--no-trim[don't trim ASCII whitespace prefix from each line]"
+
+ + type # Type options
+ '*'{-t+,--type=}'[only search files matching specified type]: :_rg_types'
+ '*--type-add=[add new glob for specified file type]: :->typespec'
+ '*--type-clear=[clear globs previously defined for specified file type]: :_rg_types'
+ # This should actually be exclusive with everything but other type options
+ '(: *)--type-list[show all supported file types and their associated globs]'
+ '*'{-T+,--type-not=}"[don't search files matching specified file type]: :_rg_types"
+
+ + '(word-line)' # Whole-word/line match options
+ {-w,--word-regexp}'[only show matches surrounded by word boundaries]'
+ {-x,--line-regexp}'[only show matches surrounded by line boundaries]'
+
+ + '(zip)' # Compression options
+ '(--pre)'{-z,--search-zip}'[search in compressed files]'
+ $no"--no-search-zip[don't search in compressed files]"
+
+ + misc # Other options — no need to separate these at the moment
+ '(-b --byte-offset)'{-b,--byte-offset}'[show 0-based byte offset for each matching line]'
+ '--color=[specify when to use colors in output]:when:((
+ never\:"never use colors"
+ auto\:"use colors or not based on stdout, TERM, etc."
+ always\:"always use colors"
+ ansi\:"always use ANSI colors (even on Windows)"
+ ))'
+ '*--colors=[specify color and style settings]: :->colorspec'
+ '--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
+ '--debug[show debug messages]'
+ '--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
+ "(1 stats)--files[show each file that would be searched (but don't search)]"
+ '*--ignore-file=[specify additional ignore file]:ignore file:_files'
+ '(-v --invert-match)'{-v,--invert-match}'[invert matching]'
+ '(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes'
+ '(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches'
+ '--max-filesize=[specify size above which files should be ignored]:file size (bytes)'
+ "--no-config[don't load configuration files]"
+ '(-0 --null)'{-0,--null}'[print NUL byte after file names]'
+ '--path-separator=[specify path separator to use when printing file names]:separator'
+ '(-q --quiet)'{-q,--quiet}'[suppress normal output]'
+ '--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)'
+ '*'{-u,--unrestricted}'[reduce level of "smart" searching]'
+
+ + operand # Operands
+ '(--files --type-list file regexp)1: :_guard "^-*" pattern'
+ '(--type-list)*: :_files'
+ )
+
+ # This is used with test_complete.sh to verify that there are no options
+ # listed in the help output that aren't also defined here
+ [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] && {
+ print -rl - $args
+ return 0
+ }
+
+ # Strip out argument groups where unsupported (see above)
+ [[ $ZSH_VERSION == (4|5.<0-3>)(.*)# ]] &&
+ args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} )
+
+ _arguments -C -s -S : $args && ret=0
+
+ case $state in
+ colorspec)
+ if [[ ${IPREFIX#--*=}$PREFIX == [^:]# ]]; then
+ suf=( -qS: )
+ tmp=(
+ 'column:specify coloring for column numbers'
+ 'line:specify coloring for line numbers'
+ 'match:specify coloring for match text'
+ 'path:specify coloring for file names'
+ )
+ descr='color/style type'
+ elif [[ ${IPREFIX#--*=}$PREFIX == (column|line|match|path):[^:]# ]]; then
+ suf=( -qS: )
+ tmp=(
+ 'none:clear color/style for type'
+ 'bg:specify background color'
+ 'fg:specify foreground color'
+ 'style:specify text style'
+ )
+ descr='color/style attribute'
+ elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:(bg|fg):[^:]# ]]; then
+ tmp=( black blue green red cyan magenta yellow white )
+ descr='color name or r,g,b'
+ elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:style:[^:]# ]]; then
+ tmp=( {,no}bold {,no}intense {,no}underline )
+ descr='style name'
+ else
+ _message -e colorspec 'no more arguments'
+ fi
+
+ (( $#tmp )) && {
+ compset -P '*:'
+ _describe -t colorspec $descr tmp $suf && ret=0
+ }
+ ;;
+
+ typespec)
+ if compset -P '[^:]##:include:'; then
+ _sequence -s , _rg_types && ret=0
+ # @todo This bit in particular could be better, but it's a little
+ # complex, and attempting to solve it seems to run us up against a crash
+ # bug — zsh # 40362
+ elif compset -P '[^:]##:'; then
+ _message 'glob or include directive' && ret=1
+ elif [[ ! -prefix *:* ]]; then
+ _rg_types -qS : && ret=0
+ fi
+ ;;
+ esac
+
+ return ret
+}
+
+# Complete encodings
+_rg_encodings() {
+ local -a expl
+ local -aU _encodings
+
+ # This is impossible to read, but these encodings rarely if ever change, so it
+ # probably doesn't matter. They are derived from the list given here:
+ # https://encoding.spec.whatwg.org/#concept-encoding-get
+ _encodings=(
+ {{,us-}ascii,arabic,chinese,cyrillic,greek{,8},hebrew,korean}
+ logical visual mac {,cs}macintosh x-mac-{cyrillic,roman,ukrainian}
+ 866 ibm{819,866} csibm866
+ big5{,-hkscs} {cn-,cs}big5 x-x-big5
+ cp{819,866,125{0..8}} x-cp125{0..8}
+ csiso2022{jp,kr} csiso8859{6,8}{e,i}
+ csisolatin{{1..6},9} csisolatin{arabic,cyrillic,greek,hebrew}
+ ecma-{114,118} asmo-708 elot_928 sun_eu_greek
+ euc-{jp,kr} x-euc-jp cseuckr cseucpkdfmtjapanese
+ {,x-}gbk csiso58gb231280 gb18030 {,cs}gb2312 gb_2312{,-80} hz-gb-2312
+ iso-2022-{cn,cn-ext,jp,kr}
+ iso8859{,-}{{1..11},13,14,15}
+ iso-8859-{{1..11},{6,8}-{e,i},13,14,15,16} iso_8859-{{1..9},15}
+ iso_8859-{1,2,6,7}:1987 iso_8859-{3,4,5,8}:1988 iso_8859-9:1989
+ iso-ir-{58,100,101,109,110,126,127,138,144,148,149,157}
+ koi{,8,8-r,8-ru,8-u,8_r} cskoi8r
+ ks_c_5601-{1987,1989} ksc{,_}5691 csksc56011987
+ latin{1..6} l{{1..6},9}
+ shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932
+ utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8
+ windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968
+ x-user-defined auto none
+ )
+
+ _wanted encodings expl encoding compadd -a "$@" - _encodings
+}
+
+# Complete file types
+_rg_types() {
+ local -a expl
+ local -aU _types
+
+ _types=( ${(@)${(f)"$( _call_program types rg --type-list )"}%%:*} )
+
+ _wanted types expl 'file type' compadd -a "$@" - _types
+}
+
+_rg "$@"
+
+################################################################################
+# ZSH COMPLETION REFERENCE
+#
+# For the convenience of developers who aren't especially familiar with zsh
+# completion functions, a brief reference guide follows. This is in no way
+# comprehensive; it covers just enough of the basic structure, syntax, and
+# conventions to help someone make simple changes like adding new options. For
+# more complete documentation regarding zsh completion functions, please see the
+# following:
+#
+# * http://zsh.sourceforge.net/Doc/Release/Completion-System.html
+# * https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide
+#
+# OVERVIEW
+#
+# Most zsh completion functions are defined in terms of `_arguments`, which is a
+# shell function that takes a series of argument specifications. The specs for
+# `rg` are stored in an array, which is common for more complex functions; the
+# elements of the array are passed to `_arguments` on invocation.
+#
+# ARGUMENT-SPECIFICATION SYNTAX
+#
+# The following is a contrived example of the argument specs for a simple tool:
+#
+# '(: * -)'{-h,--help}'[display help information]'
+# '(-q -v --quiet --verbose)'{-q,--quiet}'[decrease output verbosity]'
+# '!(-q -v --quiet --verbose)--silent'
+# '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]'
+# '--color=[specify when to use colors]:when:(always never auto)'
+# '*:example file:_files'
+#
+# Although there may appear to be six specs here, there are actually nine; we
+# use brace expansion to combine specs for options that go by multiple names,
+# like `-q` and `--quiet`. This is customary, and ties in with the fact that zsh
+# merges completion possibilities together when they have the same description.
+#
+# The first line defines the option `-h`/`--help`. With most tools, it isn't
+# useful to complete anything after `--help` because it effectively overrides
+# all others; the `(: * -)` at the beginning of the spec tells zsh not to
+# complete any other operands (`:` and `*`) or options (`-`) after this one has
+# been used. The `[...]` at the end associates a description with `-h`/`--help`;
+# as mentioned, zsh will see the identical descriptions and merge these options
+# together when offering completion possibilities.
+#
+# The next line defines `-q`/`--quiet`. Here we don't want to suppress further
+# completions entirely, but we don't want to offer `-q` if `--quiet` has been
+# given (since they do the same thing), nor do we want to offer `-v` (since it
+# doesn't make sense to be quiet and verbose at the same time). We don't need to
+# tell zsh not to offer `--quiet` a second time, since that's the default
+# behaviour, but since this line expands to two specs describing `-q` *and*
+# `--quiet` we do need to explicitly list all of them here.
+#
+# The next line defines a hidden option `--silent` — maybe it's a deprecated
+# synonym for `--quiet`. The leading `!` indicates that zsh shouldn't offer this
+# option during completion. The benefit of providing a spec for an option that
+# shouldn't be completed is that, if someone *does* use it, we can correctly
+# suppress completion of other options afterwards.
+#
+# The next line defines `-v`/`--verbose`; this works just like `-q`/`--quiet`.
+#
+# The next line defines `--color`. In this example, `--color` doesn't have a
+# corresponding short option, so we don't need to use brace expansion. Further,
+# there are no other options it's exclusive with (just itself), so we don't need
+# to define those at the beginning. However, it does take a mandatory argument.
+# The `=` at the end of `--color=` indicates that the argument may appear either
+# like `--color always` or like `--color=always`; this is how most GNU-style
+# command-line tools work. The corresponding short option would normally use `+`
+# — for example, `-c+` would allow either `-c always` or `-calways`. For this
+# option, the arguments are known ahead of time, so we can simply list them in
+# parentheses at the end (`when` is used as the description for the argument).
+#
+# The last line defines an operand (a non-option argument). In this example, the
+# operand can be used any number of times (the leading `*`), and it should be a
+# file path, so we tell zsh to call the `_files` function to complete it. The
+# `example file` in the middle is the description to use for this operand; we
+# could use a space instead to accept the default provided by `_files`.
+#
+# GROUPING ARGUMENT SPECIFICATIONS
+#
+# Newer versions of zsh support grouping argument specs together. All specs
+# following a `+` and then a group name are considered to be members of the
+# named group. Grouping is useful mostly for organisational purposes; it makes
+# the relationship between different options more obvious, and makes it easier
+# to specify exclusions.
+#
+# We could rewrite our example above using grouping as follows:
+#
+# '(: * -)'{-h,--help}'[display help information]'
+# '--color=[specify when to use colors]:when:(always never auto)'
+# '*:example file:_files'
+# + '(verbosity)'
+# {-q,--quiet}'[decrease output verbosity]'
+# '!--silent'
+# {-v,--verbose}'[increase output verbosity]'
+#
+# Here we take advantage of a useful feature of spec grouping — when the group
+# name is surrounded by parentheses, as in `(verbosity)`, it tells zsh that all
+# of the options in that group are exclusive with each other. As a result, we
+# don't need to manually list out the exclusions at the beginning of each
+# option.
+#
+# Groups can also be referred to by name in other argument specs; for example:
+#
+# '(xyz)--aaa' '*: :_files'
+# + xyz --xxx --yyy --zzz
+#
+# Here we use the group name `xyz` to tell zsh that `--xxx`, `--yyy`, and
+# `--zzz` are not to be completed after `--aaa`. This makes the exclusion list
+# much more compact and reusable.
+#
+# CONVENTIONS
+#
+# zsh completion functions generally adhere to the following conventions:
+#
+# * Use two spaces for indentation
+# * Combine specs for options with different names using brace expansion
+# * In combined specs, list the short option first (as in `{-a,--text}`)
+# * Use `+` or `=` as described above for options that take arguments
+# * Provide a description for all options, option-arguments, and operands
+# * Capitalise/punctuate argument descriptions as phrases, not complete
+# sentences — 'display help information', never 'Display help information.'
+# (but still capitalise acronyms and proper names)
+# * Write argument descriptions as verb phrases — 'display x', 'enable y',
+# 'use z'
+# * Word descriptions to make it clear when an option expects an argument;
+# usually this is done with the word 'specify', as in 'specify x' or
+# 'use specified x')
+# * Write argument descriptions as tersely as possible — for example, articles
+# like 'a' and 'the' should be omitted unless it would be confusing
+#
+# Other conventions currently used by this function:
+#
+# * Order argument specs alphabetically by group name, then option name
+# * Group options that are directly related, mutually exclusive, or frequently
+# referenced by other argument specs
+# * Use only characters in the set [a-z0-9_-] in group names
+# * Order exclusion lists as follows: short options, long options, groups
+# * Use American English in descriptions
+# * Use 'don't' in descriptions instead of 'do not'
+# * Word descriptions for related options as similarly as possible. For example,
+# `--foo[enable foo]` and `--no-foo[disable foo]`, or `--foo[use foo]` and
+# `--no-foo[don't use foo]`
+# * Word descriptions to make it clear when an option only makes sense with
+# another option, usually by adding '(with -x)' to the end
+# * Don't quote strings or variables unnecessarily. When quotes are required,
+# prefer single-quotes to double-quotes
+# * Prefix option specs with `$no` when the option serves only to negate the
+# behaviour of another option that must be provided explicitly by the user.
+# This prevents rarely used options from cluttering up the completion menu
+################################################################################
+
+# ------------------------------------------------------------------------------
+# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the zsh-users nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# Completion script for ripgrep
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * arcizan <ghostrevery@gmail.com>
+# * MaskRay <i@maskray.me>
+#
+# ------------------------------------------------------------------------------
+
+# Local Variables:
+# mode: shell-script
+# coding: utf-8-unix
+# indent-tabs-mode: nil
+# sh-indentation: 2
+# sh-basic-offset: 2
+# End:
+# vim: ft=zsh sw=2 ts=2 et
diff --git a/plugins/ros/README.md b/plugins/ros/README.md
new file mode 100644
index 000000000..83573e499
--- /dev/null
+++ b/plugins/ros/README.md
@@ -0,0 +1,10 @@
+# Roswell Plugin
+
+This plugin adds completions and aliases for [Roswell](https://github.com/roswell/roswell/).
+
+To use it, add `ros` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... ros)
+```
+
diff --git a/plugins/ros/_ros b/plugins/ros/_ros
new file mode 100644
index 000000000..6a04d3c8f
--- /dev/null
+++ b/plugins/ros/_ros
@@ -0,0 +1,64 @@
+#compdef ros
+#autoload
+
+# roswell zsh completion, based on gem completion
+
+local -a _1st_arguments
+_1st_arguments=(
+'run: Run repl'
+'install:Install a given implementation or a system for roswell environment'
+'update:Update installed systems.'
+'build:Make executable from script.'
+'use:Change default implementation.'
+'init:a new ros script, optionally based on a template.'
+'fmt:Indent lisp source.'
+'list:Information'
+'template:[WIP] Manage templates'
+'delete:Delete installed implementations'
+'config:Get and set options'
+'version:Show the roswell version information'
+"help:Use \"ros help [command]\" for more information about a command."$'\n\t\t'"Use \"ros help [topic]\" for more information about the topic."
+)
+
+#local expl
+
+_arguments \
+ '(--version)'--version'[Print version information and quit]' \
+ '(-w --wrap)'{-w,--wrap}'[\[CODE\] Run roswell with a shell wrapper CODE]' \
+ '(-m --image)'{-m,--image}'[\[IMAGE\] continue from Lisp image IMAGE]' \
+ '(-M --module)'{-M,--module}'[\[NAME\] Execute ros script found in ROSWELLPATH. (pythons -m)]' \
+ '(-L --lisp)'{-L,--lisp}'[\[NAME\] Run roswell with a lisp impl NAME\[/VERSION\].]' \
+ '(-l --load)'{-l,--load}'[\[FILE\] load lisp FILE while building]' \
+ '(-S --source-registry)'{-S,--source-registry}'[\[X\] override source registry of asdf systems]' \
+ '(-s --system --load-system)'{-s,--system,--load-system}'[\[SYSTEM\] load asdf SYSTEM while building]' \
+ '(-p --package)'{-p,--package}'[\[PACKAGE\] change current package to \[PACKAGE\]]' \
+ '(-sp --system-package)'{-sp,--system-package}'[\[SP\] combination of -s \[SP\] and -p \[SP\]]' \
+ '(-e --eval)'{-e,--eval}'[\[FORM\] evaluate \[FORM\] while building]' \
+ '--require'--require'[\[MODULE\] require \[MODULE\] while building]' \
+ '(-q --quit)'{-q,--quit}'[quit lisp here]' \
+ '(-r --restart)'{-r,--restart}'[\[FUNC\] restart from build by calling (\[FUNC\])]' \
+ '(-E --entry)'{-E,--entry}'[\[FUNC\] restart from build by calling (\[FUNC\] argv)]' \
+ '(-i --init)'{-i,--init}'[\[FORM\] evaluate \[FORM\] after restart]' \
+ '(-ip --print)'{-ip,--print}'[\[FORM\] evaluate and princ \[FORM\] after restart]' \
+ '(-iw --write)'{-iw,--write}'[\[FORM\] evaluate and write \[FORM\] after restart]' \
+ '(-F --final)'{-F,--final}'[\[FORM\] evaluate \[FORM\] before dumping IMAGE]' \
+ '(\+R --no-rc)'{\+R,--no-rc}'[skip /etc/rosrc, ~/.roswell/init.lisp]' \
+ '(-A --asdf)'{-A,--asdf}'[use new asdf]' \
+ '(\+Q --no-quicklisp)'{\+Q,--no-quicklisp}'[do not use quicklisp]' \
+ '(-v --verbose)'{-v,--verbose}'[be quite noisy while building]' \
+ '--quiet'--quiet'[be quite quiet while building default]' \
+ '--test'--test'[for test purpose]' \
+ '*:: :->subcmds' && return 0
+
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "ros subcommand" _1st_arguments
+ return
+fi
+
+# _files
+case "$words[1]" in
+ -l|--load)
+ _files
+ ;;
+esac
diff --git a/plugins/rust/README.md b/plugins/rust/README.md
new file mode 100644
index 000000000..83d7d91ba
--- /dev/null
+++ b/plugins/rust/README.md
@@ -0,0 +1,9 @@
+# rust
+
+This plugin adds completion for [`rustc`](https://doc.rust-lang.org/rustc/index.html), the compiler for the Rust programming language.
+
+To use it, add `rust` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... rust)
+```
diff --git a/plugins/rustup/README.md b/plugins/rustup/README.md
new file mode 100644
index 000000000..ba037f8f6
--- /dev/null
+++ b/plugins/rustup/README.md
@@ -0,0 +1,9 @@
+# rustup
+
+This plugin adds completion for [`rustup`](https://rustup.rs/), the toolchain installer for the Rust programming language.
+
+To use it, add `rustup` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... rustup)
+```
diff --git a/plugins/rustup/_rustup b/plugins/rustup/_rustup
new file mode 100644
index 000000000..dab33533a
--- /dev/null
+++ b/plugins/rustup/_rustup
@@ -0,0 +1,1143 @@
+#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/rvm/README.md b/plugins/rvm/README.md
new file mode 100644
index 000000000..1ed8d46a2
--- /dev/null
+++ b/plugins/rvm/README.md
@@ -0,0 +1,20 @@
+# Ruby Version Manager plugin
+
+This plugin adds some utility functions and completions for [Ruby Version Manager](https://rvm.io/).
+
+To use it, add `rvm` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... rvm)
+```
+
+## Aliases
+
+| Alias | Command |
+|----------------|----------------------|
+| `rb18` | `rvm use ruby-1.8.7` |
+| `rb19` | `rvm use ruby-1.9.3` |
+| `rb20` | `rvm use ruby-2.0.0` |
+| `rb21` | `rvm use ruby-2.1.2` |
+| `rvm-update` | `rvm get head` |
+| `gems` | `gem list` |
diff --git a/plugins/safe-paste/README.md b/plugins/safe-paste/README.md
new file mode 100644
index 000000000..a2e7ddbfc
--- /dev/null
+++ b/plugins/safe-paste/README.md
@@ -0,0 +1,9 @@
+# safe-paste
+
+Preventing any code from actually running while pasting, so you have a chance to review what was actually pasted before running it.
+
+To use it, add `safe-paste` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... safe-paste)
+```
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/salt/_salt b/plugins/salt/_salt
index 10b782af4..78d8611d2 100644
--- a/plugins/salt/_salt
+++ b/plugins/salt/_salt
@@ -271,7 +271,7 @@ _salt_comp(){
fi
if _cache_invalid salt/salt_dir || ! _retrieve_cache salt/salt_dir; then
- salt_dir="${$(python2 -c 'import salt; print(salt.__file__);')%__init__*}"
+ salt_dir="${$(python2 -c 'import sys; del sys.path[0]; import salt; print(salt.__file__);')%__init__*}"
_store_cache salt/salt_dir salt_dir
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/sbt/README.md b/plugins/sbt/README.md
index f1a5753b9..f0201938e 100644
--- a/plugins/sbt/README.md
+++ b/plugins/sbt/README.md
@@ -17,16 +17,16 @@ plugins=(... sbt)
| sbcln | `sbt clean` | Deletes all generated files |
| sbcc | `sbt clean compile` | Deletes generated files, compiles the main sources |
| sbco | `sbt console` | Starts Scala with the compiled sources and all dependencies |
-| sbcq | `sbt console-quick` | Starts Scala with all dependencies |
-| sbcp | `sbt console-project` | Starts Scala with sbt and the build definitions |
+| sbcq | `sbt consoleQuick` | Starts Scala with all dependencies |
+| sbcp | `sbt consoleProject` | Starts Scala with sbt and the build definitions |
| sbd | `sbt doc` | Generates API documentation for Scala source files |
| sbdc | `sbt dist:clean` | Deletes the distribution packages |
| sbdi | `sbt dist` | Creates the distribution packages |
-| sbgi | `sbt gen-idea` | Create Idea project files |
+| sbgi | `sbt genIdea` | Create Idea project files |
| sbp | `sbt publish` | Publishes artifacts to the repository |
-| sbpl | `sbt publish-local` | Publishes artifacts to the local Ivy repository |
+| sbpl | `sbt publishLocal` | Publishes artifacts to the local Ivy repository |
| sbr | `sbt run` | Runs the main class for the project |
-| sbrm | `sbt run-main` | Runs the specified main class for the project |
+| sbrm | `sbt runMain` | Runs the specified main class for the project |
| sbu | `sbt update` | Resolves and retrieves external dependencies |
| sbx | `sbt test` | Compiles and runs all tests |
| sba | `sbt assembly` | Create a fat JAR with all dependencies |
diff --git a/plugins/sbt/_sbt b/plugins/sbt/_sbt
index a601c9b97..2138a722f 100644
--- a/plugins/sbt/_sbt
+++ b/plugins/sbt/_sbt
@@ -6,23 +6,23 @@ _sbt_commands=(
'clean:delete files produced by the build'
'compile:compile sources'
'console:start the Scala REPL with project classes on the classpath'
- 'console-quick:start the Scala REPL with project deps on the classpath'
- 'console-project:start the Scala REPL w/sbt+build-def on the classpath'
+ 'consoleQuick:start the Scala REPL with project deps on the classpath'
+ 'consoleProject:start the Scala REPL w/sbt+build-def on the classpath'
'dist:generate distribution artifacts'
'dist\:clean:clean distribution artifacts'
'doc:generate API documentation'
- 'gen-idea:generate Intellij Idea project files'
+ 'genIdea:generate Intellij Idea project files'
'package:produce the main artifact, such as a binary jar'
- 'package-doc:produce a doc artifact, such as a jar containing API docs'
- 'package-src:produce a source artifact, such as a jar containing sources'
+ 'packageDoc:produce a doc artifact, such as a jar containing API docs'
+ 'packageSrc:produce a source artifact, such as a jar containing sources'
'publish:publish artifacts to a repository'
- 'publish-local:publish artifacts to the local repository'
- 'publish-m2:publish artifacts to the local Maven 2 repository'
+ 'publishLocal:publish artifacts to the local repository'
+ 'publishM2:publish artifacts to the local Maven 2 repository'
'run:run a main class'
- 'run-main:run the main class selected by the first argument'
+ 'runMain:run the main class selected by the first argument'
'test:execute all tests'
- 'test-only:execute the tests provided as arguments'
- 'test-quick:execute previously failed tests'
+ 'testOnly:execute the tests provided as arguments'
+ 'testQuick:execute previously failed tests'
'update:resolve and optionally retrieve dependencies'
)
diff --git a/plugins/sbt/sbt.plugin.zsh b/plugins/sbt/sbt.plugin.zsh
index f883b7fee..851302c68 100644
--- a/plugins/sbt/sbt.plugin.zsh
+++ b/plugins/sbt/sbt.plugin.zsh
@@ -9,17 +9,17 @@
alias sbc='sbt compile'
alias sbcc='sbt clean compile'
alias sbco='sbt console'
-alias sbcq='sbt console-quick'
+alias sbcq='sbt consoleQuick'
alias sbcln='sbt clean'
-alias sbcp='sbt console-project'
+alias sbcp='sbt consoleProject'
alias sbd='sbt doc'
alias sbdc='sbt dist:clean'
alias sbdi='sbt dist'
-alias sbgi='sbt gen-idea'
+alias sbgi='sbt genIdea'
alias sbp='sbt publish'
-alias sbpl='sbt publish-local'
+alias sbpl='sbt publishLocal'
alias sbr='sbt run'
-alias sbrm='sbt run-main'
+alias sbrm='sbt runMain'
alias sbu='sbt update'
alias sbx='sbt test'
alias sba='sbt assembly'
diff --git a/plugins/scala/README.md b/plugins/scala/README.md
index 957261d9e..91a322162 100644
--- a/plugins/scala/README.md
+++ b/plugins/scala/README.md
@@ -1,15 +1,16 @@
-## Scala plugin
+# Scala plugin
Completion script for [scala and scalac](https://www.scala-lang.org/) commands.
To use it, add `scala` to the plugins array of your zshrc file:
-```
+
+```zsh
plugins=(... scala)
```
## Aliases
-| Command | Description |
-|------------------|---------------------------------------------------------------------------------|
-| `scala` | Run code in the Scala language |
-| `scalac` | Compiler for the Scala language |
+| Command | Description |
+|----------|---------------------------------|
+| `scala` | Run code in the Scala language |
+| `scalac` | Compiler for the Scala language |
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/README.md b/plugins/screen/README.md
new file mode 100644
index 000000000..103e17237
--- /dev/null
+++ b/plugins/screen/README.md
@@ -0,0 +1,10 @@
+# screen
+
+This plugin sets title and hardstatus of the tab window for [screen](https://www.gnu.org/software/screen/),
+the terminal multiplexer.
+
+To use it add `screen` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... screen)
+```
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/sdk/README.md b/plugins/sdk/README.md
new file mode 100644
index 000000000..1eda5d390
--- /dev/null
+++ b/plugins/sdk/README.md
@@ -0,0 +1,14 @@
+# sdk
+
+Plugin for SDKMAN, a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems.
+Provides autocompletion for all known commands.
+
+To use it, add `sdk` to your plugins array in your zshrc file:
+
+```zsh
+plugins=(... sdk)
+```
+
+## Requirements
+
+* [SDKMAN](http://sdkman.io/)
diff --git a/plugins/sdk/sdk.plugin.zsh b/plugins/sdk/sdk.plugin.zsh
new file mode 100644
index 000000000..441bd6ff4
--- /dev/null
+++ b/plugins/sdk/sdk.plugin.zsh
@@ -0,0 +1,58 @@
+#!/usr/bin/env zsh
+
+### SDKMAN Autocomplete for Oh My Zsh
+
+_sdk() {
+ case "${CURRENT}" in
+ 2)
+ compadd -X $'Commands:\n' -- "${${(Mk)functions[@]:#__sdk_*}[@]#__sdk_}"
+ compadd -n rm
+ ;;
+ 3)
+ case "${words[2]}" in
+ l|ls|list|i|install)
+ compadd -X $'Candidates:\n' -- "${SDKMAN_CANDIDATES[@]}"
+ ;;
+ ug|upgrade|h|home|c|current|u|use|d|default|rm|uninstall)
+ compadd -X $'Installed Candidates:\n' -- "${${(u)${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}" -mindepth 2 -maxdepth 2 -type d)}[@]:h}[@]:t}"
+ ;;
+ e|env)
+ compadd init
+ ;;
+ offline)
+ compadd enable disable
+ ;;
+ selfupdate)
+ compadd force
+ ;;
+ flush)
+ compadd archives broadcast temp version
+ ;;
+ esac
+ ;;
+ 4)
+ case "${words[2]}" in
+ i|install)
+ setopt localoptions kshglob
+ if [[ "${words[3]}" == 'java' ]]; then
+ compadd -X $'Installable Versions of java:\n' -- "${${${${${(f)$(__sdkman_list_versions "${words[3]}")}[@]:5:-4}[@]:#* | (local only|installed ) | *}[@]##* | | }[@]%%+( )}"
+ else
+ compadd -X "Installable Versions of ${words[3]}:"$'\n' -- "${${(z)${(M)${(f)${$(__sdkman_list_versions "${words[3]}")//[*+>]+( )/-}}[@]:# *}[@]}[@]:#-*}"
+ fi
+ ;;
+ h|home|u|use|d|default|rm|uninstall)
+ compadd -X "Installed Versions of ${words[3]}:"$'\n' -- "${${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}/${words[3]}" -mindepth 1 -maxdepth 1 -type d -not -name 'current')}[@]:t}"
+ ;;
+ esac
+ ;;
+ 5)
+ case "${words[2]}" in
+ i|install)
+ _files -X "Path to Local Installation of ${words[3]} ${words[4]}:"$'\n' -/
+ ;;
+ esac
+ ;;
+ esac
+}
+
+compdef _sdk sdk
diff --git a/plugins/sfdx/README.md b/plugins/sfdx/README.md
new file mode 100644
index 000000000..259c17fbe
--- /dev/null
+++ b/plugins/sfdx/README.md
@@ -0,0 +1,11 @@
+# sfdx plugin
+
+This plugin provides autocompletion for the [Salesforce DX](https://developer.salesforce.com/tools/sfdxcli) CLI.
+
+To use it, add `sfdx` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... sfdx)
+```
+
+Original repository: https://github.com/wadewegner/salesforce-cli-zsh-completion
diff --git a/plugins/sfdx/_sfdx b/plugins/sfdx/_sfdx
new file mode 100644
index 000000000..42ee55970
--- /dev/null
+++ b/plugins/sfdx/_sfdx
@@ -0,0 +1,1110 @@
+#compdef sfdx
+
+# DESCRIPTION: Zsh completion script for the Salesforce CLI
+# AUTHOR: Wade Wegner (@WadeWegner)
+# REPO: https://github.com/wadewegner/salesforce-cli-zsh-completion
+# LICENSE: https://github.com/wadewegner/salesforce-cli-zsh-completion/blob/master/LICENSE
+
+local -a _1st_arguments
+
+_1st_arguments=(
+ "force\:alias\:list":"list username aliases for the Salesforce CLI"
+ "force\:alias\:set":"set username aliases for the Salesforce CLI"
+ "force\:apex\:class\:create":"create an Apex class"
+ "force\:apex\:execute":"execute anonymous Apex code"
+ "force\:apex\:log\:get":"fetch a debug log"
+ "force\:apex\:log\:list":"list debug logs"
+ "force\:apex\:log\:tail":"start debug logging and display logs"
+ "force\:apex\:test\:report":"display test results"
+ "force\:apex\:test\:run":"invoke Apex tests"
+ "force\:apex\:trigger\:create":"create an Apex trigger"
+ "force\:auth\:jwt\:grant":"authorize an org using the JWT flow"
+ "force\:auth\:logout":"log out from authorized orgs"
+ "force\:auth\:sfdxurl\:store":"authorize an org using an SFDX auth URL"
+ "force\:auth\:web\:login":"authorize an org using the web login flow"
+ "force\:config\:get":"get config var values for given names"
+ "force\:config\:list":"list config vars for the Salesforce CLI"
+ "force\:config\:set":"set config vars for the Salesforce CLI"
+ "force\:data\:bulk\:delete":"bulk delete records from a csv file"
+ "force\:data\:bulk\:status":"view the status of a bulk data load job or batch"
+ "force\:data\:bulk\:upsert":"bulk upsert records from a CSV file"
+ "force\:data\:record\:create":"create a record"
+ "force\:data\:record\:delete":"delete a record"
+ "force\:data\:record\:get":"view a record"
+ "force\:data\:record\:update":"update a record"
+ "force\:data\:soql\:query":"execute a SOQL query"
+ "force\:data\:tree\:export":"export data from an org into sObject tree format for force:data:tree:import consumption"
+ "force\:data\:tree\:import":"import data into an org using SObject Tree Save API"
+ "force\:doc\:commands\:display":"display help for force commands"
+ "force\:doc\:commands\:list":"list the force commands"
+ "force\:lightning\:app\:create":"create a Lightning app"
+ "force\:lightning\:component\:create":"create a bundle for an Aura component or a Lightning web component"
+ "force\:lightning\:event\:create":"create a Lightning event"
+ "force\:lightning\:interface\:create":"create a Lightning interface"
+ "force\:lightning\:lint":"analyse (lint) Lightning component code"
+ "force\:lightning\:test\:create":"create a Lightning test"
+ "force\:lightning\:test\:install":"install Lightning Testing Service unmanaged package in your org"
+ "force\:lightning\:test\:run":"invoke Aura component tests"
+ "force\:limits\:api\:display":"display current org’s limits"
+ "force\:mdapi\:convert":"convert metadata from the Metadata API format into the source format"
+ "force\:mdapi\:deploy":"deploy metadata to an org using Metadata API"
+ "force\:mdapi\:deploy\:cancel":"cancel a metadata deployment"
+ "force\:mdapi\:deploy\:report":"check the status of a metadata deployment"
+ "force\:mdapi\:retrieve":"retrieve metadata from an org using Metadata API"
+ "force\:mdapi\:retrieve\:report":"check the status of a metadata retrieval"
+ "force\:org\:create":"create a scratch org"
+ "force\:org\:delete":"mark a scratch org for deletion"
+ "force\:org\:display":"get org description"
+ "force\:org\:list":"list all orgs you’ve created or authenticated to"
+ "force\:org\:open":"open an org in your browser"
+ "force\:org\:shape\:create":"create a snapshot of org edition, features, and licenses"
+ "force\:org\:shape\:delete":"delete all org shapes for a target org"
+ "force\:org\:shape\:list":"list all org shapes you’ve created"
+ "force\:org\:snapshot\:create":"snapshot a scratch org"
+ "force\:org\:snapshot\:delete":"delete a scratch org snapshot"
+ "force\:org\:snapshot\:get":"get details about a scratch org snapshot"
+ "force\:org\:snapshot\:list":"list scratch org snapshots"
+ "force\:package1\:version\:create":"create a first-generation package version in the release org"
+ "force\:package1\:version\:create\:get":"retrieve the status of a package version creation request"
+ "force\:package1\:version\:display":"display details about a first-generation package version"
+ "force\:package1\:version\:list":"list package versions for the specified first-generation package or for the org"
+ "force\:package\:create":"create a package"
+ "force\:package\:hammertest\:list":"list the statuses of running and completed hammer tests"
+ "force\:package\:hammertest\:report":"display the status or results of a hammer test"
+ "force\:package\:hammertest\:run":"run ISV Hammer"
+ "force\:package\:install":"install a package in the target org"
+ "force\:package\:install\:report":"retrieve the status of a package installation request"
+ "force\:package\:installed\:list":"list the org’s installed packages"
+ "force\:package\:list":"list all packages in the Dev Hub org"
+ "force\:package\:uninstall":"uninstall a second-generation package from the target org"
+ "force\:package\:uninstall\:report":"retrieve status of package uninstall request"
+ "force\:package\:update":"update package details"
+ "force\:package\:version\:create":"create a package version"
+ "force\:package\:version\:create\:list":"list package version creation requests"
+ "force\:package\:version\:create\:report":"retrieve details about a package version creation request"
+ "force\:package\:version\:list":"list all package versions in the Dev Hub org"
+ "force\:package\:version\:promote":"promote a package version to released"
+ "force\:package\:version\:report":"retrieve details about a package version in the Dev Hub org"
+ "force\:package\:version\:update":"update a package version"
+ "force\:project\:create":"create a new SFDX project"
+ "force\:project\:upgrade":"update project config files to the latest format"
+ "force\:schema\:sobject\:describe":"describe an object"
+ "force\:schema\:sobject\:list":"list all objects of a specified category"
+ "force\:source\:convert":"convert source into Metadata API format"
+ "force\:source\:delete":"delete source from your project and from a non-source-tracked org"
+ "force\:source\:deploy":"deploy source to a non-source-tracked org"
+ "force\:source\:open":"edit a Lightning Page with Lightning App Builder"
+ "force\:source\:pull":"pull source from the scratch org to the project"
+ "force\:source\:push":"push source to a scratch org from the project"
+ "force\:source\:retrieve":"retrieve source from a non-source-tracked org"
+ "force\:source\:status":"list local changes and/or changes in a scratch org"
+ "force\:user\:create":"create a user for a scratch org"
+ "force\:user\:display":"displays information about a user of a scratch org"
+ "force\:user\:list":"lists all users of a scratch org"
+ "force\:user\:password\:generate":"generate a password for scratch org users"
+ "force\:user\:permset\:assign":"assign a permission set to one or more users of an org"
+ "force\:visualforce\:component\:create":"create a Visualforce component"
+ "force\:visualforce\:page\:create":"create a Visualforce page"
+)
+
+_arguments '*:: :->command'
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "sfdx command" _1st_arguments
+ return
+fi
+
+local -a _command_args
+case "$words[1]" in
+ force:limits:api:display)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:app:create)
+ _command_args=(
+ '(-n|--appname)'{-n,--appname}'[name of the generated Lightning app]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningApp*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:bulk:delete)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the sObject type of the records you’re deleting]' \
+ '(-f|--csvfile)'{-f,--csvfile}'[the path to the CSV file containing the ids of the records to delete]:file:_files' \
+ '(-w|--wait)'{-w,--wait}'[the number of minutes to wait for the command to complete before displaying the results]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:bulk:status)
+ _command_args=(
+ '(-i|--jobid)'{-i,--jobid}'[the ID of the job you want to view or of the job whose batch you want to view]' \
+ '(-b|--batchid)'{-b,--batchid}'[the ID of the batch whose status you want to view]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:bulk:upsert)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the sObject type of the records you want to upsert]' \
+ '(-f|--csvfile)'{-f,--csvfile}'[the path to the CSV file that defines the records to upsert]:file:_files' \
+ '(-i|--externalid)'{-i,--externalid}'[the column name of the external ID]' \
+ '(-w|--wait)'{-w,--wait}'[the number of minutes to wait for the command to complete before displaying the results]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:class:create)
+ _command_args=(
+ '(-n|--classname)'{-n,--classname}'[name of the generated Apex class]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultApexClass*,ApexException,ApexUnitTest,InboundEmailService)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:doc:commands:display)
+ _command_args=(
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:doc:commands:list)
+ _command_args=(
+ '(-u|--usage)'{-u,--usage}'[list only docopt usage strings]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:visualforce:component:create)
+ _command_args=(
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultVFComponent*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-n|--componentname)'{-n,--componentname}'[name of the generated Visualforce component]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(-l|--label)'{-l,--label}'[Visualforce component label]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:component:create)
+ _command_args=(
+ '(-n|--componentname)'{-n,--componentname}'[name of the generated Lightning component]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningCmp*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(--type)--type[type of the Lightning component (aura*,lwc)]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:mdapi:convert)
+ _command_args=(
+ '(-r|--rootdir)'{-r,--rootdir}'[the root directory containing the Metadata API–formatted metadata]:file:_files' \
+ '(-d|--outputdir)'{-d,--outputdir}'[the output directory to store the source–formatted files]:file:_files' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:source:convert)
+ _command_args=(
+ '(-r|--rootdir)'{-r,--rootdir}'[a source directory other than the default package to convert]:file:_files' \
+ '(-d|--outputdir)'{-d,--outputdir}'[output directory to store the Metadata API–formatted files in]:file:_files' \
+ '(-n|--packagename)'{-n,--packagename}'[name of the package to associate with the metadata-formatted files]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:create)
+ _command_args=(
+ '(-f|--definitionfile)'{-f,--definitionfile}'[path to a scratch org definition file]:file:_files' \
+ '(-j|--definitionjson)'{-j,--definitionjson}'[scratch org definition in json format ]' \
+ '(-n|--nonamespace)'{-n,--nonamespace}'[creates the scratch org with no namespace]' \
+ '(-c|--noancestors)'{-c,--noancestors}'[do not include second-generation package ancestors in the scratch org]' \
+ '(-i|--clientid)'{-i,--clientid}'[connected app consumer key]' \
+ '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the created org as the default username]' \
+ '(-a|--setalias)'{-a,--setalias}'[set an alias for for the created scratch org]' \
+ '(-e|--env)'{-e,--env}'[environment where the scratch org is created: \[sandbox*,virtual,prototype\] (sandbox*,virtual,prototype)]' \
+ '(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \
+ '(-d|--durationdays)'{-d,--durationdays}'[duration of the scratch org (in days) (default:7, min:1, max:30)]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:create)
+ _command_args=(
+ '(-n|--name)'{-n,--name}'[package name]' \
+ '(-t|--packagetype)'{-t,--packagetype}'[package type (Managed,Unlocked)]' \
+ '(-d|--description)'{-d,--description}'[package description]' \
+ '(-e|--nonamespace)'{-e,--nonamespace}'[creates the package with no namespace; available only for unlocked packages.]' \
+ '(-r|--path)'{-r,--path}'[path to directory that contains the contents of the package]:file:_files' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:user:create)
+ _command_args=(
+ '(-f|--definitionfile)'{-f,--definitionfile}'[file path to a user definition]:file:_files' \
+ '(-a|--setalias)'{-a,--setalias}'[set an alias for the created username to reference within the CLI]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:project:create)
+ _command_args=(
+ '(-n|--projectname)'{-n,--projectname}'[name of the generated project]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (Defaultsfdx-project.json*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-l|--loginurl)'{-l,--loginurl}'[Salesforce instance login URL (https://login.salesforce.com*)]' \
+ '(--sourceapiversion)--sourceapiversion[source API version number (45.0*)]' \
+ '(-s|--namespace)'{-s,--namespace}'[project associated namespace]' \
+ '(-p|--defaultpackagedir)'{-p,--defaultpackagedir}'[default package directory name (force-app*)]' \
+ '(-x|--manifest)'{-x,--manifest}'[generate a manifest (package.xml) for change-set-based development]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:delete)
+ _command_args=(
+ '(-p|--noprompt)'{-p,--noprompt}'[no prompt to confirm deletion]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:source:delete)
+ _command_args=(
+ '(-r|--noprompt)'{-r,--noprompt}'[do not prompt for delete confirmation]' \
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \
+ '(-p|--sourcepath)'{-p,--sourcepath}'[comma-separated list of paths to the local metadata to delete]:file:_files' \
+ '(-m|--metadata)'{-m,--metadata}'[comma-separated list of names of metadata components to delete]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:mdapi:deploy)
+ _command_args=(
+ '(-c|--checkonly)'{-c,--checkonly}'[validate deploy but don’t save to the org (default:false)]' \
+ '(-d|--deploydir)'{-d,--deploydir}'[root of directory tree of files to deploy]:file:_files' \
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 0)]' \
+ '(-i|--jobid)'{-i,--jobid}'[(deprecated) job ID of the deployment you want to check; defaults to your most recent CLI deployment if not specified]' \
+ '(-l|--testlevel)'{-l,--testlevel}'[deployment testing level (NoTestRun,RunSpecifiedTests,RunLocalTests,RunAllTestsInOrg)]' \
+ '(-r|--runtests)'{-r,--runtests}'[tests to run if --testlevel RunSpecifiedTests]' \
+ '(-e|--rollbackonerror)'{-e,--rollbackonerror}'[(deprecated) roll back deployment for any failure (default:true)]' \
+ '(-o|--ignoreerrors)'{-o,--ignoreerrors}'[ignore any errors and do not roll back deployment (default:false)]' \
+ '(-g|--ignorewarnings)'{-g,--ignorewarnings}'[whether a warning will allow a deployment to complete successfully (default:false)]' \
+ '(-q|--validateddeployrequestid)'{-q,--validateddeployrequestid}'[request ID of the validated deployment to run a Quick Deploy]' \
+ '(-f|--zipfile)'{-f,--zipfile}'[path to .zip file of metadata to deploy]:file:_files' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[verbose output of deploy results]' \
+ )
+ ;;
+ force:source:deploy)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \
+ '(-m|--metadata)'{-m,--metadata}'[comma-separated list of metadata component names]' \
+ '(-p|--sourcepath)'{-p,--sourcepath}'[comma-separated list of paths to the local source files to deploy]:file:_files' \
+ '(-x|--manifest)'{-x,--manifest}'[file path for manifest (package.xml) of components to deploy]:file:_files' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:mdapi:deploy:cancel)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \
+ '(-i|--jobid)'{-i,--jobid}'[job ID of the deployment you want to cancel; defaults to your most recent CLI deployment if not specified]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:mdapi:deploy:report)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 0)]' \
+ '(-i|--jobid)'{-i,--jobid}'[job ID of the deployment you want to check; defaults to your most recent CLI deployment if not specified]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[verbose output of deploy results]' \
+ )
+ ;;
+ force:org:display)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[emit additional command output to stdout]' \
+ )
+ ;;
+ force:user:display)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:event:create)
+ _command_args=(
+ '(-n|--eventname)'{-n,--eventname}'[name of the generated Lightning event]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningEvt*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:execute)
+ _command_args=(
+ '(-f|--apexcodefile)'{-f,--apexcodefile}'[path to a local file containing Apex code]:file:_files' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:config:get)
+ _command_args=(
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[emit additional command output to stdout]' \
+ )
+ ;;
+ force:package:hammertest:list)
+ _command_args=(
+ '(-i|--packageversionid)'{-i,--packageversionid}'[ID of the package version to list results for]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:hammertest:report)
+ _command_args=(
+ '(-i|--requestid)'{-i,--requestid}'[ID of the hammer request to report on]' \
+ '(-s|--summary)'{-s,--summary}'[report only a results summary (hide Apex test failures)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:hammertest:run)
+ _command_args=(
+ '(-i|--packageversionid)'{-i,--packageversionid}'[ID of the package version to test]' \
+ '(-s|--subscriberorg)'{-s,--subscriberorg}'[comma-separated list of subscriber orgs IDs]' \
+ '(-f|--subscriberfile)'{-f,--subscriberfile}'[file with list of subscriber orgs IDs, one per line]' \
+ '(-d|--scheduledrundatetime)'{-d,--scheduledrundatetime}'[earliest date/time to run the test]' \
+ '(-p|--preview)'{-p,--preview}'[run the package hammer test in the Salesforce preview version]' \
+ '(-t|--apextests)'{-t,--apextests}'[run the apex tests in the subscriber org]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:install)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[number of minutes to wait for installation status]' \
+ '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (default: null)]' \
+ '(-b|--publishwait)'{-b,--publishwait}'[number of minutes to wait for subscriber package version ID to become available in the target org ]' \
+ '(-r|--noprompt)'{-r,--noprompt}'[allow Remote Site Settings and Content Security Policy websites to send or receive data without confirmation]' \
+ '(-p|--package)'{-p,--package}'[ID (starts with 04t) or alias of the package version to install]' \
+ '(-s|--securitytype)'{-s,--securitytype}'[security access type for the installed package (AllUsers,AdminsOnly)]' \
+ '(-t|--upgradetype)'{-t,--upgradetype}'[the upgrade type for the package installation (Mixed*,DeprecateOnly)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:install:report)
+ _command_args=(
+ '(-i|--requestid)'{-i,--requestid}'[ID of the package install request you want to check]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:installed:list)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:interface:create)
+ _command_args=(
+ '(-n|--interfacename)'{-n,--interfacename}'[name of the generated Lightning interface]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningIntf*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:auth:jwt:grant)
+ _command_args=(
+ '(-u|--username)'{-u,--username}'[authentication username]' \
+ '(-f|--jwtkeyfile)'{-f,--jwtkeyfile}'[path to a file containing the private key]:file:_files' \
+ '(-i|--clientid)'{-i,--clientid}'[OAuth client ID (sometimes called the consumer key)]' \
+ '(-r|--instanceurl)'{-r,--instanceurl}'[the login URL of the instance the org lives on]' \
+ '(-d|--setdefaultdevhubusername)'{-d,--setdefaultdevhubusername}'[set the authenticated org as the default dev hub org for scratch org creation]' \
+ '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the authenticated org as the default username that all commands run against]' \
+ '(-a|--setalias)'{-a,--setalias}'[set an alias for the authenticated org]' \
+ '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for auth confirmation in demo mode]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:lint)
+ _command_args=(
+ '(--ignore)--ignore[pattern used to ignore some folders]' \
+ '(--files)--files[pattern used to include specific files]' \
+ '(--json)--json[format output as JSON]' \
+ '(--config)--config[path to a custom ESLint configuration file]' \
+ '(--verbose)--verbose[report warnings in addition to errors]' \
+ '(--exit)--exit[exit with error code 1 if there are lint issues]' \
+ )
+ ;;
+ force:alias:list)
+ _command_args=(
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:config:list)
+ _command_args=(
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:list)
+ _command_args=(
+ '(--all)--all[include expired, deleted, and unknown-status scratch orgs]' \
+ '(--clean)--clean[remove all local org authorizations for non-active orgs]' \
+ '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for confirmation]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[list more information about each org]' \
+ )
+ ;;
+ force:package:list)
+ _command_args=(
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[display extended package detail]' \
+ )
+ ;;
+ force:user:list)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:log:get)
+ _command_args=(
+ '(-c|--color)'{-c,--color}'[colorize noteworthy log lines]' \
+ '(-i|--logid)'{-i,--logid}'[ID of the log to display]' \
+ '(-n|--number)'{-n,--number}'[number of most recent logs to display (min:1, max:25)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:log:list)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:log:tail)
+ _command_args=(
+ '(-c|--color)'{-c,--color}'[colorize noteworthy log lines]' \
+ '(-d|--debuglevel)'{-d,--debuglevel}'[debug level for trace flag]' \
+ '(-s|--skiptraceflag)'{-s,--skiptraceflag}'[skip trace flag setup]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:auth:logout)
+ _command_args=(
+ '(-a|--all)'{-a,--all}'[include all authenticated orgs]' \
+ '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for confirmation]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:open)
+ _command_args=(
+ '(-p|--path)'{-p,--path}'[navigation URL path]' \
+ '(-r|--urlonly)'{-r,--urlonly}'[display navigation URL, but don’t launch browser]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:source:open)
+ _command_args=(
+ '(-f|--sourcefile)'{-f,--sourcefile}'[file to edit]:file:_files' \
+ '(-r|--urlonly)'{-r,--urlonly}'[generate a navigation URL; don’t launch the editor]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:visualforce:page:create)
+ _command_args=(
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultVFPage*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-n|--pagename)'{-n,--pagename}'[name of the generated Visualforce page]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(-l|--label)'{-l,--label}'[Visualforce page label]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:user:password:generate)
+ _command_args=(
+ '(-o|--onbehalfof)'{-o,--onbehalfof}'[comma-separated list of usernames for which to generate passwords]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:user:permset:assign)
+ _command_args=(
+ '(-n|--permsetname)'{-n,--permsetname}'[the name of the permission set to assign]' \
+ '(-o|--onbehalfof)'{-o,--onbehalfof}'[comma-separated list of usernames or aliases to assign the permission set to]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:source:pull)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \
+ '(-f|--forceoverwrite)'{-f,--forceoverwrite}'[ignore conflict warnings and overwrite changes to the project]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:source:push)
+ _command_args=(
+ '(-f|--forceoverwrite)'{-f,--forceoverwrite}'[ignore conflict warnings and overwrite changes to scratch org]' \
+ '(-g|--ignorewarnings)'{-g,--ignorewarnings}'[deploy changes even if warnings are generated]' \
+ '(-r|--replacetokens)'{-r,--replacetokens}'[replace tokens in source files prior to deployment]' \
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:record:create)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re creating]' \
+ '(-v|--values)'{-v,--values}'[the <fieldName>=<value> pairs you’re creating]' \
+ '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[create the record with tooling api]' \
+ '(--perflog)--perflog[get API performance data.]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:record:delete)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re deleting]' \
+ '(-i|--sobjectid)'{-i,--sobjectid}'[the ID of the record you’re deleting]' \
+ '(-w|--where)'{-w,--where}'[a list of <fieldName>=<value> pairs to search for]' \
+ '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[delete the record with Tooling API]' \
+ '(--perflog)--perflog[get API performance data.]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:record:get)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re retrieving]' \
+ '(-i|--sobjectid)'{-i,--sobjectid}'[the ID of the record you’re retrieving]' \
+ '(-w|--where)'{-w,--where}'[a list of <fieldName>=<value> pairs to search for]' \
+ '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[retrieve the record with Tooling API]' \
+ '(--perflog)--perflog[get API performance data.]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:record:update)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the type of the record you’re updating]' \
+ '(-i|--sobjectid)'{-i,--sobjectid}'[the ID of the record you’re updating]' \
+ '(-w|--where)'{-w,--where}'[a list of <fieldName>=<value> pairs to search for]' \
+ '(-v|--values)'{-v,--values}'[the <fieldName>=<value> pairs you’re updating]' \
+ '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[update the record with Tooling API]' \
+ '(--perflog)--perflog[get API performance data.]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:mdapi:retrieve)
+ _command_args=(
+ '(-a|--apiversion)'{-a,--apiversion}'[target API version for the retrieve (default 45.0)]' \
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: -1 (no limit))]' \
+ '(-r|--retrievetargetdir)'{-r,--retrievetargetdir}'[directory root for the retrieved files]:file:_files' \
+ '(-k|--unpackaged)'{-k,--unpackaged}'[file path of manifest of components to retrieve]:file:_files' \
+ '(-d|--sourcedir)'{-d,--sourcedir}'[source dir to use instead of default manifest sfdx-project.xml]:file:_files' \
+ '(-p|--packagenames)'{-p,--packagenames}'[a comma-separated list of packages to retrieve]' \
+ '(-s|--singlepackage)'{-s,--singlepackage}'[a single-package retrieve (default: false)]' \
+ '(-i|--jobid)'{-i,--jobid}'[(deprecated) job ID of the retrieve you want to check; defaults to your most recent CLI retrieval if not specified]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[verbose output of retrieve result]' \
+ )
+ ;;
+ force:source:retrieve)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: 33) (default:33, min:1)]' \
+ '(-x|--manifest)'{-x,--manifest}'[file path for manifest (package.xml) of components to retrieve]:file:_files' \
+ '(-m|--metadata)'{-m,--metadata}'[comma-separated list of metadata component names]' \
+ '(-p|--sourcepath)'{-p,--sourcepath}'[comma-separated list of source file paths to retrieve]:file:_files' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:mdapi:retrieve:report)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[wait time for command to finish in minutes (default: -1 (no limit))]' \
+ '(-r|--retrievetargetdir)'{-r,--retrievetargetdir}'[directory root for the retrieved files]:file:_files' \
+ '(-i|--jobid)'{-i,--jobid}'[job ID of the retrieve you want to check; defaults to your most recent CLI retrieval if not specified]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[verbose output of retrieve result]' \
+ )
+ ;;
+ force:alias:set)
+ _command_args=(
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:config:set)
+ _command_args=(
+ '(-g|--global)'{-g,--global}'[set config var globally (to be used from any directory)]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:auth:sfdxurl:store)
+ _command_args=(
+ '(-f|--sfdxurlfile)'{-f,--sfdxurlfile}'[path to a file containing the sfdx url]:file:_files' \
+ '(-d|--setdefaultdevhubusername)'{-d,--setdefaultdevhubusername}'[set the authenticated org as the default dev hub org for scratch org creation]' \
+ '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the authenticated org as the default username that all commands run against]' \
+ '(-a|--setalias)'{-a,--setalias}'[set an alias for the authenticated org]' \
+ '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for auth confirmation in demo mode]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:shape:create)
+ _command_args=(
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:shape:delete)
+ _command_args=(
+ '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for confirmation]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username for the target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:shape:list)
+ _command_args=(
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[list more information about each org shape]' \
+ )
+ ;;
+ force:org:snapshot:create)
+ _command_args=(
+ '(-o|--sourceorg)'{-o,--sourceorg}'[ID or locally authenticated username or alias of scratch org to snapshot]' \
+ '(-n|--snapshotname)'{-n,--snapshotname}'[unique name of snapshot]' \
+ '(-d|--description)'{-d,--description}'[description of snapshot]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:snapshot:delete)
+ _command_args=(
+ '(-s|--snapshot)'{-s,--snapshot}'[name or ID of snapshot to delete]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:snapshot:get)
+ _command_args=(
+ '(-s|--snapshot)'{-s,--snapshot}'[name or ID of snapshot to retrieve]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:org:snapshot:list)
+ _command_args=(
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:schema:sobject:describe)
+ _command_args=(
+ '(-s|--sobjecttype)'{-s,--sobjecttype}'[the API name of the object to describe]' \
+ '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[execute with Tooling API]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:schema:sobject:list)
+ _command_args=(
+ '(-c|--sobjecttypecategory)'{-c,--sobjecttypecategory}'[the type of objects to list (all|custom|standard)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:soql:query)
+ _command_args=(
+ '(-q|--query)'{-q,--query}'[SOQL query to execute]' \
+ '(-t|--usetoolingapi)'{-t,--usetoolingapi}'[execute query with Tooling API]' \
+ '(-r|--resultformat)'{-r,--resultformat}'[query result format emitted to stdout; --json flag overrides this parameter (human*,csv,json)]' \
+ '(--perflog)--perflog[get API performance data.]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:source:status)
+ _command_args=(
+ '(-a|--all)'{-a,--all}'[list all the changes that have been made]' \
+ '(-l|--local)'{-l,--local}'[list the changes that have been made locally]' \
+ '(-r|--remote)'{-r,--remote}'[list the changes that have been made in the scratch org]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:test:create)
+ _command_args=(
+ '(-n|--testname)'{-n,--testname}'[name of the generated Lightning test]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (DefaultLightningTest*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:lightning:test:install)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[number of minutes to wait for installation status (default:2)]' \
+ '(-r|--releaseversion)'{-r,--releaseversion}'[release version of Lightning Testing Service (default:latest)]' \
+ '(-t|--packagetype)'{-t,--packagetype}'[type of unmanaged package. 'full' option contains both jasmine and mocha, plus examples (full*,jasmine,mocha)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:test:report)
+ _command_args=(
+ '(-i|--testrunid)'{-i,--testrunid}'[ID of test run]' \
+ '(-c|--codecoverage)'{-c,--codecoverage}'[retrieve code coverage results]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[directory to store test run files]:file:_files' \
+ '(-r|--resultformat)'{-r,--resultformat}'[test result format emitted to stdout; --json flag overrides this parameter (human*,tap,junit,json)]' \
+ '(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[display Apex test processing details]' \
+ )
+ ;;
+ force:apex:test:run)
+ _command_args=(
+ '(-n|--classnames)'{-n,--classnames}'[comma-separated list of Apex test class names to run]' \
+ '(-s|--suitenames)'{-s,--suitenames}'[comma-separated list of Apex test suite names to run]' \
+ '(-t|--tests)'{-t,--tests}'[comma-separated list of Apex test class names or IDs and, if applicable, test methods to run]' \
+ '(-c|--codecoverage)'{-c,--codecoverage}'[retrieve code coverage results]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[directory to store test run files]:file:_files' \
+ '(-l|--testlevel)'{-l,--testlevel}'[testlevel enum value (RunLocalTests,RunAllTestsInOrg,RunSpecifiedTests)]' \
+ '(-r|--resultformat)'{-r,--resultformat}'[test result format emitted to stdout; --json flag overrides this parameter (human*,tap,junit,json)]' \
+ '(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \
+ '(--precompilewait)--precompilewait[how long to wait (in minutes) for Apex pre-compilation (default:3, min:3)]' \
+ '(-y|--synchronous)'{-y,--synchronous}'[run tests from a single class synchronously]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[display Apex test processing details]' \
+ )
+ ;;
+ force:lightning:test:run)
+ _command_args=(
+ '(-a|--appname)'{-a,--appname}'[name of your Lightning test application]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[directory path to store test run artifacts: for example, log files and test results]:file:_files' \
+ '(-r|--resultformat)'{-r,--resultformat}'[test result format emitted to stdout; --json flag overrides this parameter (human*,tap,junit,json)]' \
+ '(-f|--configfile)'{-f,--configfile}'[path to config file for the test]:file:_files' \
+ '(-o|--leavebrowseropen)'{-o,--leavebrowseropen}'[leave browser open]' \
+ '(-t|--timeout)'{-t,--timeout}'[time (ms) to wait for results element in dom (default:60000)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:tree:export)
+ _command_args=(
+ '(-q|--query)'{-q,--query}'[soql query, or filepath of file containing a soql query, to retrieve records]' \
+ '(-p|--plan)'{-p,--plan}'[generate mulitple sobject tree files and a plan definition file for aggregated import]' \
+ '(-x|--prefix)'{-x,--prefix}'[prefix of generated files]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[directory to store files]:file:_files' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:data:tree:import)
+ _command_args=(
+ '(-f|--sobjecttreefiles)'{-f,--sobjecttreefiles}'[comma-delimited, ordered paths of json files containing collection of record trees to insert]:file:_files' \
+ '(-p|--plan)'{-p,--plan}'[path to plan to insert multiple data files that have master-detail relationships]:file:_files' \
+ '(-c|--contenttype)'{-c,--contenttype}'[if data file extension is not .json, provide content type (applies to all files)]' \
+ '(--confighelp)--confighelp[display schema information for the --plan configuration file to stdout; if you use this option, all other options except --json are ignored]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:apex:trigger:create)
+ _command_args=(
+ '(-n|--triggername)'{-n,--triggername}'[name of the generated Apex trigger]' \
+ '(-t|--template)'{-t,--template}'[template to use for file creation (ApexTrigger*)]' \
+ '(-d|--outputdir)'{-d,--outputdir}'[folder for saving the created files]' \
+ '(-r|--reflect)'{-r,--reflect}'[switch to return flag detailed information]' \
+ '(-a|--apiversion)'{-a,--apiversion}'[API version number (45.0*,44.0)]' \
+ '(-s|--sobject)'{-s,--sobject}'[sObject to create a trigger on (SOBJECT*)]' \
+ '(-e|--triggerevents)'{-e,--triggerevents}'[events that fire the trigger (before insert*,before update,before delete,after insert,after update,after delete,after undelete)]' \
+ '(--json)--json[JSON output]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:uninstall)
+ _command_args=(
+ '(-w|--wait)'{-w,--wait}'[number of minutes to wait for uninstall status]' \
+ '(-p|--package)'{-p,--package}'[ID (starts with 04t) or alias of the package version to uninstall]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:uninstall:report)
+ _command_args=(
+ '(-i|--requestid)'{-i,--requestid}'[ID of the package uninstall request you want to check]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:update)
+ _command_args=(
+ '(-p|--package)'{-p,--package}'[ID (starts with 0Ho) or alias of the package to update]' \
+ '(-n|--name)'{-n,--name}'[new package name]' \
+ '(-d|--description)'{-d,--description}'[new package description]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:project:upgrade)
+ _command_args=(
+ '(-f|--forceupgrade)'{-f,--forceupgrade}'[run all upgrades even if project has already been upgraded]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:version:create)
+ _command_args=(
+ '(-p|--package)'{-p,--package}'[ID (starts with 0Ho) or alias of the package to create a version of]' \
+ '(-d|--path)'{-d,--path}'[path to directory that contains the contents of the package]:file:_files' \
+ '(-f|--definitionfile)'{-f,--definitionfile}'[path to a definition file similar to scratch org definition file that contains the list of features and org preferences that the metadata of the package version depends on]:file:_files' \
+ '(-b|--branch)'{-b,--branch}'[the package version’s branch]' \
+ '(-t|--tag)'{-t,--tag}'[the package version’s tag]' \
+ '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (either --installationkey or --installationkeybypass is required)]' \
+ '(-x|--installationkeybypass)'{-x,--installationkeybypass}'[bypass the installation key requirement (either --installationkey or --installationkeybypass is required)]' \
+ '(-r|--preserve)'{-r,--preserve}'[temp files are preserved that would otherwise be deleted]' \
+ '(-j|--validateschema)'{-j,--validateschema}'[sfdx-project.json is validated against JSON schema]' \
+ '(-w|--wait)'{-w,--wait}'[minutes to wait for the package version to be created (default:0)]' \
+ '(-s|--buildinstance)'{-s,--buildinstance}'[the instance where the package version will be created——for example, NA50]' \
+ '(-o|--sourceorg)'{-o,--sourceorg}'[the source org ID used to copy the org shape for the build org]' \
+ '(-a|--versionname)'{-a,--versionname}'[the name of the package version to be created]' \
+ '(-n|--versionnumber)'{-n,--versionnumber}'[the version number of the package version to be created]' \
+ '(-e|--versiondescription)'{-e,--versiondescription}'[the description of the package version to be created]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package1:version:create)
+ _command_args=(
+ '(-i|--packageid)'{-i,--packageid}'[ID of the metadata package (starts with 033) of which you’re creating a new version]' \
+ '(-n|--name)'{-n,--name}'[package version name]' \
+ '(-d|--description)'{-d,--description}'[package version description]' \
+ '(-v|--version)'{-v,--version}'[package version in major.minor format, for example, 3.2]' \
+ '(-m|--managedreleased)'{-m,--managedreleased}'[create a managed package version]' \
+ '(-r|--releasenotesurl)'{-r,--releasenotesurl}'[release notes URL]' \
+ '(-p|--postinstallurl)'{-p,--postinstallurl}'[post install URL]' \
+ '(-k|--installationkey)'{-k,--installationkey}'[installation key for key-protected package (default: null)]' \
+ '(-w|--wait)'{-w,--wait}'[minutes to wait for the package version to be created (default: 2 minutes)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package1:version:create:get)
+ _command_args=(
+ '(-i|--requestid)'{-i,--requestid}'[PackageUploadRequest ID]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:version:create:list)
+ _command_args=(
+ '(-c|--createdlastdays)'{-c,--createdlastdays}'[created in the last specified number of days (starting at 00:00:00 of first day to now; 0 for today)]' \
+ '(-s|--status)'{-s,--status}'[filter the list by version creation request status (Queued,InProgress,Success,Error)]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:version:create:report)
+ _command_args=(
+ '(-i|--packagecreaterequestid)'{-i,--packagecreaterequestid}'[package version creation request ID (starts with 08c)]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package1:version:display)
+ _command_args=(
+ '(-i|--packageversionid)'{-i,--packageversionid}'[metadata package version ID (starts with 04t)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:version:list)
+ _command_args=(
+ '(-c|--createdlastdays)'{-c,--createdlastdays}'[created in the last specified number of days (starting at 00:00:00 of first day to now; 0 for today)]' \
+ '(-m|--modifiedlastdays)'{-m,--modifiedlastdays}'[list items modified in the specified last number of days (starting at 00:00:00 of first day to now; 0 for today)]' \
+ '(-p|--packages)'{-p,--packages}'[filter results on specified comma-delimited packages (aliases or 0Ho IDs)]' \
+ '(-r|--released)'{-r,--released}'[display released versions only]' \
+ '(-o|--orderby)'{-o,--orderby}'[order by the specified package version fields]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--concise)--concise[display limited package version details]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[display extended package version details]' \
+ )
+ ;;
+ force:package1:version:list)
+ _command_args=(
+ '(-i|--packageid)'{-i,--packageid}'[metadata package ID (starts with 033)]' \
+ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:version:promote)
+ _command_args=(
+ '(-p|--package)'{-p,--package}'[ID (starts with 04t) or alias of the package version to promote]' \
+ '(-n|--noprompt)'{-n,--noprompt}'[no prompt to confirm setting the package version as released]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:package:version:report)
+ _command_args=(
+ '(-p|--package)'{-p,--package}'[ID (starts with 04t) or alias of the package to retrieve details for]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ '(--verbose)--verbose[displays extended package version details]' \
+ )
+ ;;
+ force:package:version:update)
+ _command_args=(
+ '(-p|--package)'{-p,--package}'[ID (starts with 04t) or alias of the package to update a version of]' \
+ '(-a|--versionname)'{-a,--versionname}'[new package version name]' \
+ '(-e|--versiondescription)'{-e,--versiondescription}'[new package version description]' \
+ '(-b|--branch)'{-b,--branch}'[new package version branch]' \
+ '(-t|--tag)'{-t,--tag}'[new package version tag]' \
+ '(-k|--installationkey)'{-k,--installationkey}'[new installation key for key-protected package (default: null)]' \
+ '(-v|--targetdevhubusername)'{-v,--targetdevhubusername}'[username or alias for the dev hub org; overrides default dev hub org]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ force:auth:web:login)
+ _command_args=(
+ '(-i|--clientid)'{-i,--clientid}'[OAuth client ID (sometimes called the consumer key)]' \
+ '(-r|--instanceurl)'{-r,--instanceurl}'[the login URL of the instance the org lives on]' \
+ '(-d|--setdefaultdevhubusername)'{-d,--setdefaultdevhubusername}'[set the authenticated org as the default dev hub org for scratch org creation]' \
+ '(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the authenticated org as the default username that all commands run against]' \
+ '(-a|--setalias)'{-a,--setalias}'[set an alias for the authenticated org]' \
+ '(--disablemasking)--disablemasking[disable masking of user input (for use with problematic terminals)]' \
+ '(-p|--noprompt)'{-p,--noprompt}'[do not prompt for auth confirmation in demo mode]' \
+ '(--json)--json[format output as json]' \
+ '(--loglevel)--loglevel[logging level for this command invocation (error*,trace,debug,info,warn,fatal)]' \
+ )
+ ;;
+ esac
+
+_arguments \
+ $_command_args \
+ && return 0
diff --git a/plugins/sfffe/README.md b/plugins/sfffe/README.md
new file mode 100644
index 000000000..29044e85b
--- /dev/null
+++ b/plugins/sfffe/README.md
@@ -0,0 +1,17 @@
+# "Search files for Front-End"
+
+This plugin adds a few functions for searching files used in Front-End web development.
+
+To use it, add `sfffe` to the plugins array in your zshrc file:
+```zsh
+plugins=(... sfffe)
+```
+
+**Requires:** `ack`
+
+## Functions
+
+- `ajs`: look for string in `.js` files.
+- `acss`: look for string in `.css` files.
+- `fjs`: search for `.js` files under the current working directory.
+- `fcss`: search for `.css` files under the current working directory.
diff --git a/plugins/sfffe/sfffe.plugin.zsh b/plugins/sfffe/sfffe.plugin.zsh
index a0f034908..177e5fa2f 100644
--- a/plugins/sfffe/sfffe.plugin.zsh
+++ b/plugins/sfffe/sfffe.plugin.zsh
@@ -6,9 +6,9 @@
# REQUIRE: ack
# ------------------------------------------------------------------------------
-if [ ! -x $(which ack) ]; then
- echo \'ack\' is not installed!
- exit -1
+if (( ! $+commands[ack] )); then
+ echo "'ack' is not installed!"
+ return
fi
ajs() {
diff --git a/plugins/shell-proxy/README.md b/plugins/shell-proxy/README.md
new file mode 100644
index 000000000..6f2cd13e0
--- /dev/null
+++ b/plugins/shell-proxy/README.md
@@ -0,0 +1,52 @@
+# Shell Proxy oh-my-zsh plugin
+
+This a pure user-space program, shell-proxy setter, written Python3 and Bash.
+
+100% only no side-effects, only effect **environment variables** and **aliases**
+
+## Key feature
+
+- Support Ubuntu, Archlinux, etc (Linux)
+- Support macOS
+- Support git via based-`$GIT_SSH`
+- Support ssh, sftp, scp, slogin and ssh-copy-id via based-`alias`
+- Built-in Auto-complete
+
+## Usage
+
+Method 1:
+
+`$DEFAULT_PROXY` is the proxy URL you will set
+
+Method 2:
+
+Write a program to `$HOME/.config/proxy` in the file.
+
+Example program:
+
+```bash
+#!/bin/bash
+# The file path: $HOME/.config/proxy
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ echo "http://127.0.0.1:6152" # Surge Mac
+else
+ echo "http://127.0.0.1:8123" # polipo
+fi
+```
+
+Method 3:
+
+The working path of **Method 2** can be changed via `$CONFIG_PROXY`
+
+## Reference
+
+- `$GIT_SSH`: <https://www.git-scm.com/docs/git#Documentation/git.txt-codeGITSSHcode>
+- OpenSSH manual: <https://man.openbsd.org/ssh>
+
+## Maintainer
+
+- <https://github.com/septs>
+
+## The oh-my-zsh plugin (shell-proxy)
+
+Public Domain
diff --git a/plugins/shell-proxy/proxy.py b/plugins/shell-proxy/proxy.py
new file mode 100755
index 000000000..97f4cf873
--- /dev/null
+++ b/plugins/shell-proxy/proxy.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3
+import os
+import sys
+from subprocess import check_output, list2cmdline
+
+cwd = os.path.dirname(__file__)
+ssh_agent = os.path.join(cwd, "ssh-agent.py")
+user_proxy = os.environ.get("CONFIG_PROXY", os.path.expandvars("$HOME/.config/proxy"))
+
+
+def get_http_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")
+
+
+def make_proxies(url: str):
+ proxies = {"%s_PROXY" % _: url for _ in ("HTTP", "HTTPS", "FTP", "RSYNC", "ALL")}
+ proxies.update({name.lower(): value for (name, value) in proxies.items()})
+ proxies["GIT_SSH"] = ssh_agent
+ return proxies
+
+
+def merge(mapping: dict):
+ return ("%s=%s" % _ for _ in mapping.items())
+
+
+class CommandSet:
+ proxies = make_proxies(get_http_proxy())
+ aliases = {
+ _: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent)
+ for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")
+ }
+
+ def enable(self):
+ cmdline("export", *merge(self.proxies))
+ cmdline("alias", *merge(self.aliases))
+
+ def disable(self):
+ cmdline("unset", *self.proxies.keys())
+ cmdline("unalias", *self.aliases.keys())
+
+ def status(self):
+ proxies = (
+ "%11s = %s" % (name, os.environ[name])
+ for name in self.proxies.keys()
+ if name in os.environ
+ )
+ for _ in proxies:
+ cmdline("echo", _)
+
+ def usage(self):
+ cmdline("echo", "usage: proxy {enable,disable,status}")
+ self.status()
+
+
+def cmdline(*items):
+ print(list2cmdline(items))
+
+
+def main():
+ command = CommandSet()
+ if len(sys.argv) == 1:
+ command.usage()
+ sys.exit(-1)
+ getattr(command, sys.argv[1], command.usage)()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/plugins/shell-proxy/shell-proxy.plugin.zsh b/plugins/shell-proxy/shell-proxy.plugin.zsh
new file mode 100644
index 000000000..315ade665
--- /dev/null
+++ b/plugins/shell-proxy/shell-proxy.plugin.zsh
@@ -0,0 +1,16 @@
+#!/usr/bin/bash
+# shellcheck disable=SC1090
+
+__PROXY__="${0:A:h}/proxy.py"
+
+proxy() {
+ source <(env "DEFAULT_PROXY=$DEFAULT_PROXY" "$__PROXY__" "$1")
+}
+
+_proxy() {
+ local -r commands=('enable' 'disable' 'status')
+ compset -P '*,'
+ compadd -S '' "${commands[@]}"
+}
+
+compdef '_proxy' 'proxy'
diff --git a/plugins/shell-proxy/ssh-agent.py b/plugins/shell-proxy/ssh-agent.py
new file mode 100755
index 000000000..4ee24b755
--- /dev/null
+++ b/plugins/shell-proxy/ssh-agent.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+import os
+import subprocess
+import sys
+
+ssh_proxy = os.path.join(os.path.dirname(__file__), "ssh-proxy.py")
+
+argv = [
+ os.environ.get("__SSH_PROGRAM_NAME__", "ssh"),
+ "-o",
+ "ProxyCommand={} %h %p".format(ssh_proxy),
+ "-o",
+ "Compression=yes",
+]
+
+subprocess.call(argv + sys.argv[1:], env=os.environ)
diff --git a/plugins/shell-proxy/ssh-proxy.py b/plugins/shell-proxy/ssh-proxy.py
new file mode 100755
index 000000000..5efd5fd21
--- /dev/null
+++ b/plugins/shell-proxy/ssh-proxy.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import os
+import subprocess
+import sys
+import urllib.parse
+
+proxy = next(os.environ[_] for _ in ("HTTP_PROXY", "HTTPS_PROXY") if _ in os.environ)
+argv = [
+ "nc",
+ "-X",
+ "connect",
+ "-x",
+ urllib.parse.urlparse(proxy).netloc, # proxy-host:proxy-port
+ sys.argv[1], # host
+ sys.argv[2], # port
+]
+
+subprocess.call(argv)
diff --git a/plugins/shrink-path/README.md b/plugins/shrink-path/README.md
index b990aea91..71a242b2c 100644
--- a/plugins/shrink-path/README.md
+++ b/plugins/shrink-path/README.md
@@ -1,61 +1,109 @@
-# 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/
- foo/
- bar/
- quux/
- biz/ # The prefix b is ambiguous between bar and biz.
+/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/ba/q
- -l|--last /h/m/f/ba/quux
- -s|--short /h/m/f/b/q
- -t|--tilde ~/f/ba/q
- -f|--fish ~/f/b/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*
+-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:
```
-f, --fish fish simulation, equivalent to -l -s -t.
+ -g, --glob Add asterisk to allow globbing of shrunk path (equivalent to -e "*")
-l, --last Print the last directory's full name.
- -s, --short Truncate directory names to the first character. Without
+ -s, --short Truncate directory names to the number of characters given by -. Without
-s, names are truncated without making them ambiguous.
-t, --tilde Substitute ~ for the home directory.
-T, --nameddirs Substitute named directories as well.
+ -# Truncate each directly to at least this many characters inclusive of the
+ 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>
+Copyright (C) 2018-2020 by Pavel N. Krivitsky
License: WTFPL <http://www.wtfpl.net>
diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh
index 86102e651..373fd5b05 100644
--- a/plugins/shrink-path/shrink-path.plugin.zsh
+++ b/plugins/shrink-path/shrink-path.plugin.zsh
@@ -9,11 +9,16 @@
# The following options are available:
#
# -f, --fish fish simulation, equivalent to -l -s -t.
+# -g, --glob Add asterisk to allow globbing of shrunk path (equivalent to -e "*")
# -l, --last Print the last directory's full name.
-# -s, --short Truncate directory names to the first character. Without
+# -s, --short Truncate directory names to the number of characters given by -#. Without
# -s, names are truncated without making them ambiguous.
# -t, --tilde Substitute ~ for the home directory.
# -T, --nameddirs Substitute named directories as well.
+# -# Truncate each directly to at least this many characters inclusive of the
+# 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
#
# The long options can also be set via zstyle, like
# zstyle :prompt:shrink_path fish yes
@@ -37,6 +42,10 @@ shrink_path () {
typeset -i short=0
typeset -i tilde=0
typeset -i named=0
+ typeset -i length=1
+ typeset ellipsis=""
+ typeset -i quote=0
+ typeset -i expand=0
if zstyle -t ':prompt:shrink_path' fish; then
lastfull=1
@@ -50,9 +59,16 @@ shrink_path () {
zstyle -t ':prompt:shrink_path' last && lastfull=1
zstyle -t ':prompt:shrink_path' short && short=1
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
+ --)
+ shift
+ break
+ ;;
-f|--fish)
lastfull=1
short=1
@@ -61,10 +77,18 @@ shrink_path () {
-h|--help)
print 'Usage: shrink_path [-f -l -s -t] [directory]'
print ' -f, --fish fish-simulation, like -l -s -t'
+ print ' -g, --glob Add asterisk to allow globbing of shrunk path (equivalent to -e "*")'
print ' -l, --last Print the last directory''s full name'
- print ' -s, --short Truncate directory names to the first character'
+ print ' -s, --short Truncate directory names to the number of characters given by -#. Without'
+ print ' -s, names are truncated without making them ambiguous.'
print ' -t, --tilde Substitute ~ for the home directory'
print ' -T, --nameddirs Substitute named directories as well'
+ print ' -# Truncate each directly to at least this many characters inclusive of the'
+ 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
@@ -76,16 +100,38 @@ shrink_path () {
tilde=1
named=1
;;
+ -[0-9]|-[0-9][0-9])
+ length=${1/-/}
+ ;;
+ -e)
+ shift
+ ellipsis="$1"
+ ;;
+ -g|--glob)
+ ellipsis='*'
+ ;;
+ -q|--quote)
+ quote=1
+ ;;
+ -x|--expand)
+ expand=1
+ ;;
esac
shift
done
+ typeset -i elllen=${#ellipsis}
typeset -a tree expn
typeset result part dir=${1-$PWD}
typeset -i i
[[ -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}
@@ -109,12 +155,22 @@ shrink_path () {
expn=(a b)
part=''
i=0
- until [[ (( ${#expn} == 1 )) || $dir = $expn || $i -gt 99 ]] do
+ until [[ $i -gt 99 || ( $i -ge $((length - ellen)) || $dir == $part ) && ( (( ${#expn} == 1 )) || $dir = $expn ) ]]; do
(( i++ ))
part+=$dir[$i]
expn=($(echo ${part}*(-/)))
- (( short )) && break
+ (( short )) && [[ $i -ge $((length - ellen)) ]] && break
done
+
+ typeset -i dif=$(( ${#dir} - ${#part} - ellen ))
+ if [[ $dif -gt 0 ]]
+ then
+ (( quote )) && part=${(q)part}
+ part+="$ellipsis"
+ else
+ part="$dir"
+ (( quote )) && part=${(q)part}
+ fi
result+="/$part"
cd -q $dir
shift tree
diff --git a/plugins/singlechar/README.md b/plugins/singlechar/README.md
new file mode 100644
index 000000000..d89029900
--- /dev/null
+++ b/plugins/singlechar/README.md
@@ -0,0 +1,118 @@
+# Singlechar plugin
+
+This plugin adds single char shortcuts (and combinations) for some commands.
+
+To use it, add `singlechar` to the plugins array of your zshrc file:
+```
+plugins=(... singlechar)
+```
+
+## Aliases
+
+### CAT, GREP, CURL, WGET
+
+| Alias | Command | Description |
+|-------|------------------|-------------|
+| y | `grep -Ri` | Find case-insensitive string in all files and directories, recursively. Follows symlinks. |
+| n | `grep -Rvi` | Same as above but only show lines that don't match the string. |
+| f | `grep -Rli` | Same as 'y' but only print the filenames where the string is found. |
+| fn | `grep -Rlvi` | Same as above but only show files that don't contain the string. |
+| f. | `find . \| grep` | Grep list of files in current directory |
+| f: | `find` | 'find' command |
+| p | `less` | 'less' command |
+| m | `man` | 'man' command |
+| d | `wget` | 'wget' command |
+| u | `curl` | 'curl' command |
+| c | `cat` | 'cat' command |
+| w | `echo >` | Write arguments to file, overwriting it if it exists. |
+| a | `echo >>` | Write arguments to file, appending them if the file exists. |
+| w: | `cat >` | Write stdin to file, overwriting if it exists. |
+| a: | `cat >>` | Write stdin to file, appending it if the file exists. |
+
+### XARGS
+
+These aliases are versions of the aliases above but using xargs. This can be used
+by piping the arguments to the xargs aliases.
+
+| Alias | Command | Description |
+|-------|----------------------|---------------------------------|
+| x | `xargs` | 'xargs' command |
+| xy | `xargs grep -Ri` | Same as 'y' alias using xargs. |
+| xn | `xargs grep -Rvi` | Same as 'n' alias using xargs. |
+| xf | `xargs grep -Rli` | Same as 'f' alias using xargs. |
+| xfn | `xargs grep -Rlvi` | Same as 'fn' alias using xargs. |
+| xf. | `xargs find \| grep` | Same as 'f.' alias using xargs. |
+| xf: | `xargs find` | Same as 'f:' alias using xargs. |
+| xc | `xargs cat` | Same as 'c' alias using xargs. |
+| xp | `xargs less` | Same as 'p' alias using xargs. |
+| xm | `xargs man` | Same as 'm' alias using xargs. |
+| xd | `xargs wget` | Same as 'd' alias using xargs. |
+| xu | `xargs curl` | Same as 'u' alias using xargs. |
+| xw | `xargs echo >` | Same as 'w' alias using xargs. |
+| xa | `xargs echo >>` | Same as 'a' alias using xargs. |
+| xw: | `xargs cat >` | Same as 'w:' alias using xargs. |
+| xa: | `xargs >>` | Same as 'a:' alias using xargs. |
+
+### SUDO
+
+These aliases are versions of the aliases above in [CAT, GREP, CURL, WGET](#cat-grep-curl-wget)
+but using sudo to run them with root permission.
+
+| Alias | Command | Description |
+|-------|-----------------------|--------------------------------|
+| s | `sudo` | 'sudo' command |
+| sy | `sudo grep -Ri` | Same as 'y' alias using sudo. |
+| sn | `sudo grep -Riv` | Same as 'n' alias using sudo. |
+| sf | `sudo grep -Rli` | Same as 'f' alias using sudo. |
+| sfn | `sudo grep -Rlvi` | Same as 'fn' alias using sudo. |
+| sf. | `sudo find . \| grep` | Same as 'f.' alias using sudo. |
+| sf: | `sudo find` | Same as 'f:' alias using sudo. |
+| sp | `sudo less` | Same as 'p' alias using sudo. |
+| sm | `sudo man` | Same as 'm' alias using sudo. |
+| sd | `sudo wget` | Same as 'd' alias using sudo. |
+| sc | `sudo cat` | Same as 'c' alias using sudo. |
+| sw | `sudo echo >` | Same as 'w' alias using sudo. |
+| sa | `sudo echo >>` | Same as 'a' alias using sudo. |
+| sw: | `sudo cat >` | Same as 'w:' alias using sudo. |
+| sa: | `sudo cat >>` | Same as 'a:' alias using sudo. |
+
+### SUDO-XARGS
+
+Same as above but using both sudo and xargs.
+
+| Alias | Command | Description |
+|-------|---------------------------|---------------------------------|
+| sx | `sudo xargs` | 'sudo xargs' command |
+| sxy | `sudo xargs grep -Ri` | Same as 'xy' alias using sudo. |
+| sxn | `sudo xargs grep -Riv` | Same as 'xn' alias using sudo. |
+| sxf | `sudo xargs grep -li` | Same as 'xf' alias using sudo. |
+| sxfn | `sudo xargs grep -lvi` | Same as 'xfn' alias using sudo. |
+| sxf. | `sudo xargs find \| grep` | Same as 'xf.' alias using sudo. |
+| sxf: | `sudo xargs find` | Same as 'xf:' alias using sudo. |
+| sxp | `sudo xargs less` | Same as 'xp' alias using sudo. |
+| sxm | `sudo xargs man` | Same as 'xm' alias using sudo. |
+| sxd | `sudo xargs wget` | Same as 'xd' alias using sudo. |
+| sxu | `sudo xargs curl` | Same as 'xu' alias using sudo. |
+| sxc | `sudo xargs cat` | Same as 'xc' alias using sudo. |
+| sxw | `sudo xargs echo >` | Same as 'xw' alias using sudo. |
+| sxa | `sudo xargs echo >>` | Same as 'xa' alias using sudo. |
+| sxw: | `sudo xargs cat >` | Same as 'xw:' alias using sudo. |
+| sxa: | `sudo xargs cat >>` | Same as 'xa:' alias using sudo. |
+
+## Options
+
+The commands `grep`, `sudo`, `wget`, `curl`, and `less` can be configured to use other commands
+via the setup variables below, before Oh My Zsh is sourced. If they are not set yet, they will
+use their default values:
+
+| Setup variable | Default value |
+|----------------|---------------|
+| GREP | `grep` |
+| ROOT | `sudo` |
+| WGET | `wget` |
+| CURL | `curl` |
+| PAGER | `less` |
+
+## Author
+
+- [Karolin Varner](https://github.com/koraa)
diff --git a/plugins/singlechar/singlechar.plugin.zsh b/plugins/singlechar/singlechar.plugin.zsh
index 44bd998aa..d4b0b6735 100644
--- a/plugins/singlechar/singlechar.plugin.zsh
+++ b/plugins/singlechar/singlechar.plugin.zsh
@@ -1,13 +1,3 @@
-################################################################################
-# FILE: singlechar.plugin.zsh
-# DESCRIPTION: oh-my-zsh plugin file.
-# AUTHOR: Michael Varner (musikmichael@web.de)
-# VERSION: 1.0.0
-#
-# This plugin adds single char shortcuts (and combinations) for some commands.
-#
-################################################################################
-
###########################
# Settings
@@ -130,4 +120,4 @@ alias sxd='"$ROOT" xargs "$WGET"'
alias sxu='"$ROOT" xargs "$CURL"'
alias sxw:='"$ROOT" xargs cat >'
-alias sxa:='"$ROOT" xargs cat >>' \ No newline at end of file
+alias sxa:='"$ROOT" xargs cat >>'
diff --git a/plugins/sprunge/README.md b/plugins/sprunge/README.md
new file mode 100644
index 000000000..28ed1834a
--- /dev/null
+++ b/plugins/sprunge/README.md
@@ -0,0 +1,32 @@
+# Sprunge plugin
+
+This plugin uploads data and fetch URL from the pastebin http://sprunge.us
+
+To enable it, add 'sprunge' to your plugins:
+
+```zsh
+plugins=(... sprunge)
+```
+
+## Usage
+
+| Command | Description |
+|------------------------------|-------------------------------------------|
+| `sprunge filename.txt` | Uploads filename.txt |
+| `sprunge "this is a string"` | Uploads plain text |
+| `sprunge < filename.txt` | Redirects filename.txt content to sprunge |
+| `echo data \| sprunge` | Any piped data will be uploaded |
+
+Once sprunge has processed the input it will give you a unique HTTP address:
+```
+$ sprunge "hello"
+http://sprunge.us/XxjnKz
+```
+
+## Notes
+
+- Sprunge accepts piped data, stdin redirection, text strings as input or filenames.
+ Only one of these can be used at a time.
+- Argument precedence goes as follows: stdin > piped input > text strings.
+- If a filename is mispelled or doesn't have the necessary path description, it will NOT
+ generate an error, but instead treat it as a text string.
diff --git a/plugins/sprunge/sprunge.plugin.zsh b/plugins/sprunge/sprunge.plugin.zsh
index e1c89b729..5d5687a82 100644
--- a/plugins/sprunge/sprunge.plugin.zsh
+++ b/plugins/sprunge/sprunge.plugin.zsh
@@ -2,12 +2,9 @@
# Created by the blogger at the URL below...I don't know where to find his/her name
# Original found at https://www.shellperson.net/sprunge-pastebin-script/
-usage() {
-description | fmt -s >&2
-}
-
-description() {
-cat << HERE
+sprunge() {
+ if [[ "$1" = --help ]]; then
+ fmt -s >&2 << EOF
DESCRIPTION
Upload data and fetch URL from the pastebin http://sprunge.us
@@ -19,44 +16,41 @@ USAGE
piped_data | $0
NOTES
---------------------------------------------------------------------------
-* INPUT METHODS *
-$0 can accept piped data, STDIN redirection [<filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
-
-* PRECEDENCE *
-STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as an arguments.
-
- EXAMPLE:
- echo piped | "$0" arguments.txt < stdin_redirection.txt
-
-In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded.
-
-* FILENAMES *
-If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it.
---------------------------------------------------------------------------
-
-HERE
-exit
-}
-
-sprunge() {
- if [ -t 0 ]; then
- echo Running interactively, checking for arguments... >&2
- if [ "$*" ]; then
- echo Arguments present... >&2
- if [ -f "$*" ]; then
- echo Uploading the contents of "$*"... >&2
- cat "$*"
- else
- echo Uploading the text: \""$*"\"... >&2
- echo "$*"
- fi | curl -F 'sprunge=<-' http://sprunge.us
- else
- echo No arguments found, printing USAGE and exiting. >&2
- usage
- fi
- else
- echo Using input from a pipe or STDIN redirection... >&2
- curl -F 'sprunge=<-' http://sprunge.us
- fi
+ Input Methods:
+ $0 can accept piped data, STDIN redirection [< filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
+
+ Precedence:
+ STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as arguments. For example:
+
+ echo piped | $0 arguments.txt < stdin_redirection.txt
+
+ In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded.
+
+ Filenames:
+ If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it.
+
+EOF
+ return
+ fi
+
+ if [ -t 0 ]; then
+ echo Running interactively, checking for arguments... >&2
+ if [ "$*" ]; then
+ echo Arguments present... >&2
+ if [ -f "$*" ]; then
+ echo Uploading the contents of "$*"... >&2
+ cat "$*"
+ else
+ echo Uploading the text: \""$*"\"... >&2
+ echo "$*"
+ fi | curl -F 'sprunge=<-' http://sprunge.us
+ else
+ echo No arguments found, printing USAGE and exiting. >&2
+ sprunge --help
+ return 1
+ fi
+ else
+ echo Using input from a pipe or STDIN redirection... >&2
+ curl -F 'sprunge=<-' http://sprunge.us
+ fi
}
diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
index 0b96d9bb5..aa96f9cc9 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,24 @@ 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` style.
+This is particularly usefull when combined with the AddKeysToAgent
+(available from OpenSSH 7.2), since it allows to enter the password only
+on first use.
+
+```zsh
+zstyle :omz:plugins:ssh-agent lazy yes
+```
+
+To **load multiple identities** use the `identities` style. This have no
+effect if `lazy` is enabled.
```zsh
zstyle :omz:plugins:ssh-agent identities 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 +45,24 @@ 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`.
+
## 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 fe4946c6d..494cf1393 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -1,36 +1,80 @@
-typeset _agent_forwarding _ssh_env_cache
+lockdir=/tmp/oh-my-zsh-ssh-agent.lock
+
+while true; do
+ if mkdir "$lockdir" 2>/dev/null
+ then # directory did not exist, but was created successfully
+ trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes
+ break # continue with script
+ else
+ sleep 0.1 # sleep for 0.2 and try again
+ fi
+done
+
+typeset _ssh_env_cache
function _start_agent() {
local lifetime
- local -a identities
-
- # start ssh-agent and setup environment
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
+}
- # load identies
+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
- echo starting ssh-agent...
- ssh-add $HOME/.ssh/${^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
+
+ local args
+ zstyle -a :omz:plugins:ssh-agent ssh-add-args args
+ [[ -n "$not_loaded" ]] && ssh-add "${args[@]}" ${^not_loaded}
}
# Get the filename to store/lookup the environment from
_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
-# 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
+if zstyle -t :omz:plugins:ssh-agent agent-forwarding && [[ -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
+ [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
elif [[ -f "$_ssh_env_cache" ]]; then
# Source SSH settings, if applicable
. $_ssh_env_cache > /dev/null
- if [[ $USER == "root" ]]; then
+ if [[ $USERNAME == "root" ]]; then
FILTER="ax"
else
FILTER="x"
@@ -38,10 +82,16 @@ elif [[ -f "$_ssh_env_cache" ]]; then
ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || {
_start_agent
}
-else
+elif [[ -d $HOME/.ssh ]]; then
_start_agent
fi
+if ! zstyle -t :omz:plugins:ssh-agent lazy; then
+ _add_identities
+fi
+
# tidy up after ourselves
-unset _agent_forwarding _ssh_env_cache
-unfunction _start_agent
+unset _ssh_env_cache
+unfunction _start_agent _add_identities
+
+rm -rf "$lockdir"
diff --git a/plugins/stack/stack.plugin.zsh b/plugins/stack/stack.plugin.zsh
index a149208d0..45ef38761 100644
--- a/plugins/stack/stack.plugin.zsh
+++ b/plugins/stack/stack.plugin.zsh
@@ -1,37 +1,4 @@
-function _stack_commands() {
- local ret=1 state
- _arguments ':subcommand:->subcommand' && ret=0
+(( $+commands[stack] )) || return
- case $state in
- subcommand)
- subcommands=(
- "build:Build the project(s) in this directory/configuration"
- "install:Build executables and install to a user path"
- "test:Build and test the project(s) in this directory/configuration"
- "bench:Build and benchmark the project(s) in this directory/configuration"
- "haddock:Generate haddocks for the project(s) in this directory/configuration"
- "new:Create a brand new project"
- "init:Initialize a stack project based on one or more stack packages"
- "solver:Use a dependency solver to try and determine missing extra-deps"
- "setup:Get the appropriate ghc for your project"
- "path:Print out handy path information"
- "unpack:Unpack one or more packages locally"
- "update:Update the package index"
- "upgrade:Upgrade to the latest stack (experimental)"
- "upload:Upload a package to Hackage"
- "dot:Visualize your project's dependency graph using Graphviz dot"
- "exec:Execute a command"
- "ghc:Run ghc"
- "ghci:Run ghci in the context of project(s)"
- "ide:Run ide-backend-client with the correct arguments"
- "runghc:Run runghc"
- "clean:Clean the local packages"
- "docker:Subcommands specific to Docker use"
- )
- _describe -t subcommands 'stack subcommands' subcommands && ret=0
- esac
-
- return ret
-}
-
-compdef _stack_commands stack
+autoload -U +X bashcompinit && bashcompinit
+source <(stack --bash-completion-script stack)
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/README.md b/plugins/sublime/README.md
index 2ad629fad..22999241f 100644
--- a/plugins/sublime/README.md
+++ b/plugins/sublime/README.md
@@ -1,25 +1,37 @@
-## sublime
+# sublime
-Plugin for Sublime Text, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
+Plugin for [Sublime Text](https://www.sublimetext.com/), a cross platform text and code editor,
+available for Linux, macOS, and Windows.
-### Requirements
+To use the plugin, add `sublime` to the plugins array of your zshrc file:
- * [Sublime Text](https://www.sublimetext.com/)
+```zsh
+plugins=(... sublime)
+```
-### Usage
+Sublime Text has to be installed to use the plugin.
- * If `st` command is called without an argument, launch Sublime Text
+## Usage
- * If `st` is passed a directory, `cd` to it and open it in Sublime Text
+The plugin defines several aliases, such as:
- * If `st` is passed a file, open it in Sublime Text
+- `st`: opens Sublime Text. If passed a file or directory, Sublime Text will open it.
- * If `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text
+- `stt`: open Sublime Text on the current directory.
- * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files.
+- `sst`: if `sudo` is available, `sst` will open Sublime Text with root permissions, so that
+ you can modify any file or directory that you pass it. Useful to edit system files.
- * If `stp` command is called, it find a `.sublime-project` file by traversing up the directory structure. If there is no `.sublime-project` file, but if the current folder is a Git repo, opens up the root directory of the repo. If the current folder is not a Git repo, then opens up the current directory.
+There are also a few functions available:
- * If `stn` command is called without an argument, create a stub `.sublime-project` file in the current working directory if one does not already exist
+- `find_project` (or `stp` alias): if called, the function will search for a `.sublime-project` file
+ on the current directory or its parents, until it finds none.
- * If `stn` is passed a directory, create a stub `.sublime-project` file in it
+ If there is no `.sublime-project` file but the current folder is in a Git repository, it will open
+ Sublime Text on the root directory of the repository.
+
+ If there is no Git repository, it will then open Sublime Text on the current directory.
+
+- `create_project` (or `stn` alias): if called without an argument, create a stub `.sublime-project`
+ file in the current working directory, if one does not already exist. If passed a directory, create
+ a stub `.sublime-project` file in it.
diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
index 485028d9f..618dd8ee8 100644
--- a/plugins/sublime/sublime.plugin.zsh
+++ b/plugins/sublime/sublime.plugin.zsh
@@ -1,121 +1,122 @@
-# Sublime Text Aliases
+# Sublime Text aliases
-() {
+alias st=subl
+alias stt='subl .'
-if [[ "$OSTYPE" == linux* ]]; then
- local _sublime_linux_paths
- _sublime_linux_paths=(
+# Define sst only if sudo exists
+(( $+commands[sudo] )) && alias sst='sudo subl'
+
+alias stp=find_project
+alias stn=create_project
+
+
+# Search for the Sublime Text command if not found
+(( $+commands[subl] )) || {
+ declare -a _sublime_paths
+
+ if [[ "$OSTYPE" == linux* ]]; then
+ if [[ "$(uname -r)" = *icrosoft* ]]; then
+ _sublime_paths=(
+ "$(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)"
+ )
+ else
+ _sublime_paths=(
"$HOME/bin/sublime_text"
"/opt/sublime_text/sublime_text"
"/opt/sublime_text_3/sublime_text"
"/usr/bin/sublime_text"
"/usr/local/bin/sublime_text"
"/usr/bin/subl"
- "/opt/sublime_text_3/sublime_text"
"/usr/bin/subl3"
+ "/snap/bin/subl"
+ "/snap/bin/sublime-text.subl"
+ )
+ fi
+ elif [[ "$OSTYPE" = darwin* ]]; then
+ _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"
)
- for _sublime_path in $_sublime_linux_paths; do
- if [[ -a $_sublime_path ]]; then
- st_run() { $_sublime_path $@ >/dev/null 2>&1 &| }
- st_run_sudo() {sudo $_sublime_path $@ >/dev/null 2>&1}
- alias sst=st_run_sudo
- alias st=st_run
- break
- fi
- done
-elif [[ "$OSTYPE" = darwin* ]]; then
- local _sublime_darwin_paths
- _sublime_darwin_paths=(
- "/usr/local/bin/subl"
- "/Applications/Sublime Text.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 3.app/Contents/SharedSupport/bin/subl"
- "$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
+ elif [[ "$OSTYPE" = cygwin ]]; then
+ _sublime_paths=(
+ "$(cygpath "$ProgramW6432/Sublime Text 2")/subl.exe"
+ "$(cygpath "$ProgramW6432/Sublime Text 3")/subl.exe"
)
- for _sublime_path in $_sublime_darwin_paths; do
- if [[ -a $_sublime_path ]]; then
- subl () { "$_sublime_path" $* }
- alias st=subl
- break
- fi
- done
-elif [[ "$OSTYPE" = 'cygwin' ]]; then
- local _sublime_cygwin_paths
- _sublime_cygwin_paths=(
- "$(cygpath $ProgramW6432/Sublime\ Text\ 2)/sublime_text.exe"
- "$(cygpath $ProgramW6432/Sublime\ Text\ 3)/sublime_text.exe"
+ elif [[ "$OSTYPE" = msys ]]; then
+ _sublime_paths=(
+ "/c/Program Files/Sublime Text 2/subl.exe"
+ "/c/Program Files/Sublime Text 3/subl.exe"
)
- for _sublime_path in $_sublime_cygwin_paths; do
- if [[ -a $_sublime_path ]]; then
- subl () { "$_sublime_path" $* }
- alias st=subl
- break
- fi
- done
-fi
+ fi
-}
+ for _sublime_path in $_sublime_paths; do
+ if [[ -a $_sublime_path ]]; then
+ alias subl="'$_sublime_path'"
+ (( $+commands[sudo] )) && alias sst="sudo '$_sublime_path'"
+ break
+ fi
+ done
-alias stt='st .'
+ unset _sublime_paths _sublime_path
+}
-find_project()
-{
- local PROJECT_ROOT="${PWD}"
- local FINAL_DEST="."
+function find_project() {
+ local PROJECT_ROOT="${PWD}"
+ local FINAL_DEST="."
- while [[ $PROJECT_ROOT != "/" && ! -d "$PROJECT_ROOT/.git" ]]; do
- PROJECT_ROOT=$(dirname $PROJECT_ROOT)
- done
+ while [[ $PROJECT_ROOT != "/" && ! -d "$PROJECT_ROOT/.git" ]]; do
+ PROJECT_ROOT=$(dirname $PROJECT_ROOT)
+ done
- if [[ $PROJECT_ROOT != "/" ]]; then
- local PROJECT_NAME="${PROJECT_ROOT##*/}"
+ if [[ $PROJECT_ROOT != "/" ]]; then
+ local PROJECT_NAME="${PROJECT_ROOT##*/}"
- local SUBL_DIR=$PROJECT_ROOT
- while [[ $SUBL_DIR != "/" && ! -f "$SUBL_DIR/$PROJECT_NAME.sublime-project" ]]; do
- SUBL_DIR=$(dirname $SUBL_DIR)
- done
+ local SUBL_DIR=$PROJECT_ROOT
+ while [[ $SUBL_DIR != "/" && ! -f "$SUBL_DIR/$PROJECT_NAME.sublime-project" ]]; do
+ SUBL_DIR=$(dirname $SUBL_DIR)
+ done
- if [[ $SUBL_DIR != "/" ]]; then
- FINAL_DEST="$SUBL_DIR/$PROJECT_NAME.sublime-project"
- else
- FINAL_DEST=$PROJECT_ROOT
- fi
+ if [[ $SUBL_DIR != "/" ]]; then
+ FINAL_DEST="$SUBL_DIR/$PROJECT_NAME.sublime-project"
+ else
+ FINAL_DEST=$PROJECT_ROOT
fi
+ fi
- st $FINAL_DEST
+ subl $FINAL_DEST
}
function create_project() {
-
- local _target=$1
-
- if [[ "${_target}" == "" ]]; then
- _target=$(pwd);
- elif [[ ! -d ${_target} ]]; then
- echo "${_target} is not a valid directory"
- return 1
- fi
-
- local _sublime_project_file=$_target/$(basename $_target).sublime-project
-
- if [[ ! -f $_sublime_project_file ]]; then
-
- touch $_sublime_project_file
-
- echo -e "{" >> $_sublime_project_file
- echo -e "\t\"folders\":" >> $_sublime_project_file
- echo -e "\t\t[{" >> $_sublime_project_file
- echo -e "\t\t\t\"path\": \".\"," >> $_sublime_project_file
- echo -e "\t\t\t\"file_exclude_patterns\": []" >> $_sublime_project_file
- echo -e "\t\t}]" >> $_sublime_project_file
- echo -e "}" >> $_sublime_project_file
-
- echo -e "New Sublime Text project created:\n\t${_sublime_project_file}"
-
- fi
+ local _target=$1
+
+ if [[ "${_target}" == "" ]]; then
+ _target=$(pwd);
+ elif [[ ! -d ${_target} ]]; then
+ echo "${_target} is not a valid directory"
+ return 1
+ fi
+
+ local _sublime_project_file=$_target/$(basename $_target).sublime-project
+
+ if [[ ! -f $_sublime_project_file ]]; then
+ touch $_sublime_project_file
+
+ echo -e "{" >> $_sublime_project_file
+ echo -e "\t\"folders\":" >> $_sublime_project_file
+ echo -e "\t\t[{" >> $_sublime_project_file
+ echo -e "\t\t\t\"path\": \".\"," >> $_sublime_project_file
+ echo -e "\t\t\t\"file_exclude_patterns\": []" >> $_sublime_project_file
+ echo -e "\t\t}]" >> $_sublime_project_file
+ echo -e "}" >> $_sublime_project_file
+
+ echo -e "New Sublime Text project created:\n\t${_sublime_project_file}"
+ fi
}
-
-alias stp=find_project
-alias stn=create_project
diff --git a/plugins/sudo/README.md b/plugins/sudo/README.md
index ebfdfd10d..4f3973ef8 100644
--- a/plugins/sudo/README.md
+++ b/plugins/sudo/README.md
@@ -2,25 +2,13 @@
Easily prefix your current or previous commands with `sudo` by pressing <kbd>esc</kbd> twice
-## Enabling the plugin
+To use it, add `sudo` to the plugins array in your zshrc file:
-1. Open your `.zshrc` file and add `sudo` in the plugins section:
-
- ```zsh
- plugins=(
- # all your enabled plugins
- sudo
- )
- ```
-
-2. Reload the source file or restart your Terminal session:
-
- ```console
- $ source ~/.zshrc
- $
- ```
+```zsh
+plugins=(... sudo)
+```
-## Usage examples
+## Usage
### Current typed commands
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index 0b843822e..f2445a762 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -9,23 +9,59 @@
# -------
#
# * 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"
+ [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
+
+ # Save beginning space
+ local WHITESPACE=""
+ if [[ ${LBUFFER:0:1} = " " ]]; then
+ WHITESPACE=" "
+ LBUFFER="${LBUFFER:1}"
+ fi
+
+ # Get the first part of the typed command and check if it's an alias to $EDITOR
+ # If so, locally change $EDITOR to the alias so that it matches below
+ if [[ -n "$EDITOR" ]]; then
+ local cmd="${${(Az)BUFFER}[1]}"
+ if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
+ local EDITOR="$cmd"
+ fi
+ fi
+
+ if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
+ __sudo-replace-buffer "$EDITOR" "sudoedit"
+ elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
+ __sudo-replace-buffer "\$EDITOR" "sudoedit"
+ elif [[ $BUFFER = sudoedit\ * ]]; then
+ __sudo-replace-buffer "sudoedit" "$EDITOR"
+ elif [[ $BUFFER = sudo\ * ]]; then
+ __sudo-replace-buffer "sudo" ""
else
LBUFFER="sudo $LBUFFER"
fi
+
+ # Preserve beginning space
+ LBUFFER="${WHITESPACE}${LBUFFER}"
}
+
zle -N sudo-command-line
+
# Defined shortcut keys: [Esc] [Esc]
-bindkey "\e\e" sudo-command-line
+bindkey -M emacs '\e\e' sudo-command-line
+bindkey -M vicmd '\e\e' sudo-command-line
+bindkey -M viins '\e\e' sudo-command-line
diff --git a/plugins/supervisor/README.md b/plugins/supervisor/README.md
new file mode 100644
index 000000000..a060ff483
--- /dev/null
+++ b/plugins/supervisor/README.md
@@ -0,0 +1,13 @@
+# supervisor plugin
+
+This plugin adds tab-completion for `supervisord`/`supervisorctl` in [Supervisor](http://supervisord.org/).
+Supervisor is a client/server system that allows its users to monitor and control a number
+of processes on UNIX-like operating systems.
+
+To use it, add `supervisor` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... supervisor)
+```
+
+These scripts are from [zshcompfunc4supervisor](https://bitbucket.org/hhatto/zshcompfunc4supervisor).
diff --git a/plugins/supervisor/_supervisorctl b/plugins/supervisor/_supervisorctl
index d159f20e0..9f576c0c0 100644
--- a/plugins/supervisor/_supervisorctl
+++ b/plugins/supervisor/_supervisorctl
@@ -112,6 +112,13 @@ _supervisorctl_start() {
'*::supvervisor process:_get_supervisor_procs'
}
+(( $+functions[_supervisorctl_restart] )) ||
+_supervisorctl_restart() {
+ # TODO: add 'all'
+ _arguments -s \
+ '*::supvervisor process:_get_supervisor_procs'
+}
+
(( $+functions[_supervisorctl_status] )) ||
_supervisorctl_status() {
_arguments \
diff --git a/plugins/suse/README.md b/plugins/suse/README.md
index 0e8a7f7ba..b9b069574 100644
--- a/plugins/suse/README.md
+++ b/plugins/suse/README.md
@@ -15,14 +15,14 @@ plugins=(... suse)
| Alias | Commands | Description |
| ---------------- | ----------------------------- | -------------------------------------------------------------- |
| z | `sudo zypper` | call zypper |
-| zh | `sudo zypper -h` | print help |
-| zhse | `sudo zypper -h se` | print help for the search command |
-| zlicenses | `sudo zypper licenses` | prints a report about licenses and EULAs of installed packages |
+| zh | `zypper -h` | print help |
+| zhse | `zypper -h se` | print help for the search command |
+| zlicenses | `zypper licenses` | prints a report about licenses and EULAs of installed packages |
| zps | `sudo zypper ps` | list process using deleted files |
| zshell | `sudo zypper shell` | open a zypper shell session |
| zsource-download | `sudo zypper source-download` | download source rpms for all installed packages |
-| ztos | `sudo zypper tos` | shows the ID string of the target operating system |
-| zvcmp | `sudo zypper vcmp` | tell whether version1 is older or newer than version2 |
+| ztos | `zypper tos` | shows the ID string of the target operating system |
+| zvcmp | `zypper vcmp` | tell whether version1 is older or newer than version2 |
## Packages commands
@@ -39,8 +39,8 @@ plugins=(... suse)
| Alias | Commands | Description |
| ------ | ------------------- | ---------------------- |
| zdup | `sudo zypper dup` | upgrade packages |
-| zlp | `sudo zypper lp` | list necessary patches |
-| zlu | `sudo zypper lu` | list updates |
+| zlp | `zypper lp` | list necessary patches |
+| zlu | `zypper lu` | list updates |
| zpchk | `sudo zypper pchk` | check for patches |
| zup | `sudo zypper up` | update packages |
| zpatch | `sudo zypper patch` | install patches |
@@ -49,16 +49,16 @@ plugins=(... suse)
| Alias | Commands | Description |
| ------------- | -------------------------- | ---------------------------------------------------- |
-| zif | `sudo zypper if` | display info about packages |
-| zpa | `sudo zypper pa` | list packages |
-| zpatch-info | `sudo zypper patch-info` | display info about patches |
-| zpattern-info | `sudo zypper pattern-info` | display info about patterns |
-| zproduct-info | `sudo zypper product-info` | display info about products |
-| zpch | `sudo zypper pch` | list all patches |
-| zpd | `sudo zypper pd` | list products |
-| zpt | `sudo zypper pt` | list patterns |
-| zse | `sudo zypper se` | search for packages |
-| zwp | `sudo zypper wp` | list all packages providing the specified capability |
+| zif | `zypper if` | display info about packages |
+| zpa | `zypper pa` | list packages |
+| zpatch-info | `zypper patch-info` | display info about patches |
+| zpattern-info | `zypper pattern-info` | display info about patterns |
+| zproduct-info | `zypper product-info` | display info about products |
+| zpch | `zypper pch` | list all patches |
+| zpd | `zypper pd` | list products |
+| zpt | `zypper pt` | list patterns |
+| zse | `zypper se` | search for packages |
+| zwp | `zypper wp` | list all packages providing the specified capability |
## Repositories commands
@@ -66,7 +66,7 @@ plugins=(... suse)
| ----- | ------------------- | ---------------------------------------- |
| zar | `sudo zypper ar` | add a repository |
| zcl | `sudo zypper clean` | clean cache |
-| zlr | `sudo zypper lr` | list repositories |
+| zlr | `zypper lr` | list repositories |
| zmr | `sudo zypper mr` | modify repositories |
| znr | `sudo zypper nr` | rename repositories (for the alias only) |
| zref | `sudo zypper ref` | refresh repositories |
@@ -79,12 +79,12 @@ plugins=(... suse)
| zms | `sudo zypper ms` | modify properties of specified services |
| zrefs | `sudo zypper refs` | refreshing a service mean executing the service's special task |
| zrs | `sudo zypper rs` | remove specified repository index service from the system |
-| zls | `sudo zypper ls` | list services defined on the system |
+| zls | `zypper ls` | list services defined on the system |
## Package Locks Management commands
| Alias | Commands | Description |
| ----- | ---------------- | ----------------------------------- |
| zal | `sudo zypper al` | add a package lock |
| zcl | `sudo zypper cl` | remove unused locks |
-| zll | `sudo zypper ll` | list currently active package locks |
+| zll | `zypper ll` | list currently active package locks |
| zrl | `sudo zypper rl` | remove specified package lock |
diff --git a/plugins/suse/suse.plugin.zsh b/plugins/suse/suse.plugin.zsh
index 60f7042eb..dcfeccb03 100644
--- a/plugins/suse/suse.plugin.zsh
+++ b/plugins/suse/suse.plugin.zsh
@@ -1,13 +1,13 @@
#Main commands
alias z='sudo zypper'
-alias zh='sudo zypper -h'
-alias zhse='sudo zypper -h se'
-alias zlicenses='sudo zypper licenses'
+alias zh='zypper -h'
+alias zhse='zypper -h se'
+alias zlicenses='zypper licenses'
alias zps='sudo zypper ps'
alias zshell='sudo zypper shell'
alias zsource-download='sudo zypper source-download'
-alias ztos='sudo zypper tos'
-alias zvcmp='sudo zypper vcmp'
+alias ztos='zypper tos'
+alias zvcmp='zypper vcmp'
#Packages commands
alias zin='sudo zypper in'
@@ -18,28 +18,28 @@ alias zve='sudo zypper ve'
#Updates commands
alias zdup='sudo zypper dup'
-alias zlp='sudo zypper lp'
-alias zlu='sudo zypper lu'
+alias zlp='zypper lp'
+alias zlu='zypper lu'
alias zpchk='sudo zypper pchk'
alias zup='sudo zypper up'
alias zpatch='sudo zypper patch'
#Request commands
-alias zif='sudo zypper if'
-alias zpa='sudo zypper pa'
-alias zpatch-info='sudo zypper patch-info'
-alias zpattern-info='sudo zypper pattern-info'
-alias zproduct-info='sudo zypper product-info'
-alias zpch='sudo zypper pch'
-alias zpd='sudo zypper pd'
-alias zpt='sudo zypper pt'
-alias zse='sudo zypper se'
-alias zwp='sudo zypper wp'
+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'
#Repositories commands
alias zar='sudo zypper ar'
alias zcl='sudo zypper clean'
-alias zlr='sudo zypper lr'
+alias zlr='zypper lr'
alias zmr='sudo zypper mr'
alias znr='sudo zypper nr'
alias zref='sudo zypper ref'
@@ -50,10 +50,10 @@ alias zas='sudo zypper as'
alias zms='sudo zypper ms'
alias zrefs='sudo zypper refs'
alias zrs='sudo zypper rs'
-alias zls='sudo zypper ls'
+alias zls='zypper ls'
#Package Locks Management commands
alias zal='sudo zypper al'
alias zcl='sudo zypper cl'
-alias zll='sudo zypper ll'
+alias zll='zypper ll'
alias zrl='sudo zypper rl'
diff --git a/plugins/svcat/README.md b/plugins/svcat/README.md
new file mode 100644
index 000000000..0bc60b117
--- /dev/null
+++ b/plugins/svcat/README.md
@@ -0,0 +1,9 @@
+# svcat
+
+This plugin provides completion for the [Kubernetes service catalog cli](https://github.com/kubernetes-incubator/service-catalog).
+
+To use it, add `svcat` to the plugins array in your zshrc file.
+
+```
+plugins=(... svcat)
+```
diff --git a/plugins/svcat/svcat.plugin.zsh b/plugins/svcat/svcat.plugin.zsh
new file mode 100644
index 000000000..f90e7d8d6
--- /dev/null
+++ b/plugins/svcat/svcat.plugin.zsh
@@ -0,0 +1,6 @@
+# Autocompletion for svcat.
+#
+
+if [ $commands[svcat] ]; then
+ source <(svcat completion zsh)
+fi
diff --git a/plugins/svn-fast-info/README.md b/plugins/svn-fast-info/README.md
new file mode 100644
index 000000000..771378254
--- /dev/null
+++ b/plugins/svn-fast-info/README.md
@@ -0,0 +1,56 @@
+# svn-fast-info plugin
+
+Faster alternative to the main SVN plugin implementation. Works with svn 1.6 and newer.
+Use as a drop-in replacement to the svn plugin, not as complementary.
+
+To use it, add `svn-fast-info` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... svn-fast-info)
+```
+
+It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
+It displays the current status of the local files (added, deleted, modified, replaced, or else...)
+
+Use `svn_prompt_info` method to display the svn repository status in your theme.
+
+## Functions
+
+- `svn_prompt_info`: displays all the available information regarding the status of the svn repository.
+
+- `svn_repo_need_upgrade`: shows whether the repository needs upgrading. `svn_prompt_info` queries the
+ rest of functions or not based on the result of this function.
+
+- `svn_current_branch_name`: shows the current branch.
+
+- `svn_repo_root_name`: displays the repository root.
+
+- `svn_current_revision`: shows the currently checked-out revision.
+
+- `svn_status_info`: shows a bunch of symbols depending on the status of the files in the repository.
+
+## Options
+
+- `ZSH_THEME_SVN_PROMPT_PREFIX`: sequence displayed at the beginning of the prompt info output.
+
+- `ZSH_THEME_SVN_PROMPT_SUFFIX`: sequence displayed at the end of the prompt info output.
+
+- `ZSH_THEME_SVN_PROMPT_CLEAN`: sequence displayed when the status of the repository is clean.
+
+- `ZSH_THEME_SVN_PROMPT_ADDITIONS`: sequence displayed if there are added files in the repository.
+ **Default:** `+`.
+
+- `ZSH_THEME_SVN_PROMPT_DELETIONS`: sequence displayed if there are deleted files in the repository.
+ **Default:** `✖`.
+
+- `ZSH_THEME_SVN_PROMPT_MODIFICATIONS`: sequence displayed if there are modified files in the repository.
+ **Default:** `✎`.
+
+- `ZSH_THEME_SVN_PROMPT_REPLACEMENTS`: sequence displayed if there are replaced files in the repository.
+ **Default:** `∿`.
+
+- `ZSH_THEME_SVN_PROMPT_UNTRACKED`: sequence displayed if there are untracked files in the repository.
+ **Default:** `?`.
+
+- `ZSH_THEME_SVN_PROMPT_DIRTY`: sequence displayed if the repository is dirty.
+ **Default:** `!`.
diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
index 9ea7f641d..f40a59685 100644
--- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh
+++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
@@ -1,50 +1,37 @@
-# vim:ft=zsh ts=2 sw=2 sts=2 et
-#
-# Faster alternative to the current SVN plugin implementation.
-#
-# Works with svn 1.6, 1.7, 1.8.
-# Use `svn_prompt_info` method to enquire the svn data.
-# It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
-# It displays the current status of the local files (added, deleted, modified, replaced, or else...)
-#
-# Use as a drop-in replacement of the svn plugin not as complementary plugin
-
function svn_prompt_info() {
local info
- info=$(svn info 2>&1) || return 1; # capture stdout and stderr
+ info=$(svn info 2>&1) || return 1 # capture stdout and stderr
local repo_need_upgrade=$(svn_repo_need_upgrade $info)
if [[ -n $repo_need_upgrade ]]; then
printf '%s%s%s%s%s%s%s\n' \
- $ZSH_PROMPT_BASE_COLOR \
- $ZSH_THEME_SVN_PROMPT_PREFIX \
- $ZSH_PROMPT_BASE_COLOR \
- $repo_need_upgrade \
- $ZSH_PROMPT_BASE_COLOR \
- $ZSH_THEME_SVN_PROMPT_SUFFIX \
- $ZSH_PROMPT_BASE_COLOR
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$ZSH_THEME_SVN_PROMPT_PREFIX" \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$repo_need_upgrade" \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
+ "$ZSH_PROMPT_BASE_COLOR"
else
- printf '%s%s%s %s%s:%s%s%s%s%s' \
- $ZSH_PROMPT_BASE_COLOR \
- $ZSH_THEME_SVN_PROMPT_PREFIX \
- \
+ printf '%s%s%s%s %s%s%s:%s%s%s%s' \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$ZSH_THEME_SVN_PROMPT_PREFIX" \
"$(svn_status_info $info)" \
- $ZSH_PROMPT_BASE_COLOR \
- \
- $ZSH_THEME_BRANCH_NAME_COLOR \
- $(svn_current_branch_name $info) \
- $ZSH_PROMPT_BASE_COLOR \
+ "$ZSH_PROMPT_BASE_COLOR" \
\
- $(svn_current_revision $info) \
- $ZSH_PROMPT_BASE_COLOR \
+ "$ZSH_THEME_BRANCH_NAME_COLOR" \
+ "$(svn_current_branch_name $info)" \
+ "$ZSH_PROMPT_BASE_COLOR" \
\
- $ZSH_THEME_SVN_PROMPT_SUFFIX \
- $ZSH_PROMPT_BASE_COLOR
+ "$(svn_current_revision $info)" \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
+ "$ZSH_PROMPT_BASE_COLOR"
fi
}
function svn_repo_need_upgrade() {
- grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \
+ grep -q "E155036" <<< "${1:-$(svn info 2> /dev/null)}" && \
echo "E155036: upgrade repo with svn upgrade"
}
@@ -63,11 +50,23 @@ function svn_current_revision() {
function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
local svn_status="$(svn status 2> /dev/null)";
- if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
- if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi
- if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi
- if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi
- if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
- if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi
+ if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then
+ svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"
+ fi
+ if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then
+ svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"
+ fi
+ if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then
+ svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"
+ fi
+ if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then
+ svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"
+ fi
+ if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then
+ svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"
+ fi
+ if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then
+ svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"
+ fi
echo $svn_status_string
}
diff --git a/plugins/swiftpm/README.md b/plugins/swiftpm/README.md
index 07ca25651..a722c03e4 100644
--- a/plugins/swiftpm/README.md
+++ b/plugins/swiftpm/README.md
@@ -2,7 +2,7 @@
## Description
-This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager).
+This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.1.
To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`:
diff --git a/plugins/swiftpm/_swift b/plugins/swiftpm/_swift
index bed6e13a7..fe6f1c9aa 100644
--- a/plugins/swiftpm/_swift
+++ b/plugins/swiftpm/_swift
@@ -72,16 +72,25 @@ _swift_build() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
- "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}"
+ "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
+ "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]"
+ "--force-resolved-versions[]"
+ "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
+ "--enable-index-store[Enable indexing-while-building feature]"
+ "--disable-index-store[Disable indexing-while-building feature]"
+ "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
+ "--enable-parseable-module-interfaces[]"
+ "--trace-resolver[]"
+ "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
+ "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--build-tests[Build both source and test targets]"
"--product[Build the specified product]:Build the specified product: "
"--target[Build the specified target]:Build the specified target: "
@@ -108,17 +117,28 @@ _swift_run() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
- "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}"
+ "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
+ "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]"
+ "--force-resolved-versions[]"
+ "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
+ "--enable-index-store[Enable indexing-while-building feature]"
+ "--disable-index-store[Disable indexing-while-building feature]"
+ "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
+ "--enable-parseable-module-interfaces[]"
+ "--trace-resolver[]"
+ "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
+ "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the executable product]"
+ "--build-tests[Build both source and test targets]"
+ "--repl[Launch Swift REPL for the package]"
)
_arguments $arguments && return
}
@@ -140,16 +160,25 @@ _swift_package() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
- "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}"
+ "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
+ "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]"
+ "--force-resolved-versions[]"
+ "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
+ "--enable-index-store[Enable indexing-while-building feature]"
+ "--disable-index-store[Disable indexing-while-building feature]"
+ "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
+ "--enable-parseable-module-interfaces[]"
+ "--trace-resolver[]"
+ "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
+ "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
'(-): :->command'
'(-)*:: :->arg'
)
@@ -158,33 +187,28 @@ _swift_package() {
(command)
local modes
modes=(
- 'edit:Put a package in editable mode'
- 'clean:Delete build artifacts'
- 'init:Initialize a new package'
+ 'completion-tool:Completion tool (for shell completions)'
'dump-package:Print parsed Package.swift as JSON'
'describe:Describe the current package'
+ 'clean:Delete build artifacts'
+ 'show-dependencies:Print the resolved dependency graph'
+ 'init:Initialize a new package'
'unedit:Remove a package from editable mode'
- 'update:Update package dependencies'
- 'completion-tool:Completion tool (for shell completions)'
'tools-version:Manipulate tools version of the current package'
- 'reset:Reset the complete cache/build directory'
+ 'fetch:'
'resolve:Resolve package dependencies'
+ 'reset:Reset the complete cache/build directory'
'generate-xcodeproj:Generates an Xcode project'
- 'fetch:'
- 'show-dependencies:Print the resolved dependency graph'
+ 'edit:Put a package in editable mode'
+ 'config:Manipulate configuration of the package'
+ 'update:Update package dependencies'
)
_describe "mode" modes
;;
(arg)
case ${words[1]} in
- (edit)
- _swift_package_edit
- ;;
- (clean)
- _swift_package_clean
- ;;
- (init)
- _swift_package_init
+ (completion-tool)
+ _swift_package_completion-tool
;;
(dump-package)
_swift_package_dump-package
@@ -192,91 +216,92 @@ _swift_package() {
(describe)
_swift_package_describe
;;
- (unedit)
- _swift_package_unedit
+ (clean)
+ _swift_package_clean
;;
- (update)
- _swift_package_update
+ (show-dependencies)
+ _swift_package_show-dependencies
;;
- (completion-tool)
- _swift_package_completion-tool
+ (init)
+ _swift_package_init
+ ;;
+ (unedit)
+ _swift_package_unedit
;;
(tools-version)
_swift_package_tools-version
;;
- (reset)
- _swift_package_reset
+ (fetch)
+ _swift_package_fetch
;;
(resolve)
_swift_package_resolve
;;
+ (reset)
+ _swift_package_reset
+ ;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;;
- (fetch)
- _swift_package_fetch
+ (edit)
+ _swift_package_edit
;;
- (show-dependencies)
- _swift_package_show-dependencies
+ (config)
+ _swift_package_config
+ ;;
+ (update)
+ _swift_package_update
;;
esac
;;
esac
}
-_swift_package_edit() {
- arguments=(
- ":The name of the package to edit:_swift_dependency"
- "--revision[The revision to edit]:The revision to edit: "
- "--branch[The branch to create]:The branch to create: "
- "--path[Create or use the checkout at this path]:Create or use the checkout at this path:_files"
- )
- _arguments $arguments && return
-}
-
-_swift_package_clean() {
+_swift_package_completion-tool() {
arguments=(
+ ": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
)
_arguments $arguments && return
}
-_swift_package_init() {
+_swift_package_dump-package() {
arguments=(
- "--type[empty|library|executable|system-module]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
)
_arguments $arguments && return
}
-_swift_package_dump-package() {
+_swift_package_describe() {
arguments=(
+ "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
)
_arguments $arguments && return
}
-_swift_package_describe() {
+_swift_package_clean() {
arguments=(
- "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
)
_arguments $arguments && return
}
-_swift_package_unedit() {
+_swift_package_show-dependencies() {
arguments=(
- ":The name of the package to unedit:_swift_dependency"
- "--force[Unedit the package even if it has uncommited and unpushed changes.]"
+ "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
)
_arguments $arguments && return
}
-_swift_package_update() {
+_swift_package_init() {
arguments=(
+ "--type[empty|library|executable|system-module|manifest]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
+ "--name[Provide custom package name]:Provide custom package name: "
)
_arguments $arguments && return
}
-_swift_package_completion-tool() {
+_swift_package_unedit() {
arguments=(
- ": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
+ ":The name of the package to unedit:_swift_dependency"
+ "--force[Unedit the package even if it has uncommited and unpushed changes.]"
)
_arguments $arguments && return
}
@@ -289,7 +314,7 @@ _swift_package_tools-version() {
_arguments $arguments && return
}
-_swift_package_reset() {
+_swift_package_fetch() {
arguments=(
)
_arguments $arguments && return
@@ -305,6 +330,12 @@ _swift_package_resolve() {
_arguments $arguments && return
}
+_swift_package_reset() {
+ arguments=(
+ )
+ _arguments $arguments && return
+}
+
_swift_package_generate-xcodeproj() {
arguments=(
"--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
@@ -312,19 +343,78 @@ _swift_package_generate-xcodeproj() {
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
+ "--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
)
_arguments $arguments && return
}
-_swift_package_fetch() {
+_swift_package_edit() {
arguments=(
+ ":The name of the package to edit:_swift_dependency"
+ "--revision[The revision to edit]:The revision to edit: "
+ "--branch[The branch to create]:The branch to create: "
+ "--path[Create or use the checkout at this path]:Create or use the checkout at this path:_files"
)
_arguments $arguments && return
}
-_swift_package_show-dependencies() {
+_swift_package_config() {
+ arguments=(
+ '(-): :->command'
+ '(-)*:: :->arg'
+ )
+ _arguments $arguments && return
+ case $state in
+ (command)
+ local modes
+ modes=(
+ 'unset-mirror:Remove an existing mirror'
+ 'get-mirror:Print mirror configuration for the given package dependency'
+ 'set-mirror:Set a mirror for a dependency'
+ )
+ _describe "mode" modes
+ ;;
+ (arg)
+ case ${words[1]} in
+ (unset-mirror)
+ _swift_package_config_unset-mirror
+ ;;
+ (get-mirror)
+ _swift_package_config_get-mirror
+ ;;
+ (set-mirror)
+ _swift_package_config_set-mirror
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_swift_package_config_unset-mirror() {
+ arguments=(
+ "--package-url[The package dependency url]:The package dependency url: "
+ "--mirror-url[The mirror url]:The mirror url: "
+ )
+ _arguments $arguments && return
+}
+
+_swift_package_config_get-mirror() {
+ arguments=(
+ "--package-url[The package dependency url]:The package dependency url: "
+ )
+ _arguments $arguments && return
+}
+
+_swift_package_config_set-mirror() {
+ arguments=(
+ "--package-url[The package dependency url]:The package dependency url: "
+ "--mirror-url[The mirror url]:The mirror url: "
+ )
+ _arguments $arguments && return
+}
+
+_swift_package_update() {
arguments=(
- "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
)
_arguments $arguments && return
}
@@ -346,23 +436,34 @@ _swift_test() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
- "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}"
+ "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
+ "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]"
+ "--force-resolved-versions[]"
+ "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
+ "--enable-index-store[Enable indexing-while-building feature]"
+ "--disable-index-store[Disable indexing-while-building feature]"
+ "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
+ "--enable-parseable-module-interfaces[]"
+ "--trace-resolver[]"
+ "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
+ "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the test target]"
"(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]"
"--generate-linuxmain[Generate LinuxMain.swift entries for the package]"
"--parallel[Run the tests in parallel.]"
+ "--num-workers[Number of tests to execute in parallel.]:Number of tests to execute in parallel.: "
"(--specifier -s)"{--specifier,-s}"[]: : "
"--xunit-output[]: :_files"
"--filter[Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>]:Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>: "
+ "--enable-code-coverage[Test with code coverage enabled]"
)
_arguments $arguments && return
}
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 bdc2219fa..a77f0069b 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -21,15 +21,15 @@ 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 -nr'
-alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10'
+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'
# top10 of the history
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 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/systemd/README.md b/plugins/systemd/README.md
index d91329290..3fa1d2118 100644
--- a/plugins/systemd/README.md
+++ b/plugins/systemd/README.md
@@ -51,3 +51,44 @@ plugins=(... systemd)
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
For example: `scu-list-units` will be aliased to `systemctl --user list-units`.
+
+### Unit Status Prompt
+
+You can add a token to your prompt in a similar way to the gitfast plugin. To add the token
+to your prompt, drop `$(systemd_prompt_info [unit]...)` into your prompt (more than one unit
+may be specified).
+
+The plugin will add the following to your prompt for each `$unit`.
+```
+<prefix><unit>:<active|notactive><suffix>
+```
+You can control these parts with the following variables:
+
+- `<prefix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`.
+
+- `<suffix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX`.
+
+- `<unit>`: name passed as parameter to the function. If you want it to be in ALL CAPS,
+ you can set the variable `$ZSH_THEME_SYSTEMD_PROMPT_CAPS` to a non-empty string.
+
+- `<active>`: shown if the systemd unit is active.
+ Set `$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE`.
+
+- `<notactive>`: shown if the systemd unit is *not* active.
+ Set `$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE`.
+
+For example, if your prompt contains `PROMPT='$(systemd_prompt_info dhcpd httpd)'` and you set the following variables:
+
+```
+ZSH_THEME_SYSTEMD_PROMPT_PREFIX="["
+ZSH_THEME_SYSTEMD_PROMPT_SUFFIX="]"
+ZSH_THEME_SYSTEMD_PROMPT_ACTIVE="+"
+ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE="X"
+ZSH_THEME_SYSTEMD_PROMPT_CAPS=1
+```
+
+If `dhcpd` is running, and `httpd` is not, then your prompt will look like this:
+
+```
+[DHCPD: +][HTTPD: X]
+```
diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh
index 7cd27d450..c6fd52990 100644
--- a/plugins/systemd/systemd.plugin.zsh
+++ b/plugins/systemd/systemd.plugin.zsh
@@ -1,12 +1,65 @@
user_commands=(
- list-units is-active status show help list-unit-files
- is-enabled list-jobs show-environment cat list-timers)
+ cat
+ get-default
+ help
+ is-active
+ is-enabled
+ is-failed
+ is-system-running
+ list-dependencies
+ list-jobs
+ list-sockets
+ list-timers
+ list-unit-files
+ list-units
+ show
+ show-environment
+ status)
sudo_commands=(
- start stop reload restart try-restart isolate kill
- reset-failed enable disable reenable preset mask unmask
- link load cancel set-environment unset-environment
- edit)
+ add-requires
+ add-wants
+ cancel
+ daemon-reexec
+ daemon-reload
+ default
+ disable
+ edit
+ emergency
+ enable
+ halt
+ hibernate
+ hybrid-sleep
+ import-environment
+ isolate
+ kexec
+ kill
+ link
+ list-machines
+ load
+ mask
+ poweroff
+ preset
+ preset-all
+ reboot
+ reenable
+ reload
+ reload-or-restart
+ reset-failed
+ rescue
+ restart
+ revert
+ set-default
+ set-environment
+ set-property
+ start
+ stop
+ suspend
+ switch-root
+ try-reload-or-restart
+ try-restart
+ unmask
+ unset-environment)
for c in $user_commands; do; alias sc-$c="systemctl $c"; done
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
@@ -20,3 +73,18 @@ alias sc-mask-now="sc-mask --now"
alias scu-enable-now="scu-enable --now"
alias scu-disable-now="scu-disable --now"
alias scu-mask-now="scu-mask --now"
+
+function systemd_prompt_info {
+ local unit
+ for unit in $@; do
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
+ [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo -n "${(U)unit}:" || echo -n "$unit:"
+ if systemctl is-active $unit &>/dev/null; then
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
+ else
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
+ fi
+ echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
+ done
+}
+
diff --git a/plugins/taskwarrior/README.md b/plugins/taskwarrior/README.md
index 2a86510dd..e77e4528a 100644
--- a/plugins/taskwarrior/README.md
+++ b/plugins/taskwarrior/README.md
@@ -4,10 +4,15 @@ This plugin adds smart tab completion for [TaskWarrior](https://taskwarrior.org/
It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
completion definitions.
-The latest version pulled in from the official project is of January 1st, 2015.
+To use it, add `taskwarrior` to the plugins array in your zshrc file:
+```zsh
+plugins=(... taskwarrior)
+```
## Examples
Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a
list of available modifications for that task, etcetera.
+
+The latest version pulled in from the official project is of January 1st, 2015.
diff --git a/plugins/taskwarrior/_task b/plugins/taskwarrior/_task
index c38d6cad9..e0fea179a 100644
--- a/plugins/taskwarrior/_task
+++ b/plugins/taskwarrior/_task
@@ -1,6 +1,6 @@
#compdef task
#
-# Copyright 2010 - 2016 Johannes Schlatow
+# Copyright 2010 - 2019 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,7 +24,7 @@
# https://www.opensource.org/licenses/mit-license.php
#
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
-_task_projects=($(task _projects))
+_task_projects=(${(f)"$(task _projects)"})
_task_tags=($(task _tags))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
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/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh
deleted file mode 100644
index 7c0c278b9..000000000
--- a/plugins/terminalapp/terminalapp.plugin.zsh
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is intentionally empty.
-#
-# The terminalapp plugin is deprecated and may be removed in a future release.
-# Its functionality has been folded in to the core lib/termsupport.zsh, which
-# is loaded for all users. You can remove terminalapp from your $plugins list
-# once all your systems are updated to the current version of Oh My Zsh.
diff --git a/plugins/terminitor/README.md b/plugins/terminitor/README.md
new file mode 100644
index 000000000..8c0e02113
--- /dev/null
+++ b/plugins/terminitor/README.md
@@ -0,0 +1,9 @@
+# Terminitor plugin
+
+This plugin adds completions for the [Terminitor](https://github.com/achiurizo/terminitor) development workflow setup tool.
+
+To use it, add `terminitor` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... terminitor)
+```
diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
index e5d9e47b6..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
@@ -10,14 +10,20 @@ Current as of Terraform v0.11.7
### Usage
+To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
+
+```shell
+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
If you want to get current Terraform workspace name in your ZSH prompt open
your .zsh-theme file and in a chosen place insert:
-```
-$FG[045]\
-$(tf_prompt_info)\
+```shell
+PROMPT=$'%{$fg[white]%}$(tf_prompt_info)%{$reset_color%} '
```
diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
index 1d1315a8a..a19e50670 100644
--- a/plugins/terraform/_terraform
+++ b/plugins/terraform/_terraform
@@ -1,67 +1,84 @@
#compdef terraform
-local -a _terraform_cmds
+local -a _terraform_cmds opt_args
_terraform_cmds=(
'apply:Builds or changes infrastructure'
'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'
'taint:Manually mark a resource for recreation'
'untaint:Manually unmark a resource as tainted'
'validate:Validates the Terraform files'
'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() {
+ _arguments \
+ '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \
+ '-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.]' \
- '-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.]' \
- '-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() {
@@ -69,36 +86,40 @@ __fmt() {
'-list=[(true) List files whose formatting differs (always false if using STDIN)]' \
'-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \
'-diff=[(false) Display diffs of formatting changes]' \
- '-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]'
+ '-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \
+ '-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() {
@@ -106,113 +127,206 @@ __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.]' \
- '-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
}
-__push() {
+__providers_mirror() {
_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).]'
+ '-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
+ "*:target_dir:_files -/"
+}
+
+__providers_schema() {
+ _arguments \
+ '-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.]' \
- '-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.]'
}
+__state() {
+ local -a __state_cmds
+ __state_cmds=(
+ 'list:List resources in the 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'
+ )
+ _describe -t state "state commands" __state_cmds
+}
+
+__state_list() {
+ _arguments \
+ '-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"
+}
+
+__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.]: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: "
+}
+
+__state_push() {
+ _arguments \
+ "-force[Write the state even if lineages don't match or the remote serial is higher.]" \
+ '-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.]::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=[(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"
+}
+
+__statelist() {
+ compadd $(terraform state list $opt_args[-state])
+}
+
__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() {
@@ -236,6 +350,10 @@ fi
local -a _command_args
case "$words[1]" in
+ 0.12upgrade)
+ __012upgrade ;;
+ 0.13upgrade)
+ __013upgrade ;;
apply)
__apply ;;
console)
@@ -244,6 +362,8 @@ case "$words[1]" in
__destroy ;;
fmt)
__fmt;;
+ force-unlock)
+ __force_unlock;;
get)
__get ;;
graph)
@@ -252,24 +372,40 @@ 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)
__show ;;
+ state)
+ test $CURRENT -lt 3 && __state
+ [[ $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
+ ;;
taint)
__taint ;;
untaint)
__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/textmate/README.md b/plugins/textmate/README.md
index 9fd342135..e6c1943f4 100644
--- a/plugins/textmate/README.md
+++ b/plugins/textmate/README.md
@@ -3,7 +3,8 @@
The plugin adds a function for the [TextMate](https://macromates.com) editor.
To use it, add `textmate` to the plugins array of your zshrc file:
-```
+
+```zsh
plugins=(... textmate)
```
diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
index a9b7550d7..84f7255ce 100644
--- a/plugins/thefuck/README.md
+++ b/plugins/thefuck/README.md
@@ -2,8 +2,12 @@
[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.
## Notes
-`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin.
+`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/sudo) plugin.
diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
index ac88e67de..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)"
@@ -15,4 +16,6 @@ fuck-command-line() {
}
zle -N fuck-command-line
# Defined shortcut keys: [Esc] [Esc]
-bindkey "\e\e" fuck-command-line
+bindkey -M emacs '\e\e' fuck-command-line
+bindkey -M vicmd '\e\e' fuck-command-line
+bindkey -M viins '\e\e' fuck-command-line
diff --git a/plugins/themes/_theme b/plugins/themes/_theme
deleted file mode 100644
index 8214ddb0d..000000000
--- a/plugins/themes/_theme
+++ /dev/null
@@ -1,3 +0,0 @@
-#compdef theme
-
-_arguments "1: :($(lstheme | tr "\n" " "))"
diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh
index 2cd0ee327..650856284 100644
--- a/plugins/themes/themes.plugin.zsh
+++ b/plugins/themes/themes.plugin.zsh
@@ -1,26 +1,35 @@
-function theme
-{
- if [ -z "$1" ] || [ "$1" = "random" ]; then
- themes=($ZSH/themes/*zsh-theme)
- N=${#themes[@]}
- ((N=(RANDOM%N)+1))
- RANDOM_THEME=${themes[$N]}
- source "$RANDOM_THEME"
- echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
+function theme {
+ : ${1:=random} # Use random theme if none provided
+
+ if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/$1.zsh-theme"
+ elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/themes/$1.zsh-theme"
+ elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
+ source "$ZSH/themes/$1.zsh-theme"
else
- if [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]
- then
- source "$ZSH_CUSTOM/themes/$1.zsh-theme"
- else
- source "$ZSH/themes/$1.zsh-theme"
- fi
+ echo "$0: Theme '$1' not found"
+ return 1
fi
}
-function lstheme
-{
+function _theme {
+ _arguments "1: :($(lstheme))"
+}
+
+compdef _theme theme
+
+function lstheme {
# Resources:
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
- print -l {$ZSH,$ZSH_CUSTOM}/themes/*.zsh-theme(N:t:r)
+ {
+ # Show themes inside $ZSH_CUSTOM (in any subfolder)
+ # Strip $ZSH_CUSTOM/themes/ and $ZSH_CUSTOM/ from the name, so that it matches
+ # the value that should be written in $ZSH_THEME to load the theme.
+ print -l "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)
+
+ # Show themes inside $ZSH, stripping the head of the path.
+ print -l "$ZSH"/themes/*.zsh-theme(.N:t:r)
+ } | sort -u | fmt -w $COLUMNS
}
diff --git a/plugins/thor/README.md b/plugins/thor/README.md
new file mode 100644
index 000000000..09c705d9a
--- /dev/null
+++ b/plugins/thor/README.md
@@ -0,0 +1,10 @@
+# Thor plugin
+
+This plugin adds completion for [Thor](http://whatisthor.com/),
+a ruby toolkit for building powerful command-line interfaces.
+
+To use it, add `thor` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... thor)
+```
diff --git a/plugins/tig/README.md b/plugins/tig/README.md
index bb24cd147..3323fd098 100644
--- a/plugins/tig/README.md
+++ b/plugins/tig/README.md
@@ -1,6 +1,6 @@
# `tig` plugin
-This plugin adds some aliases for people who work with `tig` in
+This plugin adds some aliases for people who work with [`tig`](https://jonas.github.io/tig/) (text-mode interface for Git) in
a regular basis. To use it, add `tig` to your plugins array:
```zsh
diff --git a/plugins/timer/README.md b/plugins/timer/README.md
new file mode 100644
index 000000000..30b0bd00e
--- /dev/null
+++ b/plugins/timer/README.md
@@ -0,0 +1,18 @@
+This plugin allows to display command's execution time in a very nonintrusive way.
+
+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:
+
+ me@here:~$ sleep 1 /1.0s
+ me@here:~$ sleep 73 /1m13.0s
+ me@here:~$ TIMER_FORMAT='[%d]'; TIMER_PRECISION=2 [0.00s]
+ me@here:~$ head -c50 < /dev/urandom | hexdump
+ 0000000 b2 16 20 f0 29 1f 61 2d 8a 29 20 8c 8c 39 5a ab
+ 0000010 21 47 0e f9 ee a4 76 46 71 9e 4f 6b a4 c4 51 cb
+ 0000020 f9 1f 7e b9 6f 2c ae dd cf 40 6d 64 a8 fb d3 db
+ 0000030 09 37
+ 0000032 [0.02s]
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
new file mode 100644
index 000000000..b261f71c5
--- /dev/null
+++ b/plugins/timer/timer.plugin.zsh
@@ -0,0 +1,35 @@
+zmodload zsh/datetime
+
+__timer_current_time() {
+ zmodload zsh/datetime
+ echo $EPOCHREALTIME
+}
+
+__timer_format_duration() {
+ local mins=$(printf '%.0f' $(($1 / 60)))
+ local secs=$(printf "%.${TIMER_PRECISION:-1}f" $(($1 - 60 * mins)))
+ local duration_str=$(echo "${mins}m${secs}s")
+ local format="${TIMER_FORMAT:-/%d}"
+ echo "${format//\%d/${duration_str#0m}}"
+}
+
+__timer_save_time_preexec() {
+ __timer_cmd_start_time=$(__timer_current_time)
+}
+
+__timer_display_timer_precmd() {
+ if [ -n "${__timer_cmd_start_time}" ]; then
+ local cmd_end_time=$(__timer_current_time)
+ local tdiff=$((cmd_end_time - __timer_cmd_start_time))
+ unset __timer_cmd_start_time
+ 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
+}
+
+autoload -U add-zsh-hook
+add-zsh-hook preexec __timer_save_time_preexec
+add-zsh-hook precmd __timer_display_timer_precmd
diff --git a/plugins/tmux-cssh/README.md b/plugins/tmux-cssh/README.md
new file mode 100644
index 000000000..4602a502a
--- /dev/null
+++ b/plugins/tmux-cssh/README.md
@@ -0,0 +1,10 @@
+# tmux-cssh plugin
+
+This plugin adds autocompletion for [`tmux-cssh`](https://github.com/zinic/tmux-cssh/).
+
+To use it, add `tmux-cssh` to the plugins array in your zshrc file:
+```zsh
+plugins=(... tmux-cssh)
+```
+
+First upstream repo, now disappeared: https://github.com/dennishafemann/tmux-cssh.
diff --git a/plugins/tmux-cssh/_tmux-cssh b/plugins/tmux-cssh/_tmux-cssh
index 604e2e478..3e81b82ea 100644
--- a/plugins/tmux-cssh/_tmux-cssh
+++ b/plugins/tmux-cssh/_tmux-cssh
@@ -5,21 +5,21 @@
# Author: Manfred Touron (@moul)
_arguments \
-'(-h --help)'{-h,--help}'[This help.]' \
-'(-u --user)'{-u,--user}'[User to use.]' \
-'(-c --certificate)'{-c,--certificate}'[Path to ssh-certificate to use.]' \
-'(-sc --ssh)'{-sc,--ssh}'[SSH-connection-string, multiple.]' \
-'(-sa --ssh)'{-sa,--ssh}'[SSH connection arguments, used on every session.]' \
-'(-ts --tmux)'{-ts,--tmux}'[Alternative tmux-session-name, default: tmux-cssh]' \
-'(-ns --new)'{-ns,--new}'[Initializes a new session, like -ts \[name\].]' \
-'(-q --quiet)'{-q,--quiet}'[Quiet-mode.]' \
-'(-f --filename)'{-f,--filename}'[Filename of textfile to get -sc connection-strings from, line separated.]' \
-'(-cs --config)'{-cs,--config}'[Name of config-settings which should be get from config-file "$HOME/.tmux-cssh". Which can be a grep-regular expression to find the name(s).]' \
+ '(-h --help)'{-h,--help}'[This help.]' \
+ '(-u --user)'{-u,--user}'[User to use.]' \
+ '(-c --certificate)'{-c,--certificate}'[Path to ssh-certificate to use.]' \
+ '(-sc --ssh)'{-sc,--ssh}'[SSH-connection-string, multiple.]' \
+ '(-sa --ssh)'{-sa,--ssh}'[SSH connection arguments, used on every session.]' \
+ '(-ts --tmux)'{-ts,--tmux}'[Alternative tmux-session-name, default: tmux-cssh]' \
+ '(-ns --new)'{-ns,--new}'[Initializes a new session, like -ts \[name\].]' \
+ '(-q --quiet)'{-q,--quiet}'[Quiet-mode.]' \
+ '(-f --filename)'{-f,--filename}'[Filename of textfile to get -sc connection-strings from, line separated.]' \
+ '(-cs --config)'{-cs,--config}'[Name of config-settings which should be get from config-file "$HOME/.tmux-cssh". Which can be a grep-regular expression to find the name(s).]' \
':hosts:_hosts' \
'*:: :->subcmds' \
&& return 0
if (( CURRENT == 1 )); then
- _describe -t commands "tmux-cssh command"
- return
+ _describe -t commands "tmux-cssh command"
+ return
fi
diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md
index 427119d3d..2ceaf1ad5 100644
--- a/plugins/tmux/README.md
+++ b/plugins/tmux/README.md
@@ -1,13 +1,14 @@
# tmux
-This plugin provides aliases for [tmux](http://tmux.github.io/), the terminal multiplexer.
+This plugin provides aliases for [tmux](https://tmux.github.io/), the terminal multiplexer.
To use it add `tmux` to the plugins array in your zshrc file.
```zsh
plugins=(... tmux)
```
-The plugin also supports the following -
+The plugin also supports the following:
+
- determines if tmux is installed or not, if not, prompts user to install tmux
- determines if the terminal supports the 256 colors or not, sets the appropriate configuration variable
- sets the correct local config file to use
@@ -24,7 +25,6 @@ The plugin also supports the following -
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
-
## Configuration Variables
| Variable | Description |
@@ -37,3 +37,5 @@ The plugin also supports the following -
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
+| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
+| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
diff --git a/plugins/tmux/tmux.extra.conf b/plugins/tmux/tmux.extra.conf
index beffd380c..c4aaad0b0 100644
--- a/plugins/tmux/tmux.extra.conf
+++ b/plugins/tmux/tmux.extra.conf
@@ -1,2 +1,2 @@
set -g default-terminal $ZSH_TMUX_TERM
-source $HOME/.tmux.conf
+source-file $ZSH_TMUX_CONFIG \ No newline at end of file
diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
index 7ddf42099..e52443a71 100644
--- a/plugins/tmux/tmux.plugin.zsh
+++ b/plugins/tmux/tmux.plugin.zsh
@@ -34,16 +34,21 @@ alias tkss='tmux kill-session -t'
# Tmux states this should be screen-256color, but you may need to change it on
# systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
+# Set the configuration path
+: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+# Set -u option to support unicode
+: ${ZSH_TMUX_UNICODE:=false}
# Determine if the terminal supports 256 colors
-if [[ $(tput colors) == 256 ]]; then
+if [[ $terminfo[colors] == 256 ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
else
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
fi
# Set the correct local config file to use.
-if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$HOME/.tmux.conf" ]]; then
+if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
+ export ZSH_TMUX_CONFIG
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
else
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
@@ -59,13 +64,18 @@ function _zsh_tmux_plugin_run() {
local -a tmux_cmd
tmux_cmd=(command tmux)
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
+ [[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
# Try to connect to an existing session.
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
# If failed, just run tmux, fixing the TERM variable if requested.
if [[ $? -ne 0 ]]; then
- [[ "$ZSH_TMUX_FIXTERM" == "true" ]] && tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
+ if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]; then
+ tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
+ elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
+ tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
+ fi
$tmux_cmd new-session
fi
diff --git a/plugins/tmuxinator/README.md b/plugins/tmuxinator/README.md
index 994d8d46d..8709204a0 100644
--- a/plugins/tmuxinator/README.md
+++ b/plugins/tmuxinator/README.md
@@ -11,9 +11,9 @@ plugins=(... tmuxinator)
## Aliases
-| Alias | Command | Description |
-| ------ | ---------------- | ------------------------ |
-| `txs ` | tmuxinator start | Start Tmuxinator |
-| `txo ` | tmuxinator open | Open project for editing |
-| `txn ` | tmuxinator new | Create project |
-| `txl ` | tmuxinator list | List projects |
+| Alias | Command | Description |
+| ----- | ---------------- | ------------------------ |
+| `txs` | tmuxinator start | Start Tmuxinator |
+| `txo` | tmuxinator open | Open project for editing |
+| `txn` | tmuxinator new | Create project |
+| `txl` | tmuxinator list | List projects |
diff --git a/plugins/tmuxinator/_tmuxinator b/plugins/tmuxinator/_tmuxinator
index 37032f8d8..9ae25ac38 100644
--- a/plugins/tmuxinator/_tmuxinator
+++ b/plugins/tmuxinator/_tmuxinator
@@ -1,3 +1,6 @@
+#compdef tmuxinator mux
+#autoload
+
_tmuxinator() {
local commands projects
commands=(${(f)"$(tmuxinator commands zsh)"})
@@ -17,5 +20,4 @@ _tmuxinator() {
return
}
-compdef _tmuxinator tmuxinator mux
-alias mux="tmuxinator"
+compdef _tmuxinator tmuxinator
diff --git a/plugins/torrent/README.md b/plugins/torrent/README.md
new file mode 100644
index 000000000..079aafcb0
--- /dev/null
+++ b/plugins/torrent/README.md
@@ -0,0 +1,13 @@
+# torrent
+
+This plugin creates a Torrent file based on a [MagnetURI](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
+
+To use it, add `torrent` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... torrent)
+```
+
+## Plugin commands
+
+* `magnet_to_torrent <MagnetURI>`: creates Torrent file.
diff --git a/plugins/transfer/transfer.plugin.zsh b/plugins/transfer/transfer.plugin.zsh
index 7a7cd85ec..db744b0cd 100644
--- a/plugins/transfer/transfer.plugin.zsh
+++ b/plugins/transfer/transfer.plugin.zsh
@@ -61,7 +61,9 @@ transfer() {
# cat output link
cat $tmpfile
+ # add newline
+ echo
# cleanup
rm -f $tmpfile
-} \ No newline at end of file
+}
diff --git a/plugins/tugboat/README.md b/plugins/tugboat/README.md
new file mode 100644
index 000000000..14f828f85
--- /dev/null
+++ b/plugins/tugboat/README.md
@@ -0,0 +1,12 @@
+# Tugboat plugin
+
+This plugin adds autocompletion for Tugboat, a command line tool for interacting with your
+[DigitalOcean droplets](https://www.digitalocean.com/products/droplets/).
+
+To use it, add it to the plugins array in your `~/.zshrc` file:
+
+```zsh
+plugins=(... tugboat)
+```
+
+Further documentation for Tugboat can be found in the [Tugboat repository](https://github.com/petems/tugboat).
diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md
index caa6a90b4..f72182f5c 100644
--- a/plugins/ubuntu/README.md
+++ b/plugins/ubuntu/README.md
@@ -2,7 +2,7 @@
This plugin adds completions and aliases for [Ubuntu](https://www.ubuntu.com/).
-To use it, add `ubuntu` to the plugins array in your zshrc file:
+To use it, add `ubuntu` to the plugins array in your zshrc file:
```zsh
plugins=(... ubuntu)
@@ -10,34 +10,34 @@ plugins=(... ubuntu)
## Aliases
-Commands that use `$APT` will use apt if installed or defer to apt-get otherwise.
-
-| Alias | Command | Description |
-|---------|------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
-| acs | `apt-cache search` | Search the apt-cache with the specified criteria |
-| acp | `apt-cache policy` | Display the package source priorities |
-| afs | `apt-file search --regexp` | Perform a regular expression apt-file search |
-| afu | `sudo apt-file update` | Generates or updates the apt-file package database |
-| ag | `sudo $APT` | Run apt-get with sudo |
-| aga | `sudo $APT autoclean` | Clears out the local reposityory of retrieved package files that can no longer be downloaded |
-| agb | `sudo $APT build-dep <source_pkg>` | Installs/Removes packages to satisfy the dependencies of a specified build pkg |
-| agc | `sudo $APT clean` | Clears out the local repository of retrieved package files leaving everything from the lock files |
-| agd | `sudo $APT dselect-upgrade` | Follows dselect choices for package installation |
-| agi | `sudo $APT install <pkg>` | Install the specified package |
-| agli | `apt list --installed` | List the installed packages |
-| aglu | `sudo apt-get -u upgrade --assume-no` | Run an apt-get upgrade assuming no to all prompts |
-| agp | `sudo $APT purge <pkg>` | Remove a package including any configuration files |
-| agr | `sudo $APT remove <pkg>` | Remove a package |
-| ags | `$APT source <pkg>` | Fetch the source for the specified package |
-| agu | `sudo $APT update` | Update package list |
-| agud | `sudo $APT update && sudo $APT dist-upgrade` | Update packages list and perform a distribution upgrade |
-| agug | `sudo $APT upgrade` | Upgrade available packages |
-| agar | `sudo $APT autoremove` | Remove automatically installed packages no longer needed |
-| aguu | `sudo $APT update && sudo $APT upgrade` | Update packages list and upgrade available packages |
-| allpkgs | `dpkg --get-selections \| grep -v deinstall` | Print all installed packages |
-| kclean | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` |Remove ALL kernel images and headers EXCEPT the one in use |
-| mydeb | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package |
-| ppap | `sudo ppa-purge <ppa>` | Remove the specified PPA |
+Commands that use `$APT` will use `apt` if installed or defer to `apt-get` otherwise.
+
+| Alias | Command | Description |
+|---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
+| age | `sudo $APT` | Run apt-get with sudo |
+| acs | `apt-cache search` | Search the apt-cache with the specified criteria |
+| acp | `apt-cache policy` | Display the package source priorities |
+| afs | `apt-file search --regexp` | Perform a regular expression apt-file search |
+| afu | `sudo apt-file update` | Generates or updates the apt-file package database |
+| aga | `sudo $APT autoclean` | Clears out the local reposityory of retrieved package files that can no longer be downloaded |
+| agb | `sudo $APT build-dep <source_pkg>` | Installs/Removes packages to satisfy the dependencies of a specified build pkg |
+| agc | `sudo $APT clean` | Clears out the local repository of retrieved package files leaving everything from the lock files |
+| agd | `sudo $APT dselect-upgrade` | Follows dselect choices for package installation |
+| agi | `sudo $APT install <pkg>` | Install the specified package |
+| agli | `apt list --installed` | List the installed packages |
+| aglu | `sudo apt-get -u upgrade --assume-no` | Run an apt-get upgrade assuming no to all prompts |
+| agp | `sudo $APT purge <pkg>` | Remove a package including any configuration files |
+| agr | `sudo $APT remove <pkg>` | Remove a package |
+| ags | `$APT source <pkg>` | Fetch the source for the specified package |
+| agu | `sudo $APT update` | Update package list |
+| agud | `sudo $APT update && sudo $APT dist-upgrade` | Update packages list and perform a distribution upgrade |
+| agug | `sudo $APT upgrade` | Upgrade available packages |
+| agar | `sudo $APT autoremove` | Remove automatically installed packages no longer needed |
+| aguu | `sudo $APT update && sudo $APT upgrade` | Update packages list and upgrade available packages |
+| allpkgs | `dpkg --get-selections \| grep -v deinstall` | Print all installed packages |
+| kclean | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` |Remove ALL kernel images and headers EXCEPT the one in use |
+| mydeb | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package |
+| ppap | `sudo ppa-purge <ppa>` | Remove the specified PPA |
## Functions
@@ -47,6 +47,14 @@ Commands that use `$APT` will use apt if installed or defer to apt-get otherwise
| aar | `aar ppa:xxxxxx/xxxxxx [packagename]` | apt-add-repository with automatic install/upgrade of the desired package |
| apt-history | `apt-history <action>` | Prints the Apt history of the specified action |
| apt-list-packages | `apt-list-packages` | List packages by size |
-| kerndeb | `kerndeb` | Kernel-package building shortcut |
+| kerndeb | `kerndeb` | Kernel-package building shortcut |
+## Authors:
+- [@AlexBio](https://github.com/AlexBio)
+- [@dbb](https://github.com/dbb)
+- [@Mappleconfusers](https://github.com/Mappleconfusers)
+- [@trinaldi](https://github.com/trinaldi)
+- [Nicolas Jonas](https://nextgenthemes.com)
+- [@loctauxphilippe](https://github.com/loctauxphilippe)
+- [@HaraldNordgren](https://github.com/HaraldNordgren)
diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
index 198f06743..989ffd1ff 100644
--- a/plugins/ubuntu/ubuntu.plugin.zsh
+++ b/plugins/ubuntu/ubuntu.plugin.zsh
@@ -1,76 +1,46 @@
-# Authors:
-# https://github.com/AlexBio
-# https://github.com/dbb
-# https://github.com/Mappleconfusers
-# https://github.com/trinaldi
-# Nicolas Jonas nextgenthemes.com
-# https://github.com/loctauxphilippe
-# https://github.com/HaraldNordgren
-#
-# Debian, Ubuntu and friends related zsh aliases and functions for zsh
-
(( $+commands[apt] )) && APT=apt || APT=apt-get
alias acs='apt-cache search'
-compdef _acs acs='apt-cache search'
alias afs='apt-file search --regexp'
-compdef _afs afs='apt-file search --regexp'
# These are apt/apt-get only
-alias ags="$APT source" # asrc
-compdef _ags ags="$APT source"
+alias ags="$APT source"
-alias acp='apt-cache policy' # app
-compdef _acp acp='apt-cache policy'
+alias acp='apt-cache policy'
#List all installed packages
alias agli='apt list --installed'
-compdef _agli agli='apt list --installed'
-
-# superuser operations ######################################################
# List available updates only
-alias aglu='sudo apt-get -u upgrade --assume-no'
-compdef _aglu aglu='sudo apt-get -u upgrade --assume-no'
+alias aglu='apt list --upgradable'
+
+alias acsp='apt-cache showpkg'
+compdef _acsp acsp='apt-cache showpkg'
+
+# superuser operations ######################################################
alias afu='sudo apt-file update'
-compdef _afu afu='sudo apt-file update'
alias ppap='sudo ppa-purge'
-compdef _ppap ppap='sudo ppa-purge'
-
-alias ag="sudo $APT" # age - but without sudo
-alias aga="sudo $APT autoclean" # aac
-alias agb="sudo $APT build-dep" # abd
-alias agc="sudo $APT clean" # adc
-alias agd="sudo $APT dselect-upgrade" # ads
-alias agi="sudo $APT install" # ai
-alias agp="sudo $APT purge" # ap
-alias agr="sudo $APT remove" # ar
-alias agu="sudo $APT update" # ad
-alias agud="sudo $APT update && sudo $APT dist-upgrade" #adu
-alias agug="sudo $APT upgrade" # ag
-alias aguu="sudo $APT update && sudo $APT upgrade" #adg
+
+alias age="sudo $APT"
+alias aga="sudo $APT autoclean"
+alias agb="sudo $APT build-dep"
+alias agc="sudo $APT clean"
+alias agd="sudo $APT dselect-upgrade"
+alias agi="sudo $APT install"
+alias agp="sudo $APT purge"
+alias agr="sudo $APT remove"
+alias agu="sudo $APT update"
+alias agud="sudo $APT update && sudo $APT dist-upgrade"
+alias agug="sudo $APT upgrade"
+alias aguu="sudo $APT update && sudo $APT upgrade"
alias agar="sudo $APT autoremove"
-compdef _ag ag="sudo $APT"
-compdef _aga aga="sudo $APT autoclean"
-compdef _agb agb="sudo $APT build-dep"
-compdef _agc agc="sudo $APT clean"
-compdef _agd agd="sudo $APT dselect-upgrade"
-compdef _agi agi="sudo $APT install"
-compdef _agp agp="sudo $APT purge"
-compdef _agr agr="sudo $APT remove"
-compdef _agu agu="sudo $APT update"
-compdef _agud agud="sudo $APT update && sudo $APT dist-upgrade"
-compdef _agug agug="sudo $APT upgrade"
-compdef _aguu aguu="sudo $APT update && sudo $APT upgrade"
-compdef _agar agar="sudo $APT autoremove"
# 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`))'
# Misc. #####################################################################
# print all installed packages
@@ -89,11 +59,11 @@ aar() {
else
read "PACKAGE?Type in the package name to install/upgrade with this ppa [${1##*/}]: "
fi
-
+
if [ -z "$PACKAGE" ]; then
PACKAGE=${1##*/}
fi
-
+
sudo apt-add-repository $1 && sudo $APT update
sudo $APT install $PACKAGE
}
@@ -136,22 +106,22 @@ apt-history () {
# Kernel-package building shortcut
kerndeb () {
- # temporarily unset MAKEFLAGS ( '-j3' will fail )
- MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
- print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
- appendage='-custom' # this shows up in $ (uname -r )
- revision=$(date +"%Y%m%d") # this shows up in the .deb file name
+ # temporarily unset MAKEFLAGS ( '-j3' will fail )
+ MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
+ print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
+ appendage='-custom' # this shows up in $(uname -r)
+ revision=$(date +"%Y%m%d") # this shows up in the .deb file name
- make-kpkg clean
+ make-kpkg clean
- time fakeroot make-kpkg --append-to-version "$appendage" --revision \
- "$revision" kernel_image kernel_headers
+ time fakeroot make-kpkg --append-to-version "$appendage" --revision \
+ "$revision" kernel_image kernel_headers
}
# List packages by size
function apt-list-packages {
- dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
- grep -v deinstall | \
- sort -n | \
- awk '{print $1" "$2}'
+ dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
+ grep -v deinstall | \
+ sort -n | \
+ awk '{print $1" "$2}'
}
diff --git a/plugins/ufw/README.md b/plugins/ufw/README.md
new file mode 100644
index 000000000..ac377cd17
--- /dev/null
+++ b/plugins/ufw/README.md
@@ -0,0 +1,18 @@
+# UFW plugin
+
+This plugin adds completion for managing everybody's favorite Uncomplicated Firewall (UFW),
+a simple interface for managing iptables. Learn more about [`UFW`](https://wiki.ubuntu.com/UncomplicatedFirewall).
+
+To use it, add ufw to the plugins array of your zshrc file:
+```
+plugins=(... ufw)
+```
+
+Some of the commands include:
+
+* `allow <port>/<optional: protocol>` add an allow rule
+* `default` set default policy
+* `delete <port>/<optional: protocol>` delete RULE
+* `deny <port>/<optional: protocol>` add deny rule
+* `disable` disables the firewall
+* `enable` enables the firewall
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/urltools/README.md b/plugins/urltools/README.md
index 548301c72..29c371070 100644
--- a/plugins/urltools/README.md
+++ b/plugins/urltools/README.md
@@ -21,9 +21,9 @@ Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/20
## Examples
```zsh
-urlencode 'https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code'
-# returns https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode
+urlencode 'https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code'
+# returns https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode
-urldecode 'https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
-# returns https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code
+urldecode 'https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
+# returns https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code
```
diff --git a/plugins/urltools/urltools.plugin.zsh b/plugins/urltools/urltools.plugin.zsh
index 47d9a34e4..b443e5027 100644
--- a/plugins/urltools/urltools.plugin.zsh
+++ b/plugins/urltools/urltools.plugin.zsh
@@ -12,11 +12,11 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD
alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif [[ $(whence python3) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
- alias urlencode='python3 -c "import sys, urllib.parse as up; print(up.quote_plus(sys.argv[1]))"'
- alias urldecode='python3 -c "import sys, urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"'
+ alias urlencode='python3 -c "import sys; del sys.path[0]; import urllib.parse as up; print(up.quote_plus(sys.argv[1]))"'
+ alias urldecode='python3 -c "import sys; del sys.path[0]; import urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"'
elif [[ $(whence python2) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
- alias urlencode='python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
- alias urldecode='python2 -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
+ alias urlencode='python2 -c "import sys; del sys.path[0]; import urllib as ul; print ul.quote_plus(sys.argv[1])"'
+ alias urldecode='python2 -c "import sys; del sys.path[0]; import urllib as ul; print ul.unquote_plus(sys.argv[1])"'
elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then
function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"}
function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"}
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/README.md b/plugins/vagrant/README.md
index f6ea87b0e..331bfa143 100644
--- a/plugins/vagrant/README.md
+++ b/plugins/vagrant/README.md
@@ -8,3 +8,33 @@ To use it, add `vagrant` to the plugins array in your zshrc file:
plugins=(... vagrant)
```
+## Aliases
+
+| Alias | Command |
+|---------|------------------------------|
+| `vgi` | `vagrant init` |
+| `vup` | `vagrant up` |
+| `vd` | `vagrant destroy` |
+| `vdf` | `vagrant destroy -f` |
+| `vssh` | `vagrant ssh` |
+| `vsshc` | `vagrant ssh-config` |
+| `vrdp` | `vagrant rdp` |
+| `vh` | `vagrant halt` |
+| `vssp` | `vagrant suspend` |
+| `vst` | `vagrant status` |
+| `vre` | `vagrant resume` |
+| `vgs` | `vagrant global-status` |
+| `vpr` | `vagrant provision` |
+| `vr` | `vagrant reload` |
+| `vrp` | `vagrant reload --provision` |
+| `vp` | `vagrant push` |
+| `vsh` | `vagrant share` |
+| `vba` | `vagrant box add` |
+| `vbr` | `vagrant box remove` |
+| `vbl` | `vagrant box list` |
+| `vbo` | `vagrant box outdated` |
+| `vbu` | `vagrant box update` |
+| `vpli` | `vagrant plugin install` |
+| `vpll` | `vagrant plugin list` |
+| `vplun` | `vagrant plugin uninstall` |
+| `vplu` | `vagrant plugin update` |
diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant
index a99a8f0e7..e88835506 100644
--- a/plugins/vagrant/_vagrant
+++ b/plugins/vagrant/_vagrant
@@ -6,6 +6,7 @@
local -a _1st_arguments
_1st_arguments=(
'box:Box commands'
+ 'cloud:Manages everything related to Vagrant Cloud'
'connect:Connects to a remotely shared Vagrant environment'
'destroy:Destroys the vagrant environment'
'docker-logs:Outputs the logs from the Docker container'
@@ -18,6 +19,7 @@ _1st_arguments=(
'login:Authenticates against a Vagrant Cloud server to access protected boxes'
'package:Packages a vagrant environment for distribution'
'plugin:Plugin commands'
+ 'port:Displays information about guest port mappings'
'provision:Run the provisioner'
'push:Deploys code in this environment to a configured destination'
'rdp:Connects to machine via RDP'
@@ -33,6 +35,7 @@ _1st_arguments=(
'suspend:Suspends the currently running vagrant environment'
'snapshot:Used to manage snapshots with the guest machine'
'up:Creates the vagrant environment'
+ 'validate:Validates the Vagrantfile'
'version:Prints current and latest Vagrant version'
'--help:[TASK] Describe available tasks or one specific task'
'--version:Prints the Vagrant version information'
@@ -54,20 +57,20 @@ __task_list ()
local expl
declare -a tasks
- tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version)
+ tasks=(box destroy halt init package port provision reload resume ssh ssh_config status suspend up version)
_wanted tasks expl 'help' compadd $tasks
}
__box_list ()
{
- _wanted application expl 'command' compadd $(command vagrant box list | sed -e 's/ /\\ /g')
+ _wanted application expl 'command' compadd $(command vagrant box list | sed -e 's/ *(.*)//g;s/ /\\ /g')
}
__vm_list ()
{
- _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
- _wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null)
+ _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)
}
__vagrant-box ()
@@ -123,7 +126,7 @@ case $state in
(box)
__vagrant-box
;;
- (up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status)
+ (up|provision|port|package|destroy|reload|ssh|ssh-config|halt|resume|status)
_arguments ':feature:__vm_list'
esac
;;
diff --git a/plugins/vagrant/vagrant.plugin.zsh b/plugins/vagrant/vagrant.plugin.zsh
new file mode 100644
index 000000000..a4e9b06c2
--- /dev/null
+++ b/plugins/vagrant/vagrant.plugin.zsh
@@ -0,0 +1,33 @@
+alias vgi="vagrant init"
+
+alias vup="vagrant up"
+alias vd="vagrant destroy"
+alias vdf="vagrant destroy -f"
+
+alias vssh="vagrant ssh"
+alias vsshc="vagrant ssh-config"
+alias vrdp="vagrant rdp"
+
+alias vh="vagrant halt"
+alias vssp="vagrant suspend"
+alias vst="vagrant status"
+alias vre="vagrant resume"
+alias vgs="vagrant global-status"
+
+alias vpr="vagrant provision"
+alias vr="vagrant reload"
+alias vrp="vagrant reload --provision"
+
+alias vp="vagrant push"
+alias vsh="vagrant share"
+
+alias vba="vagrant box add"
+alias vbr="vagrant box remove"
+alias vbl="vagrant box list"
+alias vbo="vagrant box outdated"
+alias vbu="vagrant box update"
+
+alias vpli="vagrant plugin install"
+alias vpll="vagrant plugin list"
+alias vplun="vagrant plugin uninstall"
+alias vplu="vagrant plugin update"
diff --git a/plugins/vault/README.md b/plugins/vault/README.md
index 5cdbb16f0..69051d2b2 100644
--- a/plugins/vault/README.md
+++ b/plugins/vault/README.md
@@ -1,18 +1,15 @@
-## Vault (https://www.vaultproject.io) autocomplete plugin
+# Vault plugin
-- Adds autocomplete options for all vault commands.
+Note: this plugin is deprecated. Use the [official autocompletion](https://www.vaultproject.io/docs/commands/index.html#autocompletion) instead.
-####Show help for all commands
-![General Help](https://i.imgur.com/yv5Db1r.png "Help for all commands")
+-------
+Adds autocomplete options for all [vault](https://www.vaultproject.io) commands.
-####Create new Vault token
-![Create token](https://i.imgur.com/xMegNgh.png "Create token")
-
-
-####Enable audit backends
-![Audit backends](https://i.imgur.com/fKLeiSF.png "Audit backends")
-
+To use it, add `vault` to the plugins array in your zshrc file:
+```zsh
+plugins=(... vault)
+```
Crafted with <3 by Valentin Bud ([@valentinbud](https://twitter.com/valentinbud))
diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
index 8519a5592..b59d5f279 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
+NOTE: this used to be bound to `v`. That is now the default (`visual-mode`)
-Vim edition
------------
-
-- `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,5 @@ 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
diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
index 93964594b..dd4afdd8b 100644
--- a/plugins/vi-mode/vi-mode.plugin.zsh
+++ b/plugins/vi-mode/vi-mode.plugin.zsh
@@ -1,23 +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() {
- zle reset-prompt
- zle -R
-}
+ # update keymap variable for the prompt
+ typeset -g VI_KEYMAP=$KEYMAP
-# Ensure that the prompt is redrawn when the terminal size changes.
-TRAPWINCH() {
- zle && { zle -R; zle reset-prompt }
+ 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
-zle -N edit-command-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
+
+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
-# allow v to edit the command line (standard behaviour)
+# allow vv to edit the command line (standard behaviour)
autoload -Uz edit-command-line
-bindkey -M vicmd 'v' edit-command-line
+zle -N edit-command-line
+bindkey -M vicmd 'vv' edit-command-line
# allow ctrl-p, ctrl-n for navigate history (standard behaviour)
bindkey '^P' up-history
@@ -28,23 +82,64 @@ bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
-# allow ctrl-r to perform backward search in history
+# allow ctrl-r and ctrl-s to search the history
bindkey '^r' history-incremental-search-backward
+bindkey '^s' history-incremental-search-forward
# allow ctrl-a and ctrl-e to move to beginning/end of line
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() {
- echo "${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
+ # 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/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/README.md b/plugins/virtualenvwrapper/README.md
new file mode 100644
index 000000000..63eb58541
--- /dev/null
+++ b/plugins/virtualenvwrapper/README.md
@@ -0,0 +1,38 @@
+# Virtualenvwrapper plugin
+
+This plugin loads Python's [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) shell tools.
+
+To use it, add `virtualenvwrapper` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... virtualenvwrapper)
+```
+
+## Usage
+
+The plugin allows to automatically activate virtualenvs on cd into git repositories with a matching name:
+
+```
+➜ github $ cd ansible
+(ansible) ➜ ansible git:(devel) $ cd docs
+(ansible) ➜ docs git:(devel) $ cd ..
+(ansible) ➜ ansible git:(devel) $ cd ..
+➜ github $
+```
+
+We can override this by having a `.venv` file in the directory containing a differently named virtualenv:
+
+```
+➜ github $ cat ansible/.venv
+myvirtualenv
+➜ github $ cd ansible
+(myvirtualenv) ➜ ansible git:(devel) $ cd ..
+➜ github $
+```
+
+We can disable this behaviour by setting `DISABLE_VENV_CD=1` before Oh My Zsh is sourced:
+```zsh
+DISABLE_VENV_CD=1
+plugins=(... virtualenvwrapper)
+source $ZSH/oh-my-zsh.sh
+```
diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
index e27c6bb76..c30216f51 100644
--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
@@ -1,48 +1,31 @@
-virtualenvwrapper='virtualenvwrapper.sh'
-virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh'
+function {
+ # search in these locations for the init script:
+ for virtualenvwrapper in $commands[virtualenvwrapper_lazy.sh] \
+ $commands[virtualenvwrapper.sh] \
+ /usr/share/virtualenvwrapper/virtualenvwrapper{_lazy,}.sh \
+ /usr/local/bin/virtualenvwrapper{_lazy,}.sh \
+ /etc/bash_completion.d/virtualenvwrapper \
+ /usr/share/bash-completion/completions/virtualenvwrapper \
+ $HOME/.local/bin/virtualenvwrapper.sh
+ do
+ if [[ -f "$virtualenvwrapper" ]]; then
+ source "$virtualenvwrapper"
+ return
+ fi
+ done
+ print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh.\n"\
+ "Please install with \`pip install virtualenvwrapper\`" >&2
+ return 1
+}
-if (( $+commands[$virtualenvwrapper_lazy] )); then
- function {
- setopt local_options
- unsetopt equals
- virtualenvwrapper=${${virtualenvwrapper_lazy}:c}
- source ${${virtualenvwrapper_lazy}:c}
- [[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs"
- }
-elif (( $+commands[$virtualenvwrapper] )); then
- function {
- setopt local_options
- unsetopt equals
- source ${${virtualenvwrapper}:c}
- }
-elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then
- function {
- setopt local_options
- unsetopt equals
- virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh"
- source "/usr/local/bin/virtualenvwrapper.sh"
- }
-elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
- function {
- setopt local_options
- unsetopt equals
- virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
- source "/etc/bash_completion.d/virtualenvwrapper"
- }
-else
- print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
- "Please install with \`pip install virtualenvwrapper\`" >&2
- return
-fi
-if ! type workon &>/dev/null; then
+if [[ $? -eq 0 ]] && ! type workon &>/dev/null; then
print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2
return
fi
-if [[ "$WORKON_HOME" == "" ]]; then
- print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2
- return
+if [[ -z "$WORKON_HOME" ]]; then
+ WORKON_HOME="$HOME/.virtualenvs"
fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
@@ -52,41 +35,42 @@ 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=""
fi
+
+ if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_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
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
- elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
+ 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
@@ -96,7 +80,6 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# Append workon_cwd to the chpwd_functions array, so it will be called on cd
# http://zsh.sourceforge.net/Doc/Release/Functions.html
- if ! (( $chpwd_functions[(I)workon_cwd] )); then
- chpwd_functions+=(workon_cwd)
- fi
+ autoload -U add-zsh-hook
+ add-zsh-hook chpwd workon_cwd
fi
diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md
index 8ee45525a..e95ed5d4f 100644
--- a/plugins/vscode/README.md
+++ b/plugins/vscode/README.md
@@ -1,6 +1,6 @@
-# VS code
+# VS Code
-This plugin makes interaction between the command line and the 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`:
@@ -8,6 +8,46 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`
plugins=(... vscode)
```
+## Requirements
+
+This plugin requires to have a flavour of VS Code installed and it's executable available in PATH.
+
+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:
+> Shell Command: Install 'code' command in PATH
+
+[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
+
+## Using multiple flavours
+
+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=...
+
+# 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)
+
+source $ZSH/oh-my-zsh.sh
+```
+
## Common aliases
| Alias | Command | Description |
diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh
index 902c23ecf..48d904377 100644
--- a/plugins/vscode/vscode.plugin.zsh
+++ b/plugins/vscode/vscode.plugin.zsh
@@ -1,19 +1,41 @@
-# VScode zsh plugin
-# author: https://github.com/MarsiBarsi
+# VS Code (stable / insiders) / VSCodium zsh plugin
+# Authors:
+# https://github.com/MarsiBarsi (original author)
+# https://github.com/babakks
+# https://github.com/SteelShot
-alias vsc='code .'
-alias vsca='code --add'
-alias vscd='code --diff'
-alias vscg='code --goto'
-alias vscn='code --new-window'
-alias vscr='code --reuse-window'
-alias vscw='code --wait'
-alias vscu='code --user-data-dir'
+# 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
-alias vsced='code --extensions-dir'
-alias vscie='code --install-extension'
-alias vscue='code --uninstall-extension'
+# 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
-alias vscv='code --verbose'
-alias vscl='code --log'
-alias vscde='code --disable-extensions'
+alias vsc="$VSCODE ."
+alias vsca="$VSCODE --add"
+alias vscd="$VSCODE --diff"
+alias vscg="$VSCODE --goto"
+alias vscn="$VSCODE --new-window"
+alias vscr="$VSCODE --reuse-window"
+alias vscw="$VSCODE --wait"
+alias vscu="$VSCODE --user-data-dir"
+
+alias vsced="$VSCODE --extensions-dir"
+alias vscie="$VSCODE --install-extension"
+alias vscue="$VSCODE --uninstall-extension"
+
+alias vscv="$VSCODE --verbose"
+alias vscl="$VSCODE --log"
+alias vscde="$VSCODE --disable-extensions"
diff --git a/plugins/wakeonlan/README b/plugins/wakeonlan/README.md
index 16fdd4587..3fcb6d7f1 100644
--- a/plugins/wakeonlan/README
+++ b/plugins/wakeonlan/README.md
@@ -1,9 +1,17 @@
+# wakeonlan
+
This plugin provides a wrapper around the "wakeonlan" tool available from most
-distributions' package repositories, or from the following website:
+distributions' package repositories, or from [the following website](https://github.com/jpoliv/wakeonlan).
+
+To use it, add `wakeonlan` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... wakeonlan)
+```
-http://gsd.di.uminho.pt/jpo/software/wakeonlan/
+## Usage
-In order to use this wrapper, create the ~/.wakeonlan directory, and place in
+In order to use this wrapper, create the `~/.wakeonlan` directory, and place in
that directory one file for each device you would like to be able to wake. Give
the file a name that describes the device, such as its hostname. Each file
should contain a line with the mac address of the target device and the network
@@ -12,15 +20,21 @@ broadcast address.
For instance, there might be a file ~/.wakeonlan/leto with the following
contents:
+```
00:11:22:33:44:55:66 192.168.0.255
+```
To wake that device, use the following command:
-# wake leto
+```console
+$ wake leto
+```
The available device names will be autocompleted, so:
-# wake <tab>
+```console
+$ wake <tab>
+```
...will suggest "leto", along with any other configuration files that were
placed in the ~/.wakeonlan directory.
diff --git a/plugins/wd/README.md b/plugins/wd/README.md
index b1deeffd5..8791f9f0e 100644
--- a/plugins/wd/README.md
+++ b/plugins/wd/README.md
@@ -1,158 +1,259 @@
-wd
-==
+# wd
[![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
-### Setup
+### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
-### oh-my-zsh
+`wd` comes bundled with oh-my-zsh!
-`wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
+Just add the plugin in your `.zshrc` file:
-Just add the plugin in your `~/.zshrc` file:
+```zsh
+plugins=(... wd)
+```
- plugins=(... wd)
+### [Antigen](https://github.com/zsh-users/antigen)
+In your `.zshrc`:
-#### Automatic
+```zsh
+antigen bundle mfaerevaag/wd
+```
-Run either in terminal:
+### [Antibody](https://github.com/getantibody/antibody)
- * `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh`
+In your `.zshrc`:
- * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
+```zsh
+antibody bundle mfaerevaag/wd
+```
-##### Arch ([AUR](https://aur.archlinux.org/))
+### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
- # yaourt -S zsh-plugin-wd-git
+1. Install from the AUR
+```zsh
+yay -S zsh-plugin-wd-git
+# or use any other AUR helper
+```
-#### Manual
+2. Then add to your `.zshrc`:
- * Clone this repo to your liking
+```zsh
+wd() {
+ . /usr/share/wd/wd.sh
+}
+```
- * Add `wd` function to `.zshrc` (or `.profile` etc.):
+### [zplug](https://github.com/zplug/zplug)
- wd() {
- . ~/path/to/cloned/repo/wd/wd.sh
- }
+```zsh
+zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS/mfaerevaag/wd/wd.sh }"
+```
- * Install manpage. From `wd`'s base directory (requires root permissions):
+### Automatic
- # cp wd.1 /usr/share/man/man1/wd.1
- # chmod 644 /usr/share/man/man1/wd.1
+_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)_
- Note, when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
+Run either command in your terminal:
+```zsh
+curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
+```
-#### Completion
+or
-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
+wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh
+```
- fpath=(~/path/to/wd $fpath)
+### Manual
+
+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):
+
+```zsh
+git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
+```
+
+2. Add `wd` function to `.zshrc` (or `.profile` etc.):
+
+```zsh
+wd() {
+ . ~/.local/wd/wd.sh
+}
+```
+
+3. Install manpage (optional):
+
+```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`:
+
+```zsh
+fpath=(~/path/to/wd $fpath)
+```
Also, you may have to force a rebuild of `zcompdump` by running:
- $ rm -f ~/.zcompdump; compinit
+```zsh
+rm -f ~/.zcompdump; compinit
+```
+
+## Usage
+
+* Add warp point to current working directory:
+
+```zsh
+wd add foo
+```
+
+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.
+You can omit point name to automatically use the current directory's name instead.
-### Usage
+* From any directory, warp to `foo` with:
- * Add warp point to current working directory:
+```zsh
+wd foo
+```
- $ wd add foo
+* You can also warp to a directory within `foo`, with autocompletion:
- If a warp point with the same name exists, use `add!` to overwrite it.
+```zsh
+wd foo some/inner/path
+```
- Note, a warp point cannot contain colons, or only 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 warp back to previous directory and higher, with this dot syntax:
- You can omit point name to use the current directory's name instead.
+```zsh
+wd ..
+wd ...
+```
- * From an other directory (not necessarily), warp to `foo` with:
+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)._
- $ wd foo
+* Remove warp point:
- * You can warp back to previous directory, and so on, with this dot syntax:
+```zsh
+wd rm foo
+```
- $ wd ..
- $ wd ...
+You can omit point name to use the current directory's name instead.
- This is a wrapper for the zsh `dirs` function.
- (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)).
+* List all warp points (stored in `~/.warprc` by default):
- * Remove warp point test point:
+```zsh
+wd list
+```
- $ wd rm foo
+* List files in given warp point:
- You can omit point name to use the current directory's name instead.
+```zsh
+wd ls foo
+```
- * List all warp points (stored in `~/.warprc`):
+* Show path of given warp point:
- $ wd list
+```zsh
+wd path foo
+```
- * List files in given warp point:
+* List warp points to current directory, or optionally, path to given warp point:
- $ wd ls foo
+```zsh
+wd show
+```
- * Show path of given warp point:
+* Remove warp points to non-existent directories.
- $ wd path foo
+```zsh
+wd clean
+```
- * List warp points to current directory, or optionally, path to given warp point:
+Use `wd clean --force` to not be prompted with confirmation.
- $ wd show
+* Print usage info:
- * Remove warp points to non-existent directories.
+```zsh
+wd help
+```
- $ wd clean
+The usage will be printed also if you call `wd` with no command
- Use `clean!` to not be prompted with confirmation (force).
+* Print the running version of `wd`:
- * Print usage with no opts or the `help` argument:
+```zsh
+wd --version
+```
- $ wd help
+* Specifically set the config file (default being `~/.warprc`), which is useful for testing:
- * Print the running version of `wd`:
+```zsh
+wd --config ./file <command>
+```
- $ wd --version
+* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
- * Specifically set the config file (default `~/.warprc`), which is useful when testing:
+```zsh
+wd --debug <command>
+```
- $ wd --config ./file <action>
+* Silence all output:
- * Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required when testing/debugging.
+```zsh
+wd --quiet <command>
+```
- $ wd --debug <action>
+## Configuration
- * Silence all output:
+You can configure `wd` with the following environment variables:
- $ wd --quiet <action>
+### `WD_CONFIG`
+Defines the path where warp points get stored. Defaults to `$HOME/.warprc`.
-### Testing
+## 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 it 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`.
- $ ./tests.sh
+```zsh
+cd ./test
+./tests.sh
+```
+## Maintainers
-### License
+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
+* @MattLewin
-### Finally
+Anyone else contributing is greatly appreciated and will be mentioned in the release notes!
-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.
+---
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
index 4354a71f4..8d5cf15a2 100644
--- a/plugins/wd/_wd.sh
+++ b/plugins/wd/_wd.sh
@@ -1,6 +1,6 @@
#compdef wd
-zstyle ':completion:*:descriptions' format '%B%d%b'
+zstyle ':completion::complete:wd:*:descriptions' format '%B%d%b'
zstyle ':completion::complete:wd:*:commands' group-name commands
zstyle ':completion::complete:wd:*:warp_points' group-name warp_points
zstyle ':completion::complete:wd::' list-grouped
@@ -8,13 +8,13 @@ zstyle ':completion::complete:wd::' list-grouped
zmodload zsh/mapfile
function _wd() {
- local CONFIG=$HOME/.warprc
+ local WD_CONFIG=${WD_CONFIG:-$HOME/.warprc}
local ret=1
local -a commands
local -a warp_points
- warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
+ warp_points=( "${(f)mapfile[$WD_CONFIG]//$HOME/~}" )
typeset -A points
while read -r line
@@ -27,11 +27,12 @@ function _wd() {
target_path=${target_path/#\~/$HOME}
points[$name]=$target_path
- done < $CONFIG
+ done < $WD_CONFIG
commands=(
'add:Adds the current working directory to your warp points'
'add!:Overwrites existing warp point'
+ 'export:Export warp points as static named directories'
'rm:Removes the given warp point'
'list:Outputs all stored warp points'
'ls:Show files from given warp point'
@@ -72,8 +73,12 @@ function _wd() {
_describe -t points "Warp points" warp_points && ret=0
;;
*)
- # complete sub directories from the warp point
- _path_files -W "(${points[$target]})" -/ && ret=0
+ if [[ -v points[$target] ]]; then
+ # complete sub directories from the warp point
+ _path_files -W "(${points[$target]})" -/ && ret=0
+ fi
+
+ # don't complete anything if warp point is not valid
;;
esac
;;
diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh
index c0559293d..87d1d0858 100644
--- a/plugins/wd/wd.plugin.zsh
+++ b/plugins/wd/wd.plugin.zsh
@@ -2,10 +2,9 @@
# WARP DIRECTORY
# ==============
-# oh-my-zsh plugin
+# Jump to custom directories in terminal
+# because `cd` takes too long...
#
# @github.com/mfaerevaag/wd
-wd() {
- . $ZSH/plugins/wd/wd.sh
-}
+eval "wd() { source '${0:A:h}/wd.sh' }"
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index 3d68583f1..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"
@@ -36,11 +36,11 @@ wd_yesorno()
read -r answer
case ${answer:=${default}} in
- Y|y|YES|yes|Yes )
+ "Y"|"y"|"YES"|"yes"|"Yes" )
RETVAL=${yes_RETVAL} && \
break
;;
- N|n|NO|no|No )
+ "N"|"n"|"NO"|"no"|"No" )
RETVAL=${no_RETVAL} && \
break
;;
@@ -71,14 +71,14 @@ wd_print_msg()
wd_print_usage()
{
- cat <<- EOF
+ command cat <<- EOF
Usage: wd [command] [point]
Commands:
+ <point> Warps to the directory specified by the warp point
+ <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
@@ -86,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
@@ -101,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
}
@@ -109,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
}
@@ -117,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
@@ -160,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 =~ "^[\.]+$" ]]
@@ -174,52 +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_print_msg $WD_GREEN "Warp point added"
+ wd_export_static_named_directories
+
+ 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=$WD_CONFIG.tmp
- if sed -n "/^${point}:.*$/!p" $WD_CONFIG > $config_tmp && mv $config_tmp $WD_CONFIG
+ 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
@@ -232,7 +243,7 @@ wd_list_all()
then
max_warp_point_length=$length
fi
- done <<< $entries
+ done <<< "$entries"
while IFS= read -r line
do
@@ -244,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
@@ -280,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
}
@@ -302,7 +313,7 @@ wd_clean() {
local count=0
local wd_tmp=""
- while read line
+ while read -r line
do
if [[ $line != "" ]]
then
@@ -312,29 +323,38 @@ 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
}
-local WD_CONFIG=$HOME/.warprc
+wd_export_static_named_directories() {
+ if [[ ! -z $WD_EXPORT ]]
+ then
+ command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read -r warpdir ; do
+ hash -d "$warpdir"
+ done
+ fi
+}
+
+local WD_CONFIG=${WD_CONFIG:-$HOME/.warprc}
local WD_QUIET=0
local WD_EXIT_CODE=0
local WD_DEBUG=0
@@ -347,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
@@ -360,10 +381,12 @@ 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
# load warp points
@@ -376,72 +399,69 @@ 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
- for o
+ local wd_o
+ for wd_o
do
- case "$o"
+ case "$wd_o"
in
- -a|--add|add)
- wd_add false $2
+ "-a"|"--add"|"add")
+ wd_add "$2" "$wd_force_mode"
break
;;
- -a!|--add!|add!)
- wd_add true $2
+ "-e"|"export")
+ wd_export_static_named_directories
break
;;
- -r|--remove|rm)
- wd_remove $2
+ "-r"|"--remove"|"rm")
+ # Passes all the arguments as a single string separated by whitespace to wd_remove
+ wd_remove "${@:2}"
break
;;
- -l|list)
+ "-l"|"list")
wd_list_all
break
;;
- -ls|ls)
- wd_ls $2
+ "-ls"|"ls")
+ wd_ls "$2"
break
;;
- -p|--path|path)
- wd_path $2
+ "-p"|"--path"|"path")
+ wd_path "$2"
break
;;
- -h|--help|help)
+ "-h"|"--help"|"help")
wd_print_usage
break
;;
- -s|--show|show)
- wd_show $2
- break
- ;;
- -c|--clean|clean)
- wd_clean false
+ "-s"|"--show"|"show")
+ wd_show "$2"
break
;;
- -c!|--clean!|clean!)
- wd_clean true
+ "-c"|"--clean"|"clean")
+ wd_clean "$wd_force_mode"
break
;;
*)
- wd_warp $o $2
+ wd_warp "$wd_o" "$2"
break
;;
--)
@@ -466,12 +486,14 @@ unset wd_print_usage
unset wd_alt_config
unset wd_quiet_mode
unset wd_print_version
+unset wd_export_static_named_directories
+unset wd_o
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 d790d944d..da90f90a0 100644
--- a/plugins/web-search/README.md
+++ b/plugins/web-search/README.md
@@ -37,6 +37,11 @@ Available search contexts are:
| `ecosia` | `https://www.ecosia.org/search?q=` |
| `goodreads` | `https://www.goodreads.com/search?q=` |
| `qwant` | `https://www.qwant.com/?q=` |
+| `givero` | `https://www.givero.com/search?q=` |
+| `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:
@@ -48,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 863384223..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="
@@ -17,11 +18,16 @@ function web_search() {
ecosia "https://www.ecosia.org/search?q="
goodreads "https://www.goodreads.com/search?q="
qwant "https://www.qwant.com/?q="
+ givero "https://www.givero.com/search?q="
+ 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
@@ -51,6 +57,11 @@ alias baidu='web_search baidu'
alias ecosia='web_search ecosia'
alias goodreads='web_search goodreads'
alias qwant='web_search qwant'
+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'
@@ -59,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 45fac0761..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'
@@ -109,9 +75,7 @@ alias wptm='wp theme mod'
alias wptp='wp theme path'
alias wpts='wp theme search'
alias wptst='wp theme status'
-alias wptu='wp theme updatet'
-
-# Transient
+alias wptu='wp theme update'
# User
alias wpuac='wp user add-cap'
@@ -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 671a272d9..fd748b742 100644
--- a/plugins/yarn/README.md
+++ b/plugins/yarn/README.md
@@ -11,29 +11,36 @@ 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 |
-| 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` |
-| 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` |
-| 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 |
+| 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 |
+| 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 382f58a0a..70e783b86 100644
--- a/plugins/yarn/_yarn
+++ b/plugins/yarn/_yarn
@@ -71,7 +71,7 @@ _global_commands=(
'bin:Displays the location of the yarn bin folder'
'remove:Remove installed package from dependencies updating package.json'
'upgrade:Upgrades packages to their latest version based on the specified range'
- 'upgrade-interactive'
+ 'upgrade-interactive:Interactively upgrade packages'
)
_yarn_commands_scripts() {
@@ -81,9 +81,23 @@ _yarn_commands_scripts() {
}
_yarn_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'))
- _describe 'script' scripts
+ local -a commands binaries scripts
+ local -a scriptNames scriptCommands
+ local i runJSON
+
+ runJSON=$(yarn run --json 2>/dev/null)
+ # 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"))
+ scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
+ scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{(.+")\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\'$'\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
+
+ for (( i=1; i <= $#scriptNames; i++ )); do
+ scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
+ done
+
+ commands=($scripts $binaries)
+ _describe 'command' commands
}
_yarn_global_commands() {
@@ -240,7 +254,8 @@ _yarn() {
run)
_arguments \
- '1: :_yarn_scripts'
+ '1: :_yarn_scripts' \
+ '*:: :_default'
;;
tag)
@@ -255,6 +270,11 @@ _yarn() {
'*:: :->team_args'
;;
+ upgrade-interactive)
+ _arguments \
+ '--latest:use the version tagged latest in the registry:'
+ ;;
+
version)
_arguments \
'--new-version:version:' \
@@ -266,6 +286,10 @@ _yarn() {
_arguments \
'1:query:_files'
;;
+
+ *)
+ _default
+ ;;
esac
;;
esac
diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
index 9ed8322cd..4a5192c61 100644
--- a/plugins/yarn/yarn.plugin.zsh
+++ b/plugins/yarn/yarn.plugin.zsh
@@ -4,6 +4,7 @@ alias yad="yarn add --dev"
alias yap="yarn add --peer"
alias yb="yarn build"
alias ycc="yarn cache clean"
+alias yd="yarn dev"
alias yga="yarn global add"
alias ygls="yarn global list"
alias ygrm="yarn global remove"
@@ -11,6 +12,7 @@ alias ygu="yarn global upgrade"
alias yh="yarn help"
alias yi="yarn init"
alias yin="yarn install"
+alias yln="yarn lint"
alias yls="yarn list"
alias yout="yarn outdated"
alias yp="yarn pack"
@@ -19,6 +21,11 @@ alias yrun="yarn run"
alias ys="yarn serve"
alias yst="yarn start"
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"
+alias yws="yarn workspaces"
diff --git a/plugins/yii/README.md b/plugins/yii/README.md
new file mode 100644
index 000000000..9636149ca
--- /dev/null
+++ b/plugins/yii/README.md
@@ -0,0 +1,15 @@
+# Yii plugin
+
+The plugin adds autocomplete commands and subcommands for [yii](https://www.yiiframework.com/).
+
+To use it, add `yii` to the plugins array of your zshrc file:
+
+```zsh
+plugins=(... yii)
+```
+
+## Aliases
+
+| Alias | Command |
+|--------|----------------------|
+| yiic | `protected/yiic` |
diff --git a/plugins/yii2/yii2.plugin.zsh b/plugins/yii2/yii2.plugin.zsh
index e8993adf4..713f2ef2a 100644
--- a/plugins/yii2/yii2.plugin.zsh
+++ b/plugins/yii2/yii2.plugin.zsh
@@ -26,4 +26,4 @@ _yii2 () {
fi
}
-compdef _yii2 yii \ No newline at end of file
+compdef _yii2 yii
diff --git a/plugins/yum/README.md b/plugins/yum/README.md
index 8043421d8..fec584911 100644
--- a/plugins/yum/README.md
+++ b/plugins/yum/README.md
@@ -4,7 +4,7 @@ This plugin adds useful aliases for common [Yum](http://yum.baseurl.org/) comman
To use it, add `yum` to the plugins array in your zshrc file:
-```
+```zsh
plugins=(... yum)
```
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/README.md b/plugins/z/README.md
new file mode 100644
index 000000000..ea8d4610a
--- /dev/null
+++ b/plugins/z/README.md
@@ -0,0 +1,23 @@
+# z - jump around
+
+This plugin defines the [z command](https://github.com/rupa/z) that tracks your most visited directories and allows you to access them with very few keystrokes.
+
+### Example
+Assume that you have previously visited directory `~/.oh-my-zsh/plugins`. From any folder in your command line, you can quickly access it by using a regex match to this folder:
+
+```bash
+/usr/bin$ z plug # Even 'z p' might suffice
+~/.oh-my-zsh/plugins$
+```
+
+### Setup
+To enable z, add `z` to your `plugins` array in your zshrc file:
+
+```zsh
+plugins=(... z)
+```
+
+### Further reading
+
+For advanced usage and details of z, see [README](./README) (in man page format, copied from [rupa/z](https://github.com/rupa/z)).
+
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 4fc75dc6a..13008a60e 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."
@@ -62,7 +65,8 @@ _z() {
# 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 +83,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]
@@ -89,7 +93,7 @@ _z() {
if [ $? -ne 0 -a -f "$datafile" ]; then
env rm -f "$tempfile"
else
- [ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile"
+ [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
fi
@@ -110,20 +114,21 @@ _z() {
else
# list/go
+ local echo fnd last list opt typ
while [ "$1" ]; do case "$1" in
- --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
- -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
- c) local fnd="^$PWD $fnd";;
- e) local echo=1;;
+ --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
+ -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
+ c) fnd="^$PWD $fnd";;
+ e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
- l) local list=1;;
- r) local typ="rank";;
- t) local typ="recent";;
+ l) list=1;;
+ r) typ="rank";;
+ t) typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;;
- *) local fnd="$fnd${fnd:+ }$1";;
- esac; local last=$1; [ "$#" -gt 0 ] && shift; done
- [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
+ *) fnd="$fnd${fnd:+ }$1";;
+ esac; last=$1; [ "$#" -gt 0 ] && shift; done
+ [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
# if we hit enter on a completion just go there
case "$last" in
@@ -137,27 +142,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 ) {
+ 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
}
}
@@ -199,15 +201,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
}
@@ -222,10 +231,12 @@ if type compctl >/dev/null 2>&1; then
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() {
(_z --add "${PWD:a}" &)
+ : $RANDOM
}
else
_z_precmd() {
(_z --add "${PWD:A}" &)
+ : $RANDOM
}
fi
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
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/zeus/README.md b/plugins/zeus/README.md
index 451880049..0131f70d5 100644
--- a/plugins/zeus/README.md
+++ b/plugins/zeus/README.md
@@ -1,56 +1,50 @@
-## zeus
-**Maintainer:** [b4mboo](https://github.com/b4mboo)
-
-* `zi` aliases `zeus init`
-* `zinit` aliases `zeus init`
-
-* `zs` aliases `zeus start`
-* `ztart` aliases `zeus start`
-
-* `zc` aliases `zeus console`
-* `zonsole` aliases `zeus console`
-
-* `zsr` aliases `zeus server`
-* `zerver` aliases `zeus server`
-
-* `zr` aliases `zeus rake`
-* `zake` aliases `zeus rake`
-
-* `zg` aliases `zeus generate`
-* `zenerate` aliases `zeus generate`
-
-* `zrn` aliases `zeus runner`
-* `zunner` aliases `zeus runner`
-
-* `zcu` aliases `zeus cucumber`
-* `zucumber` aliases `zeus cucumber`
-
-* `zspec` aliases `zeus rspec`
-
-* `zt` aliases `zeus test`
-* `zest` aliases `zeus test`
-
-* `zu` aliases `zeus test test/unit/*`
-* `zunits` aliases `zeus test test/unit/*`
-
-* `zf` aliases `zeus test test/functional/*`
-* `zunctional` aliases `zeus test test/functional/*`
-
-* `za` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber`
-* `zall` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber`
-
-* `zsw` aliases `rm .zeus.sock`
-* `zweep` aliases `rm .zeus.sock`
-
-* `zdbr` aliases `zeus rake db:reset db:test:prepare`
-* `zdbreset` aliases `zeus rake db:reset db:test:prepare`
-
-* `zdbm` aliases `zeus rake db:migrate db:test:prepare`
-* `zdbmigrate` aliases `zeus rake db:migrate db:test:prepare`
-
-* `zdbc` aliases `zeus rake db:create`
-
-* `zdbcm` aliases `zeus rake db:create db:migrate db:test:prepare`
-
-## Installation
-Add zeus to the plugins line of your `.zshconfig` file (e.g. `plugins=(rails git zeus)`)
+# zeus plugin
+
+[Zeus](https://github.com/burke/zeus) preloads your Rails environment and forks that
+process whenever needed. This effectively speeds up Rails' boot process to under 1 sec.
+This plugin adds autocompletion for zeus and aliases for common usage.
+
+To use it, add `zeus` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... zeus)
+```
+
+You also need to have the `zeus` gem installed.
+
+| Alias | Command |
+|:-------------|:-------------------------------------------------------------------|
+| _zi_ | `zeus init` |
+| _zinit_ | `zeus init` |
+| _zs_ | `zeus start` |
+| _ztart_ | `zeus start` |
+| _zc_ | `zeus console` |
+| _zonsole_ | `zeus console` |
+| _zsr_ | `zeus server` |
+| _zerver_ | `zeus server` |
+| _zr_ | `noglob zeus rake` |
+| _zake_ | `noglob zeus rake` |
+| _zg_ | `zeus generate` |
+| _zenerate_ | `zeus generate` |
+| _zrn_ | `zeus runner` |
+| _zunner_ | `zeus runner` |
+| _zcu_ | `zeus cucumber` |
+| _zucumber_ | `zeus cucumber` |
+| _zwip_ | `zeus cucumber --profile wip` |
+| _zspec_ | `zeus rspec` |
+| _zt_ | `zeus test` |
+| _zest_ | `zeus test` |
+| _zu_ | `zeus test test/unit/*` |
+| _zunits_ | `zeus test test/unit/*` |
+| _zf_ | `zeus test test/functional/*` |
+| _zunctional_ | `zeus test test/functional/*` |
+| _za_ | `zeus test test/unit/*; zeus test test/functional/; zeus cucumber` |
+| _zall_ | `zeus test test/unit/*; zeus test test/functional/; zeus cucumber` |
+| _zsw_ | `rm .zeus.sock` |
+| _zweep_ | `rm .zeus.sock` |
+| _zdbr_ | `zeus rake db:reset db:test:prepare` |
+| _zdbreset_ | `zeus rake db:reset db:test:prepare` |
+| _zdbm_ | `zeus rake db:migrate db:test:prepare` |
+| _zdbmigrate_ | `zeus rake db:migrate db:test:prepare` |
+| _zdbc_ | `zeus rake db:create` |
+| _zdbcm_ | `zeus rake db:create db:migrate db:test:prepare` |
diff --git a/plugins/zeus/zeus.plugin.zsh b/plugins/zeus/zeus.plugin.zsh
index 0c01083a5..5dec1a48c 100644
--- a/plugins/zeus/zeus.plugin.zsh
+++ b/plugins/zeus/zeus.plugin.zsh
@@ -33,6 +33,7 @@ alias zunner='zeus runner'
# Cucumber
alias zcu='zeus cucumber'
alias zucumber='zeus cucumber'
+alias zwip='zeus cucumber --profile wip'
# Rspec
alias zspec='zeus rspec'
diff --git a/plugins/zsh-interactive-cd/README.md b/plugins/zsh-interactive-cd/README.md
new file mode 100644
index 000000000..c8337fbc8
--- /dev/null
+++ b/plugins/zsh-interactive-cd/README.md
@@ -0,0 +1,23 @@
+# zsh-interactive-cd
+
+This plugin adds a fish-like interactive tab completion for the `cd` command.
+
+To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file:
+```zsh
+plugins=(... zsh-interactive-cd)
+```
+
+![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif)
+
+## Usage
+
+Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
+
+## Requirements
+
+This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following
+its [installation instructions](https://github.com/junegunn/fzf#installation).
+
+## Author
+
+[Henry Chang](https://github.com/changyuheng)
diff --git a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
new file mode 100644
index 000000000..b0520c239
--- /dev/null
+++ b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
@@ -0,0 +1,148 @@
+# Copyright (c) 2017 Henry Chang
+
+__zic_fzf_prog() {
+ [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
+ && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
+}
+
+__zic_matched_subdir_list() {
+ local dir length seg starts_with_dir
+ if [[ "$1" == */ ]]; then
+ dir="$1"
+ if [[ "$dir" != / ]]; then
+ dir="${dir: : -1}"
+ fi
+ length=$(echo -n "$dir" | wc -c)
+ if [ "$dir" = "/" ]; then
+ length=0
+ fi
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
+ | cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
+ if [[ "${line[1]}" == "." ]]; then
+ continue
+ fi
+ echo "$line"
+ done
+ else
+ dir=$(dirname -- "$1")
+ length=$(echo -n "$dir" | wc -c)
+ if [ "$dir" = "/" ]; then
+ length=0
+ fi
+ seg=$(basename -- "$1")
+ starts_with_dir=$( \
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
+ 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
+ | while read -r line; do
+ if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
+ continue
+ fi
+ if [[ "$line" == "$seg"* ]]; then
+ echo "$line"
+ fi
+ done
+ )
+ if [ -n "$starts_with_dir" ]; then
+ echo "$starts_with_dir"
+ else
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
+ 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
+ | while read -r line; do
+ if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
+ continue
+ fi
+ if [[ "$line" == *"$seg"* ]]; then
+ echo "$line"
+ fi
+ done
+ fi
+ fi
+}
+
+_zic_list_generator() {
+ __zic_matched_subdir_list "${(Q)@[-1]}" | sort
+}
+
+_zic_complete() {
+ setopt localoptions nonomatch
+ local l matches fzf tokens base
+
+ l=$(_zic_list_generator $@)
+
+ if [ -z "$l" ]; then
+ zle ${__zic_default_completion:-expand-or-complete}
+ return
+ fi
+
+ fzf=$(__zic_fzf_prog)
+
+ if [ $(echo $l | wc -l) -eq 1 ]; then
+ matches=${(q)l}
+ else
+ matches=$(echo $l \
+ | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
+ --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
+ --bind 'shift-tab:up,tab:down'" ${=fzf} \
+ | while read -r item; do
+ echo -n "${(q)item} "
+ done)
+ fi
+
+ matches=${matches% }
+ if [ -n "$matches" ]; then
+ tokens=(${(z)LBUFFER})
+ base="${(Q)@[-1]}"
+ if [[ "$base" != */ ]]; then
+ if [[ "$base" == */* ]]; then
+ base="$(dirname -- "$base")"
+ if [[ ${base[-1]} != / ]]; then
+ base="$base/"
+ fi
+ else
+ base=""
+ fi
+ fi
+ LBUFFER="${tokens[1]} "
+ if [ -n "$base" ]; then
+ base="${(q)base}"
+ if [ "${tokens[2][1]}" = "~" ]; then
+ base="${base/#$HOME/~}"
+ fi
+ LBUFFER="${LBUFFER}${base}"
+ fi
+ LBUFFER="${LBUFFER}${matches}/"
+ fi
+ zle redisplay
+ typeset -f zle-line-init >/dev/null && zle zle-line-init
+}
+
+zic-completion() {
+ setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
+ local tokens cmd
+
+ tokens=(${(z)LBUFFER})
+ cmd=${tokens[1]}
+
+ if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then
+ zle ${__zic_default_completion:-expand-or-complete}
+ elif [ "$cmd" = cd ]; then
+ _zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
+ else
+ zle ${__zic_default_completion:-expand-or-complete}
+ fi
+}
+
+[ -z "$__zic_default_completion" ] && {
+ binding=$(bindkey '^I')
+ # $binding[(s: :w)2]
+ # The command substitution and following word splitting to determine the
+ # default zle widget for ^I formerly only works if the IFS parameter contains
+ # a space via $binding[(w)2]. Now it specifically splits at spaces, regardless
+ # of IFS.
+ [[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2]
+ unset binding
+}
+
+zle -N zic-completion
+bindkey -M emacs '^I' zic-completion
+bindkey -M viins '^I' zic-completion
diff --git a/plugins/zsh-navigation-tools/LICENSE b/plugins/zsh-navigation-tools/LICENSE
index 4ee028112..075c80ccd 100644
--- a/plugins/zsh-navigation-tools/LICENSE
+++ b/plugins/zsh-navigation-tools/LICENSE
@@ -27,7 +27,7 @@ GPLv3 License
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -671,7 +671,7 @@ the "copyright" line and a pointer to where the full notice is found.
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, see <https://www.gnu.org/licenses/>.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -690,11 +690,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
-<https://www.gnu.org/licenses/>.
+<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
-<https://www.gnu.org/philosophy/why-not-lgpl.html>.
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/plugins/zsh-navigation-tools/Makefile b/plugins/zsh-navigation-tools/Makefile
new file mode 100644
index 000000000..f34af0cc3
--- /dev/null
+++ b/plugins/zsh-navigation-tools/Makefile
@@ -0,0 +1,35 @@
+NAME=zsh-navigation-tools
+
+INSTALL?=install -c
+PREFIX?=/usr/local
+SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME)
+DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME)
+
+all:
+
+install:
+ $(INSTALL) -d $(SHARE_DIR)
+ $(INSTALL) -d $(SHARE_DIR)/.config
+ $(INSTALL) -d $(SHARE_DIR)/.config/znt
+ $(INSTALL) -d $(DOC_DIR)
+ cp zsh-navigation-tools.plugin.zsh _n-kill doc/znt-tmux.zsh $(SHARE_DIR)
+ cp README.md NEWS LICENSE doc/img/n-history2.png $(DOC_DIR)
+ if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \
+ git rev-parse HEAD; \
+ else \
+ cat .revision-hash; \
+ fi > $(SHARE_DIR)/.revision-hash
+ :
+ for fname in n-*; do cp "$$fname" $(SHARE_DIR); done; \
+ for fname in znt-*; do cp "$$fname" $(SHARE_DIR); done; \
+ for fname in .config/znt/n-*; do cp "$$fname" $(SHARE_DIR)/.config/znt; done;
+
+uninstall:
+ rm -f $(SHARE_DIR)/.revision-hash $(SHARE_DIR)/_* $(SHARE_DIR)/zsh-* $(SHARE_DIR)/n-* $(SHARE_DIR)/znt-* $(SHARE_DIR)/.config/znt/n-*
+ [ -d $(SHARE_DIR)/.config/znt ] && rmdir $(SHARE_DIR)/.config/znt || true
+ [ -d $(SHARE_DIR)/.config ] && rmdir $(SHARE_DIR)/.config || true
+ [ -d $(SHARE_DIR) ] && rmdir $(SHARE_DIR) || true
+ rm -f $(DOC_DIR)/README.md $(DOC_DIR)/LICENSE $(DOC_DIR)/n-history2.png
+ [ -d $(DOC_DIR) ] && rmdir $(DOC_DIR) || true
+
+.PHONY: all install uninstall
diff --git a/plugins/zsh-navigation-tools/README.md b/plugins/zsh-navigation-tools/README.md
index ed532a161..7d2ce99f4 100644
--- a/plugins/zsh-navigation-tools/README.md
+++ b/plugins/zsh-navigation-tools/README.md
@@ -1,58 +1,68 @@
+[![License (GPL version 3)](https://img.shields.io/badge/license-GNU%20GPL%20version%203-blue.svg?style=flat-square)](./LICENSE)
+[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](./LICENSE)
+![ZSH 5.0.0](https://img.shields.io/badge/zsh-v5.0.0-orange.svg?style=flat-square)
+
+![znt logo](http://imageshack.com/a/img905/2629/WK9qjN.png)
+
+[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D6XDCHDSBDSDG)
+
# Zsh Navigation Tools
-https://raw.githubusercontent.com/psprint/zsh-navigation-tools/master/doc/img/n-history2.png
+Also check out [![ZCA](http://imageshack.com/a/img911/8084/qSpO8a.png) Zsh Command Architect](https://github.com/psprint/zsh-cmd-architect)
+and [Zconvey](https://github.com/psprint/zconvey)
-Set of tools like n-history – multi-word history searcher, n-cd – directory
-bookmark manager, n-kill – htop like kill utility, and more. Based on
-n-list, a tool generating selectable curses-based list of elements that has
-access to current Zsh session, i.e. has broad capabilities to work together
-with it. Feature highlights include incremental multi-word searching, ANSI
-coloring, unique mode, horizontal scroll, non-selectable elements, grepping and
-various integrations with Zsh.
-## History Widget
-To have n-history as multi-word incremental searcher bound to Ctrl-R copy znt-*
-files into the */site-functions dir (unless you use Oh My Zsh) and
-add:
+Videos:
+- [https://youtu.be/QwZ8IJEgXRE](https://youtu.be/QwZ8IJEgXRE)
+- [https://youtu.be/DN9QqssAYB8](https://youtu.be/DN9QqssAYB8)
- autoload znt-history-widget
- zle -N znt-history-widget
- bindkey "^R" znt-history-widget
+Screenshots:
-to .zshrc. This is done automatically when using Oh My Zsh. Two other
-widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned
-to key combinations (no need for autoload when using Oh My Zsh):
+![n-history](http://imageshack.com/a/img921/5046/bqr0mk.png)
- zle -N znt-cd-widget
- bindkey "^A" znt-cd-widget
- zle -N znt-kill-widget
- bindkey "^Y" znt-kill-widget
+![n-history](http://imageshack.com/a/img633/9905/WzfSdl.gif)
-Oh My Zsh stores history into ~/.zsh_history. When you switch to OMZ you could
-want to copy your previous data (from e.g. ~/.zhistory) into the new location.
+Set of tools like `n-history` – multi-word history searcher, `n-cd` – directory
+bookmark manager, `n-kill` – `htop` like kill utility, and more. Based on
+`n-list`, a tool generating selectable curses-based list of elements that has
+access to current `Zsh` session, i.e. has broad capabilities to work together
+with it. Feature highlights include incremental multi-word searching, approximate
+matching, ANSI coloring, themes, unique mode, horizontal scroll, grepping, advanced
+history management and various integrations with `Zsh`.
## News
-
* 06-10-2016
- - Tmux-integration – Ctrl-b-h in Tmux to open n-history in new window.
+ - **Tmux-integration** – `Ctrl-B H` in Tmux to open `n-history` in new window.
Then select history entry, it will be copied to the original Tmux window.
- Use this to execute local commands on remote hosts. All that is needed is
- this line added to ~/.tmux.conf:
+ Use this to execute local commands on remote hosts:
+ ![tmux integration](http://imageshack.com/a/img922/4760/oyX7eN.gif)
+
+ All that is needed is this line added to `~/.tmux.conf`:
+
+ ```
+ bind h run-shell -b "$ZNT_REPO_DIR/doc/znt-tmux.zsh"
+ ```
+
+ or – if Homebrew or other package manager is used:
+
+ ```
bind h run-shell -b "$ZNT_REPO_DIR/znt-tmux.zsh"
+ ```
* 16-05-2016
- - n-kill has completion. It proposes *words* from what's in `ps -A`. Giving n-kill
+ - `n-kill` has completion. It proposes **words** from what's in `ps -A`. Giving `n-kill`
arguments means grepping – it will start only with matching `ps` entries.
* 15-05-2016
- - Fixed problem where zsh-syntax-highlighting could render n-history slow (for
+ - Fixed problem where zsh-syntax-highlighting could render `n-history` slow (for
long history entries).
* 14-05-2016
- - Configuration can be set from zshrc. Example:
+ - Configuration can be set from `zshrc` (starting from `v2.1.12`). Documentation is [below](#configuration). Example:
+ ```zsh
znt_list_instant_select=1
znt_list_border=0
znt_list_bold=1
@@ -63,76 +73,197 @@ want to copy your previous data (from e.g. ~/.zhistory) into the new location.
znt_cd_hotlist=( "~/.config/znt" "/usr/share/zsh/site-functions" "/usr/share/zsh"
"/usr/local/share/zsh/site-functions" "/usr/local/share/zsh"
"/usr/local/bin" )
+ ```
* 10-05-2016
- - Search query rotation – use Ctrl-A to rotate entered words right.
+ - Search query rotation – use `Ctrl-A` to rotate entered words right.
Words `1 2 3` become `3 1 2`.
* 09-05-2016
- - New feature: n-help tool, available also from n-history via H key. It
- displays help screen with various information on ZNT.
+ - New feature: n-help tool, available also from n-history via `H` key. It
+ displays help screen with various information on `ZNT`.
+
+ ![n-help](http://imageshack.com/a/img922/7595/MvtJdI.gif)
* 08-05-2016
- - Approximate matching – pressing f or Ctrl-F will enter FIX mode, in
- which 1 or 2 errors are allowed in what is searched. This utilizes
+ - Approximate matching – pressing `f` or `Ctrl-F` will enter "`FIX`" mode,
+ in which `1` or `2` errors are allowed in what's searched. This utilizes
original Zsh approximate matching features and is intended to be used
after entering search query, when a typo is discovered.
+ ![fix mode](http://imageshack.com/a/img921/5756/64lFnv.gif)
+
* 06-05-2016
- - Private history can be edited. Use e key or Ctrl-E for that when in
- n-history. Your $EDITOR will start. This is a way to have handy set
- of bookmarks prepared in private history's file.
- - Border can be disabled. Use following snippet in ~/.config/znt/n-list.conf
+ - Private history can be edited. Use `e` key or `Ctrl-E` for that when in
+ n-history. Your `$EDITOR` will start. This is a way to have handy set of
+ bookmarks prepared in private history's file.
+ - Border can be disabled. Use following snippet in `~/.config/znt/n-list.conf`
or any other tool-targetted config file:
+ ```zsh
# Should draw the border?
local border=0
+ ```
* 30-04-2016
- - New feature: color themes. Use Ctrl-T and Ctrl-G to browse predefined
- themes. They are listed in ~/.config/znt/n-list.conf. Use the file to
- permanently set a color scheme. Also, I sent a patch to Zsh developers
+ - New feature: color themes. Use `Ctrl-T` and `Ctrl-G` to browse predefined
+ themes. They are listed in [~/.config/znt/n-list.conf](https://github.com/psprint/zsh-navigation-tools/blob/master/.config/znt/n-list.conf).
+ Use the file to permanently set a color scheme. Also, I sent a patch to Zsh developers
and starting from Zsh > 5.2 (not yet released) supported will be 256 colors.
- The file ~/.config/znt/n-list.conf already has set of 256-color themes prepared :)
+ The file [~/.config/znt/n-list.conf](https://github.com/psprint/zsh-navigation-tools/blob/master/.config/znt/n-list.conf)
+ already has set of 256-color themes prepared :)
+
+ ![themes](http://imageshack.com/a/img924/4310/EbRh30.gif)
* 29-04-2016
- New feature: private history – n-history tracks selected history entries,
- exposes them via new view (activated with F1)
+ exposes them via new view (activated with `F1`). It is shared across all
+ sessions
* 28-04-2016
- New features:
- 1. New n-history view (activated with F1): Most Frequent History Words
+ 1. New n-history view (activated with `F1`): Most Frequent History Words
2. Predefined search keywords – use F2 to quickly search for chosen
keywords (video: [https://youtu.be/DN9QqssAYB8](https://youtu.be/DN9QqssAYB8))
3. Configuration option for doing instant selection in search mode
+## Installation
+
+```
+sh -c "$(curl -fsSL https://raw.githubusercontent.com/psprint/zsh-navigation-tools/master/doc/install.sh)"
+```
+
+To update run the command again.
+
+`ZNT` will be installed at `~/.config/znt/zsh-navigation-tools`, config files will be copied to `~/.config/znt`. `.zshrc`
+will be updated with only `8` lines of code, which will be added at the bottom.
+
+After installing and reloading shell give `ZNT` a quick try with `Ctrl-R` – this keyboard shortcut will open `n-history`.
+
+## Installation With [Zplugin](https://github.com/psprint/zplugin)
+Add `zplugin load psprint/zsh-navigation-tools` to `.zshrc`. The config files will be in `~/.config/znt`.
+
+## Installation With Zgen
+
+Add `zgen load psprint/zsh-navigation-tools` to `.zshrc` and issue a `zgen reset` (this assumes that there is a proper `zgen save` construct in `.zshrc`).
+The config files will be available in `~/.config/znt`.
+
+## Installation With Antigen
+Add `antigen bundle psprint/zsh-navigation-tools` to `.zshrc`. There also
+should be `antigen apply`. The config files will be in `~/.config/znt`.
+
+## Single File Manual Installation
+
+Running script `doc/generate_single_file` will create single-file version of `ZNT`.
+It can be sourced from `.zshrc`. Don't forget about configuration files as described
+above.
+
+## Manual Installation
+
+After extracting `ZNT` to `{some-directory}` add following two lines
+to `~/.zshrc`:
+
+```zsh
+fpath+=( {some-directory} )
+source "{some-directory}/zsh-navigation-tools.plugin.zsh"
+```
+
+As you can see, no plugin manager is needed to use the `*.plugin.zsh`
+file. The above two lines of code are all that almost **all** plugin
+managers do. In fact, what's actually needed is only:
+
+```zsh
+source "{some-directory}/zsh-navigation-tools.plugin.zsh"
+```
+
+because `ZNT` detects if it is used by **any** plugin manager and can
+handle `$fpath` update by itself.
+
+## Truly Manual Installation
+Copy (or link) all `n-*` and `znt-*` files to **/usr/share/zsh/site-functions/**
+(or **/usr/local/share/zsh/site-functions/**, check with `echo $fpath[1]`) and then add:
+
+ autoload n-list n-cd n-env n-kill n-panelize n-options n-aliases n-functions n-history n-help
+
+to `~/.zshrc`.
+
+Create aliases to avoid typing of the minus sign "-":
+
+```zsh
+alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history
+alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help
+```
+
+Don't forget to copy [configuration files](https://github.com/psprint/zsh-navigation-tools/tree/master/.config/znt). They should go to `~/.config/znt`. Moreover, `n-cd` works together with option `AUTO_PUSHD` and you should have:
+
+```zsh
+setopt AUTO_PUSHD
+```
+
+in `.zshrc` (also recommend `PUSHD_IGNORE_DUPS`). Without the option `n-cd`
+will just work as incremental searcher of directory bookmarks.
+
+## History Widget
+
+To have `n-history` as the incremental searcher bound to `Ctrl-R` copy `znt-*`
+files into the `*/site-functions` dir (unless you do single file install) and
+add:
+
+```zsh
+autoload znt-history-widget
+zle -N znt-history-widget
+bindkey "^R" znt-history-widget
+```
+
+to `.zshrc`. This is done automatically when using the installer, zgen, antigen
+or single file install. Two other widgets exist, `znt-cd-widget` and
+`znt-kill-widget`, they too can be assigned to key combinations (`autoload` is done
+in `.zshrc` so no need of it):
+
+```zsh
+zle -N znt-cd-widget
+bindkey "^B" znt-cd-widget
+zle -N znt-kill-widget
+bindkey "^Y" znt-kill-widget
+```
+
## Introduction
The tools are:
-- n-aliases - browses aliases, relegates editing to vared
-- n-cd - browses dirstack and bookmarked directories, allows to enter selected directory
-- n-functions - browses functions, relegates editing to zed or vared
-- n-history - browses history, allows to edit and run commands from it
-- n-kill - browses processes list, allows to send signal to selected process
-- n-env - browses environment, relegates editing to vared
-- n-options - browses options, allows to toggle their state
-- n-panelize - loads output of given command into the list for browsing
-
-All tools support horizontal scroll with <,>, {,}, h,l or left and right
-cursors. Other keys are:
-
-- [,] - jump directory bookmarks in n-cd and typical signals in n-kill
-- Ctrl-d, Ctrl-u - half page up or down
-- Ctrl-p, Ctrl-n - previous and next (also done with vim's j,k)
-- Ctrl-l - redraw of whole display
-- g, G - beginning and end of the list
-- Ctrl-o, o - enter uniq mode (no duplicate lines)
-- / - start incremental search
-- Enter - finish incremental search, retaining filter
-- Esc - exit incremental search, clearing filter
-- Ctrl-w (in incremental search) - delete whole word
-- Ctrl-k (in incremental search) - delete whole line
+- `n-aliases` - browses aliases, relegates editing to `vared`
+- `n-cd` - browses dirstack and bookmarked directories, allows to enter selected directory
+- `n-functions` - browses functions, relegates editing to `zed` or `vared`
+- `n-history` - browses history, allows to edit and run commands from it
+- `n-kill` - browses processes list, allows to send signal to selected process
+- `n-env` - browses environment, relegates editing to `vared`
+- `n-options` - browses options, allows to toggle their state
+- `n-panelize` - loads output of given command into the list for browsing
+
+All tools support horizontal scroll with `<`,`>`, `{`,`}`, `h`,`l` or left and right cursors. Other keys are:
+
+- `H`, `?` (from n-history) - run n-help
+- `Ctrl-R` - start n-history, the incremental, multi-keyword history searcher (Zsh binding)
+- `Ctrl-A` - rotate entered words (1+2+3 -> 3+1+2)
+- `Ctrl-F` - fix mode (approximate matching)
+- `Ctrl-L` - redraw of whole display
+- `Ctrl-T` - browse themes (next theme)
+- `Ctrl-G` - browse themes (previous theme)
+- `Ctrl-U` - half page up
+- `Ctrl-D` - half page down
+- `Ctrl-P` - previous element (also done with vim's k)
+- `Ctrl-N` - next element (also done with vim's j)
+- `[`, `]` - jump directory bookmarks in n-cd and typical signals in n-kill
+- `g`, `G` - beginning and end of the list
+- `/` - show incremental search
+- `F3` - show/hide incremental search
+- `Esc` - exit incremental search, clearing filter
+- `Ctrl-W` (in incremental search) - delete whole word
+- `Ctrl-K` (in incremental search) - delete whole line
+- `Ctrl-O`, `o` - enter uniq mode (no duplicate lines)
+- `Ctrl-E`, `e` - edit private history (when in private history view)
+- `F1` - (in n-history) - switch view
+- `F2`, `Ctrl-X`, `Ctrl-/` - search predefined keywords (defined in config files)
## Configuration
@@ -177,7 +308,7 @@ znt_history_active_text - underline or reverse - how should be active element hi
znt_history_nlist_coloring_pattern - pattern that can be used to colorize elements
znt_history_nlist_coloring_color - color with which to colorize
znt_history_nlist_coloring_match_multiple - should multiple matches be colorized (0 or 1)
-znt_history_keywords (array) - search keywords activated with `Ctrl-X`
+znt_history_keywords (array) - search keywords activated with `Ctrl-X`, `F2` or `Ctrl-/`, e.g. ( "git" "vim" )
```
Above variables will work for `n-history` tool. For other tools, change `_history_` to
@@ -193,52 +324,108 @@ znt_list_themes (array) - list of themes to try out with Ctrl-T, e.g. ( "white/b
znt_list_instant_select - should pressing enter in search mode leave tool (0 or 1)
```
+If you used `ZNT` before `v2.1.12`, remove old configuration files `~/.config/znt/*.conf` so that `ZNT`
+can update them to the latest versions that support integration with `Zshrc`. If you used installer
+then run it again (after the remove of configuration files).
+
## Programming
-The function n-list is used as follows:
+The function `n-list` is used as follows:
- n-list {element1} [element2] ... [elementN]
+```zsh
+n-list {element1} [element2] ... [elementN]
+```
This is all that is needed to be done to have the features like ANSI coloring,
incremental multi-word search, unique mode, horizontal scroll, non-selectable
-elements (grepping is done outside n-list, see the tools for how it can be
+elements (grepping is done outside `n-list`, see the tools for how it can be
done). To set up non-selectable entries add their indices into array
-NLIST_NONSELECTABLE_ELEMENTS:
+`NLIST_NONSELECTABLE_ELEMENTS`:
- typeset -a NLIST_NONSELECTABLE_ELEMENTS
- NLIST_NONSELECTABLE_ELEMENTS=( 1 )
+```zsh
+typeset -a NLIST_NONSELECTABLE_ELEMENTS
+NLIST_NONSELECTABLE_ELEMENTS=( 1 )
+```
-Result is stored as $reply[REPLY] ($ isn't needed before REPLY because
-of arithmetic context inside []). The returned array might be different from
-input arguments as n-list can process them via incremental search or uniq
-mode. $REPLY is the index in that possibly processed array. If $REPLY
-equals -1 it means that no selection have been made (user quitted via q
+Result is stored as `$reply[REPLY]` (`$` isn't needed before `REPLY` because
+of arithmetic context inside `[]`). The returned array might be different from
+input arguments as `n-list` can process them via incremental search or uniq
+mode. `$REPLY` is the index in that possibly processed array. If `$REPLY`
+equals `-1` it means that no selection have been made (user quitted via `q`
key).
-To set up entries that can be jumped to with [,] keys add their indices to
-NLIST_HOP_INDEXES array:
+To set up entries that can be jumped to with `[`,`]` keys add their indices to
+`NLIST_HOP_INDEXES` array:
- typeset -a NLIST_HOP_INDEXES
- NLIST_HOP_INDEXES=( 1 10 )
+```zsh
+typeset -a NLIST_HOP_INDEXES
+NLIST_HOP_INDEXES=( 1 10 )
+```
-n-list can automatically colorize entries according to a Zsh pattern.
+`n-list` can automatically colorize entries according to a `Zsh` pattern.
Following example will colorize all numbers with blue:
- local NLIST_COLORING_PATTERN="[0-9]##"
- local NLIST_COLORING_COLOR=$'\x1b[00;34m'
- local NLIST_COLORING_END_COLOR=$'\x1b[0m'
- local NLIST_COLORING_MATCH_MULTIPLE=1
- n-list "This is a number 123" "This line too has a number: 456"
+```zsh
+local NLIST_COLORING_PATTERN="[0-9]##"
+local NLIST_COLORING_COLOR=$'\x1b[00;34m'
+local NLIST_COLORING_END_COLOR=$'\x1b[0m'
+local NLIST_COLORING_MATCH_MULTIPLE=1
+
+n-list "This is a number 123" "This line too has a number: 456"
+```
-Blue is the default color, it doesn't have to be set. See zshexpn man page
-for more information on Zsh patterns. Briefly, comparing to regular
-expressions, (#s) is ^, (#e) is $, # is *, ## is +. Alternative
-will work when in parenthesis, i.e. (a|b). BTW by using this method you can
+Blue is the default color, it doesn't have to be set. See `zshexpn` man page
+for more information on `Zsh` patterns. Briefly, comparing to regular
+expressions, `(#s)` is `^`, `(#e)` is `$`, `#` is `*`, `##` is `+`. Alternative
+will work when in parenthesis, i.e. `(a|b)`. BTW by using this method you can
colorize output of the tools, via their config files (check out e.g. n-cd.conf,
-it uses this).
+it is using this).
## Performance
-ZNT are fastest with Zsh before 5.0.6 and starting from 5.2
+`ZNT` are fastest with `Zsh` before `5.0.6` and starting from `5.2`
+
+## A tip
+
+Zsh plugins may look scary, as they seem to have some "architecture". In fact, what a plugin really is, is that:
+
+1. It has its directory added to `fpath`
+2. It has any first `*.plugin.zsh` file sourced
+
+That's it. When one contributes to Oh-My-Zsh or creates a plugin for any plugin manager, he only needs to account for this.
+The same with doing any non-typical Zsh Navigation Tools installation.
+
+## More
+
+- be aware of [this](https://github.com/psprint/zsh-navigation-tools/blob/f49f910d239ae5bc6e1a5bb34930307b4f4e3ffe/zsh-navigation-tools.plugin.zsh#L35-L49)
+
+## IRC Channel
+
+Channel `#zplugin@freenode` is a support place for all author's projects. Connect to:
+[chat.freenode.net:6697](ircs://chat.freenode.net:6697/%23zplugin) (SSL) or [chat.freenode.net:6667](irc://chat.freenode.net:6667/%23zplugin)
+ and join #zplugin.
+
+Following is a quick access via Webchat [![IRC](https://kiwiirc.com/buttons/chat.freenode.net/zplugin.png)](https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin)
+
+# Fixing tmux, screen and linux vt
+
+If `TERM=screen-256color` (often a case for `tmux` and `screen` sessions) then
+`ncv` terminfo capability will have `2`nd bit set. This in general means that
+underline won't work. To fix this by creating your own `ncv=0`-equipped
+terminfo file, run:
+
+```zsh
+{ infocmp -x screen-256color; printf '\t%s\n' 'ncv@,'; } > /tmp/t && tic -x /tmp/t
+```
+
+A file will be created in directory `~/.terminfo` and will be automatically
+used, `tmux` and `screen` will work. Similar is for Linux virtual terminal:
+
+```zsh
+{ infocmp -x linux; printf '\t%s\n' 'ncv@,'; } > /tmp/t && tic -x /tmp/t
+```
+
+It will not display underline properly, but will instead highlight by a color,
+which is quite nice. The same will not work for FreeBSD's vt, `ZNT` will detect
+if that vt is used and will revert to highlighting elements via `reverse` mode.
-vim:filetype=conf
diff --git a/plugins/zsh-navigation-tools/_n-kill b/plugins/zsh-navigation-tools/_n-kill
index 6f5d47971..9da68b9ec 100644
--- a/plugins/zsh-navigation-tools/_n-kill
+++ b/plugins/zsh-navigation-tools/_n-kill
@@ -10,8 +10,8 @@ integer cygwin=0
local IFS="
"
-case "$OSTYPE" in
- cygwin*) list=( `command ps -Wa` ); cygwin=1 ;;
+case "$(uname)" in
+ CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;;
*) list=( `command ps -o pid,uid,command -A` ) ;;
esac
@@ -36,6 +36,6 @@ for line in "${list[@]}"; do
done
_wanted bits expl "Processes' name bits" \
- compadd "$@" -a - words && ret=0
+ compadd -M 'm:{a-z}={A-Z}' "$@" -a - words && ret=0
return "$ret"
diff --git a/plugins/zsh-navigation-tools/n-kill b/plugins/zsh-navigation-tools/n-kill
index 76050f969..0d10565e4 100644
--- a/plugins/zsh-navigation-tools/n-kill
+++ b/plugins/zsh-navigation-tools/n-kill
@@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 )
type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 }
-case "$OSTYPE" in
- cygwin*) list=( `command ps -Wa` ) ;;
+case "$(uname)" in
+ CYGWIN*) list=( `command ps -Wa` ) ;;
*) list=( `command ps -o pid,uid,command -A` ) ;;
esac
diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list
index 3fe5542a6..f25db8f60 100644
--- a/plugins/zsh-navigation-tools/n-list
+++ b/plugins/zsh-navigation-tools/n-list
@@ -261,6 +261,8 @@ done
last_element="$#list"
+zcurses clear main redraw
+zcurses clear inner redraw
while (( 1 )); do
# Do searching (filtering with string)
if [ -n "$NLIST_SEARCH_BUFFER" ]; then
diff --git a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
index 32b4ca064..f015620f5 100644
--- a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
+++ b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
@@ -1,10 +1,31 @@
#!/usr/bin/env zsh
-0="${(%):-%N}" # this gives immunity to functionargzero being unset
-export ZNT_REPO_DIR="${0%/*}"
+#
+# No plugin manager is needed to use this file. All that is needed is adding:
+# source {where-znt-is}/zsh-navigation-tools.plugin.zsh
+#
+# to ~/.zshrc.
+#
+
+# According to the standard:
+# http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+export ZNT_REPO_DIR="${0:h}"
export ZNT_CONFIG_DIR="$HOME/.config/znt"
#
+# Update FPATH if:
+# 1. Not loading with a plugin manager
+# 2. Not having fpath already updated
+#
+
+if [[ ${zsh_loaded_plugins[-1]} != */zsh-navigation-tools && -z ${fpath[(r)${0:h}]} ]]
+then
+ fpath+=( "${0:h}" )
+fi
+
+#
# Copy configs
#
diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
index 51048ba9d..0d29a7ce3 100644
--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
+++ b/plugins/zsh_reload/zsh_reload.plugin.zsh
@@ -3,10 +3,20 @@ src() {
autoload -U compinit zrecompile
compinit -i -d "$cache/zcomp-$HOST"
- for f in ~/.zshrc "$cache/zcomp-$HOST"; do
+ for f in ${ZDOTDIR:-~}/.zshrc "$cache/zcomp-$HOST"; do
zrecompile -p $f && command rm -f $f.zwc.old
done
- # Use $SHELL if available; remove leading dash if login shell
- [[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
+ # Use $SHELL if it's available and a zsh shell
+ local shell="$ZSH_ARGZERO"
+ if [[ "${${SHELL:t}#-}" = zsh ]]; then
+ shell="$SHELL"
+ fi
+
+ # Remove leading dash if login shell and run accordingly
+ if [[ "${shell:0:1}" = "-" ]]; then
+ exec -l "${shell#-}"
+ else
+ exec "$shell"
+ fi
}
diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
index 7cd2a873b..65d5ea65b 100644
--- a/templates/zshrc.zsh-template
+++ b/templates/zshrc.zsh-template
@@ -7,12 +7,12 @@ export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
-# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
+# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
-# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
+# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
@@ -26,9 +26,15 @@ ZSH_THEME="robbyrussell"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
+# Uncomment the following line to automatically update without prompting.
+# DISABLE_UPDATE_PROMPT="true"
+
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
+# Uncomment the following line if pasting URLs and other text is messed up.
+# DISABLE_MAGIC_FUNCTIONS="true"
+
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
@@ -39,6 +45,8 @@ ZSH_THEME="robbyrussell"
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
+# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
+# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
@@ -58,13 +66,11 @@ ZSH_THEME="robbyrussell"
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
-# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
-# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
+# Standard plugins can be found in $ZSH/plugins/
+# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
-plugins=(
- git
-)
+plugins=(git)
source $ZSH/oh-my-zsh.sh
@@ -85,9 +91,6 @@ source $ZSH/oh-my-zsh.sh
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
-# ssh
-# export SSH_KEY_PATH="~/.ssh/rsa_id"
-
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
diff --git a/themes/3den.zsh-theme b/themes/3den.zsh-theme
index 1d2c7db7f..ae3a88659 100644
--- a/themes/3den.zsh-theme
+++ b/themes/3den.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT=$'%{$fg[white]%}$(~/.rvm/bin/rvm-prompt) %{$fg_bold[cyan]%}%~%{$reset_color%}$(git_prompt_info) %{$fg[cyan]%}%D{[%I:%M:%S]}\
+PROMPT=$'%{$fg[white]%}$(ruby_prompt_info) %{$fg_bold[cyan]%}%~%{$reset_color%}$(git_prompt_info) %{$fg[cyan]%}%D{[%I:%M:%S]}\
%{$fg_bold[green]%}%n$%{$reset_color%} '
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}("
diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme
index b9ac77d00..ebdec7c82 100644
--- a/themes/adben.zsh-theme
+++ b/themes/adben.zsh-theme
@@ -29,11 +29,13 @@
# # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
# # https://pthree.org/2008/11/23/727/
# # enjoy!
+
########## COLOR ###########
for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
- eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
- eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
+ eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
+ eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
+
PR_RESET="%{$reset_color%}"
RED_START="${PR_RESET}${PR_GREY}<${PR_RESET}${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
RED_END="${PR_RESET}${PR_BRIGHT_RED}>${PR_RESET}${PR_RED}>${PR_GREY}>${PR_RESET} "
@@ -44,14 +46,14 @@ DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}"
VCS_CLEAN_COLOR="${PR_RESET}${PR_GREEN}"
VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}"
-# ########## COLOR ###########
-# ########## SVN ###########
+
+########## SVN ###########
ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹svn:"
ZSH_THEME_SVN_PROMPT_SUFFIX=""
ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
-# ########## SVN ###########
-# ########## GIT ###########
+
+########## GIT ###########
ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
@@ -62,53 +64,63 @@ ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}"
ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜${PR_RESET}"
ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═${PR_RESET}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭${PR_RESET}"
-# ########## GIT ###########
-function precmd {
- #gets the fortune
- ps1_fortune () {
- #Choose from all databases, regardless of whether they are considered "offensive"
- fortune -a
- }
- #obtains the tip
- ps1_command_tip () {
- wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d'
- }
- prompt_header () {
- if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then
- ps1_command_tip
- else
- ps1_fortune
- fi
- }
- PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
- # set a simple variable to show when in screen
- if [[ -n "${WINDOW}" ]]; then
- SCREEN=""
+
+# Get a fortune quote
+ps1_fortune() {
+ (( ${+commands[fortune]} )) && fortune
+}
+
+# Obtain a command tip
+ps1_command_tip() {
+ {
+ if (( ${+commands[wget]} )); then
+ command wget -qO- https://www.commandlinefu.com/commands/random/plaintext
+ elif (( ${+commands[curl]} )); then
+ command curl -fsL https://www.commandlinefu.com/commands/random/plaintext
fi
+ } | sed 1d | sed '/^$/d'
}
-# Context: user@directory or just directory
-prompt_context () {
- if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
- echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
+function precmd_adben {
+ prompt_header() {
+ if [[ "$ENABLE_COMMAND_TIP" = true ]]; then
+ ps1_command_tip
else
- echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
+ ps1_fortune
fi
+ }
+
+ PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
+
+ # set a simple variable to show when in screen
+ if [[ -n "${WINDOW}" ]]; then
+ SCREEN=""
+ fi
}
-set_prompt () {
- # required for the prompt
- setopt prompt_subst
- autoload zsh/terminfo
+# Context: user@directory or just directory
+prompt_context() {
+ if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
+ echo -n "${PR_RESET}${PR_RED}$USERNAME@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
+ else
+ echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
+ fi
+}
- # ######### PROMPT #########
- PROMPT='${PROMPT_HEAD}
+########## SETUP ###########
+
+# Required for the prompt
+setopt prompt_subst
+autoload zsh/terminfo
+
+# Prompt
+PROMPT='${PROMPT_HEAD}
${RED_START}$(prompt_context)
${GREEN_START_P1}'
- RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
- # Matching continuation prompt
- PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
- # ######### PROMPT #########
-}
+RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
+# Matching continuation prompt
+PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
-set_prompt
+# Prompt head
+autoload -Uz add-zsh-hook
+add-zsh-hook precmd precmd_adben
diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme
index 1c6d1732c..1d2af3458 100644
--- a/themes/af-magic.zsh-theme
+++ b/themes/af-magic.zsh-theme
@@ -2,32 +2,46 @@
# Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
-if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
-local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-# primary prompt
-PROMPT='$FG[237]------------------------------------------------------------%{$reset_color%}
-$FG[032]%~\
-$(git_prompt_info) \
-$FG[105]%(!.#.»)%{$reset_color%} '
-PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
-RPS1='${return_code}'
+# settings
+typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
+typeset +H my_gray="$FG[237]"
+typeset +H my_orange="$FG[214]"
+# separator dashes size
+function afmagic_dashes {
+ local PYTHON_ENV="$VIRTUAL_ENV"
+ [[ -z "$PYTHON_ENV" ]] && PYTHON_ENV="$CONDA_DEFAULT_ENV"
-# color vars
-eval my_gray='$FG[237]'
-eval my_orange='$FG[214]'
+ if [[ -n "$PYTHON_ENV" && "$PS1" = \(* ]]; then
+ echo $(( COLUMNS - ${#PYTHON_ENV} - 3 ))
+ else
+ echo $COLUMNS
+ fi
+}
+
+# primary prompt
+PS1='$FG[237]${(l.$(afmagic_dashes)..-.)}%{$reset_color%}
+$FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} '
+PS2='%{$fg[red]%}\ %{$reset_color%}'
+RPS1='${return_code}'
# right prompt
-if type "virtualenv_prompt_info" > /dev/null
-then
- RPROMPT='$(virtualenv_prompt_info)$my_gray%n@%m%{$reset_color%}%'
-else
- RPROMPT='$my_gray%n@%m%{$reset_color%}%'
-fi
+(( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
+RPS1+=' $my_gray%n@%m%{$reset_color%}%'
# git settings
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
+
+# hg settings
+ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
+ZSH_THEME_HG_PROMPT_CLEAN=""
+ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
+ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
+
+# virtualenv settings
+ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
+ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 0edb773aa..fe7ddbac6 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -88,7 +88,7 @@ prompt_end() {
# Context: user@hostname (who am I and where am I)
prompt_context() {
- if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
+ if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
fi
}
@@ -106,7 +106,7 @@ prompt_git() {
}
local ref dirty mode repo_path
- if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
+ if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
@@ -131,7 +131,7 @@ prompt_git() {
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '✚'
- zstyle ':vcs_info:*' unstagedstr '●'
+ zstyle ':vcs_info:*' unstagedstr '±'
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
@@ -140,25 +140,30 @@ prompt_git() {
}
prompt_bzr() {
- (( $+commands[bzr] )) || return
- if (bzr status >/dev/null 2>&1); then
- status_mod=`bzr status | head -n1 | grep "modified" | wc -m`
- status_all=`bzr status | head -n1 | wc -m`
- revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
- if [[ $status_mod -gt 0 ]] ; then
- prompt_segment yellow black
- echo -n "bzr@"$revision "✚ "
- else
- if [[ $status_all -gt 0 ]] ; then
- prompt_segment yellow black
- echo -n "bzr@"$revision
-
- else
- prompt_segment green black
- echo -n "bzr@"$revision
- fi
- fi
+ (( $+commands[bzr] )) || return
+
+ # Test if bzr repository in directory hierarchy
+ local dir="$PWD"
+ while [[ ! -d "$dir/.bzr" ]]; do
+ [[ "$dir" = "/" ]] && return
+ dir="${dir:h}"
+ done
+
+ local bzr_status status_mod status_all revision
+ if bzr_status=$(bzr status 2>&1); then
+ status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
+ status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
+ revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
+ if [[ $status_mod -gt 0 ]] ; then
+ prompt_segment yellow black "bzr@$revision ✚"
+ else
+ if [[ $status_all -gt 0 ]] ; then
+ prompt_segment yellow black "bzr@$revision"
+ else
+ prompt_segment green black "bzr@$revision"
+ fi
fi
+ fi
}
prompt_hg() {
@@ -224,11 +229,25 @@ prompt_status() {
[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
}
+#AWS Profile:
+# - display current AWS_PROFILE name
+# - displays yellow on red if profile name contains 'production' or
+# ends in '-prod'
+# - displays black on green otherwise
+prompt_aws() {
+ [[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
+ case "$AWS_PROFILE" in
+ *-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;;
+ *) prompt_segment green black "AWS: $AWS_PROFILE" ;;
+ esac
+}
+
## Main prompt
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
+ prompt_aws
prompt_context
prompt_dir
prompt_git
diff --git a/themes/alanpeabody.zsh-theme b/themes/alanpeabody.zsh-theme
index 4a1b1b386..1de90e57b 100644
--- a/themes/alanpeabody.zsh-theme
+++ b/themes/alanpeabody.zsh-theme
@@ -1,17 +1,10 @@
local user='%{$fg[magenta]%}%n@%{$fg[magenta]%}%m%{$reset_color%}'
local pwd='%{$fg[blue]%}%~%{$reset_color%}'
-local rvm=''
-if which rvm-prompt &> /dev/null; then
- rvm='%{$fg[green]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
-else
- if which rbenv &> /dev/null; then
- rvm='%{$fg[green]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
- fi
-fi
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}'
+ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=""
@@ -24,5 +17,8 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[green]%}‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
+
PROMPT="${user} ${pwd}$ "
-RPROMPT="${return_code} ${git_branch} ${rvm}"
+RPROMPT="${return_code} ${git_branch} \$(ruby_prompt_info)"
diff --git a/themes/amuse.zsh-theme b/themes/amuse.zsh-theme
index d3f15ace5..3f7ec0bc5 100644
--- a/themes/amuse.zsh-theme
+++ b/themes/amuse.zsh-theme
@@ -1,17 +1,5 @@
# vim:ft=zsh ts=2 sw=2 sts=2
-rvm_current() {
- rvm current 2>/dev/null
-}
-
-rbenv_version() {
- rbenv version 2>/dev/null | awk '{print $1}'
-}
-
-PROMPT='
-%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
-$ '
-
# Must use Powerline font, for \uE0A0 to render.
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}\uE0A0 "
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
@@ -19,11 +7,12 @@ ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN=""
-if [ -e ~/.rvm/bin/rvm-prompt ]; then
- RPROMPT='%{$fg_bold[red]%}‹$(rvm_current)›%{$reset_color%}'
-else
- if which rbenv &> /dev/null; then
- RPROMPT='%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}'
- fi
-fi
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg_bold[red]%}‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
+
+PROMPT='
+%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
+$ '
+
+RPROMPT='$(ruby_prompt_info)'
diff --git a/themes/arrow.zsh-theme b/themes/arrow.zsh-theme
index a3e77d65d..76c031fd2 100644
--- a/themes/arrow.zsh-theme
+++ b/themes/arrow.zsh-theme
@@ -1,7 +1,7 @@
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="yellow"; fi
PROMPT='%{$fg[$NCOLOR]%}%c ➤ %{$reset_color%}'
-RPROMPT='%{$fg[$NCOLOR]%}%p $(git_prompt_info)%{$reset_color%}'
+RPROMPT='%{$fg[$NCOLOR]%} $(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index aec14e4a6..1e20d8f9f 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -1,30 +1,23 @@
# AVIT ZSH Theme
-PROMPT='
-$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
-%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
-
-PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
+# settings
+typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
+typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
+typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
-RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
+PROMPT='
+$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
+%{%(!.${fg[red]}.${fg[white]})%}▶%{$reset_color%} '
-local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
-local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
-local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
+PROMPT2='%{%(!.${fg[red]}.${fg[white]})%}◀%{$reset_color%} '
-function _current_dir() {
- local _max_pwd_length="65"
- if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
- echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
- else
- echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
- fi
-}
+RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
function _user_host() {
+ local me
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
- elif [[ $LOGNAME != $USER ]]; then
+ elif [[ $LOGNAME != $USERNAME ]]; then
me="%n"
fi
if [[ -n $me ]]; then
@@ -32,61 +25,41 @@ function _user_host() {
fi
}
-function _vi_status() {
- if {echo $fpath | grep -q "plugins/vi-mode"}; then
- echo "$(vi_mode_prompt_info)"
- fi
-}
-
-function _ruby_version() {
- if {echo $fpath | grep -q "plugins/rvm"}; then
- echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
- elif {echo $fpath | grep -q "plugins/rbenv"}; then
- echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
- fi
-}
-
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() {
-# Only proceed if there is actually a commit.
+ local last_commit now seconds_since_last_commit
+ local minutes hours days years commit_age
+ # Only proceed if there is actually a commit.
if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
now=$(date +%s)
seconds_since_last_commit=$((now-last_commit))
# Totals
minutes=$((seconds_since_last_commit / 60))
- hours=$((seconds_since_last_commit/3600))
-
- # Sub-hours and sub-minutes
- days=$((seconds_since_last_commit / 86400))
- sub_hours=$((hours % 24))
- sub_minutes=$((minutes % 60))
-
- if [ $hours -ge 24 ]; then
- commit_age="${days}d"
- elif [ $minutes -gt 60 ]; then
- commit_age="${sub_hours}h${sub_minutes}m"
+ hours=$((minutes / 60))
+ days=$((hours / 24))
+ years=$((days / 365))
+
+ if [[ $years -gt 0 ]]; then
+ commit_age="${years}y$((days % 365 ))d"
+ elif [[ $days -gt 0 ]]; then
+ commit_age="${days}d$((hours % 24))h"
+ elif [[ $hours -gt 0 ]]; then
+ commit_age+="${hours}h$(( minutes % 60 ))m"
else
commit_age="${minutes}m"
fi
- color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
- echo "$color$commit_age%{$reset_color%}"
+ echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
fi
}
-if [[ $USER == "root" ]]; then
- CARETCOLOR="red"
-else
- CARETCOLOR="white"
-fi
-
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
+# Git prompt settings
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
+# Ruby prompt settings
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
+
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
diff --git a/themes/awesomepanda.zsh-theme b/themes/awesomepanda.zsh-theme
index 1c5d06b2d..85036e4ac 100644
--- a/themes/awesomepanda.zsh-theme
+++ b/themes/awesomepanda.zsh-theme
@@ -1,6 +1,6 @@
# the svn plugin has to be activated for this to work.
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
-PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
+PROMPT='${ret_status}%{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/bira.zsh-theme b/themes/bira.zsh-theme
index 675483996..cdae68d6c 100644
--- a/themes/bira.zsh-theme
+++ b/themes/bira.zsh-theme
@@ -1,30 +1,32 @@
# ZSH Theme - Preview: https://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-
if [[ $UID -eq 0 ]]; then
- local user_host='%{$terminfo[bold]$fg[red]%}%n@%m%{$reset_color%}'
+ local user_host='%{$terminfo[bold]$fg[red]%}%n@%m %{$reset_color%}'
local user_symbol='#'
else
- local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
+ local user_host='%{$terminfo[bold]$fg[green]%}%n@%m %{$reset_color%}'
local user_symbol='$'
fi
-local current_dir='%{$terminfo[bold]$fg[blue]%}%~%{$reset_color%}'
-local rvm_ruby=''
-if which rvm-prompt &> /dev/null; then
- rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
-else
- if which rbenv &> /dev/null; then
- rvm_ruby='%{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
- fi
-fi
-local git_branch='$(git_prompt_info)%{$reset_color%}'
+local current_dir='%{$terminfo[bold]$fg[blue]%}%~ %{$reset_color%}'
+local git_branch='$(git_prompt_info)'
+local rvm_ruby='$(ruby_prompt_info)'
+local venv_prompt='$(virtualenv_prompt_info)'
-PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
+ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
+
+PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${git_branch}${venv_prompt}
╰─%B${user_symbol}%b "
-RPS1="%B${return_code}%b"
+RPROMPT="%B${return_code}%b"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="› %{$reset_color%}"
+
+ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$fg[green]%}‹"
+ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="› %{$reset_color%}"
+ZSH_THEME_VIRTUALENV_PREFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX
+ZSH_THEME_VIRTUALENV_SUFFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX
diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme
index 30ce785c0..ad03cc320 100644
--- a/themes/candy-kingdom.zsh-theme
+++ b/themes/candy-kingdom.zsh-theme
@@ -1,16 +1,14 @@
-# neuralsanwich.zsh-theme
-
-if [ "x$OH_MY_ZSH_HG" = "x" ]; then
- OH_MY_ZSH_HG="hg"
-fi
-
-function hg_prompt_info {
- $OH_MY_ZSH_HG prompt --angle-brackets "\
+if ! hg prompt 2>/dev/null; then
+ function hg_prompt_info { }
+else
+ function hg_prompt_info {
+ hg prompt --angle-brackets "\
< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
-}
+ }
+fi
function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
-local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}"
-RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
+RPROMPT='%{$fg[red]%}%(?..✘)%{$reset_color%}'
+
+# Add battery status if the battery plugin is enabled
+if (( $+functions[battery_pct_prompt] )); then
+ RPROMPT+='$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
+fi
diff --git a/themes/cloud.zsh-theme b/themes/cloud.zsh-theme
index 59a3472b6..e26f786e1 100644
--- a/themes/cloud.zsh-theme
+++ b/themes/cloud.zsh-theme
@@ -2,7 +2,7 @@ if [[ -z $ZSH_THEME_CLOUD_PREFIX ]]; then
ZSH_THEME_CLOUD_PREFIX='☁'
fi
-PROMPT='%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX %{$fg_bold[green]%}%p %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+PROMPT='%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX %{$fg_bold[green]%} %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/crcandy.zsh-theme b/themes/crcandy.zsh-theme
index 0a63c1245..5b9cd42f8 100644
--- a/themes/crcandy.zsh-theme
+++ b/themes/crcandy.zsh-theme
@@ -1,5 +1,5 @@
PROMPT=$'
-%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%I:%M:%S]} %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(git_prompt_info)\
+%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%H:%M:%S]} %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(git_prompt_info)\
%{$fg[blue]%}->%{$fg_bold[blue]%} %#%{$reset_color%} '
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}["
diff --git a/themes/crunch.zsh-theme b/themes/crunch.zsh-theme
index 2fc066381..8278661ab 100644
--- a/themes/crunch.zsh-theme
+++ b/themes/crunch.zsh-theme
@@ -29,13 +29,9 @@ ZSH_THEME_GIT_PROMPT_DIRTY=" $CRUNCH_GIT_DIRTY_COLOR✗"
# Our elements:
CRUNCH_TIME_="$CRUNCH_BRACKET_COLOR{$CRUNCH_TIME_COLOR%T$CRUNCH_BRACKET_COLOR}%{$reset_color%}"
-if [ -e ~/.rvm/bin/rvm-prompt ]; then
- CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
-else
- if which rbenv &> /dev/null; then
- CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(rbenv version | sed -e 's/ (set.*$//' -e 's/^ruby-//')}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
- fi
-fi
+ZSH_THEME_RUBY_PROMPT_PREFIX="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
+CRUNCH_RVM_='$(ruby_prompt_info)'
CRUNCH_DIR_="$CRUNCH_DIR_COLOR%~\$(git_prompt_info) "
CRUNCH_PROMPT="$CRUNCH_BRACKET_COLOR➭ "
diff --git a/themes/dallas.zsh-theme b/themes/dallas.zsh-theme
index e9e86177b..d6c417fc3 100644
--- a/themes/dallas.zsh-theme
+++ b/themes/dallas.zsh-theme
@@ -2,14 +2,6 @@
# Grab the current date (%D) and time (%T) wrapped in {}: {%D %T}
DALLAS_CURRENT_TIME_="%{$fg[white]%}{%{$fg[yellow]%}%D %T%{$fg[white]%}}%{$reset_color%}"
-# Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
-if [ -e ~/.rvm/bin/rvm-prompt ]; then
- DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
-else
- if which rbenv &> /dev/null; then
- DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
- fi
-fi
# Grab the current machine name: muscato
DALLAS_CURRENT_MACH_="%{$fg[green]%}%m%{$fg[white]%}:%{$reset_color%}"
# Grab the current filepath, use shortcuts: ~/Desktop
@@ -28,5 +20,8 @@ ZSH_THEME_GIT_PROMPT_CLEAN=""
# Add 3 cyan ✗s if this branch is diiirrrty! Dirty branch!
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[cyan]%}✗✗✗"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[white]%}[%{$fg[magenta]%}"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$fg[white]%}]%{$reset_color%}"
+
# Put it all together!
-PROMPT="$DALLAS_CURRENT_TIME_$DALLAS_CURRENT_RUBY_$DALLAS_CURRENT_MACH_$DALLAS_CURRENT_LOCA_ $DALLAS_CURRENT_USER_$DALLAS_PROMPT_CHAR_ "
+PROMPT="$DALLAS_CURRENT_TIME_\$(ruby_prompt_info)$DALLAS_CURRENT_MACH_$DALLAS_CURRENT_LOCA_ $DALLAS_CURRENT_USER_$DALLAS_PROMPT_CHAR_ "
diff --git a/themes/dst.zsh-theme b/themes/dst.zsh-theme
index 3e2539d57..6b2f8767d 100644
--- a/themes/dst.zsh-theme
+++ b/themes/dst.zsh-theme
@@ -11,6 +11,6 @@ function prompt_char {
PROMPT='%(?, ,%{$fg[red]%}FAIL%{$reset_color%}
)
%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info)
-%_ $(prompt_char) '
+$(prompt_char) '
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
diff --git a/themes/edvardm.zsh-theme b/themes/edvardm.zsh-theme
index f9ca1a9e2..d41dd4434 100644
--- a/themes/edvardm.zsh-theme
+++ b/themes/edvardm.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg_bold[white]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%} %{$fg_bold[white]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/essembeh.zsh-theme b/themes/essembeh.zsh-theme
index 939bb7a4c..f34f36f8a 100644
--- a/themes/essembeh.zsh-theme
+++ b/themes/essembeh.zsh-theme
@@ -1,24 +1,14 @@
-# Theme with full path names and hostname
-# Handy if you work on different servers all the time;
-
-local return_code="%(?..%{$fg_bold[red]%}%? ↵%{$reset_color%})"
-
-function my_git_prompt_info() {
- ref=$(git symbolic-ref HEAD 2> /dev/null) || return
- GIT_STATUS=$(git_prompt_status)
- [[ -n $GIT_STATUS ]] && GIT_STATUS=" $GIT_STATUS"
- echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$GIT_STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
-}
-
-# Colored prompt
-ZSH_THEME_COLOR_USER="green"
-ZSH_THEME_COLOR_HOST="green"
-ZSH_THEME_COLOR_PWD="yellow"
-test -n "$SSH_CONNECTION" && ZSH_THEME_COLOR_USER="red" && ZSH_THEME_COLOR_HOST="red"
-test `id -u` = 0 && ZSH_THEME_COLOR_USER="magenta" && ZSH_THEME_COLOR_HOST="magenta"
-PROMPT='%{$fg_bold[$ZSH_THEME_COLOR_USER]%}%n@%{$fg_bold[$ZSH_THEME_COLOR_HOST]%}%M%{$reset_color%}:%{$fg_bold[$ZSH_THEME_COLOR_PWD]%}%~%{$reset_color%} $(my_git_prompt_info)%(!.#.$) '
-RPS1="${return_code}"
+# My custom theme:
+# - single line
+# - quite simple by default: user@host:$PWD
+# - green for local shell as non root
+# - red for ssh shell as non root
+# - magenta for root sessions
+# - prefix with remote address for ssh shells
+# - prefix to detect docker containers or chroot
+# - git plugin to display current branch and status
+# git plugin
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%%"
@@ -28,3 +18,33 @@ ZSH_THEME_GIT_PROMPT_RENAMED="~"
ZSH_THEME_GIT_PROMPT_DELETED="!"
ZSH_THEME_GIT_PROMPT_UNMERGED="?"
+function zsh_essembeh_gitstatus {
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || return
+ GIT_STATUS=$(git_prompt_status)
+ if [[ -n $GIT_STATUS ]]; then
+ GIT_STATUS=" $GIT_STATUS"
+ fi
+ echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$GIT_STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
+}
+
+# by default, use green for user@host and no prefix
+local ZSH_ESSEMBEH_COLOR="green"
+local ZSH_ESSEMBEH_PREFIX=""
+if [[ -n "$SSH_CONNECTION" ]]; then
+ # display the source address if connected via ssh
+ ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[$(echo $SSH_CONNECTION | awk '{print $1}')]%{$reset_color%} "
+ # use red color to highlight a remote connection
+ ZSH_ESSEMBEH_COLOR="red"
+elif [[ -r /etc/debian_chroot ]]; then
+ # prefix prompt in case of chroot
+ ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[chroot:$(cat /etc/debian_chroot)]%{$reset_color%} "
+elif [[ -r /.dockerenv ]]; then
+ # also prefix prompt inside a docker contrainer
+ ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[docker]%{$reset_color%} "
+fi
+if [[ $UID = 0 ]]; then
+ # always use magenta for root sessions, even in ssh
+ ZSH_ESSEMBEH_COLOR="magenta"
+fi
+PROMPT='${ZSH_ESSEMBEH_PREFIX}%{$fg[$ZSH_ESSEMBEH_COLOR]%}%n@%M%{$reset_color%}:%{%B$fg[yellow]%}%~%{$reset_color%b%} $(zsh_essembeh_gitstatus)%(!.#.$) '
+RPROMPT="%(?..%{$fg[red]%}%?%{$reset_color%})"
diff --git a/themes/evan.zsh-theme b/themes/evan.zsh-theme
index 5ef1f40dd..02ca22d4c 100644
--- a/themes/evan.zsh-theme
+++ b/themes/evan.zsh-theme
@@ -1,2 +1,2 @@
-# Evan describes this sexy prompt as: "a skinny, topless prompt"
-PROMPT='%m :: %2~ %B»%b ' \ No newline at end of file
+# Evan's minimal prompt
+PROMPT='%m :: %2~ %B»%b '
diff --git a/themes/fino-time.zsh-theme b/themes/fino-time.zsh-theme
index 9caebc69e..57c47db02 100644
--- a/themes/fino-time.zsh-theme
+++ b/themes/fino-time.zsh-theme
@@ -25,18 +25,12 @@ function box_name {
}
-rvm_ruby=''
-if type rvm-prompt &>/dev/null; then
- rvm_ruby='using%{$FG[243]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
-fi
-
-local git_info='$(git_prompt_info)'
-
-
-PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}${git_info} %{$FG[239]%}${rvm_ruby} %D - %*
-╰─$(virtualenv_info)$(prompt_char) "
+PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}\$(git_prompt_info)\$(ruby_prompt_info) %D - %*
+╰─\$(virtualenv_info)\$(prompt_char) "
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔"
+ZSH_THEME_RUBY_PROMPT_PREFIX=" %{$FG[239]%}using%{$FG[243]%} ‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
diff --git a/themes/fino.zsh-theme b/themes/fino.zsh-theme
index 28d6cc2ec..2523c1776 100644
--- a/themes/fino.zsh-theme
+++ b/themes/fino.zsh-theme
@@ -11,32 +11,35 @@
#
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
+function virtualenv_prompt_info {
+ [[ -n ${VIRTUAL_ENV} ]] || return
+ echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}"
+}
+
function prompt_char {
- git branch >/dev/null 2>/dev/null && echo "±" && return
- echo '○'
+ command git branch &>/dev/null && echo "±" || echo '○'
}
function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
+ [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
}
-local ruby_env=''
-if which rvm-prompt &> /dev/null; then
- ruby_env='using%{$FG[243]%} ‹$(rvm-prompt i v g)›%{$reset_color%}'
-else
- if which rbenv &> /dev/null; then
- ruby_env='using%{$FG[243]%} ‹$(rbenv version-name)›%{$reset_color%}'
- fi
-fi
-
+local ruby_env='$(ruby_prompt_info)'
local git_info='$(git_prompt_info)'
+local virtualenv_info='$(virtualenv_prompt_info)'
local prompt_char='$(prompt_char)'
-
-PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}${git_info} %{$FG[239]%}${ruby_env}
+PROMPT="╭─${FG[040]}%n ${FG[239]}at ${FG[033]}$(box_name) ${FG[239]}in %B${FG[226]}%~%b${git_info}${ruby_env}${virtualenv_info}
╰─${prompt_char}%{$reset_color%} "
-ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
+ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[239]}on%{$reset_color%} ${FG[255]}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘"
-ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔"
+ZSH_THEME_GIT_PROMPT_DIRTY="${FG[202]}✘✘✘"
+ZSH_THEME_GIT_PROMPT_CLEAN="${FG[040]}✔"
+
+ZSH_THEME_RUBY_PROMPT_PREFIX=" ${FG[239]}using${FG[243]} ‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
+
+export VIRTUAL_ENV_DISABLE_PROMPT=1
+ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[239]}using${FG[243]} «"
+ZSH_THEME_VIRTUALENV_SUFFIX="»%{$reset_color%}"
diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme
index 83bd455b5..2b8d559e5 100644
--- a/themes/fishy.zsh-theme
+++ b/themes/fishy.zsh-theme
@@ -1,12 +1,18 @@
# ZSH Theme emulating the Fish shell's default prompt.
_fishy_collapsed_wd() {
- echo $(pwd | perl -pe '
- BEGIN {
- binmode STDIN, ":encoding(UTF-8)";
- binmode STDOUT, ":encoding(UTF-8)";
- }; s|^$ENV{HOME}|~|g; s|/([^/.])[^/]*(?=/)|/$1|g; s|/\.([^/])[^/]*(?=/)|/.$1|g
-')
+ local i pwd
+ pwd=("${(s:/:)PWD/#$HOME/~}")
+ if (( $#pwd > 1 )); then
+ for i in {1..$(($#pwd-1))}; do
+ if [[ "$pwd[$i]" = .* ]]; then
+ pwd[$i]="${${pwd[$i]}[1,2]}"
+ else
+ pwd[$i]="${${pwd[$i]}[1]}"
+ fi
+ done
+ fi
+ echo "${(j:/:)pwd}"
}
local user_color='green'; [ $UID -eq 0 ] && user_color='red'
@@ -14,7 +20,7 @@ PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>)
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}"
-RPROMPT='${return_status}$(git_prompt_info)$(git_prompt_status)%{$reset_color%}'
+RPROMPT="${RPROMPT}"'${return_status}$(git_prompt_info)$(git_prompt_status)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=" "
ZSH_THEME_GIT_PROMPT_SUFFIX=""
diff --git a/themes/flazz.zsh-theme b/themes/flazz.zsh-theme
index c0a7fb5d0..e21b52ef5 100644
--- a/themes/flazz.zsh-theme
+++ b/themes/flazz.zsh-theme
@@ -1,4 +1,4 @@
-if [ "$USER" = "root" ]
+if [ "$USERNAME" = "root" ]
then CARETCOLOR="red"
else CARETCOLOR="blue"
fi
diff --git a/themes/frontcube.zsh-theme b/themes/frontcube.zsh-theme
index 539e744f8..f9488d0ac 100644
--- a/themes/frontcube.zsh-theme
+++ b/themes/frontcube.zsh-theme
@@ -1,12 +1,13 @@
-local rvm="%{$fg[green]%}[$(rvm-prompt i v g)]%{$reset_color%}"
PROMPT='
%{$fg_bold[gray]%}%~%{$fg_bold[blue]%}%{$fg_bold[blue]%} % %{$reset_color%}
%{$fg[green]%}➞ %{$reset_color%'
-RPROMPT='$(git_prompt_info) ${rvm}'
+RPROMPT='$(git_prompt_info) $(ruby_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}[git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}] %{$fg[red]%}✖ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}] %{$fg[green]%}✔%{$reset_color%}"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[green]%}["
+ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
diff --git a/themes/fwalch.zsh-theme b/themes/fwalch.zsh-theme
index 24edf55c0..33f851c9d 100644
--- a/themes/fwalch.zsh-theme
+++ b/themes/fwalch.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT='%{$fg_bold[green]%}%p %{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+PROMPT='%{$fg_bold[green]%} %{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/gallifrey.zsh-theme b/themes/gallifrey.zsh-theme
index 252566f06..47b057fa3 100644
--- a/themes/gallifrey.zsh-theme
+++ b/themes/gallifrey.zsh-theme
@@ -1,8 +1,11 @@
-# ZSH Theme - Preview: https://flic.kr/p/ZFvivf
-local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
+# ZSH Theme - Preview: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#gallifrey
+return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
+host_color="%(!.%{$fg[red]%}.%{$fg[green]%})"
-PROMPT='%{$fg[green]%}%m%{$reset_color%} %2~ $(git_prompt_info)%{$reset_color%}%B»%b '
+PROMPT="${host_color}%m%{$reset_color%} %2~ \$(git_prompt_info)%{$reset_color%}%B»%b "
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
+
+unset return_code host_color
diff --git a/themes/gallois.zsh-theme b/themes/gallois.zsh-theme
index 515325e38..bb97bfb17 100644
--- a/themes/gallois.zsh-theme
+++ b/themes/gallois.zsh-theme
@@ -1,23 +1,24 @@
# Depends on the git plugin for work_in_progress()
+(( $+functions[work_in_progress] )) || work_in_progress() {}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
-#Customized git status, oh-my-zsh currently does not allow render dirty status before branch
+# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
- local cb=$(git_current_branch)
- if [ -n "$cb" ]; then
- echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
- fi
+ local branch=$(git_current_branch)
+ [[ -n "$branch" ]] || return 0
+ echo "$(parse_git_dirty)\
+%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
+${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# RVM component of prompt
-ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}["
-ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
+ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
# Combine it all into a final right-side prompt
-RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1'
-
+RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
diff --git a/themes/gentoo.zsh-theme b/themes/gentoo.zsh-theme
index ee205d248..7ac461036 100644
--- a/themes/gentoo.zsh-theme
+++ b/themes/gentoo.zsh-theme
@@ -1,8 +1,28 @@
-function prompt_char {
- if [ $UID -eq 0 ]; then echo "#"; else echo $; fi
+autoload -Uz colors && colors
+
+autoload -Uz vcs_info
+zstyle ':vcs_info:*' check-for-changes true
+zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes
+zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes
+zstyle ':vcs_info:*' actionformats '%F{5}(%F{2}%b%F{3}|%F{1}%a%c%u%m%F{5})%f '
+zstyle ':vcs_info:*' formats '%F{5}(%F{2}%b%c%u%m%F{5})%f '
+zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
+zstyle ':vcs_info:*' enable git cvs svn
+zstyle ':vcs_info:git*+set-message:*' hooks untracked-git
+
++vi-untracked-git() {
+ if command git status --porcelain 2>/dev/null | command grep -q '??'; then
+ hook_com[misc]='%F{red}?'
+ else
+ hook_com[misc]=''
+ fi
+}
+
+gentoo_precmd() {
+ vcs_info
}
-PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) $(git_prompt_info)%_$(prompt_char)%{$reset_color%} '
+autoload -U add-zsh-hook
+add-zsh-hook precmd gentoo_precmd
-ZSH_THEME_GIT_PROMPT_PREFIX="("
-ZSH_THEME_GIT_PROMPT_SUFFIX=") "
+PROMPT='%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%F{blue}%(!.#.$)%k%b%f '
diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme
index c763ef3c6..1e6c4e93b 100644
--- a/themes/gnzh.zsh-theme
+++ b/themes/gnzh.zsh-theme
@@ -29,21 +29,15 @@ local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
-local rvm_ruby=''
-if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
- rvm_ruby='%F{red}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%f'
-elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
- rvm_ruby='%F{red}‹$(rvm-prompt i v g s)›%f'
-elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
- rvm_ruby='%F{red}‹$(rbenv version | sed -e "s/ (set.*$//")›%f'
-fi
local git_branch='$(git_prompt_info)'
-PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
+PROMPT="╭─${user_host} ${current_dir} \$(ruby_prompt_info) ${git_branch}
╰─$PR_PROMPT "
RPROMPT="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %f"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%F{red}‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="›%f"
}
diff --git a/themes/gozilla.zsh-theme b/themes/gozilla.zsh-theme
index c6b752e9b..593b8ec35 100644
--- a/themes/gozilla.zsh-theme
+++ b/themes/gozilla.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
diff --git a/themes/itchy.zsh-theme b/themes/itchy.zsh-theme
index e1f2d56e2..41a42e88c 100644
--- a/themes/itchy.zsh-theme
+++ b/themes/itchy.zsh-theme
@@ -7,10 +7,12 @@ local pwd="%{$fg[yellow]%}%~%{$reset_color%}"
PROMPT='${user}${host} ${pwd}
${smiley} '
-RPROMPT='$(rvm-prompt || rbenv version) %{$fg[white]%}$(git_prompt_info)%{$reset_color%}'
+RPROMPT='$(ruby_prompt_info) %{$fg[white]%}$(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} ✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✔%{$reset_color%}"
+ZSH_THEME_RUBY_PROMPT_PREFIX=""
+ZSH_THEME_RUBY_PROMPT_SUFFIX=""
diff --git a/themes/jaischeema.zsh-theme b/themes/jaischeema.zsh-theme
index da1dd1e5d..50d2bc4a5 100644
--- a/themes/jaischeema.zsh-theme
+++ b/themes/jaischeema.zsh-theme
@@ -1,16 +1,12 @@
# jaischeema.zsh-theme
PROMPT='%{$fg_bold[magenta]%}%m%{$reset_color%} at %{$fg_bold[green]%}%~%{$reset_color%} %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}%{$fg[red]%}❯%{$reset_color%} '
+RPROMPT='$(ruby_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="±(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}) "
-if which rbenv &> /dev/null; then
- RPROMPT='%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}'
-else
- if which rvm-prompt &> /dev/null; then
- RPROMPT='%{$fg[red]%}$(rvm-prompt)%{$reset_color%}'
- fi
-fi
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/jbergantine.zsh-theme b/themes/jbergantine.zsh-theme
index d84247cff..8e9a8ee95 100644
--- a/themes/jbergantine.zsh-theme
+++ b/themes/jbergantine.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[white]%}$(git_prompt_info)%{$fg_bold[white]%} % %{$reset_color%}'
+PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[white]%}$(git_prompt_info)%{$fg_bold[white]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/jnrowe.zsh-theme b/themes/jnrowe.zsh-theme
index bae88f7ab..9d8fb2488 100644
--- a/themes/jnrowe.zsh-theme
+++ b/themes/jnrowe.zsh-theme
@@ -33,6 +33,6 @@ function {
local ret_status="%(?:%{$fg_bold[green]%}Ξ:%{$fg_bold[red]%}%S↑%s%?)"
-PROMPT='${ret_status}%{$fg[blue]%}${PROMPT_HOST}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} '
+PROMPT='${ret_status}%{$fg[blue]%}${PROMPT_HOST}%{$fg_bold[green]%} %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} '
# vim: set ft=zsh ts=4 sw=4 et:
diff --git a/themes/jtriley.zsh-theme b/themes/jtriley.zsh-theme
index 15d77ed23..0f5b16f0a 100644
--- a/themes/jtriley.zsh-theme
+++ b/themes/jtriley.zsh-theme
@@ -1,8 +1,2 @@
-#PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
PROMPT="%{$fg_bold[cyan]%}%T%{$fg_bold[green]%} %{$fg_bold[white]%}%n%{$fg[magenta]%}@%{$fg_bold[white]%}%m %{$fg_bold[green]%}%d
%{$fg_bold[yellow]%}%% %{$reset_color%}"
-
-#ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
-#ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-#ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
-#ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
diff --git a/themes/kafeitu.zsh-theme b/themes/kafeitu.zsh-theme
index c4720b24d..af96f5e38 100644
--- a/themes/kafeitu.zsh-theme
+++ b/themes/kafeitu.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%n%{$fg[cyan]%}@%{$fg_bold[green]%}%m %{$fg_bold[green]%}%p %{$fg[cyan]%}%~ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%n%{$fg[cyan]%}@%{$fg_bold[green]%}%m %{$fg_bold[green]%} %{$fg[cyan]%}%~ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/themes/kiwi.zsh-theme b/themes/kiwi.zsh-theme
index f93de2b75..94f0ffcbf 100644
--- a/themes/kiwi.zsh-theme
+++ b/themes/kiwi.zsh-theme
@@ -1,6 +1,4 @@
-#
-# Kiwi ZSH Theme
-#
+(( $+functions[battery_pct_prompt] )) || function battery_pct_prompt { }
PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt)
└> % %{$reset_color%}'
diff --git a/themes/linuxonly.zsh-theme b/themes/linuxonly.zsh-theme
index f9e0aa07d..2afae8fc3 100644
--- a/themes/linuxonly.zsh-theme
+++ b/themes/linuxonly.zsh-theme
@@ -1,7 +1,6 @@
-# vim: set ts=2 textwidth=0
-
autoload -U add-zsh-hook
autoload -Uz vcs_info
+
local c0=$(printf "\033[0m")
local c1=$(printf "\033[38;5;215m")
local c2=$(printf "\033[38;5;209m")
@@ -13,7 +12,6 @@ local c7=$(printf "\033[38;5;149m")
local c8=$(printf "\033[38;5;126m")
local c9=$(printf "\033[38;5;162m")
-
if [ "$TERM" = "linux" ]; then
c1=$(printf "\033[34;1m")
c2=$(printf "\033[35m")
@@ -26,9 +24,6 @@ if [ "$TERM" = "linux" ]; then
c9=$(printf "\033[34m")
fi
-#local newtv=$(perl $HOME/devel/newtv.pl)
-local newtv=''
-
zstyle ':vcs_info:*' actionformats \
'%{$c8%}(%f%s)%{$c7%}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
@@ -42,38 +37,23 @@ prompt_jnrowe_precmd () {
vcs_info
if [ "${vcs_info_msg_0_}" = "" ]; then
- #dir_status="|%F{3}%n%F{7}@%F{3}%m%F{7}:%F{9}%l%f"
- #dir_status="$c1%n%F{7}@%F{9}%m%F{7}:%F{12}%/"
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$c4%}%/ %{$c0%}(%{$c5%}%?%{$c0%})"
- #dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$foopath%} %{$c0%}(%{$c5%}%?%{$c0%})"
-
- PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
+ PROMPT='${dir_status} ${ret_status}%{$reset_color%}
> '
elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$c4%}%/ %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}
-%{$fg_bold[green]%}%p%{$reset_color%}${dir_status} ${vcs_info_msg_0_}%{$reset_color%}
+${dir_status} ${vcs_info_msg_0_}%{$reset_color%}
> '
-
elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$c4%}%/ %{$c0%}(%{$c5%}%?%{$c0%})"
-
PROMPT='${vcs_info_msg_0_}
-%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
+${dir_status}%{$reset_color%}
%{$c9%}·>%{$c0%} '
else
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$c4%}%/ %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}
-%{$fg_bold[green]%}%p%{$reset_color%}${dir_status} ${vcs_info_msg_0_}%{$reset_color%}
+${dir_status} ${vcs_info_msg_0_}%{$reset_color%}
> '
-
fi
}
-
-
-#PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$reset_color%} ${vcs_info_msg_0_}${dir_status}%{$reset_color%}
-#> '
-
-# vim: set ft=zsh ts=4 sw=4 et:
-
-
diff --git a/themes/macovsky-ruby.zsh-theme b/themes/macovsky-ruby.zsh-theme
index abda6232c..d3ee200a9 100644..120000
--- a/themes/macovsky-ruby.zsh-theme
+++ b/themes/macovsky-ruby.zsh-theme
@@ -1,15 +1 @@
-# ZSH Theme - Preview: https://i.gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
-local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-
-if [ -e ~/.rvm/bin/rvm-prompt ]; then
- PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
-else
- if which rbenv &> /dev/null; then
- PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
- fi
-fi
-
-RPS1="${return_code}"
-
-ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
-ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
+macovsky.zsh-theme \ No newline at end of file
diff --git a/themes/macovsky.zsh-theme b/themes/macovsky.zsh-theme
index d3f7d16b4..f527e5861 100644
--- a/themes/macovsky.zsh-theme
+++ b/themes/macovsky.zsh-theme
@@ -1,14 +1,12 @@
# ZSH Theme - Preview: https://i.gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-if [ -e ~/.rvm/bin/rvm-prompt ]; then
- PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
-else
- if which rbenv &> /dev/null; then
- PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
- fi
-fi
-RPS1="${return_code}"
+PROMPT='%{$fg[green]%}%~%{$reset_color%} $(ruby_prompt_info) $(git_prompt_info)%{$reset_color%}%B$%b '
+RPROMPT="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
+
+
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="› %{$reset_color%}"
diff --git a/themes/maran.zsh-theme b/themes/maran.zsh-theme
index 6fba04688..fddb7bc30 100644
--- a/themes/maran.zsh-theme
+++ b/themes/maran.zsh-theme
@@ -1,6 +1,6 @@
# Theme with full path names and hostname
# Handy if you work on different servers all the time;
-PROMPT='%{$fg[cyan]%}%n%{$reset_color%}@%{$fg[yellow]%}%M:%{$fg[green]%}%/%{$reset_color%} $(git_prompt_info) %(!.#.$) '
+PROMPT='%{$fg[cyan]%}%n%{$reset_color%}@%{$fg[yellow]%}%M:%{$fg[green]%}%/%{$reset_color%}$(git_prompt_info) %(!.#.$) '
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[cyan]%}git:("
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}"
diff --git a/themes/mira.zsh-theme b/themes/mira.zsh-theme
index e6c952998..a7c60359c 100644
--- a/themes/mira.zsh-theme
+++ b/themes/mira.zsh-theme
@@ -4,22 +4,13 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
-local rvm_ruby=''
-if which rvm-prompt &> /dev/null; then
- rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
-else
- if which rbenv &> /dev/null; then
- rvm_ruby='%{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
- fi
-fi
+local nvm_node='%{$fg[green]%}‹node-$(nvm_prompt_info)›%{$reset_color%}'
-local nvm_node=''
-nvm_node='%{$fg[green]%}‹node-$(nvm_prompt_info)›%{$reset_color%}'
+local jenv_java='%{$fg[blue]%}‹$(jenv_prompt_info)›%{$reset_color%}'
-local jenv_java=''
-jenv_java='%{$fg[blue]%}‹$(jenv_prompt_info)›%{$reset_color%}'
+local git_branch='$(git_prompt_info)'
-local git_branch='$(git_prompt_info)%{$reset_color%}'
+local rvm_ruby='$(ruby_prompt_info)'
PROMPT="╭─${user_host} ${current_dir} ${nvm_node} ${rvm_ruby} ${jenv_java} ${git_branch}
╰─%B$%b "
@@ -27,3 +18,6 @@ RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
+
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}‹"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme
new file mode 100644
index 000000000..a21a546bc
--- /dev/null
+++ b/themes/mlh.zsh-theme
@@ -0,0 +1,59 @@
+# The Official Theme of
+## ## ## ## ##
+### ### ## ## ##
+#### #### ## ## ##
+## ### ## ## #########
+## ## ## ## ##
+## ## ## ## ##
+## ## ######## ## ##
+
+# # # # # # # # # # # # # # # # # #
+# # # Feel free to customize! # # #
+# # # # # # # # # # # # # # # # # #
+
+# To easily discover colors and their codes, type `spectrum_ls` in the terminal
+
+AT_SYMBOL=" @ "
+IN_SYMBOL=" in "
+ON_SYMBOL=" on "
+SYMBOL="$"
+
+USER_COLOR="%F{001}"
+DEVICE_COLOR="%F{033}"
+DIR_COLOR="%F{220}"
+BRANCH_COLOR="%F{001}"
+TIME_COLOR="%F{033}"
+
+username() {
+ echo "$USER_COLOR%n%f"
+}
+
+# Returns device name
+device() {
+ echo "$DEVICE_COLOR%m%f"
+}
+
+# The current directory
+directory() {
+ echo "$DIR_COLOR%1~%f"
+}
+
+# Current time with milliseconds
+current_time() {
+ echo "$TIME_COLOR%*%f"
+}
+
+# Return status of the last command
+return_status() {
+ echo "%(?..%F{001}out %?)%f"
+}
+
+# Set the git_prompt_info text
+ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
+ZSH_THEME_GIT_PROMPT_DIRTY=""
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+
+# %B and %b make the text bold
+PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SYMBOL '
+RPROMPT="$(return_status) $(current_time)"
diff --git a/themes/muse.zsh-theme b/themes/muse.zsh-theme
index c7cd9ee30..84bee52c3 100644
--- a/themes/muse.zsh-theme
+++ b/themes/muse.zsh-theme
@@ -1,33 +1,16 @@
-#!/usr/bin/env zsh
-#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-
-setopt promptsubst
-
-autoload -U add-zsh-hook
-
-PROMPT_SUCCESS_COLOR=$FG[117]
-PROMPT_FAILURE_COLOR=$FG[124]
-PROMPT_VCS_INFO_COLOR=$FG[242]
-PROMPT_PROMPT=$FG[077]
-GIT_DIRTY_COLOR=$FG[133]
-GIT_CLEAN_COLOR=$FG[118]
-GIT_PROMPT_INFO=$FG[012]
-
-PROMPT='%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%}%{$GIT_PROMPT_INFO%}$(git_prompt_info)$(virtualenv_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} '
-
-#RPS1="${return_code}"
-
-ZSH_THEME_GIT_PROMPT_PREFIX=" ("
-ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%})"
-ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘"
-ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔"
-
-ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[082]%}✚%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[166]%}✹%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[160]%}✖%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[220]%}➜%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_UNMERGED="%{$FG[082]%}═%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$FG[190]%}✭%{$reset_color%}"
+PROMPT="${FG[117]}%~%{$reset_color%}\$(git_prompt_info)\$(virtualenv_prompt_info)${FG[133]}\$(git_prompt_status) ${FG[077]}ᐅ%{$reset_color%} "
+
+ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[012]}("
+ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[012]})%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY=" ${FG[133]}✘"
+ZSH_THEME_GIT_PROMPT_CLEAN=" ${FG[118]}✔"
+
+ZSH_THEME_GIT_PROMPT_ADDED="${FG[082]}✚%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_MODIFIED="${FG[166]}✹%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DELETED="${FG[160]}✖%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_RENAMED="${FG[220]}➜%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_UNMERGED="${FG[082]}═%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_UNTRACKED="${FG[190]}✭%{$reset_color%}"
ZSH_THEME_VIRTUALENV_PREFIX=" ["
ZSH_THEME_VIRTUALENV_SUFFIX="]"
diff --git a/themes/nebirhos.zsh-theme b/themes/nebirhos.zsh-theme
index e2424465a..fc05e7955 100644
--- a/themes/nebirhos.zsh-theme
+++ b/themes/nebirhos.zsh-theme
@@ -11,7 +11,7 @@ else
fi
# Get the host name (first 4 chars)
-HOST_PROMPT_="%{$fg_bold[red]%}@$HOST ➜ %{$fg_bold[cyan]%}%c "
+HOST_PROMPT_="%{$fg_bold[red]%}@%m ➜ %{$fg_bold[cyan]%}%c "
GIT_PROMPT="%{$fg_bold[blue]%}\$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}"
PROMPT="$HOST_PROMPT_$RUBY_PROMPT_$GIT_PROMPT"
diff --git a/themes/norm.zsh-theme b/themes/norm.zsh-theme
index 13077ccf5..bd7ca568a 100644
--- a/themes/norm.zsh-theme
+++ b/themes/norm.zsh-theme
@@ -1,4 +1,7 @@
-PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)%{$reset_color%}'
+PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
+ZSH_THEME_HG_PROMPT_PREFIX="λ %{$fg[blue]%}hg %{$fg[red]%}"
+ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
+
diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme
index 7af44056f..cc2769e4b 100644
--- a/themes/obraun.zsh-theme
+++ b/themes/obraun.zsh-theme
@@ -1,4 +1,4 @@
-if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
+if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
diff --git a/themes/peepcode.zsh-theme b/themes/peepcode.zsh-theme
index b6dfa6870..044534614 100644
--- a/themes/peepcode.zsh-theme
+++ b/themes/peepcode.zsh-theme
@@ -4,11 +4,11 @@
#
git_repo_path() {
- git rev-parse --git-dir 2>/dev/null
+ command git rev-parse --git-dir 2>/dev/null
}
git_commit_id() {
- git rev-parse --short HEAD 2>/dev/null
+ command git rev-parse --short HEAD 2>/dev/null
}
git_mode() {
@@ -22,23 +22,26 @@ git_mode() {
}
git_dirty() {
- if [[ "$repo_path" != '.' && `git ls-files -m` != "" ]]; then
+ if [[ "$repo_path" != '.' && -n "$(command git ls-files -m)" ]]; then
echo " %{$fg_bold[grey]%}✗%{$reset_color%}"
fi
}
git_prompt() {
local cb=$(git_current_branch)
- if [ -n "$cb" ]; then
+ if [[ -n "$cb" ]]; then
local repo_path=$(git_repo_path)
echo " %{$fg_bold[grey]%}$cb %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)"
fi
}
-local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})"
+local smiley='%(?.%F{green}☺%f.%F{red}☹%f)'
PROMPT='
-%~
-${smiley} %{$reset_color%}'
+${VIRTUAL_ENV:+"($VIRTUAL_ENV) "}%~
+${smiley} '
-RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
+RPROMPT='%F{white} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
+
+# Disable automatic virtualenv prompt change
+export VIRTUAL_ENV_DISABLE_PROMPT=1
diff --git a/themes/pure.zsh-theme b/themes/pure.zsh-theme
deleted file mode 100644
index 98c1312af..000000000
--- a/themes/pure.zsh-theme
+++ /dev/null
@@ -1,10 +0,0 @@
-print -P '%F{yellow}'Oh My Zsh pure theme:
-cat <<-EOF
-
- The pure theme has been renamed as 'refined' as per the original author's
- request. Change your ZSH_THEME to 'refined' to avoid seeing this warning.
-
-EOF
-print -P '%f'
-
-source ${0:h:A}/refined.zsh-theme
diff --git a/themes/pygmalion-virtualenv.zsh-theme b/themes/pygmalion-virtualenv.zsh-theme
new file mode 100644
index 000000000..47b0b4fb1
--- /dev/null
+++ b/themes/pygmalion-virtualenv.zsh-theme
@@ -0,0 +1,53 @@
+# Yay! High voltage and arrows!
+
+
+function _virtualenv_prompt_info {
+ if [[ -n "$(whence virtualenv_prompt_info)" ]]; then
+ if [ -n "$(whence pyenv_prompt_info)" ]; then
+ if [ "$1" = "inline" ]; then
+ ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=%{$fg[blue]%}"::%{$fg[red]%}"
+ ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=""
+ virtualenv_prompt_info
+ fi
+ [ "$(pyenv_prompt_info)" = "${PYENV_PROMPT_DEFAULT_VERSION}" ] && virtualenv_prompt_info
+ else
+ virtualenv_prompt_info
+ fi
+ fi
+}
+
+prompt_setup_pygmalion(){
+ setopt localoptions extendedglob
+
+ ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
+ ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
+ ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
+ ZSH_THEME_GIT_PROMPT_CLEAN=""
+
+ base_prompt='$(_virtualenv_prompt_info)%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
+ post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
+
+ base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
+ post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
+
+ autoload -U add-zsh-hook
+ add-zsh-hook precmd prompt_pygmalion_precmd
+}
+
+prompt_pygmalion_precmd(){
+ setopt localoptions extendedglob
+
+ local gitinfo=$(git_prompt_info)
+ local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
+ local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
+ local prompt_length=${#exp_nocolor}
+
+ local nl=""
+
+ if [[ $prompt_length -gt 40 ]]; then
+ nl=$'\n%{\r%}';
+ fi
+ PROMPT="$base_prompt$gitinfo$nl$post_prompt"
+}
+
+prompt_setup_pygmalion
diff --git a/themes/pygmalion.zsh-theme b/themes/pygmalion.zsh-theme
index 5f5fe7f9a..b13adfd5f 100644
--- a/themes/pygmalion.zsh-theme
+++ b/themes/pygmalion.zsh-theme
@@ -1,6 +1,8 @@
# Yay! High voltage and arrows!
prompt_setup_pygmalion(){
+ setopt localoptions extendedglob
+
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
@@ -9,26 +11,22 @@ prompt_setup_pygmalion(){
base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
- base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
- post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
+ base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
+ post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
- precmd_functions+=(prompt_pygmalion_precmd)
+ autoload -U add-zsh-hook
+ add-zsh-hook precmd prompt_pygmalion_precmd
}
prompt_pygmalion_precmd(){
+ setopt localoptions extendedglob
+
local gitinfo=$(git_prompt_info)
- local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
+ local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
local prompt_length=${#exp_nocolor}
- local nl=""
-
- if [[ $prompt_length -gt 40 ]]; then
- nl=$'\n%{\r%}';
- fi
- PROMPT="$base_prompt$gitinfo$nl$post_prompt"
+ PROMPT="${base_prompt}${gitinfo}${post_prompt}"
}
prompt_setup_pygmalion
-
-
diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme
new file mode 100644
index 000000000..f0b8e5c18
--- /dev/null
+++ b/themes/random.zsh-theme
@@ -0,0 +1,47 @@
+# Deprecate ZSH_THEME_RANDOM_BLACKLIST
+if [[ -n "$ZSH_THEME_RANDOM_BLACKLIST" ]]; then
+ echo '[oh-my-zsh] ZSH_THEME_RANDOM_BLACKLIST is deprecated. Use `ZSH_THEME_RANDOM_IGNORED` instead.'
+ ZSH_THEME_RANDOM_IGNORED=($ZSH_THEME_RANDOM_BLACKLIST)
+ unset ZSH_THEME_RANDOM_BLACKLIST
+fi
+
+# Make themes a unique array
+typeset -Ua themes
+
+if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then
+ # Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
+ themes=(${(@)ZSH_THEME_RANDOM_CANDIDATES:#random})
+else
+ # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
+ themes=(
+ "$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
+ "$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
+ "$ZSH"/themes/*.zsh-theme(N:t:r)
+ )
+ # Remove ignored themes from the list
+ for theme in random ${ZSH_THEME_RANDOM_IGNORED[@]}; do
+ themes=("${(@)themes:#$theme}")
+ done
+fi
+
+# Choose a theme out of the pool of candidates
+N=${#themes[@]}
+(( N = (RANDOM%N) + 1 ))
+RANDOM_THEME="${themes[$N]}"
+unset N themes theme
+
+# Source theme
+if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme"
+elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme"
+elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH/themes/$RANDOM_THEME.zsh-theme"
+else
+ echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found"
+ return 1
+fi
+
+if [[ -z "$ZSH_THEME_RANDOM_QUIET" ]]; then
+ echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
+fi
diff --git a/themes/re5et.zsh-theme b/themes/re5et.zsh-theme
index 95af1e2ee..bdf342f49 100644
--- a/themes/re5et.zsh-theme
+++ b/themes/re5et.zsh-theme
@@ -1,4 +1,4 @@
-if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
+if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
diff --git a/themes/refined.zsh-theme b/themes/refined.zsh-theme
index 0e5681cc7..2a4188c9d 100644
--- a/themes/refined.zsh-theme
+++ b/themes/refined.zsh-theme
@@ -72,6 +72,7 @@ preexec() {
precmd() {
vcs_info # Get version control info before we start outputting stuff
print -P "\n$(repo_information) %F{yellow}$(cmd_exec_time)%f"
+ unset cmd_timestamp #Reset cmd exec time.
}
# Define prompts
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
index f9eca6a87..2fd5f2cdc 100644
--- a/themes/robbyrussell.zsh-theme
+++ b/themes/robbyrussell.zsh-theme
@@ -1,5 +1,5 @@
-local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
-PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
+PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme
index 63ce4261b..ef91c5ee3 100644
--- a/themes/simonoff.zsh-theme
+++ b/themes/simonoff.zsh-theme
@@ -23,7 +23,7 @@ function precmd {
local promptsize=${#${(%):---(%n@%M:%l)---()}}
local pwdsize=${#${(%):-%~}}
local gitbranch="$(git_prompt_info)"
- local rvmprompt="$(rvm_prompt_info)"
+ local rvmprompt="$(ruby_prompt_info)"
local gitbranchsize=${#${gitbranch:-''}}
local rvmpromptsize=${#${rvmprompt:-''}}
@@ -90,8 +90,8 @@ setprompt () {
ZSH_THEME_GIT_PROMPT_SUFFIX="]"
###
# Modify RVM prompt
- ZSH_THEME_RVM_PROMPT_PREFIX=" ["
- ZSH_THEME_RVM_PROMPT_SUFFIX="]"
+ ZSH_THEME_RUBY_PROMPT_PREFIX=" ["
+ ZSH_THEME_RUBY_PROMPT_SUFFIX="]"
###
diff --git a/themes/smt.zsh-theme b/themes/smt.zsh-theme
index f2b0526b7..7f54472c6 100644
--- a/themes/smt.zsh-theme
+++ b/themes/smt.zsh-theme
@@ -21,9 +21,9 @@ ZSH_THEME_GIT_PROMPT_SHA_BEFORE="➤ %{$fg_bold[yellow]%}"
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}"
function prompt_char() {
- git branch >/dev/null 2>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return
- hg root >/dev/null 2>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return
- darcs show repo >/dev/null 2>/dev/null && echo "%{$fg_bold[green]%}❉%{$reset_color%}" && return
+ command git branch &>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return
+ command hg root &>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return
+ command darcs show repo &>/dev/null && echo "%{$fg_bold[green]%}❉%{$reset_color%}" && return
echo "%{$fg[cyan]%}◯%{$reset_color%}"
}
@@ -36,47 +36,44 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function git_time_since_commit() {
- if git rev-parse --git-dir > /dev/null 2>&1; then
- # Only proceed if there is actually a commit.
- if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
- # Get the last commit.
- last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
- now=`date +%s`
- seconds_since_last_commit=$((now-last_commit))
+ local COLOR MINUTES HOURS DAYS SUB_HOURS SUB_MINUTES
+ local last_commit seconds_since_last_commit
- # Totals
- MINUTES=$((seconds_since_last_commit / 60))
- HOURS=$((seconds_since_last_commit/3600))
+ # Only proceed if there is actually a commit
+ if ! last_commit=$(command git log --pretty=format:'%at' -1 2>/dev/null); then
+ echo "[$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL~%{$reset_color%}]"
+ return
+ fi
- # Sub-hours and sub-minutes
- DAYS=$((seconds_since_last_commit / 86400))
- SUB_HOURS=$((HOURS % 24))
- SUB_MINUTES=$((MINUTES % 60))
+ # Totals
+ seconds_since_last_commit=$(( EPOCHSECONDS - last_commit ))
+ MINUTES=$(( seconds_since_last_commit / 60 ))
+ HOURS=$(( MINUTES / 60 ))
- if [[ -n $(git status -s 2> /dev/null) ]]; then
- if [ "$MINUTES" -gt 30 ]; then
- COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
- elif [ "$MINUTES" -gt 10 ]; then
- COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
- else
- COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
- fi
- else
- COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
- fi
+ # Sub-hours and sub-minutes
+ DAYS=$(( HOURS / 24 ))
+ SUB_HOURS=$(( HOURS % 24 ))
+ SUB_MINUTES=$(( MINUTES % 60 ))
- if [ "$HOURS" -gt 24 ]; then
- echo "[$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}]"
- elif [ "$MINUTES" -gt 60 ]; then
- echo "[$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}]"
- else
- echo "[$COLOR${MINUTES}m%{$reset_color%}]"
- fi
+ if [[ -z "$(command git status -s 2>/dev/null)" ]]; then
+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
+ else
+ if [[ "$MINUTES" -gt 30 ]]; then
+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
+ elif [[ "$MINUTES" -gt 10 ]]; then
+ COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
else
- COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
- echo "[$COLOR~]"
+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
fi
fi
+
+ if [[ "$HOURS" -gt 24 ]]; then
+ echo "[${COLOR}${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}]"
+ elif [[ "$MINUTES" -gt 60 ]]; then
+ echo "[${COLOR}${HOURS}h${SUB_MINUTES}m%{$reset_color%}]"
+ else
+ echo "[${COLOR}${MINUTES}m%{$reset_color%}]"
+ fi
}
PROMPT='
diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme
index e3f4019d6..11f6af127 100644
--- a/themes/sunrise.zsh-theme
+++ b/themes/sunrise.zsh-theme
@@ -1,5 +1,5 @@
# Sunrise theme for oh-my-zsh
-# Intended to be used with Solarized: http://ethanschoonover.com/solarized
+# Intended to be used with Solarized: https://ethanschoonover.com/solarized
# Color shortcuts
R=$fg_no_bold[red]
@@ -9,7 +9,7 @@ Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue]
RESET=$reset_color
-if [ "$USER" = "root" ]; then
+if [ "$USERNAME" = "root" ]; then
PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-";
else
PROMPTCOLOR="" PROMPTPREFIX="---";
diff --git a/themes/suvash.zsh-theme b/themes/suvash.zsh-theme
index 1680973df..850476cdf 100644
--- a/themes/suvash.zsh-theme
+++ b/themes/suvash.zsh-theme
@@ -8,20 +8,7 @@ function virtualenv_info {
[[ -n "$VIRTUAL_ENV" ]] && echo '('${VIRTUAL_ENV:t}') '
}
-function ruby_prompt {
- if (( $+commands[rvm-prompt] )); then
- print -n $ZSH_THEME_RUBY_PROMPT_PREFIX
- print -n $(~/.rvm/bin/rvm-prompt)
- print -n $ZSH_THEME_RUBY_PROMPT_SUFFIX
- elif (( $+commands[rbenv] )); then
- print -n $ZSH_THEME_RUBY_PROMPT_PREFIX
- print -n $(rbenv version | sed -e "s/ (set.*$//")
- print -n $ZSH_THEME_RUBY_PROMPT_SUFFIX
- fi
- return 0
-}
-
-PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)$(ruby_prompt)
+PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)$(ruby_prompt_info)
$(virtualenv_info) $(prompt_char) '
ZSH_THEME_GIT_PROMPT_PREFIX=' on %F{magenta}'
diff --git a/themes/tjkirch.zsh-theme b/themes/tjkirch.zsh-theme
index 446cde724..c51609860 100644
--- a/themes/tjkirch.zsh-theme
+++ b/themes/tjkirch.zsh-theme
@@ -10,6 +10,6 @@ function prompt_char {
PROMPT='%(?, ,%{$fg[red]%}FAIL: $?%{$reset_color%}
)
%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info)
-%_$(prompt_char) '
+$(prompt_char) '
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
diff --git a/themes/tjkirch_mod.zsh-theme b/themes/tjkirch_mod.zsh-theme
index 1b206a7e1..2dd060ea1 100644
--- a/themes/tjkirch_mod.zsh-theme
+++ b/themes/tjkirch_mod.zsh-theme
@@ -8,6 +8,6 @@ function prompt_char {
}
PROMPT='%(?,,%{$fg[red]%}FAIL: $?%{$reset_color%}
-)%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) %_$(prompt_char) '
+)%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) $(prompt_char) '
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme
index 144d2549a..4e3238393 100644
--- a/themes/trapd00r.zsh-theme
+++ b/themes/trapd00r.zsh-theme
@@ -2,7 +2,7 @@
#
# This theme needs a terminal supporting 256 colors as well as unicode.
# In order to avoid external dependencies, it also has a zsh version of
-# the perl script at https://github.com/trapd00r/utils/blob/master/zsh_path,
+# the previously used perl script https://github.com/trapd00r/utils/blob/master/zsh_path,
# which splits up the current path and makes it fancy.
#
# By default it spans over two lines like so:
@@ -109,23 +109,23 @@ prompt_jnrowe_precmd () {
vcs_info
if [ "${vcs_info_msg_0_}" = "" ]; then
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
- PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
+ PROMPT='${dir_status} ${ret_status}%{$reset_color%}
> '
# modified, to be committed
elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%}
-%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
+${dir_status}%{$reset_color%}
> '
elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%}
-%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
+${dir_status}%{$reset_color%}
%{$c13%}>%{$c0%} '
else
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}
-%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
+${dir_status}%{$reset_color%}
> '
fi
}
diff --git a/themes/wedisagree.zsh-theme b/themes/wedisagree.zsh-theme
index 9bdbce40d..07006ecd9 100644
--- a/themes/wedisagree.zsh-theme
+++ b/themes/wedisagree.zsh-theme
@@ -28,7 +28,7 @@ PROMPT='%{$fg[magenta]%}[%c] %{$reset_color%}'
RPROMPT='${time} %{$fg[magenta]%}$(git_prompt_info)%{$reset_color%}$(git_prompt_status)%{$reset_color%}$(git_prompt_ahead)%{$reset_color%}'
# Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name
-# %{$fg[yellow]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%}
+# $(ruby_prompt_info)
# local time, color coded by last return code
time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
@@ -48,6 +48,9 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%} ➜" # ⓡ ⑄
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%} ♒" # ⓤ ⑊
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[blue]%} 𝝙"
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[yellow]%}"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
+
# More symbols to choose from:
# ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷
# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠
diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme
index 89d5355dc..303c898b4 100644
--- a/themes/ys.zsh-theme
+++ b/themes/ys.zsh-theme
@@ -26,15 +26,26 @@ ys_hg_prompt_info() {
if [ -d '.hg' ]; then
echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}"
echo -n $(hg branch 2>/dev/null)
- if [ -n "$(hg status 2>/dev/null)" ]; then
- echo -n "$YS_VCS_PROMPT_DIRTY"
- else
- echo -n "$YS_VCS_PROMPT_CLEAN"
+ if [[ "$(hg config oh-my-zsh.hide-dirty 2>/dev/null)" != "1" ]]; then
+ if [ -n "$(hg status 2>/dev/null)" ]; then
+ echo -n "$YS_VCS_PROMPT_DIRTY"
+ else
+ echo -n "$YS_VCS_PROMPT_CLEAN"
+ fi
fi
echo -n "$YS_VCS_PROMPT_SUFFIX"
fi
}
+# Virtualenv
+local venv_info='$(virtenv_prompt)'
+YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
+YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
+virtenv_prompt() {
+ [[ -n ${VIRTUAL_ENV} ]] || return
+ echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
+}
+
local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
# Prompt format:
@@ -55,6 +66,7 @@ PROMPT="
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
${hg_info}\
${git_info}\
+${venv_info}\
\
%{$fg[white]%}[%*] $exit_code
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
diff --git a/tools/changelog.sh b/tools/changelog.sh
new file mode 100755
index 000000000..836afef14
--- /dev/null
+++ b/tools/changelog.sh
@@ -0,0 +1,431 @@
+#!/usr/bin/env zsh
+
+##############################
+# CHANGELOG SCRIPT CONSTANTS #
+##############################
+
+#* Holds the list of valid types recognized in a commit subject
+#* and the display string of such type
+local -A TYPES
+TYPES=(
+ build "Build system"
+ chore "Chore"
+ ci "CI"
+ docs "Documentation"
+ feat "Features"
+ fix "Bug fixes"
+ perf "Performance"
+ refactor "Refactor"
+ style "Style"
+ test "Testing"
+)
+
+#* Types that will be displayed in their own section,
+#* in the order specified here.
+local -a MAIN_TYPES
+MAIN_TYPES=(feat fix perf docs)
+
+#* Types that will be displayed under the category of other changes
+local -a OTHER_TYPES
+OTHER_TYPES=(refactor style other)
+
+#* Commit types that don't appear in $MAIN_TYPES nor $OTHER_TYPES
+#* will not be displayed and will simply be ignored.
+
+
+############################
+# COMMIT PARSING UTILITIES #
+############################
+
+function parse-commit {
+
+ # This function uses the following globals as output: commits (A),
+ # subjects (A), scopes (A) and breaking (A). All associative arrays (A)
+ # have $hash as the key.
+ # - commits holds the commit type
+ # - subjects holds the commit subject
+ # - scopes holds the scope of a commit
+ # - breaking holds the breaking change warning if a commit does
+ # make a breaking change
+
+ function commit:type {
+ local type="$(sed -E 's/^([a-zA-Z_\-]+)(\(.+\))?!?: .+$/\1/' <<< "$1")"
+
+ # If $type doesn't appear in $TYPES array mark it as 'other'
+ if [[ -n "${(k)TYPES[(i)$type]}" ]]; then
+ echo $type
+ else
+ echo other
+ fi
+ }
+
+ function commit:scope {
+ local scope
+
+ # Try to find scope in "type(<scope>):" format
+ scope=$(sed -nE 's/^[a-zA-Z_\-]+\((.+)\)!?: .+$/\1/p' <<< "$1")
+ if [[ -n "$scope" ]]; then
+ echo "$scope"
+ return
+ fi
+
+ # If no scope found, try to find it in "<scope>:" format
+ # Make sure it's not a type before printing it
+ scope=$(sed -nE 's/^([a-zA-Z_\-]+): .+$/\1/p' <<< "$1")
+ if [[ -z "${(k)TYPES[(i)$scope]}" ]]; then
+ echo "$scope"
+ fi
+ }
+
+ function commit:subject {
+ # Only display the relevant part of the commit, i.e. if it has the format
+ # type[(scope)!]: subject, where the part between [] is optional, only
+ # displays subject. If it doesn't match the format, returns the whole string.
+ sed -E 's/^[a-zA-Z_\-]+(\(.+\))?!?: (.+)$/\2/' <<< "$1"
+ }
+
+ # Return subject if the body or subject match the breaking change format
+ function commit:is-breaking {
+ local subject="$1" body="$2" message
+
+ if [[ "$body" =~ "BREAKING CHANGE: (.*)" || \
+ "$subject" =~ '^[^ :\)]+\)?!: (.*)$' ]]; then
+ message="${match[1]}"
+ # remove CR characters (might be inserted in GitHub UI commit description form)
+ message="${message//$'\r'/}"
+ # skip next paragraphs (separated by two newlines or more)
+ message="${message%%$'\n\n'*}"
+ # ... and replace newlines with spaces
+ echo "${message//$'\n'/ }"
+ else
+ return 1
+ fi
+ }
+
+ # Return truncated hash of the reverted commit
+ function commit:is-revert {
+ local subject="$1" body="$2"
+
+ if [[ "$subject" = Revert* && \
+ "$body" =~ "This reverts commit ([^.]+)\." ]]; then
+ echo "${match[1]:0:7}"
+ else
+ return 1
+ fi
+ }
+
+ # Parse commit with hash $1
+ local hash="$1" subject body warning rhash
+ subject="$(command git show -s --format=%s $hash)"
+ body="$(command git show -s --format=%b $hash)"
+
+ # Commits following Conventional Commits (https://www.conventionalcommits.org/)
+ # have the following format, where parts between [] are optional:
+ #
+ # type[(scope)][!]: subject
+ #
+ # commit body
+ # [BREAKING CHANGE: warning]
+
+ # commits holds the commit type
+ commits[$hash]="$(commit:type "$subject")"
+ # scopes holds the commit scope
+ scopes[$hash]="$(commit:scope "$subject")"
+ # subjects holds the commit subject
+ subjects[$hash]="$(commit:subject "$subject")"
+
+ # breaking holds whether a commit has breaking changes
+ # and its warning message if it does
+ if warning=$(commit:is-breaking "$subject" "$body"); then
+ breaking[$hash]="$warning"
+ fi
+
+ # reverts holds commits reverted in the same release
+ if rhash=$(commit:is-revert "$subject" "$body"); then
+ reverts[$hash]=$rhash
+ fi
+}
+
+#############################
+# RELEASE CHANGELOG DISPLAY #
+#############################
+
+function display-release {
+
+ # This function uses the following globals: output, version,
+ # commits (A), subjects (A), scopes (A), breaking (A) and reverts (A).
+ #
+ # - output is the output format to use when formatting (raw|text|md)
+ # - version is the version in which the commits are made
+ # - commits, subjects, scopes, breaking, and reverts are associative arrays
+ # with commit hashes as keys
+
+ # Remove commits that were reverted
+ local hash rhash
+ for hash rhash in ${(kv)reverts}; do
+ if (( ${+commits[$rhash]} )); then
+ # Remove revert commit
+ unset "commits[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]"
+ # Remove reverted commit
+ unset "commits[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]"
+ fi
+ done
+
+ # If no commits left skip displaying the release
+ if (( $#commits == 0 )); then
+ return
+ fi
+
+ ##* Formatting functions
+
+ # Format the hash according to output format
+ # If no parameter is passed, assume it comes from `$hash`
+ function fmt:hash {
+ #* Uses $hash from outer scope
+ local hash="${1:-$hash}"
+ case "$output" in
+ raw) printf "$hash" ;;
+ text) printf "\e[33m$hash\e[0m" ;; # red
+ md) printf "[\`$hash\`](https://github.com/ohmyzsh/ohmyzsh/commit/$hash)" ;;
+ esac
+ }
+
+ # Format headers according to output format
+ # Levels 1 to 2 are considered special, the rest are formatted
+ # the same, except in md output format.
+ function fmt:header {
+ local header="$1" level="$2"
+ case "$output" in
+ raw)
+ case "$level" in
+ 1) printf "$header\n$(printf '%.0s=' {1..${#header}})\n\n" ;;
+ 2) printf "$header\n$(printf '%.0s-' {1..${#header}})\n\n" ;;
+ *) printf "$header:\n\n" ;;
+ esac ;;
+ text)
+ case "$level" in
+ 1|2) printf "\e[1;4m$header\e[0m\n\n" ;; # bold, underlined
+ *) printf "\e[1m$header:\e[0m\n\n" ;; # bold
+ esac ;;
+ md) printf "$(printf '%.0s#' {1..${level}}) $header\n\n" ;;
+ esac
+ }
+
+ function fmt:scope {
+ #* Uses $scopes (A) and $hash from outer scope
+ local scope="${1:-${scopes[$hash]}}"
+
+ # Get length of longest scope for padding
+ local max_scope=0 padding=0
+ for hash in ${(k)scopes}; do
+ max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope ))
+ done
+
+ # If no scopes, exit the function
+ if [[ $max_scope -eq 0 ]]; then
+ return
+ fi
+
+ # Get how much padding is required for this scope
+ padding=$(( max_scope < ${#scope} ? 0 : max_scope - ${#scope} ))
+ padding="${(r:$padding:: :):-}"
+
+ # If no scope, print padding and 3 spaces (equivalent to "[] ")
+ if [[ -z "$scope" ]]; then
+ printf "${padding} "
+ return
+ fi
+
+ # Print [scope]
+ case "$output" in
+ raw|md) printf "[$scope]${padding} " ;;
+ text) printf "[\e[38;5;9m$scope\e[0m]${padding} " ;; # red 9
+ esac
+ }
+
+ # If no parameter is passed, assume it comes from `$subjects[$hash]`
+ function fmt:subject {
+ #* Uses $subjects (A) and $hash from outer scope
+ local subject="${1:-${subjects[$hash]}}"
+
+ # Capitalize first letter of the subject
+ subject="${(U)subject:0:1}${subject:1}"
+
+ case "$output" in
+ raw) printf "$subject" ;;
+ # In text mode, highlight (#<issue>) and dim text between `backticks`
+ text) sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" ;;
+ # In markdown mode, link to (#<issue>) issues
+ md) sed -E 's|#([0-9]+)|[#\1](https://github.com/ohmyzsh/ohmyzsh/issues/\1)|g' <<< "$subject" ;;
+ esac
+ }
+
+ function fmt:type {
+ #* Uses $type from outer scope
+ local type="${1:-${TYPES[$type]:-${(C)type}}}"
+ [[ -z "$type" ]] && return 0
+ case "$output" in
+ raw|md) printf "$type: " ;;
+ text) printf "\e[4m$type\e[24m: " ;; # underlined
+ esac
+ }
+
+ ##* Section functions
+
+ function display:version {
+ fmt:header "$version" 2
+ }
+
+ function display:breaking {
+ (( $#breaking != 0 )) || return 0
+
+ case "$output" in
+ raw) fmt:header "BREAKING CHANGES" 3 ;;
+ text|md) fmt:header "⚠ BREAKING CHANGES" 3 ;;
+ esac
+
+ local hash subject
+ for hash message in ${(kv)breaking}; do
+ echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject "${message}")"
+ done | sort
+ echo
+ }
+
+ function display:type {
+ local hash type="$1"
+
+ local -a hashes
+ hashes=(${(k)commits[(R)$type]})
+
+ # If no commits found of type $type, go to next type
+ (( $#hashes != 0 )) || return 0
+
+ fmt:header "${TYPES[$type]}" 3
+ for hash in $hashes; do
+ echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject)"
+ done | sort -k3 # sort by scope
+ echo
+ }
+
+ function display:others {
+ local hash type
+
+ # Commits made under types considered other changes
+ local -A changes
+ changes=(${(kv)commits[(R)${(j:|:)OTHER_TYPES}]})
+
+ # If no commits found under "other" types, don't display anything
+ (( $#changes != 0 )) || return 0
+
+ fmt:header "Other changes" 3
+ for hash type in ${(kv)changes}; do
+ case "$type" in
+ other) echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject)" ;;
+ *) echo " - $(fmt:hash) $(fmt:scope)$(fmt:type)$(fmt:subject)" ;;
+ esac
+ done | sort -k3 # sort by scope
+ echo
+ }
+
+ ##* Release sections order
+
+ # Display version header
+ display:version
+
+ # Display breaking changes first
+ display:breaking
+
+ # Display changes for commit types in the order specified
+ for type in $MAIN_TYPES; do
+ display:type "$type"
+ done
+
+ # Display other changes
+ display:others
+}
+
+function main {
+ # $1 = until commit, $2 = since commit
+ local until="$1" since="$2"
+
+ # $3 = output format (--text|--raw|--md)
+ # --md: uses markdown formatting
+ # --raw: outputs without style
+ # --text: uses ANSI escape codes to style the output
+ local output=${${3:-"--text"}#--*}
+
+ if [[ -z "$until" ]]; then
+ until=HEAD
+ fi
+
+ if [[ -z "$since" ]]; then
+ # If $since is not specified:
+ # 1) try to find the version used before updating
+ # 2) try to find the first version tag before $until
+ since=$(command git config --get oh-my-zsh.lastVersion 2>/dev/null) || \
+ since=$(command git describe --abbrev=0 --tags "$until^" 2>/dev/null) || \
+ unset since
+ elif [[ "$since" = --all ]]; then
+ unset since
+ fi
+
+ # Commit classification arrays
+ local -A commits subjects scopes breaking reverts
+ local truncate=0 read_commits=0
+ local hash version tag
+
+ # Get the first version name:
+ # 1) try tag-like version, or
+ # 2) try name-rev, or
+ # 3) try branch name, or
+ # 4) try short hash
+ version=$(command git describe --tags $until 2>/dev/null) \
+ || version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" $until 2>/dev/null) \
+ || version=$(command git symbolic-ref --quiet --short $until 2>/dev/null) \
+ || version=$(command git rev-parse --short $until 2>/dev/null)
+
+ # Get commit list from $until commit until $since commit, or until root
+ # commit if $since is unset, in short hash form.
+ # --first-parent is used when dealing with merges: it only prints the
+ # merge commit, not the commits of the merged branch.
+ command git rev-list --first-parent --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do
+ # Truncate list on versions with a lot of commits
+ if [[ -z "$since" ]] && (( ++read_commits > 35 )); then
+ truncate=1
+ break
+ fi
+
+ # If we find a new release (exact tag)
+ if tag=$(command git describe --exact-match --tags $hash 2>/dev/null); then
+ # Output previous release
+ display-release
+ # Reinitialize commit storage
+ commits=()
+ subjects=()
+ scopes=()
+ breaking=()
+ reverts=()
+ # Start work on next release
+ version="$tag"
+ read_commits=1
+ fi
+
+ parse-commit "$hash"
+ done
+
+ display-release
+
+ if (( truncate )); then
+ echo " ...more commits omitted"
+ echo
+ fi
+}
+
+cd "$ZSH"
+
+# Use raw output if stdout is not a tty
+if [[ ! -t 1 && -z "$3" ]]; then
+ main "$1" "$2" --raw
+else
+ main "$@"
+fi
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 05b31e8d4..29a48b880 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -1,60 +1,91 @@
-#!/usr/bin/env zsh
+# Migrate .zsh-update file to $ZSH_CACHE_DIR
+if [[ -f ~/.zsh-update && ! -f "${ZSH_CACHE_DIR}/.zsh-update" ]]; then
+ mv ~/.zsh-update "${ZSH_CACHE_DIR}/.zsh-update"
+fi
+
+# Cancel update if:
+# - the automatic update is disabled.
+# - the current user doesn't have write permissions nor owns the $ZSH directory.
+# - git is unavailable on the system.
+if [[ "$DISABLE_AUTO_UPDATE" = true ]] \
+ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
+ || ! command -v git &>/dev/null; then
+ return
+fi
-zmodload zsh/datetime
-function _current_epoch() {
- echo $(( $EPOCHSECONDS / 60 / 60 / 24 ))
+function current_epoch() {
+ zmodload zsh/datetime
+ echo $(( EPOCHSECONDS / 60 / 60 / 24 ))
}
-function _update_zsh_update() {
- echo "LAST_EPOCH=$(_current_epoch)" >! ${ZSH_CACHE_DIR}/.zsh-update
+function update_last_updated_file() {
+ echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
}
-function _upgrade_zsh() {
- env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
- # update the zsh file
- _update_zsh_update
+function update_ohmyzsh() {
+ if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive; then
+ update_last_updated_file
+ fi
}
-epoch_target=$UPDATE_ZSH_DAYS
-if [[ -z "$epoch_target" ]]; then
- # Default to old behavior
- epoch_target=13
-fi
+() {
+ emulate -L zsh
-# Cancel upgrade if the current user doesn't have write permissions for the
-# oh-my-zsh directory.
-[[ -w "$ZSH" ]] || return 0
+ local epoch_target mtime option LAST_EPOCH
-# Cancel upgrade if git is unavailable on the system
-whence git >/dev/null || return 0
+ # Remove lock directory if older than a day
+ zmodload zsh/datetime
+ zmodload -F zsh/stat b:zstat
+ if mtime=$(zstat +mtime "$ZSH/log/update.lock" 2>/dev/null); then
+ if (( (mtime + 3600 * 24) < EPOCHSECONDS )); then
+ command rm -rf "$ZSH/log/update.lock"
+ fi
+ fi
-if mkdir "$ZSH/log/update.lock" 2>/dev/null; then
- if [ -f ${ZSH_CACHE_DIR}/.zsh-update ]; then
- . ${ZSH_CACHE_DIR}/.zsh-update
+ # Check for lock directory
+ if ! command mkdir "$ZSH/log/update.lock" 2>/dev/null; then
+ return
+ fi
- if [[ -z "$LAST_EPOCH" ]]; then
- _update_zsh_update && return 0
- fi
+ # Remove lock directory on exit. `return 1` is important for when trapping a SIGINT:
+ # The return status from the function is handled specially. If it is zero, the signal is
+ # assumed to have been handled, and execution continues normally. Otherwise, the shell
+ # will behave as interrupted except that the return status of the trap is retained.
+ trap "
+ unset -f current_epoch update_last_updated_file update_ohmyzsh
+ command rm -rf '$ZSH/log/update.lock'
+ return 1
+ " EXIT INT QUIT
- epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
- if [ $epoch_diff -gt $epoch_target ]; then
- if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
- _upgrade_zsh
- else
- echo "[Oh My Zsh] Would you like to update? [Y/n]: \c"
- read line
- if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
- _upgrade_zsh
- else
- _update_zsh_update
- fi
- fi
- fi
- else
- # create the zsh file
- _update_zsh_update
+ # Create or update .zsh-update file if missing or malformed
+ if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
+ update_last_updated_file
+ return
fi
- rmdir $ZSH/log/update.lock
-fi
+ # Number of days before trying to update again
+ epoch_target=${UPDATE_ZSH_DAYS:-13}
+ # Test if enough time has passed until the next update
+ if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
+ return
+ fi
+
+ # Ask for confirmation before updating unless disabled
+ if [[ "$DISABLE_UPDATE_PROMPT" = true ]]; then
+ update_ohmyzsh
+ else
+ # input sink to swallow all characters typed before the prompt
+ # and add a newline if there wasn't one after characters typed
+ while read -t -k 1 option; do true; done
+ [[ "$option" != ($'\n'|"") ]] && echo
+
+ echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
+ read -r -k 1 option
+ [[ "$option" != $'\n' ]] && echo
+ case "$option" in
+ [yY$'\n']) update_ohmyzsh ;;
+ [nN]) update_last_updated_file ;;
+ esac
+ fi
+}
diff --git a/tools/install.sh b/tools/install.sh
index 0cc020053..cfc2808fe 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -1,44 +1,94 @@
-main() {
- # Use colors, but only if connected to a terminal, and that terminal
- # supports them.
- if which tput >/dev/null 2>&1; then
- ncolors=$(tput colors)
- fi
- if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
- RED="$(tput setaf 1)"
- GREEN="$(tput setaf 2)"
- YELLOW="$(tput setaf 3)"
- BLUE="$(tput setaf 4)"
- BOLD="$(tput bold)"
- NORMAL="$(tput sgr0)"
- else
- RED=""
- GREEN=""
- YELLOW=""
- BLUE=""
- BOLD=""
- NORMAL=""
- fi
+#!/bin/sh
+#
+# This script should be run via curl:
+# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+# or via wget:
+# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+# or via fetch:
+# sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+#
+# As an alternative, you can first download the install script and run it afterwards:
+# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
+# sh install.sh
+#
+# You can tweak the install behavior by setting variables when running the script. For
+# example, to change the path to the Oh My Zsh repository:
+# ZSH=~/.zsh sh install.sh
+#
+# Respects the following environment variables:
+# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
+# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
+# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
+# BRANCH - branch to check out immediately after install (default: master)
+#
+# Other options:
+# CHSH - 'no' means the installer will not change the default shell (default: yes)
+# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)
+# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)
+#
+# You can also pass some arguments to the install script to set some these options:
+# --skip-chsh: has the same behavior as setting CHSH to 'no'
+# --unattended: sets both CHSH and RUNZSH to 'no'
+# --keep-zshrc: sets KEEP_ZSHRC to 'yes'
+# For example:
+# sh install.sh --unattended
+# or:
+# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
+#
+set -e
- # Only enable exit-on-error after the non-critical colorization stuff,
- # which may fail on systems lacking tput or terminfo
- set -e
+# Track if $ZSH was provided
+custom_zsh=${ZSH:+yes}
- if ! command -v zsh >/dev/null 2>&1; then
- printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
- exit
- fi
+# Default settings
+ZSH=${ZSH:-~/.oh-my-zsh}
+REPO=${REPO:-ohmyzsh/ohmyzsh}
+REMOTE=${REMOTE:-https://github.com/${REPO}.git}
+BRANCH=${BRANCH:-master}
- if [ ! -n "$ZSH" ]; then
- ZSH=~/.oh-my-zsh
- fi
+# Other options
+CHSH=${CHSH:-yes}
+RUNZSH=${RUNZSH:-yes}
+KEEP_ZSHRC=${KEEP_ZSHRC:-no}
- if [ -d "$ZSH" ]; then
- printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
- printf "You'll need to remove $ZSH if you want to re-install.\n"
- exit
- fi
+command_exists() {
+ command -v "$@" >/dev/null 2>&1
+}
+
+fmt_error() {
+ printf '%sError: %s%s\n' "$BOLD$RED" "$*" "$RESET" >&2
+}
+
+fmt_underline() {
+ printf '\033[4m%s\033[24m\n' "$*"
+}
+
+fmt_code() {
+ # shellcheck disable=SC2016 # backtic in single-quote
+ printf '`\033[38;5;247m%s%s`\n' "$*" "$RESET"
+}
+
+setup_color() {
+ # Only use colors if connected to a terminal
+ if [ -t 1 ]; then
+ RED=$(printf '\033[31m')
+ GREEN=$(printf '\033[32m')
+ YELLOW=$(printf '\033[33m')
+ BLUE=$(printf '\033[34m')
+ BOLD=$(printf '\033[1m')
+ RESET=$(printf '\033[m')
+ else
+ RED=""
+ GREEN=""
+ YELLOW=""
+ BLUE=""
+ BOLD=""
+ RESET=""
+ fi
+}
+
+setup_ohmyzsh() {
# Prevent the cloned repository from having insecure permissions. Failing to do
# so causes compinit() calls to fail with "command not found: compdef" errors
# for users with insecure umasks (e.g., "002", allowing group writability). Note
@@ -46,69 +96,228 @@ main() {
# precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w
- printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
- command -v git >/dev/null 2>&1 || {
- echo "Error: git is not installed"
+ echo "${BLUE}Cloning Oh My Zsh...${RESET}"
+
+ command_exists git || {
+ fmt_error "git is not installed"
exit 1
}
- # The Windows (MSYS) Git is not compatible with normal use on cygwin
- if [ "$OSTYPE" = cygwin ]; then
- if git --version | grep msysgit > /dev/null; then
- echo "Error: Windows/MSYS Git is not supported on Cygwin"
- echo "Error: Make sure the Cygwin git package is installed and is first on the path"
- exit 1
- fi
+
+ ostype=$(uname)
+ if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -q msysgit; then
+ fmt_error "Windows/MSYS Git is not supported on Cygwin"
+ fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH"
+ exit 1
fi
- env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$ZSH" || {
- printf "Error: git clone of oh-my-zsh repo failed\n"
+
+ git clone -c core.eol=lf -c core.autocrlf=false \
+ -c fsck.zeroPaddedFilemode=ignore \
+ -c fetch.fsck.zeroPaddedFilemode=ignore \
+ -c receive.fsck.zeroPaddedFilemode=ignore \
+ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
+ fmt_error "git clone of oh-my-zsh repo failed"
exit 1
}
+ echo
+}
+
+setup_zshrc() {
+ # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
+ # with datestamp of installation that moved them aside, so we never actually
+ # destroy a user's original zshrc
+ echo "${BLUE}Looking for an existing zsh config...${RESET}"
- printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
+ # Must use this exact name so uninstall.sh can find it
+ OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
- printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n";
- mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
+ # Skip this if the user doesn't want to replace an existing .zshrc
+ if [ "$KEEP_ZSHRC" = yes ]; then
+ echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
+ return
+ fi
+ if [ -e "$OLD_ZSHRC" ]; then
+ OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
+ if [ -e "$OLD_OLD_ZSHRC" ]; then
+ fmt_error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
+ fmt_error "re-run the installer again in a couple of seconds"
+ exit 1
+ fi
+ mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
+
+ echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \
+ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}"
+ fi
+ echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}"
+ mv ~/.zshrc "$OLD_ZSHRC"
fi
- printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n"
- cp "$ZSH"/templates/zshrc.zsh-template ~/.zshrc
+ echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
+
sed "/^export ZSH=/ c\\
- export ZSH=\"$ZSH\"
- " ~/.zshrc > ~/.zshrc-omztemp
- mv -f ~/.zshrc-omztemp ~/.zshrc
-
- # If this user's login shell is not already "zsh", attempt to switch.
- TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
- if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
- # If this platform provides a "chsh" command (not Cygwin), do it, man!
- if hash chsh >/dev/null 2>&1; then
- printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
- chsh -s $(grep /zsh$ /etc/shells | tail -1)
- # Else, suggest the user do so manually.
+export ZSH=\"$ZSH\"
+" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
+ mv -f ~/.zshrc-omztemp ~/.zshrc
+
+ echo
+}
+
+setup_shell() {
+ # Skip setup if the user wants or stdin is closed (not running interactively).
+ if [ "$CHSH" = no ]; then
+ return
+ fi
+
+ # If this user's login shell is already "zsh", do not attempt to switch.
+ if [ "$(basename -- "$SHELL")" = "zsh" ]; then
+ return
+ fi
+
+ # If this platform doesn't provide a "chsh" command, bail out.
+ if ! command_exists chsh; then
+ cat <<EOF
+I can't change your shell automatically because this system does not have chsh.
+${BLUE}Please manually change your default shell to zsh${RESET}
+EOF
+ return
+ fi
+
+ echo "${BLUE}Time to change your default shell to zsh:${RESET}"
+
+ # Prompt for user choice on changing the default login shell
+ printf '%sDo you want to change your default shell to zsh? [Y/n]%s ' \
+ "$YELLOW" "$RESET"
+ read -r opt
+ case $opt in
+ y*|Y*|"") echo "Changing the shell..." ;;
+ n*|N*) echo "Shell change skipped."; return ;;
+ *) echo "Invalid choice. Shell change skipped."; return ;;
+ esac
+
+ # Check if we're running on Termux
+ case "$PREFIX" in
+ *com.termux*) termux=true; zsh=zsh ;;
+ *) termux=false ;;
+ esac
+
+ if [ "$termux" != true ]; then
+ # Test for the right location of the "shells" file
+ if [ -f /etc/shells ]; then
+ shells_file=/etc/shells
+ elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
+ shells_file=/usr/share/defaults/etc/shells
else
- printf "I can't change your shell automatically because this system does not have chsh.\n"
- printf "${BLUE}Please manually change your default shell to zsh!${NORMAL}\n"
+ fmt_error "could not find /etc/shells file. Change your default shell manually."
+ return
+ fi
+
+ # Get the path to the right zsh binary
+ # 1. Use the most preceding one based on $PATH, then check that it's in the shells file
+ # 2. If that fails, get a zsh path from the shells file, then check it actually exists
+ if ! zsh=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
+ if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
+ fmt_error "no zsh binary found or not present in '$shells_file'"
+ fmt_error "change your default shell manually."
+ return
+ fi
fi
fi
- printf "${GREEN}"
- echo ' __ __ '
- echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
- echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
- echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
- echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
- echo ' /____/ ....is now installed!'
- echo ''
- echo ''
- echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.'
- echo ''
- echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
- echo ''
- echo 'p.p.s. Get stickers and t-shirts at https://shop.planetargon.com.'
- echo ''
- printf "${NORMAL}"
- env zsh -l
+ # We're going to change the default shell, so back up the current one
+ if [ -n "$SHELL" ]; then
+ echo "$SHELL" > ~/.shell.pre-oh-my-zsh
+ else
+ grep "^$USERNAME:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
+ fi
+
+ # Actually change the default shell to zsh
+ if ! chsh -s "$zsh"; then
+ fmt_error "chsh command unsuccessful. Change your default shell manually."
+ else
+ export SHELL="$zsh"
+ echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
+ fi
+
+ echo
+}
+
+main() {
+ # Run as unattended if stdin is not a tty
+ if [ ! -t 0 ]; then
+ RUNZSH=no
+ CHSH=no
+ fi
+
+ # Parse arguments
+ while [ $# -gt 0 ]; do
+ case $1 in
+ --unattended) RUNZSH=no; CHSH=no ;;
+ --skip-chsh) CHSH=no ;;
+ --keep-zshrc) KEEP_ZSHRC=yes ;;
+ esac
+ shift
+ done
+
+ setup_color
+
+ if ! command_exists zsh; then
+ echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
+ exit 1
+ fi
+
+ if [ -d "$ZSH" ]; then
+ echo "${YELLOW}The \$ZSH folder already exists ($ZSH).${RESET}"
+ if [ "$custom_zsh" = yes ]; then
+ cat <<EOF
+
+You ran the installer with the \$ZSH setting or the \$ZSH variable is
+exported. You have 3 options:
+
+1. Unset the ZSH variable when calling the installer:
+ $(fmt_code "ZSH= sh install.sh")
+2. Install Oh My Zsh to a directory that doesn't exist yet:
+ $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
+3. (Caution) If the folder doesn't contain important information,
+ you can just remove it with $(fmt_code "rm -r $ZSH")
+
+EOF
+ else
+ echo "You'll need to remove it if you want to reinstall."
+ fi
+ exit 1
+ fi
+
+ setup_ohmyzsh
+ setup_zshrc
+ setup_shell
+
+ printf %s "$GREEN"
+ cat <<'EOF'
+ __ __
+ ____ / /_ ____ ___ __ __ ____ _____/ /_
+ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
+/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
+\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
+ /____/ ....is now installed!
+
+
+EOF
+ cat <<EOF
+Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.
+
+• Follow us on Twitter: $(fmt_underline https://twitter.com/ohmyzsh)
+• Join our Discord server: $(fmt_underline https://discord.gg/ohmyzsh)
+• Get stickers, shirts, coffee mugs and other swag: $(fmt_underline https://shop.planetargon.com/collections/oh-my-zsh)
+
+EOF
+ printf %s "$RESET"
+
+ if [ $RUNZSH = no ]; then
+ echo "${YELLOW}Run zsh to try it out.${RESET}"
+ exit
+ fi
+
+ exec zsh -l
}
-main
+main "$@"
diff --git a/tools/theme_chooser.sh b/tools/theme_chooser.sh
index 82ae5857c..3883f1d37 100755
--- a/tools/theme_chooser.sh
+++ b/tools/theme_chooser.sh
@@ -25,6 +25,7 @@ function theme_preview() {
print "$fg[blue]${(l.((${COLUMNS}-${#THEME_NAME}-5))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color"
source "$THEMES_DIR/$THEME"
cols=$(tput cols)
+ (exit 1)
print -P "$PROMPT $RPROMPT"
}
diff --git a/tools/uninstall.sh b/tools/uninstall.sh
index bf2244be8..6a0e7b4c7 100644
--- a/tools/uninstall.sh
+++ b/tools/uninstall.sh
@@ -9,26 +9,32 @@ if [ -d ~/.oh-my-zsh ]; then
rm -rf ~/.oh-my-zsh
fi
-echo "Looking for original zsh config..."
-if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]; then
- echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
-
- if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
- ZSHRC_SAVE=".zshrc.omz-uninstalled-$(date +%Y%m%d%H%M%S)";
- echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
- mv ~/.zshrc ~/"${ZSHRC_SAVE}";
- fi
-
- mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
+if [ -e ~/.zshrc ]; then
+ ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
+ echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
+ mv ~/.zshrc "${ZSHRC_SAVE}"
+fi
- echo "Your original zsh config was restored. Please restart your session."
+echo "Looking for original zsh config..."
+ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
+if [ -e "$ZSHRC_ORIG" ]; then
+ echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
+ mv "$ZSHRC_ORIG" ~/.zshrc
+ echo "Your original zsh config was restored."
else
- if hash chsh >/dev/null 2>&1; then
- echo "Switching back to bash"
- chsh -s /bin/bash
+ echo "No original zsh config found"
+fi
+
+if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
+ old_shell=$(cat ~/.shell.pre-oh-my-zsh)
+ echo "Switching your shell back to '$old_shell':"
+ if chsh -s "$old_shell"; then
+ rm -f ~/.shell.pre-oh-my-zsh
else
- echo "You can edit /etc/passwd to switch your default shell back to bash"
+ echo "Could not change default shell. Change it manually by running chsh"
+ echo "or editing the /etc/passwd file."
fi
fi
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
+echo "Don't forget to restart your terminal!"
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 25b2de27a..38fac3ce0 100644..100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -1,39 +1,106 @@
+#!/usr/bin/env zsh
-# Use colors, but only if connected to a terminal, and that terminal
-# supports them.
-if which tput >/dev/null 2>&1; then
- ncolors=$(tput colors)
-fi
-if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
- RED="$(tput setaf 1)"
- GREEN="$(tput setaf 2)"
- YELLOW="$(tput setaf 3)"
- BLUE="$(tput setaf 4)"
- BOLD="$(tput bold)"
- NORMAL="$(tput sgr0)"
-else
- RED=""
- GREEN=""
- YELLOW=""
- BLUE=""
- BOLD=""
- NORMAL=""
+if [ -z "$ZSH_VERSION" ]; then
+ exec zsh "$0" "$@"
fi
-printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
cd "$ZSH"
-if git pull --rebase --stat origin master
-then
- printf '%s' "$GREEN"
- printf '%s\n' ' __ __ '
- printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
- printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
- printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
- printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
- printf '%s\n' ' /____/ '
- printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
- printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
- printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: https://shop.planetargon.com/"
+
+# Use colors, but only if connected to a terminal
+# and that terminal supports them.
+
+local -a RAINBOW
+local RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
+
+if [ -t 1 ]; then
+ RAINBOW=(
+ "$(printf '\033[38;5;196m')"
+ "$(printf '\033[38;5;202m')"
+ "$(printf '\033[38;5;226m')"
+ "$(printf '\033[38;5;082m')"
+ "$(printf '\033[38;5;021m')"
+ "$(printf '\033[38;5;093m')"
+ "$(printf '\033[38;5;163m')"
+ )
+
+ RED=$(printf '\033[31m')
+ GREEN=$(printf '\033[32m')
+ YELLOW=$(printf '\033[33m')
+ BLUE=$(printf '\033[34m')
+ BOLD=$(printf '\033[1m')
+ DIM=$(printf '\033[2m')
+ UNDER=$(printf '\033[4m')
+ RESET=$(printf '\033[m')
+fi
+
+# Update upstream remote to ohmyzsh org
+git remote -v | while read remote url extra; do
+ case "$url" in
+ https://github.com/robbyrussell/oh-my-zsh(|.git))
+ git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
+ break ;;
+ git@github.com:robbyrussell/oh-my-zsh(|.git))
+ git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git"
+ break ;;
+ esac
+done
+
+# Set git-config values known to fix git errors
+# Line endings (#4069)
+git config core.eol lf
+git config core.autocrlf false
+# zeroPaddedFilemode fsck errors (#4963)
+git config fsck.zeroPaddedFilemode ignore
+git config fetch.fsck.zeroPaddedFilemode ignore
+git config receive.fsck.zeroPaddedFilemode ignore
+# autostash on rebase (#7172)
+resetAutoStash=$(git config --bool rebase.autoStash 2>/dev/null)
+git config rebase.autoStash true
+
+local ret=0
+
+# Update Oh My Zsh
+printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
+last_commit=$(git rev-parse HEAD)
+if git pull --rebase --stat origin master; then
+ # Check if it was really updated or not
+ if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
+ message="Oh My Zsh is already at the latest version."
+ else
+ message="Hooray! Oh My Zsh has been updated!"
+
+ # Save the commit prior to updating
+ git config oh-my-zsh.lastVersion "$last_commit"
+
+ # Print changelog to the terminal
+ if [[ "$1" = --interactive ]]; then
+ "$ZSH/tools/changelog.sh" HEAD "$last_commit"
+ fi
+
+ printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
+ fi
+
+ printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
+ printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
+ printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ ___/%s __ \ %s\n' $RAINBOW $RESET
+ printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
+ printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
+ printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
+ printf '\n'
+ printf "${BLUE}%s${RESET}\n" "$message"
+ printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "https://twitter.com/ohmyzsh"
+ printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Want to get involved in the community? Join our Discord:" "https://discord.gg/ohmyzsh"
+ printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Get your Oh My Zsh swag at:" "https://shop.planetargon.com/collections/oh-my-zsh"
else
- printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
+ ret=$?
+ printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
fi
+
+# Unset git-config values set just for the upgrade
+case "$resetAutoStash" in
+ "") git config --unset rebase.autoStash ;;
+ *) git config rebase.autoStash "$resetAutoStash" ;;
+esac
+
+# Exit with `1` if the update failed
+exit $ret