summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore11
-rw-r--r--CONTRIBUTING.md123
-rw-r--r--LICENSE.txt (renamed from MIT-LICENSE.txt)13
-rw-r--r--README.md (renamed from README.markdown)53
-rw-r--r--cache/.easter-egg4
-rw-r--r--cache/.gitkeep0
-rw-r--r--custom/example.zsh13
-rw-r--r--lib/clipboard.zsh8
-rw-r--r--lib/completion.zsh35
-rw-r--r--lib/functions.zsh6
-rw-r--r--lib/git.zsh41
-rw-r--r--lib/misc.zsh4
-rw-r--r--lib/nvm.zsh2
-rw-r--r--lib/theme-and-appearance.zsh56
-rw-r--r--log/.easter-egg4
-rw-r--r--log/.gitkeep0
-rw-r--r--oh-my-zsh.sh4
-rw-r--r--plugins/adb/_adb5
-rw-r--r--plugins/arcanist/README.md5
-rw-r--r--plugins/arcanist/arcanist.plugin.zsh21
-rw-r--r--plugins/archlinux/README.md143
-rw-r--r--plugins/archlinux/archlinux.plugin.zsh153
-rw-r--r--plugins/asdf/README.md27
-rw-r--r--plugins/asdf/asdf.plugin.zsh7
-rw-r--r--plugins/autoenv/autoenv.plugin.zsh2
-rw-r--r--plugins/battery/battery.plugin.zsh14
-rw-r--r--plugins/bower/bower.plugin.zsh1
-rw-r--r--plugins/branch/branch.plugin.zsh7
-rw-r--r--plugins/brew-cask/brew-cask.plugin.zsh84
-rw-r--r--plugins/brew/_brew109
-rw-r--r--plugins/brew/brew.plugin.zsh16
-rw-r--r--plugins/bundler/README.md1
-rw-r--r--plugins/bundler/bundler.plugin.zsh2
-rw-r--r--plugins/cakephp3/cakephp3.plugin.zsh27
-rw-r--r--plugins/cargo/README.md11
-rw-r--r--plugins/cargo/_cargo497
-rw-r--r--plugins/cask/README.md15
-rw-r--r--plugins/cask/cask.plugin.zsh31
-rw-r--r--plugins/chruby/chruby.plugin.zsh6
-rw-r--r--plugins/coffee/README.md2
-rw-r--r--plugins/command-not-found/command-not-found.plugin.zsh8
-rw-r--r--plugins/common-aliases/common-aliases.plugin.zsh19
-rw-r--r--plugins/composer/composer.plugin.zsh5
-rw-r--r--plugins/copybuffer/README.md11
-rw-r--r--plugins/copybuffer/copybuffer.plugin.zsh14
-rw-r--r--plugins/cp/README.md32
-rw-r--r--plugins/cp/cp.plugin.zsh18
-rw-r--r--plugins/debian/debian.plugin.zsh2
-rw-r--r--plugins/dircycle/dircycle.plugin.zsh16
-rwxr-xr-xplugins/dnf/README.md25
-rw-r--r--plugins/dnf/dnf.plugin.zsh15
-rw-r--r--plugins/docker-compose/README.md3
-rw-r--r--plugins/docker-compose/_docker-compose331
-rw-r--r--plugins/docker-compose/docker-compose.plugin.zsh23
-rw-r--r--plugins/docker/README.md20
-rw-r--r--plugins/docker/_docker3141
-rw-r--r--plugins/dotenv/README.md34
-rw-r--r--plugins/dotenv/dotenv.plugin.zsh10
-rw-r--r--plugins/droplr/README.md19
-rw-r--r--plugins/droplr/droplr.plugin.zsh15
-rw-r--r--plugins/emacs/emacs.plugin.zsh7
-rwxr-xr-xplugins/emacs/emacsclient.sh30
-rw-r--r--plugins/encode64/encode64.plugin.zsh17
-rw-r--r--plugins/extract/README.md46
-rw-r--r--plugins/extract/_extract5
-rw-r--r--plugins/extract/extract.plugin.zsh135
-rw-r--r--plugins/fasd/fasd.plugin.zsh2
-rw-r--r--plugins/firewalld/firewalld.plugin.zsh17
-rw-r--r--plugins/firewalld/readme.md22
-rw-r--r--plugins/forklift/README.md8
-rw-r--r--plugins/fossil/README.md7
-rw-r--r--plugins/fossil/fossil.plugin.zsh89
-rw-r--r--plugins/frontend-search/README.md2
-rw-r--r--plugins/frontend-search/_frontend-search.sh4
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh8
-rw-r--r--plugins/gb/README.md21
-rw-r--r--plugins/gb/_gb111
-rw-r--r--plugins/geeknote/README.md12
-rw-r--r--plugins/geeknote/_geeknote136
-rw-r--r--plugins/geeknote/geeknote.plugin.zsh2
-rw-r--r--plugins/git-flow/README.md31
-rw-r--r--plugins/git-flow/git-flow.plugin.zsh10
-rw-r--r--plugins/git/git.plugin.zsh112
-rw-r--r--plugins/gitfast/_git5
-rw-r--r--plugins/gitfast/git-completion.bash248
-rw-r--r--plugins/gitfast/git-prompt.sh132
-rw-r--r--plugins/github/README.md4
-rw-r--r--plugins/github/github.plugin.zsh2
-rw-r--r--plugins/gitignore/gitignore.plugin.zsh2
-rw-r--r--plugins/globalias/README.md62
-rw-r--r--plugins/globalias/globalias.plugin.zsh17
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh2
-rw-r--r--plugins/golang/golang.plugin.zsh14
l---------plugins/gradle/_gradle1
l---------plugins/gradle/_gradlew1
-rw-r--r--plugins/gradle/gradle.plugin.zsh125
-rw-r--r--plugins/heroku/_heroku7
-rw-r--r--plugins/history-substring-search/history-substring-search.zsh2
-rw-r--r--plugins/jira/jira.plugin.zsh7
-rw-r--r--plugins/jump/jump.plugin.zsh2
-rw-r--r--plugins/kitchen/_kitchen110
-rw-r--r--plugins/knife/_knife56
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh7
-rw-r--r--plugins/last-working-dir/README.md9
-rw-r--r--plugins/last-working-dir/last-working-dir.plugin.zsh33
-rw-r--r--plugins/lein/lein.plugin.zsh2
-rw-r--r--plugins/meteor/README.md45
-rw-r--r--plugins/meteor/meteor.plugin.zsh33
-rw-r--r--plugins/mix/_mix19
-rw-r--r--plugins/mvn/README.md33
-rw-r--r--plugins/mvn/mvn.plugin.zsh70
-rw-r--r--plugins/ng/README.md37
-rw-r--r--plugins/ng/ng.plugin.zsh77
-rw-r--r--plugins/node/node.plugin.zsh3
-rw-r--r--plugins/nomad/README.md15
-rw-r--r--plugins/nomad/_nomad153
-rw-r--r--plugins/npm/npm.plugin.zsh29
-rw-r--r--plugins/nvm/_nvm2
-rw-r--r--plugins/nvm/nvm.plugin.zsh6
-rw-r--r--plugins/osx/README.md33
-rw-r--r--plugins/osx/_man-preview5
-rw-r--r--plugins/osx/osx.plugin.zsh332
-rw-r--r--plugins/per-directory-history/README.md5
-rw-r--r--plugins/per-directory-history/per-directory-history.zsh12
-rw-r--r--plugins/perms/README.md9
-rw-r--r--plugins/perms/perms.plugin.zsh78
-rw-r--r--plugins/phing/phing.plugin.zsh11
-rw-r--r--plugins/pip/_pip36
-rw-r--r--plugins/pip/pip.plugin.zsh3
-rw-r--r--plugins/pj/README.md45
-rw-r--r--plugins/pj/pj.plugin.zsh54
-rw-r--r--plugins/pylint/pylint.plugin.zsh4
-rw-r--r--plugins/rails/rails.plugin.zsh4
-rw-r--r--plugins/rake-fast/README.md22
-rw-r--r--plugins/rake-fast/rake-fast.plugin.zsh42
-rw-r--r--plugins/react-native/README.md29
-rw-r--r--plugins/react-native/_react-native32
-rw-r--r--plugins/react-native/react-native.plugin.zsh14
-rw-r--r--plugins/rust/_rust191
-rw-r--r--plugins/sbt/sbt.plugin.zsh1
-rw-r--r--plugins/scala/_scala4
-rw-r--r--plugins/shrink-path/README.md68
-rw-r--r--plugins/shrink-path/shrink-path.plugin.zsh127
-rw-r--r--plugins/ssh-agent/README.md38
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh93
-rw-r--r--plugins/sublime/README.md6
-rw-r--r--plugins/sublime/sublime.plugin.zsh31
-rw-r--r--plugins/sudo/sudo.plugin.zsh8
-rw-r--r--plugins/suse/suse.plugin.zsh4
-rw-r--r--plugins/svn/README.md67
-rw-r--r--plugins/svn/svn.plugin.zsh56
-rw-r--r--plugins/swiftpm/README.md22
-rw-r--r--plugins/swiftpm/swiftpm.plugin.zsh8
-rw-r--r--plugins/symfony2/symfony2.plugin.zsh6
-rw-r--r--plugins/systemd/systemd.plugin.zsh2
-rw-r--r--plugins/taskwarrior/_task9
-rw-r--r--plugins/terraform/_terraform2
-rw-r--r--plugins/textmate/textmate.plugin.zsh11
-rw-r--r--plugins/tig/README.md16
-rw-r--r--plugins/tig/tig.plugin.zsh3
-rw-r--r--plugins/tmux/tmux.plugin.zsh1
-rw-r--r--plugins/ubuntu/readme.md2
-rw-r--r--plugins/ubuntu/ubuntu.plugin.zsh8
-rw-r--r--plugins/urltools/urltools.plugin.zsh9
-rw-r--r--plugins/vagrant/_vagrant2
-rw-r--r--plugins/vault/README.md18
-rw-r--r--plugins/vault/_vault400
-rw-r--r--plugins/vi-mode/vi-mode.plugin.zsh9
-rw-r--r--plugins/web-search/web-search.plugin.zsh4
-rw-r--r--plugins/wp-cli/README.md4
-rw-r--r--plugins/xcode/README.md2
-rw-r--r--plugins/xcode/xcode.plugin.zsh13
-rw-r--r--plugins/yarn/yarn.plugin.zsh81
-rw-r--r--plugins/z/README2
-rw-r--r--plugins/z/z.12
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-aliases.conf34
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-cd.conf50
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-env.conf35
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-functions.conf37
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-history.conf37
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-kill.conf41
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-list.conf54
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-options.conf35
-rw-r--r--plugins/zsh-navigation-tools/.config/znt/n-panelize.conf35
-rw-r--r--plugins/zsh-navigation-tools/NEWS17
-rw-r--r--plugins/zsh-navigation-tools/README.md137
-rw-r--r--plugins/zsh-navigation-tools/_n-kill41
-rw-r--r--plugins/zsh-navigation-tools/n-aliases4
-rw-r--r--plugins/zsh-navigation-tools/n-cd17
-rw-r--r--plugins/zsh-navigation-tools/n-env4
-rw-r--r--plugins/zsh-navigation-tools/n-functions4
-rw-r--r--plugins/zsh-navigation-tools/n-help135
-rw-r--r--plugins/zsh-navigation-tools/n-history355
-rw-r--r--plugins/zsh-navigation-tools/n-kill8
-rw-r--r--plugins/zsh-navigation-tools/n-list142
-rw-r--r--plugins/zsh-navigation-tools/n-list-draw16
-rw-r--r--plugins/zsh-navigation-tools/n-list-input163
-rw-r--r--plugins/zsh-navigation-tools/n-options4
-rw-r--r--plugins/zsh-navigation-tools/n-panelize4
-rw-r--r--plugins/zsh-navigation-tools/znt-history-widget14
-rwxr-xr-xplugins/zsh-navigation-tools/znt-tmux.zsh50
-rwxr-xr-xplugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh45
-rw-r--r--templates/zshrc.zsh-template17
-rw-r--r--themes/af-magic.zsh-theme2
-rw-r--r--themes/agnoster.zsh-theme26
-rw-r--r--themes/avit.zsh-theme23
-rw-r--r--themes/bira.zsh-theme17
-rw-r--r--themes/bureau.zsh-theme54
-rw-r--r--themes/candy.zsh-theme2
-rw-r--r--themes/dogenpunk.zsh-theme2
-rw-r--r--themes/half-life.zsh-theme2
-rw-r--r--themes/kennethreitz.zsh-theme8
-rw-r--r--themes/muse.zsh-theme7
-rw-r--r--themes/nebirhos.zsh-theme2
-rw-r--r--themes/peepcode.zsh-theme2
-rw-r--r--themes/pure.zsh-theme110
-rw-r--r--themes/refined.zsh-theme106
-rw-r--r--themes/rkj-repos.zsh-theme6
-rw-r--r--themes/robbyrussell.zsh-theme10
-rw-r--r--themes/steeef.zsh-theme2
-rw-r--r--themes/sunrise.zsh-theme6
-rw-r--r--themes/suvash.zsh-theme38
-rw-r--r--themes/trapd00r.zsh-theme4
-rw-r--r--themes/xiong-chiamiov-plus.zsh-theme2
-rw-r--r--themes/xiong-chiamiov.zsh-theme2
-rw-r--r--themes/ys.zsh-theme54
-rw-r--r--tools/check_for_upgrade.sh43
-rwxr-xr-xtools/install.sh16
228 files changed, 9734 insertions, 1977 deletions
diff --git a/.gitignore b/.gitignore
index 8fa66f02f..b2022081a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,8 @@
-locals.zsh
-log/.zsh_history
-projects.zsh
-custom
+# custom files
+custom/
!custom/plugins/example
!custom/example.zsh
-*.swp
-!custom/example.zshcache
+
+# temp files directories
cache/
+log/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..ac263fd18
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,123 @@
+# CONTRIBUTING GUIDELINES
+
+Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged and appreciated.
+It is also essential for the development of the project.
+
+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)
+
+**BONUS:** [Volunteering](#you-have-spare-time-to-volunteer)
+
+## Reporting Issues
+
+### You have a problem
+
+Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
+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)
+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.
+It should include the data gathered as indicated above, along with:
+
+1. How to reproduce the problem
+2. What the correct behavior should be
+3. What the actual behavior is
+
+Please copy to anyone relevant (_eg_ plugin maintainers) by mentioning their GitHub handle
+(starting with `@`) in your message.
+
+We will do our very best to help you.
+
+### You have a suggestion
+
+Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
+your suggestion.
+
+If you find one, comment on it so we can know there are more people supporting it.
+
+If not, you can go ahead and create an issue. Please copy to anyone relevant (_eg_ plugin
+maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
+
+## Submitting Pull Requests
+
+### Getting started
+
+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).
+
+You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree.
+
+If you create your own PR, please make sure you do it right. Also be so kind as to reference
+any issue that would be solved in the PR description body,
+[for instance](https://help.github.com/articles/closing-issues-via-commit-messages/)
+_"Fixes #XXXX"_ for issue number XXXX.
+
+### You have a solution
+
+Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
+your [problem](#you-have-a-problem), and any pending/merged/rejected PR covering your solution.
+
+If the solution is already reported, try it out and +1 the pull request if the
+solution works ok. On the other hand, if you think your solution is better, post
+it with a reference to the other one so we can have both solutions to compare.
+
+If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin
+maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
+
+### You have an addition
+
+Please [do not](https://github.com/robbyrussell/oh-my-zsh/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
+covering or related to what you want to add.
+
+If you find one, try it out and work with the author on a common solution.
+
+If not, then go ahead and submit a PR. Please copy to anyone relevant (_eg_ plugin
+maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
+
+For any extensive change, _eg_ a new plugin, you will have to find testers to +1 your PR.
+
+----
+
+## Use the Search, Luke
+
+_May the Force (of past experiences) be with you_
+
+GitHub offers [many search features](https://help.github.com/articles/searching-github/)
+to help you check whether a similar contribution to yours already exists. Please search
+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)
+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
+and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-requests).
+
+----
+
+### You have spare time to volunteer
+
+Very nice!! :)
+
+Please have a look at the [Volunteer](https://github.com/robbyrussell/oh-my-zsh/wiki/Volunteers)
+page for instructions on where to start and more.
diff --git a/MIT-LICENSE.txt b/LICENSE.txt
index dfbd90035..ed0ae75fc 100644
--- a/MIT-LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,7 @@
-The MIT License
+The MIT License (MIT)
-Copyright (c) 2009-2015 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors)
+Copyright (c) 2009-2017 Robby Russell and contributors
+See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +10,13 @@ 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 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.
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.markdown b/README.md
index 0d3144dde..fd4a0abc0 100644
--- a/README.markdown
+++ b/README.md
@@ -1,21 +1,27 @@
-![Oh My Zsh](https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png)
+<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](http://www.zsh.org/) configuration.
-Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again.
+Sounds boring. Let's try again.
-__Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able to take advantage of the hundreds of bundled plugins and pretty 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 always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often.
+__Oh My Zsh will not make you a 10x developer...but you might feel like one.__
-To learn more, visit [ohmyz.sh](http://ohmyz.sh) and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter.
+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?"_
-## Getting Started
+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](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter.
+## Getting Started
### Prerequisites
-__Disclaimer:__ _Oh My Zsh works best on Mac OS X and Linux._
+__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._
-* Unix-based operating system (Mac OS X or Linux)
-* [Zsh](http://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)
+* Unix-like operating system (macOS or Linux)
+* [Zsh](http://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
@@ -26,13 +32,13 @@ Oh My Zsh is installed by running one of the following commands in your terminal
#### via curl
```shell
-sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
+sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```
#### via wget
```shell
-sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
+sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
```
## Using Oh My Zsh
@@ -43,9 +49,9 @@ Oh My Zsh comes with a shit load of plugins to take advantage of. You can take a
#### Enabling Plugins
-If you spot a plugin (or several) that you would like to use with Oh My Zsh, you will need to edit the `~/.zshrc` file. Once you open it with your favorite editor, you'll see a spot to list all the plugins that you'd like Oh My Zsh to load in initialization.
+Once you spot a plugin (or several) that you'd like to use 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.
-For example, this line might begin to look like...
+For example, this line might begin to look like this:
```shell
plugins=(git bundler osx rake ruby)
@@ -61,7 +67,7 @@ We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme
#### Selecting a Theme
-_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just right (for him)._
+_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right one (for him)._
Once you find a theme that you want to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
@@ -73,9 +79,11 @@ 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)
+# you might need to install a special Powerline font on your console's host for this to work
+# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster
```
-Open up a new terminal window and your prompt should look something like...
+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)
@@ -112,7 +120,7 @@ The default location is `~/.oh-my-zsh` (hidden in your home directory)
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
-export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
+export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```
#### Manual Installation
@@ -131,7 +139,7 @@ cp ~/.zshrc ~/.zshrc.orig
##### 3. Create a new zsh configuration file
-You can create a new zsh config file by copying the template that we included for you.
+You can create a new zsh config file by copying the template that we have included for you.
```shell
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
@@ -210,7 +218,10 @@ Thank you so much!
## Follow Us
-We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it.
+We're on the 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.
## Merchandise
@@ -218,4 +229,10 @@ We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-
## License
-Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt).
+Oh My Zsh is released under the [MIT license](LICENSE.txt).
+
+## About Planet Argon
+
+![Planet Argon](http://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg)
+
+Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github).
diff --git a/cache/.easter-egg b/cache/.easter-egg
deleted file mode 100644
index 4b6164edb..000000000
--- a/cache/.easter-egg
+++ /dev/null
@@ -1,4 +0,0 @@
-This file is only here so that Git will keep a cache directory as .gitignore is ignoring all the files within it.
-
-Feel free to add love notes for people here.
-
diff --git a/cache/.gitkeep b/cache/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/cache/.gitkeep
diff --git a/custom/example.zsh b/custom/example.zsh
index 28ffcae25..c505a9673 100644
--- a/custom/example.zsh
+++ b/custom/example.zsh
@@ -1,5 +1,10 @@
-# Add yourself some shortcuts to projects you often work on
-# Example:
+# You can put files here to add functionality separated per file, which
+# will be ignored by git.
+# Files on the custom/ directory will be automatically loaded by the init
+# script, in alphabetical order.
+
+# For example: add yourself some shortcuts to projects you often work on.
+#
+# brainstormr=~/Projects/development/planetargon/brainstormr
+# cd $brainstormr
#
-# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr
-# \ No newline at end of file
diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
index b663800a4..2c93d1bb5 100644
--- a/lib/clipboard.zsh
+++ b/lib/clipboard.zsh
@@ -31,13 +31,13 @@ function clipcopy() {
cat $file > /dev/clipboard
fi
else
- if which xclip &>/dev/null; then
+ if (( $+commands[xclip] )); then
if [[ -z $file ]]; then
xclip -in -selection clipboard
else
xclip -in -selection clipboard $file
fi
- elif which xsel &>/dev/null; then
+ elif (( $+commands[xsel] )); then
if [[ -z $file ]]; then
xsel --clipboard --input
else
@@ -74,9 +74,9 @@ function clippaste() {
elif [[ $OSTYPE == cygwin* ]]; then
cat /dev/clipboard
else
- if which xclip &>/dev/null; then
+ if (( $+commands[xclip] )); then
xclip -out -selection clipboard
- elif which xsel &>/dev/null; then
+ elif (( $+commands[xsel] )); then
xsel --clipboard --output
else
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
diff --git a/lib/completion.zsh b/lib/completion.zsh
index f5b292471..a1e934315 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -1,37 +1,34 @@
# fixme - the load process here seems a bit bizarre
+zmodload -i zsh/complist
+
+WORDCHARS=''
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
-setopt auto_menu # show completion menu on succesive tab press
+setopt auto_menu # show completion menu on successive tab press
setopt complete_in_word
setopt always_to_end
-WORDCHARS=''
-
-zmodload -i zsh/complist
+# should this be in keybindings?
+bindkey -M menuselect '^o' accept-and-infer-next-history
+zstyle ':completion:*:*:*:*:*' menu select
-## case-insensitive (all),partial-word and then substring completion
-if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
- zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
- unset CASE_SENSITIVE
+# case insensitive (all), partial-word and substring completion
+if [[ "$CASE_SENSITIVE" = true ]]; then
+ zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
else
- if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then
- zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
- unset HYPHEN_INSENSITIVE
+ if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
+ zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
else
- zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
+ zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
fi
fi
+unset CASE_SENSITIVE HYPHEN_INSENSITIVE
zstyle ':completion:*' list-colors ''
-
-# should this be in keybindings?
-bindkey -M menuselect '^o' accept-and-infer-next-history
-
-zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
-if [ "$OSTYPE[0,7]" = "solaris" ]
-then
+
+if [[ "$OSTYPE" = solaris* ]]; then
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
else
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
diff --git a/lib/functions.zsh b/lib/functions.zsh
index f9d4a9717..f30653784 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -3,11 +3,11 @@ function zsh_stats() {
}
function uninstall_oh_my_zsh() {
- env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
+ env ZSH=$ZSH sh $ZSH/tools/uninstall.sh
}
function upgrade_oh_my_zsh() {
- env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
+ env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
}
function take() {
@@ -86,7 +86,7 @@ function default() {
}
#
-# Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined.
+# Set environment variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The env variable to set
diff --git a/lib/git.zsh b/lib/git.zsh
index de51daafa..f7eccb81d 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -37,7 +37,9 @@ function git_remote_status() {
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)
- if [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
+ if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
+ git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
+ elif [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
@@ -74,10 +76,21 @@ function git_current_branch() {
# Gets the number of commits ahead from remote
function git_commits_ahead() {
- if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
- local COMMITS
- COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
- echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
+ if command git rev-parse --git-dir &>/dev/null; then
+ local commits="$(git rev-list --count @{upstream}..HEAD)"
+ if [[ "$commits" != 0 ]]; then
+ echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
+ fi
+ fi
+}
+
+# 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})"
+ if [[ "$commits" != 0 ]]; then
+ echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
+ fi
fi
}
@@ -152,13 +165,13 @@ function git_prompt_status() {
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
fi
- if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then
+ if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
fi
- if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then
+ if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
fi
- if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then
+ if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
fi
echo $STATUS
@@ -186,6 +199,18 @@ function git_compare_version() {
echo 0
}
+# 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
+}
+
+# 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
+}
+
# 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
diff --git a/lib/misc.zsh b/lib/misc.zsh
index c81dab413..3052b7710 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -19,8 +19,8 @@ fi
setopt long_list_jobs
## pager
-export PAGER="less"
-export LESS="-R"
+env_default PAGER 'less'
+env_default LESS '-R'
## super user alias
alias _='sudo'
diff --git a/lib/nvm.zsh b/lib/nvm.zsh
index 61d997fc0..4a8b6811e 100644
--- a/lib/nvm.zsh
+++ b/lib/nvm.zsh
@@ -1,6 +1,6 @@
# get the node.js version
function nvm_prompt_info() {
- [ -f "$HOME/.nvm/nvm.sh" ] || return
+ [[ -f "$NVM_DIR/nvm.sh" ]] || return
local nvm_prompt
nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index ebb11fb31..96f34aa81 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -1,38 +1,49 @@
# ls colors
autoload -U colors && colors
-export LSCOLORS="Gxfxcxdxbxegedabagacad"
# Enable ls colors
-if [ "$DISABLE_LS_COLORS" != "true" ]
-then
- # Find the option for using colors in ls, depending on the version: Linux or BSD
- if [[ "$(uname -s)" == "NetBSD" ]]; then
+export LSCOLORS="Gxfxcxdxbxegedabagacad"
+
+# TODO organise this chaotic logic
+
+if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
+ # Find the option for using colors in ls, depending on the version
+ if [[ "$OSTYPE" == netbsd* ]]; then
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
- gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
- elif [[ "$(uname -s)" == "OpenBSD" ]]; then
- # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
- # with color and multibyte support) are available from ports. "colorls"
- # will be installed on purpose and can't be pulled in by installing
+ gls --color -d . &>/dev/null && alias ls='gls --color=tty'
+ elif [[ "$OSTYPE" == openbsd* ]]; then
+ # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
+ # with color and multibyte support) are available from ports. "colorls"
+ # will be installed on purpose and can't be pulled in by installing
# coreutils, so prefer it to "gls".
- gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
- colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G'
+ gls --color -d . &>/dev/null && alias ls='gls --color=tty'
+ colorls -G -d . &>/dev/null && alias ls='colorls -G'
+ elif [[ "$OSTYPE" == darwin* ]]; then
+ # this is a good alias, it works by default just using $LSCOLORS
+ ls -G . &>/dev/null && alias ls='ls -G'
+
+ # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file)
+ # otherwise, gls will use the default color scheme which is ugly af
+ [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty'
else
- ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
+ # For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
+ if [[ -z "$LS_COLORS" ]]; then
+ (( $+commands[dircolors] )) && eval "$(dircolors -b)"
+ fi
+
+ ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
+
+ # Take advantage of $LS_COLORS for completion as well.
+ zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
fi
fi
-#setopt no_beep
setopt auto_cd
setopt multios
-setopt cdablevars
+setopt prompt_subst
-if [[ x$WINDOW != x ]]
-then
- SCREEN_NO="%B$WINDOW%b "
-else
- SCREEN_NO=""
-fi
+[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
# Apply theming defaults
PS1="%n@%m:%~%# "
@@ -42,6 +53,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th
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
-
-# Setup the prompt with pretty colors
-setopt prompt_subst
diff --git a/log/.easter-egg b/log/.easter-egg
deleted file mode 100644
index 2533149e2..000000000
--- a/log/.easter-egg
+++ /dev/null
@@ -1,4 +0,0 @@
-This file is only here so that Git will keep a log directory as .gitignore is ignoring all the log files within it.
-
-feel free to add love notes for people here.
-
diff --git a/log/.gitkeep b/log/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/log/.gitkeep
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 4517a2ba0..7f78e4140 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -22,7 +22,7 @@ fi
# 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/"
+ ZSH_CACHE_DIR="$ZSH/cache"
fi
@@ -53,7 +53,7 @@ done
# Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then
- # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
+ # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
else
SHORT_HOST=${HOST/.*/}
diff --git a/plugins/adb/_adb b/plugins/adb/_adb
index f30f3247f..5f37bedac 100644
--- a/plugins/adb/_adb
+++ b/plugins/adb/_adb
@@ -13,9 +13,13 @@ _1st_arguments=(
'disconnect:disconnect from a TCP/IP device. Port 5555 is default.'
'emu:run emulator console command'
'forward:forward socket connections'
+'get-devpath:print the device path'
+'get-serialno:print the serial number of the device'
+'get-state:print the current state of the device: offline | bootloader | device'
'help:show the help message'
'install:push this package file to the device and install it'
'jdwp:list PIDs of processes hosting a JDWP transport'
+'keygen:generate adb public/private key'
'kill-server:kill the server if it is running'
'logcat:view device log'
'pull:copy file/dir from device'
@@ -30,6 +34,7 @@ _1st_arguments=(
'start-server:ensure that there is a server running'
'tcpip:restart host adb in tcpip mode'
'uninstall:remove this app package from the device'
+'usb:restart the adbd daemon listing on USB'
'version:show version num'
'wait-for-device:block until device is online'
)
diff --git a/plugins/arcanist/README.md b/plugins/arcanist/README.md
new file mode 100644
index 000000000..4bb8c8090
--- /dev/null
+++ b/plugins/arcanist/README.md
@@ -0,0 +1,5 @@
+## arcanist
+
+**Maintainer:** [@emzar](https://github.com/emzar)
+
+This plugin adds many useful aliases.
diff --git a/plugins/arcanist/arcanist.plugin.zsh b/plugins/arcanist/arcanist.plugin.zsh
new file mode 100644
index 000000000..3f4eb07f4
--- /dev/null
+++ b/plugins/arcanist/arcanist.plugin.zsh
@@ -0,0 +1,21 @@
+#
+# Aliases
+# (sorted alphabetically)
+#
+
+alias ara='arc amend'
+alias arb='arc branch'
+alias arco='arc cover'
+alias arci='arc commit'
+
+alias ard='arc diff'
+alias ardnu='arc diff --nounit'
+alias ardnupc='arc diff --nounit --plan-changes'
+alias ardpc='arc diff --plan-changes'
+
+alias are='arc export'
+alias arh='arc help'
+alias arl='arc land'
+alias arli='arc lint'
+alias arls='arc list'
+alias arpa='arc patch'
diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md
index ad42d4cd2..e408db13d 100644
--- a/plugins/archlinux/README.md
+++ b/plugins/archlinux/README.md
@@ -1,64 +1,97 @@
-## ARCHLINUX PLUGIN
+# Archlinux plugin
+## Features
----
+#### YAOURT
-### FEATURES
+| 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 |
-| Alias | Function | Description |
-|:------------:|-----------------------------------------|:--------------------------------------------------------------------------------------------------------------------|
-| pacin | sudo pacman -S | Install specific package(s) from the repositories |
-| pacins | sudo pacman -U | Install specific package not from the repositories but from a file |
-| pacinsd | sudo pacman -S --asdeps | Install given package(s) as dependencies of another package |
-| pacloc | pacman -Qi | Display information about a given package in the local database |
-| paclocs | pacman -Qs | Search for package(s) in the local database |
-| paclsorphans | sudo pacman -Qdt' | List all orphaned packages |
-| pacmir | sudo pacman -Syy | Force refresh of all package lists after updating /etc/pacman.d/mirrorlist |
-| pacre | sudo pacman -R | Remove the specified package(s), retaining its configuration(s) and required dependencies |
-| pacrem | sudo pacman -Rns | Remove the specified package(s), its configuration(s) and unneeded dependencies |
-| pacrep | pacman -Si | Display information about a given package in the repositories |
-| pacreps | pacman -Ss | Search for package(s) 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 against repositories |
-| pacupd | sudo pacman -Sy && sudo abs | Update and refresh the local package and ABS databases against repositories |
-| pacupd | sudo pacman -Sy && sudo aur | Update and refresh the local package and AUR databases against repositories |
-| pacupd | sudo pacman -Sy | Update and refresh the local package database against repositories |
-| pacupg | sudo pacman -Syu | Synchronize with repositories before upgrading packages that are out of date on the local system. |
-| yaconf | yaourt -C | Fix all configuration files with vimdiff |
-| yain | yaourt -S | Install specific package(s) from the repositories |
-| yains | yaourt -U | Install specific package not from the repositories but from a file |
-| yainsd | yaourt -S --asdeps | Install given package(s) as dependencies of another package |
-| yaloc | yaourt -Qi | Display information about a given package in the local database |
-| yalocs | yaourt -Qs | Search for package(s) in the local database |
-| yalst | yaourt -Qe | List installed packages, even those installed from AUR (they're tagged as "local") |
-| yamir | yaourt -Syy | Force refresh of all package lists after updating /etc/pacman.d/mirrorlist |
-| yaorph | yaourt -Qtd | Remove orphans using yaourt |
-| yare | yaourt -R | Remove the specified package(s), retaining its configuration(s) and required dependencies |
-| yarem | yaourt -Rns | Remove the specified package(s), its configuration(s) and unneeded dependencies |
-| yarep | yaourt -Si | Display information about a given package in the repositories |
-| yareps | yaourt -Ss | Search for package(s) in the repositories |
-| yasu | yaourt --sucre | Same as yaupg, but without confirmation |
-| yaupd | yaourt -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases against repositories |
-| yaupd | yaourt -Sy && sudo abs | Update and refresh the local package and ABS databases against repositories |
-| yaupd | yaourt -Sy && sudo aur | Update and refresh the local package and AUR databases against repositories |
-| yaupd | yaourt -Sy | Update and refresh the local package database against repositories |
-| yaupg | yaourt -Syua | Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system |
+### PACAUR
-| Function | Description |
-|----------------|:------------------------------------------------------------------------------------------------------------------|
-| pacdisowned | List all disowned files in your system |
-| paclist | List all installed packages with a short description - [Source](https://bbs.archlinux.org/viewtopic.php?id=93683) |
-| pacmanallkeys | Get all keys for developers and trusted users |
-| pacmansignkeys | |
+| 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. |
-### CONTRIBUTORS
- - Benjamin Boudreau - dreurmail@gmail.com
- - Celso Miranda - contacto@celsomiranda.net
- - KhasMek - Boushh@gmail.com
- - Martin Putniorz - mputniorz@gmail.com
- - MatthR3D - matthr3d@gmail.com
- - ornicar - thibault.duplessis@gmail.com
+| 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 |
---
+
+## Contributors
+
+- Benjamin Boudreau - dreurmail@gmail.com
+- Celso Miranda - contacto@celsomiranda.net
+- KhasMek - Boushh@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
diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh
index 99de5b936..105bd2d5f 100644
--- a/plugins/archlinux/archlinux.plugin.zsh
+++ b/plugins/archlinux/archlinux.plugin.zsh
@@ -1,75 +1,110 @@
-# Archlinux zsh aliases and functions
-# Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
-
-# Look for yaourt, and add some useful functions if we have it.
if (( $+commands[yaourt] )); then
- upgrade () {
- yaourt -Syu
- }
- alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
- # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
- alias yaupg='yaourt -Syua' # Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system.
- alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation
- alias yain='yaourt -S' # Install specific package(s) from the repositories
- alias yains='yaourt -U' # Install specific package not from the repositories but from a file
- alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
- alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
- alias yarep='yaourt -Si' # Display information about a given package in the repositories
- alias yareps='yaourt -Ss' # Search for package(s) in the repositories
- alias yaloc='yaourt -Qi' # Display information about a given package in the local database
- alias yalocs='yaourt -Qs' # Search for package(s) in the local database
- alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
- alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
- # Additional yaourt alias examples
+ 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[pacaur] )); then
+ alias paupg='pacaur -Syua'
+ alias pasu='pacaur -Syua --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 yaupd='yaourt -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
+ alias paupd='pacaur -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
- alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
+ alias paupd='pacaur -Sy && sudo abs'
elif (( $+commands[aur] )); then
- alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
+ alias paupd='pacaur -Sy && sudo aur'
else
- alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories
+ alias paupd='pacaur -Sy'
fi
- alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package
- alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
+fi
+
+if (( $+commands[pacaur] )); then
+ upgrade() {
+ pacaur -Syu
+ }
+elif (( $+commands[yaourt] )); then
+ upgrade() {
+ yaourt -Syu
+ }
else
- upgrade() {
- sudo pacman -Syu
- }
+ upgrade() {
+ sudo pacman -Syu
+ }
fi
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
-alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
-alias pacin='sudo pacman -S' # Install specific package(s) from the repositories
-alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file
-alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
-alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
-alias pacrep='pacman -Si' # Display information about a given package in the repositories
-alias pacreps='pacman -Ss' # Search for package(s) in the repositories
-alias pacloc='pacman -Qi' # Display information about a given package in the local database
-alias paclocs='pacman -Qs' # Search for package(s) in the local database
-# Additional pacman alias examples
+alias pacupg='sudo pacman -Syu'
+alias pacin='sudo pacman -S'
+alias pacins='sudo pacman -U'
+alias pacre='sudo pacman -R'
+alias pacrem='sudo pacman -Rns'
+alias pacrep='pacman -Si'
+alias pacreps='pacman -Ss'
+alias pacloc='pacman -Qi'
+alias paclocs='pacman -Qs'
+alias pacinsd='sudo pacman -S --asdeps'
+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 tFs'
+
+
if (( $+commands[abs] && $+commands[aur] )); then
- alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
+ alias pacupd='sudo pacman -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
- alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
+ alias pacupd='sudo pacman -Sy && sudo abs'
elif (( $+commands[aur] )); then
- alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
+ alias pacupd='sudo pacman -Sy && sudo aur'
else
- alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories
+ alias pacupd='sudo pacman -Sy'
fi
-alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package
-alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
-# https://bbs.archlinux.org/viewtopic.php?id=93683
paclist() {
- 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}'
+ # 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}'
}
-alias paclsorphans='sudo pacman -Qdt'
-alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
-
pacdisowned() {
+ emulate -L zsh
+
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
@@ -79,21 +114,21 @@ pacdisowned() {
pacman -Qlq | sort -u > "$db"
- find /bin /etc /lib /sbin /usr \
- ! -name lost+found \
- \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
+ find /bin /etc /lib /sbin /usr ! -name lost+found \
+ \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
}
pacmanallkeys() {
- # Get all keys for developers and trusted users
- curl https://www.archlinux.org/{developers,trustedusers}/ |
- awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' |
- xargs sudo pacman-key --recv-keys
+ 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
}
pacmansignkeys() {
+ emulate -L zsh
for key in $*; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
diff --git a/plugins/asdf/README.md b/plugins/asdf/README.md
new file mode 100644
index 000000000..e8aa976bc
--- /dev/null
+++ b/plugins/asdf/README.md
@@ -0,0 +1,27 @@
+## asdf
+
+**Maintainer:** [@RobLoach](https://github.com/RobLoach)
+
+Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more.
+
+### Installation
+
+1. Enable the plugin by adding it to your `plugins` definition in `~/.zshrc`.
+
+ ```
+ plugins=(asdf)
+ ```
+
+2. [Install asdf](https://github.com/asdf-vm/asdf#setup) by running the following:
+ ```
+ git clone https://github.com/asdf-vm/asdf.git ~/.asdf
+ ```
+
+### Usage
+
+See the [asdf usage documentation](https://github.com/asdf-vm/asdf#usage) for information on how to use asdf:
+
+```
+asdf plugin-add nodejs git@github.com:asdf-vm/asdf-nodejs.git
+asdf install nodejs 5.9.1
+```
diff --git a/plugins/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh
new file mode 100644
index 000000000..8736d2ff8
--- /dev/null
+++ b/plugins/asdf/asdf.plugin.zsh
@@ -0,0 +1,7 @@
+# Find where asdf should be installed.
+ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
+
+# Load asdf, if found.
+if [ -f $ASDF_DIR/asdf.sh ]; then
+ . $ASDF_DIR/asdf.sh
+fi
diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
index ea2e56dd6..3c1b0fafc 100644
--- a/plugins/autoenv/autoenv.plugin.zsh
+++ b/plugins/autoenv/autoenv.plugin.zsh
@@ -1,7 +1,7 @@
# Activates autoenv or reports its failure
() {
if ! type autoenv_init >/dev/null; then
- for d (~/.autoenv /usr/local/opt/autoenv); do
+ for d (~/.autoenv ~/.local/bin /usr/local/opt/autoenv /usr/local/bin); do
if [[ -e $d/activate.sh ]]; then
autoenv_dir=$d
break
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index 014bb15dd..8f398cfb3 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -64,15 +64,15 @@ if [[ "$OSTYPE" = darwin* ]] ; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
}
-elif [[ $(uname) == "Linux" ]] ; then
+elif [[ "$OSTYPE" = linux* ]] ; then
function battery_is_charging() {
- ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
+ ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
}
function battery_pct() {
if (( $+commands[acpi] )) ; then
- echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
+ echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
fi
}
@@ -85,14 +85,14 @@ elif [[ $(uname) == "Linux" ]] ; then
}
function battery_time_remaining() {
- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
- echo $(acpi | cut -f3 -d ',')
+ if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
+ echo $(acpi 2>/dev/null | cut -f3 -d ',')
fi
}
function battery_pct_prompt() {
b=$(battery_pct_remaining)
- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
+ if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
if [ $b -gt 50 ] ; then
color='green'
elif [ $b -gt 20 ] ; then
@@ -100,7 +100,7 @@ elif [[ $(uname) == "Linux" ]] ; then
else
color='red'
fi
- echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
+ echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
else
echo "∞"
fi
diff --git a/plugins/bower/bower.plugin.zsh b/plugins/bower/bower.plugin.zsh
index 68a67a3cc..6019b9d37 100644
--- a/plugins/bower/bower.plugin.zsh
+++ b/plugins/bower/bower.plugin.zsh
@@ -72,6 +72,7 @@ _bower ()
compadd "$@" $(echo $bower_package_list)
;;
*)
+ _arguments \
$_no_color \
;;
esac
diff --git a/plugins/branch/branch.plugin.zsh b/plugins/branch/branch.plugin.zsh
index a1e9ca31b..2e5659bdf 100644
--- a/plugins/branch/branch.plugin.zsh
+++ b/plugins/branch/branch.plugin.zsh
@@ -17,7 +17,12 @@ function branch_prompt_info() {
# Mercurial repository
if [[ -d "${current_dir}/.hg" ]]
then
- echo '☿' $(<"$current_dir/.hg/branch")
+ if [[ -f "$current_dir/.hg/branch" ]]
+ then
+ echo '☿' $(<"$current_dir/.hg/branch")
+ else
+ echo '☿ default'
+ fi
return;
fi
# Defines path as parent directory and keeps looking for :)
diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh
deleted file mode 100644
index 91ce0f498..000000000
--- a/plugins/brew-cask/brew-cask.plugin.zsh
+++ /dev/null
@@ -1,84 +0,0 @@
-# Autocompletion for homebrew-cask.
-#
-# This script intercepts calls to the brew plugin and adds autocompletion
-# for the cask subcommand.
-#
-# Author: https://github.com/pstadler
-
-compdef _brew-cask brew
-
-_brew-cask()
-{
- local curcontext="$curcontext" state line
- typeset -A opt_args
-
- _arguments -C \
- ':command:->command' \
- ':subcmd:->subcmd' \
- '*::options:->options'
-
- case $state in
- (command)
- __call_original_brew
- cask_commands=(
- 'cask:manage casks'
- )
- _describe -t commands 'brew cask command' cask_commands ;;
-
- (subcmd)
- case "$line[1]" in
- cask)
- if (( CURRENT == 3 )); then
- local -a subcommands
- subcommands=(
- "alfred:used to modify Alfred's scope to include the Caskroom"
- 'audit:verifies installability of casks'
- 'checklinks:checks for bad cask links'
- 'cleanup:cleans up cached downloads'
- 'create:creates a cask of the given name and opens it in an editor'
- 'doctor:checks for configuration issues'
- 'edit:edits the cask of the given name'
- 'fetch:downloads Cask resources to local cache'
- 'home:opens the homepage of the cask of the given name'
- 'info:displays information about the cask of the given name'
- 'install:installs the cask of the given name'
- 'list:with no args, lists installed casks; given installed casks, lists installed files'
- 'search:searches all known casks'
- 'uninstall:uninstalls the cask of the given name'
- "update:a synonym for 'brew update'"
- )
- _describe -t commands "brew cask subcommand" subcommands
- fi ;;
-
- *)
- __call_original_brew ;;
- esac ;;
-
- (options)
- local -a casks installed_casks
- local expl
- case "$line[2]" in
- list|uninstall)
- __brew_installed_casks
- _wanted installed_casks expl 'installed casks' compadd -a installed_casks ;;
- audit|edit|home|info|install)
- __brew_all_casks
- _wanted casks expl 'all casks' compadd -a casks ;;
- esac ;;
- esac
-}
-
-__brew_all_casks() {
- casks=(`brew cask search`)
-}
-
-__brew_installed_casks() {
- installed_casks=(`brew cask list`)
-}
-
-__call_original_brew()
-{
- local ret=1
- _call_function ret _brew
- compdef _brew-cask brew
-}
diff --git a/plugins/brew/_brew b/plugins/brew/_brew
deleted file mode 100644
index 4c99a383a..000000000
--- a/plugins/brew/_brew
+++ /dev/null
@@ -1,109 +0,0 @@
-#compdef brew
-#autoload
-
-# imported from the latest homebrew contributions
-
-_brew_all_formulae() {
- formulae=(`brew search`)
-}
-
-_brew_installed_formulae() {
- installed_formulae=(`brew list`)
-}
-
-_brew_installed_taps() {
- installed_taps=(`brew tap`)
-}
-
-_brew_outdated_formulae() {
- outdated_formulae=(`brew outdated`)
-}
-
-local -a _1st_arguments
-_1st_arguments=(
- 'audit:check formulae for Homebrew coding style'
- 'cat:display formula file for a formula'
- 'cleanup:uninstall unused and old versions of packages'
- 'commands:show a list of commands'
- 'create:create a new formula'
- 'deps:list dependencies of a formula'
- 'doctor:audits your installation for common issues'
- 'edit:edit a formula'
- 'fetch:download formula resources to the cache'
- 'gist-logs:generate a gist of the full build logs'
- 'home:visit the homepage of a formula or the brew project'
- 'info:information about a formula'
- 'install:install a formula'
- 'reinstall:install a formula anew; re-using its current options'
- 'leaves:show installed formulae that are not dependencies of another installed formula'
- 'link:link a formula'
- 'list:list files in a formula or not-installed formulae'
- 'log:git commit log for a formula'
- 'missing:check all installed formuale for missing dependencies.'
- 'outdated:list formulae for which a newer version is available'
- 'pin:pin specified formulae'
- 'postinstall:perform post_install for a given formula'
- 'prune:remove dead links'
- 'remove:remove a formula'
- 'search:search for a formula (/regex/ or string)'
- 'switch:switch linkage between installed versions of a formula'
- 'tap:tap a new formula repository from GitHub, or list existing taps'
- 'test-bot:test a formula and build a bottle'
- 'uninstall:uninstall a formula'
- 'unlink:unlink a formula'
- 'unpin:unpin specified formulae'
- 'untap:remove a tapped repository'
- 'update:pull latest repository'
- 'upgrade:upgrade outdated formulae'
- 'uses:show formulae which depend on a formula'
-)
-
-local expl
-local -a formulae installed_formulae installed_taps outdated_formulae
-
-_arguments \
- '(-v)-v[verbose]' \
- '(--cellar)--cellar[brew cellar]' \
- '(--config)--config[brew configuration]' \
- '(--env)--env[brew environment]' \
- '(--repository)--repository[brew repository]' \
- '(--version)--version[version information]' \
- '(--prefix)--prefix[where brew lives on this system]' \
- '(--cache)--cache[brew cache]' \
- '(--force)--force[brew force]' \
- '*:: :->subcmds' && return 0
-
-if (( CURRENT == 1 )); then
- _describe -t commands "brew subcommand" _1st_arguments
- return
-fi
-
-case "$words[1]" in
- install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options)
- _brew_all_formulae
- _wanted formulae expl 'all formulae' compadd -a formulae ;;
- list|ls)
- _arguments \
- '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
- '(--pinned)--pinned[list all versions of pinned formulae]' \
- '(--versions)--versions[list all installed versions of a formula]' \
- '1: :->forms' && return 0
-
- if [[ "$state" == forms ]]; then
- _brew_installed_formulae
- _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
- fi ;;
- remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
- _brew_installed_formulae
- _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
- search|-S)
- _arguments \
- '(--macports)--macports[search the macports repository]' \
- '(--fink)--fink[search the fink repository]' ;;
- untap)
- _brew_installed_taps
- _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
- upgrade)
- _brew_outdated_formulae
- _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
-esac
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index 5b5847328..6fb7f3453 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -2,3 +2,19 @@ alias brews='brew list -1'
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
diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md
index edd95ccc2..04d551447 100644
--- a/plugins/bundler/README.md
+++ b/plugins/bundler/README.md
@@ -6,6 +6,7 @@
- `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:
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index 382a1a471..c5284dbb1 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -58,7 +58,7 @@ bundle_install() {
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
if [[ "$OSTYPE" = darwin* ]]
then
- local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
+ local cores_num="$(sysctl -n hw.ncpu)"
else
local cores_num="$(nproc)"
fi
diff --git a/plugins/cakephp3/cakephp3.plugin.zsh b/plugins/cakephp3/cakephp3.plugin.zsh
index 28d5af2ea..dbfbeba3b 100644
--- a/plugins/cakephp3/cakephp3.plugin.zsh
+++ b/plugins/cakephp3/cakephp3.plugin.zsh
@@ -1,11 +1,31 @@
# CakePHP 3 basic command completion
_cakephp3_get_command_list () {
- cakephp3commands=($(bin/cake completion commands));printf "%s\n" "${cakephp3commands[@]}"
+ bin/cake Completion commands
+}
+
+_cakephp3_get_sub_command_list () {
+ bin/cake Completion subcommands ${words[2]}
+}
+
+_cakephp3_get_3rd_argument () {
+ bin/cake ${words[2]} ${words[3]} | \grep '\-\ '| \awk '{print $2}'
}
_cakephp3 () {
- if [ -f bin/cake ]; then
- compadd `_cakephp3_get_command_list`
+ local -a has3rdargument
+ has3rdargument=("all" "controller" "fixture" "model" "template")
+ if [ -f bin/cake ]; then
+ if (( CURRENT == 2 )); then
+ compadd $(_cakephp3_get_command_list)
+ fi
+ if (( CURRENT == 3 )); then
+ compadd $(_cakephp3_get_sub_command_list)
+ fi
+ if (( CURRENT == 4 )); then
+ if [[ ${has3rdargument[(i)${words[3]}]} -le ${#has3rdargument} ]]; then
+ compadd $(_cakephp3_get_3rd_argument)
+ fi
+ fi
fi
}
@@ -14,6 +34,5 @@ compdef _cakephp3 cake
#Alias
alias c3='bin/cake'
-
alias c3cache='bin/cake orm_cache clear'
alias c3migrate='bin/cake migrations migrate'
diff --git a/plugins/cargo/README.md b/plugins/cargo/README.md
new file mode 100644
index 000000000..5fa688d21
--- /dev/null
+++ b/plugins/cargo/README.md
@@ -0,0 +1,11 @@
+# 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:
+
+```zsh
+plugins=(... cargo)
+```
+
+Updated on October 4th, 2016.
diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo
new file mode 100644
index 000000000..175859202
--- /dev/null
+++ b/plugins/cargo/_cargo
@@ -0,0 +1,497 @@
+#compdef cargo
+
+typeset -A opt_args
+autoload -U regexp-replace
+
+_cargo() {
+
+_arguments \
+ '(- 1 *)'{-h,--help}'[show help message]' \
+ '(- 1 *)'--list'[list installed commands]' \
+ '(- 1 *)'{-v,--verbose}'[use verbose output]' \
+ '(- 1 *)'--color'[colorization option]' \
+ '(- 1 *)'{-V,--version}'[show version information]' \
+ '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_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
+
+}
+
+
+#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
+}
+
+# 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)
+ if [[ -z $manifest ]]; then
+ return 0
+ fi
+
+ local last_line
+ local -a names;
+ local in_block=false
+ local block_name=$1
+ names=()
+ while read line
+ do
+ if [[ $last_line == "[[$block_name]]" ]]; then
+ in_block=true
+ else
+ if [[ $last_line =~ '.*\[\[.*' ]]; then
+ in_block=false
+ fi
+ fi
+
+ if [[ $in_block == true ]]; then
+ if [[ $line =~ '.*name.*=' ]]; then
+ regexp-replace line '^.*name *= *|"' ""
+ names+=$line
+ fi
+ fi
+
+ last_line=$line
+ done < $manifest
+ _describe $block_name names
+
+}
+
+#Gets the test names from the manifest file
+_test_names()
+{
+ _get_names_from_array "test"
+}
+
+#Gets the bench names from the manifest file
+_benchmark_names()
+{
+ _get_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/cask/README.md b/plugins/cask/README.md
new file mode 100644
index 000000000..e1335c1b8
--- /dev/null
+++ b/plugins/cask/README.md
@@ -0,0 +1,15 @@
+# Cask plugin
+
+[Cask](https://github.com/cask/cask) is a project management tool for Emacs that helps
+automate the package development cycle; development, dependencies, testing, building,
+packaging and more.
+
+This plugin loads `cask` completion from non-standard locations, such as if installed
+via Homebrew or others. To enable it, add `cask` to your plugins array:
+
+```zsh
+plugins=(... cask)
+```
+
+Make sure you have the `cask` directory in your `$PATH` before loading Oh My Zsh,
+otherwise you'll get a "command not found" error.
diff --git a/plugins/cask/cask.plugin.zsh b/plugins/cask/cask.plugin.zsh
index c55862924..29120b306 100644
--- a/plugins/cask/cask.plugin.zsh
+++ b/plugins/cask/cask.plugin.zsh
@@ -1,5 +1,26 @@
-if which cask &> /dev/null; then
- source $(dirname $(which cask))/../etc/cask_completion.zsh
-else
- print "zsh cask plugin: cask not found"
-fi
+() {
+ emulate -L zsh
+
+ if ! (( $+commands[cask] )); then
+ print "zsh cask plugin: cask command not found" >&2
+ return
+ fi
+
+ cask_base=${commands[cask]:h:h}
+
+ # Plain cask installation location (for Cask 0.7.2 and earlier)
+ comp_files=($cask_base/etc/cask_completion.zsh)
+
+ # Mac Homebrew installs the completion in a different location
+ if (( $+commands[brew] )); then
+ comp_files+=($(brew --prefix)/share/zsh/site-functions/cask_completion.zsh)
+ fi
+
+ # Load first found file
+ for f in $comp_files; do
+ if [[ -f "$f" ]]; then
+ source "$f"
+ break
+ fi
+ done
+}
diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh
index 164b4319f..758b4a56c 100644
--- a/plugins/chruby/chruby.plugin.zsh
+++ b/plugins/chruby/chruby.plugin.zsh
@@ -16,9 +16,6 @@
# rvm and rbenv plugins also provide this alias
alias rubies='chruby'
-local _chruby_path
-local _chruby_auto
-
_homebrew-installed() {
whence brew &> /dev/null
}
@@ -42,6 +39,9 @@ if _ruby-build_installed; then
fi
_source_from_omz_settings() {
+ local _chruby_path
+ local _chruby_auto
+
zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto
diff --git a/plugins/coffee/README.md b/plugins/coffee/README.md
index 432ce3414..d6cd074d3 100644
--- a/plugins/coffee/README.md
+++ b/plugins/coffee/README.md
@@ -1,7 +1,7 @@
## Coffeescript Plugin
This plugin provides aliases for quickly compiling and previewing your
-cofeescript code.
+coffeescript code.
When writing Coffeescript it's very common to want to preview the output of a
certain snippet of code, either because you want to test the output or because
diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
index 797554a13..0e2f2133f 100644
--- a/plugins/command-not-found/command-not-found.plugin.zsh
+++ b/plugins/command-not-found/command-not-found.plugin.zsh
@@ -23,3 +23,11 @@ if [ -f /usr/libexec/pk-command-not-found ]; then
return $retval
}
fi
+
+# 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)";
+ fi
+fi
diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
index c7aafd8b8..742798f27 100644
--- a/plugins/common-aliases/common-aliases.plugin.zsh
+++ b/plugins/common-aliases/common-aliases.plugin.zsh
@@ -54,17 +54,21 @@ alias mv='mv -i'
# depends on the SUFFIX :)
if is-at-least 4.2.0; then
# open browser on urls
- _browser_fts=(htm html de org net com at cx nl se dk dk php)
- for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done
+ 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
+ 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
- _image_fts=(jpg jpeg png gif mng tiff tif xpm)
- for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; 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
+ fi
- _media_fts=(ape avi flv mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
- for ft in $_media_fts ; do alias -s $ft=mplayer ; done
+ _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
+ for ft in $_media_fts; do alias -s $ft=mplayer; done
#read documents
alias -s pdf=acroread
@@ -83,4 +87,3 @@ fi
# Make zsh know about hosts already accessed by SSH
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
-
diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
index 07eb1de88..8cf50d502 100644
--- a/plugins/composer/composer.plugin.zsh
+++ b/plugins/composer/composer.plugin.zsh
@@ -39,14 +39,17 @@ alias c='composer'
alias csu='composer self-update'
alias cu='composer update'
alias cr='composer require'
+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 cgu='composer global update'
alias cgr='composer global require'
+alias cgrm='composer global remove'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH
-export PATH=$PATH:~/.composer/vendor/bin
+export PATH=$PATH:$(composer global config bin-dir --absolute) 2>/dev/null
diff --git a/plugins/copybuffer/README.md b/plugins/copybuffer/README.md
new file mode 100644
index 000000000..da138bdbd
--- /dev/null
+++ b/plugins/copybuffer/README.md
@@ -0,0 +1,11 @@
+# `copybuffer` plugin
+
+This plugin binds the ctrl-o keyboard shortcut to a command that copies the text
+that is currently typed in the command line ($BUFFER) to the system clipboard.
+
+This is useful if you type a command - and before you hit enter to execute it - want
+to copy it maybe so you can paste it into a script, gist or whatnot.
+
+```zsh
+plugins=(... copybuffer)
+```
diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh
new file mode 100644
index 000000000..cc205d40f
--- /dev/null
+++ b/plugins/copybuffer/copybuffer.plugin.zsh
@@ -0,0 +1,14 @@
+# copy the active line from the command line buffer
+# onto the system clipboard (requires clipcopy plugin)
+
+copybuffer () {
+ if which clipcopy &>/dev/null; then
+ echo $BUFFER | clipcopy
+ else
+ echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
+ fi
+}
+
+zle -N copybuffer
+
+bindkey "^O" copybuffer
diff --git a/plugins/cp/README.md b/plugins/cp/README.md
new file mode 100644
index 000000000..e8a9b6ccc
--- /dev/null
+++ b/plugins/cp/README.md
@@ -0,0 +1,32 @@
+# cp plugin
+
+This plugin defines a `cpv` function that uses `rsync` so that you
+get the features and security of this command.
+
+To enable, add `cp` to your `plugins` array in your zshrc file:
+
+```zsh
+plugins=(... cp)
+```
+
+## Description
+
+The enabled options for rsync are:
+
+- `-p`: preserves permissions.
+
+- `-o`: preserves owner.
+
+* `-g`: preserves group.
+
+* `-b`: make a backup of the original file instead of overwriting it, if it exists.
+
+* `-r`: recurse directories.
+
+* `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T).
+
+* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync".
+
+* `-e /dev/null`: only work on local files (disable remote shells).
+
+* `--progress`: display progress.
diff --git a/plugins/cp/cp.plugin.zsh b/plugins/cp/cp.plugin.zsh
index 7355a9990..fe6ea87a8 100644
--- a/plugins/cp/cp.plugin.zsh
+++ b/plugins/cp/cp.plugin.zsh
@@ -1,14 +1,4 @@
-#Show progress while file is copying
-
-# Rsync options are:
-# -p - preserve permissions
-# -o - preserve owner
-# -g - preserve group
-# -h - output in human-readable format
-# --progress - display progress
-# -b - instead of just overwriting an existing file, save the original
-# --backup-dir=/tmp/rsync - move backup copies to "/tmp/rsync"
-# -e /dev/null - only work on local files
-# -- - everything after this is an argument, even if it looks like an option
-
-alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"
+cpv() {
+ rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
+}
+compdef _files cpv
diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
index 31a772d60..28131ff80 100644
--- a/plugins/debian/debian.plugin.zsh
+++ b/plugins/debian/debian.plugin.zsh
@@ -192,7 +192,7 @@ apt-history () {
awk '{print $4"="$5}'
;;
list)
- zcat $(ls -rt /var/log/dpkg*)
+ zgrep --no-filename '' $(ls -rt /var/log/dpkg*)
;;
*)
echo "Parameters:"
diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh
index 8a406b54d..8c58cab4c 100644
--- a/plugins/dircycle/dircycle.plugin.zsh
+++ b/plugins/dircycle/dircycle.plugin.zsh
@@ -8,11 +8,23 @@
# pushd +N: start counting from left of `dirs' output
# pushd -N: start counting from right of `dirs' output
+switch-to-dir () {
+ [[ ${#dirstack} -eq 0 ]] && return
+
+ while ! builtin pushd -q $1 &>/dev/null; do
+ # We found a missing directory: pop it out of the dir stack
+ builtin popd -q $1
+
+ # Stop trying if there are no more directories in the dir stack
+ [[ ${#dirstack} -eq 0 ]] && break
+ done
+}
+
insert-cycledleft () {
emulate -L zsh
setopt nopushdminus
- builtin pushd -q +1 &>/dev/null || true
+ switch-to-dir +1
zle reset-prompt
}
zle -N insert-cycledleft
@@ -21,7 +33,7 @@ insert-cycledright () {
emulate -L zsh
setopt nopushdminus
- builtin pushd -q -0 &>/dev/null || true
+ switch-to-dir -0
zle reset-prompt
}
zle -N insert-cycledright
diff --git a/plugins/dnf/README.md b/plugins/dnf/README.md
new file mode 100755
index 000000000..f9ef496fa
--- /dev/null
+++ b/plugins/dnf/README.md
@@ -0,0 +1,25 @@
+## Description
+
+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`.
+
+## Aliases
+
+| Alias | Command | Description |
+|-------|-------------------------|--------------------------|
+| dnfl | `dnf list` | List packages |
+| dnfli | `dnf list installed` | List installed packages |
+| dnfgl | `dnf grouplist` | List package groups |
+| dnfmc | `dnf makecache` | Generate metadata cache |
+| dnfp | `dnf info` | Show package information |
+| dnfs | `dnf search` | Search package |
+| **Use `sudo`** |
+| dnfu | `sudo dnf upgrade` | Upgrade package |
+| dnfi | `sudo dnf install` | Install package |
+| dnfgi | `sudo dnf groupinstall` | Install package group |
+| dnfr | `sudo dnf remove` | Remove package |
+| dnfgr | `sudo dnf groupremove` | Remove package group |
+| dnfc | `sudo dnf clean all` | Clean cache |
diff --git a/plugins/dnf/dnf.plugin.zsh b/plugins/dnf/dnf.plugin.zsh
new file mode 100644
index 000000000..653ce7dda
--- /dev/null
+++ b/plugins/dnf/dnf.plugin.zsh
@@ -0,0 +1,15 @@
+## Aliases
+
+alias dnfl="dnf list" # List packages
+alias dnfli="dnf list installed" # List installed packages
+alias dnfgl="dnf grouplist" # List package groups
+alias dnfmc="dnf makecache" # Generate metadata cache
+alias dnfp="dnf info" # Show package information
+alias dnfs="dnf search" # Search package
+
+alias dnfu="sudo dnf upgrade" # Upgrade package
+alias dnfi="sudo dnf install" # Install package
+alias dnfgi="sudo dnf groupinstall" # Install package group
+alias dnfr="sudo dnf remove" # Remove package
+alias dnfgr="sudo dnf groupremove" # Remove package group
+alias dnfc="sudo dnf clean all" # Clean cache
diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md
index 567b82148..d3fcb29fe 100644
--- a/plugins/docker-compose/README.md
+++ b/plugins/docker-compose/README.md
@@ -1,5 +1,4 @@
# Docker-compose plugin for oh my zsh
-A copy of the completion script from the [docker-compose](1) git repo.
+A copy of the completion script from the [docker-compose](https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose) git repo.
-[1]:[https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose]
diff --git a/plugins/docker-compose/_docker-compose b/plugins/docker-compose/_docker-compose
index 19c06675a..2947cef38 100644
--- a/plugins/docker-compose/_docker-compose
+++ b/plugins/docker-compose/_docker-compose
@@ -7,7 +7,7 @@
# -------------------------------------------------------------------------
# Version
# -------
-# 0.1.0
+# 1.5.0
# -------------------------------------------------------------------------
# Authors
# -------
@@ -19,58 +19,69 @@
# * @felixr docker zsh completion script : https://github.com/felixr/docker-zsh-completion
# -------------------------------------------------------------------------
-# For compatibility reasons, Compose and therefore its completion supports several
-# stack compositon files as listed here, in descending priority.
-# Support for these filenames might be dropped in some future version.
-__docker-compose_compose_file() {
- local file
- for file in docker-compose.y{,a}ml fig.y{,a}ml ; do
- [ -e $file ] && {
- echo $file
- return
- }
- done
- echo docker-compose.yml
+__docker-compose_q() {
+ docker-compose 2>/dev/null $compose_options "$@"
}
-# Extracts all service names from docker-compose.yml.
-___docker-compose_all_services_in_compose_file() {
+# All services defined in docker-compose.yml
+__docker-compose_all_services_in_compose_file() {
local already_selected
local -a services
- already_selected=$(echo ${words[@]} | tr " " "|")
- awk -F: '/^[a-zA-Z0-9]/{print $1}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | grep -Ev "$already_selected"
+ already_selected=$(echo $words | tr " " "|")
+ __docker-compose_q config --services \
+ | grep -Ev "^(${already_selected})$"
}
# All services, even those without an existing container
__docker-compose_services_all() {
- services=$(___docker-compose_all_services_in_compose_file)
- _alternative "args:services:($services)"
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ 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() {
+__docker-compose_services_with_key() {
local already_selected
local -a buildable
- already_selected=$(echo ${words[@]} | tr " " "|")
+ already_selected=$(echo $words | tr " " "|")
# flatten sections to one line, then filter lines containing the key and return section name.
- awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | awk -F: -v key=": +$1:" '$0 ~ key {print $1}' 2>/dev/null | grep -Ev "$already_selected"
+ __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() {
- buildable=$(___docker-compose_services_with_key build)
- _alternative "args:buildable services:($buildable)"
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ buildable=$(__docker-compose_services_with_key build)
+ _alternative "args:buildable services:($buildable)" && ret=0
+
+ return ret
}
# All services that are defined by an image
__docker-compose_services_from_image() {
- pullable=$(___docker-compose_services_with_key image)
- _alternative "args:pullable services:($pullable)"
+ [[ $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() {
- local kind expl
- declare -a running stopped lines args 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
@@ -80,64 +91,78 @@ __docker-compose_get_services() {
kind=$1
shift
- [[ $kind = (stopped|all) ]] && args=($args -a)
+ [[ $kind =~ (stopped|all) ]] && args=($args -a)
- lines=(${(f)"$(_call_program commands docker ps ${args})"})
- services=(${(f)"$(_call_program commands docker-compose 2>/dev/null ${compose_file:+-f $compose_file} ${compose_project:+-p $compose_project} ps -q)"})
+ 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 )) {
- 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
- }
+ 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
+ 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]]}/:/\\:}%% ##}"
+ 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
- [[ $kind = (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped
+ [[ $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_pausedservices() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker-compose_get_services paused "$@"
}
__docker-compose_stoppedservices() {
+ [[ $PREFIX = -* ]] && return 1
__docker-compose_get_services stopped "$@"
}
__docker-compose_runningservices() {
+ [[ $PREFIX = -* ]] && return 1
__docker-compose_get_services running "$@"
}
-__docker-compose_services () {
+__docker-compose_services() {
+ [[ $PREFIX = -* ]] && return 1
__docker-compose_get_services all "$@"
}
__docker-compose_caching_policy() {
- oldp=( "$1"(Nmh+1) ) # 1 hour
+ oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
-__docker-compose_commands () {
+__docker-compose_commands() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
@@ -151,110 +176,204 @@ __docker-compose_commands () {
local -a lines
lines=(${(f)"$(_call_program commands docker-compose 2>&1)"})
_docker_compose_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
- _store_cache docker_compose_subcommands _docker_compose_subcommands
+ (( $#_docker_compose_subcommands > 0 )) && _store_cache docker_compose_subcommands _docker_compose_subcommands
fi
_describe -t docker-compose-commands "docker-compose command" _docker_compose_subcommands
}
-__docker-compose_subcommand () {
- local -a _command_args
+__docker-compose_subcommand() {
+ local opts_help opts_force_recreate opts_no_recreate opts_no_build opts_remove_orphans opts_timeout opts_no_color opts_no_deps
+
+ opts_help='(: -)--help[Print usage]'
+ opts_force_recreate="(--no-recreate)--force-recreate[Recreate containers even if their configuration and image haven't changed. Incompatible with --no-recreate.]"
+ opts_no_recreate="(--force-recreate)--no-recreate[If containers already exist, don't recreate them. Incompatible with --force-recreate.]"
+ opts_no_build="(--build)--no-build[Don't build an image, even if it's missing.]"
+ opts_remove_orphans="--remove-orphans[Remove containers for services not defined in the Compose file]"
+ opts_timeout=('(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: ")
+ opts_no_color='--no-color[Produce monochrome output.]'
+ opts_no_deps="--no-deps[Don't start linked services.]"
+
integer ret=1
+
case "$words[1]" in
(build)
_arguments \
- '--no-cache[Do not use cache when building the image]' \
+ $opts_help \
+ '--force-rm[Always remove intermediate containers.]' \
+ '--no-cache[Do not use cache when building the image.]' \
+ '--pull[Always attempt to pull a newer version of the image.]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
+ (bundle)
+ _arguments \
+ $opts_help \
+ '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
+ ;;
+ (config)
+ _arguments \
+ $opts_help \
+ '(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \
+ '--services[Print the service names, one per line.]' && ret=0
+ ;;
+ (create)
+ _arguments \
+ $opts_help \
+ $opts_force_recreate \
+ $opts_no_recreate \
+ $opts_no_build \
+ "(--no-build)--build[Build images before creating containers.]" \
+ '*:services:__docker-compose_services_all' && ret=0
+ ;;
+ (down)
+ _arguments \
+ $opts_help \
+ "--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
+ ;;
+ (events)
+ _arguments \
+ $opts_help \
+ '--json[Output events as a stream of json objects]' \
+ '*:services:__docker-compose_services_all' && ret=0
+ ;;
+ (exec)
+ _arguments \
+ $opts_help \
+ '-d[Detached mode: Run command in the background.]' \
+ '--privileged[Give extended privileges to the process.]' \
+ '--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: ' \
+ '(-):running services:__docker-compose_runningservices' \
+ '(-):command: _command_names -e' \
+ '*::arguments: _normal' && ret=0
+ ;;
(help)
_arguments ':subcommand:__docker-compose_commands' && ret=0
;;
(kill)
_arguments \
+ $opts_help \
'-s[SIGNAL to send to the container. Default signal is SIGKILL.]:signal:_signals' \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(logs)
_arguments \
- '--no-color[Produce monochrome output.]' \
+ $opts_help \
+ '(-f --follow)'{-f,--follow}'[Follow log output]' \
+ $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
;;
- (migrate-to-labels)
+ (pause)
_arguments \
- '(-):Recreate containers to add labels' && ret=0
+ $opts_help \
+ '*:running services:__docker-compose_runningservices' && ret=0
;;
(port)
_arguments \
- '--protocol=-[tcp or udap (defaults to tcp)]:protocol:(tcp udp)' \
- '--index=-[index of the container if there are mutiple instances of a service (defaults to 1)]:index: ' \
+ $opts_help \
+ '--protocol=[tcp or udp \[default: tcp\]]:protocol:(tcp udp)' \
+ '--index=[index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \
'1:running services:__docker-compose_runningservices' \
'2:port:_ports' && ret=0
;;
(ps)
_arguments \
+ $opts_help \
'-q[Only display IDs]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(pull)
_arguments \
- '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
+ $opts_help \
+ '--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \
'*:services:__docker-compose_services_from_image' && ret=0
;;
+ (push)
+ _arguments \
+ $opts_help \
+ '--ignore-push-failures[Push what it can and ignores images with push failures.]' \
+ '*:services:__docker-compose_services' && ret=0
+ ;;
(rm)
_arguments \
+ $opts_help \
'(-f --force)'{-f,--force}"[Don't ask to confirm removal]" \
- '-v[Remove volumes associated with containers]' \
+ '-v[Remove any anonymous volumes attached to containers]' \
'*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(run)
_arguments \
- '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
+ $opts_help \
'-d[Detached mode: Run container in the background, print new container name.]' \
- '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
- '(-u --user)'{-u,--user=-}'[Run as specified username or uid]:username or uid:_users' \
- "--no-deps[Don't start linked services.]" \
+ '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
+ '--name=[Assign a name to the container]:name: ' \
+ $opts_no_deps \
+ '(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \
'--rm[Remove container after run. Ignored in detached mode.]' \
"--service-ports[Run command with the service's ports enabled and mapped to the host.]" \
'-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \
+ '(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \
+ '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
'(-):services:__docker-compose_services' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
;;
(scale)
- _arguments '*:running services:__docker-compose_runningservices' && ret=0
+ _arguments \
+ $opts_help \
+ $opts_timeout \
+ '*:running services:__docker-compose_runningservices' && ret=0
;;
(start)
- _arguments '*:stopped services:__docker-compose_stoppedservices' && ret=0
+ _arguments \
+ $opts_help \
+ '*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(stop|restart)
_arguments \
- '(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \
+ $opts_help \
+ $opts_timeout \
'*:running services:__docker-compose_runningservices' && ret=0
;;
+ (unpause)
+ _arguments \
+ $opts_help \
+ '*:paused services:__docker-compose_pausedservices' && ret=0
+ ;;
(up)
_arguments \
- '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
- '-d[Detached mode: Run containers in the background, print new container names.]' \
- '--no-color[Produce monochrome output.]' \
- "--no-deps[Don't start linked services.]" \
- "--no-recreate[If containers already exist, don't recreate them.]" \
- "--no-build[Don't build an image, even if it's missing]" \
- '(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \
- "--x-smart-recreate[Only recreate containers whose configuration or image needs to be updated. (EXPERIMENTAL)]" \
+ $opts_help \
+ '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \
+ $opts_no_color \
+ $opts_no_deps \
+ $opts_force_recreate \
+ $opts_no_recreate \
+ $opts_no_build \
+ "(--no-build)--build[Build images before starting containers.]" \
+ "(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
+ '(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
+ $opts_remove_orphans \
'*:services:__docker-compose_services_all' && ret=0
;;
(version)
_arguments \
+ $opts_help \
"--short[Shows only Compose's version number.]" && ret=0
;;
(*)
- _message 'Unknown sub command'
+ _message 'Unknown sub command' && ret=1
+ ;;
esac
return ret
}
-_docker-compose () {
+_docker-compose() {
# Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`.
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
if [[ $service != docker-compose ]]; then
@@ -262,34 +381,62 @@ _docker-compose () {
return
fi
- local curcontext="$curcontext" state line ret=1
+ local curcontext="$curcontext" state line
+ integer ret=1
typeset -A opt_args
_arguments -C \
'(- :)'{-h,--help}'[Get help]' \
- '--verbose[Show more output]' \
- '(- :)'{-v,--version}'[Print version and exit]' \
'(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
+ '--verbose[Show more output]' \
+ '(- :)'{-v,--version}'[Print version and exit]' \
+ '(-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:' \
+ '--tlscert=[Path to TLS certificate file]:client cert path:' \
+ '--tlskey=[Path to TLS key file]:tls key path:' \
+ '--tlsverify[Use TLS and verify the remote]' \
+ "--skip-hostname-check[Don't check the daemon's hostname against the name specified in the client certificate (for example if your docker host is an IP address)]" \
'(-): :->command' \
'(-)*:: :->option-or-argument' && ret=0
- local counter=1
- #local compose_file compose_project
- while [ $counter -lt ${#words[@]} ]; do
- case "${words[$counter]}" in
- -f|--file)
- (( counter++ ))
- compose_file="${words[$counter]}"
- ;;
- -p|--project-name)
- (( counter++ ))
- compose_project="${words[$counter]}"
- ;;
- *)
- ;;
- esac
- (( counter++ ))
+ local -a relevant_compose_flags relevant_docker_flags compose_options docker_options
+
+ relevant_compose_flags=(
+ "--file" "-f"
+ "--host" "-H"
+ "--project-name" "-p"
+ "--tls"
+ "--tlscacert"
+ "--tlscert"
+ "--tlskey"
+ "--tlsverify"
+ "--skip-hostname-check"
+ )
+
+ relevant_docker_flags=(
+ "--host" "-H"
+ "--tls"
+ "--tlscacert"
+ "--tlscert"
+ "--tlskey"
+ "--tlsverify"
+ )
+
+ for k in "${(@k)opt_args}"; do
+ if [[ -n "${relevant_docker_flags[(r)$k]}" ]]; then
+ docker_options+=$k
+ if [[ -n "$opt_args[$k]" ]]; then
+ docker_options+=$opt_args[$k]
+ fi
+ fi
+ if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then
+ compose_options+=$k
+ if [[ -n "$opt_args[$k]" ]]; then
+ compose_options+=$opt_args[$k]
+ fi
+ fi
done
case $state in
diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh
new file mode 100644
index 000000000..4e4ac114a
--- /dev/null
+++ b/plugins/docker-compose/docker-compose.plugin.zsh
@@ -0,0 +1,23 @@
+# Authors:
+# https://github.com/tristola
+#
+# Docker-compose related zsh aliases
+
+# Aliases ###################################################################
+
+# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator'
+# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
+
+alias dco='docker-compose'
+
+alias dcb='docker-compose build'
+alias dce='docker-compose exec'
+alias dcps='docker-compose ps'
+alias dcrestart='docker-compose restart'
+alias dcrm='docker-compose rm'
+alias dcr='docker-compose run'
+alias dcstop='docker-compose stop'
+alias dcup='docker-compose up'
+alias dcdn='docker-compose down'
+alias dcl='docker-compose logs'
+alias dclf='docker-compose logs -f'
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index 231a6dcf5..1615f75f5 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -1,19 +1,5 @@
## Docker autocomplete plugin
-- Adds autocomplete options for all docker commands.
-- Will also show containerIDs and Image names where applicable
-
-####Shows help for all commands
-![General Help](http://i.imgur.com/tUBO9jh.png "Help for all commands")
-
-
-####Shows your downloaded images where applicable
-![Images](http://i.imgur.com/R8ZsWO1.png "Images")
-
-
-####Shows your running containers where applicable
-![Containers](http://i.imgur.com/WQtbheg.png "Containers")
-
-
-
-Maintainer : Ahmed Azaan ([@aeonazaan](https://twitter.com/aeonazaan))
+A copy of the completion script from the
+[docker](https://github.com/docker/docker/tree/master/contrib/completion/zsh)
+git repo.
diff --git a/plugins/docker/_docker b/plugins/docker/_docker
index a82a31ad3..1aec353c5 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -1,439 +1,2754 @@
-#compdef docker
-
-# Docker autocompletion for oh-my-zsh
-# Requires: Docker installed
-# Author: Azaan (@aeonazaan)
-# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
-# Paul van den Berg (@bergvandenp) for Docker v1.3+
-
-
-# ----- Helper functions
-# Output a selectable list of all running docker containers
-__docker_containers() {
- declare -a cont_cmd
- cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
- if [[ 'X$cont_cmd' != 'X' ]]
- _describe 'containers' cont_cmd
-}
-
-# Output a selectable list of all containers, even not running
-__docker_all_containers() {
- declare -a cont_cmd
- cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
- if [[ 'X$cont_cmd' != 'X' ]]
- _describe 'containers' cont_cmd
-}
-
-# output a selectable list of all docker images
-__docker_images() {
- declare -a img_cmd
- img_cmd=($(docker images | awk 'NR>1{print $1}'| sed 's/:/\\:/g'))
- _describe 'images' img_cmd
-}
-
-# ----- Commands
-# Seperate function for each command, makes extension easier later
-# ---------------------------
-__attach() {
- _arguments \
- '--no-stdin[Do not attach STDIN]' \
- '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]'
- __docker_containers
-}
-
-__build() {
- _arguments \
- '--no-cache[Do not use cache when building the image]' \
- '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \
- '--rm[Remove intermediate containers after a successful build]' \
- '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \
- '*:files:_files'
-}
-
-__commit() {
- _arguments \
- '(-a,--author=)'{-a,--author=}'[Author (e.g. "John Hannibal Smith <hannibal@a-team.com>")]' \
- '(-c,--change=)'{-c,--change=}'[Apply Dockerfile instruction to the created image]' \
- '(-m,--message=)'{-m,--message=}'[Commit message]' \
- '(-p,--pause=)'{-p,--pause=}'[Pause container during commit]' \
-}
-
-__cp() {
- __docker_containers
-}
-
-__create() {
- _arguments \
- '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
- '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \
- '--add-host=[Add a custom host-to-IP mapping]' \
- '--cap-add=[Add Linux capabilities]' \
- '--cap-drop=[Drop Linux capabilities]' \
- '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \
- '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \
- '--cidfile=[Write the container ID to the file]' \
- '--device=[Add a host device to the container]' \
- '--dns=[Set custom dns servers]' \
- '--dns-search=[Set custom DNS search domains]' \
- '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
- '--env-file=[Read in a file of environment variables]' \
- '--entrypoint=[Overwrite the default entrypoint of the image]' \
- '--expose=[Expose a port from the container without publishing it to your host]' \
- '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
- '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
- '--ipc=[IPC namespace to use]' \
- '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \
- '--link=[Add link to another container (name:alias)]' \
- '--log-driver=[Logging driver for the container]' \
- '--lxc-conf=[Add custom LXC options]' \
- '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \
- '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
- '--net=[Set the Network mode for the container]' \
- '--name=[Assign a name to the container]' \
- '--pid=[PID namespace to use]' \
- '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \
- '--privileged=[Give extended privileges to this container]' \
- '--restart=[Restart policy to apply when a container exits]' \
- '--security-opt=[Security Options]' \
- '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
- '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
- '(-u,--user=)'{-u,--user=}'[Username or UID]' \
- '--ulimit=[Ulimit options]' \
- '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \
- '--volumes-from=[Mount volumes from the specified container(s)]' \
- '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
- __docker_images
+#compdef docker dockerd
+#
+# zsh completion for docker (http://docker.com)
+#
+# version: 0.3.0
+# github: https://github.com/felixr/docker-zsh-completion
+#
+# contributors:
+# - Felix Riedel
+# - Steve Durrheimer
+# - Vincent Bernat
+#
+# license:
+#
+# Copyright (c) 2013, Felix Riedel
+# 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 <organization> 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 <COPYRIGHT HOLDER> 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.
+#
+
+# Short-option stacking can be enabled with:
+# zstyle ':completion:*:*:docker:*' option-stacking yes
+# zstyle ':completion:*:*:docker-*:*' option-stacking yes
+__docker_arguments() {
+ if zstyle -t ":completion:${curcontext}:" option-stacking; then
+ print -- -s
+ fi
+}
+
+__docker_get_containers() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local kind type line s
+ declare -a running stopped lines args names
+
+ kind=$1; shift
+ type=$1; shift
+ [[ $kind = (stopped|all) ]] && args=($args -a)
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options ps --format 'table' --no-trunc $args)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1 # Last column, should go to the end of the line
+ lines=(${lines[2,-1]})
+
+ # Container ID
+ if [[ $type = (ids|all) ]]; then
+ for line in $lines; do
+ s="${${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}[0,12]}"
+ s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
+ s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
+ if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
+ stopped=($stopped $s)
+ else
+ running=($running $s)
+ fi
+ done
+ fi
+
+ # Names: we only display the one without slash. All other names
+ # are generated and may clutter the completion. However, with
+ # Swarm, all names may be prefixed by the swarm node name.
+ if [[ $type = (names|all) ]]; then
+ for line in $lines; do
+ names=(${(ps:,:)${${line[${begin[NAMES]},${end[NAMES]}]}%% *}})
+ # First step: find a common prefix and strip it (swarm node case)
+ (( ${#${(u)names%%/*}} == 1 )) && names=${names#${names[1]%%/*}/}
+ # Second step: only keep the first name without a /
+ s=${${names:#*/*}[1]}
+ # If no name, well give up.
+ (( $#s != 0 )) || continue
+ s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
+ s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
+ if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
+ stopped=($stopped $s)
+ else
+ running=($running $s)
+ fi
+ done
+ fi
+
+ [[ $kind = (running|all) ]] && _describe -t containers-running "running containers" running "$@" && ret=0
+ [[ $kind = (stopped|all) ]] && _describe -t containers-stopped "stopped containers" stopped "$@" && ret=0
+ return ret
+}
+
+__docker_complete_stopped_containers() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_containers stopped all "$@"
+}
+
+__docker_complete_running_containers() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_containers running all "$@"
+}
+
+__docker_complete_containers() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_containers all all "$@"
+}
+
+__docker_complete_containers_ids() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_containers all ids "$@"
+}
+
+__docker_complete_containers_names() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_containers all names "$@"
+}
+
+__docker_complete_info_plugins() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ emulate -L zsh
+ setopt extendedglob
+ local -a plugins
+ plugins=(${(ps: :)${(M)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Plugins:}%%$'\n'^ *}}:# $1: *}## $1: })
+ _describe -t plugins "$1 plugins" plugins && ret=0
+ return ret
+}
+
+__docker_complete_images() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a images
+ images=(${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}})
+ _describe -t docker-images "images" images && ret=0
+ __docker_complete_repositories_with_tags && ret=0
+ return ret
+}
+
+__docker_complete_repositories() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a repos
+ repos=(${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}%% *}[2,-1]})
+ repos=(${repos#<none>})
+ _describe -t docker-repos "repositories" repos && ret=0
+ return ret
+}
+
+__docker_complete_repositories_with_tags() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a repos onlyrepos matched
+ declare m
+ repos=(${${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}[2,-1]}/ ##/:::}%% *})
+ repos=(${${repos%:::<none>}#<none>})
+ # Check if we have a prefix-match for the current prefix.
+ onlyrepos=(${repos%::*})
+ for m in $onlyrepos; do
+ [[ ${PREFIX##${~~m}} != ${PREFIX} ]] && {
+ # Yes, complete with tags
+ repos=(${${repos/:::/:}/:/\\:})
+ _describe -t docker-repos-with-tags "repositories with tags" repos && ret=0
+ return ret
+ }
+ done
+ # No, only complete repositories
+ onlyrepos=(${${repos%:::*}/:/\\:})
+ _describe -t docker-repos "repositories" onlyrepos -qS : && ret=0
+
+ return ret
+}
+
+__docker_search() {
+ [[ $PREFIX = -* ]] && return 1
+ local cache_policy
+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+ if [[ -z "$cache_policy" ]]; then
+ zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy
+ fi
+
+ local searchterm cachename
+ searchterm="${words[$CURRENT]%/}"
+ cachename=_docker-search-$searchterm
+
+ local expl
+ local -a result
+ if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
+ && ! _retrieve_cache ${cachename#_}; then
+ _message "Searching for ${searchterm}..."
+ result=(${${${(f)${:-"$(_call_program commands docker $docker_options search $searchterm)"$'\n'}}%% *}[2,-1]})
+ _store_cache ${cachename#_} result
+ fi
+ _wanted dockersearch expl 'available images' compadd -a result
+}
+
+__docker_get_log_options() {
+ [[ $PREFIX = -* ]] && return 1
+
+ integer ret=1
+ local log_driver=${opt_args[--log-driver]:-"all"}
+ local -a awslogs_options fluentd_options gelf_options journald_options json_file_options logentries_options syslog_options splunk_options
+
+ awslogs_options=("awslogs-region" "awslogs-group" "awslogs-stream")
+ fluentd_options=("env" "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "labels" "tag")
+ gcplogs_options=("env" "gcp-log-cmd" "gcp-project" "labels")
+ gelf_options=("env" "gelf-address" "gelf-compression-level" "gelf-compression-type" "labels" "tag")
+ journald_options=("env" "labels" "tag")
+ json_file_options=("env" "labels" "max-file" "max-size")
+ logentries_options=("logentries-token")
+ syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag")
+ splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag")
+
+ [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0
+ [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0
+ [[ $log_driver = (gcplogs|all) ]] && _describe -t gcplogs-options "gcplogs options" gcplogs_options "$@" && ret=0
+ [[ $log_driver = (gelf|all) ]] && _describe -t gelf-options "gelf options" gelf_options "$@" && ret=0
+ [[ $log_driver = (journald|all) ]] && _describe -t journald-options "journald options" journald_options "$@" && ret=0
+ [[ $log_driver = (json-file|all) ]] && _describe -t json-file-options "json-file options" json_file_options "$@" && ret=0
+ [[ $log_driver = (logentries|all) ]] && _describe -t logentries-options "logentries options" logentries_options "$@" && ret=0
+ [[ $log_driver = (syslog|all) ]] && _describe -t syslog-options "syslog options" syslog_options "$@" && ret=0
+ [[ $log_driver = (splunk|all) ]] && _describe -t splunk-options "splunk options" splunk_options "$@" && ret=0
+
+ return ret
+}
+
+__docker_complete_log_drivers() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ drivers=(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog)
+ _describe -t log-drivers "log drivers" drivers && ret=0
+ return ret
+}
+
+__docker_complete_log_options() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (syslog-format)
+ syslog_format_opts=('rfc3164' 'rfc5424' 'rfc5424micro')
+ _describe -t syslog-format-opts "Syslog format Options" syslog_format_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ __docker_get_log_options -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_complete_detach_keys() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ compset -P "*,"
+ keys=(${:-{a-z}})
+ ctrl_keys=(${:-ctrl-{{a-z},{@,'[','\\','^',']',_}}})
+ _describe -t detach_keys "[a-z]" keys -qS "," && ret=0
+ _describe -t detach_keys-ctrl "'ctrl-' + 'a-z @ [ \\\\ ] ^ _'" ctrl_keys -qS "," && ret=0
+}
+
+__docker_complete_pid() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local -a opts vopts
+
+ opts=('host')
+ vopts=('container')
+
+ if compset -P '*:'; then
+ case "${${words[-1]%:*}#*=}" in
+ (container)
+ __docker_complete_running_containers && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ _describe -t pid-value-opts "PID Options with value" vopts -qS ":" && ret=0
+ _describe -t pid-opts "PID Options" opts && ret=0
+ fi
+
+ return ret
+}
+
+__docker_complete_runtimes() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ emulate -L zsh
+ setopt extendedglob
+ local -a runtimes_opts
+ runtimes_opts=(${(ps: :)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Runtimes: }%%$'\n'^ *}}})
+ _describe -t runtimes-opts "runtimes options" runtimes_opts && ret=0
+}
+
+__docker_complete_ps_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (ancestor)
+ __docker_complete_images && ret=0
+ ;;
+ (before|since)
+ __docker_complete_containers && ret=0
+ ;;
+ (health)
+ health_opts=('healthy' 'none' 'starting' 'unhealthy')
+ _describe -t health-filter-opts "health filter options" health_opts && ret=0
+ ;;
+ (id)
+ __docker_complete_containers_ids && ret=0
+ ;;
+ (is-task)
+ _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0
+ ;;
+ (name)
+ __docker_complete_containers_names && ret=0
+ ;;
+ (network)
+ __docker_complete_networks && ret=0
+ ;;
+ (status)
+ status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing')
+ _describe -t status-filter-opts "status filter options" status_opts && ret=0
+ ;;
+ (volume)
+ __docker_complete_volumes && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('ancestor' 'before' 'exited' 'health' 'id' 'label' 'name' 'network' 'since' 'status' 'volume')
+ _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_complete_search_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a boolean_opts opts
+
+ boolean_opts=('true' 'false')
+ opts=('is-automated' 'is-official' 'stars')
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (is-automated|is-official)
+ _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_complete_images_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a boolean_opts opts
+
+ boolean_opts=('true' 'false')
+ opts=('before' 'dangling' 'label' 'reference' 'since')
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (before|reference|since)
+ __docker_complete_images && ret=0
+ ;;
+ (dangling)
+ _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_complete_events_filter() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a opts
+
+ opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'type' 'volume')
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (container)
+ __docker_complete_containers && ret=0
+ ;;
+ (daemon)
+ emulate -L zsh
+ setopt extendedglob
+ local -a daemon_opts
+ daemon_opts=(
+ ${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Name: }%%$'\n'^ *}}
+ ${${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'ID: }%%$'\n'^ *}}//:/\\:}
+ )
+ _describe -t daemon-filter-opts "daemon filter options" daemon_opts && ret=0
+ ;;
+ (event)
+ local -a event_opts
+ event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach'
+ 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start'
+ 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update')
+ _describe -t event-filter-opts "event filter options" event_opts && ret=0
+ ;;
+ (image)
+ __docker_complete_images && ret=0
+ ;;
+ (network)
+ __docker_complete_networks && ret=0
+ ;;
+ (type)
+ local -a type_opts
+ type_opts=('container' 'daemon' 'image' 'network' 'volume')
+ _describe -t type-filter-opts "type filter options" type_opts && ret=0
+ ;;
+ (volume)
+ __docker_complete_volumes && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+# BO container
+
+__docker_container_commands() {
+ local -a _docker_container_subcommands
+ _docker_container_subcommands=(
+ "attach:Attach to a running container"
+ "commit:Create a new image from a container's changes"
+ "cp:Copy files/folders between a container and the local filesystem"
+ "create:Create a new container"
+ "diff:Inspect changes on a container's filesystem"
+ "exec:Run a command in a running container"
+ "export:Export a container's filesystem as a tar archive"
+ "inspect:Display detailed information on one or more containers"
+ "kill:Kill one or more running containers"
+ "logs:Fetch the logs of a container"
+ "ls:List containers"
+ "pause:Pause all processes within one or more containers"
+ "port:List port mappings or a specific mapping for the container"
+ "prune:Remove all stopped containers"
+ "rename:Rename a container"
+ "restart:Restart one or more containers"
+ "rm:Remove one or more containers"
+ "run:Run a command in a new container"
+ "start:Start one or more stopped containers"
+ "stats:Display a live stream of container(s) resource usage statistics"
+ "stop:Stop one or more running containers"
+ "top:Display the running processes of a container"
+ "unpause:Unpause all processes within one or more containers"
+ "update:Update configuration of one or more containers"
+ "wait:Block until one or more containers stop, then print their exit codes"
+ )
+ _describe -t docker-container-commands "docker container command" _docker_container_subcommands
+}
+
+__docker_container_subcommand() {
+ local -a _command_args opts_help opts_attach_exec_run_start opts_create_run opts_create_run_update
+ local expl help="--help"
+ integer ret=1
+
+ opts_attach_exec_run_start=(
+ "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys"
+ )
+ opts_create_run=(
+ "($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)"
+ "($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: "
+ "($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)--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: "
+ "($help)*--device=[Add a host device to the container]:device:_files"
+ "($help)*--device-read-bps=[Limit the read rate (bytes per second) from a device]:device:IO rate: "
+ "($help)*--device-read-iops=[Limit the read rate (IO per second) from a device]:device:IO rate: "
+ "($help)*--device-write-bps=[Limit the write rate (bytes per second) to a device]:device:IO rate: "
+ "($help)*--device-write-iops=[Limit the write rate (IO per second) to a device]:device:IO rate: "
+ "($help)--disable-content-trust[Skip image verification]"
+ "($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)*"{-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 -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
+ "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
+ "($help)--ip=[Container IPv4 address]:IPv4: "
+ "($help)--ip6=[Container IPv6 address]:IPv6: "
+ "($help)--ipc=[IPC namespace to use]:IPC namespace: "
+ "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)"
+ "($help)*--link=[Add link to another container]:link:->link"
+ "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: "
+ "($help)*"{-l=,--label=}"[Container metadata]:label: "
+ "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers"
+ "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_complete_log_options"
+ "($help)--mac-address=[Container MAC address]:MAC address: "
+ "($help)--name=[Container name]:name: "
+ "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)"
+ "($help)*--network-alias=[Add network-scoped alias for the container]:alias: "
+ "($help)--oom-kill-disable[Disable OOM Killer]"
+ "($help)--oom-score-adj[Tune the host's OOM preferences for containers (accepts -1000 to 1000)]"
+ "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]"
+ "($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]"
+ "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports"
+ "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid"
+ "($help)--privileged[Give extended privileges to this container]"
+ "($help)--read-only[Mount the container's root filesystem as read only]"
+ "($help)*--security-opt=[Security options]:security option: "
+ "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: "
+ "($help)--stop-timeout=[Timeout (in seconds) to stop a container]:time: "
+ "($help)*--sysctl=-[sysctl options]:sysctl: "
+ "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]"
+ "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users"
+ "($help)*--ulimit=[ulimit options]:ulimit: "
+ "($help)--userns=[Container user namespace]:user namespace:(host)"
+ "($help)--tmpfs[mount tmpfs]"
+ "($help)*-v[Bind mount a volume]:volume: "
+ "($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)"
+ "($help)*--volumes-from=[Mount volumes from the specified container]:volume: "
+ "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
+ )
+ opts_create_run_update=(
+ "($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)"
+ "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)"
+ "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: "
+ "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: "
+ "($help)--cpu-rt-period=[Limit the CPU real-time period]:CPU real-time period in microseconds: "
+ "($help)--cpu-rt-runtime=[Limit the CPU real-time runtime]:CPU real-time runtime in microseconds: "
+ "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: "
+ "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: "
+ "($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: "
+ "($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)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)"
+ )
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (attach)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $opts_attach_exec_run_start \
+ "($help)--no-stdin[Do not attach stdin]" \
+ "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
+ "($help -):containers:__docker_complete_running_containers" && ret=0
+ ;;
+ (commit)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --author)"{-a=,--author=}"[Author]:author: " \
+ "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \
+ "($help -m --message)"{-m=,--message=}"[Commit message]:message: " \
+ "($help -p --pause)"{-p,--pause}"[Pause container during commit]" \
+ "($help -):container:__docker_complete_containers" \
+ "($help -): :__docker_complete_repositories_with_tags" && ret=0
+ ;;
+ (cp)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -L --follow-link)"{-L,--follow-link}"[Always follow symbol link]" \
+ "($help -)1:container:->container" \
+ "($help -)2:hostpath:_files" && ret=0
+ case $state in
+ (container)
+ if compset -P "*:"; then
+ _files && ret=0
+ else
+ __docker_complete_containers -qS ":" && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (create)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $opts_create_run \
+ $opts_create_run_update \
+ "($help -): :__docker_complete_images" \
+ "($help -):command: _command_names -e" \
+ "($help -)*::arguments: _normal" && ret=0
+ case $state in
+ (link)
+ if compset -P "*:"; then
+ _wanted alias expl "Alias" compadd -E "" && ret=0
+ else
+ __docker_complete_running_containers -qS ":" && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (diff)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:containers:__docker_complete_containers" && ret=0
+ ;;
+ (exec)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $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 -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]" \
+ "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \
+ "($help -):containers:__docker_complete_running_containers" \
+ "($help -)*::command:->anycommand" && ret=0
+ case $state in
+ (anycommand)
+ shift 1 words
+ (( CURRENT-- ))
+ _normal && ret=0
+ ;;
+ esac
+ ;;
+ (export)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \
+ "($help -)*:containers:__docker_complete_containers" && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help -s --size)"{-s,--size}"[Display total file sizes]" \
+ "($help -)*:containers:__docker_complete_containers" && ret=0
+ ;;
+ (kill)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \
+ "($help -)*:containers:__docker_complete_running_containers" && ret=0
+ ;;
+ (logs)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--details[Show extra details provided to logs]" \
+ "($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 -)*:containers:__docker_complete_containers" && ret=0
+ ;;
+ (ls|list)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Show all containers]" \
+ "($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \
+ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \
+ "($help)--format=[Pretty-print containers using a Go template]:template: " \
+ "($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 -s --size)"{-s,--size}"[Display total file sizes]" \
+ "($help)--since=[Show only containers created since...]:containers:__docker_complete_containers" && ret=0
+ ;;
+ (pause|unpause)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:containers:__docker_complete_running_containers" && ret=0
+ ;;
+ (port)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:containers:__docker_complete_running_containers" \
+ "($help -)2:port:_ports" && ret=0
+ ;;
+ (prune)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
+ ;;
+ (rename)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -):old name:__docker_complete_containers" \
+ "($help -):new name: " && ret=0
+ ;;
+ (restart)
+ _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
+ ;;
+ (rm)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Force removal]" \
+ "($help -l --link)"{-l,--link}"[Remove the specified link and not the underlying container]" \
+ "($help -v --volumes)"{-v,--volumes}"[Remove the volumes associated to the container]" \
+ "($help -)*:containers:->values" && ret=0
+ case $state in
+ (values)
+ if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then
+ __docker_complete_containers && ret=0
+ else
+ __docker_complete_stopped_containers && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (run)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $opts_create_run \
+ $opts_create_run_update \
+ $opts_attach_exec_run_start \
+ "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
+ "($help)--health-cmd=[Command to run to check health]:command: " \
+ "($help)--health-interval=[Time between running the check]:time: " \
+ "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" \
+ "($help)--health-timeout=[Maximum time to allow one check to run]:time: " \
+ "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" \
+ "($help)--rm[Remove intermediate containers when it exits]" \
+ "($help)--runtime=[Name of the runtime to be used for that container]:runtime:__docker_complete_runtimes" \
+ "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
+ "($help)--stop-signal=[Signal to kill a container]:signal:_signals" \
+ "($help)--storage-opt=[Storage driver options for the container]:storage options:->storage-opt" \
+ "($help -): :__docker_complete_images" \
+ "($help -):command: _command_names -e" \
+ "($help -)*::arguments: _normal" && ret=0
+ case $state in
+ (link)
+ if compset -P "*:"; then
+ _wanted alias expl "Alias" compadd -E "" && ret=0
+ else
+ __docker_complete_running_containers -qS ":" && ret=0
+ fi
+ ;;
+ (storage-opt)
+ if compset -P "*="; then
+ _message "value" && ret=0
+ else
+ opts=('size')
+ _describe -t filter-opts "storage options" opts -qS "=" && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (start)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $opts_attach_exec_run_start \
+ "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \
+ "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \
+ "($help -)*:containers:__docker_complete_stopped_containers" && ret=0
+ ;;
+ (stats)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \
+ "($help)--format=[Pretty-print images using a Go template]:template: " \
+ "($help)--no-stream[Disable streaming stats and only pull the first result]" \
+ "($help -)*:containers:__docker_complete_running_containers" && ret=0
+ ;;
+ (stop)
+ _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_running_containers" && ret=0
+ ;;
+ (top)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:containers:__docker_complete_running_containers" \
+ "($help -)*:: :->ps-arguments" && ret=0
+ case $state in
+ (ps-arguments)
+ _ps && ret=0
+ ;;
+ esac
+ ;;
+ (update)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ opts_create_run_update \
+ "($help -)*: :->values" && ret=0
+ case $state in
+ (values)
+ if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then
+ __docker_complete_stopped_containers && ret=0
+ else
+ __docker_complete_containers && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (wait)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:containers:__docker_complete_running_containers" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_container_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO container
+
+# BO image
+
+__docker_image_commands() {
+ local -a _docker_image_subcommands
+ _docker_image_subcommands=(
+ "build:Build an image from a Dockerfile"
+ "history:Show the history of an image"
+ "import:Import the contents from a tarball to create a filesystem image"
+ "inspect:Display detailed information on one or more images"
+ "load:Load an image from a tar archive or STDIN"
+ "ls:List images"
+ "prune:Remove unused images"
+ "pull:Pull an image or a repository from a registry"
+ "push:Push an image or a repository to a registry"
+ "rm:Remove one or more images"
+ "save:Save one or more images to a tar archive (streamed to STDOUT by default)"
+ "tag:Tag an image into a repository"
+ )
+ _describe -t docker-image-commands "docker image command" _docker_image_subcommands
+}
+
+__docker_image_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (build)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*--build-arg=[Build-time variables]:<varname>=<value>: " \
+ "($help)*--cache-from=[Images to consider as cache sources]: :__docker_complete_repositories_with_tags" \
+ "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" \
+ "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " \
+ "($help)--compress[Compress the build context using gzip]" \
+ "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " \
+ "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " \
+ "($help)--cpu-rt-period=[Limit the CPU real-time period]:CPU real-time period in microseconds: " \
+ "($help)--cpu-rt-runtime=[Limit the CPU real-time runtime]:CPU real-time runtime in microseconds: " \
+ "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " \
+ "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " \
+ "($help)--disable-content-trust[Skip image verification]" \
+ "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \
+ "($help)--force-rm[Always remove intermediate containers]" \
+ "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" \
+ "($help)*--label=[Set metadata for an image]:label=value: " \
+ "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " \
+ "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " \
+ "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" \
+ "($help)--no-cache[Do not use cache when building the image]" \
+ "($help)--pull[Attempt to pull a newer version of the image]" \
+ "($help -q --quiet)"{-q,--quiet}"[Suppress verbose build output]" \
+ "($help)--rm[Remove intermediate containers after a successful build]" \
+ "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " \
+ "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_complete_repositories_with_tags" \
+ "($help)*--ulimit=[ulimit options]:ulimit: " \
+ "($help)--userns=[Container user namespace]:user namespace:(host)" \
+ "($help -):path or URL:_directories" && ret=0
+ ;;
+ (history)
+ _arguments $(__docker_arguments) \
+ $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 -)*: :__docker_complete_images" && ret=0
+ ;;
+ (import)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \
+ "($help -m --message)"{-m=,--message=}"[Commit message for imported image]:message: " \
+ "($help -):URL:(- http:// file://)" \
+ "($help -): :__docker_complete_repositories_with_tags" && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help -)*:images:__docker_complete_images" && ret=0
+ ;;
+ (load)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -i --input)"{-i=,--input=}"[Read from tar archive file]:archive file:_files -g \"*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)\"" \
+ "($help -q --quiet)"{-q,--quiet}"[Suppress the load output]" && ret=0
+ ;;
+ (ls|list)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Show all images]" \
+ "($help)--digests[Show digests]" \
+ "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \
+ "($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 -): :__docker_complete_repositories" && ret=0
+ case $state in
+ (filter-options)
+ __docker_complete_images_filters && ret=0
+ ;;
+ esac
+ ;;
+ (prune)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Remove all unused images, not just dangling ones]" \
+ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
+ ;;
+ (pull)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all-tags)"{-a,--all-tags}"[Download all tagged images]" \
+ "($help)--disable-content-trust[Skip image verification]" \
+ "($help -):name:__docker_search" && ret=0
+ ;;
+ (push)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--disable-content-trust[Skip image signing]" \
+ "($help -): :__docker_complete_images" && ret=0
+ ;;
+ (rm)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Force removal]" \
+ "($help)--no-prune[Do not delete untagged parents]" \
+ "($help -)*: :__docker_complete_images" && ret=0
+ ;;
+ (save)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -o --output)"{-o=,--output=}"[Write to file]:file:_files" \
+ "($help -)*: :__docker_complete_images" && ret=0
+ ;;
+ (tag)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -):source:__docker_complete_images"\
+ "($help -):destination:__docker_complete_repositories_with_tags" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_container_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO image
+
+# BO network
+
+__docker_network_complete_ls_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (driver)
+ __docker_complete_info_plugins Network && ret=0
+ ;;
+ (id)
+ __docker_complete_networks_ids && ret=0
+ ;;
+ (name)
+ __docker_complete_networks_names && ret=0
+ ;;
+ (type)
+ type_opts=('builtin' 'custom')
+ _describe -t type-filter-opts "Type Filter Options" type_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('driver' 'id' 'label' 'name' 'type')
+ _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_get_networks() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local line s
+ declare -a lines networks
+
+ type=$1; shift
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options network ls)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # Network ID
+ if [[ $type = (ids|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[NETWORK ID]},${end[NETWORK ID]}]%% ##}"
+ s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}"
+ s="$s, ${${line[${begin[SCOPE]},${end[SCOPE]}]}%% ##}"
+ networks=($networks $s)
+ done
+ fi
+
+ # Names
+ if [[ $type = (names|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
+ s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}"
+ s="$s, ${${line[${begin[SCOPE]},${end[SCOPE]}]}%% ##}"
+ networks=($networks $s)
+ done
+ fi
+
+ _describe -t networks-list "networks" networks "$@" && ret=0
+ return ret
+}
+
+__docker_complete_networks() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_networks all "$@"
+}
+
+__docker_complete_networks_ids() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_networks ids "$@"
+}
+
+__docker_complete_networks_names() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_get_networks names "$@"
+}
+
+__docker_network_commands() {
+ local -a _docker_network_subcommands
+ _docker_network_subcommands=(
+ "connect:Connect a container to a network"
+ "create:Creates a new network with a name specified by the user"
+ "disconnect:Disconnects a container from a network"
+ "inspect:Displays detailed information on a network"
+ "ls:Lists all the networks created by the user"
+ "prune:Remove all unused networks"
+ "rm:Deletes one or more networks"
+ )
+ _describe -t docker-network-commands "docker network command" _docker_network_subcommands
+}
+
+__docker_network_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (connect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*--alias=[Add network-scoped alias for the container]:alias: " \
+ "($help)--ip=[Container IPv4 address]:IPv4: " \
+ "($help)--ip6=[Container IPv6 address]:IPv6: " \
+ "($help)*--link=[Add a link to another container]:link:->link" \
+ "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " \
+ "($help -)1:network:__docker_complete_networks" \
+ "($help -)2:containers:__docker_complete_containers" && ret=0
+
+ case $state in
+ (link)
+ if compset -P "*:"; then
+ _wanted alias expl "Alias" compadd -E "" && ret=0
+ else
+ __docker_complete_running_containers -qS ":" && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (create)
+ _arguments $(__docker_arguments) -A '-*' \
+ $opts_help \
+ "($help)--attachable[Enable manual container attachment]" \
+ "($help)*--aux-address[Auxiliary IPv4 or IPv6 addresses used by network driver]:key=IP: " \
+ "($help -d --driver)"{-d=,--driver=}"[Driver to manage the Network]:driver:(null host bridge overlay)" \
+ "($help)*--gateway=[IPv4 or IPv6 Gateway for the master subnet]:IP: " \
+ "($help)--internal[Restricts external access to the network]" \
+ "($help)*--ip-range=[Allocate container ip from a sub-range]:IP/mask: " \
+ "($help)--ipam-driver=[IP Address Management Driver]:driver:(default)" \
+ "($help)*--ipam-opt=[Custom IPAM plugin options]:opt=value: " \
+ "($help)--ipv6[Enable IPv6 networking]" \
+ "($help)*--label=[Set metadata on a network]:label=value: " \
+ "($help)*"{-o=,--opt=}"[Driver specific options]:opt=value: " \
+ "($help)*--subnet=[Subnet in CIDR format that represents a network segment]:IP/mask: " \
+ "($help -)1:Network Name: " && ret=0
+ ;;
+ (disconnect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:network:__docker_complete_networks" \
+ "($help -)2:containers:__docker_complete_containers" && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help -)*:network:__docker_complete_networks" && ret=0
+ ;;
+ (ls)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--no-trunc[Do not truncate the output]" \
+ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
+ "($help)--format=[Pretty-print networks using a Go template]:template: " \
+ "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0
+ case $state in
+ (filter-options)
+ __docker_network_complete_ls_filters && ret=0
+ ;;
+ esac
+ ;;
+ (prune)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
+ ;;
+ (rm)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:network:__docker_complete_networks" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO network
+
+# BO node
+
+__docker_node_complete_ls_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (id)
+ __docker_complete_nodes_ids && ret=0
+ ;;
+ (membership)
+ membership_opts=('accepted' 'pending' 'rejected')
+ _describe -t membership-opts "membership options" membership_opts && ret=0
+ ;;
+ (name)
+ __docker_complete_nodes_names && ret=0
+ ;;
+ (role)
+ role_opts=('manager' 'worker')
+ _describe -t role-opts "role options" role_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('id' 'label' 'membership' 'name' 'role')
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_node_complete_ps_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (desired-state)
+ state_opts=('accepted' 'running')
+ _describe -t state-opts "desired state options" state_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('desired-state' 'id' 'label' 'name')
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_nodes() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local line s
+ declare -a lines nodes args
+
+ type=$1; shift
+ filter=$1; shift
+ [[ $filter != "none" ]] && args=("-f $filter")
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options node ls $args)"$'\n'}})
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # Node ID
+ if [[ $type = (ids|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[ID]},${end[ID]}]%% ##}"
+ nodes=($nodes $s)
+ done
+ fi
+
+ # Names
+ if [[ $type = (names|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
+ nodes=($nodes $s)
+ done
+ fi
+
+ _describe -t nodes-list "nodes" nodes "$@" && ret=0
+ return ret
+}
+
+__docker_complete_nodes() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_nodes all none "$@"
+}
+
+__docker_complete_nodes_ids() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_nodes ids none "$@"
+}
+
+__docker_complete_nodes_names() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_nodes names none "$@"
+}
+
+__docker_complete_pending_nodes() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_nodes all "membership=pending" "$@"
+}
+
+__docker_complete_manager_nodes() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_nodes all "role=manager" "$@"
+}
+
+__docker_complete_worker_nodes() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_nodes all "role=worker" "$@"
+}
+
+__docker_node_commands() {
+ local -a _docker_node_subcommands
+ _docker_node_subcommands=(
+ "demote:Demote a node as manager in the swarm"
+ "inspect:Display detailed information on one or more nodes"
+ "ls:List nodes in the swarm"
+ "promote:Promote a node as manager in the swarm"
+ "rm:Remove one or more nodes from the swarm"
+ "ps:List tasks running on one or more nodes, defaults to current node"
+ "update:Update a node"
+ )
+ _describe -t docker-node-commands "docker node command" _docker_node_subcommands
+}
+
+__docker_node_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (rm|remove)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Force remove a node from the swarm]" \
+ "($help -)*:node:__docker_complete_pending_nodes" && ret=0
+ ;;
+ (demote)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:node:__docker_complete_manager_nodes" && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help)--pretty[Print the information in a human friendly format]" \
+ "($help -)*:node:__docker_complete_nodes" && ret=0
+ ;;
+ (ls|list)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
+ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
+ case $state in
+ (filter-options)
+ __docker_node_complete_ls_filters && ret=0
+ ;;
+ esac
+ ;;
+ (promote)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:node:__docker_complete_worker_nodes" && ret=0
+ ;;
+ (ps)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Display all instances]" \
+ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
+ "($help)--no-resolve[Do not map IDs to Names]" \
+ "($help)--no-trunc[Do not truncate output]" \
+ "($help -)*:node:__docker_complete_nodes" && ret=0
+ case $state in
+ (filter-options)
+ __docker_node_complete_ps_filters && ret=0
+ ;;
+ esac
+ ;;
+ (update)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--availability=[Availability of the node]:availability:(active pause drain)" \
+ "($help)*--label-add=[Add or update a node label]:key=value: " \
+ "($help)*--label-rm=[Remove a node label if exists]:label: " \
+ "($help)--role=[Role of the node]:role:(manager worker)" \
+ "($help -)1:node:__docker_complete_nodes" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_node_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO node
+
+# BO plugin
+
+__docker_complete_plugins() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local line s
+ declare -a lines plugins
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options plugin ls)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # Name
+ for line in $lines; do
+ s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
+ s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}"
+ plugins=($plugins $s)
+ done
+
+ _describe -t plugins-list "plugins" plugins "$@" && ret=0
+ return ret
+}
+
+__docker_plugin_commands() {
+ local -a _docker_plugin_subcommands
+ _docker_plugin_subcommands=(
+ "disable:Disable a plugin"
+ "enable:Enable a plugin"
+ "inspect:Return low-level information about a plugin"
+ "install:Install a plugin"
+ "ls:List plugins"
+ "push:Push a plugin"
+ "rm:Remove a plugin"
+ "set:Change settings for a plugin"
+ )
+ _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands
+}
+
+__docker_plugin_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (disable|enable|inspect|install|ls|push|rm)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:plugin:__docker_complete_plugins" && ret=0
+ ;;
+ (set)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:plugin:__docker_complete_plugins" \
+ "($help-)*:key=value: " && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO plugin
+
+# BO secret
+
+__docker_secrets() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local line s
+ declare -a lines secrets
+
+ type=$1; shift
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options secret ls)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # ID
+ if [[ $type = (ids|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[ID]},${end[ID]}]%% ##}"
+ secrets=($secrets $s)
+ done
+ fi
+
+ # Names
+ if [[ $type = (names|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
+ secrets=($secrets $s)
+ done
+ fi
+
+ _describe -t secrets-list "secrets" secrets "$@" && ret=0
+ return ret
+}
+
+__docker_complete_secrets() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_secrets all "$@"
+}
+
+__docker_secret_commands() {
+ local -a _docker_secret_subcommands
+ _docker_secret_subcommands=(
+ "create:Create a secret using stdin as content"
+ "inspect:Display detailed information on one or more secrets"
+ "ls:List secrets"
+ "rm:Remove one or more secrets"
+ )
+ _describe -t docker-secret-commands "docker secret command" _docker_secret_subcommands
}
-__diff() {
- __docker_containers
+__docker_secret_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (create)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-l=,--label=}"[Secret labels]:label: " \
+ "($help -):secret: " && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given Go template]:template: " \
+ "($help -)*:secret:__docker_complete_secrets" && ret=0
+ ;;
+ (ls|list)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
+ ;;
+ (rm|remove)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:secret:__docker_complete_secrets" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_secret_commands" && ret=0
+ ;;
+ esac
+
+ return ret
}
-__events() {
- _arguments \
- '--since=[Show previously created events and then stream.]'
+# EO secret
+
+# BO service
+
+__docker_service_complete_ls_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (id)
+ __docker_complete_services_ids && ret=0
+ ;;
+ (name)
+ __docker_complete_services_names && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('id' 'label' 'name')
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
}
-__export() {
- __docker_containers
+__docker_service_complete_ps_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (desired-state)
+ state_opts=('accepted' 'running')
+ _describe -t state-opts "desired state options" state_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('desired-state' 'id' 'label' 'name')
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
}
-__history() {
- _arguments \
- '--no-trunc=[Don''t truncate output]' \
- '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]'
- __docker_images
+__docker_services() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local line s
+ declare -a lines services
+
+ type=$1; shift
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options service ls)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # Service ID
+ if [[ $type = (ids|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[ID]},${end[ID]}]%% ##}"
+ s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}"
+ services=($services $s)
+ done
+ fi
+
+ # Names
+ if [[ $type = (names|all) ]]; then
+ for line in $lines; do
+ s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
+ s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}"
+ services=($services $s)
+ done
+ fi
+
+ _describe -t services-list "services" services "$@" && ret=0
+ return ret
}
-__images() {
- _arguments \
- '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \
- '--no-trunc[Don''t truncate output]' \
- '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \
- '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \
- '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]'
- __docker_images
+__docker_complete_services() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_services all "$@"
}
-__import() {
- _arguments '*:files:_files'
+__docker_complete_services_ids() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_services ids "$@"
}
-__info() {
- # no arguments
-}
-
-__inspect() {
- __docker_images
- __docker_all_containers
-}
-
-__kill() {
- _arguments \
- '(-s,--signal=)'{-s,--signal=}'[KILL Signal]'
- __docker_containers
-}
-
-__load() {
- _arguments '*:files:_files'
-}
-
-__login() {
- _arguments \
- '(-e,--email=)'{-e,-email=}'[Email]' \
- '(-p,--password=)'{-p,-password=}'[Password]' \
- '(-u,--username=)'{-u,-username=}'[Username]'
-}
-
-__logs() {
- _arguments \
- '(-f,--follow)'{-f,-follow}'[Follow log output]'
- __docker_containers
-}
-
-__port() {
- __docker_containers
-}
-
-__top() {
- __docker_containers
-}
-
-__ps() {
- _arguments \
- '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \
- '--before-id=[Show only container created before Id, include non-running ones.]' \
- '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \
- '-n=[Show n last created containers, include non-running ones. default=-1.]' \
- '--no-trunc[Don''t truncate output]' \
- '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \
- '(-s,--size)'{-s,--size}'[Display sizes]' \
- '--since-id=[Show only containers created since Id, include non-running ones.]'
+__docker_complete_services_names() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_services names "$@"
}
-__pull() {
- _arguments \
- '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]'
+__docker_service_commands() {
+ local -a _docker_service_subcommands
+ _docker_service_subcommands=(
+ "create:Create a new service"
+ "inspect:Display detailed information on one or more services"
+ "ls:List services"
+ "rm:Remove one or more services"
+ "scale:Scale one or multiple replicated services"
+ "ps:List the tasks of a service"
+ "update:Update a service"
+ )
+ _describe -t docker-service-commands "docker service command" _docker_service_subcommands
}
-__push() {
- # no arguments
+__docker_service_subcommand() {
+ local -a _command_args opts_help opts_create_update
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+ opts_create_update=(
+ "($help)*--constraint=[Placement constraints]:constraint: "
+ "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)"
+ "($help)*"{-e=,--env=}"[Set environment variables]:env: "
+ "($help)--health-cmd=[Command to run to check health]:command: "
+ "($help)--health-interval=[Time between running the check]:time: "
+ "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)"
+ "($help)--health-timeout=[Maximum time to allow one check to run]:time: "
+ "($help)--hostname=[Service container hostname]:hostname: " \
+ "($help)*--label=[Service labels]:label: "
+ "($help)--limit-cpu=[Limit CPUs]:value: "
+ "($help)--limit-memory=[Limit Memory]:value: "
+ "($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: "
+ "($help)*--network=[Network attachments]:network: "
+ "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]"
+ "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: "
+ "($help)--replicas=[Number of tasks]:replicas: "
+ "($help)--reserve-cpu=[Reserve CPUs]:value: "
+ "($help)--reserve-memory=[Reserve Memory]:value: "
+ "($help)--restart-condition=[Restart when condition is met]:mode:(any none on-failure)"
+ "($help)--restart-delay=[Delay between restart attempts]:delay: "
+ "($help)--restart-max-attempts=[Maximum number of restarts before giving up]:max-attempts: "
+ "($help)--restart-window=[Window used to evaluate the restart policy]:window: "
+ "($help)*--secret=[Specify secrets to expose to the service]:secret:__docker_complete_secrets"
+ "($help)--stop-grace-period=[Time to wait before force killing a container]:grace period: "
+ "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-TTY]"
+ "($help)--update-delay=[Delay between updates]:delay: "
+ "($help)--update-failure-action=[Action on update failure]:mode:(pause continue)"
+ "($help)--update-max-failure-ratio=[Failure rate to tolerate during an update]:fraction: "
+ "($help)--update-monitor=[Duration after each task update to monitor for failure]:window: "
+ "($help)--update-parallelism=[Maximum number of tasks updated simultaneously]:number: "
+ "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users"
+ "($help)--with-registry-auth[Send registry authentication details to swarm agents]"
+ "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
+ )
+
+ case "$words[1]" in
+ (create)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $opts_create_update \
+ "($help)*--container-label=[Container labels]:label: " \
+ "($help)*--dns=[Set custom DNS servers]:DNS: " \
+ "($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)--mode=[Service Mode]:mode:(global replicated)" \
+ "($help)--name=[Service name]:name: " \
+ "($help)*--publish=[Publish a port]:port: " \
+ "($help -): :__docker_complete_images" \
+ "($help -):command: _command_names -e" \
+ "($help -)*::arguments: _normal" && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help)--pretty[Print the information in a human friendly format]" \
+ "($help -)*:service:__docker_complete_services" && ret=0
+ ;;
+ (ls|list)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:->filter-options" \
+ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
+ case $state in
+ (filter-options)
+ __docker_service_complete_ls_filters && ret=0
+ ;;
+ esac
+ ;;
+ (rm|remove)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:service:__docker_complete_services" && ret=0
+ ;;
+ (scale)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)*:service:->values" && ret=0
+ case $state in
+ (values)
+ if compset -P '*='; then
+ _message 'replicas' && ret=0
+ else
+ __docker_complete_services -qS "="
+ fi
+ ;;
+ esac
+ ;;
+ (ps)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
+ "($help)--no-resolve[Do not map IDs to Names]" \
+ "($help)--no-trunc[Do not truncate output]" \
+ "($help -q --quiet)"{-q,--quiet}"[Only display task IDs]" \
+ "($help -)1:service:__docker_complete_services" && ret=0
+ case $state in
+ (filter-options)
+ __docker_service_complete_ps_filters && ret=0
+ ;;
+ esac
+ ;;
+ (update)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ $opts_create_update \
+ "($help)--arg=[Service command args]:arguments: _normal" \
+ "($help)*--container-label-add=[Add or update container labels]:label: " \
+ "($help)*--container-label-rm=[Remove a container label by its key]:label: " \
+ "($help)*--dns-add=[Add or update custom DNS servers]:DNS: " \
+ "($help)*--dns-rm=[Remove custom DNS servers]:DNS: " \
+ "($help)*--dns-option-add=[Add or update DNS options]:DNS option: " \
+ "($help)*--dns-option-rm=[Remove DNS options]:DNS option: " \
+ "($help)*--dns-search-add=[Add or update custom DNS search domains]:DNS search: " \
+ "($help)*--dns-search-rm=[Remove DNS search domains]:DNS search: " \
+ "($help)--force[Force update]" \
+ "($help)*--group-add=[Add additional supplementary user groups to the container]:group:_groups" \
+ "($help)*--group-rm=[Remove previously added supplementary user groups from the container]:group:_groups" \
+ "($help)--image=[Service image tag]:image:__docker_complete_repositories" \
+ "($help)*--publish-add=[Add or update a port]:port: " \
+ "($help)*--publish-rm=[Remove a port(target-port mandatory)]:port: " \
+ "($help)--rollback[Rollback to previous specification]" \
+ "($help -)1:service:__docker_complete_services" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_service_commands" && ret=0
+ ;;
+ esac
+
+ return ret
}
-__restart() {
- _arguments \
- '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]'
- __docker_containers
+# EO service
+
+# BO stack
+
+__docker_stack_complete_ps_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (desired-state)
+ state_opts=('accepted' 'running')
+ _describe -t state-opts "desired state options" state_opts && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('desired-state' 'id' 'name')
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_stack_complete_services_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('id' 'label' 'name')
+ _describe -t filter-opts "filter options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_stacks() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ local line s
+ declare -a lines stacks
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options stack ls)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # Service ID
+ for line in $lines; do
+ s="${line[${begin[ID]},${end[ID]}]%% ##}"
+ stacks=($stacks $s)
+ done
+
+ _describe -t stacks-list "stacks" stacks "$@" && ret=0
+ return ret
}
-__rm() {
- _arguments \
- '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
- '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
- '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
- __docker_all_containers
+__docker_complete_stacks() {
+ [[ $PREFIX = -* ]] && return 1
+ __docker_stacks "$@"
}
-__rmi() {
- _arguments \
- '(-f,--force=)'{-f,--force=}'[Force]'
- __docker_images
+__docker_stack_commands() {
+ local -a _docker_stack_subcommands
+ _docker_stack_subcommands=(
+ "deploy:Deploy a new stack or update an existing stack"
+ "ls:List stacks"
+ "ps:List the tasks in the stack"
+ "rm:Remove the stack"
+ "services:List the services in the stack"
+ )
+ _describe -t docker-stack-commands "docker stack command" _docker_stack_subcommands
+}
+
+__docker_stack_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (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)--with-registry-auth[Send registry authentication details to Swarm agents]" \
+ "($help -):stack:__docker_complete_stacks" && ret=0
+ ;;
+ (ls|list)
+ _arguments $(__docker_arguments) \
+ $opts_help && ret=0
+ ;;
+ (ps)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Display all tasks]" \
+ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_ps_filters" \
+ "($help)--no-resolve[Do not map IDs to Names]" \
+ "($help)--no-trunc[Do not truncate output]" \
+ "($help -):stack:__docker_complete_stacks" && ret=0
+ ;;
+ (rm|remove|down)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -):stack:__docker_complete_stacks" && ret=0
+ ;;
+ (services)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \
+ "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \
+ "($help -):stack:__docker_complete_stacks" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_stack_commands" && ret=0
+ ;;
+ esac
+
+ return ret
}
-__run() {
- _arguments \
- '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
- '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \
- '--add-host=[Add a custom host-to-IP mapping]' \
- '--cap-add=[Add Linux capabilities]' \
- '--cap-drop=[Drop Linux capabilities]' \
- '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \
- '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \
- '--cidfile=[Write the container ID to the file]' \
- '(-d,--detach=)'{-d,--detach=}'[Run container in the background, print new container id]' \
- '--device=[Add a host device to the container]' \
- '--dns=[Set custom dns servers]' \
- '--dns-search=[Set custom DNS search domains]' \
- '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
- '--env-file=[Read in a file of environment variables]' \
- '--entrypoint=[Overwrite the default entrypoint of the image]' \
- '--expose=[Expose a port from the container without publishing it to your host]' \
- '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
- '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
- '--ipc=[IPC namespace to use]' \
- '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \
- '--link=[Add link to another container (name:alias)]' \
- '--log-driver=[Logging driver for the container]' \
- '--lxc-conf=[Add custom LXC options]' \
- '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \
- '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
- '--net=[Set the Network mode for the container]' \
- '--name=[Assign a name to the container]' \
- '--pid=[PID namespace to use]' \
- '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \
- '--privileged=[Give extended privileges to this container]' \
- '--restart=[Restart policy to apply when a container exits]' \
- '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \
- '--security-opt=[Security Options]' \
- '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
- '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
- '(-u,--user=)'{-u,--user=}'[Username or UID]' \
- '--ulimit=[Ulimit options]' \
- '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \
- '--volumes-from=[Mount volumes from the specified container(s)]' \
- '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
- __docker_images
-}
-
-__search() {
- _arguments \
- '--no-trunc=[Don''t truncate output]' \
- '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \
- '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]'
-}
-
-__save() {
- __docker_images
-}
-
-__start() {
- _arguments \
- '(-a,--attach=)'{-a,--attach=}'[Attach container''s STDOUT/STDERR and forward all signals to the process]' \
- '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s STDIN]'
- __docker_all_containers
-}
-
-__stats() {
- __docker_containers
-}
-
-__stop() {
- _arguments \
- '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]'
- __docker_containers
-}
-
-__tag() {
- _arguments \
- '(-f,--force=)'{-f,--force=}'[Force]'
- __docker_images
-}
-
-__version() {
- # no arguments
-}
-
-__wait() {
- __docker_containers
-}
-
-__exec() {
- _arguments \
- '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
- '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
- '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
- __docker_containers
-}
-
-# end commands ---------
-# ----------------------
-
-local -a _1st_arguments
-_1st_arguments=(
- "attach":"Attach to a running container"
- "build":"Build a container from a Dockerfile"
- "commit":"Create a new image from a container's changes"
- "cp":"Copy files/folders from the containers filesystem to the host path"
- "create":"Create new container without running it"
- "diff":"Inspect changes on a container's filesystem"
- "events":"Get real time events from the server"
- "export":"Stream the contents of a container as a tar archive"
- "history":"Show the history of an image"
- "images":"List images"
- "import":"Create a new filesystem image from the contents of a tarball"
- "info":"Display system-wide information"
- "inspect":"Return low-level information on a container"
- "kill":"Kill a running container"
- "load":"Load an image from a tar archive"
- "login":"Register or Login to the docker registry server"
- "logs":"Fetch the logs of a container"
- "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"
- "ps":"List containers"
- "pull":"Pull an image or a repository from the docker registry server"
- "push":"Push an image or a repository to the docker registry server"
- "restart":"Restart a running container"
- "rm":"Remove one or more containers"
- "rmi":"Remove one or more images"
- "run":"Run a command in a new container"
- "save":"Save an image to a tar archive"
- "search":"Search for an image in the docker index"
- "start":"Start a stopped container"
- "stats":"Display a live stream of one or more containers' resource usage statistics"
- "stop":"Stop a running container"
- "tag":"Tag an image into a repository"
- "top":"Lookup the running processes of a container"
- "version":"Show the docker version information"
- "wait":"Block until a container stops, then print its exit code"
- "exec":"Run a task inside a running container"
-)
-
-_arguments '*:: :->command'
-
-if (( CURRENT == 1 )); then
- _describe -t commands "docker command" _1st_arguments
- return
-fi
-
-local -a _command_args
-case "$words[1]" in
- attach)
- __attach ;;
- build)
- __build ;;
- commit)
- __commit ;;
- cp)
- __cp ;;
- create)
- __create ;;
- diff)
- __diff ;;
- events)
- __events ;;
- export)
- __export ;;
- history)
- __history ;;
- images)
- __images ;;
- import)
- __import ;;
- info)
- __info ;;
- inspect)
- __inspect ;;
- kill)
- __kill ;;
- load)
- __load ;;
- login)
- __login ;;
- logs)
- __logs ;;
- port)
- __port ;;
- ps)
- __ps ;;
- pull)
- __pull ;;
- push)
- __push ;;
- restart)
- __restart ;;
- rm)
- __rm ;;
- rmi)
- __rmi ;;
- run)
- __run ;;
- save)
- __save ;;
- search)
- __search ;;
- stats)
- __stats ;;
- start)
- __start ;;
- stop)
- __stop ;;
- tag)
- __tag ;;
- top)
- __top ;;
- version)
- __version ;;
- wait)
- __wait ;;
- exec)
- __exec ;;
-esac
+# EO stack
+
+# BO swarm
+
+__docker_swarm_commands() {
+ local -a _docker_swarm_subcommands
+ _docker_swarm_subcommands=(
+ "init:Initialize a swarm"
+ "join:Join a swarm as a node and/or manager"
+ "join-token:Manage join tokens"
+ "leave:Leave a swarm"
+ "update:Update the swarm"
+ )
+ _describe -t docker-swarm-commands "docker swarm command" _docker_swarm_subcommands
+}
+
+__docker_swarm_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (init)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--advertise-addr[Advertised address]:ip\:port: " \
+ "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \
+ "($help)--force-new-cluster[Force create a new cluster from current state]" \
+ "($help)--listen-addr=[Listen address]:ip\:port: " \
+ "($help)--max-snapshots[Number of additional Raft snapshots to retain]" \
+ "($help)--snapshot-interval[Number of log entries between Raft snapshots]" \
+ "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0
+ ;;
+ (join)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--advertise-addr[Advertised address]:ip\:port: " \
+ "($help)--listen-addr=[Listen address]:ip\:port: " \
+ "($help)--token=[Token for entry into the swarm]:secret: " \
+ "($help -):host\:port: " && ret=0
+ ;;
+ (join-token)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -q --quiet)"{-q,--quiet}"[Only display token]" \
+ "($help)--rotate[Rotate join token]" \
+ "($help -):role:(manager worker)" && ret=0
+ ;;
+ (leave)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Force this node to leave the swarm, ignoring warnings]" && ret=0
+ ;;
+ (update)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)--cert-expiry=[Validity period for node certificates]:duration: " \
+ "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \
+ "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \
+ "($help)--max-snapshots[Number of additional Raft snapshots to retain]" \
+ "($help)--snapshot-interval[Number of log entries between Raft snapshots]" \
+ "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO swarm
+
+# BO system
+
+__docker_system_commands() {
+ local -a _docker_system_subcommands
+ _docker_system_subcommands=(
+ "df:Show docker filesystem usage"
+ "events:Get real time events from the server"
+ "info:Display system-wide information"
+ "prune:Remove unused data"
+ )
+ _describe -t docker-system-commands "docker system command" _docker_system_subcommands
+}
+
+__docker_system_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (df)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -v --verbose)"{-v,--verbose}"[Show detailed information on space usage]" && ret=0
+ ;;
+ (events)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \
+ "($help)--since=[Events created since this timestamp]:timestamp: " \
+ "($help)--until=[Events created until this timestamp]:timestamp: " \
+ "($help)--format=[Format the output using the given go template]:template: " && ret=0
+ ;;
+ (info)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
+ ;;
+ (prune)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -a --all)"{-a,--all}"[Remove all unused data, not just dangling ones]" \
+ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO system
+
+# BO volume
+
+__docker_volume_complete_ls_filters() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+
+ if compset -P '*='; then
+ case "${${words[-1]%=*}#*=}" in
+ (dangling)
+ dangling_opts=('true' 'false')
+ _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0
+ ;;
+ (driver)
+ __docker_complete_info_plugins Volume && ret=0
+ ;;
+ (name)
+ __docker_complete_volumes && ret=0
+ ;;
+ *)
+ _message 'value' && ret=0
+ ;;
+ esac
+ else
+ opts=('dangling' 'driver' 'label' 'name')
+ _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
+ fi
+
+ return ret
+}
+
+__docker_complete_volumes() {
+ [[ $PREFIX = -* ]] && return 1
+ integer ret=1
+ declare -a lines volumes
+
+ lines=(${(f)${:-"$(_call_program commands docker $docker_options volume ls)"$'\n'}})
+
+ # 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
+ end[${header[$i,$((j-1))]}]=-1
+ lines=(${lines[2,-1]})
+
+ # Names
+ local line s
+ for line in $lines; do
+ s="${line[${begin[VOLUME NAME]},${end[VOLUME NAME]}]%% ##}"
+ s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}"
+ volumes=($volumes $s)
+ done
+
+ _describe -t volumes-list "volumes" volumes && ret=0
+ return ret
+}
+
+__docker_volume_commands() {
+ local -a _docker_volume_subcommands
+ _docker_volume_subcommands=(
+ "create:Create a volume"
+ "inspect:Display detailed information on one or more volumes"
+ "ls:List volumes"
+ "prune:Remove all unused volumes"
+ "rm:Remove one or more volumes"
+ )
+ _describe -t docker-volume-commands "docker volume command" _docker_volume_subcommands
+}
+
+__docker_volume_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (create)
+ _arguments $(__docker_arguments) -A '-*' \
+ $opts_help \
+ "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \
+ "($help)*--label=[Set metadata for a volume]:label=value: " \
+ "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \
+ "($help -)1:Volume name: " && ret=0
+ ;;
+ (inspect)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help -)1:volume:__docker_complete_volumes" && ret=0
+ ;;
+ (ls)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
+ "($help)--format=[Pretty-print volumes using a Go template]:template: " \
+ "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0
+ case $state in
+ (filter-options)
+ __docker_volume_complete_ls_filters && ret=0
+ ;;
+ esac
+ ;;
+ (prune)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
+ ;;
+ (rm)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \
+ "($help -):volume:__docker_complete_volumes" && ret=0
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+# EO volume
+
+__docker_caching_policy() {
+ oldp=( "$1"(Nmh+1) ) # 1 hour
+ (( $#oldp ))
+}
+
+__docker_commands() {
+ local cache_policy
+
+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+ if [[ -z "$cache_policy" ]]; then
+ zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy
+ fi
+
+ if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
+ && ! _retrieve_cache docker_subcommands;
+ then
+ local -a lines
+ lines=(${(f)"$(_call_program commands docker 2>&1)"})
+ _docker_subcommands=(${${${(M)${lines[$((${lines[(i)*Commands:]} + 1)),-1]}:# *}## #}/ ##/:})
+ _docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command')
+ (( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands
+ fi
+ _describe -t docker-commands "docker command" _docker_subcommands
+}
+
+__docker_subcommand() {
+ local -a _command_args opts_help
+ local expl help="--help"
+ integer ret=1
+
+ opts_help=("(: -)--help[Print usage]")
+
+ case "$words[1]" in
+ (attach|commit|cp|create|diff|exec|export|kill|logs|pause|unpause|port|rename|restart|rm|run|start|stats|stop|top|update|wait)
+ __docker_container_subcommand && ret=0
+ ;;
+ (build|history|import|load|pull|push|save|tag)
+ __docker_image_subcommand && ret=0
+ ;;
+ (container)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_container_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_container_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (daemon)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*--add-runtime=[Register an additional OCI compatible runtime]:runtime:__docker_complete_runtimes" \
+ "($help)--api-cors-header=[CORS headers in the Engine API]:CORS headers: " \
+ "($help)*--authorization-plugin=[Authorization plugins to load]" \
+ "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \
+ "($help)--bip=[Network bridge IP]:IP address: " \
+ "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \
+ "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \
+ "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \
+ "($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 -D --debug)"{-D,--debug}"[Enable debug mode]" \
+ "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \
+ "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \
+ "($help)*--default-ulimit=[Default ulimits for containers]:ulimit: " \
+ "($help)--disable-legacy-registry[Disable contacting legacy registries]" \
+ "($help)*--dns=[DNS server to use]:DNS: " \
+ "($help)*--dns-opt=[DNS options to use]:DNS option: " \
+ "($help)*--dns-search=[DNS search domains to use]:DNS search: " \
+ "($help)*--exec-opt=[Runtime execution options]:runtime execution options: " \
+ "($help)--exec-root=[Root directory for execution state files]:path:_directories" \
+ "($help)--experimental[Enable experimental features]" \
+ "($help)--fixed-cidr=[IPv4 subnet for fixed IPs]:IPv4 subnet: " \
+ "($help)--fixed-cidr-v6=[IPv6 subnet for fixed IPs]:IPv6 subnet: " \
+ "($help -G --group)"{-G=,--group=}"[Group for the unix socket]:group:_groups" \
+ "($help -g --graph)"{-g=,--graph=}"[Root of the Docker runtime]:path:_directories" \
+ "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
+ "($help)--icc[Enable inter-container communication]" \
+ "($help)--init-path=[Path to the docker-init binary]:docker-init binary:_files" \
+ "($help)*--insecure-registry=[Enable insecure registry communication]:registry: " \
+ "($help)--ip=[Default IP when binding container ports]" \
+ "($help)--ip-forward[Enable net.ipv4.ip_forward]" \
+ "($help)--ip-masq[Enable IP masquerading]" \
+ "($help)--iptables[Enable addition of iptables rules]" \
+ "($help)--ipv6[Enable IPv6 networking]" \
+ "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
+ "($help)*--label=[Key=value labels]:label: " \
+ "($help)--live-restore[Enable live restore of docker when containers are still running]" \
+ "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" \
+ "($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)--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" \
+ "($help)--raw-logs[Full timestamps without ANSI coloring]" \
+ "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \
+ "($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \
+ "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \
+ "($help)--selinux-enabled[Enable selinux support]" \
+ "($help)--shutdown-timeout=[Set the shutdown timeout value in seconds]:time: " \
+ "($help)*--storage-opt=[Storage driver options]:storage driver options: " \
+ "($help)--tls[Use TLS]" \
+ "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g \"*.(pem|crt)\"" \
+ "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g \"*.(pem|crt)\"" \
+ "($help)--tlskey=[Path to TLS key file]:Key file:_files -g \"*.(pem|key)\"" \
+ "($help)--tlsverify[Use TLS and verify the remote]" \
+ "($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \
+ "($help)--userland-proxy[Use userland proxy for loopback traffic]" \
+ "($help)--userland-proxy-path=[Path to the userland proxy binary]:binary:_files" && ret=0
+
+ case $state in
+ (cluster-store)
+ if compset -P '*://'; then
+ _message 'host:port' && ret=0
+ else
+ store=('consul' 'etcd' 'zk')
+ _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0
+ fi
+ ;;
+ (cluster-store-options)
+ if compset -P '*='; then
+ _files && ret=0
+ else
+ opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path')
+ _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0
+ fi
+ ;;
+ (users-groups)
+ if compset -P '*:'; then
+ _groups && ret=0
+ else
+ _describe -t userns-default "default Docker user management" '(default)' && ret=0
+ _users && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (events|info)
+ __docker_system_subcommand && ret=0
+ ;;
+ (image)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_image_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_image_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (images)
+ words[1]='ls'
+ __docker_image_subcommand && ret=0
+ ;;
+ (inspect)
+ local state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
+ "($help -s --size)"{-s,--size}"[Display total file sizes if the type is container]" \
+ "($help)--type=[Return JSON for specified type]:type:(container image network node plugin service volume)" \
+ "($help -)*: :->values" && ret=0
+
+ case $state in
+ (values)
+ if [[ ${words[(r)--type=container]} == --type=container ]]; then
+ __docker_complete_containers && ret=0
+ elif [[ ${words[(r)--type=image]} == --type=image ]]; then
+ __docker_complete_images && ret=0
+ elif [[ ${words[(r)--type=network]} == --type=network ]]; then
+ __docker_complete_networks && ret=0
+ elif [[ ${words[(r)--type=node]} == --type=node ]]; then
+ __docker_complete_nodes && ret=0
+ elif [[ ${words[(r)--type=plugin]} == --type=plugin ]]; then
+ __docker_complete_plugins && ret=0
+ elif [[ ${words[(r)--type=service]} == --type=service ]]; then
+ __docker_complete_services && ret=0
+ elif [[ ${words[(r)--type=volume]} == --type=volume ]]; then
+ __docker_complete_volumes && ret=0
+ else
+ __docker_complete_containers
+ __docker_complete_images
+ __docker_complete_networks
+ __docker_complete_nodes
+ __docker_complete_plugins
+ __docker_complete_services
+ __docker_complete_volumes && ret=0
+ fi
+ ;;
+ esac
+ ;;
+ (login)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -p --password)"{-p=,--password=}"[Password]:password: " \
+ "($help -u --user)"{-u=,--user=}"[Username]:username: " \
+ "($help -)1:server: " && ret=0
+ ;;
+ (logout)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -)1:server: " && ret=0
+ ;;
+ (network)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_network_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_network_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (node)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_node_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_node_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (plugin)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_plugin_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_plugin_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (ps)
+ words[1]='ls'
+ __docker_container_subcommand && ret=0
+ ;;
+ (rmi)
+ words[1]='rm'
+ __docker_image_subcommand && ret=0
+ ;;
+ (search)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \
+ "($help)--limit=[Maximum returned search results]:limit:(1 5 10 25 50)" \
+ "($help)--no-trunc[Do not truncate output]" \
+ "($help -):term: " && ret=0
+
+ case $state in
+ (filter-options)
+ __docker_complete_search_filters && ret=0
+ ;;
+ esac
+ ;;
+ (secret)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_secret_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_secret_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (service)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_service_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_service_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (stack)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_stack_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_stack_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (swarm)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_swarm_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_swarm_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (system)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_system_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_system_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (version)
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
+ ;;
+ (volume)
+ local curcontext="$curcontext" state
+ _arguments $(__docker_arguments) \
+ $opts_help \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ case $state in
+ (command)
+ __docker_volume_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-${words[-1]}:
+ __docker_volume_subcommand && ret=0
+ ;;
+ esac
+ ;;
+ (help)
+ _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+_docker() {
+ # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`.
+ # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
+ if [[ $service != docker ]]; then
+ _call_function - _$service
+ return
+ fi
+
+ local curcontext="$curcontext" state line help="-h --help"
+ integer ret=1
+ typeset -A opt_args
+
+ _arguments $(__docker_arguments) -C \
+ "(: -)"{-h,--help}"[Print usage]" \
+ "($help)--config[Location of client config files]:path:_directories" \
+ "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
+ "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
+ "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
+ "($help)--tls[Use TLS]" \
+ "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g "*.(pem|crt)"" \
+ "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g "*.(pem|crt)"" \
+ "($help)--tlskey=[Path to TLS key file]:Key file:_files -g "*.(pem|key)"" \
+ "($help)--tlsverify[Use TLS and verify the remote]" \
+ "($help)--userland-proxy[Use userland proxy for loopback traffic]" \
+ "($help -v --version)"{-v,--version}"[Print version information and quit]" \
+ "($help -): :->command" \
+ "($help -)*:: :->option-or-argument" && ret=0
+
+ local host=${opt_args[-H]}${opt_args[--host]}
+ local config=${opt_args[--config]}
+ local docker_options="${host:+--host $host} ${config:+--config $config}"
+
+ case $state in
+ (command)
+ __docker_commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:docker-$words[1]:
+ __docker_subcommand && ret=0
+ ;;
+ esac
+
+ return ret
+}
+
+_dockerd() {
+ integer ret=1
+ words[1]='daemon'
+ __docker_subcommand && ret=0
+ return ret
+}
+
+_docker "$@"
+
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 4
+# indent-tabs-mode: nil
+# sh-basic-offset: 4
+# End:
+# vim: ft=zsh sw=4 ts=4 et
diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md
new file mode 100644
index 000000000..ade09fbb2
--- /dev/null
+++ b/plugins/dotenv/README.md
@@ -0,0 +1,34 @@
+# dotenv
+
+Automatically load your project ENV variables from `.env` file when you `cd` into project root directory.
+
+Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://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`:
+
+```sh
+plugins=(git man dotenv)
+```
+
+## Usage
+
+Create `.env` file inside your project directory and put your local 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
+```
+
+**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 supposed to be local only.
diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
new file mode 100644
index 000000000..9dd784229
--- /dev/null
+++ b/plugins/dotenv/dotenv.plugin.zsh
@@ -0,0 +1,10 @@
+#!/bin/zsh
+
+source_env() {
+ if [[ -f .env ]]; then
+ source .env
+ fi
+}
+
+autoload -U add-zsh-hook
+add-zsh-hook chpwd source_env
diff --git a/plugins/droplr/README.md b/plugins/droplr/README.md
new file mode 100644
index 000000000..25cf61db7
--- /dev/null
+++ b/plugins/droplr/README.md
@@ -0,0 +1,19 @@
+# droplr
+
+Use [Droplr](https://droplr.com/) from the command line to upload files and shorten
+links. It needs to have [Droplr.app](https://droplr.com/apps) installed and logged
+in. MacOS only.
+
+To use it, add `droplr` to the `$plugins` variable in your zshrc file:
+
+```zsh
+plugins=(... droplr)
+```
+
+Author: [Fabio Fernandes](https://github.com/fabiofl)
+
+## Examples
+
+- Upload a file: `droplr ./path/to/file/`
+
+- Shorten a link: `droplr http://example.com`
diff --git a/plugins/droplr/droplr.plugin.zsh b/plugins/droplr/droplr.plugin.zsh
new file mode 100644
index 000000000..af0a21299
--- /dev/null
+++ b/plugins/droplr/droplr.plugin.zsh
@@ -0,0 +1,15 @@
+# Only compatible with MacOS
+[[ "$OSTYPE" == darwin* ]] || return
+
+droplr() {
+ if [[ $# -eq 0 ]]; then
+ echo You need to specify a parameter. >&2
+ return 1
+ fi
+
+ if [[ "$1" =~ ^https?:// ]]; then
+ osascript -e 'tell app "Droplr" to shorten "'"$1"'"'
+ else
+ open -ga /Applications/Droplr.app "$1"
+ fi
+}
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index a3f0085a8..c102a5a1e 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -10,7 +10,7 @@
# - Configuration changes made at runtime are applied to all frames.
-if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
+if "$ZSH/tools/require_tool.sh" emacs 24 2>/dev/null ; then
export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
# set EDITOR if not already defined.
@@ -18,15 +18,14 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
alias e=emacs
+ # open terminal emacsclient
+ alias te="$EMACS_PLUGIN_LAUNCHER -nw"
# same than M-x eval but from outside Emacs.
alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
# create a new X frame
alias eframe='emacsclient --alternate-editor "" --create-frame'
- # to code all night long
- alias emasc=emacs
- alias emcas=emacs
# 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 625201a16..26b28d495 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -1,12 +1,28 @@
#!/bin/sh
-# get list of available X windows.
-x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
+_emacsfun()
+{
+ # get list of emacs frames.
+ frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'`
-if [ -z "$x" ] || [ "$x" = "nil" ] ;then
- # Create one if there is no X window yet.
- emacsclient --alternate-editor "" --create-frame "$@"
+ if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then
+ # prevent creating another X frame if there is at least one present.
+ emacsclient --alternate-editor "" "$@"
+ else
+ # Create one if there is no X window yet.
+ emacsclient --alternate-editor "" --create-frame "$@"
+ fi
+}
+
+
+# adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
+# If the second argument is - then write stdin to a tempfile and open the
+# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
+if [ "$#" -ge "2" -a "$2" = "-" ]
+then
+ tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)"
+ cat - > "$tempfile"
+ _emacsfun --no-wait $tempfile
else
- # prevent creating another X frame if there is at least one present.
- emacsclient --alternate-editor "" "$@"
+ _emacsfun "$@"
fi
diff --git a/plugins/encode64/encode64.plugin.zsh b/plugins/encode64/encode64.plugin.zsh
index 53de6478a..979e06742 100644
--- a/plugins/encode64/encode64.plugin.zsh
+++ b/plugins/encode64/encode64.plugin.zsh
@@ -1,4 +1,17 @@
-encode64(){ printf '%s' $1 | base64 }
-decode64(){ printf '%s' $1 | base64 --decode }
+encode64() {
+ if [[ $# -eq 0 ]]; then
+ cat | base64
+ else
+ printf '%s' $1 | base64
+ fi
+}
+
+decode64() {
+ if [[ $# -eq 0 ]]; then
+ cat | base64 --decode
+ else
+ printf '%s' $1 | base64 --decode
+ fi
+}
alias e64=encode64
alias d64=decode64
diff --git a/plugins/extract/README.md b/plugins/extract/README.md
new file mode 100644
index 000000000..c6bdd36dd
--- /dev/null
+++ b/plugins/extract/README.md
@@ -0,0 +1,46 @@
+# extract plugin
+
+This plugin defines a function called `extract` that extracts the archive file
+you pass it, and it supports a wide variety of archive filetypes.
+
+This way you don't have to know what specific command extracts a file, you just
+do `extract <filename>` and the function takes care of the rest.
+
+To use it, add `extract` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... extract)
+```
+
+## Supported file extensions
+
+| Extension | Description |
+|:------------------|:-------------------------------------|
+| `7z` | 7zip file |
+| `Z` | Z archive (LZW) |
+| `apk` | Android app file |
+| `bz2` | Bzip2 file |
+| `deb` | Debian package |
+| `gz` | Gzip file |
+| `ipsw` | iOS firmware file |
+| `jar` | Java Archive |
+| `lzma` | LZMA archive |
+| `rar` | WinRAR archive |
+| `sublime-package` | Sublime Text package |
+| `tar` | Tarball |
+| `tar.bz2` | Tarball with bzip2 compression |
+| `tar.gz` | Tarball with gzip compression |
+| `tar.xz` | Tarball with lzma2 compression |
+| `tar.zma` | Tarball with lzma 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 |
+| `war` | Web Application archive (Java-based) |
+| `xpi` | Mozilla XPI module file |
+| `xz` | LZMA2 archive |
+| `zip` | Zip archive |
+
+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 387b344bc..172425d2c 100644
--- a/plugins/extract/_extract
+++ b/plugins/extract/_extract
@@ -3,6 +3,5 @@
_arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
- "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0
-
-
+ "*::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|xpi|xz|zip)(-.)'" \
+ && return 0
diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
index 5d0809e9a..c524bf8f5 100644
--- a/plugins/extract/extract.plugin.zsh
+++ b/plugins/extract/extract.plugin.zsh
@@ -1,80 +1,71 @@
-# ------------------------------------------------------------------------------
-# FILE: extract.plugin.zsh
-# DESCRIPTION: oh-my-zsh plugin file.
-# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
-# VERSION: 1.0.1
-# ------------------------------------------------------------------------------
+alias x=extract
+extract() {
+ local remove_archive
+ local success
+ local extract_dir
-function extract() {
- local remove_archive
- local success
- local file_name
- local extract_dir
+ if (( $# == 0 )); then
+ cat <<-'EOF' >&2
+ Usage: extract [-option] [file ...]
- if (( $# == 0 )); then
- echo "Usage: extract [-option] [file ...]"
- echo
- echo Options:
- echo " -r, --remove Remove archive."
- echo
- echo "Report bugs to <sorin.ionescu@gmail.com>."
- fi
+ Options:
+ -r, --remove Remove archive.
+ EOF
+ fi
- remove_archive=1
- if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
- remove_archive=0
- shift
- fi
+ remove_archive=1
+ if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
+ remove_archive=0
+ shift
+ fi
- while (( $# > 0 )); do
- if [[ ! -f "$1" ]]; then
- echo "extract: '$1' is not a valid file" 1>&2
- shift
- continue
- fi
+ while (( $# > 0 )); do
+ if [[ ! -f "$1" ]]; then
+ echo "extract: '$1' is not a valid file" >&2
+ shift
+ continue
+ fi
- success=0
- file_name="$( basename "$1" )"
- extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
- case "$1" in
- (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;;
- (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
- (*.tar.xz|*.txz) tar --xz --help &> /dev/null \
- && tar --xz -xvf "$1" \
- || xzcat "$1" | tar xvf - ;;
- (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
- && tar --lzma -xvf "$1" \
- || lzcat "$1" | tar xvf - ;;
- (*.tar) tar xvf "$1" ;;
- (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;;
- (*.bz2) bunzip2 "$1" ;;
- (*.xz) unxz "$1" ;;
- (*.lzma) unlzma "$1" ;;
- (*.Z) uncompress "$1" ;;
- (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
- (*.rar) unrar x -ad "$1" ;;
- (*.7z) 7za x "$1" ;;
- (*.deb)
- mkdir -p "$extract_dir/control"
- mkdir -p "$extract_dir/data"
- cd "$extract_dir"; ar vx "../${1}" > /dev/null
- cd control; tar xzvf ../control.tar.gz
- cd ../data; tar xzvf ../data.tar.gz
- cd ..; rm *.tar.gz debian-binary
- cd ..
- ;;
- (*)
- echo "extract: '$1' cannot be extracted" 1>&2
- success=1
- ;;
- esac
+ success=0
+ extract_dir="${1:t:r}"
+ case "$1" in
+ (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
+ (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
+ (*.tar.xz|*.txz)
+ tar --xz --help &> /dev/null \
+ && tar --xz -xvf "$1" \
+ || xzcat "$1" | tar xvf - ;;
+ (*.tar.zma|*.tlz)
+ tar --lzma --help &> /dev/null \
+ && tar --lzma -xvf "$1" \
+ || lzcat "$1" | tar xvf - ;;
+ (*.tar) tar xvf "$1" ;;
+ (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;;
+ (*.bz2) bunzip2 "$1" ;;
+ (*.xz) unxz "$1" ;;
+ (*.lzma) unlzma "$1" ;;
+ (*.Z) uncompress "$1" ;;
+ (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
+ (*.rar) unrar x -ad "$1" ;;
+ (*.7z) 7za x "$1" ;;
+ (*.deb)
+ mkdir -p "$extract_dir/control"
+ mkdir -p "$extract_dir/data"
+ cd "$extract_dir"; ar vx "../${1}" > /dev/null
+ cd control; tar xzvf ../control.tar.gz
+ cd ../data; extract ../data.tar.*
+ cd ..; rm *.tar.* debian-binary
+ cd ..
+ ;;
+ (*)
+ echo "extract: '$1' cannot be extracted" >&2
+ success=1
+ ;;
+ esac
- (( success = $success > 0 ? $success : $? ))
- (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
- shift
- done
+ (( success = $success > 0 ? $success : $? ))
+ (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
+ shift
+ done
}
-
-alias x=extract
-
diff --git a/plugins/fasd/fasd.plugin.zsh b/plugins/fasd/fasd.plugin.zsh
index b11f0b511..2c302f74d 100644
--- a/plugins/fasd/fasd.plugin.zsh
+++ b/plugins/fasd/fasd.plugin.zsh
@@ -6,6 +6,6 @@ if [ $commands[fasd] ]; then # check if fasd is installed
source "$fasd_cache"
unset fasd_cache
- alias v='f -e vim'
+ alias v="f -e $EDITOR"
alias o='a -e open_command'
fi
diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh
new file mode 100644
index 000000000..bfbf6f48f
--- /dev/null
+++ b/plugins/firewalld/firewalld.plugin.zsh
@@ -0,0 +1,17 @@
+alias fw="sudo firewall-cmd"
+alias fwp="sudo firewall-cmd --permanent"
+alias fwr="sudo firewall-cmd --reload"
+alias fwrp="sudo firewall-cmd --runtime-to-permanent"
+
+function fwl () {
+ # converts output to zsh array ()
+ # @f flag split on new line
+ zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v interfaces)}")
+
+ for i in $zones; do
+ sudo firewall-cmd --zone $i --list-all
+ done
+
+ echo 'Direct Rules:'
+ sudo firewall-cmd --direct --get-all-rules
+}
diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md
new file mode 100644
index 000000000..8b5bc74d4
--- /dev/null
+++ b/plugins/firewalld/readme.md
@@ -0,0 +1,22 @@
+# FirewallD Plugin
+
+This plugin adds some aliases and functions for FirewallD using the `firewalld-cmd` command. To use it, add firewalld to your plugins array.
+
+```zsh
+plugins=(... firewalld)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+| :---- | :----------------------------------------- | :--------------------------- |
+| fw | `sudo firewall-cmd` | Shorthand |
+| fwr | `sudo firewall-cmd --reload` | Reload current configuration |
+| fwp | `sudo firewall-cmd --permanent` | Create permanent rule |
+| fwrp | `sudo firewall-cmd --runtime-to-permanent` | Save current configuration |
+
+## Functions
+
+| Function | Description |
+| :------- | :--------------------------------------------------------- |
+| fwl | Lists configuration from all active zones and direct rules |
diff --git a/plugins/forklift/README.md b/plugins/forklift/README.md
index b452a357c..6c5cbab23 100644
--- a/plugins/forklift/README.md
+++ b/plugins/forklift/README.md
@@ -4,10 +4,12 @@ Plugin for ForkLift, an FTP application for OS X.
### Requirements
-* [ForkLift](http://forkliftapp.com/forklift/)
+* [ForkLift](http://www.binarynights.com/forklift/)
### Usage
-* If `fl` is called without arguments then the current folder is opened in ForkLift. Is equivalent to `fl .`
+<code>fl [*file_or_folder*]</code>
-* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift \ No newline at end of file
+* 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.
diff --git a/plugins/fossil/README.md b/plugins/fossil/README.md
new file mode 100644
index 000000000..5bb47b7d5
--- /dev/null
+++ b/plugins/fossil/README.md
@@ -0,0 +1,7 @@
+## Fossil Plugin
+
+This plugin adds completion support and prompt for fossil repositories.
+The prompt will display the current branch and status been dirty or clean.
+
+### CONTRIBUTOR
+ - Jefferson González ([jgmdev](https://github.com/jgmdev))
diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh
new file mode 100644
index 000000000..1ae166e62
--- /dev/null
+++ b/plugins/fossil/fossil.plugin.zsh
@@ -0,0 +1,89 @@
+_FOSSIL_PROMPT=""
+
+# Prefix at the very beginning of the prompt, before the branch name
+ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
+
+# At the very end of the prompt
+ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
+
+# Text to display if the branch is dirty
+ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
+
+# Text to display if the branch is clean
+ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
+
+function fossil_prompt_info () {
+ local _OUTPUT=`fossil branch 2>&1`
+ local _STATUS=`echo $_OUTPUT | grep "use --repo"`
+ if [ "$_STATUS" = "" ]; then
+ local _EDITED=`fossil changes`
+ local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
+ local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'`
+
+ if [ "$_EDITED" != "" ]; then
+ _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
+ fi
+
+ echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
+ "$_BRANCH" \
+ "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
+ "$_EDITED_SYM"\
+ "%{$reset_color%}"
+ fi
+}
+
+function _fossil_get_command_list () {
+ fossil help -a | grep -v "Usage|Common|This is"
+}
+
+function _fossil () {
+ local context state state_descr line
+ typeset -A opt_args
+
+ _arguments \
+ '1: :->command'\
+ '2: :->subcommand'
+
+ case $state in
+ command)
+ local _OUTPUT=`fossil branch 2>&1 | grep "use --repo"`
+ if [ "$_OUTPUT" = "" ]; then
+ compadd `_fossil_get_command_list`
+ else
+ compadd clone init import help version
+ fi
+ ;;
+ subcommand)
+ if [ "$words[2]" = "help" ]; then
+ compadd `_fossil_get_command_list`
+ else
+ compcall -D
+ fi
+ ;;
+ esac
+}
+
+function _fossil_prompt () {
+ local current=`echo $PROMPT $RPROMPT | grep fossil`
+
+ if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then
+ local _prompt=${PROMPT}
+ local _rprompt=${RPROMPT}
+
+ local is_prompt=`echo $PROMPT | grep git`
+
+ if [ "$is_prompt" = "" ]; then
+ export RPROMPT="$_rprompt"'$(fossil_prompt_info)'
+ else
+ export PROMPT="$_prompt"'$(fossil_prompt_info) '
+ fi
+
+ _FOSSIL_PROMPT="1"
+ fi
+}
+
+compdef _fossil fossil
+
+autoload -U add-zsh-hook
+
+add-zsh-hook precmd _fossil_prompt
diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
index d0bc5589f..4d956e38f 100644
--- a/plugins/frontend-search/README.md
+++ b/plugins/frontend-search/README.md
@@ -38,7 +38,7 @@ Available search contexts are:
| bootsnipp | `http://bootsnipp.com/search?q=` |
| caniuse | `http://caniuse.com/#search=` |
| codepen | `http://codepen.io/search?q=` |
-| compass | `http://compass-style.org/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 | `http://emberjs.com/api/#stp=1&stq=` |
diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh
index b12f829a1..9aad76f76 100644
--- a/plugins/frontend-search/_frontend-search.sh
+++ b/plugins/frontend-search/_frontend-search.sh
@@ -19,7 +19,7 @@ function _frontend() {
commands=(
'jquery: Search in jQuery website'
'mdn: Search in MDN website'
- 'compass: Search in COMPASS website'
+ 'compassdoc: Search in COMPASS website'
'html5please: Search in HTML5 Please website'
'caniuse: Search in Can I Use website'
'aurajs: Search in AuraJs website'
@@ -57,7 +57,7 @@ function _frontend() {
mdn)
_describe -t points "Warp points" frontend_points && ret=0
;;
- compass)
+ compassdoc)
_describe -t points "Warp points" frontend_points && ret=0
;;
html5please)
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index 2fd5416b3..3fd49ab8e 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -4,7 +4,7 @@ alias bem='frontend bem'
alias bootsnipp='frontend bootsnipp'
alias caniuse='frontend caniuse'
alias codepen='frontend codepen'
-alias compass='frontend compass'
+alias compassdoc='frontend compassdoc'
alias cssflow='frontend cssflow'
alias dartlang='frontend dartlang'
alias emberjs='frontend emberjs'
@@ -32,7 +32,7 @@ function frontend() {
bootsnipp 'http://bootsnipp.com/search?q='
caniuse 'http://caniuse.com/#search='
codepen 'http://codepen.io/search?q='
- compass 'http://compass-style.org/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 'http://emberjs.com/api/#stp=1&stq='
@@ -57,7 +57,7 @@ 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, compass, cssflow,"
+ 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 ""
@@ -73,7 +73,7 @@ function frontend() {
echo ""
echo "Valid contexts are:"
echo ""
- echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, "
+ 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 ""
diff --git a/plugins/gb/README.md b/plugins/gb/README.md
new file mode 100644
index 000000000..822c29aaa
--- /dev/null
+++ b/plugins/gb/README.md
@@ -0,0 +1,21 @@
+# `gb` plugin
+
+> A project based build tool for the Go programming language.
+
+See https://getgb.io for the full `gb` documentation
+
+* * * *
+
+- Adds completion support for all `gb` commands.
+- Also supports completion for the [`gb-vendor` plugin](https://godoc.org/github.com/constabulary/gb/cmd/gb-vendor).
+
+To use it, add `gb` to your plugins array:
+```sh
+plugins=(... gb)
+```
+
+## Caveats
+
+The `git` plugin defines an alias `gb` that usually conflicts with the `gb` program.
+If you're having trouble with it, remove it by adding `unalias gb` at the end of your
+zshrc file.
diff --git a/plugins/gb/_gb b/plugins/gb/_gb
new file mode 100644
index 000000000..8148adf16
--- /dev/null
+++ b/plugins/gb/_gb
@@ -0,0 +1,111 @@
+#compdef gb
+#autoload
+
+_gb () {
+ local ret=1 state
+ _arguments -C ':command:->command' '*::options:->options' && ret=0
+
+ case $state in
+ (command)
+ local -a subcommands
+ subcommands=(
+ "build:build a package"
+ "doc:show documentation for a package or symbol"
+ "env:print project environment variables"
+ "generate:generate Go files by processing source"
+ "help:displays the help"
+ "info:info returns information about this project"
+ "list:list the packages named by the importpaths"
+ "test:test packages"
+ "vendor:manage your vendored dependencies"
+ )
+ _describe -t subcommands 'gb subcommands' subcommands && ret=0
+ ;;
+ (options)
+ case $line[1] in
+ (build)
+ _arguments \
+ -f'[ignore cached packages]' \
+ -F'[do not cache packages]' \
+ -q'[decreases verbosity]' \
+ -P'[the number of build jobs to run in parallel]' \
+ -R'[sets the base of the project root search path]' \
+ -dotfile'[output a dot formatted file of the build steps]' \
+ -ldflags'["flag list" arguments to pass to the linker]' \
+ -gcflags'["arg list" arguments to pass to the compiler]' \
+ -race'[enable data race detection]' \
+ -tags'["tag list" additional build tags]'
+ ;;
+ (list)
+ _arguments \
+ -f'[alternate format for the list, using the syntax of package template]' \
+ -s'[read format template from STDIN]' \
+ -json'[prints output in structured JSON format]'
+ ;;
+ (test)
+ _arguments \
+ -v'[print output from test subprocess]' \
+ -ldflags'["flag list" arguments to pass to the linker]' \
+ -gcflags'["arg list" arguments to pass to the compiler]' \
+ -race'[enable data race detection]' \
+ -tags'["tag list" additional build tags]'
+ ;;
+ (vendor)
+ _gb-vendor
+ esac
+ ;;
+ esac
+
+ return ret
+}
+
+_gb-vendor () {
+ local curcontext="$curcontext" state line
+ _arguments -C ':command:->command' '*::options:->options'
+
+ case $state in
+ (command)
+ local -a subcommands
+ subcommands=(
+ 'delete:deletes a local dependency'
+ 'fetch:fetch a remote dependency'
+ 'list:lists dependencies, one per line'
+ 'purge:remove all unreferenced dependencies'
+ 'restore:restore dependencies from the manifest'
+ 'update:update a local dependency'
+ )
+ _describe -t subcommands 'gb vendor subcommands' subcommands && ret=0
+ ;;
+ (options)
+ case $line[1] in
+ (delete)
+ _arguments \
+ -all'[remove all dependencies]'
+ ;;
+ (fetch)
+ _arguments \
+ -branch'[fetch from a particular branch]' \
+ -no-recurse'[do not fetch recursively]' \
+ -tag'[fetch the specified tag]' \
+ -revision'[fetch the specific revision from the branch (if supplied)]' \
+ -precaire'[allow the use of insecure protocols]' \
+ ;;
+ (list)
+ _arguments \
+ -f'[controls the template used for printing each manifest entry]'
+ ;;
+ (restore)
+ _arguments \
+ -precaire'[allow the use of insecure protocols]'
+ ;;
+ (update)
+ _arguments \
+ -all'[update all dependencies in the manifest or supply a given dependency]' \
+ -precaire'[allow the use of insecure protocols]'
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_gb
diff --git a/plugins/geeknote/README.md b/plugins/geeknote/README.md
new file mode 100644
index 000000000..a6b50e27f
--- /dev/null
+++ b/plugins/geeknote/README.md
@@ -0,0 +1,12 @@
+## ZSH-Geeknote
+
+[Geeknote](https://github.com/VitaliyRodnenko/geeknote) plugin for [oh-my-zsh framework](http://github.com/robbyrussell/oh-my-zsh).
+
+Plugins provides:
+
+- 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))
diff --git a/plugins/geeknote/_geeknote b/plugins/geeknote/_geeknote
new file mode 100644
index 000000000..cf1a187d2
--- /dev/null
+++ b/plugins/geeknote/_geeknote
@@ -0,0 +1,136 @@
+#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.
+# --------------- ------------------------------------------------------------
+
+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'
+)
+
+_arguments '*:: :->command'
+
+if (( CURRENT == 1 )); then
+ _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
diff --git a/plugins/geeknote/geeknote.plugin.zsh b/plugins/geeknote/geeknote.plugin.zsh
new file mode 100644
index 000000000..8126d26b3
--- /dev/null
+++ b/plugins/geeknote/geeknote.plugin.zsh
@@ -0,0 +1,2 @@
+#Alias
+alias gn='geeknote'
diff --git a/plugins/git-flow/README.md b/plugins/git-flow/README.md
new file mode 100644
index 000000000..f37f418db
--- /dev/null
+++ b/plugins/git-flow/README.md
@@ -0,0 +1,31 @@
+# Git-Flow plugin
+
+This plugin adds completion and aliases for the `git-flow` command. More information
+at https://github.com/nvie/gitflow.
+
+Enable git-flow plugin in your zshrc file:
+```
+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 |
+| `gfli` | `git flow init` | Initialize git-flow repository |
+| `gcd` | `git checkout develop` | Check out develop branch |
+| `gch` | `git checkout hotfix` | Check out hotfix branch |
+| `gcr` | `git checkout release` | Check out release branch |
+| `gflf` | `git flow feature` | List existing feature branches |
+| `gflh` | `git flow hotfix` | List existing hotfix branches |
+| `gflr` | `git flow release` | List existing release branches |
+| `gflfs` | `git flow feature start` | Start a new feature: `gflfs <name>` |
+| `gflhs` | `git flow hotfix start` | Start a new hotfix: `gflhs <version>` |
+| `gflrs` | `git flow release start` | Start a new release: `gflrs <version>` |
+| `gflff` | `git flow feature finish` | Finish feature: `gflff <name>` |
+| `gflhf` | `git flow hotfix finish` | Finish hotfix: `gflhf <version>` |
+| `gflrf` | `git flow release finish` | Finish release: `gflrf <version>` |
diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh
index a8386cb19..bda050725 100644
--- a/plugins/git-flow/git-flow.plugin.zsh
+++ b/plugins/git-flow/git-flow.plugin.zsh
@@ -22,9 +22,19 @@
#Alias
alias gfl='git flow'
+alias gfli='git flow init'
alias gcd='git checkout develop'
alias gch='git checkout hotfix'
alias gcr='git checkout release'
+alias gflf='git flow feature'
+alias gflh='git flow hotfix'
+alias gflr='git flow release'
+alias gflfs='git flow feature start'
+alias gflhs='git flow hotfix start'
+alias gflrs='git flow release start'
+alias gflff='git flow feature finish'
+alias gflhf='git flow hotfix finish'
+alias gflrf='git flow release finish'
_git-flow ()
{
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index b851fb97d..34942d387 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -43,10 +43,12 @@ alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
+alias gau='git add --update'
alias gb='git branch'
alias gba='git branch -a'
-alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d'
+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 gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
@@ -58,103 +60,124 @@ alias gbss='git bisect start'
alias gc='git commit -v'
alias gc!='git commit -v --amend'
+alias gcn!='git commit -v --no-edit --amend'
alias gca='git commit -v -a'
alias gca!='git commit -v -a --amend'
-alias gcan!='git commit -v -a -s --no-edit --amend'
+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 gcb='git checkout -b'
alias gcf='git config --list'
alias gcl='git clone --recursive'
alias gclean='git clean -fd'
alias gpristine='git reset --hard && git clean -dfx'
alias gcm='git checkout master'
+alias gcd='git checkout develop'
alias gcmsg='git commit -m'
alias gco='git checkout'
alias gcount='git shortlog -sn'
-compdef gcount=git
+compdef _git gcount
alias gcp='git cherry-pick'
+alias gcpa='git cherry-pick --abort'
+alias gcpc='git cherry-pick --continue'
alias gcs='git commit -S'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
alias gdt='git diff-tree --no-commit-id --name-only -r'
+alias gdw='git diff --word-diff'
+
gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
-alias gdw='git diff --word-diff'
alias gf='git fetch'
alias gfa='git fetch --all --prune'
-function gfg() { git ls-files | grep $@ }
-compdef gfg=grep
alias gfo='git fetch origin'
+function gfg() { git ls-files | grep $@ }
+compdef _grep gfg
+
alias gg='git gui citool'
alias gga='git gui citool --amend'
+
ggf() {
-[[ "$#" != 1 ]] && local b="$(git_current_branch)"
-git push --force origin "${b:=$1}"
+ [[ "$#" != 1 ]] && local b="$(git_current_branch)"
+ git push --force origin "${b:=$1}"
}
compdef _git ggf=git-checkout
+
ggl() {
-if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
-git pull origin "${*}"
-else
-[[ "$#" == 0 ]] && local b="$(git_current_branch)"
-git pull origin "${b:=$1}"
-fi
+ if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
+ git pull origin "${*}"
+ else
+ [[ "$#" == 0 ]] && local b="$(git_current_branch)"
+ git pull origin "${b:=$1}"
+ fi
}
compdef _git ggl=git-checkout
-alias ggpull='git pull origin $(git_current_branch)'
-compdef _git ggpull=git-checkout
+
ggp() {
-if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
-git push origin "${*}"
-else
-[[ "$#" == 0 ]] && local b="$(git_current_branch)"
-git push origin "${b:=$1}"
-fi
+ if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
+ git push origin "${*}"
+ else
+ [[ "$#" == 0 ]] && local b="$(git_current_branch)"
+ git push origin "${b:=$1}"
+ fi
}
compdef _git ggp=git-checkout
-alias ggpush='git push origin $(git_current_branch)'
-compdef _git ggpush=git-checkout
+
ggpnp() {
-if [[ "$#" == 0 ]]; then
-ggl && ggp
-else
-ggl "${*}" && ggp "${*}"
-fi
+ if [[ "$#" == 0 ]]; then
+ ggl && ggp
+ else
+ ggl "${*}" && ggp "${*}"
+ fi
}
compdef _git ggpnp=git-checkout
-alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
+
ggu() {
-[[ "$#" != 1 ]] && local b="$(git_current_branch)"
-git pull --rebase origin "${b:=$1}"
+ [[ "$#" != 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 ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
+alias gpsup='git push --set-upstream origin $(git_current_branch)'
+
+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-svn-dcommit-push=git
+compdef _git git-svn-dcommit-push=git
alias gk='\gitk --all --branches'
compdef _git gk='gitk'
-alias gke='\gitk --all $(git log -g --pretty=format:%h)'
+alias gke='\gitk --all $(git log -g --pretty=%h)'
compdef _git gke='gitk'
alias gl='git pull'
-alias glg='git log --stat --color'
-alias glgp='git log --stat --color -p'
-alias glgg='git log --graph --color'
+alias glg='git log --stat'
+alias glgp='git log --stat -p'
+alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
-alias glo='git log --oneline --decorate --color'
-alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
-alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
-alias glog='git log --oneline --decorate --color --graph'
+alias glo='git log --oneline --decorate'
+alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
+alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
+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
@@ -196,8 +219,9 @@ 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'
+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'
@@ -213,7 +237,5 @@ alias gup='git pull --rebase'
alias gupv='git pull --rebase -v'
alias glum='git pull upstream master'
-alias gvt='git verify-tag'
-
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 -m "--wip--"'
+alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip-- [skip ci]"'
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
index c75b0be7f..6d1b4ecc7 100644
--- a/plugins/gitfast/_git
+++ b/plugins/gitfast/_git
@@ -104,6 +104,7 @@ __git_zsh_bash_func ()
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
fi
@@ -213,8 +214,10 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main
- else
+ elif (( $+functions[__${service}_main] )); then
emulate ksh -c __${service}_main
+ elif (( $+functions[_${service}] )); then
+ emulate ksh -c _${service}
fi
let _ret && _default && _ret=0
diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
index 9525343fc..8ce6b5c5f 100644
--- a/plugins/gitfast/git-completion.bash
+++ b/plugins/gitfast/git-completion.bash
@@ -10,17 +10,24 @@
# *) local and remote tag names
# *) .git/remotes file names
# *) git 'subcommands'
+# *) git email aliases for git-send-email
# *) tree paths within 'ref:path/to/file' expressions
# *) file paths within current working directory and index
# *) common --long-options
#
# To use these routines:
#
-# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
+# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
# 2) Add the following line to your .bashrc/.zshrc:
-# source ~/.git-completion.sh
+# source ~/.git-completion.bash
# 3) Consider changing your PS1 to also show the current branch,
# see git-prompt.sh for details.
+#
+# If you use complex aliases of form '!f() { ... }; f', you can use the null
+# command ':' as the first command in the function body to declare the desired
+# 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 ; ... '".
case "$COMP_WORDBREAKS" in
*:*) : great ;;
@@ -180,7 +187,7 @@ fi
__gitcompappend ()
{
- local i=${#COMPREPLY[@]}
+ local x i=${#COMPREPLY[@]}
for x in $1; do
if [[ "$x" == "$3"* ]]; then
COMPREPLY[i++]="$2$x$4"
@@ -275,16 +282,12 @@ __gitcomp_file ()
# argument, and using the options specified in the second argument.
__git_ls_files_helper ()
{
- (
- test -n "${CDPATH+set}" && unset CDPATH
- cd "$1"
- if [ "$2" == "--committable" ]; then
- git diff-index --name-only --relative HEAD
- else
- # NOTE: $2 is not quoted in order to support multiple options
- git ls-files --exclude-standard $2
- fi
- ) 2>/dev/null
+ if [ "$2" == "--committable" ]; then
+ git -C "$1" diff-index --name-only --relative HEAD
+ else
+ # NOTE: $2 is not quoted in order to support multiple options
+ git -C "$1" ls-files --exclude-standard $2
+ fi 2>/dev/null
}
@@ -382,7 +385,8 @@ __git_refs ()
;;
*)
echo "HEAD"
- git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
+ git for-each-ref --format="%(refname:short)" -- \
+ "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
;;
esac
}
@@ -408,12 +412,9 @@ __git_refs_remotes ()
__git_remotes ()
{
- local i IFS=$'\n' d="$(__gitdir)"
+ local d="$(__gitdir)"
test -d "$d/remotes" && ls -1 "$d/remotes"
- for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
- i="${i#remote.}"
- echo "${i/.url*/}"
- done
+ git --git-dir="$d" remote
}
__git_list_merge_strategies ()
@@ -516,7 +517,7 @@ __git_complete_index_file ()
;;
esac
- __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
+ __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
}
__git_complete_file ()
@@ -663,10 +664,11 @@ __git_list_porcelain_commands ()
check-mailmap) : plumbing;;
check-ref-format) : plumbing;;
checkout-index) : plumbing;;
+ column) : internal helper;;
commit-tree) : plumbing;;
count-objects) : infrequent;;
- credential-cache) : credentials helper;;
- credential-store) : credentials helper;;
+ credential) : credentials;;
+ credential-*) : credentials helper;;
cvsexportcommit) : export;;
cvsimport) : import;;
cvsserver) : daemon;;
@@ -735,35 +737,28 @@ __git_list_porcelain_commands ()
__git_porcelain_commands=
__git_compute_porcelain_commands ()
{
- __git_compute_all_commands
test -n "$__git_porcelain_commands" ||
__git_porcelain_commands=$(__git_list_porcelain_commands)
}
-__git_pretty_aliases ()
+# Lists all set config variables starting with the given section prefix,
+# with the prefix removed.
+__git_get_config_variables ()
{
- local i IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
- case "$i" in
- pretty.*)
- i="${i#pretty.}"
- echo "${i/ */}"
- ;;
- esac
+ local section="$1" i IFS=$'\n'
+ for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do
+ echo "${i#$section.}"
done
}
+__git_pretty_aliases ()
+{
+ __git_get_config_variables "pretty"
+}
+
__git_aliases ()
{
- local i IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
- case "$i" in
- alias.*)
- i="${i#alias.}"
- echo "${i/ */}"
- ;;
- esac
- done
+ __git_get_config_variables "alias"
}
# __git_aliased_command requires 1 argument
@@ -781,6 +776,10 @@ __git_aliased_command ()
-*) : 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"
return
@@ -973,7 +972,7 @@ _git_branch ()
case "$cur" in
--set-upstream-to=*)
- __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
+ __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}"
;;
--*)
__gitcomp "
@@ -1041,7 +1040,7 @@ _git_checkout ()
_git_cherry ()
{
- __gitcomp "$(__git_refs)"
+ __gitcomp_nl "$(__git_refs)"
}
_git_cherry_pick ()
@@ -1110,7 +1109,7 @@ _git_commit ()
case "$cur" in
--cleanup=*)
- __gitcomp "default strip verbatim whitespace
+ __gitcomp "default scissors strip verbatim whitespace
" "" "${cur##--cleanup=}"
return
;;
@@ -1165,12 +1164,12 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--full-index --binary --abbrev --diff-filter=
--find-copies-harder
--text --ignore-space-at-eol --ignore-space-change
- --ignore-all-space --exit-code --quiet --ext-diff
- --no-ext-diff
+ --ignore-all-space --ignore-blank-lines --exit-code
+ --quiet --ext-diff --no-ext-diff
--no-prefix --src-prefix= --dst-prefix=
--inter-hunk-context=
--patience --histogram --minimal
- --raw --word-diff
+ --raw --word-diff --word-diff-regex=
--dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative
--diff-algorithm=
@@ -1197,7 +1196,7 @@ _git_diff ()
}
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
- tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
+ tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
"
_git_difftool ()
@@ -1221,14 +1220,20 @@ _git_difftool ()
__git_complete_revlist_file
}
+__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
+ --tags --no-tags --all --prune --dry-run --recurse-submodules=
"
_git_fetch ()
{
case "$cur" in
+ --recurse-submodules=*)
+ __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
+ return
+ ;;
--*)
__gitcomp "$__git_fetch_options"
return
@@ -1292,7 +1297,7 @@ _git_gitk ()
}
__git_match_ctag() {
- awk "/^${1////\\/}/ { print \$1 }" "$2"
+ awk "/^${1//\//\\/}/ { print \$1 }" "$2"
}
_git_grep ()
@@ -1307,6 +1312,7 @@ _git_grep ()
--full-name --line-number
--extended-regexp --basic-regexp --fixed-strings
--perl-regexp
+ --threads
--files-with-matches --name-only
--files-without-match
--max-depth
@@ -1412,7 +1418,7 @@ __git_log_gitk_options="
# Options that go well for log and shortlog (not gitk)
__git_log_shortlog_options="
--author= --committer= --grep=
- --all-match
+ --all-match --invert-grep
"
__git_log_pretty_formats="oneline short medium full fuller email raw format:"
@@ -1438,7 +1444,7 @@ _git_log ()
return
;;
--decorate=*)
- __gitcomp "long short" "" "${cur##--decorate=}"
+ __gitcomp "full short no" "" "${cur##--decorate=}"
return
;;
--*)
@@ -1451,6 +1457,7 @@ _git_log ()
--abbrev-commit --abbrev=
--relative-date --date=
--pretty= --format= --oneline
+ --show-signature
--cherry-pick
--graph
--decorate --decorate=
@@ -1466,9 +1473,12 @@ _git_log ()
__git_complete_revlist
}
+# Common merge options shared by git-merge(1) and git-pull(1).
__git_merge_options="
--no-commit --no-stat --log --no-log --squash --strategy
--commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
+ --verify-signatures --no-verify-signatures --gpg-sign
+ --quiet --verbose --progress --no-progress
"
_git_merge ()
@@ -1477,7 +1487,8 @@ _git_merge ()
case "$cur" in
--*)
- __gitcomp "$__git_merge_options"
+ __gitcomp "$__git_merge_options
+ --rerere-autoupdate --no-rerere-autoupdate --abort"
return
esac
__gitcomp_nl "$(__git_refs)"
@@ -1583,6 +1594,10 @@ _git_pull ()
__git_complete_strategy && return
case "$cur" in
+ --recurse-submodules=*)
+ __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
+ return
+ ;;
--*)
__gitcomp "
--rebase --no-rebase
@@ -1595,22 +1610,55 @@ _git_pull ()
__git_complete_remote_or_refspec
}
+__git_push_recurse_submodules="check on-demand"
+
+__git_complete_force_with_lease ()
+{
+ local cur_=$1
+
+ case "$cur_" in
+ --*=)
+ ;;
+ *:*)
+ __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}"
+ ;;
+ *)
+ __gitcomp_nl "$(__git_refs)" "" "$cur_"
+ ;;
+ esac
+}
+
_git_push ()
{
case "$prev" in
--repo)
__gitcomp_nl "$(__git_remotes)"
return
+ ;;
+ --recurse-submodules)
+ __gitcomp "$__git_push_recurse_submodules"
+ return
+ ;;
esac
case "$cur" in
--repo=*)
__gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
return
;;
+ --recurse-submodules=*)
+ __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
+ return
+ ;;
+ --force-with-lease=*)
+ __git_complete_force_with_lease "${cur##--force-with-lease=}"
+ return
+ ;;
--*)
__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=
"
return
;;
@@ -1621,7 +1669,10 @@ _git_push ()
_git_rebase ()
{
local dir="$(__gitdir)"
- if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
+ if [ -f "$dir"/rebase-merge/interactive ]; then
+ __gitcomp "--continue --skip --abort --edit-todo"
+ return
+ elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
__gitcomp "--continue --skip --abort"
return
fi
@@ -1637,7 +1688,12 @@ _git_rebase ()
--preserve-merges --stat --no-stat
--committer-date-is-author-date --ignore-date
--ignore-whitespace --whitespace=
- --autosquash --fork-point --no-fork-point
+ --autosquash --no-autosquash
+ --fork-point --no-fork-point
+ --autostash --no-autostash
+ --verify --no-verify
+ --keep-empty --root --force-rebase --no-ff
+ --exec
"
return
@@ -1662,6 +1718,15 @@ __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
_git_send_email ()
{
+ case "$prev" in
+ --to|--cc|--bcc|--from)
+ __gitcomp "
+ $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
+ "
+ return
+ ;;
+ esac
+
case "$cur" in
--confirm=*)
__gitcomp "
@@ -1686,6 +1751,12 @@ _git_send_email ()
" "" "${cur##--thread=}"
return
;;
+ --to=*|--cc=*|--bcc=*|--from=*)
+ __gitcomp "
+ $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
+ " "" "${cur#--*=}"
+ return
+ ;;
--*)
__gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
--compose --confirm= --dry-run --envelope-sender
@@ -1727,15 +1798,7 @@ __git_config_get_set_variables ()
c=$((--c))
done
- git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
- while read -r line
- do
- case "$line" in
- *.*=*)
- echo "${line/=*/}"
- ;;
- esac
- done
+ git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null
}
_git_config ()
@@ -1750,7 +1813,7 @@ _git_config ()
return
;;
branch.*.rebase)
- __gitcomp "false true"
+ __gitcomp "false true preserve interactive"
return
;;
remote.pushdefault)
@@ -1820,6 +1883,10 @@ _git_config ()
__gitcomp "$__git_send_email_suppresscc_options"
return
;;
+ sendemail.transferencoding)
+ __gitcomp "7bit 8bit quoted-printable base64"
+ return
+ ;;
--get|--get-all|--unset|--unset-all)
__gitcomp_nl "$(__git_config_get_set_variables)"
return
@@ -1836,6 +1903,7 @@ _git_config ()
--get --get-all --get-regexp
--add --unset --unset-all
--remove-section --rename-section
+ --name-only
"
return
;;
@@ -1954,6 +2022,7 @@ _git_config ()
color.status.changed
color.status.header
color.status.nobranch
+ color.status.unmerged
color.status.untracked
color.status.updated
color.ui
@@ -1991,6 +2060,7 @@ _git_config ()
core.sparseCheckout
core.symlinks
core.trustctime
+ core.untrackedCache
core.warnAmbiguousRefs
core.whitespace
core.worktree
@@ -2065,6 +2135,8 @@ _git_config ()
http.noEPSV
http.postBuffer
http.proxy
+ http.sslCipherList
+ http.sslVersion
http.sslCAInfo
http.sslCAPath
http.sslCert
@@ -2128,6 +2200,7 @@ _git_config ()
pull.octopus
pull.twohead
push.default
+ push.followTags
rebase.autosquash
rebase.stat
receive.autogc
@@ -2201,12 +2274,7 @@ _git_remote ()
__git_complete_remote_or_refspec
;;
update)
- local i c='' IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
- i="${i#remotes.}"
- c="$c ${i/ */}"
- done
- __gitcomp "$c"
+ __gitcomp "$(__git_get_config_variables "remotes")"
;;
*)
;;
@@ -2233,6 +2301,11 @@ _git_reset ()
_git_revert ()
{
+ local dir="$(__gitdir)"
+ if [ -f "$dir"/REVERT_HEAD ]; then
+ __gitcomp "--continue --quit --abort"
+ return
+ fi
case "$cur" in
--*)
__gitcomp "--edit --mainline --no-edit --no-commit --signoff"
@@ -2287,6 +2360,7 @@ _git_show ()
;;
--*)
__gitcomp "--pretty= --format= --abbrev-commit --oneline
+ --show-signature
$__git_diff_common_options
"
return
@@ -2300,7 +2374,7 @@ _git_show_branch ()
case "$cur" in
--*)
__gitcomp "
- --all --remotes --topo-order --current --more=
+ --all --remotes --topo-order --date-order --current --more=
--list --independent --merge-base --no-name
--color --no-color
--sha1-name --sparse --topics --reflog
@@ -2313,7 +2387,7 @@ _git_show_branch ()
_git_stash ()
{
- local save_opts='--keep-index --no-keep-index --quiet --patch'
+ 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")"
if [ -z "$subcommand" ]; then
@@ -2335,9 +2409,20 @@ _git_stash ()
apply,--*|pop,--*)
__gitcomp "--index --quiet"
;;
- show,--*|drop,--*|branch,--*)
+ drop,--*)
+ __gitcomp "--quiet"
;;
- show,*|apply,*|drop,*|pop,*|branch,*)
+ show,--*|branch,--*)
+ ;;
+ branch,*)
+ if [ $cword -eq 3 ]; then
+ __gitcomp_nl "$(__git_refs)";
+ else
+ __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+ | sed -n -e 's/:.*//p')"
+ fi
+ ;;
+ show,*|apply,*|drop,*|pop,*)
__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
| sed -n -e 's/:.*//p')"
;;
@@ -2492,6 +2577,16 @@ _git_tag ()
__gitcomp_nl "$(__git_refs)"
;;
esac
+
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --list --delete --verify --annotate --message --file
+ --sign --cleanup --local-user --force --column --sort
+ --contains --points-at
+ "
+ ;;
+ esac
}
_git_whatchanged ()
@@ -2547,6 +2642,7 @@ __git_main ()
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
fi
@@ -2675,6 +2771,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
+if [[ "$OSTYPE" = cygwin* ]]; then
__git_complete git.exe __git_main
fi
diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
index 54489080f..0da14eee9 100644
--- a/plugins/gitfast/git-prompt.sh
+++ b/plugins/gitfast/git-prompt.sh
@@ -66,6 +66,10 @@
# git always compare HEAD to @{upstream}
# svn always compare HEAD to your SVN upstream
#
+# You can change the separator between the branch name and the above
+# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
+# is SP.
+#
# 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
@@ -84,6 +88,11 @@
# 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.
+#
+# 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
+# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
+# repository level by setting bash.hideIfPwdIgnored to "false".
# check whether printf supports -v
__git_printf_supports_v=
@@ -207,7 +216,16 @@ __git_ps1_show_upstream ()
p=" u+${count#* }-${count% *}" ;;
esac
if [[ -n "$count" && -n "$name" ]]; then
- p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
+ __git_ps1_upstream_name=$(git rev-parse \
+ --abbrev-ref "$upstream" 2>/dev/null)
+ if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
+ p="$p \${__git_ps1_upstream_name}"
+ else
+ p="$p ${__git_ps1_upstream_name}"
+ # not needed anymore; keep user's
+ # environment clean
+ unset __git_ps1_upstream_name
+ fi
fi
fi
@@ -259,9 +277,9 @@ __git_ps1_colorize_gitstring ()
r="$c_clear$r"
}
-eread ()
+__git_eread ()
{
- f="$1"
+ local f="$1"
shift
test -r "$f" && read "$@" <"$f"
}
@@ -279,6 +297,8 @@ eread ()
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
__git_ps1 ()
{
+ # preserve exit status
+ local exit=$?
local pcmode=no
local detached=no
local ps1pc_start='\u@\h:\w '
@@ -290,13 +310,54 @@ __git_ps1 ()
ps1pc_start="$1"
ps1pc_end="$2"
printf_format="${3:-$printf_format}"
+ # set PS1 to a plain prompt so that we can
+ # simply return early if the prompt should not
+ # be decorated
+ PS1="$ps1pc_start$ps1pc_end"
;;
0|1) printf_format="${1:-$printf_format}"
;;
- *) return
+ *) return $exit
;;
esac
+ # ps1_expanded: This variable is set to 'yes' if the shell
+ # subjects the value of PS1 to parameter expansion:
+ #
+ # * bash does unless the promptvars option is disabled
+ # * zsh does not unless the PROMPT_SUBST option is set
+ # * POSIX shells always do
+ #
+ # If the shell would expand the contents of PS1 when drawing
+ # the prompt, a raw ref name must not be included in PS1.
+ # This protects the user from arbitrary code execution via
+ # specially crafted ref names. For example, a ref named
+ # 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the
+ # shell to execute 'sudo rm -rf /' when the prompt is drawn.
+ #
+ # Instead, the ref name should be placed in a separate global
+ # variable (in the __git_ps1_* namespace to avoid colliding
+ # with the user's environment) and that variable should be
+ # referenced from PS1. For example:
+ #
+ # __git_ps1_foo=$(do_something_to_get_ref_name)
+ # PS1="...stuff...\${__git_ps1_foo}...stuff..."
+ #
+ # If the shell does not expand the contents of PS1, the raw
+ # ref name must be included in PS1.
+ #
+ # The value of this variable is only relevant when in pcmode.
+ #
+ # Assume that the shell follows the POSIX specification and
+ # expands PS1 unless determined otherwise. (This is more
+ # likely to be correct if the user has a non-bash, non-zsh
+ # shell and safer than the alternative if the assumption is
+ # incorrect.)
+ #
+ local ps1_expanded=yes
+ [ -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 \
--is-bare-repository --is-inside-work-tree \
@@ -304,11 +365,7 @@ __git_ps1 ()
rev_parse_exit_code="$?"
if [ -z "$repo_info" ]; then
- if [ $pcmode = yes ]; then
- #In PC mode PS1 always needs to be set
- PS1="$ps1pc_start$ps1pc_end"
- fi
- return
+ return $exit
fi
local short_sha
@@ -323,14 +380,22 @@ __git_ps1 ()
local inside_gitdir="${repo_info##*$'\n'}"
local g="${repo_info%$'\n'*}"
+ if [ "true" = "$inside_worktree" ] &&
+ [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
+ [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
+ git check-ignore -q .
+ then
+ return $exit
+ fi
+
local r=""
local b=""
local step=""
local total=""
if [ -d "$g/rebase-merge" ]; then
- eread "$g/rebase-merge/head-name" b
- eread "$g/rebase-merge/msgnum" step
- eread "$g/rebase-merge/end" total
+ __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
@@ -338,10 +403,10 @@ __git_ps1 ()
fi
else
if [ -d "$g/rebase-apply" ]; then
- eread "$g/rebase-apply/next" step
- eread "$g/rebase-apply/last" total
+ __git_eread "$g/rebase-apply/next" step
+ __git_eread "$g/rebase-apply/last" total
if [ -f "$g/rebase-apply/rebasing" ]; then
- eread "$g/rebase-apply/head-name" b
+ __git_eread "$g/rebase-apply/head-name" b
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
@@ -365,11 +430,8 @@ __git_ps1 ()
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
local head=""
- if ! eread "$g/HEAD" head; then
- if [ $pcmode = yes ]; then
- PS1="$ps1pc_start$ps1pc_end"
- fi
- return
+ if ! __git_eread "$g/HEAD" head; then
+ return $exit
fi
# is it a symbolic ref?
b="${head#ref: }"
@@ -414,21 +476,21 @@ __git_ps1 ()
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
[ "$(git config --bool bash.showDirtyState)" != "false" ]
then
- git diff --no-ext-diff --quiet --exit-code || w="*"
- if [ -n "$short_sha" ]; then
- git diff-index --cached --quiet HEAD -- || i="+"
- else
+ git diff --no-ext-diff --quiet || w="*"
+ git diff --no-ext-diff --cached --quiet || i="+"
+ if [ -z "$short_sha" ] && [ -z "$i" ]; then
i="#"
fi
fi
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
- [ -r "$g/refs/stash" ]; then
+ git rev-parse --verify --quiet refs/stash >/dev/null
+ then
s="$"
fi
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
- git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
+ git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null
then
u="%${ZSH_VERSION+%}"
fi
@@ -440,13 +502,21 @@ __git_ps1 ()
local z="${GIT_PS1_STATESEPARATOR-" "}"
- # NO color option unless in PROMPT_COMMAND mode
- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
- __git_ps1_colorize_gitstring
+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+ __git_ps1_colorize_gitstring
+ fi
+ fi
+
+ b=${b##refs/heads/}
+ if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
+ __git_ps1_branch_name=$b
+ b="\${__git_ps1_branch_name}"
fi
local f="$w$i$s$u"
- local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
+ local gitstring="$c$b${f:+$z$f}$r$p"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
@@ -458,4 +528,6 @@ __git_ps1 ()
else
printf -- "$printf_format" "$gitstring"
fi
+
+ return $exit
}
diff --git a/plugins/github/README.md b/plugins/github/README.md
index 21b7367f7..fea607876 100644
--- a/plugins/github/README.md
+++ b/plugins/github/README.md
@@ -1,6 +1,6 @@
# github
-This plugin supports working with GitHub the command line. It provides a few things:
+This plugin supports working with GitHub from the command line. It provides a few things:
* Sets up the `hub` wrapper and completions for the `git` command if you have `hub` installed.
* Completion for the `github` Ruby gem.
@@ -37,7 +37,7 @@ See `man hub` for more details.
### 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 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`.
+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`.
```zsh
if (( ! ${fpath[(I)/usr/local/share/zsh/site-functions]} )); then
diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh
index ca19901fd..0ab399c97 100644
--- a/plugins/github/github.plugin.zsh
+++ b/plugins/github/github.plugin.zsh
@@ -71,7 +71,7 @@ exist_gh() { # [DIRECTORY]
#
git.io() {
emulate -L zsh
- curl -i -s http://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " "
+ curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " "
}
# End Functions #############################################################
diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh
index 481d487ba..ba1b38711 100644
--- a/plugins/gitignore/gitignore.plugin.zsh
+++ b/plugins/gitignore/gitignore.plugin.zsh
@@ -1,4 +1,4 @@
-function gi() { curl -sL https://www.gitignore.io/api/$@ ;}
+function gi() { curl -sL https://www.gitignore.io/api/${(j:,:)@} }
_gitignoreio_get_command_list() {
curl -sL https://www.gitignore.io/api/list | tr "," "\n"
diff --git a/plugins/globalias/README.md b/plugins/globalias/README.md
new file mode 100644
index 000000000..ba9888ccb
--- /dev/null
+++ b/plugins/globalias/README.md
@@ -0,0 +1,62 @@
+# Globalias plugin
+
+Expands all glob expressions, subcommands and aliases (including global).
+
+Idea from: http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html.
+
+## Usage
+
+Add `globalias` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... globalias)
+```
+
+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`.
+
+## Examples
+
+#### Glob expressions
+
+```
+$ touch {1..10}<space>
+# expands to
+$ touch 1 2 3 4 5 6 7 8 9 10
+
+$ ls **/*.json<space>
+# expands to
+$ ls folder/file.json anotherfolder/another.json
+```
+
+#### Subcommands
+
+```
+$ mkdir "`date -R`"
+# expands to
+$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
+
+```
+
+#### Aliases
+
+```
+# .zshrc:
+alias -g G="| grep --color=auto -P"
+alias l='ls --color=auto -lah'
+
+$ l<space>G<space>
+# expands to
+$ ls --color=auto -lah | grep --color=auto -P
+```
+
+```
+# .zsrc:
+alias S="sudo systemctl"
+
+$ S<space>
+# expands to:
+$ sudo systemctl
+```
diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh
new file mode 100644
index 000000000..9602a9606
--- /dev/null
+++ b/plugins/globalias/globalias.plugin.zsh
@@ -0,0 +1,17 @@
+globalias() {
+ zle _expand_alias
+ zle expand-word
+ zle self-insert
+}
+zle -N globalias
+
+# space expands all aliases, including global
+bindkey -M emacs " " globalias
+bindkey -M viins " " globalias
+
+# control-space to make a normal space
+bindkey -M emacs "^ " magic-space
+bindkey -M viins "^ " magic-space
+
+# normal space during searches
+bindkey -M isearch " " magic-space
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index de95f7e6c..b66e25d7f 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -52,7 +52,7 @@ if [[ -x "${commands[gwhoami]}" ]]; then
#
# This method is inflexible since the aliases are at risk of being
- # overriden resulting in the BSD coreutils being called.
+ # overridden resulting in the BSD coreutils being called.
#
# (( ${+commands[$gcmd]} )) && \
# alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
index 1ce3cea58..d9d450690 100644
--- a/plugins/golang/golang.plugin.zsh
+++ b/plugins/golang/golang.plugin.zsh
@@ -179,5 +179,15 @@ __go_tool_complete() {
compdef __go_tool_complete go
-# aliases
-alias gfa='go fmt . ./...'
+# aliases: go<~>
+alias gob='go build'
+alias goc='go clean'
+alias god='go doc'
+alias gof='go fmt'
+alias gofa='go fmt . ./...'
+alias gog='go get'
+alias goi='go install'
+alias gol='go list'
+alias gor='go run'
+alias got='go test'
+alias gov='go vet'
diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle
new file mode 120000
index 000000000..80723f2fc
--- /dev/null
+++ b/plugins/gradle/_gradle
@@ -0,0 +1 @@
+gradle.plugin.zsh \ No newline at end of file
diff --git a/plugins/gradle/_gradlew b/plugins/gradle/_gradlew
new file mode 120000
index 000000000..80723f2fc
--- /dev/null
+++ b/plugins/gradle/_gradlew
@@ -0,0 +1 @@
+gradle.plugin.zsh \ No newline at end of file
diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
index a908eaeaa..0adc04a13 100644
--- a/plugins/gradle/gradle.plugin.zsh
+++ b/plugins/gradle/gradle.plugin.zsh
@@ -24,29 +24,60 @@ function _gradle_core_commands() {
function _gradle_arguments() {
_arguments -C \
'-a[Do not rebuild project dependencies]' \
- '-h[Help]' \
- '-D[System property]' \
+ '-b[Specifies the build file]' \
+ '-c[Specifies the settings file]' \
'-d[Log at the debug level]' \
- '--gui[Launches the Gradle GUI app]' \
- '--stop[Stop the Gradle daemon]' \
- '--daemon[Use the Gradle daemon]' \
- '--no-daemon[Do not use the Gradle daemon]' \
- '--rerun-task [Specifies that any task optimization is ignored.]' \
- '-i[Log at the info level]' \
- '-m[Dry run]' \
- '-P[Set a project property]' \
- '-p[Specifies the start directory]' \
- '--profile[Profile the build time]' \
- '-q[Log at the quiet level (only show errors)]' \
- '-v[Print the Gradle version info]' \
+ '-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]' \
- '-b[Specifies the build file.]' \
- '-c[Specifies the settings file.]' \
- '--continue[Continues task execution after a task failure.]' \
- '-g[Specifies the Gradle user home directory.]' \
- '-I[Specifies an initialization script.]' \
- '--refresh-dependencies[Refresh the state of dependencies.]' \
- '-u[Don''t search in parent directories for a settings.gradle file.]' \
+ '-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
}
@@ -60,6 +91,54 @@ _gradle_does_task_list_need_generating () {
[[ ! -f .gradletasknamecache ]] || [[ build.gradle -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"
@@ -68,7 +147,7 @@ _gradle_tasks () {
if [[ -f build.gradle ]]; then
_gradle_arguments
if _gradle_does_task_list_need_generating; then
- gradle tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache
+ _gradle_parse_and_extract_tasks "$(gradle tasks --all)" > .gradletasknamecache
fi
compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache)
fi
@@ -78,7 +157,7 @@ _gradlew_tasks () {
if [[ -f build.gradle ]]; then
_gradle_arguments
if _gradle_does_task_list_need_generating; then
- ./gradlew tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache
+ _gradle_parse_and_extract_tasks "$(./gradlew tasks --all)" > .gradletasknamecache
fi
compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache)
fi
diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku
index fd72e530e..878d3ce1b 100644
--- a/plugins/heroku/_heroku
+++ b/plugins/heroku/_heroku
@@ -31,6 +31,10 @@ _1st_arguments=(
"domains\:add":"add a custom domain to an app"
"domains\:remove":"remove a custom domain from an app"
"domains\:clear":"remove all custom domains from an app"
+ "features":"list available app features"
+ "features\:disable":"disables a feature"
+ "features\:enable":"enables an feature"
+ "features\:info":"displays additional information about feature"
"help":"list available commands or display help for a specific command"
"keys":"display keys for the current user"
"keys\:add":"add a key for the current user"
@@ -144,5 +148,4 @@ _arguments \
'(--app)--app[the app name]' \
'(--remote)--remote[the remote name]' \
'(--help)--help[help about the current command]' \
- && return 0
-
+ && return 0
diff --git a/plugins/history-substring-search/history-substring-search.zsh b/plugins/history-substring-search/history-substring-search.zsh
index ad316acc8..3b8afd317 100644
--- a/plugins/history-substring-search/history-substring-search.zsh
+++ b/plugins/history-substring-search/history-substring-search.zsh
@@ -244,7 +244,7 @@ _history-substring-search-end() {
_history_substring_search_result=$BUFFER
- # the search was succesful so display the result properly by clearing away
+ # the search was successful so display the result properly by clearing away
# existing highlights and moving the cursor to the end of the result buffer
if [[ $_history_substring_search_refresh_display -eq 1 ]]; then
region_highlight=()
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index 341e23ec0..67c989457 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -38,7 +38,11 @@ function jira() {
_jira_query $@
elif [[ "$action" == "dashboard" ]]; then
echo "Opening dashboard"
- open_command "${jira_url}/secure/Dashboard.jspa"
+ if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
+ open_command "${jira_url}/secure/RapidBoard.jspa"
+ else
+ open_command "${jira_url}/secure/Dashboard.jspa"
+ fi
elif [[ "$action" == "dumpconfig" ]]; then
echo "JIRA_URL=$jira_url"
echo "JIRA_PREFIX=$jira_prefix"
@@ -99,4 +103,3 @@ function _jira_query() {
query="${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${query}"
}
-
diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
index e58e7373d..86d9553a2 100644
--- a/plugins/jump/jump.plugin.zsh
+++ b/plugins/jump/jump.plugin.zsh
@@ -9,7 +9,7 @@
export MARKPATH=$HOME/.marks
jump() {
- cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
+ cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
}
mark() {
diff --git a/plugins/kitchen/_kitchen b/plugins/kitchen/_kitchen
index 54105b61a..dee5c5809 100644
--- a/plugins/kitchen/_kitchen
+++ b/plugins/kitchen/_kitchen
@@ -1,41 +1,85 @@
-# author: Peter Eisentraut
-# source: https://gist.github.com/petere/10307599
-# compdef kitchen
+#compdef kitchen
+# ------------------------------------------------------------------------------
+# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the zsh-users nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# Completion script for Test Kitchen (http://kitchen.ci/).
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Peter Eisentraut (https://github.com/petere)
+#
+# ------------------------------------------------------------------------------
+
_kitchen() {
- local curcontext="$curcontext" state line
- typeset -A opt_args
-
- _arguments '1: :->cmds'\
- '2: :->args'
-
- case $state in
- cmds)
- _arguments "1:Commands:(console converge create destroy diagnose driver help init list login setup test verify version)"
- ;;
- args)
- case $line[1] in
- converge|create|destroy|diagnose|list|setup|test|verify)
- compadd "$@" all
- _kitchen_instances
- ;;
- login)
- _kitchen_instances
- ;;
- esac
- ;;
- esac
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ _arguments '1: :->cmds'\
+ '2: :->args'
+
+ case $state in
+ cmds)
+ _kitchen_commands
+ ;;
+ args)
+ case $line[1] in
+ converge|create|destroy|diagnose|list|setup|test|verify)
+ compadd 'all'
+ _kitchen_instances
+ ;;
+ login)
+ _kitchen_instances
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_kitchen_commands() {
+ local commands
+
+ commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ [].*# \(.*\)$/\1:\2/p')}")
+ _describe -t commands 'kitchen commands' commands
}
_kitchen_instances() {
- if [[ $_kitchen_instances_cache_dir != $PWD ]]; then
- unset _kitchen_instances_cache
- fi
- if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then
- _kitchen_instances_cache=(${(f)"$(bundle exec kitchen list -b 2>/dev/null || kitchen list -b 2>/dev/null)"})
- _kitchen_instances_cache_dir=$PWD
- fi
- compadd -a _kitchen_instances_cache
+ if [[ $_kitchen_instances_cache_dir != $PWD ]]; then
+ unset _kitchen_instances_cache
+ fi
+ if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then
+ _kitchen_instances_cache=(${(f)"$(_call_program instances $service list -b 2>/dev/null)"})
+ _kitchen_instances_cache_dir=$PWD
+ fi
+ _wanted instances expl 'instance' compadd -a _kitchen_instances_cache
}
_kitchen "$@"
diff --git a/plugins/knife/_knife b/plugins/knife/_knife
index 163149267..0d61ff15c 100644
--- a/plugins/knife/_knife
+++ b/plugins/knife/_knife
@@ -3,6 +3,9 @@
# You can override the path to knife.rb and your cookbooks by setting
# KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb
# KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks
+# If you want your local cookbooks path to be calculated relative to where you are then
+# set the below option
+# KNIFE_RELATIVE_PATH=true
# Read around where these are used for more detail.
# These flags should be available everywhere according to man knife
@@ -119,7 +122,19 @@ _knife() {
_arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
;;
file)
- _arguments '*:file or directory:_files -g "*.(rb|json)"'
+ 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
@@ -132,11 +147,22 @@ _knife() {
if (( versioncomp > 0 )); then
compadd "$@" attributes definitions files libraries providers recipes resources templates
else
- _arguments '*:Subsubcommands:($(_knife_options2))'
+ case $words[5] in
+ file)
+ _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
+ ;;
+ *) _arguments '*:Subsubcommands:($(_knife_options2))'
+ esac
fi
;;
knifesubcmd5)
- _arguments '*:Subsubcommands:($(_knife_options3))'
+ case $words[5] in
+ file)
+ _arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"'
+ ;;
+ *)
+ _arguments '*:Subsubcommands:($(_knife_options3))'
+ esac
esac
}
@@ -184,12 +210,15 @@ _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() {
-
- local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
- if [ -f ./.chef/knife.rb ]; then
- knife_rb="./.chef/knife.rb"
+ if [ $KNIFE_RELATIVE_PATH ]; then
+ local cookbook_path="$(_chef_root)/cookbooks"
+ else
+ local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
+ if [ -f ./.chef/knife.rb ]; then
+ knife_rb="./.chef/knife.rb"
+ fi
+ local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )}
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/' )}
(for i in $cookbook_path; do ls $i; done)
}
@@ -198,4 +227,15 @@ _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 () {
+ directory="$PWD"
+ while [ $directory != '/' ]
+ do
+ test -e "$directory/.chef" && echo "$directory" && return
+ directory="${directory:h}"
+ done
+}
+
_knife "$@"
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
new file mode 100644
index 000000000..51ae142a2
--- /dev/null
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -0,0 +1,7 @@
+# Autocompletion for kubectl, the command line interface for Kubernetes
+#
+# Author: https://github.com/pstadler
+
+if [ $commands[kubectl] ]; then
+ source <(kubectl completion zsh)
+fi
diff --git a/plugins/last-working-dir/README.md b/plugins/last-working-dir/README.md
new file mode 100644
index 000000000..4cc4acab6
--- /dev/null
+++ b/plugins/last-working-dir/README.md
@@ -0,0 +1,9 @@
+# last-working-dir plugin
+
+Keeps track of the last used working directory and automatically jumps into it
+for new shells, unless:
+
+- The plugin is already loaded.
+- The current `$PWD` is not `$HOME`.
+
+Adds `lwd` function to jump to the last working directory.
diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh
index c458464ce..e882b288f 100644
--- a/plugins/last-working-dir/last-working-dir.plugin.zsh
+++ b/plugins/last-working-dir/last-working-dir.plugin.zsh
@@ -1,26 +1,23 @@
-#!/usr/bin/env zsh
-# Keeps track of the last used working directory and automatically jumps
-# into it for new shells.
-
-# Flag indicating if we've previously jumped to last directory.
+# Flag indicating if we've previously jumped to last directory
typeset -g ZSH_LAST_WORKING_DIRECTORY
-mkdir -p $ZSH_CACHE_DIR
-cache_file="$ZSH_CACHE_DIR/last-working-dir"
-# Updates the last directory once directory is changed.
+# Updates the last directory once directory is changed
chpwd_functions+=(chpwd_last_working_dir)
-function chpwd_last_working_dir() {
- # Use >| in case noclobber is set to avoid "file exists" error
+chpwd_last_working_dir() {
+ local cache_file="$ZSH_CACHE_DIR/last-working-dir"
pwd >| "$cache_file"
}
-# Changes directory to the last working directory.
-function lwd() {
- [[ ! -r "$cache_file" ]] || cd "`cat "$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")"
}
-# Automatically jump to last working directory unless this isn't the first time
-# this plugin has been loaded.
-if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then
- lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
-fi
+# Jump to last directory automatically unless:
+# - this isn't the first time the plugin is loaded
+# - it's not in $HOME directory
+[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return
+[[ "$PWD" != "$HOME" ]] && return
+
+lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
diff --git a/plugins/lein/lein.plugin.zsh b/plugins/lein/lein.plugin.zsh
index 11c92979b..f4e50b447 100644
--- a/plugins/lein/lein.plugin.zsh
+++ b/plugins/lein/lein.plugin.zsh
@@ -33,6 +33,8 @@ function _lein_commands() {
"version:print leiningen's version"
)
_describe -t subcommands 'leiningen subcommands' subcommands && ret=0
+ ;;
+ *) _files
esac
return ret
diff --git a/plugins/meteor/README.md b/plugins/meteor/README.md
new file mode 100644
index 000000000..4bee87f8f
--- /dev/null
+++ b/plugins/meteor/README.md
@@ -0,0 +1,45 @@
+## Introduction
+
+The [meteor plugin](https://github.com/robbyrussell/oh-my-zsh/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)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|---------|----------------------------|------------------------------------------------------------------|
+| `ma` | `meteor add` | Add a package to this project |
+| `map` | `meteor add-platform` | Add a platform to this project |
+| `mad` | `meteor admin` | Administrative commands |
+| `mau` | `meteor authorized` | View or change authorized users and organizations for a site |
+| `mb` | `meteor build` | Build this project for all platforms |
+| `mcl` | `meteor claim` | Claim a site deployed with an old Meteor version |
+| `mca` | `meteor configure-android` | Run the Android configuration tool from Meteor's ADK environment |
+| `mc` | `meteor create` | Create a new project |
+| `mdb` | `meteor debug` | Run the project, but suspend the server process for debugging |
+| `mde` | `meteor deploy` | Deploy this project to Meteor |
+| `mis` | `meteor install-sdk` | Installs SDKs for a platform |
+| `ml` | `meteor list` | List the packages explicitly used by your project |
+| `mlp` | `meteor list-platforms` | List the platforms added to your project |
+| `mls` | `meteor list-sites` | List sites for which you are authorized |
+| `mli` | `meteor login` | Log in to your Meteor developer account |
+| `mlo` | `meteor logout` | Log out of your Meteor developer account |
+| `mlog` | `meteor logs` | Show logs for specified site |
+| `mm` | `meteor mongo` | Connect to the Mongo database for the specified site |
+| `mp` | `meteor publish` | Publish a new version of a package to the package server |
+| `mpa` | `meteor publish-for-arch` | Builds an already-published package for a new platform |
+| `mpr` | `meteor publish-release` | Publish a new meteor release to the package server |
+| `mr` | `meteor remove` | Remove a package from this project |
+| `mrp` | `meteor remove-platform` | Remove a platform from this project |
+| `mre` | `meteor reset` | Reset the project state. Erases the local database |
+| `m` | `meteor run` | **[default]** Run this project in local development mode |
+| `ms` | `meteor search` | Search through the package server database |
+| `msh` | `meteor shell` | Launch a Node REPL for interactively evaluating server-side code |
+| `msw` | `meteor show` | Show detailed information about a release or package |
+| `mt` | `meteor test-packages` | Test one or more packages |
+| `mu` | `meteor update` | Upgrade this project's dependencies to their latest versions |
+| `mw` | `meteor whoami` | Prints the username of your Meteor developer account |
diff --git a/plugins/meteor/meteor.plugin.zsh b/plugins/meteor/meteor.plugin.zsh
new file mode 100644
index 000000000..db55e367d
--- /dev/null
+++ b/plugins/meteor/meteor.plugin.zsh
@@ -0,0 +1,33 @@
+# Aliases in alphabetical order
+
+alias ma='meteor add' # Add a package to this project.
+alias map='meteor add-platform' # Add a platform to this project.
+alias mad='meteor admin' # Administrative commands.
+alias mau='meteor authorized' # View or change authorized users and organizations for a site.
+alias mb='meteor build' # Build this project for all platforms.
+alias mcl='meteor claim' # Claim a site deployed with an old Meteor version.
+alias mca='meteor configure-android' # Run the Android configuration tool from Meteor's ADK environment.
+alias mc='meteor create' # Create a new project.
+alias mdb='meteor debug' # Run the project, but suspend the server process for debugging.
+alias mde='meteor deploy' # Deploy this project to Meteor.
+alias mis='meteor install-sdk' # Installs SDKs for a platform.
+alias ml='meteor list' # List the packages explicitly used by your project.
+alias mlp='meteor list-platforms' # List the platforms added to your project.
+alias mls='meteor list-sites' # List sites for which you are authorized.
+alias mli='meteor login' # Log in to your Meteor developer account.
+alias mlo='meteor logout' # Log out of your Meteor developer account.
+alias mlog='meteor logs' # Show logs for specified site.
+alias mm='meteor mongo' # Connect to the Mongo database for the specified site.
+alias mp='meteor publish' # Publish a new version of a package to the package server.
+alias mpa='meteor publish-for-arch' # Builds an already-published package for a new platform.
+alias mpr='meteor publish-release' # Publish a new meteor release to the package server.
+alias mr='meteor remove' # Remove a package from this project.
+alias mrp='meteor remove-platform' # Remove a platform from this project.
+alias mre='meteor reset' # Reset the project state. Erases the local database.
+alias m='meteor run' # [default] Run this project in local development mode.
+alias ms='meteor search' # Search through the package server database.
+alias msh='meteor shell' # Launch a Node REPL for interactively evaluating server-side code.
+alias msw='meteor show' # Show detailed information about a release or package.
+alias mt='meteor test-packages' # Test one or more packages.
+alias mu='meteor update' # Upgrade this project's dependencies to their latest versions.
+alias mw='meteor whoami' # Prints the username of your Meteor developer account.
diff --git a/plugins/mix/_mix b/plugins/mix/_mix
index 319932b3f..cfeb4705e 100644
--- a/plugins/mix/_mix
+++ b/plugins/mix/_mix
@@ -38,6 +38,15 @@ _1st_arguments=(
'local.hex:Install hex locally'
'local.rebar:Install rebar locally'
'new:Create a new Elixir project'
+ 'phoenix.digest:Digests and compress static files'
+ 'phoenix.gen.channel:Generates a Phoenix channel'
+ 'phoenix.gen.html:Generates controller, model and views for an HTML based resource'
+ 'phoenix.gen.json:Generates a controller and model for a JSON based resource'
+ 'phoenix.gen.model:Generates an Ecto model'
+ 'phoenix.gen.secret:Generates a secret'
+ 'phoenix.new:Create a new Phoenix application'
+ 'phoenix.routes:Prints all routes'
+ 'phoenix.server:Starts applications and their servers'
'run:Run the given file or expression'
"test:Run a project's tests"
'--help:Describe available tasks'
@@ -49,7 +58,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 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 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 run test)
_wanted tasks expl 'help' compadd $tasks
}
@@ -73,7 +82,13 @@ case $state in
case $line[1] in
(help)
_arguments ':feature:__task_list'
+ ;;
+ (test)
+ _files
+ ;;
+ (run)
+ _files
+ ;;
esac
;;
esac
-
diff --git a/plugins/mvn/README.md b/plugins/mvn/README.md
new file mode 100644
index 000000000..ffc5f6832
--- /dev/null
+++ b/plugins/mvn/README.md
@@ -0,0 +1,33 @@
+## Introduction
+
+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.
+
+Enable it by adding `mvn` to the plugins array in your zshrc file:
+```zsh
+plugins=(... mvn)
+```
+
+## Aliases
+
+| Alias | Command |
+|:---------------------|:------------------------------------------------|
+| `mvncie` | `mvn clean install eclipse:eclipse` |
+| `mvnci` | `mvn clean install` |
+| `mvncist` | `mvn clean install -DskipTests` |
+| `mvncisto` | `mvn clean install -DskipTests --offline` |
+| `mvne` | `mvn eclipse:eclipse` |
+| `mvnd` | `mvn deploy` |
+| `mvnp` | `mvn package` |
+| `mvnc` | `mvn clean` |
+| `mvncom` | `mvn compile` |
+| `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` |
+| `mvndt` | `mvn dependency:tree` |
+| `mvns` | `mvn site` |
+| `mvnsrc` | `mvn dependency:sources` |
+| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 865b15235..c5a7faa0f 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -1,29 +1,28 @@
# mvn-color based on https://gist.github.com/1027800
-export BOLD=`tput bold`
-export UNDERLINE_ON=`tput smul`
-export UNDERLINE_OFF=`tput rmul`
-export TEXT_BLACK=`tput setaf 0`
-export TEXT_RED=`tput setaf 1`
-export TEXT_GREEN=`tput setaf 2`
-export TEXT_YELLOW=`tput setaf 3`
-export TEXT_BLUE=`tput setaf 4`
-export TEXT_MAGENTA=`tput setaf 5`
-export TEXT_CYAN=`tput setaf 6`
-export TEXT_WHITE=`tput setaf 7`
-export BACKGROUND_BLACK=`tput setab 0`
-export BACKGROUND_RED=`tput setab 1`
-export BACKGROUND_GREEN=`tput setab 2`
-export BACKGROUND_YELLOW=`tput setab 3`
-export BACKGROUND_BLUE=`tput setab 4`
-export BACKGROUND_MAGENTA=`tput setab 5`
-export BACKGROUND_CYAN=`tput setab 6`
-export BACKGROUND_WHITE=`tput setab 7`
-export RESET_FORMATTING=`tput sgr0`
+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`
+
-
# Wrapper function for Maven's mvn command.
-mvn-color()
-{
+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
@@ -37,7 +36,7 @@ mvn-color()
echo -ne ${RESET_FORMATTING}
)
}
-
+
# Override the mvn command with the colorized one.
#alias mvn="mvn-color"
@@ -45,6 +44,7 @@ mvn-color()
alias mvncie='mvn clean install eclipse:eclipse'
alias mvnci='mvn clean install'
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 mvnd='mvn deploy'
@@ -64,13 +64,13 @@ alias mvnsrc='mvn dependency:sources'
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
function listMavenCompletions {
- reply=(
+ reply=(
# common lifecycle
clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site
-
+
# common plugins
deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt
-
+
# deploy
deploy:deploy-file
# failsafe
@@ -81,7 +81,7 @@ function listMavenCompletions {
site:site site:deploy site:run site:stage site:stage-deploy
# surefire
surefire:test
-
+
# checkstyle
checkstyle:checkstyle checkstyle:check
# javadoc
@@ -109,16 +109,18 @@ function listMavenCompletions {
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: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
-
+
# eclipse
eclipse:clean eclipse:eclipse
# idea
idea:clean idea:idea
-
+
# jetty
jetty:run jetty:run-exploded
# cargo
@@ -131,7 +133,7 @@ function listMavenCompletions {
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
tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
# spring-boot
spring-boot:run spring-boot:repackage
@@ -169,9 +171,10 @@ function listMavenCompletions {
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
# options
- -Dmaven.test.skip=true -DskipTests -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven
+ -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 -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X
@@ -180,6 +183,7 @@ function listMavenCompletions {
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`
);
}
diff --git a/plugins/ng/README.md b/plugins/ng/README.md
new file mode 100644
index 000000000..86ad64041
--- /dev/null
+++ b/plugins/ng/README.md
@@ -0,0 +1,37 @@
+## 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).
+
+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
+
+```zsh
+eval `ng completion`
+```
+
+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
new file mode 100644
index 000000000..2488bc230
--- /dev/null
+++ b/plugins/ng/ng.plugin.zsh
@@ -0,0 +1,77 @@
+
+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 v version -h --help'
+
+_ng_completion () {
+ local words cword opts
+ read -Ac words
+ read -cn cword
+ let cword-=1
+
+ case $words[cword] in
+ addon )
+ opts='-b --blueprint -d -dir --directory --dry-run -sb --skip-bower -sg --skip-git -sn --skip-npm -v --verbose'
+ ;;
+
+ asset-sizes )
+ opts='-o --output-path'
+ ;;
+
+ b | build )
+ opts='--environment --output-path --suppress-sizes --target --watch --watcher -dev -e -prod'
+ ;;
+
+ d | destroy )
+ opts='--dry-run --verbose --pod --classic --dummy --in-repo --in-repo-addon -d -v -p -c -dum -id -ir'
+ ;;
+
+ g | generate )
+ opts='class component directive enum module pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir'
+ ;;
+
+ gh-pages:deploy | github-pages:deploy )
+ opts='--environment --gh-token --gh-username --skip-build --user-page --message'
+ ;;
+
+ h | help | -h | --help)
+ opts='--json --verbose -v'
+ ;;
+
+ init )
+ opts='--blueprint --dry-run --link-cli --mobile --name --prefix --skip-bower --skip-npm --source-dir --style --verbose -b -d -lc -n -p -sb -sd -sn -v'
+ ;;
+
+ new )
+ opts='--blueprint --directory --dry-run --link-cli --mobile --prefix --skip-bower --skip-git --skip-npm --source-dir --style --verbose -b -d -dir -lc -p -sb -sd -sg -sn -v'
+ ;;
+
+ s | serve | server )
+ opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --target --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -t -w'
+ ;;
+
+ set )
+ opts='--global -g'
+ ;;
+
+ t | test )
+ opts='--browsers --colors --config-file --environment --filter --host --launch --log-level --module --path --port --query --reporter --server --silent --test-page --test-port --watch -H -c -cf -e -f -m -r -s -tp -w'
+ ;;
+
+ v | version )
+ opts='--verbose'
+ ;;
+
+ ng )
+ opts=$ng_opts
+ ;;
+
+ * )
+ opts=''
+ ;;
+ esac
+
+ setopt shwordsplit
+ reply=($opts)
+ unset shwordsplit
+}
+
+compctl -K _ng_completion ng
diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh
index 2463815ac..e196662c7 100644
--- a/plugins/node/node.plugin.zsh
+++ b/plugins/node/node.plugin.zsh
@@ -1,5 +1,6 @@
# Open the node api for your current version to the optional section.
# TODO: Make the section part easier to use.
function node-docs {
- open_command "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
+ local section=${1:-all}
+ open_command "https://nodejs.org/docs/$(node --version)/api/$section.html"
}
diff --git a/plugins/nomad/README.md b/plugins/nomad/README.md
new file mode 100644
index 000000000..04b361683
--- /dev/null
+++ b/plugins/nomad/README.md
@@ -0,0 +1,15 @@
+# Nomad
+
+The `nomad` plugin provides a simple autocompletion for [Nomad](https://nomadproject.io/), a tool from Hashicorp for easily deploy applications at any scale.
+
+## Usage
+
+1. Enable the `nomad` plugin:
+
+ ```zsh
+ plugins=(... nomad)
+ ```
+
+2. Install [Nomad](https://nomadproject.io/)
+
+3. Type `nomad` into your prompt and hit `TAB` to see available completion options.
diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad
new file mode 100644
index 000000000..1c935a02e
--- /dev/null
+++ b/plugins/nomad/_nomad
@@ -0,0 +1,153 @@
+#compdef nomad
+
+local -a _nomad_cmds
+_nomad_cmds=(
+ 'agent:Runs a Nomad agent'
+ 'agent-info:Display status information about the local agent'
+ 'alloc-status:Display allocation status information and metadata'
+ 'client-config:View or modify client configuration details'
+ 'eval-status:Display evaluation status and placement failure reasons'
+ 'fs:Inspect the contents of an allocation directory'
+ 'init:Create an example job file'
+ 'inspect:Inspect a submitted job'
+ 'logs:Streams the logs of a task.'
+ 'node-drain:Toggle drain mode on a given node'
+ 'node-status:Display status information about nodes'
+ 'plan:Dry-run a job update to determine its effects'
+ 'run:Run a new job or update an existing'
+ 'server-force-leave:Force a server into the left state'
+ 'server-join:Join server nodes together'
+ 'server-members:Display a list of known servers and their'
+ 'status:Display status information about jobs'
+ 'stop:Stop a running job'
+ 'validate:Checks if a given job specification is valid'
+ 'version:Prints the Nomad version'
+)
+
+__allocstatus() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-short[Display short output. Shows only the most recent task event.]' \
+ '-stats[Display detailed resource usage statistics.]' \
+ '-verbose[Show full information.]' \
+ '-json[Output the allocation in its JSON format.]' \
+ '-t[Format and display allocation using a Go template.]'
+}
+
+__evalstatus() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-monitor[Monitor an outstanding evaluation.]' \
+ '-verbose[Show full information.]' \
+ '-json[Output the allocation in its JSON format.]' \
+ '-t[Format and display allocation using a Go template.]'
+}
+
+__inspect() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-json[Output the allocation in its JSON format.]' \
+ '-t[Format and display allocation using a Go template.]'
+}
+
+__logs() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-stderr[ Display stderr logs.]' \
+ '-job[<job-id> Use a random allocation from the specified job ID.]' \
+ '-verbose[Show full information.]' \
+ '-f[Causes the output to not stop when the end of the logs are reached, but rather to wait for additional output.]' \
+ '-tail[Show the logs contents with offsets relative to the end of the logs. If no offset is given, -n is defaulted to 10.]' \
+ '-n[Sets the tail location in best-efforted number of lines relative to the end of the logs.]' \
+ '-c[Sets the tail location in number of bytes relative to the end of the logs.]'
+}
+
+__nodestatus() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-self[Query the status of the local node.]' \
+ '-allocs[ Display a count of running allocations for each node.]' \
+ '-short[Display short output. Shows only the most recent task event.]' \
+ '-stats[Display detailed resource usage statistics.]' \
+ '-verbose[Show full information.]' \
+ '-json[Output the allocation in its JSON format.]' \
+ '-t[Format and display allocation using a Go template.]'
+}
+
+__plan() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]'
+}
+
+__run() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
+ '-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
+ '-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
+ '-verbose[Show full information.]'
+}
+
+__status() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-short[Display short output. Shows only the most recent task event.]' \
+ '-evals[Display the evaluations associated with the job.]' \
+ '-verbose[Show full information.]'
+}
+
+__stop() {
+ _arguments \
+ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
+ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
+ '-no-color[Disables colored command output.]' \
+ '-detach[Return immediately instead of entering monitor mode. After the deregister command is submitted, a new evaluation ID is printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
+ '-yes[Automatic yes to prompts.]' \
+ '-verbose[Show full information.]'
+}
+
+_arguments '*:: :->command'
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "nomad command" _nomad_cmds
+ return
+fi
+
+local -a _command_args
+case "$words[1]" in
+ alloc-status)
+ __allocstatus ;;
+ eval-status)
+ __evalstatus ;;
+ inspect)
+ __inspect ;;
+ logs)
+ __logs ;;
+ node-status)
+ __nodestatus ;;
+ plan)
+ __plan ;;
+ run)
+ __run ;;
+ status)
+ __status ;;
+ stop)
+ __stop ;;
+esac
diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
index 3f6fe0fb3..43aedc36d 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -1,4 +1,15 @@
-eval "$(npm completion 2>/dev/null)"
+(( $+commands[npm] )) && {
+ __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/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
+}
# Install dependencies globally
alias npmg="npm i -g "
@@ -17,3 +28,19 @@ alias npmD="npm i -D "
# Execute command from node_modules folder based on current directory
# i.e npmE gulp
alias npmE='PATH="$(npm bin)":"$PATH"'
+
+# Check which npm modules are outdated
+alias npmO="npm outdated"
+
+# Check package versions
+alias npmV="npm -v"
+
+# List packages
+alias npmL="npm list"
+
+# Run npm start
+alias npmst="npm start"
+
+# Run npm test
+alias npmt="npm test"
+
diff --git a/plugins/nvm/_nvm b/plugins/nvm/_nvm
index a95c9e375..1414dcbb1 100644
--- a/plugins/nvm/_nvm
+++ b/plugins/nvm/_nvm
@@ -1,7 +1,7 @@
#compdef nvm
#autoload
-[[ -s ~/.nvm/nvm.sh ]] || return 0
+[[ -f "$NVM_DIR/nvm.sh" ]] || return 0
local -a _1st_arguments
_1st_arguments=(
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 9709719fe..9dde3a266 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -1,3 +1,5 @@
-# The addition 'nvm install' attempts in ~/.profile
+# Set NVM_DIR if it isn't already defined
+[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
-[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh
+# Load nvm if it exists
+[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
diff --git a/plugins/osx/README.md b/plugins/osx/README.md
new file mode 100644
index 000000000..b77daecc5
--- /dev/null
+++ b/plugins/osx/README.md
@@ -0,0 +1,33 @@
+# OSX plugin
+
+## Description
+
+This plugin provides a few utilities to make it more enjoyable on OSX.
+
+To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`:
+
+```zsh
+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 |
+| `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. User `itunes -h` for usage details |
+| `spotify` | Control Spotify and search by artist, album, track and etc.|
diff --git a/plugins/osx/_man-preview b/plugins/osx/_man-preview
deleted file mode 100644
index 6cc344ad4..000000000
--- a/plugins/osx/_man-preview
+++ /dev/null
@@ -1,5 +0,0 @@
-#compdef man-preview
-#autoload
-
-_man
-
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index a1516dcce..e8488ebc9 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -1,9 +1,5 @@
-# ------------------------------------------------------------------------------
-# FILE: osx.plugin.zsh
-# DESCRIPTION: oh-my-zsh plugin file.
-# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
-# VERSION: 1.1.0
-# ------------------------------------------------------------------------------
+# Open the current directory in a Finder window
+alias ofd='open_command $PWD'
function _omz_osx_get_frontmost_app() {
local the_app=$(
@@ -46,6 +42,16 @@ EOF
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
+ end tell
+EOF
+
else
echo "tab: unsupported terminal app: $the_app"
false
@@ -73,6 +79,19 @@ function vsplit_tab() {
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
+ end tell
+ end tell
+EOF
+
else
echo "$0: unsupported terminal app: $the_app" >&2
false
@@ -100,6 +119,19 @@ function split_tab() {
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
+ end tell
+ end tell
+EOF
+
else
echo "$0: unsupported terminal app: $the_app" >&2
false
@@ -143,6 +175,7 @@ function quick-look() {
function man-preview() {
man -t "$@" | open -f -a Preview
}
+compdef _man man-preview
function vncviewer() {
open vnc://$@
@@ -151,6 +184,7 @@ function vncviewer() {
# iTunes control function
function itunes() {
local opt=$1
+ local playlist=$2
shift
case "$opt" in
launch|play|pause|stop|rewind|resume|quit)
@@ -167,6 +201,19 @@ function itunes() {
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
@@ -217,6 +264,7 @@ EOF
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
;;
@@ -227,3 +275,275 @@ EOF
esac
osascript -e "tell application \"iTunes\" to $opt"
}
+
+# Spotify control function
+function spotify() {
+
+ showHelp () {
+ echo "Usage:";
+ echo;
+ echo " $(basename "$0") <command>";
+ echo;
+ echo "Commands:";
+ echo;
+ echo " play # Resumes playback where Spotify last left off.";
+ echo " play [song name] # Finds a song by name and plays it.";
+ echo " play album [album name] # Finds an album by name and plays it.";
+ echo " play artist [artist name] # Finds an artist by name and plays it.";
+ echo " play list [playlist name] # Finds a playlist by name and plays it.";
+ echo " pause # Pauses Spotify playback.";
+ echo " next # Skips to the next song in a playlist.";
+ echo " prev # Returns to the previous song in a playlist.";
+ echo " pos [time] # Jumps to a time (in secs) in the current song.";
+ echo " quit # Stops playback and quits Spotify.";
+ echo;
+ echo " vol up # Increases the volume by 10%.";
+ echo " vol down # Decreases the volume by 10%.";
+ echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
+ echo " vol show # Shows the current Spotify volume.";
+ echo;
+ echo " status # Shows the current player status.";
+ echo " share # Copies the current song URL to the clipboard."
+ echo " info # Shows Full Information about song that is playing.";
+ echo;
+ echo " toggle shuffle # Toggles shuffle playback mode.";
+ echo " toggle repeat # Toggles repeat playback mode.";
+ }
+
+ cecho(){
+ bold=$(tput bold);
+ green=$(tput setaf 2);
+ reset=$(tput sgr0);
+ echo "$bold$green$1$reset";
+ }
+
+ showStatus () {
+ state=$(osascript -e 'tell application "Spotify" to player state as string');
+ cecho "Spotify is currently $state.";
+ if [ "$state" = "playing" ]; then
+ 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" to duration of current track as string');
+ duration=$(echo "scale=2; $duration / 60 / 1000" | bc);
+ position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.');
+ position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}');
+
+ printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s\n" "$artist" "$album" "$track" "$position" "$duration";
+ fi
+ }
+
+
+
+ if [ $# = 0 ]; then
+ showHelp;
+ else
+ if [ "$1" != "quit" ] && [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then
+ osascript -e 'tell application "Spotify" to activate'
+ sleep 2
+ fi
+ fi
+
+ while [ $# -gt 0 ]; do
+ arg=$1;
+
+ case $arg in
+ "play" )
+ if [ $# != 1 ]; then
+ # There are additional arguments, so find out how many
+ array=( $@ );
+ len=${#array[@]};
+ SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search"
+ SPOTIFY_PLAY_URI="";
+
+ searchAndPlay() {
+ type="$1"
+ Q="$2"
+
+ cecho "Searching ${type}s for: $Q";
+
+ SPOTIFY_PLAY_URI=$( \
+ curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=$type&limit=1&offset=0" -H "Accept: application/json" \
+ | grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
+ )
+ }
+
+ case $2 in
+ "list" )
+ _args=${array[*]:2:$len};
+ Q=$_args;
+
+ cecho "Searching playlists for: $Q";
+
+ results=$( \
+ curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" \
+ | grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \
+ )
+
+ count=$( \
+ echo "$results" | grep -c "spotify:user" \
+ )
+
+ 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}' \
+ )
+ fi;;
+
+ "album" | "artist" | "track" )
+ _args=${array[*]:2:$len};
+ searchAndPlay "$2" "$_args";;
+
+ * )
+ _args=${array[*]:1:$len};
+ searchAndPlay track "$_args";;
+ esac
+
+ if [ "$SPOTIFY_PLAY_URI" != "" ]; then
+ cecho "Playing ($Q Search) -> Spotify URL: $SPOTIFY_PLAY_URI";
+
+ osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\"";
+
+ else
+ cecho "No results when searching for $Q";
+ fi
+ else
+ # play is the only param
+ cecho "Playing Spotify.";
+ osascript -e 'tell application "Spotify" to play';
+ fi
+ break ;;
+
+ "pause" )
+ state=$(osascript -e 'tell application "Spotify" to player state as string');
+ if [ "$state" = "playing" ]; then
+ cecho "Pausing Spotify.";
+ else
+ cecho "Playing Spotify.";
+ fi
+
+ osascript -e 'tell application "Spotify" to playpause';
+ break ;;
+
+ "quit" )
+ if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then
+ cecho "Spotify was not running."
+ else
+ cecho "Closing Spotify.";
+ osascript -e 'tell application "Spotify" to quit';
+ fi
+ break ;;
+
+ "next" )
+ cecho "Going to next track." ;
+ osascript -e 'tell application "Spotify" to next track';
+ break ;;
+
+ "prev" )
+ cecho "Going to previous track.";
+ osascript -e 'tell application "Spotify" to previous track';
+ break ;;
+
+ "vol" )
+ vol=$(osascript -e 'tell application "Spotify" to sound volume as integer');
+ if [[ "$2" = "show" || "$2" = "" ]]; then
+ cecho "Current Spotify volume level is $vol.";
+ break ;
+ elif [ "$2" = "up" ]; then
+ if [ "$vol" -le 90 ]; then
+ newvol=$(( vol+10 ));
+ cecho "Increasing Spotify volume to $newvol.";
+ else
+ newvol=100;
+ cecho "Spotify volume level is at max.";
+ fi
+ elif [ "$2" = "down" ]; then
+ if [ "$vol" -ge 10 ]; then
+ newvol=$(( vol-10 ));
+ cecho "Reducing Spotify volume to $newvol.";
+ else
+ newvol=0;
+ cecho "Spotify volume level is at min.";
+ fi
+ elif [ "$2" -ge 0 ]; then
+ newvol=$2;
+ fi
+
+ osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
+ break ;;
+
+ "toggle" )
+ if [ "$2" = "shuffle" ]; then
+ osascript -e 'tell application "Spotify" to set shuffling to not shuffling';
+ curr=$(osascript -e 'tell application "Spotify" to shuffling');
+ cecho "Spotify shuffling set to $curr";
+ elif [ "$2" = "repeat" ]; then
+ osascript -e 'tell application "Spotify" to set repeating to not repeating';
+ curr=$(osascript -e 'tell application "Spotify" to repeating');
+ cecho "Spotify repeating set to $curr";
+ fi
+ break ;;
+
+ "pos" )
+ cecho "Adjusting Spotify play position."
+ osascript -e "tell application \"Spotify\" to set player position to $2";
+ break ;;
+
+ "status" )
+ showStatus;
+ break ;;
+
+ "info" )
+ info=$(osascript -e 'tell application "Spotify"
+ set tM to round (duration of current track / 60) rounding down
+ set tS to duration of current track mod 60
+ set pos to player position as text
+ set myTime to tM as text & "min " & tS as text & "s"
+ set nM to round (player position / 60) rounding down
+ set nS to round (player position mod 60) rounding down
+ set nowAt to nM as text & "min " & nS as text & "s"
+ set info to "" & "\nArtist: " & artist of current track
+ set info to info & "\nTrack: " & name of current track
+ set info to info & "\nAlbum Artist: " & album artist of current track
+ set info to info & "\nAlbum: " & album of current track
+ set info to info & "\nSeconds: " & duration of current track
+ set info to info & "\nSeconds played: " & pos
+ set info to info & "\nDuration: " & mytime
+ set info to info & "\nNow at: " & nowAt
+ set info to info & "\nPlayed Count: " & played count of current track
+ set info to info & "\nTrack Number: " & track number of current track
+ set info to info & "\nPopularity: " & popularity of current track
+ set info to info & "\nId: " & id of current track
+ set info to info & "\nSpotify URL: " & spotify url of current track
+ set info to info & "\nArtwork: " & artwork of current track
+ set info to info & "\nPlayer: " & player state
+ set info to info & "\nVolume: " & sound volume
+ set info to info & "\nShuffle: " & shuffling
+ set info to info & "\nRepeating: " & repeating
+ end tell
+ return info')
+ echo "$info";
+ break ;;
+
+ "share" )
+ url=$(osascript -e 'tell application "Spotify" to spotify url of current track');
+ remove='spotify:track:'
+ url=${url#$remove}
+ url="http://open.spotify.com/track/$url"
+ cecho "Share URL: $url";
+ cecho -n "$url" | pbcopy
+ break;;
+
+ -h|--help| *)
+ showHelp;
+ break ;;
+ esac
+ done
+}
+
+
+# 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"
diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md
index d8ff93dc0..196f74e6c 100644
--- a/plugins/per-directory-history/README.md
+++ b/plugins/per-directory-history/README.md
@@ -27,9 +27,8 @@ Usage
2. The default mode if per directory history, interact with your history as normal.
3. Press ^G (the Control and G keys simultaneously) to toggle between local
- and global histories.
-
-
+ and global histories. If you would prefer a different shortcut to toggle
+ set the PER_DIRECTORY_HISTORY_TOGGLE environment variable.
-------------------------------------------------------------------------------
Configuration
diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh
index bdee341bd..1242dc420 100644
--- a/plugins/per-directory-history/per-directory-history.zsh
+++ b/plugins/per-directory-history/per-directory-history.zsh
@@ -30,7 +30,7 @@
#
################################################################################
#
-# Copyright (c) 2012 Jim Hester
+# Copyright (c) 2014 Jim Hester
#
# This software is provided 'as-is', without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from the
@@ -57,6 +57,7 @@
#-------------------------------------------------------------------------------
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
+[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
#-------------------------------------------------------------------------------
# toggle global/directory history used for searching - ctrl-G by default
@@ -76,7 +77,7 @@ function per-directory-history-toggle-history() {
autoload per-directory-history-toggle-history
zle -N per-directory-history-toggle-history
-bindkey '^G' per-directory-history-toggle-history
+bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
#-------------------------------------------------------------------------------
# implementation details
@@ -108,7 +109,7 @@ function _per-directory-history-change-directory() {
}
function _per-directory-history-addhistory() {
- print -Sr -- ${1%%$'\n'}
+ print -Sr -- "${1%%$'\n'}"
fc -p $_per_directory_history_directory
}
@@ -140,8 +141,9 @@ function _per-directory-history-set-global-history() {
#add functions to the exec list for chpwd and zshaddhistory
-chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory")
-zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory")
+autoload -U add-zsh-hook
+add-zsh-hook chpwd _per-directory-history-change-directory
+add-zsh-hook zshaddhistory _per-directory-history-addhistory
#start in directory mode
mkdir -p ${_per_directory_history_directory:h}
diff --git a/plugins/perms/README.md b/plugins/perms/README.md
new file mode 100644
index 000000000..873c21d42
--- /dev/null
+++ b/plugins/perms/README.md
@@ -0,0 +1,9 @@
+## Perms
+
+Plugin to handle some unix filesystem permissions quickly
+
+### Usage
+
+* `set755` recursively sets all directories located within the current working directory and sub directories to octal 755.
+* `set644` recursively sets all files located within the current working directory and sub directories 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. \ No newline at end of file
diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh
new file mode 100644
index 000000000..7cdebab7f
--- /dev/null
+++ b/plugins/perms/perms.plugin.zsh
@@ -0,0 +1,78 @@
+# Some useful commands for setting permissions.
+#
+# Rory Hardy [GneatGeek]
+# Andrew Janke [apjanke]
+
+### Aliases
+
+# Set all files' permissions to 644 recursively in a directory
+alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644'
+
+# Set all directories' permissions to 755 recursively in a directory
+alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755'
+
+### Functions
+
+# fixperms - fix permissions on files and directories, with confirmation
+# Returns 0 on success, nonzero if any errors occurred
+fixperms () {
+ local opts confirm target exit_status chmod_opts use_slow_mode
+ zparseopts -E -D -a opts -help -slow v+=chmod_opts
+ if [[ $# > 1 || -n "${opts[(r)--help]}" ]]; then
+ cat <<EOF
+Usage: fixperms [-v] [--help] [--slow] [target]
+
+ target is the file or directory to change permissions on. If omitted,
+ the current directory is taken to be the target.
+
+ -v enables verbose output (may be supplied multiple times)
+
+ --slow will use a slower but more robust mode, which is effective if
+ directories themselves have permissions that forbid you from
+ traversing them.
+
+EOF
+ exit_status=$(( $# > 1 ))
+ return $exit_status
+ fi
+
+ if [[ $# == 0 ]]; then
+ target="."
+ else
+ target="$1"
+ fi
+ if [[ -n ${opts[(r)--slow]} ]]; then use_slow=true; else use_slow=false; fi
+
+ # Because this requires confirmation, bail in noninteractive shells
+ if [[ ! -o interactive ]]; then
+ echo "fixperms: cannot run in noninteractive shell"
+ return 1
+ fi
+
+ echo "Fixing perms on $target?"
+ printf '%s' "Proceed? (y|n) "
+ read confirm
+ if [[ "$confirm" != y ]]; then
+ # User aborted
+ return 1
+ fi
+
+ # This xargs form is faster than -exec chmod <N> {} \; but will encounter
+ # issues if the directories themselves have permissions such that you can't
+ # recurse in to them. If that happens, just rerun this a few times.
+ exit_status=0;
+ if [[ $use_slow == true ]]; then
+ # Process directories first so non-traversable ones are fixed as we go
+ find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \;
+ if [[ $? != 0 ]]; then exit_status=$?; fi
+ find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \;
+ if [[ $? != 0 ]]; then exit_status=$?; fi
+ else
+ find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755
+ if [[ $? != 0 ]]; then exit_status=$?; fi
+ find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644
+ if [[ $? != 0 ]]; then exit_status=$?; fi
+ fi
+ echo "Complete"
+ return $exit_status
+}
diff --git a/plugins/phing/phing.plugin.zsh b/plugins/phing/phing.plugin.zsh
index 1f022047c..d5a2649bf 100644
--- a/plugins/phing/phing.plugin.zsh
+++ b/plugins/phing/phing.plugin.zsh
@@ -1,15 +1,6 @@
-_phing_does_target_list_need_generating () {
- [ ! -f .phing_targets ] && return 0;
- [ build.xml -nt .phing_targets ] && return 0;
- return 1;
-}
-
_phing () {
if [ -f build.xml ]; then
- if _phing_does_target_list_need_generating; then
- phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets
- fi
- compadd `cat .phing_targets`
+ compadd $(phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|grep -v "Warning:"|awk '{print $1}')
fi
}
diff --git a/plugins/pip/_pip b/plugins/pip/_pip
index cb155e5f4..732ffabea 100644
--- a/plugins/pip/_pip
+++ b/plugins/pip/_pip
@@ -1,7 +1,8 @@
#compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4
#autoload
-# pip zsh completion, based on homebrew completion
+# pip zsh completion, based on last stable release (pip8)
+# homebrew completion and backwards compatibility
_pip_all() {
# we cache the list of packages (originally from the macports plugin)
@@ -17,30 +18,43 @@ _pip_installed() {
local -a _1st_arguments
_1st_arguments=(
- 'bundle:create pybundles (archives containing multiple packages)'
+ 'install:install packages'
+ 'download:download packages'
+ 'uninstall:uninstall packages'
'freeze:output all currently installed packages (exact versions) to stdout'
- 'help:show available commands'
+ 'list:list installed packages'
'show:show information about installed packages'
- 'install:install packages'
'search:search PyPI'
- 'uninstall:uninstall packages'
- 'unzip:unzip individual packages'
- 'zip:zip individual packages'
+ 'wheel:build individual wheel archives for your requirements and dependencies'
+ 'hash:compute a hash of a local package archive'
+ 'help:show available commands'
+ 'bundle:create pybundles (archives containing multiple packages)(deprecated)'
+ 'unzip:unzip individual packages(deprecated)'
+ 'zip:zip individual packages(deprecated)'
)
local expl
local -a all_pkgs installed_pkgs
_arguments \
- '(--version)--version[show version number of program and exit]' \
'(-h --help)'{-h,--help}'[show help]' \
- '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \
- '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
+ '(--isolated)--isolated[run pip in isolated mode, ignores environment variables and user configuration]' \
'(-v --verbose)'{-v,--verbose}'[give more output]' \
+ '(-V --version)'{-V,--version}'[show version number of program and exit]' \
'(-q --quiet)'{-q,--quiet}'[give less output]' \
'(--log)--log[log file location]' \
'(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
+ '(--retries)--retries[max number of retries per connection (default 5 times)]' \
'(--timeout)--timeout[socket timeout (default 15s)]' \
+ '(--exists-action)--exists-action[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]' \
+ '(--trusted-host)--trusted-host[mark this host as trusted]' \
+ '(--cert)--cert[path to alternate CA bundle]' \
+ '(--client-cert)--client-cert[path to SSL client certificate]' \
+ '(--cache-dir)--cache-dir[store the cache data in specified directory]' \
+ '(--no-cache-dir)--no-cache-dir[disable de cache]' \
+ '(--disable-pip-version-check)--disable-pip-version-check[do not check periodically for new pip version downloads]' \
+ '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in (deprecated)]' \
+ '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv (deprecated)]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
@@ -56,7 +70,7 @@ case "$words[1]" in
_arguments \
'(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
install)
- _arguments \
+ _arguments \
'(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
'(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
'(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh
index b5433ae9d..d7236b02a 100644
--- a/plugins/pip/pip.plugin.zsh
+++ b/plugins/pip/pip.plugin.zsh
@@ -76,3 +76,6 @@ zsh-pip-test-clean-packages() {
echo "the djangopypi2 index is fine"
fi
}
+
+alias pip="noglob pip" # allows square brackets for pip command invocation
+
diff --git a/plugins/pj/README.md b/plugins/pj/README.md
new file mode 100644
index 000000000..27e5638ec
--- /dev/null
+++ b/plugins/pj/README.md
@@ -0,0 +1,45 @@
+# pj
+
+The `pj` plugin (short for `Project Jump`) allows you to define several
+folders where you store your projects, so that you can jump there directly
+by just using the name of the project directory.
+
+Original idea and code by Jan De Poorter ([@DefV](https://github.com/DefV))
+Source: https://gist.github.com/pjaspers/368394#gistcomment-1016
+
+## Usage
+
+1. Enable the `pj` plugin:
+
+ ```zsh
+ plugins=(... pj)
+ ```
+
+2. Set `$PROJECT_PATHS` in your ~/.zshrc:
+
+ ```zsh
+ PROJECT_PATHS=(~/src ~/work ~/"dir with spaces")
+ ```
+
+You can now use one of the following commands:
+
+##### `pj my-project`:
+
+`cd` to the directory named "my-project" found in one of the `$PROJECT_PATHS`
+directories. If there are several directories named the same, the first one
+to appear in `$PROJECT_PATHS` has preference.
+
+For example:
+```zsh
+PROJECT_PATHS=(~/code ~/work)
+$ ls ~/code # ~/code/blog ~/code/react
+$ ls ~/work # ~/work/blog ~/work/project
+$ pj blog # <-- will cd to ~/code/blog
+```
+
+##### `pjo my-project`
+
+Open the project directory with your defined `$EDITOR`. This follows the same
+directory rules as the `pj` command above.
+
+Note: `pjo` is an alias of `pj open`.
diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh
index 1572e9363..e36d49204 100644
--- a/plugins/pj/pj.plugin.zsh
+++ b/plugins/pj/pj.plugin.zsh
@@ -1,49 +1,37 @@
-#!/bin/zsh
-
-#
-# Original idea by DefV (Jan De Poorter)
-# Source: https://gist.github.com/pjaspers/368394#comment-1016
-#
-# Usage:
-# - Set `$PROJECT_PATHS` in your ~/.zshrc
-# e.g.: PROJECT_PATHS=(~/src ~/work)
-# - In ZSH you now can open a project directory with the command: `pj my-project`
-# the plugin will locate the `my-project` directory in one of the $PROJECT_PATHS
-# Also tab completion is supported.
-# - `pjo my-project` will open the directory in $EDITOR
-#
-
-function pj() {
+alias pjo="pj open"
+
+pj () {
+ emulate -L zsh
+
cmd="cd"
- file=$1
+ project=$1
- if [[ "open" == "$file" ]] then
+ if [[ "open" == "$project" ]]; then
shift
- file=$*
- cmd=(${(s: :)EDITOR})
+ project=$*
+ cmd=${=EDITOR}
else
- file=$*
+ project=$*
fi
- for project in $PROJECT_PATHS; do
- if [[ -d $project/$file ]] then
- $cmd "$project/$file"
- unset project # Unset project var
+ for basedir ($PROJECT_PATHS); do
+ if [[ -d "$basedir/$project" ]]; then
+ $cmd "$basedir/$project"
return
fi
done
- echo "No such project $1"
+ echo "No such project '${project}'."
}
-alias pjo="pj open"
+_pj () {
+ emulate -L zsh
-function _pj () {
- # might be possible to improve this using glob, without the basename trick
typeset -a projects
- projects=($PROJECT_PATHS/*)
- projects=$projects:t
- _arguments "*:file:($projects)"
-}
+ for basedir ($PROJECT_PATHS); do
+ projects+=(${basedir}/*(/N))
+ done
+ compadd ${projects:t}
+}
compdef _pj pj
diff --git a/plugins/pylint/pylint.plugin.zsh b/plugins/pylint/pylint.plugin.zsh
index 6760c67b0..57c7c0ac5 100644
--- a/plugins/pylint/pylint.plugin.zsh
+++ b/plugins/pylint/pylint.plugin.zsh
@@ -1,3 +1,3 @@
# Aliases
-alias pylint-quick='pylint --reports=n --include-ids=y'
-compdef _pylint-quick pylint-quick='pylint --reports=n --include-ids=y' \ No newline at end of file
+alias pylint-quick='pylint --reports=n'
+compdef _pylint-quick pylint-quick='pylint --reports=n'
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index 8af1d6301..c8974b5f4 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -13,6 +13,8 @@ function _rails_command () {
function _rake_command () {
if [ -e "bin/rake" ]; then
bin/rake $@
+ elif type bundle &> /dev/null && [ -e "Gemfile" ]; then
+ bundle exec rake $@
else
command rake $@
fi
@@ -34,6 +36,7 @@ alias -g RET='RAILS_ENV=test'
# Rails aliases
alias rc='rails console'
+alias rcs='rails console --sandbox'
alias rd='rails destroy'
alias rdb='rails dbconsole'
alias rg='rails generate'
@@ -55,6 +58,7 @@ alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
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'
diff --git a/plugins/rake-fast/README.md b/plugins/rake-fast/README.md
index f56142f69..1417befa1 100644
--- a/plugins/rake-fast/README.md
+++ b/plugins/rake-fast/README.md
@@ -2,22 +2,34 @@
Fast rake autocompletion plugin.
-This script caches the output for later usage and significantly speeds it up. It generates a .rake_tasks cache file in parallel to the Rakefile. It also checks the file modification dates to see if it needs to regenerate the cache file.
+This plugin caches the output for later usage and significantly speeds it up.
+It generates a `.rake_tasks` cache file in parallel to the Rakefile. It also
+checks the file modification time to see if it needs to regenerate the cache
+file.
-This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/).
+This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/),
+which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/).
Think about that. 2006.
+----------
+
+Since August of 2016, it also checks if it's in a Rails project and looks at
+rake files inside `lib/tasks` and their modification time to know if the
+cache file needs to be regenerated.
+
## Installation
Just add the plugin to your `.zshrc`:
-```bash
-plugins=(foo bar rake-fast)
+```zsh
+plugins=(... rake-fast)
```
You might consider adding `.rake_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore)
## Usage
-`rake`, then press tab
+Type `rake`, then press tab.
+
+If you want to force the regeneration of the `.rake_tasks` file, run `rake_refresh`.
diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh
index d305eb1f0..ca80d86e1 100644
--- a/plugins/rake-fast/rake-fast.plugin.zsh
+++ b/plugins/rake-fast/rake-fast.plugin.zsh
@@ -1,14 +1,22 @@
-_rake_refresh () {
- if [ -f .rake_tasks ]; then
- rm .rake_tasks
- fi
- echo "Generating .rake_tasks..." > /dev/stderr
- _rake_generate
- cat .rake_tasks
+_rake_does_task_list_need_generating () {
+ [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] || { _is_rails_app && _tasks_changed }
}
-_rake_does_task_list_need_generating () {
- [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]]
+_is_rails_app () {
+ [[ -e "bin/rails" ]] || [[ -e "script/rails" ]]
+}
+
+_tasks_changed () {
+ local -a files
+ files=(lib/tasks lib/tasks/**/*(N))
+
+ for file in $files; do
+ if [[ "$file" -nt .rake_tasks ]]; then
+ return 0
+ fi
+ done
+
+ return 1
}
_rake_generate () {
@@ -16,14 +24,20 @@ _rake_generate () {
}
_rake () {
- if [ -f Rakefile ]; then
+ if [[ -f Rakefile ]]; then
if _rake_does_task_list_need_generating; then
- echo "\nGenerating .rake_tasks..." > /dev/stderr
+ echo "\nGenerating .rake_tasks..." >&2
_rake_generate
fi
- compadd `cat .rake_tasks`
+ compadd $(cat .rake_tasks)
fi
}
-
compdef _rake rake
-alias rake_refresh='_rake_refresh'
+
+rake_refresh () {
+ [[ -f .rake_tasks ]] && rm -f .rake_tasks
+
+ echo "Generating .rake_tasks..." >&2
+ _rake_generate
+ cat .rake_tasks
+}
diff --git a/plugins/react-native/README.md b/plugins/react-native/README.md
new file mode 100644
index 000000000..980246cf1
--- /dev/null
+++ b/plugins/react-native/README.md
@@ -0,0 +1,29 @@
+# React Native plugin
+
+This plugin adds completion for [`react-native`](https://facebook.github.io/react-native/).
+It also defines a few [aliases](#aliases) for the commands more frequently used.
+
+To enable, add `react-native` to your `plugins` array in your zshrc file:
+
+```zsh
+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"` |
+| _Logging_ |
+| **rnland** | `react-native log-android` |
+| **rnlios** | `react-native log-ios` |
diff --git a/plugins/react-native/_react-native b/plugins/react-native/_react-native
new file mode 100644
index 000000000..893ac040a
--- /dev/null
+++ b/plugins/react-native/_react-native
@@ -0,0 +1,32 @@
+#compdef react-native
+#autoload
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'init:<ProjectName> generates a new project and installs its dependencies'
+ 'android:creates an empty android project'
+ 'start:starts the webserver'
+ 'run-ios:builds your app and starts it on iOS simulator'
+ 'run-android:builds your app and starts it on a connected Android emulator or device'
+ 'new-library:generates a native library bridge'
+ 'bundle:builds the javascript bundle for offline use'
+ 'unbundle:builds javascript as "unbundle" for offline use'
+ 'link:[options] <packageName> links all native dependencies'
+ 'unlink:[options] <packageName> unlink native dependency'
+ 'install:[options] <packageName> install and link native dependencies'
+ 'uninstall:[options] <packageName> uninstall and unlink native dependencies'
+ "upgrade:upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install"
+ 'log-android:starts adb logcat'
+ 'log-ios:starts iOS device syslog tail'
+)
+
+
+_arguments \
+ '(--version)--version[show version]' \
+ '(--help)--help[show help]' \
+ '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "react-native subcommand" _1st_arguments
+ return
+fi
diff --git a/plugins/react-native/react-native.plugin.zsh b/plugins/react-native/react-native.plugin.zsh
new file mode 100644
index 000000000..0566941a1
--- /dev/null
+++ b/plugins/react-native/react-native.plugin.zsh
@@ -0,0 +1,14 @@
+alias rn='react-native'
+alias rns='react-native start'
+alias rnlink='react-native link'
+
+alias rnand='react-native run-android'
+alias rnios='react-native run-ios'
+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 rnios6s='react-native run-ios --simulator "iPhone 6s"'
+
+alias rnland='react-native log-android'
+alias rnlios='react-native log-ios'
diff --git a/plugins/rust/_rust b/plugins/rust/_rust
new file mode 100644
index 000000000..f4e8f6f78
--- /dev/null
+++ b/plugins/rust/_rust
@@ -0,0 +1,191 @@
+#compdef rustc
+
+local -a _rustc_opts_switches _rustc_opts_lint _rustc_opts_debug
+
+typeset -A opt_args
+
+_rustc_debuginfo_levels=(
+ "0[no debug info]"
+ "1[line-tables only (for stacktraces and breakpoints)]"
+ "2[full debug info with variable and type information (same as -g)]"
+)
+
+_rustc_crate_types=(
+ 'bin'
+ 'lib'
+ 'rlib'
+ 'dylib'
+ 'staticlib'
+)
+
+_rustc_emit_types=(
+ 'asm'
+ 'bc'
+ 'ir'
+ 'obj'
+ 'link'
+)
+_rustc_pretty_types=(
+ 'normal[un-annotated source]'
+ 'expanded[crates expanded]'
+ 'typed[crates expanded, with type annotations]'
+ 'identified[fully parenthesized, AST nodes and blocks with IDs]'
+ 'flowgraph=[graphviz formatted flowgraph for node]:NODEID:'
+)
+_rustc_color_types=(
+ 'auto[colorize, if output goes to a tty (default)]'
+ 'always[always colorize output]'
+ 'never[never colorize output]'
+)
+
+_rustc_opts_vals=(
+ --crate-name='[Specify the name of the crate being built]'
+ --crate-type='[Comma separated list of types of crates for the compiler to emit]:TYPES:_values -s "," "Crate types" "$_rustc_crate_types[@]"'
+ --emit='[Comma separated list of types of output for the compiler to emit]:TYPES:_values -s "," "Emit Targets" "$_rustc_emit_types[@]"'
+ --debuginfo='[Emit DWARF debug info to the objects created]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"'
+ --dep-info='[Output dependency info to <filename> after compiling]::FILE:_files -/'
+ --sysroot='[Override the system root]:PATH:_files -/'
+ --cfg='[Configure the compilation environment]:SPEC:'
+ --out-dir='[Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. (default the current directory)]:DIR:_files -/'
+ -o'[Write output to <filename>. Ignored if more than one --emit is specified.]:FILENAME:_files'
+ --opt-level='[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)'
+ --pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"'
+ -L'[Add a directory to the library search path]:DIR:_files -/'
+ --target='[Target triple cpu-manufacturer-kernel\[-os\] to compile]:TRIPLE:'
+ --color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"'
+ {-v,--version}'[Print version info and exit]::VERBOSE:(verbose)'
+ --explain='[Provide a detailed explanation of an error message]:OPT:'
+ --extern'[Specify where an external rust library is located]:ARG:'
+)
+
+_rustc_opts_switches=(
+ -g'[Equivalent to --debuginfo=2]'
+ {-h,--help}'[Display this message]'
+ --no-analysis'[Parse and expand the output, but run no analysis or produce output]'
+ --no-trans'[Run all passes except translation; no output]'
+ -O'[Equivalent to --opt-level=2]'
+ --parse-only'[Parse only; do not compile, assemble, or link]'
+ --print-crate-name'[Output the crate name and exit]'
+ --print-file-name'[Output the file(s) that would be written if compilation continued and exit]'
+ --test'[Build a test harness]'
+)
+_rustc_opts_codegen=(
+ 'ar=[Path to the archive utility to use when assembling archives.]:BIN:_path_files'
+ 'linker=[Path to the linker utility to use when linking libraries, executables, and objects.]:BIN:_path_files'
+ 'link-args=[A space-separated list of extra arguments to pass to the linker when the linker is invoked.]:ARGS:'
+ 'target-cpu=[Selects a target processor. If the value is "help", then a list of available CPUs is printed.]:CPU:'
+ 'target-feature=[A space-separated list of features to enable or disable for the target. A preceding "+" enables a feature while a preceding "-" disables it. Available features can be discovered through target-cpu=help.]:FEATURE:'
+ 'passes=[A space-separated list of extra LLVM passes to run. A value of "list" will cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager.]:LIST:'
+ 'llvm-args=[A space-separated list of arguments to pass through to LLVM.]:ARGS:'
+ 'save-temps[If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated throughout compilation in the output directory.]'
+ 'rpath[If specified, then the rpath value for dynamic libraries will be set in either dynamic library or executable outputs.]'
+ 'no-prepopulate-passes[Suppresses pre-population of the LLVM pass manager that is run over the module.]'
+ 'no-vectorize-loops[Suppresses running the loop vectorization LLVM pass, regardless of optimization level.]'
+ 'no-vectorize-slp[Suppresses running the LLVM SLP vectorization pass, regardless of optimization level.]'
+ 'soft-float[Generates software floating point library calls instead of hardware instructions.]'
+ 'prefer-dynamic[Prefers dynamic linking to static linking.]'
+ "no-integrated-as[Force usage of an external assembler rather than LLVM's integrated one.]"
+ 'no-redzone[disable the use of the redzone]'
+ 'relocation-model=[The relocation model to use. (default: pic)]:MODEL:(pic static dynamic-no-pic)'
+ 'code-model=[choose the code model to use (llc -code-model for details)]:MODEL:'
+ 'metadata=[metadata to mangle symbol names with]:VAL:'
+ 'extra-filenames=[extra data to put in each output filename]:VAL:'
+ 'codegen-units=[divide crate into N units to optimize in parallel]:N:'
+ 'help[Show all codegen options]'
+)
+
+_rustc_opts_lint=(
+ 'help[Show a list of all lints]'
+ 'experimental[detects use of #\[experimental\] items]'
+ 'heap-memory[use of any (Box type or @ type) heap memory]'
+ 'managed-heap-memory[use of managed (@ type) heap memory]'
+ 'missing-doc[detects missing documentation for public members]'
+ 'non-uppercase-statics[static constants should have uppercase identifiers]'
+ 'owned-heap-memory[use of owned (~ type) heap memory]'
+ 'unnecessary-qualification[detects unnecessarily qualified names]'
+ 'unsafe-block[usage of an `unsafe` block]'
+ 'unstable[detects use of #\[unstable\] items (incl. items with no stability attribute)]'
+ 'unused-result[unused result of an expression in a statement]'
+ 'variant-size-difference[detects enums with widely varying variant sizes]'
+ 'ctypes[proper use of libc types in foreign modules]'
+ 'dead-assignment[detect assignments that will never be read]'
+ 'dead-code[detect piece of code that will never be used]'
+ 'deprecated[detects use of #\[deprecated\] items]'
+ 'non-camel-case-types[types, variants and traits should have camel case names]'
+ 'non-snake-case[methods, functions, lifetime parameters and modules should have snake case names]'
+ 'path-statement[path statements with no effect]'
+ 'raw-pointer-deriving[uses of #\[deriving\] with raw pointers are rarely correct]'
+ 'type-limits[comparisons made useless by limits of the types involved]'
+ 'type-overflow[literal out of range for its type]'
+ 'unnecessary-allocation[detects unnecessary allocations that can be eliminated]'
+ 'unnecessary-parens[`if`, `match`, `while` and `return` do not need parentheses]'
+ 'unreachable-code[detects unreachable code]'
+ 'unrecognized-lint[unrecognized lint attribute]'
+ 'unsigned-negate[using an unary minus operator on unsigned type]'
+ 'unused-attribute[detects attributes that were not used by the compiler]'
+ 'unused-imports[imports that are never used]'
+ 'unused-must-use[unused result of a type flagged as #\[must_use\]]'
+ "unused-mut[detect mut variables which don't need to be mutable]"
+ 'unused-unsafe[unnecessary use of an `unsafe` block]'
+ 'unused-variable[detect variables which are not used in any way]'
+ 'visible-private-types[detect use of private types in exported type signatures]'
+ 'warnings[mass-change the level for lints which produce warnings]'
+ 'while-true[suggest using `loop { }` instead of `while true { }`]'
+ 'unknown-crate-type[unknown crate type found in #\[crate_type\] directive]'
+ 'unknown-features[unknown features found in crate-level #\[feature\] directives]'
+ 'bad-style[group of non_camel_case_types, non_snake_case, non_uppercase_statics]'
+ 'unused[group of unused_imports, unused_variable, dead_assignment, dead_code, unused_mut, unreachable_code]'
+)
+
+_rustc_opts_debug=(
+ 'verbose[in general, enable more debug printouts]'
+ 'time-passes[measure time of each rustc pass]'
+ 'count-llvm-insns[count where LLVM instrs originate]'
+ 'time-llvm-passes[measure time of each LLVM pass]'
+ 'trans-stats[gather trans statistics]'
+ 'asm-comments[generate comments into the assembly (may change behavior)]'
+ 'no-verify[skip LLVM verification]'
+ 'borrowck-stats[gather borrowck statistics]'
+ 'no-landing-pads[omit landing pads for unwinding]'
+ 'debug-llvm[enable debug output from LLVM]'
+ 'show-span[show spans for compiler debugging]'
+ 'count-type-sizes[count the sizes of aggregate types]'
+ 'meta-stats[gather metadata statistics]'
+ 'no-opt[do not optimize, even if -O is passed]'
+ 'print-link-args[Print the arguments passed to the linker]'
+ 'gc[Garbage collect shared data (experimental)]'
+ 'print-llvm-passes[Prints the llvm optimization passes being run]'
+ 'lto[Perform LLVM link-time optimizations]'
+ 'ast-json[Print the AST as JSON and halt]'
+ 'ast-json-noexpand[Print the pre-expansion AST as JSON and halt]'
+ 'ls[List the symbols defined by a library crate]'
+ 'save-analysis[Write syntax and type analysis information in addition to normal output]'
+ 'flowgraph-print-loans[Include loan analysis data in --pretty flowgraph output]'
+ 'flowgraph-print-moves[Include move analysis data in --pretty flowgraph output]'
+ 'flowgraph-print-assigns[Include assignment analysis data in --pretty flowgraph output]'
+ 'flowgraph-print-all[Include all dataflow analysis data in --pretty flowgraph output]'
+)
+
+_rustc_opts_fun_lint(){
+ _values -s , 'options' \
+ "$_rustc_opts_lint[@]"
+}
+
+_rustc_opts_fun_debug(){
+ _values 'options' "$_rustc_opts_debug[@]"
+}
+
+_rustc_opts_fun_codegen(){
+ _values 'options' "$_rustc_opts_codegen[@]"
+}
+
+_arguments -s : \
+ '(-W --warn)'{-W,--warn=}'[Set lint warnings]:lint options:_rustc_opts_fun_lint' \
+ '(-A --allow)'{-A,--allow=}'[Set lint allowed]:lint options:_rustc_opts_fun_lint' \
+ '(-D --deny)'{-D,--deny=}'[Set lint denied]:lint options:_rustc_opts_fun_lint' \
+ '(-F --forbid)'{-F,--forbid=}'[Set lint forbidden]:lint options:_rustc_opts_fun_lint' \
+ '*-Z[Set internal debugging options]:debug options:_rustc_opts_fun_debug' \
+ '*-C[Set internal Codegen options]:codegen options:_rustc_opts_fun_codegen' \
+ "$_rustc_opts_switches[@]" \
+ "$_rustc_opts_vals[@]" \
+ '::files:_files -g "*.rs"'
diff --git a/plugins/sbt/sbt.plugin.zsh b/plugins/sbt/sbt.plugin.zsh
index 203c691f5..15acfec4f 100644
--- a/plugins/sbt/sbt.plugin.zsh
+++ b/plugins/sbt/sbt.plugin.zsh
@@ -21,3 +21,4 @@ alias sbr='sbt run'
alias sbrm='sbt run-main'
alias sbu='sbt update'
alias sbx='sbt test'
+alias sba='sbt assembly'
diff --git a/plugins/scala/_scala b/plugins/scala/_scala
index c4ccb37d3..80434680c 100644
--- a/plugins/scala/_scala
+++ b/plugins/scala/_scala
@@ -152,10 +152,10 @@ Y_opts=(
"-Ydump-classes+[Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders)]:output directory:_files -/"
"-Yeta-expand-keeps-star[Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.]"
"-Ygen-javap+[Generate a parallel output directory of .javap files]:output directory:_files -/"
- "-Yinfer-argument-types[Infer types for arguments of overriden methods]"
+ "-Yinfer-argument-types[Infer types for arguments of overridden methods]"
"-Yinline[Perform inlining when possible]"
"-Yinline-handlers[Perform exception handler inlining when possible]"
- "-Yinline-warnings[Emit inlining warnings (normally surpressed due to high volume)]"
+ "-Yinline-warnings[Emit inlining warnings (normally suppressed due to high volume)]"
"-Yinvalidate+[Invalidate classpath entry before run]:classpath entry"
"-Ylinearizer\:-[Linearizer to use (default\: rpo)]:linearizer:(normal dfs rpo dump)"
"-Ylog-classpath[Output information about what classpath is being applied]"
diff --git a/plugins/shrink-path/README.md b/plugins/shrink-path/README.md
new file mode 100644
index 000000000..51fa8a051
--- /dev/null
+++ b/plugins/shrink-path/README.md
@@ -0,0 +1,68 @@
+# A plugin to shrink directory paths for brevity and pretty-printing
+
+
+## Examples
+
+For this directory tree:
+```
+ /home/
+ me/
+ foo/
+ bar/
+ quux/
+ biz/ # The prefix b is ambiguous between bar and biz.
+```
+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
+```
+
+
+## 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)>'
+```
+
+The following options are available:
+
+```
+ -f, --fish fish simulation, equivalent to -l -s -t.
+ -l, --last Print the last directory's full name.
+ -s, --short Truncate directory names to the first character. Without
+ -s, names are truncated without making them ambiguous.
+ -t, --tilde Substitute ~ for the home directory.
+ -T, --nameddirs Substitute named directories as well.
+```
+
+The long options can also be set via zstyle, like
+```
+ zstyle :prompt:shrink_path fish yes
+```
+
+Note: Directory names containing two or more consecutive spaces are not yet
+supported.
+
+
+## License
+
+Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>
+
+License: WTFPL <http://sam.zoy.org/wtfpl>
+
+Ref: http://www.zsh.org/mla/workers/2009/msg00415.html
+ http://www.zsh.org/mla/workers/2009/msg00419.html
+
+
+## Misc
+
+Keywords: prompt directory truncate shrink collapse fish
diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh
new file mode 100644
index 000000000..f111962a5
--- /dev/null
+++ b/plugins/shrink-path/shrink-path.plugin.zsh
@@ -0,0 +1,127 @@
+# Shrink directory paths, e.g. /home/me/foo/bar/quux -> ~/f/b/quux.
+#
+# 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)>'
+#
+# The following options are available:
+#
+# -f, --fish fish simulation, equivalent to -l -s -t.
+# -l, --last Print the last directory's full name.
+# -s, --short Truncate directory names to the first character. Without
+# -s, names are truncated without making them ambiguous.
+# -t, --tilde Substitute ~ for the home directory.
+# -T, --nameddirs Substitute named directories as well.
+#
+# The long options can also be set via zstyle, like
+# zstyle :prompt:shrink_path fish yes
+#
+# Note: Directory names containing two or more consecutive spaces are not yet
+# supported.
+#
+# Keywords: prompt directory truncate shrink collapse fish
+#
+# Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>
+# License: WTFPL <http://sam.zoy.org/wtfpl>
+#
+# Ref: http://www.zsh.org/mla/workers/2009/msg00415.html
+# http://www.zsh.org/mla/workers/2009/msg00419.html
+
+shrink_path () {
+ setopt localoptions
+ setopt rc_quotes null_glob
+
+ typeset -i lastfull=0
+ typeset -i short=0
+ typeset -i tilde=0
+ typeset -i named=0
+
+ if zstyle -t ':prompt:shrink_path' fish; then
+ lastfull=1
+ short=1
+ tilde=1
+ fi
+ if zstyle -t ':prompt:shrink_path' nameddirs; then
+ tilde=1
+ named=1
+ fi
+ zstyle -t ':prompt:shrink_path' last && lastfull=1
+ zstyle -t ':prompt:shrink_path' short && short=1
+ zstyle -t ':prompt:shrink_path' tilde && tilde=1
+
+ while [[ $1 == -* ]]; do
+ case $1 in
+ -f|--fish)
+ lastfull=1
+ short=1
+ tilde=1
+ ;;
+ -h|--help)
+ print 'Usage: shrink_path [-f -l -s -t] [directory]'
+ print ' -f, --fish fish-simulation, like -l -s -t'
+ print ' -l, --last Print the last directory''s full name'
+ print ' -s, --short Truncate directory names to the first character'
+ print ' -t, --tilde Substitute ~ for the home directory'
+ print ' -T, --nameddirs Substitute named directories as well'
+ print 'The long options can also be set via zstyle, like'
+ print ' zstyle :prompt:shrink_path fish yes'
+ return 0
+ ;;
+ -l|--last) lastfull=1 ;;
+ -s|--short) short=1 ;;
+ -t|--tilde) tilde=1 ;;
+ -T|--nameddirs)
+ tilde=1
+ named=1
+ ;;
+ esac
+ shift
+ done
+
+ typeset -a tree expn
+ typeset result part dir=${1-$PWD}
+ typeset -i i
+
+ [[ -d $dir ]] || return 0
+
+ if (( named )) {
+ for part in ${(k)nameddirs}; {
+ [[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/${nameddirs[$part]}/\~$part}
+ }
+ }
+ (( tilde )) && dir=${dir/$HOME/\~}
+ tree=(${(s:/:)dir})
+ (
+ unfunction chpwd 2> /dev/null
+ if [[ $tree[1] == \~* ]] {
+ cd ${~tree[1]}
+ result=$tree[1]
+ shift tree
+ } else {
+ cd /
+ }
+ for dir in $tree; {
+ if (( lastfull && $#tree == 1 )) {
+ result+="/$tree"
+ break
+ }
+ expn=(a b)
+ part=''
+ i=0
+ until [[ (( ${#expn} == 1 )) || $dir = $expn || $i -gt 99 ]] do
+ (( i++ ))
+ part+=$dir[$i]
+ expn=($(echo ${part}*(-/)))
+ (( short )) && break
+ done
+ result+="/$part"
+ cd $dir
+ shift tree
+ }
+ echo ${result:-/}
+ )
+}
+
+## vim:ft=zsh
diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
new file mode 100644
index 000000000..00af42f01
--- /dev/null
+++ b/plugins/ssh-agent/README.md
@@ -0,0 +1,38 @@
+# ssh-agent plugin
+
+This plugin starts automatically `ssh-agent` to set up and load whichever
+credentials you want for ssh connections.
+
+To enable it, add `ssh-agent` to your plugins:
+
+```zsh
+plugins=(... ssh-agent)
+```
+
+## Instructions
+
+To enable **agent forwarding support** add the following to your zshrc file:
+
+```zsh
+zstyle :omz:plugins:ssh-agent agent-forwarding on
+```
+
+To **load multiple identities** use the `identities` style, For example:
+
+```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.
+
+```zsh
+zstyle :omz:plugins:ssh-agent lifetime 4h
+```
+
+## Credits
+
+Based on code from Joseph M. Reagle: http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
+
+Agent-forwarding support based on ideas from Florent Thoumie and Jonas Pfenniger
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 610ad34dc..20f97c6f1 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -1,79 +1,42 @@
-#
-# INSTRUCTIONS
-#
-# 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:
-#
-# 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.
-#
-# zstyle :omz:plugins:ssh-agent lifetime 4h
-#
-# CREDITS
-#
-# Based on code from Joseph M. Reagle
-# http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
-#
-# Agent forwarding support based on ideas from
-# Florent Thoumie and Jonas Pfenniger
-#
+typeset _agent_forwarding _ssh_env_cache
-local _plugin__ssh_env
-local _plugin__forwarding
+function _start_agent() {
+ local lifetime
+ local -a identities
-function _plugin__start_agent()
-{
- local -a identities
- local lifetime
- zstyle -s :omz:plugins:ssh-agent lifetime lifetime
+ # start ssh-agent and setup environment
+ zstyle -s :omz:plugins:ssh-agent lifetime lifetime
- # start ssh-agent and setup environment
- /usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' > ${_plugin__ssh_env}
- chmod 600 ${_plugin__ssh_env}
- . ${_plugin__ssh_env} > /dev/null
+ 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
- zstyle -a :omz:plugins:ssh-agent identities identities
- echo starting ssh-agent...
+ # load identies
+ zstyle -a :omz:plugins:ssh-agent identities identities
- /usr/bin/ssh-add $HOME/.ssh/${^identities}
+ echo starting ssh-agent...
+ ssh-add $HOME/.ssh/${^identities}
}
# Get the filename to store/lookup the environment from
-if (( $+commands[scutil] )); then
- # It's OS X!
- _plugin__ssh_env="$HOME/.ssh/environment-$(scutil --get ComputerName)"
-else
- _plugin__ssh_env="$HOME/.ssh/environment-$HOST"
-fi
+_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
# test if agent-forwarding is enabled
-zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding
-if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
- # Add a nifty symlink for screen/tmux if agent forwarding
- [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
-
-elif [ -f "${_plugin__ssh_env}" ]; then
- # Source SSH settings, if applicable
- . ${_plugin__ssh_env} > /dev/null
- ps x | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || {
- _plugin__start_agent;
- }
+zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
+
+if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
+ # Add a nifty symlink for screen/tmux if agent forwarding
+ [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
+elif [[ -f "$_ssh_env_cache" ]]; then
+ # Source SSH settings, if applicable
+ . $_ssh_env_cache > /dev/null
+ ps x | grep ssh-agent | grep -q $SSH_AGENT_PID || {
+ _start_agent
+ }
else
- _plugin__start_agent;
+ _start_agent
fi
# tidy up after ourselves
-unfunction _plugin__start_agent
-unset _plugin__forwarding
-unset _plugin__ssh_env
-
+unset _agent_forwarding _ssh_env_cache
+unfunction _start_agent
diff --git a/plugins/sublime/README.md b/plugins/sublime/README.md
index e1e666f05..7b02d8428 100644
--- a/plugins/sublime/README.md
+++ b/plugins/sublime/README.md
@@ -15,5 +15,7 @@ Plugin for Sublime Text, a cross platform text and code editor, available for Li
* If `st` is passed a file, open it in Sublime Text
* If `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text
-
- * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files. \ No newline at end of file
+
+ * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected 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.
diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
index a5d63cde6..f84b7032a 100644
--- a/plugins/sublime/sublime.plugin.zsh
+++ b/plugins/sublime/sublime.plugin.zsh
@@ -1,4 +1,4 @@
-if [[ $('uname') == 'Linux' ]]; then
+if [[ "$OSTYPE" == linux* ]]; then
local _sublime_linux_paths > /dev/null 2>&1
_sublime_linux_paths=(
"$HOME/bin/sublime_text"
@@ -56,3 +56,32 @@ elif [[ "$OSTYPE" = 'cygwin' ]]; then
fi
alias stt='st .'
+
+find_project()
+{
+ local PROJECT_ROOT="${PWD}"
+ local FINAL_DEST="."
+
+ while [[ $PROJECT_ROOT != "/" && ! -d "$PROJECT_ROOT/.git" ]]; do
+ PROJECT_ROOT=$(dirname $PROJECT_ROOT)
+ done
+
+ 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
+
+ if [[ $SUBL_DIR != "/" ]]; then
+ FINAL_DEST="$SUBL_DIR/$PROJECT_NAME.sublime-project"
+ else
+ FINAL_DEST=$PROJECT_ROOT
+ fi
+ fi
+
+ st $FINAL_DEST
+}
+
+alias stp=find_project
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index 0ba8bed5b..0b843822e 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -2,7 +2,7 @@
# Description
# -----------
#
-# sudo will be inserted before the command
+# sudo or sudoedit will be inserted before the command
#
# ------------------------------------------------------------------------------
# Authors
@@ -16,6 +16,12 @@ sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
+ elif [[ $BUFFER == $EDITOR\ * ]]; then
+ LBUFFER="${LBUFFER#$EDITOR }"
+ LBUFFER="sudoedit $LBUFFER"
+ elif [[ $BUFFER == sudoedit\ * ]]; then
+ LBUFFER="${LBUFFER#sudoedit }"
+ LBUFFER="$EDITOR $LBUFFER"
else
LBUFFER="sudo $LBUFFER"
fi
diff --git a/plugins/suse/suse.plugin.zsh b/plugins/suse/suse.plugin.zsh
index afd8ecabd..f7215528b 100644
--- a/plugins/suse/suse.plugin.zsh
+++ b/plugins/suse/suse.plugin.zsh
@@ -1,4 +1,4 @@
-#Alias for Zypper according to the offical Zypper's alias
+#Alias for Zypper according to the official Zypper's alias
#Main commands
alias z='sudo zypper' #call zypper
@@ -51,7 +51,7 @@ alias zrr='sudo zypper rr' #remove repositories
alias zas='sudo zypper as' #adds a service specified by URI to the system
alias zms='sudo zypper ms' #modify properties of specified services
alias zrefs='sudo zypper refs' #refreshing a service mean executing the service's special task
-alias zrs='sudo zypper rs' #remove specified repository index service from the sytem
+alias zrs='sudo zypper rs' #remove specified repository index service from the system
alias zls='sudo zypper ls' #list services defined on the system
#Package Locks Management commands
diff --git a/plugins/svn/README.md b/plugins/svn/README.md
new file mode 100644
index 000000000..1f7b70c86
--- /dev/null
+++ b/plugins/svn/README.md
@@ -0,0 +1,67 @@
+# `svn` plugin
+
+This plugin adds some utility functions to display additional information regarding your current
+svn repository. See http://subversion.apache.org/ for the full svn documentation.
+
+To use it, add `svn` to your plugins array:
+
+```zsh
+plugins=(... svn)
+```
+
+## Functions
+
+| Command | Description |
+|:----------------------|:--------------------------------------------|
+| `svn_prompt_info` | Shows svn prompt in themes |
+| `in_svn` | Checks if we're in an svn repository |
+| `svn_get_repo_name` | Get repository name |
+| `svn_get_branch_name` | Get branch name (see [caveats](#caveats)) |
+| `svn_get_rev_nr` | Get revision number |
+| `svn_dirty` | Checks if there are changes in the svn repo |
+
+## Caveats
+
+The plugin expects the first directory to be the current branch / tag / trunk. So it returns
+the first path element if you don't use branches.
+
+## Usage on themes
+
+To use this in the `agnoster` theme follow these instructions:
+
+1. Enable the svn plugin
+
+2. Add the following lines to your `zshrc` file:
+
+ ```shell
+ prompt_svn() {
+ local rev branch
+ if in_svn; then
+ rev=$(svn_get_rev_nr)
+ branch=$(svn_get_branch_name)
+ if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then
+ prompt_segment yellow black
+ echo -n "$rev@$branch"
+ echo -n "±"
+ else
+ prompt_segment green black
+ echo -n "$rev@$branch"
+ fi
+ fi
+ }
+ ```
+
+3. Override the agnoster `build_prompt()` function:
+
+ ```zsh
+ build_prompt() {
+ RETVAL=$?
+ prompt_status
+ prompt_context
+ prompt_dir
+ prompt_git
+ prompt_svn
+ prompt_end
+ }
+ ```
+
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
index 816055afe..fbc9ee538 100644
--- a/plugins/svn/svn.plugin.zsh
+++ b/plugins/svn/svn.plugin.zsh
@@ -1,9 +1,7 @@
-# vim:ft=zsh ts=2 sw=2 sts=2
-#
-function svn_prompt_info() {
+svn_prompt_info() {
local _DISPLAY
if in_svn; then
- if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
+ if [[ "$SVN_SHOW_BRANCH" = true ]]; then
unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name)
else
@@ -16,23 +14,20 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S
}
-function in_svn() {
- if $(svn info >/dev/null 2>&1); then
- return 0
- fi
- return 1
+in_svn() {
+ svn info >/dev/null 2>&1
}
-function svn_get_repo_name() {
+svn_get_repo_name() {
if in_svn; then
- svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
- svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
+ LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT
+ LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p"
fi
}
-function svn_get_branch_name() {
+svn_get_branch_name() {
local _DISPLAY=$(
- svn info 2> /dev/null | \
+ LANG=C svn info 2> /dev/null | \
awk -F/ \
'/^URL:/ { \
for (i=0; i<=NF; i++) { \
@@ -44,24 +39,28 @@ function svn_get_branch_name() {
} \
}'
)
-
- if [ "x$_DISPLAY" = "x" ]; then
+
+ if [[ -z "$_DISPLAY" ]]; then
svn_get_repo_name
else
echo $_DISPLAY
fi
}
-function svn_get_rev_nr() {
+svn_get_rev_nr() {
if in_svn; then
- svn info 2> /dev/null | sed -n 's/Revision:\ //p'
+ LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p'
fi
}
-function svn_dirty_choose() {
+svn_dirty() {
+ svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
+}
+
+svn_dirty_choose() {
if in_svn; then
- local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
- if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
+ local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p')
+ if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
else
@@ -71,14 +70,13 @@ function svn_dirty_choose() {
fi
}
-function svn_dirty() {
- svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
+svn_dirty_pwd () {
+ svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
}
-function svn_dirty_choose_pwd () {
+svn_dirty_choose_pwd () {
if in_svn; then
- local root=$PWD
- if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
+ if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
else
@@ -87,9 +85,3 @@ function svn_dirty_choose_pwd () {
fi
fi
}
-
-function svn_dirty_pwd () {
- svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
-}
-
-
diff --git a/plugins/swiftpm/README.md b/plugins/swiftpm/README.md
new file mode 100644
index 000000000..07ca25651
--- /dev/null
+++ b/plugins/swiftpm/README.md
@@ -0,0 +1,22 @@
+# Swift Package Manager
+
+## 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).
+
+To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`:
+
+```zsh
+plugins=(... swiftpm)
+```
+
+## Aliases
+
+| Alias | Description | Command |
+|-------|-------------------------------------|------------------------------------|
+| `spi` | Initialize a new package | `swift package init` |
+| `spf` | Fetch package dependencies | `swift package fetch` |
+| `spu` | Update package dependencies | `swift package update` |
+| `spx` | Generates an Xcode project | `swift package generate-xcodeproj` |
+| `sps` | Print the resolved dependency graph | `swift package show-dependencies` |
+| `spd` | Print parsed Package.swift as JSON | `swift package dump-package` |
diff --git a/plugins/swiftpm/swiftpm.plugin.zsh b/plugins/swiftpm/swiftpm.plugin.zsh
new file mode 100644
index 000000000..ef872ea34
--- /dev/null
+++ b/plugins/swiftpm/swiftpm.plugin.zsh
@@ -0,0 +1,8 @@
+# Some aliases to make your life with the Swift Package Manager faster ✌️
+
+alias spi='swift package init'
+alias spf='swift package fetch'
+alias spu='swift package update'
+alias spx='swift package generate-xcodeproj'
+alias sps='swift package show-dependencies'
+alias spd='swift package dump-package'
diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh
index 98a2321db..c2a1affad 100644
--- a/plugins/symfony2/symfony2.plugin.zsh
+++ b/plugins/symfony2/symfony2.plugin.zsh
@@ -22,6 +22,8 @@ alias sf='`_symfony_console`'
alias sfcl='sf cache:clear'
alias sfsr='sf server:run -vvv'
alias sfcw='sf cache:warmup'
-alias sfroute='sf router:debug'
-alias sfcontainer='sf container:debug'
+alias sfroute='sf debug:router'
+alias sfcontainer='sf debug:container'
alias sfgb='sf generate:bundle'
+alias sfdev='sf --env=dev'
+alias sfprod='sf --env=prod'
diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh
index b19793557..5a35ecbc7 100644
--- a/plugins/systemd/systemd.plugin.zsh
+++ b/plugins/systemd/systemd.plugin.zsh
@@ -1,6 +1,6 @@
user_commands=(
list-units is-active status show help list-unit-files
- is-enabled list-jobs show-environment cat)
+ is-enabled list-jobs show-environment cat list-timers)
sudo_commands=(
start stop reload restart try-restart isolate kill
diff --git a/plugins/taskwarrior/_task b/plugins/taskwarrior/_task
index afa30d45a..46628be94 100644
--- a/plugins/taskwarrior/_task
+++ b/plugins/taskwarrior/_task
@@ -1,6 +1,6 @@
#compdef task
#
-# Copyright 2010 - 2015 Johannes Schlatow
+# Copyright 2010 - 2016 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -26,7 +26,6 @@
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects))
_task_tags=($(task _tags))
-_task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_columns=($(task _columns))
@@ -139,8 +138,10 @@ task_dates=(
)
local -a task_zshids
-_regex_words values 'task IDs' $_task_zshids
-task_zshids=("$reply[@]")
+if (( $#_task_zshids )); then
+ _regex_words values 'task IDs' $_task_zshids
+ task_zshids=("$reply[@]")
+fi
_regex_words values 'task frequencies' \
'daily:Every day' \
diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
index 11740dc48..97c42a559 100644
--- a/plugins/terraform/_terraform
+++ b/plugins/terraform/_terraform
@@ -98,7 +98,7 @@ __push() {
'-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 comitted to version control. If no version control system is detected, Terraform will upload all files in path (parameter to the command).]'
+ '-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).]'
}
__refresh() {
diff --git a/plugins/textmate/textmate.plugin.zsh b/plugins/textmate/textmate.plugin.zsh
index 02813de9e..174511019 100644
--- a/plugins/textmate/textmate.plugin.zsh
+++ b/plugins/textmate/textmate.plugin.zsh
@@ -1,13 +1,14 @@
# If the tm command is called without an argument, open TextMate in the current directory
# If tm is passed a directory, cd to it and open it in TextMate
-# If tm is passed a file, open it in TextMate
+# If tm is passed anything else (i.e., a list of files and/or options), pass them all along
+# This allows easy opening of multiple files.
function tm() {
if [[ -z $1 ]]; then
mate .
- else
+ elif [[ -d $1 ]]; then
mate $1
- if [[ -d $1 ]]; then
- cd $1
- fi
+ cd $1
+ else
+ mate "$@"
fi
}
diff --git a/plugins/tig/README.md b/plugins/tig/README.md
new file mode 100644
index 000000000..bb24cd147
--- /dev/null
+++ b/plugins/tig/README.md
@@ -0,0 +1,16 @@
+# `tig` plugin
+
+This plugin adds some aliases for people who work with `tig` in
+a regular basis. To use it, add `tig` to your plugins array:
+
+```zsh
+plugins=(... tig)
+```
+
+## Features
+
+| Alias | Command | Description |
+|-------|----------------|-------------------------------------------------|
+| `tis` | `tig status` | Show git status |
+| `til` | `tig log` | Show git log |
+| `tib` | `tig blame -C` | `git-blame` a file detecting copies and renames |
diff --git a/plugins/tig/tig.plugin.zsh b/plugins/tig/tig.plugin.zsh
new file mode 100644
index 000000000..7e0c530ac
--- /dev/null
+++ b/plugins/tig/tig.plugin.zsh
@@ -0,0 +1,3 @@
+alias tis='tig status'
+alias til='tig log'
+alias tib='tig blame -C'
diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
index bc32c8907..fb514a44c 100644
--- a/plugins/tmux/tmux.plugin.zsh
+++ b/plugins/tmux/tmux.plugin.zsh
@@ -3,6 +3,7 @@
#
alias ta='tmux attach -t'
+alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
diff --git a/plugins/ubuntu/readme.md b/plugins/ubuntu/readme.md
index c9ef61f4e..5ad4bbcd2 100644
--- a/plugins/ubuntu/readme.md
+++ b/plugins/ubuntu/readme.md
@@ -10,7 +10,7 @@ By now you already can guess almost all aliases
There are two exeptions since ...
agu = sudo Apt-Get Update - we have ...
-agug = sudo Apt-Get UpGrade - as the exeptional 4 letter alias for a single command.
+agug = sudo Apt-Get UpGrade - as the exceptional 4 letter alias for a single command.
afs = Apt-File Search --regexp - this has the regexp switch on without being represented in the alias, I guess this makes sense since the debian plugin has it, I never used that command.
diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
index f08853643..60ff0457f 100644
--- a/plugins/ubuntu/ubuntu.plugin.zsh
+++ b/plugins/ubuntu/ubuntu.plugin.zsh
@@ -29,7 +29,6 @@ compdef _ppap ppap='sudo ppa-purge'
alias ag='sudo apt-get' # age - but without sudo
alias aga='sudo apt-get autoclean' # aac
-alias agar='sudo apt-get autoremove'
alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc
alias agd='sudo apt-get dselect-upgrade' # ads
@@ -44,7 +43,6 @@ alias agar='sudo apt-get autoremove'
compdef _ag ag='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean'
-compdef _agar agar='sudo apt-get autoremove'
compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean'
compdef _agd agd='sudo apt-get dselect-upgrade'
@@ -63,7 +61,7 @@ alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
# Misc. #####################################################################
# print all installed packages
-alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
+alias allpkgs='dpkg --get-selections | grep -v deinstall'
# Create a basic .deb package
alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
@@ -71,7 +69,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# apt-add-repository with automatic install/upgrade of the desired package
# Usage: aar ppa:xxxxxx/xxxxxx [packagename]
# If packagename is not given as 2nd argument the function will ask for it and guess the default by taking
-# the part after the / from the ppa name wich is sometimes the right name for the package you want to install
+# the part after the / from the ppa name which is sometimes the right name for the package you want to install
aar() {
if [ -n "$2" ]; then
PACKAGE=$2
@@ -110,7 +108,7 @@ apt-history () {
awk '{print $4"="$5}'
;;
list)
- zcat $(ls -rt /var/log/dpkg*)
+ zgrep --no-filename '' $(ls -rt /var/log/dpkg*)
;;
*)
echo "Parameters:"
diff --git a/plugins/urltools/urltools.plugin.zsh b/plugins/urltools/urltools.plugin.zsh
index 22327334d..fa337acba 100644
--- a/plugins/urltools/urltools.plugin.zsh
+++ b/plugins/urltools/urltools.plugin.zsh
@@ -11,9 +11,12 @@ fi
if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xnode" ) ]]; then
alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"'
-elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
- alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
- alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.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]))"'
+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])"'
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/_vagrant b/plugins/vagrant/_vagrant
index 764f89545..c5335e72e 100644
--- a/plugins/vagrant/_vagrant
+++ b/plugins/vagrant/_vagrant
@@ -26,10 +26,12 @@ _1st_arguments=(
'rsync:Syncs rsync synced folders to remote machine'
'rsync-auto:Syncs rsync synced folders automatically when files change'
'share:Shares your Vagrant environment with anyone in the world'
+ 'snapshot:Manage snapshots with the guest machine'
'ssh:SSH into the currently running environment'
'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh'
'status:Shows the status of the current Vagrant environment'
'suspend:Suspends the currently running vagrant environment'
+ 'snapshot:Used to manage snapshots with the guest machine'
'up:Creates the vagrant environment'
'version:Prints current and latest Vagrant version'
'--help:[TASK] Describe available tasks or one specific task'
diff --git a/plugins/vault/README.md b/plugins/vault/README.md
new file mode 100644
index 000000000..0f61c9410
--- /dev/null
+++ b/plugins/vault/README.md
@@ -0,0 +1,18 @@
+## Vault (https://www.vaultproject.io) autocomplete plugin
+
+- Adds autocomplete options for all vault commands.
+
+####Show help for all commands
+![General Help](http://i.imgur.com/yv5Db1r.png "Help for all commands")
+
+
+####Create new Vault token
+![Create token](http://i.imgur.com/xMegNgh.png "Create token")
+
+
+####Enable audit backends
+![Audit backends](http://i.imgur.com/fKLeiSF.png "Audit backends")
+
+
+
+Crafted with <3 by Valentin Bud ([@valentinbud](https://twitter.com/valentinbud)) \ No newline at end of file
diff --git a/plugins/vault/_vault b/plugins/vault/_vault
new file mode 100644
index 000000000..c5338dffa
--- /dev/null
+++ b/plugins/vault/_vault
@@ -0,0 +1,400 @@
+#compdef vault
+
+typeset -a main_args
+main_args=(
+ '(-version)-version[Prints the Vault version]'
+ '(-help)-help[Prints Vault Help]'
+)
+
+typeset -a general_args
+general_args=(
+ '(-help)-help[Prints Help]'
+ '(-address)-address=-[The address of the Vault server. Overrides the VAULT_ADDR environment variable if set.]:address:'
+ '(-ca-cert)-ca-cert=-[Path to a PEM encoded CA cert file to use to verify the Vault server SSL certificate. Overrides the VAULT_CACERT environment variable if set.]:file:_files -g "*.pem"'
+ '(-ca-path)-ca-path=-[Path to a directory of PEM encoded CA cert files to verify the Vault server SSL certificate. If both -ca-cert and -ca-path are specified, -ca-path is used.Overrides the VAULT_CAPATH environment variable if set.]:directory:_directories'
+ '(-client-cert)-client-cert=-[Path to a PEM encoded client certificate for TLS authentication to the Vault server. Must also specify -client-key. Overrides the VAULT_CLIENT_CERT environment variable if set.]:file:_files -g "*.pem"'
+ '(-client-key)-client-key=-[Path to an unencrypted PEM encoded private key matching the client certificate from -client-cert. Overrides the VAULT_CLIENT_KEY environment variable if set.]:file:_files -g "*.pem"'
+ '(-tls-skip-verify)-tls-skip-verify[Do not verify TLS certificate. This is highly not recommended. Verification will also be skipped if VAULT_SKIP_VERIFY is set.]'
+)
+
+typeset -a audit_enable_args
+audit_enable_args=(
+ '(-description)-description=-[A human-friendly description for the backend. This shows up only when querying the enabled backends.]:description:'
+ '(-id)-id=-[Specify a unique ID for this audit backend. This is purely for referencing this audit backend. By default this will be the backend type.]:id:'
+)
+
+typeset -a auth_args
+auth_args=(
+ '(-method)-method=-[Outputs help for the authentication method with the given name for the remote server. If this authentication method is not available, exit with code 1.]:method:(cert ldap github userpass app-id)'
+ '(-method-help)-method-help[If set, the help for the selected method will be shown.]'
+ '(-methods)-methods[List the available auth methods.]'
+ '(-no-verify)-no-verify[Do not verify the token after creation; avoids a use count]'
+)
+
+typeset -a auth_enable_args
+auth_enable_args=(
+ '(-description)-description=-[Human-friendly description of the purpose for the auth provider. This shows up in the auth-list command.]:description:'
+ '(-path)-path=-[Mount point for the auth provider. This defaults to the type of the mount. This will make the auth provider available at "/auth/<path>"]:path:'
+)
+
+typeset -a init_args
+init_args=(
+ '(-key-shares)-key-shares=-[(default: 5) The number of key shares to split the master key into.]:keyshares:'
+ '(-key-threshold)-key-threshold=-[(default: 3) The number of key shares required to reconstruct the master key.]:keythreshold:'
+ '(-pgp-keys)-pgp-keys[If provided, must be a comma-separated list of files on disk containing binary- or base64-format public PGP keys. The number of files must match "key-shares". The output unseal keys will encrypted and hex-encoded, in order, with the given public keys. If you want to use them with the "vault unseal" command, you will need to hex decode and decrypt; this will be the plaintext unseal key.]:pgpkeys:_files'
+)
+
+typeset -a mount_tune_args
+mount_tune_args=(
+ '(-default-lease-ttl)-default-lease-ttl=-[Default lease time-to-live for this backend. If not specified, uses the system default, or the previously set value. Set to "system" to explicitly set it to use the system default.]:defaultleasettl:'
+ '(-max-lease-ttl)-max-lease-ttl=-[Max lease time-to-live for this backend. If not specified, uses the system default, or the previously set value. Set to "system" to explicitly set it to use the system default.]:maxleasettl:'
+)
+
+typeset -a mount_args
+mount_args=(
+ $mount_tune_args
+ '(-path)-path=-[Mount point for the logical backend. This defauls to the type of the mount.]:path:'
+ '(-description)-description=-[Human-friendly description of the purpose for the mount. This shows up in the mounts command.]:description:'
+)
+
+typeset -a rekey_args
+rekey_args=(
+ $init_args
+ '(-init)-init[Initialize the rekey operation by setting the desired number of shares and the key threshold. This can only be done if no rekey is already initiated.]:init:'
+ '(-cancel)-cancel[Reset the rekey process by throwing away prior keys and the rekey configuration.]:cancel:'
+ '(-status)-status[Prints the status of the current rekey operation. This can be used to see the status without attempting to provide an unseal key.]:status:'
+)
+
+typeset -a ssh_args
+ssh_args=(
+ '(-role)-role[Role to be used to create the key. ]:role:'
+ '(-no-exec)-no-exec[Shows the credentials but does not establish connection.]:noexec:'
+ '(-mount-point)-mount-point[Mount point of SSH backend. If the backend is mounted at "ssh", which is the default as well, this parameter can be skipped.]:mountpoint:'
+ '(-format)-format[If no-exec option is enabled, then the credentials will be printed out and SSH connection will not be established. The format of the output can be "json" or "table". JSON output is useful when writing scripts. Default is "table".]:format:(json table)'
+)
+
+typeset -a token_create_args
+token_create_args=(
+ '(-id)-id=-[The token value that clients will use to authenticate with vault. If not provided this defaults to a 36 character UUID. A root token is required to specify the ID of a token.]:id:'
+ '(-display-name)-display-name=-[A display name to associate with this token. This is a non-security sensitive value used to help identify created secrets, i.e. prefixes.]:displayname:'
+ '(-ttl)-ttl=-[TTL to associate with the token. This option enables the tokens to be renewable.]:ttl:'
+ '*-metadata=-[Metadata to associate with the token. This shows up in the audit log. This can be specified multiple times.]:metadata:'
+ '(-orphan)-orphan[If specified, the token will have no parent. Only root tokens can create orphan tokens. This prevents the new token from being revoked with your token.]:orphan:'
+ '(-no-default-policy)-no-default-policy[If specified, the token will not have the "default" policy included in its policy set.]:nodefaultpolicy:'
+ '*-policy=-[Policy to associate with this token. This can be specified multiple times.]:policy:__vault_policies'
+ '(-use-limit)-use-limit=-[The number of times this token can be used until it is automatically revoked.]:uselimit:'
+ '(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)'
+)
+
+typeset -a server_args
+server_args=(
+ '*-config=-[Path to the configuration file or directory. This can be specified multiple times. If it is a directory, all files with a ".hcl" or ".json" suffix will be loaded.]:config:_files'
+ '-dev[Enables Dev mode. In this mode, Vault is completely in-memory and unsealed. Do not run the Dev server in production!]:dev:'
+ '-log-level=-[Log verbosity. Defaults to "info", will be outputtedto stderr. Supported values: "trace", "debug", "info", "warn", "err"]:loglevel:(trace debug info warn err)'
+)
+
+_vault_audit-list() {
+ _arguments : \
+ ${general_args[@]} && ret=0
+}
+
+_vault_audit-disable() {
+ # vault audit-list doesn't print the backend id so for now
+ # no *smart* autocompletion for this subcommand.
+ _arguments : \
+ ${general_args[@]} \
+ ':::(file syslog)' && ret=0
+}
+
+_vault_audit-enable() {
+ _arguments : \
+ ${general_args[@]} \
+ ${audit_enable_args[@]} \
+ ': :->backends' \
+ '*:: :->backendconfig' && ret=0
+
+ case $state in
+ backends)
+ local -a backends
+ backends=(
+ 'file:The "file" audit backend writes audit logs to a file.'
+ 'syslog:The "syslog" audit backend writes audit logs to syslog.'
+ )
+ _describe -t backends 'vault audit backends' backends && ret=0
+ ;;
+ backendconfig)
+ case ${line[1]} in
+ file)
+ _values -w "Audit Backend File" \
+ 'path[(required) - The path to where the file will be written. If this path exists, the audit backend will append to it.]:file:_files' \
+ 'log_raw[(optional) Should security sensitive information be logged raw. Defaults to "false".]:log_raw:(true false)' && ret=0
+ ;;
+ syslog)
+ _values -w "Audit Backend Syslog" \
+ 'facility[(optional) - The syslog facility to use. Defaults to "AUTH".]:facility:(kern user mail daemon auth syslog lpr news uucp authpriv ftp cron local0 local1 local2 local3 local4 local5 local6 local7)' \
+ 'tag[(optional) - The syslog tag to use. Defaults to "vault".]:tag:' \
+ 'log_raw[(optional) Should security sensitive information be logged raw.]:log_raw:(true false)' && ret=0
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_vault_auth() {
+ _arguments : \
+ ${general_args[@]} \
+ ${auth_args[@]} && ret=0
+}
+
+_vault_auth-enable() {
+ _arguments : \
+ ${general_args[@]} \
+ ${auth_enable_args[@]} \
+ ':::(cert ldap github userpass app-id)' && ret=0
+}
+
+__vault_auth_methods() {
+ local -a authmethods
+ authmethods=($(vault auth -methods | awk 'NR>1{split ($1,a,"/"); print a[1]":["$2"]"}'))
+ _describe -t authmethods 'authmethods' authmethods && ret=0
+}
+
+_vault_auth-disable() {
+ _arguments : \
+ ${general_args[@]} \
+ ':::__vault_auth_methods' && ret=0
+
+}
+
+_vault_init() {
+ _arguments : \
+ ${general_args[@]} \
+ ${init_args[@]} && ret=0
+}
+
+_vault_key-status() {
+ _arguments : \
+ ${general_args[@]} && ret=0
+}
+
+__vault_mounts() {
+ local -a mounts
+ mounts=($(vault mounts | awk 'NR>1{split ($1,a,"/"); print a[1]":["$2"]"}'))
+ _describe -t mounts 'mounts' mounts && ret=0
+}
+
+_vault_mounts() {
+ _arguments : \
+ ${general_args[@]} && ret=0
+}
+
+_vault_mount() {
+ # to find out how many types of backens are there
+ _arguments : \
+ ${general_args[@]} \
+ ${mount_args[@]} \
+ ':::(generic ssh)' && ret=0
+}
+
+_vault_mount-tune() {
+ _arguments : \
+ ${general_args[@]} \
+ ${mount_tune_args[@]} \
+ ':::__vault_mounts' && ret=0
+}
+
+_vault_unmount() {
+ _arguments : \
+ ${general_args[@]} \
+ ':::__vault_mounts' && ret=0
+}
+
+_vault_remount() {
+ _arguments : \
+ ${general_args[@]} \
+ ':::__vault_mounts' \
+ ':::' && ret=0
+}
+
+__vault_policies() {
+ local -a policies
+ policies=($(vault policies | awk '{print $1":["$1"]"}'))
+ _describe -t policies 'policies' policies && ret=0
+}
+
+_vault_policies() {
+ _arguments : \
+ ${general_args[@]} \
+ ':::__vault_policies' && ret=0
+}
+
+_vault_policy-delete() {
+ _arguments : \
+ ${general_args[@]} \
+ ':::__vault_policies' && ret=0
+}
+
+_vault_policy-write() {
+ _arguments : \
+ ${general_args[@]} \
+ ': ::' \
+ '::policy:_files' && ret=0
+}
+
+_vault_status() {
+ _arguments : \
+ ${general_args[@]} && ret=0
+}
+
+_vault_rekey() {
+ _arguments : \
+ ${general_args[@]} \
+ ${rekey_args[@]} \
+ ': ::' && ret=0
+}
+
+_vault_rotate() {
+ _arguments : \
+ ${general_args[@]} && ret=0
+}
+
+_vault_seal() {
+ _arguments : \
+ ${general_args[@]} && ret=0
+}
+
+_vault_ssh() {
+ _arguments : \
+ ${general_args[@]} \
+ ${ssh_args[@]} \
+ ': ::' && ret=0
+}
+
+_vault_token-create() {
+ _arguments : \
+ ${general_args[@]} \
+ ${token_create_args[@]} && ret=0
+}
+
+_vault_token-renew() {
+ _arguments : \
+ ${general_args[@]} \
+ '(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)' \
+ ': ::' \
+ ': ::' && ret=0
+}
+
+_vault_token-revoke() {
+ _arguments : \
+ ${general_args[@]} \
+ '(-mode)-mode=-[The type of revocation to do. See the documentation above for more information.]:mode:( orphan path)' \
+ ': ::' && ret=0
+}
+
+_vault_unseal() {
+ _arguments : \
+ ${general_args[@]} \
+ '(-reset)-reset[Reset the unsealing process by throwing away prior keys in process to unseal the vault.]:reset:' \
+ ': ::' && ret=0
+}
+
+_vault_version() {
+ # no args
+}
+
+_vault_delete() {
+ _arguments : \
+ ${general_args[@]} \
+ ': ::' && ret=0
+}
+
+_vault_path-help() {
+ _arguments : \
+ ${general_args[@]} \
+ ': ::' && ret=0
+}
+
+_vault_revoke() {
+ _arguments : \
+ ${general_args[@]} \
+ '(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)' \
+ ': ::' \
+ ': ::' && ret=0
+}
+
+_vault_server() {
+ _arguments : \
+ ${server_args[@]} && ret=0
+
+}
+
+_vault_write() {
+ _arguments : \
+ ${general_args[@]} \
+ '(-f -force)'{-f,-force}'[Force the write to continue without any data values specified. This allows writing to keys that do not need or expect any fields to be specified.]:force:' \
+ ': ::' \
+ ': ::' && ret=0
+}
+
+_vault_read() {
+ _arguments : \
+ ${general_args[@]} \
+ '(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)' \
+ '(-field)-field=-[If included, the raw value of the specified field will be output raw to stdout.]:field:' \
+ ': ::' && ret=0
+}
+
+_vault_commands() {
+ local -a commands
+
+ commands=(
+ "delete":"Delete operation on secrets in Vault"
+ "path-help":"Look up the help for a path"
+ "read":"Read data or secrets from Vault"
+ "renew":"Renew the lease of a secret"
+ "revoke":"Revoke a secret"
+ "server":"Start a Vault server"
+ "status":"Outputs status of whether Vault is sealed and if HA mode is enabled"
+ "write":"Write secrets or configuration into Vault"
+ "audit-disable":"Disable an audit backend"
+ "audit-enable":"Enable an audit backend"
+ "audit-list":"Lists enabled audit backends in Vault"
+ "auth":"Prints information about how to authenticate with Vault"
+ "auth-disable":"Disable an auth provider"
+ "auth-enable":"Enable a new auth provider"
+ "init":"Initialize a new Vault server"
+ "key-status":"Provides information about the active encryption key"
+ "mount":"Mount a logical backend"
+ "mount-tune":"Tune mount configuration parameters"
+ "mounts":"Lists mounted backends in Vault"
+ "policies":"List the policies on the server"
+ "policy-delete":"Delete a policy from the server"
+ "policy-write":"Write a policy to the server"
+ "rekey":"Rekeys Vault to generate new unseal keys"
+ "remount":"Remount a secret backend to a new path"
+ "rotate":"Rotates the backend encryption key used to persist data"
+ "seal":"Seals the vault server"
+ "ssh":"Initiate a SSH session"
+ "token-create":"Create a new auth token"
+ "token-renew":"Renew an auth token if there is an associated lease"
+ "token-revoke":"Revoke one or more auth tokens"
+ "unmount":"Unmount a secret backend"
+ "unseal":"Unseals the vault server"
+ "version":"Prints the Vault version"
+ )
+
+ _describe -t commands 'vault command' commands && ret=0
+}
+
+local curcontext=$curcontext ret=1
+_arguments : \
+ ${main_args[@]} \
+ '*:: :->subcommands' && ret=0
+if ((CURRENT == 1 )); then
+ _vault_commands && ret=0
+fi
+if [[ $state == subcommands ]]; then
+ # (( CURRENT -- ))
+ curcontext="${curcontext%:*:*}:vault-$words[1]:"
+ _call_function ret _vault_$words[1]
+fi
diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
index 0e2af5dce..82a2f3040 100644
--- a/plugins/vi-mode/vi-mode.plugin.zsh
+++ b/plugins/vi-mode/vi-mode.plugin.zsh
@@ -6,7 +6,7 @@ function zle-keymap-select() {
# Ensure that the prompt is redrawn when the terminal size changes.
TRAPWINCH() {
- zle && { zle reset-prompt; zle -R }
+ zle && zle -R
}
zle -N zle-keymap-select
@@ -28,6 +28,13 @@ bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
+# allow ctrl-r to perform backward search in history
+bindkey '^r' history-incremental-search-backward
+
+# allow ctrl-a and ctrl-e to move to beginning/end of line
+bindkey '^a' beginning-of-line
+bindkey '^e' end-of-line
+
# if mode indicator wasn't setup by theme, define default
if [[ "$MODE_INDICATOR" == "" ]]; then
MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh
index d3bf97d75..cc970e5fd 100644
--- a/plugins/web-search/web-search.plugin.zsh
+++ b/plugins/web-search/web-search.plugin.zsh
@@ -10,10 +10,12 @@ function web_search() {
bing "https://www.bing.com/search?q="
yahoo "https://search.yahoo.com/search?p="
duckduckgo "https://www.duckduckgo.com/?q="
+ startpage "https://www.startpage.com/do/search?q="
yandex "https://yandex.ru/yandsearch?text="
github "https://github.com/search?q="
baidu "https://www.baidu.com/s?wd="
ecosia "https://www.ecosia.org/search?q="
+ goodreads "https://www.goodreads.com/search?q="
)
# check whether the search engine is supported
@@ -41,10 +43,12 @@ alias bing='web_search bing'
alias google='web_search google'
alias yahoo='web_search yahoo'
alias ddg='web_search duckduckgo'
+alias sp='web_search startpage'
alias yandex='web_search yandex'
alias github='web_search github'
alias baidu='web_search baidu'
alias ecosia='web_search ecosia'
+alias goodreads='web_search goodreads'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'
diff --git a/plugins/wp-cli/README.md b/plugins/wp-cli/README.md
index 1a79d60fc..da398ed1a 100644
--- a/plugins/wp-cli/README.md
+++ b/plugins/wp-cli/README.md
@@ -4,7 +4,9 @@
WordPress Command Line Interface (http://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.
+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](http://wp-cli.org/#complete) for `wp-cli` as well as several aliases.
## List of Aliases
diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md
index 15e657859..c12ce047f 100644
--- a/plugins/xcode/README.md
+++ b/plugins/xcode/README.md
@@ -26,7 +26,7 @@ plugins=(... xcode)
### `xc`
-Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory.
+Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
Returns 1 if it didn't find any relevant files.
### `simulator`
diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
index 0a2fa0839..f711c39fb 100644
--- a/plugins/xcode/xcode.plugin.zsh
+++ b/plugins/xcode/xcode.plugin.zsh
@@ -7,10 +7,19 @@ alias xcsel='sudo xcode-select --switch'
# source: http://gist.github.com/subdigital/5420709
function xc {
local xcode_proj
- xcode_proj=(*.{xcworkspace,xcodeproj}(N))
+ if [[ $# == 0 ]]; then
+ xcode_proj=(*.{xcworkspace,xcodeproj}(N))
+ else
+ xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
+ fi
+
if [[ ${#xcode_proj} -eq 0 ]]; then
- echo "No xcworkspace/xcodeproj file found in the current directory."
+ if [[ $# == 0 ]]; then
+ echo "No xcworkspace/xcodeproj file found in the current directory."
+ else
+ echo "No xcworkspace/xcodeproj file found in $1."
+ fi
return 1
else
echo "Found ${xcode_proj[1]}"
diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
new file mode 100644
index 000000000..47c503acb
--- /dev/null
+++ b/plugins/yarn/yarn.plugin.zsh
@@ -0,0 +1,81 @@
+alias yi="yarn install"
+
+_yarn ()
+{
+ local -a _1st_arguments _dopts _dev _production
+ local expl
+ typeset -A opt_args
+
+ _dopts=(
+ '(--force)--force[This refetches all packages, even ones that were previously installed.]'
+ )
+
+ _installopts=(
+ '(--flat)--flat[Only allow one version of a package. On the first run this will prompt you to choose a single version for each package that is depended on at multiple version ranges.]'
+ '(--har)--har[Outputs an HTTP archive from all the network requests performed during the installation.]'
+ '(--no-lockfile)--no-lockfile[Don’t read or generate a yarn.lock lockfile.]'
+ '(--pure-lockfile)--pure-lockfile[Don’t generate a yarn.lock lockfile.]'
+ )
+
+ _dev=('(--dev)--dev[Save installed packages into the project"s package.json devDependencies]')
+
+ _production=('(--production)--production[Do not install project devDependencies]')
+
+ _1st_arguments=(
+ 'help:Display help information about yarn' \
+ 'init:Initialize for the development of a package.' \
+ 'add:Add a package to use in your current package.' \
+ 'install:Install all the dependencies listed within package.json in the local node_modules folder.' \
+ 'publish:Publish a package to a package manager.' \
+ 'remove:Remove a package that will no longer be used in your current package.' \
+ 'cache:Clear the local cache. It will be populated again the next time yarn or yarn install is run.' \
+ 'clean:Frees up space by removing unnecessary files and folders from dependencies.' \
+ 'check:Verifies that versions of the package dependencies in the current project’s package.json matches that of yarn’s lock file.' \
+ 'ls:List all installed packages.' \
+ 'global:Makes binaries available to use on your operating system.' \
+ 'info:<package> [<field>] - fetch information about a package and return it in a tree format.' \
+ 'outdated:Checks for outdated package dependencies.' \
+ 'run:Runs a defined package script.' \
+ 'self-update:Updates Yarn to the latest version.' \
+ 'upgrade:Upgrades packages to their latest version based on the specified range.' \
+ 'why:<query> - Show information about why a package is installed.'
+ )
+ _arguments \
+ '*:: :->subcmds' && return 0
+
+ if (( CURRENT == 1 )); then
+ _describe -t commands "yarn subcommand" _1st_arguments
+ return
+ fi
+
+ case "$words[1]" in
+ add)
+ _arguments \
+ $_dopts \
+ $_dev \
+ $_production
+ ;;
+ install)
+ _arguments \
+ $_installopts \
+ $_dopts \
+ $_dev \
+ $_no_color \
+ $_production
+ ;;
+ update)
+ _arguments \
+ $_dopts
+ ;;
+ remove)
+ _arguments \
+ $_dopts
+ ;;
+ *)
+ _arguments \
+ ;;
+ esac
+
+}
+
+compdef _yarn yarn
diff --git a/plugins/z/README b/plugins/z/README
index 7de82a4c7..56261cff4 100644
--- a/plugins/z/README
+++ b/plugins/z/README
@@ -125,7 +125,7 @@ ENVIRONMENT
Directories must be full paths without trailing slashes.
The environment variable $_Z_OWNER can be set to your username, to
- allow usage of z when your sudo enviroment keeps $HOME set.
+ allow usage of z when your sudo environment keeps $HOME set.
FILES
Data is stored in $HOME/.z. This can be overridden by setting the
diff --git a/plugins/z/z.1 b/plugins/z/z.1
index cc99910bf..bbc1bf5df 100644
--- a/plugins/z/z.1
+++ b/plugins/z/z.1
@@ -151,7 +151,7 @@ directory trees to exclude from tracking. \fB$HOME\fR is always excluded.
Directories must be full paths without trailing slashes.
.P
The environment variable \fB$_Z_OWNER\fR can be set to your username, to
-allow usage of \fBz\fR when your sudo enviroment keeps \fB$HOME\fR set.
+allow usage of \fBz\fR when your sudo environment keeps \fB$HOME\fR set.
.SH
FILES
Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf b/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
index 98f4625f1..047b017eb 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
@@ -1,5 +1,33 @@
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_aliases_active_text
+active_text=${znt_aliases_active_text:-$active_text}
+
+# 2. znt_aliases_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_aliases_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 3. znt_aliases_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_aliases_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 4. znt_aliases_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_aliases_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 5. znt_aliases_keywords (array)
+if (( ${+znt_aliases_keywords} )); then
+ keywords=( "${znt_aliases_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
index f8c49bfac..8271e5d98 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
@@ -1,5 +1,6 @@
# Hotlist
-local hotlist
+# Can use e.g. $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions
+local -a hotlist
hotlist=(
~/.config/znt
/usr/share/zsh/site-functions
@@ -15,12 +16,53 @@ hotlist=(
local NCD_DONT_PUSHD=0
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
# Colorize last segments of the paths
# (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex)
local NLIST_COLORING_PATTERN="[a-zA-Z0-9 ._-]##/#(#e)"
local NLIST_COLORING_COLOR=$'\x1b[00;33m'
+
+# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/
+local -a keywords
+keywords=( "zsh" "local" "git" )
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_cd_hotlist (array)
+if (( ${+znt_cd_hotlist} )); then
+ hotlist=( "${znt_cd_hotlist[@]}" )
+fi
+
+# 2. znt_cd_dont_pushd
+NCD_DONT_PUSHD=${znt_cd_dont_pushd:-$NCD_DONT_PUSHD}
+
+# 3. znt_cd_active_text
+active_text=${znt_cd_active_text:-$active_text}
+
+# 4. znt_cd_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_cd_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 5. znt_cd_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_cd_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 6. znt_cd_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_cd_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 7. znt_cd_keywords (array)
+if (( ${+znt_cd_keywords} )); then
+ keywords=( "${znt_cd_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-env.conf b/plugins/zsh-navigation-tools/.config/znt/n-env.conf
index 0c4bdce64..85dda05ed 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-env.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-env.conf
@@ -1,9 +1,38 @@
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
# (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex)
local NLIST_COLORING_PATTERN="[a-zA-Z0-9_]##"
local NLIST_COLORING_MATCH_MULTIPLE=0
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_env_active_text
+active_text=${znt_env_active_text:-$active_text}
+
+# 2. znt_env_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_env_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 3. znt_env_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_env_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 4. znt_env_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_env_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 5. znt_env_keywords (array)
+if (( ${+znt_env_keywords} )); then
+ keywords=( "${znt_env_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-functions.conf b/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
index 93d31e8fd..d032e2788 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
@@ -4,7 +4,38 @@ local feditor="zed"
# local feditor="vared"
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_functions_feditor
+feditor=${znt_functions_feditor:-$feditor}
+
+# 2. znt_functions_active_text
+active_text=${znt_functions_active_text:-$active_text}
+
+# 3. znt_functions_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_functions_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 4. znt_functions_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_functions_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 5. znt_functions_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_functions_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 6. znt_functions_keywords (array)
+if (( ${+znt_functions_keywords} )); then
+ keywords=( "${znt_functions_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-history.conf b/plugins/zsh-navigation-tools/.config/znt/n-history.conf
index 5d4bad822..d7c69e154 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-history.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-history.conf
@@ -1,10 +1,43 @@
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
+# underline support on that terminal). The same for screen/tmux.
local active_text=underline
# Highlight a few keywords
local NLIST_COLORING_PATTERN="(while|for |sudo|make|(#s)git|vim(#e)|vim |emacs(#e)|emacs )"
local NLIST_COLORING_COLOR=$'\x1b[00;33m'
local NLIST_COLORING_MATCH_MULTIPLE=1
+
+# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/
+local -a keywords
+keywords=( "git" "vim" "mplayer" )
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_history_active_text
+active_text=${znt_history_active_text:-$active_text}
+
+# 2. znt_history_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_history_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 3. znt_history_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_history_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 4. znt_history_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_history_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 5. znt_history_keywords (array)
+if (( ${+znt_history_keywords} )); then
+ keywords=( "${znt_history_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-kill.conf b/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
index f1c4f02da..59807b2c3 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
@@ -1,13 +1,46 @@
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
# Colorize first number column and last path segment
# This doesn't cover scripts named "[0-9]## *", which should be very rare
# (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex)
# | is alternative, but only in ()
-local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e)|[^ /\\\\]##[^0-9/\\\\ ]##[^/\\\\]#(#e))"
+local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e))"
local NLIST_COLORING_COLOR=$'\x1b[00;33m'
local NLIST_COLORING_MATCH_MULTIPLE=1
+
+# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/
+local -a keywords
+keywords=( "vim" "git" "git commit" "firefox" "mplayer" )
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_kill_active_text
+active_text=${znt_kill_active_text:-$active_text}
+
+# 2. znt_kill_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_kill_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 3. znt_kill_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_kill_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 4. znt_kill_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_kill_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 5. znt_kill_keywords (array)
+if (( ${+znt_kill_keywords} )); then
+ keywords=( "${znt_kill_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-list.conf b/plugins/zsh-navigation-tools/.config/znt/n-list.conf
index cf9d2a3be..096104df6 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-list.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-list.conf
@@ -1,3 +1,55 @@
# Should the list (text, borders) be drawn in bold
# Value 1 is the default
-local bold=1
+local bold=0
+
+# Main color pair (foreground/background)
+local colorpair="white/black"
+
+# Should draw the border?
+local border=0
+
+# Combinations of colors to try out with Ctrl-T and Ctrl-G
+# The last number is the bold option, 0 or 1
+local -a themes
+themes=( "white/black/1" "green/black/0" "green/black/1" "white/blue/0" "white/blue/1"
+ "magenta/black/0" "magenta/black/1" )
+
+# Uncomment when using new (>5.2) Zsh version that supports 256 colors in zcurses
+#themes=( "white/17/0" "10/17/1" "white/24/1" "white/22/0" "white/22/1" "white/25/0" "white/25/1"
+# "white/59/0" "white/59/1" "white/60/0" "white/60/1" "white/61/0" "white/61/1" "black/65/0"
+# "black/244/0" )
+
+# When 1, pressing enter when in search mode will not
+# only leave the mode, but also do selection and leave
+# n-history
+local NLIST_INSTANT_SELECT=0
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_list_bold
+bold=${znt_list_bold:-$bold}
+
+# 2. znt_list_colorpair
+colorpair=${znt_list_colorpair:-$colorpair}
+
+# 3. znt_list_border
+border=${znt_list_border:-$border}
+
+# 4. znt_list_themes (array)
+if (( ${+znt_list_themes} )); then
+ themes=( "${znt_list_themes[@]}" )
+fi
+
+# 5. znt_list_instant_select
+NLIST_INSTANT_SELECT=${znt_list_instant_select:-$NLIST_INSTANT_SELECT}
+
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-options.conf b/plugins/zsh-navigation-tools/.config/znt/n-options.conf
index 98f4625f1..29c5e089a 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-options.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-options.conf
@@ -1,5 +1,34 @@
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_options_active_text
+active_text=${znt_options_active_text:-$active_text}
+
+# 2. znt_options_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_options_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 3. znt_options_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_options_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 4. znt_options_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_options_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 5. znt_options_keywords (array)
+if (( ${+znt_options_keywords} )); then
+ keywords=( "${znt_options_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf b/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
index 98f4625f1..58ce1b620 100644
--- a/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
+++ b/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
@@ -1,5 +1,34 @@
# How should be current element of the list drawn. Possible values: reverse,
-# underline. Default (without option set) is reverse
+# underline.
# On Linux virtual terminal this will be enforced to reverse (because of poor
-# underline support on that terminal)
-# local active_text=underline
+# underline support on that terminal). The same for screen/tmux.
+local active_text=reverse
+
+
+
+
+
+
+
+#
+# Zshrc integration. All below variables can
+# be set in zshrc and will have precedence
+# over config files
+#
+
+# 1. znt_panelize_active_text
+active_text=${znt_panelize_active_text:-$active_text}
+
+# 2. znt_panelize_nlist_coloring_pattern
+NLIST_COLORING_PATTERN=${znt_panelize_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
+
+# 3. znt_panelize_nlist_coloring_color
+NLIST_COLORING_COLOR=${znt_panelize_nlist_coloring_color:-$NLIST_COLORING_COLOR}
+
+# 4. znt_panelize_nlist_coloring_match_multiple
+NLIST_COLORING_MATCH_MULTIPLE=${znt_panelize_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
+
+# 5. znt_panelize_keywords (array)
+if (( ${+znt_panelize_keywords} )); then
+ keywords=( "${znt_panelize_keywords[@]}" )
+fi
diff --git a/plugins/zsh-navigation-tools/NEWS b/plugins/zsh-navigation-tools/NEWS
new file mode 100644
index 000000000..acd9f2ebc
--- /dev/null
+++ b/plugins/zsh-navigation-tools/NEWS
@@ -0,0 +1,17 @@
+-------------------------------------
+CHANGES FROM PREVIOUS VERSIONS OF ZNT
+-------------------------------------
+
+Changes from 2.2.1 to 2.2.7
+---------------------------
+
+Tmux integration has been added – bind file znt-tmux.zsh in Tmux as
+described in README.md and e.g. run local history on remote hosts. Tmux
+opens new window with n-history, and pastes selected history entry into
+immediate previous window (e.g. a remote session). Fixed plugin.zsh file
+to not use (outer scope) positional parameters. This fixes problem with
+Grlm's Zsh configuration. The file now doesn't use "test" builtin (but
+[[ instead), because it can be shadowed by alias or command. Private
+history has been fixed to not overwrite its history file with the same
+content. This improves performance when switching to private history
+view.
diff --git a/plugins/zsh-navigation-tools/README.md b/plugins/zsh-navigation-tools/README.md
index 4420dab82..ed532a161 100644
--- a/plugins/zsh-navigation-tools/README.md
+++ b/plugins/zsh-navigation-tools/README.md
@@ -1,6 +1,6 @@
# Zsh Navigation Tools
-http://imageshack.com/a/img633/7967/ps6rKR.png
+https://raw.githubusercontent.com/psprint/zsh-navigation-tools/master/doc/img/n-history2.png
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
@@ -25,13 +25,87 @@ 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):
zle -N znt-cd-widget
- bindkey "^T" znt-cd-widget
+ bindkey "^A" znt-cd-widget
zle -N znt-kill-widget
bindkey "^Y" znt-kill-widget
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.
+## News
+
+* 06-10-2016
+ - 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:
+
+ 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
+ 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
+ long history entries).
+
+* 14-05-2016
+ - Configuration can be set from zshrc. Example:
+
+ znt_list_instant_select=1
+ znt_list_border=0
+ znt_list_bold=1
+ znt_list_colorpair="green/black"
+ znt_functions_keywords=( "zplg" "zgen" "match" )
+ znt_cd_active_text="underline"
+ znt_env_nlist_coloring_color=$'\x1b[00;33m'
+ 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.
+ 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.
+
+* 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
+ original Zsh approximate matching features and is intended to be used
+ after entering search query, when a typo is discovered.
+
+* 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
+ or any other tool-targetted config file:
+
+ # 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
+ 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 :)
+
+* 29-04-2016
+ - New feature: private history – n-history tracks selected history entries,
+ exposes them via new view (activated with F1)
+
+* 28-04-2016
+ - New features:
+ 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
+
## Introduction
The tools are:
@@ -60,6 +134,65 @@ cursors. Other keys are:
- Ctrl-w (in incremental search) - delete whole word
- Ctrl-k (in incremental search) - delete whole line
+## Configuration
+
+`ZNT` has configuration files located in `~/.config/znt`. The files are:
+
+```
+n-aliases.conf
+n-cd.conf
+n-env.conf
+n-functions.conf
+n-history.conf
+n-kill.conf
+n-list.conf
+n-options.conf
+n-panelize.conf
+```
+
+`n-list.conf` contains main configuration variables:
+
+```zsh
+# Should the list (text, borders) be drawn in bold
+local bold=0
+
+# Main color pair (foreground/background)
+local colorpair="white/black"
+
+# Should draw the border?
+local border=1
+
+# Combinations of colors to try out with Ctrl-T and Ctrl-G
+# The last number is the bold option, 0 or 1
+local -a themes
+themes=( "white/black/1" "green/black/0" "green/black/1" "white/blue/0" "white/blue/1"
+ "magenta/black/0" "magenta/black/1" )
+```
+
+Read remaining configuration files to see what's in them. Nevertheless, configuration
+can be also set from `zshrc`. There are `5` standard `zshrc` configuration variables:
+
+```
+znt_history_active_text - underline or reverse - how should be active element highlighted
+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`
+```
+
+Above variables will work for `n-history` tool. For other tools, change `_history_` to
+e.g. `_cd_`, for the `n-cd` tool. The same works for all `8` tools.
+
+Common configuration of the tools uses variables with `_list_` in them:
+
+```
+znt_list_bold - should draw text in bold (0 or 1)
+znt_list_colorpair - main pair of colors to be used, e.g "green/black"
+znt_list_border - should draw borders around windows (0 or 1)
+znt_list_themes (array) - list of themes to try out with Ctrl-T, e.g. ( "white/black/1" "green/black/0" )
+znt_list_instant_select - should pressing enter in search mode leave tool (0 or 1)
+```
+
## Programming
The function n-list is used as follows:
diff --git a/plugins/zsh-navigation-tools/_n-kill b/plugins/zsh-navigation-tools/_n-kill
new file mode 100644
index 000000000..6f5d47971
--- /dev/null
+++ b/plugins/zsh-navigation-tools/_n-kill
@@ -0,0 +1,41 @@
+#compdef n-kill
+
+local context ret=1
+
+typeset -a list linewords
+typeset -aU words wordbits
+local line word
+integer cygwin=0
+
+local IFS="
+"
+
+case "$OSTYPE" in
+ cygwin*) list=( `command ps -Wa` ); cygwin=1 ;;
+ *) list=( `command ps -o pid,uid,command -A` ) ;;
+esac
+
+shift list
+
+IFS=" "
+for line in "${list[@]}"; do
+ linewords=( $=line )
+ if [ "$cygwin" = "1" ]; then
+ linewords=( "${(@)linewords[8,-1]}" )
+ else
+ linewords=( "${(@)linewords[3,-1]}" )
+ fi
+ for word in "${linewords[@]}"; do
+ if [ "$cygwin" = "1" ]; then
+ wordbits=( "${(@s:\:)word}" )
+ else
+ wordbits=( "${(@s:/:)word}" )
+ fi
+ words+=( "${wordbits[@]}" )
+ done
+done
+
+_wanted bits expl "Processes' name bits" \
+ compadd "$@" -a - words && ret=0
+
+return "$ret"
diff --git a/plugins/zsh-navigation-tools/n-aliases b/plugins/zsh-navigation-tools/n-aliases
index d81db9253..f8c1c3727 100644
--- a/plugins/zsh-navigation-tools/n-aliases
+++ b/plugins/zsh-navigation-tools/n-aliases
@@ -16,8 +16,8 @@ local IFS="
unset NLIST_COLORING_PATTERN
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-aliases.conf ] && . ~/.config/znt/n-aliases.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-aliases.conf ] && builtin source ~/.config/znt/n-aliases.conf
local list
local selected
diff --git a/plugins/zsh-navigation-tools/n-cd b/plugins/zsh-navigation-tools/n-cd
index b1ac5b159..48c6dbf4e 100644
--- a/plugins/zsh-navigation-tools/n-cd
+++ b/plugins/zsh-navigation-tools/n-cd
@@ -16,8 +16,8 @@ local IFS="
# Unset before configuration is read
unset NLIST_COLORING_PATTERN
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-cd.conf ] && . ~/.config/znt/n-cd.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-cd.conf ] && builtin source ~/.config/znt/n-cd.conf
local list
local selected
@@ -53,13 +53,16 @@ if [ "$REPLY" -gt 0 ]; then
(( NCD_DONT_PUSHD )) && setopt NO_AUTO_PUSHD
cd "$selected"
+ local code=$?
(( NCD_DONT_PUSHD )) && setopt AUTO_PUSHD
- # ZLE?
- if [ "${(t)CURSOR}" = "integer-local-special" ]; then
- zle -M "You have selected $selected"
- else
- echo "You have selected $selected"
+ if [ "$code" -eq "0" ]; then
+ # ZLE?
+ if [ "${(t)CURSOR}" = "integer-local-special" ]; then
+ zle -M "You have selected $selected"
+ else
+ echo "You have selected $selected"
+ fi
fi
else
[ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay
diff --git a/plugins/zsh-navigation-tools/n-env b/plugins/zsh-navigation-tools/n-env
index 612796c00..c003b63a8 100644
--- a/plugins/zsh-navigation-tools/n-env
+++ b/plugins/zsh-navigation-tools/n-env
@@ -15,8 +15,8 @@ zmodload zsh/curses
local IFS="
"
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-env.conf ] && . ~/.config/znt/n-env.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-env.conf ] && builtin source ~/.config/znt/n-env.conf
local list
local selected
diff --git a/plugins/zsh-navigation-tools/n-functions b/plugins/zsh-navigation-tools/n-functions
index 6f10a3dec..1748cbc90 100644
--- a/plugins/zsh-navigation-tools/n-functions
+++ b/plugins/zsh-navigation-tools/n-functions
@@ -16,8 +16,8 @@ local IFS="
unset NLIST_COLORING_PATTERN
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-functions.conf ] && . ~/.config/znt/n-functions.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-functions.conf ] && builtin source ~/.config/znt/n-functions.conf
local list
local selected
diff --git a/plugins/zsh-navigation-tools/n-help b/plugins/zsh-navigation-tools/n-help
new file mode 100644
index 000000000..c7f6328b7
--- /dev/null
+++ b/plugins/zsh-navigation-tools/n-help
@@ -0,0 +1,135 @@
+autoload colors
+colors
+
+local h1="$fg_bold[magenta]"
+local h2="$fg_bold[green]"
+local h3="$fg_bold[blue]"
+local h4="$fg_bold[yellow]"
+local h5="$fg_bold[cyan]"
+local rst="$reset_color"
+
+LESS="-iRc" less <<<"
+${h1}Key Bindings${rst}
+
+${h2}H${rst}, ${h2}?${rst} (from n-history) - run n-help
+${h2}Ctrl-A${rst} - rotate entered words (1+2+3 -> 3+1+2)
+${h2}Ctrl-F${rst} - fix mode (approximate matching)
+${h2}Ctrl-L${rst} - redraw of whole display
+${h2}Ctrl-T${rst} - browse themes (next theme)
+${h2}Ctrl-G${rst} - browse themes (previous theme)
+${h2}Ctrl-U${rst} - half page up
+${h2}Ctrl-D${rst} - half page down
+${h2}Ctrl-P${rst} - previous element (also done with vim's k)
+${h2}Ctrl-N${rst} - next element (also done with vim's j)
+${h2}[${rst}, ${h2}]${rst} - jump directory bookmarks in n-cd and typical signals in n-kill
+${h2}g, ${h2}G${rst} - beginning and end of the list
+${h2}/${rst} - show incremental search
+${h2}F3${rst} - show/hide incremental search
+${h2}Esc${rst} - exit incremental search, clearing filter
+${h2}Ctrl-W${rst} (in incremental search) - delete whole word
+${h2}Ctrl-K${rst} (in incremental search) - delete whole line
+${h2}Ctrl-O, ${h2}o${rst} - enter uniq mode (no duplicate lines)
+${h2}Ctrl-E, ${h2}e${rst} - edit private history (when in private history view)
+${h2}F1${rst} - (in n-history) - switch view
+${h2}F2${rst}, ${h2}Ctrl-X${rst}, ${h2}Ctrl-/${rst} - search predefined keywords (defined in config files)
+
+${h1}Configuration files${rst}
+
+Location of the files is ${h3}~/.config/znt${rst}. Skeletons are copied there
+when using ${h3}zsh-navigation-tools.plugin.zsh${rst} file (sourcing it or using
+a plugin manager). There's a main config file ${h3}n-list.conf${rst} and files
+for each tool.
+
+To have a skeleton copied again into ${h3}~/.config/znt${rst}, delete it from
+there and restart Zsh a few times (3-7 or so; there's a random check
+that optimizes startup time).
+
+${h1}Predefined search keywords${rst}
+
+Following block of code in e.g. ${h3}~/.config/znt/n-history.conf${rst} defines
+set of keywords that can be invoked (i.e. searched for) via ${h2}F2${rst}, ${h2}Ctrl-X${rst}
+or ${h2}Ctrl-/${rst}:
+
+ ${h4}# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/${rst}
+ ${h2}local${rst} -a keywords
+ keywords=( ${h2}\"git\" \"vim\" \"mplayer\"${rst} )
+
+${h1}Search query rotation${rst}
+
+When searching, after pressing ${h2}Ctrl-A${rst}, words 1 2 3 will become 3 1 2, etc.
+This can be used to edit some not-last word.
+
+${h1}Fix mode${rst}
+
+Approximate matching - pressing ${h2}f${rst} or ${h2}Ctrl-F${rst} 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.
+
+${h1}Color themes${rst}
+
+Following block of code in ${h3}~/.config/znt/n-list.conf${rst} defines set of
+themes that can be browsed with ${h2}Ctrl-T${rst} and ${h2}Ctrl-G${rst}:
+
+ ${h4}# Combinations of colors to try out with Ctrl-T and Ctrl-G
+ # The last number is the bold option, 0 or 1${rst}
+ ${h2}local${rst} -a themes
+ themes=( ${h2}\"white/black/1\" \"green/black/0\" \"green/black/1\"${rst}
+ ${h2}\"white/blue/0\" \"white/blue/1\" \"magenta/black/0\"${rst}
+ ${h2}\"magenta/black/1\"${rst} )
+
+It's \"foreground/background/bold\". There's support for 256-color themes
+for Zsh > 5.2, defined like e.g.:
+
+ themes=( ${h2}\"white/17/0\" \"10/17/1\" \"white/24/1\"${rst} )
+
+i.e. with use of numbers, from 0 to 254.
+
+${h1}Private history${rst}
+
+N-history stores what's selected in its own history file. It can be
+edited. Use ${h2}e${rst} or ${h2}Ctrl-E${rst} 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.
+
+Private history is instantly shared among sessions.
+
+${h1}Zshrc integration${rst}
+
+There are 5 standard configuration variables that can be set in zshrc:
+
+${h4}znt_history_active_text${rst}
+\"underline\" or \"reverse\" - how should be active element highlighted
+${h4}znt_history_nlist_coloring_pattern${rst}
+Pattern that can be used to colorize elements
+${h4}znt_history_nlist_coloring_color${rst}
+Color with which to colorize via the pattern
+${h4}znt_history_nlist_coloring_match_multiple${rst}
+Should multiple matches be colorized (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
+${h4}znt_history_keywords ${h2}(array)${rst}
+Search keywords activated with Ctrl-X, F2, Ctrl-/, e.g. ( ${h2}\"git\"${rst} ${h2}\"vim\"${rst} )
+
+Above variables will work for n-history tool. For other tools, change
+\"_history_\" to e.g. \"_cd_\", for the n-cd tool. The same works for
+all 8 tools.
+
+Common configuration of the tools uses variables with \"_list_\" in them:
+
+${h4}znt_list_bold${rst}
+Should draw text in bold (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
+${h4}znt_list_colorpair${rst}
+Main pair of colors to be used, e.g ${h2}\"green/black\"${rst}
+${h4}znt_list_border${rst}
+Should draw borders around windows (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
+${h4}znt_list_themes ${h2}(array)${rst}
+List of themes to try out with Ctrl-T, e.g. ( ${h2}\"white/black/1\"${rst}
+${h2}\"green/black/0\"${rst} )
+${h4}znt_list_instant_select${rst}
+Should pressing enter in search mode leave tool (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
+
+If you used ZNT before v2.1.12 then remove old configuration files
+${h3}~/.config/znt/*.conf${rst} 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), that is not needed when
+using as plugin.
+"
diff --git a/plugins/zsh-navigation-tools/n-history b/plugins/zsh-navigation-tools/n-history
index c9e53316b..b425ecd10 100644
--- a/plugins/zsh-navigation-tools/n-history
+++ b/plugins/zsh-navigation-tools/n-history
@@ -15,40 +15,357 @@ zmodload zsh/parameter
local IFS="
"
-unset NLIST_COLORING_PATTERN
+# Variables to save list's state when switching views
+# The views are: history and "most frequent history words"
+local one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+local one_NLIST_CURRENT_IDX
+local one_NLIST_IS_SEARCH_MODE
+local one_NLIST_SEARCH_BUFFER
+local one_NLIST_TEXT_OFFSET
+local one_NLIST_IS_UNIQ_MODE
+local one_NLIST_IS_F_MODE
+local one_NLIST_GREP_STRING
+local one_NLIST_NONSELECTABLE_ELEMENTS
+local one_NLIST_REMEMBER_STATE
+local one_NLIST_ENABLED_EVENTS
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-history.conf ] && . ~/.config/znt/n-history.conf
+local two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+local two_NLIST_CURRENT_IDX
+local two_NLIST_IS_SEARCH_MODE
+local two_NLIST_SEARCH_BUFFER
+local two_NLIST_TEXT_OFFSET
+local two_NLIST_IS_UNIQ_MODE
+local two_NLIST_IS_F_MODE
+local two_NLIST_GREP_STRING
+local two_NLIST_NONSELECTABLE_ELEMENTS
+local two_NLIST_REMEMBER_STATE
+local two_NLIST_ENABLED_EVENTS
-local list
-local selected
+local three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+local three_NLIST_CURRENT_IDX
+local three_NLIST_IS_SEARCH_MODE
+local three_NLIST_SEARCH_BUFFER
+local three_NLIST_TEXT_OFFSET
+local three_NLIST_IS_UNIQ_MODE
+local three_NLIST_IS_F_MODE
+local three_NLIST_GREP_STRING
+local three_NLIST_NONSELECTABLE_ELEMENTS
+local three_NLIST_REMEMBER_STATE
+local three_NLIST_ENABLED_EVENTS
-NLIST_REMEMBER_STATE=0
+# history view
+integer active_view=0
-list=( "$history[@]" )
-list=( "${(@M)list:#(#i)*$1*}" )
+# Lists are "0", "1", "2" - 1st, 2nd, 3rd
+# Switching is done in cyclic manner
+# i.e. 0 -> 1, 1 -> 2, 2 -> 0
+_nhistory_switch_lists_states() {
+ # First argument is current, newly selected list, i.e. $active_view
+ # This implies that we are switching from previous view
+
+ if [ "$1" = "0" ]; then
+ # Switched to 1st list, save 3rd list's state
+ three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+ three_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX
+ three_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE
+ three_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER
+ three_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET
+ three_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE
+ three_NLIST_IS_F_MODE=$NLIST_IS_F_MODE
+ three_NLIST_GREP_STRING=$NLIST_GREP_STRING
+ three_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} )
+ three_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE
+ three_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} )
-if [ "$#list" -eq 0 ]; then
- echo "No matching history entries"
- return 1
-fi
+ # ..and restore 1st list's state
+ NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+ NLIST_CURRENT_IDX=$one_NLIST_CURRENT_IDX
+ NLIST_IS_SEARCH_MODE=$one_NLIST_IS_SEARCH_MODE
+ NLIST_SEARCH_BUFFER=$one_NLIST_SEARCH_BUFFER
+ NLIST_TEXT_OFFSET=$one_NLIST_TEXT_OFFSET
+ NLIST_IS_UNIQ_MODE=$one_NLIST_IS_UNIQ_MODE
+ NLIST_IS_F_MODE=$one_NLIST_IS_F_MODE
+ NLIST_GREP_STRING=$one_NLIST_GREP_STRING
+ NLIST_NONSELECTABLE_ELEMENTS=( ${one_NLIST_NONSELECTABLE_ELEMENTS[@]} )
+ NLIST_REMEMBER_STATE=$one_NLIST_REMEMBER_STATE
+ NLIST_ENABLED_EVENTS=( ${one_NLIST_ENABLED_EVENTS[@]} )
+ elif [ "$1" = "1" ]; then
+ # Switched to 2nd list, save 1st list's state
+ one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+ one_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX
+ one_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE
+ one_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER
+ one_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET
+ one_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE
+ one_NLIST_IS_F_MODE=$NLIST_IS_F_MODE
+ one_NLIST_GREP_STRING=$NLIST_GREP_STRING
+ one_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} )
+ one_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE
+ one_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} )
+
+ # ..and restore 2nd list's state
+ NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+ NLIST_CURRENT_IDX=$two_NLIST_CURRENT_IDX
+ NLIST_IS_SEARCH_MODE=$two_NLIST_IS_SEARCH_MODE
+ NLIST_SEARCH_BUFFER=$two_NLIST_SEARCH_BUFFER
+ NLIST_TEXT_OFFSET=$two_NLIST_TEXT_OFFSET
+ NLIST_IS_UNIQ_MODE=$two_NLIST_IS_UNIQ_MODE
+ NLIST_IS_F_MODE=$two_NLIST_IS_F_MODE
+ NLIST_GREP_STRING=$two_NLIST_GREP_STRING
+ NLIST_NONSELECTABLE_ELEMENTS=( ${two_NLIST_NONSELECTABLE_ELEMENTS[@]} )
+ NLIST_REMEMBER_STATE=$two_NLIST_REMEMBER_STATE
+ NLIST_ENABLED_EVENTS=( ${two_NLIST_ENABLED_EVENTS[@]} )
+ elif [ "$1" = "2" ]; then
+ # Switched to 3rd list, save 2nd list's state
+ two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+ two_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX
+ two_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE
+ two_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER
+ two_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET
+ two_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE
+ two_NLIST_IS_F_MODE=$NLIST_IS_F_MODE
+ two_NLIST_GREP_STRING=$NLIST_GREP_STRING
+ two_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} )
+ two_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE
+ two_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} )
+
+ # ..and restore 3rd list's state
+ NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
+ NLIST_CURRENT_IDX=$three_NLIST_CURRENT_IDX
+ NLIST_IS_SEARCH_MODE=$three_NLIST_IS_SEARCH_MODE
+ NLIST_SEARCH_BUFFER=$three_NLIST_SEARCH_BUFFER
+ NLIST_TEXT_OFFSET=$three_NLIST_TEXT_OFFSET
+ NLIST_IS_UNIQ_MODE=$three_NLIST_IS_UNIQ_MODE
+ NLIST_IS_F_MODE=$three_NLIST_IS_F_MODE
+ NLIST_GREP_STRING=$three_NLIST_GREP_STRING
+ NLIST_NONSELECTABLE_ELEMENTS=( ${three_NLIST_NONSELECTABLE_ELEMENTS[@]} )
+ NLIST_REMEMBER_STATE=$three_NLIST_REMEMBER_STATE
+ NLIST_ENABLED_EVENTS=( ${three_NLIST_ENABLED_EVENTS[@]} )
+ fi
+}
+
+local most_frequent_db="$HOME/.config/znt/mostfrequent.db"
+_nhistory_generate_most_frequent() {
+ local title=$'\x1b[00;31m'"Most frequent history words:"$'\x1b[00;00m\0'
+
+ typeset -A uniq
+ for k in "${historywords[@]}"; do
+ uniq[$k]=$(( ${uniq[$k]:-0} + 1 ))
+ done
+ vk=()
+ for k v in ${(kv)uniq}; do
+ vk+="$v"$'\t'"$k"
+ done
+
+ print -rl -- "$title" "${(On)vk[@]}" > "$most_frequent_db"
+}
+
+# Load configuration
+unset NLIST_COLORING_PATTERN
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-history.conf ] && builtin source ~/.config/znt/n-history.conf
+
+local list
+local selected
+local private_history_db="$HOME/.config/znt/privhist.db"
local NLIST_GREP_STRING="$1"
+# 2 is: init once, then remember
+local NLIST_REMEMBER_STATE=2
+two_NLIST_REMEMBER_STATE=2
+three_NLIST_REMEMBER_STATE=2
+
+# Only Private history has EDIT
+local -a NLIST_ENABLED_EVENTS
+NLIST_ENABLED_EVENTS=( "F1" "HELP" )
+two_NLIST_ENABLED_EVENTS=( "F1" "EDIT" "HELP" )
+three_NLIST_ENABLED_EVENTS=( "F1" "HELP" )
+
+# All view should attempt to replace new lines with \n
local NLIST_REPLACE_NEWLINES="1"
-n-list "${list[@]}"
+two_NLIST_REPLACE_NEWLINES="1"
+three_NLIST_REPLACE_NEWLINES="1"
+
+# Only second and third view has non-selectable first entry
+local -a NLIST_NONSELECTABLE_ELEMENTS
+NLIST_NONSELECTABLE_ELEMENTS=( )
+two_NLIST_NONSELECTABLE_ELEMENTS=( 1 )
+three_NLIST_NONSELECTABLE_ELEMENTS=( 1 )
+
+while (( 1 )); do
+
+ #
+ # View 1 - history
+ #
+ if [ "$active_view" = "0" ]; then
+ list=( "$history[@]" )
+ list=( "${(@M)list:#(#i)*$NLIST_GREP_STRING*}" )
+
+ if [ "$#list" -eq 0 ]; then
+ echo "No matching history entries"
+ return 1
+ fi
+
+ n-list "${list[@]}"
+
+ # Selection or quit?
+ if [[ "$REPLY" = -(#c0,1)[0-9]## && ("$REPLY" -lt 0 || "$REPLY" -gt 0) ]]; then
+ break
+ fi
+
+ # View change?
+ if [ "$REPLY" = "F1" ]; then
+ # Target view: 2
+ active_view=1
+ _nhistory_switch_lists_states "1"
+ elif [ "$REPLY" = "HELP" ]; then
+ n-help
+ fi
+
+ #
+ # View 3 - most frequent words in history
+ #
+ elif [ "$active_view" = "2" ]; then
+ local -a dbfile
+ dbfile=( $most_frequent_db(Nm+1) )
+
+ # Compute most frequent history words
+ if [[ "${#NHISTORY_WORDS}" -eq "0" || "${#dbfile}" -ne "0" ]]; then
+ # Read the list if it's there
+ local -a list
+ list=()
+ [ -s "$most_frequent_db" ] && list=( ${(f)"$(<$most_frequent_db)"} )
+
+ # Will wait for the data?
+ local message=0
+ if [[ "${#list}" -eq 0 ]]; then
+ message=1
+ _nlist_alternate_screen 1
+ zcurses init
+ zcurses delwin info 2>/dev/null
+ zcurses addwin info "$term_height" "$term_width" 0 0
+ zcurses bg info white/black
+ zcurses string info "Computing most frequent history words..."$'\n'
+ zcurses string info "(This is done once per day, from now on transparently)"$'\n'
+ zcurses refresh info
+ sleep 3
+ fi
+
+ # Start periodic list regeneration?
+ if [[ "${#list}" -eq 0 || "${#dbfile}" -ne "0" ]]; then
+ # Mark the file with current time, to prevent double
+ # regeneration (on quick double change of view)
+ print >> "$most_frequent_db"
+ (_nhistory_generate_most_frequent &) &> /dev/null
+ fi
+
+ # Ensure we got the list, wait for it if needed
+ while [[ "${#list}" -eq 0 ]]; do
+ zcurses string info "."
+ zcurses refresh info
+ LANG=C sleep 0.5
+ [ -s "$most_frequent_db" ] && list=( ${(f)"$(<$most_frequent_db)"} )
+ done
+
+ NHISTORY_WORDS=( "${list[@]}" )
+
+ if [ "$message" -eq "1" ]; then
+ zcurses delwin info 2>/dev/null
+ zcurses refresh
+ zcurses end
+ _nlist_alternate_screen 0
+ fi
+ else
+ # Reuse most frequent history words
+ local -a list
+ list=( "${NHISTORY_WORDS[@]}" )
+ fi
+
+ n-list "${list[@]}"
+
+ if [ "$REPLY" = "F1" ]; then
+ # Target view: 1
+ active_view=0
+ _nhistory_switch_lists_states "0"
+ elif [[ "$REPLY" = -(#c0,1)[0-9]## && "$REPLY" -lt 0 ]]; then
+ break
+ elif [[ "$REPLY" = -(#c0,1)[0-9]## && "$REPLY" -gt 0 ]]; then
+ local word="${reply[REPLY]#(#s) #[0-9]##$'\t'}"
+ one_NLIST_SEARCH_BUFFER="$word"
+ one_NLIST_SEARCH_BUFFER="${one_NLIST_SEARCH_BUFFER## ##}"
+
+ # Target view: 1
+ active_view=0
+ _nhistory_switch_lists_states "0"
+ elif [ "$REPLY" = "HELP" ]; then
+ n-help
+ fi
+
+ #
+ # View 2 - private history
+ #
+ elif [ "$active_view" = "1" ]; then
+ if [ -s "$private_history_db" ]; then
+ local title=$'\x1b[00;32m'"Private history:"$'\x1b[00;00m\0'
+ () { fc -Rap "$private_history_db" 20000 0; list=( "$title" ${history[@]} ) }
+ else
+ list=( "Private history - history entries selected via this tool will be put here" )
+ fi
+
+ n-list "${list[@]}"
+
+ # Selection or quit?
+ if [[ "$REPLY" = -(#c0,1)[0-9]## && ("$REPLY" -lt 0 || "$REPLY" -gt 0) ]]; then
+ break
+ fi
+
+ # View change?
+ if [ "$REPLY" = "F1" ]; then
+ # Target view: 3
+ active_view=2
+ _nhistory_switch_lists_states "2"
+ # Edit of the history?
+ elif [ "$REPLY" = "EDIT" ]; then
+ "${EDITOR:-vim}" "$private_history_db"
+ elif [ "$REPLY" = "HELP" ]; then
+ n-help
+ fi
+ fi
+done
if [ "$REPLY" -gt 0 ]; then
selected="$reply[REPLY]"
+
+ # Append to private history
+ if [[ "$active_view" = "0" ]]; then
+ local newline=$'\n'
+ local selected_ph="${selected//$newline/\\$newline}"
+ print -r -- "$selected_ph" >> "$private_history_db"
+ fi
+
+ # TMUX?
+ if [[ "$ZNT_TMUX_MODE" = "1" ]]; then
+ tmux send -t "$ZNT_TMUX_ORIGIN_SESSION:$ZNT_TMUX_ORIGIN_WINDOW.$ZNT_TMUX_ORIGIN_PANE" "$selected"
+ tmux kill-window
+ return 0
# ZLE?
- if [ "${(t)CURSOR}" = "integer-local-special" ]; then
- zle redisplay
- zle kill-whole-line
- zle -U "$selected"
+ elif [ "${(t)CURSOR}" = "integer-local-special" ]; then
+ zle .redisplay
+ zle .kill-buffer
+ LBUFFER+="$selected"
else
- print -zr "$selected"
+ print -zr -- "$selected"
fi
else
- [ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay
+ # TMUX?
+ if [[ "$ZNT_TMUX_MODE" = "1" ]]; then
+ tmux kill-window
+ # ZLE?
+ elif [[ "${(t)CURSOR}" = "integer-local-special" ]]; then
+ zle redisplay
+ fi
fi
+return 0
+
# vim: set filetype=zsh:
diff --git a/plugins/zsh-navigation-tools/n-kill b/plugins/zsh-navigation-tools/n-kill
index e52082282..76050f969 100644
--- a/plugins/zsh-navigation-tools/n-kill
+++ b/plugins/zsh-navigation-tools/n-kill
@@ -13,8 +13,8 @@ zmodload zsh/curses
local IFS="
"
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-kill.conf ] && . ~/.config/znt/n-kill.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-kill.conf ] && builtin source ~/.config/znt/n-kill.conf
typeset -A signals
signals=(
@@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 )
type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 }
-case "$(uname)" in
- CYGWIN*) list=( `command ps -Wa` ) ;;
+case "$OSTYPE" 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 388712bd0..3fe5542a6 100644
--- a/plugins/zsh-navigation-tools/n-list
+++ b/plugins/zsh-navigation-tools/n-list
@@ -1,6 +1,7 @@
# $1, $2, ... - elements of the list
# $NLIST_NONSELECTABLE_ELEMENTS - array of indexes (1-based) that cannot be selected
# $REPLY is the output variable - contains index (1-based) or -1 when no selection
+# $reply (array) is the second part of the output - use the index (REPLY) to get selected element
#
# Copy this file into /usr/share/zsh/site-functions/
# and add 'autoload n-list` to .zshrc
@@ -28,7 +29,7 @@ _nlist_exit() {
setopt localoptions
setopt extendedglob
- [[ "$REPLY" = -(#c0,1)[0-9]## ]] || REPLY="-1"
+ [[ "$REPLY" = -(#c0,1)[0-9]## || "$REPLY" = F<-> || "$REPLY" = "EDIT" || "$REPLY" = "HELP" ]] || REPLY="-1"
zcurses 2>/dev/null delwin inner
zcurses 2>/dev/null delwin main
zcurses 2>/dev/null refresh
@@ -164,6 +165,27 @@ integer current_difference=0
local prev_search_buffer=""
integer prev_uniq_mode=0
integer prev_start_idx=-1
+local MBEGIN MEND MATCH mbegin mend match
+
+# Iteration over predefined keywords
+integer curkeyword nkeywords
+local keywordisfresh="0"
+if [[ "${(t)keywords}" != *array* ]]; then
+ local -a keywords
+ keywords=()
+fi
+curkeyword=0
+nkeywords=${#keywords}
+
+# Iteration over themes
+integer curtheme nthemes
+local themeisfresh="0"
+if [[ "${(t)themes}" != *array* ]]; then
+ local -a themes
+ themes=()
+fi
+curtheme=0
+nthemes=${#themes}
# Ability to remember the list between calls
if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then
@@ -173,6 +195,7 @@ if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REM
NLIST_SEARCH_BUFFER=""
NLIST_TEXT_OFFSET=0
NLIST_IS_UNIQ_MODE=0
+ NLIST_IS_F_MODE=0
# Zero - because it isn't known, unless we
# confirm that first element is selectable
@@ -205,12 +228,19 @@ zcurses delwin main 2>/dev/null
zcurses delwin inner 2>/dev/null
zcurses addwin main "$term_height" "$term_width" 0 0
zcurses addwin inner "$inner_height" "$inner_width" 1 2
-zcurses bg main white/black
-zcurses bg inner white/black
+# From n-list.conf
+[ "$colorpair" = "" ] && colorpair="white/black"
+[ "$border" = "0" ] || border="1"
+local background="${colorpair#*/}"
+local backuptheme="$colorpair/$bold"
+zcurses bg main "$colorpair"
+zcurses bg inner "$colorpair"
if [ "$NLIST_IS_SEARCH_MODE" -ne 1 ]; then
_nlist_cursor_visibility 0
fi
+zcurses refresh
+
#
# Listening for input
#
@@ -235,9 +265,12 @@ while (( 1 )); do
# Do searching (filtering with string)
if [ -n "$NLIST_SEARCH_BUFFER" ]; then
# Compute new list?
- if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then
+ if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode"
+ || "$NLIST_IS_F_MODE" -ne "$prev_f_mode" ]]
+ then
prev_search_buffer="$NLIST_SEARCH_BUFFER"
prev_uniq_mode="$NLIST_IS_UNIQ_MODE"
+ prev_f_mode="$NLIST_IS_F_MODE"
# regenerating list -> regenerating disp_list
prev_start_idx=-1
@@ -249,7 +282,9 @@ while (( 1 )); do
# Remove non-selectable elements
[ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
- list[$i]=()
+ if [[ "$i" = <-> ]]; then
+ list[$i]=()
+ fi
done
# Remove duplicates
@@ -264,11 +299,25 @@ while (( 1 )); do
local search_pattern=""
local colsearch_pattern=""
if [ -n "$search_buffer" ]; then
- # Patterns will be *foo*~^*bar* and foo|bar)
- search_pattern="${search_buffer// ##/*~^*}"
- colsearch_pattern="${search_buffer// ##/|}"
+ # The repeat will make the matching work on a fresh heap
+ repeat 1; do
+ if [ "$NLIST_IS_F_MODE" -eq "1" ]; then
+ search_pattern="${search_buffer// ##/*~^(#a1)*}"
+ colsearch_pattern="${search_buffer// ##/|(#a1)}"
+ list=( "${(@M)list:#(#ia1)*$~search_pattern*}" )
+ elif [ "$NLIST_IS_F_MODE" -eq "2" ]; then
+ search_pattern="${search_buffer// ##/*~^(#a2)*}"
+ colsearch_pattern="${search_buffer// ##/|(#a2)}"
+ list=( "${(@M)list:#(#ia2)*$~search_pattern*}" )
+ else
+ # Pattern will be *foo*~^*bar* (inventor: Mikael Magnusson)
+ search_pattern="${search_buffer// ##/*~^*}"
+ # Pattern will be (foo|bar)
+ colsearch_pattern="${search_buffer// ##/|}"
+ list=( "${(@M)list:#(#i)*$~search_pattern*}" )
+ fi
+ done
- list=( "${(@M)list:#(#i)*$~search_pattern*}" )
last_element="$#list"
fi
@@ -287,7 +336,16 @@ while (( 1 )); do
if [ -n "$colsearch_pattern" ]; then
local red=$'\x1b[00;31m' reset=$'\x1b[00;00m'
- disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
+ # The repeat will make the matching work on a fresh heap
+ repeat 1; do
+ if [ "$NLIST_IS_F_MODE" -eq "1" ]; then
+ disp_list=( "${(@)disp_list//(#mia1)($~colsearch_pattern)/$red${MATCH}$reset}" )
+ elif [ "$NLIST_IS_F_MODE" -eq "2" ]; then
+ disp_list=( "${(@)disp_list//(#mia2)($~colsearch_pattern)/$red${MATCH}$reset}" )
+ else
+ disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
+ fi
+ done
fi
# We have display list, lets replace newlines with "\n" when needed (1/2)
@@ -295,6 +353,7 @@ while (( 1 )); do
fi
# Output colored list
+ zcurses clear inner
n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \
"$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \
"$disp_list[@]"
@@ -318,7 +377,9 @@ while (( 1 )); do
# Remove non-selectable elements only when in uniq mode
[ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] &&
for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
- list[$i]=()
+ if [[ "$i" = <-> ]]; then
+ list[$i]=()
+ fi
done
# Remove duplicates when in uniq mode
@@ -346,29 +407,49 @@ while (( 1 )); do
fi
# Output the list
+ zcurses clear inner
n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \
"$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \
"$disp_list[@]"
fi
local status_msg_strlen
+ local keywordmsg=""
+ if [ "$keywordisfresh" = "1" ]; then
+ keywordmsg="($curkeyword/$nkeywords) "
+ keywordisfresh="0"
+ fi
+
+ local thememsg=""
+ if [ "$themeisfresh" = "1" ]; then
+ local theme="$backuptheme"
+ [ "$curtheme" -gt 0 ] && theme="${themes[curtheme]}"
+ thememsg="($curtheme/$nthemes $theme) "
+ themeisfresh="0"
+ fi
+
+ local _txt2="" _txt3=""
+ [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] "
+ [ "$NLIST_IS_F_MODE" -eq 1 ] && _txt3="[-FIX-] "
+ [ "$NLIST_IS_F_MODE" -eq 2 ] && _txt3="[-FIX2-] "
+
if [ "$NLIST_IS_SEARCH_MODE" = "1" ]; then
- local _txt2=""
- [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] "
- _nlist_status_msg "${_txt2}Filtering with: ${NLIST_SEARCH_BUFFER// /+}"
+ _nlist_status_msg "${_txt2}${_txt3}${keywordmsg}${thememsg}Filtering with: ${NLIST_SEARCH_BUFFER// /+}"
elif [[ ${NLIST_NONSELECTABLE_ELEMENTS[(r)$NLIST_CURRENT_IDX]} != $NLIST_CURRENT_IDX ||
-n "$NLIST_SEARCH_BUFFER" || "$NLIST_IS_UNIQ_MODE" -eq 1 ]]; then
- local _txt="" _txt2=""
+ local _txt=""
[ -n "$NLIST_GREP_STRING" ] && _txt=" [$NLIST_GREP_STRING]"
- [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] "
- _nlist_status_msg "${_txt2}Current #$NLIST_USER_CURRENT_IDX (of #$NLIST_USER_LAST_ELEMENT entries)$_txt"
+ _nlist_status_msg "${_txt2}${_txt3}${keywordmsg}${thememsg}Current #$NLIST_USER_CURRENT_IDX (of #$NLIST_USER_LAST_ELEMENT entries)$_txt"
else
- _nlist_status_msg ""
+ _nlist_status_msg "${keywordmsg}${thememsg}"
fi
- zcurses border main
+ [ "$border" = "1" ] && zcurses border main
- local top_msg="${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL, $USER"
+ local top_msg=" ${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL "
+ if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then
+ top_msg=" F1-change view,$top_msg"
+ fi
zcurses move main 0 $(( term_width / 2 - $#top_msg / 2 ))
zcurses string main $top_msg
@@ -380,7 +461,7 @@ while (( 1 )); do
# Get the special (i.e. "keypad") key or regular key
if [ -n "$key" ]; then
- final_key="$key"
+ final_key="$key"
elif [ -n "$keypad" ]; then
final_key="$keypad"
else
@@ -391,7 +472,7 @@ while (( 1 )); do
n-list-input "$NLIST_CURRENT_IDX" "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" \
"$page_height" "$page_width" "$last_element" "$NLIST_TEXT_OFFSET" \
"$final_key" "$NLIST_IS_SEARCH_MODE" "$NLIST_SEARCH_BUFFER" \
- "$NLIST_IS_UNIQ_MODE"
+ "$NLIST_IS_UNIQ_MODE" "$NLIST_IS_F_MODE"
selection="$reply[1]"
action="$reply[2]"
@@ -401,8 +482,11 @@ while (( 1 )); do
NLIST_IS_SEARCH_MODE="$reply[6]"
NLIST_SEARCH_BUFFER="$reply[7]"
NLIST_IS_UNIQ_MODE="$reply[8]"
+ NLIST_IS_F_MODE="$reply[9]"
- if [ "$action" = "SELECT" ]; then
+ if [ -z "$action" ]; then
+ continue
+ elif [ "$action" = "SELECT" ]; then
REPLY="$selection"
reply=( "$list[@]" )
break
@@ -413,6 +497,18 @@ while (( 1 )); do
elif [ "$action" = "REDRAW" ]; then
zcurses clear main redraw
zcurses clear inner redraw
+ elif [[ "$action" = F<-> ]]; then
+ REPLY="$action"
+ reply=( "$list[@]" )
+ break
+ elif [[ "$action" = "EDIT" ]]; then
+ REPLY="EDIT"
+ reply=( "$list[@]" )
+ break
+ elif [[ "$action" = "HELP" ]]; then
+ REPLY="HELP"
+ reply=( "$list[@]" )
+ break
fi
done
diff --git a/plugins/zsh-navigation-tools/n-list-draw b/plugins/zsh-navigation-tools/n-list-draw
index 1b2571fbd..ae1e0115f 100644
--- a/plugins/zsh-navigation-tools/n-list-draw
+++ b/plugins/zsh-navigation-tools/n-list-draw
@@ -79,9 +79,9 @@ _nlist_print_with_ansi() {
if (( no_match == 0 )); then
if (( col >= 30 && col <= 37 )); then
- zcurses attr "$win" $c[col-29]/black
+ zcurses attr "$win" $c[col-29]/"$background"
elif [[ "$col" -eq 0 ]]; then
- zcurses attr "$win" white/black
+ zcurses attr "$win" "$colorpair"
fi
fi
done
@@ -97,17 +97,19 @@ local win="$7"
shift 7
integer max_text_len=page_width-x_offset
-[ "$bold" = "0" ] && bold="" || bold="+bold"
-[[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || active_text="reverse"
-# With Linux terminal underline won't work properly
-[ "$TERM" = "linux" ] && active_text="reverse"
+[[ "$bold" = "0" || "$bold" = "-bold" ]] && bold="-bold" || bold="+bold"
+[[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || local active_text="reverse"
+# Linux has ncv 18, screen* has ncv 3 - underline won't work properly
+(( ${terminfo[ncv]:-0} & 2 )) && active_text="reverse"
+# FreeBSD uses TERM=xterm for newcons but doesn't actually support underline
+[[ "$TERM" = "xterm" && -z "$DISPLAY" ]] && active_text="reverse"
integer max_idx=page_height
integer end_idx=max_idx
[ "$end_idx" -gt "$#" ] && end_idx="$#"
integer y=y_offset
-zcurses attr "$win" $bold white/black
+zcurses attr "$win" "$bold" "$colorpair"
integer i text_len
local text
diff --git a/plugins/zsh-navigation-tools/n-list-input b/plugins/zsh-navigation-tools/n-list-input
index 380acdc00..9bafc51b6 100644
--- a/plugins/zsh-navigation-tools/n-list-input
+++ b/plugins/zsh-navigation-tools/n-list-input
@@ -14,6 +14,52 @@ _nlist_compute_first_to_show_idx() {
from_what_idx_list_is_shown=0+((current_idx-1)/page_height)*page_height+1
}
+_nlist_update_from_keywords() {
+ keywordisfresh="1"
+ if [ "$nkeywords" -gt 0 ]; then
+ curkeyword=$(( (curkeyword+1) % (nkeywords+1) ))
+ if [ "$curkeyword" -eq "0" ]; then
+ buffer=""
+ else
+ buffer="${keywords[curkeyword]}"
+ fi
+ fi
+}
+
+_nlist_iterate_theme() {
+ themeisfresh="1"
+ if [ "$1" = "1" ]; then
+ curtheme=$(( (curtheme+1) % (nthemes+1) ))
+ else
+ curtheme=curtheme-1
+ [ "$curtheme" -lt 0 ] && curtheme=nthemes
+ fi
+
+ if [ "$nthemes" -gt 0 ]; then
+ local theme=${themes[curtheme]}
+ [ "$curtheme" -eq "0" ] && theme="$backuptheme"
+
+ colorpair="${theme%/*}"
+ bold="${theme##*/}"
+ background="${colorpair#*/}"
+ zcurses bg main "$colorpair"
+ zcurses bg inner "$colorpair"
+ fi
+}
+
+_nlist_rotate_buffer() {
+ setopt localoptions noglob
+
+ local -a words
+ words=( ${(s: :)buffer} )
+ words=( ${words[-1]} ${words[1,-2]} )
+
+ local space=""
+ [ "${buffer[-1]}" = " " ] && space=" "
+
+ buffer="${(j: :)words}$space"
+}
+
typeset -ga reply
reply=( -1 '' )
integer current_idx="$1"
@@ -26,6 +72,7 @@ local key="$7"
integer search="$8"
local buffer="$9"
integer uniq_mode="$10"
+integer f_mode="$11"
#
# Listening for input
@@ -44,7 +91,7 @@ case "$key" in
[ "$current_idx" -lt "$last_element" ] && current_idx=current_idx+1;
_nlist_compute_first_to_show_idx
;;
- (PPAGE)
+ (PPAGE|$'\b'|$'\C-?'|BACKSPACE)
current_idx=current_idx-page_height
[ "$current_idx" -lt 1 ] && current_idx=1;
_nlist_compute_first_to_show_idx
@@ -72,28 +119,43 @@ case "$key" in
current_idx=last_element
_nlist_compute_first_to_show_idx
;;
- ($'\n')
+ ($'\n'|ENTER)
# Is that element selectable?
# Check for this only when there is no search
if [[ "$NLIST_SEARCH_BUFFER" != "" || "$NLIST_IS_UNIQ_MODE" -eq 1 ||
${NLIST_NONSELECTABLE_ELEMENTS[(r)$current_idx]} != $current_idx ]]
then
# Save current element in the result variable
- reply=( $current_idx SELECT )
+ reply=( $current_idx "SELECT" )
+ fi
+ ;;
+ (H|'?')
+ # This event needs to be enabled
+ if [[ "${NLIST_ENABLED_EVENTS[(r)HELP]}" = "HELP" ]]; then
+ reply=( -1 "HELP" )
+ fi
+ ;;
+ (F1)
+ # This event needs to be enabled
+ if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then
+ reply=( -1 "$key" )
fi
;;
+ (F4|F5|F6|F7|F8|F9|F10|DC)
+ # ignore; F2, F3 are used below
+ ;;
(q)
- reply=( -1 QUIT )
+ reply=( -1 "QUIT" )
;;
(/)
search=1
_nlist_cursor_visibility 1
;;
($'\t')
- reply=( $current_idx LEAVE )
+ reply=( $current_idx "LEAVE" )
;;
($'\C-L')
- reply=( -1 REDRAW )
+ reply=( -1 "REDRAW" )
;;
(\])
[[ "${(t)NLIST_HOP_INDEXES}" = "array" || "${(t)NLIST_HOP_INDEXES}" = "array-local" ]] &&
@@ -127,9 +189,41 @@ case "$key" in
($'\E')
buffer=""
;;
+ (F3)
+ if [ "$search" = "1" ]; then
+ search=0
+ _nlist_cursor_visibility 0
+ else
+ search=1
+ _nlist_cursor_visibility 1
+ fi
+ ;;
(o|$'\C-O')
uniq_mode=1-uniq_mode
;;
+ (f|$'\C-F')
+ (( f_mode=(f_mode+1) % 3 ))
+ ;;
+ ($'\x1F'|F2|$'\C-X')
+ search=1
+ _nlist_cursor_visibility 1
+ _nlist_update_from_keywords
+ ;;
+ ($'\C-T')
+ _nlist_iterate_theme 1
+ ;;
+ ($'\C-G')
+ _nlist_iterate_theme 0
+ ;;
+ ($'\C-E'|e)
+ # This event needs to be enabled
+ if [[ "${NLIST_ENABLED_EVENTS[(r)EDIT]}" = "EDIT" ]]; then
+ reply=( -1 "EDIT" )
+ fi
+ ;;
+ ($'\C-A')
+ _nlist_rotate_buffer
+ ;;
(*)
;;
esac
@@ -137,12 +231,20 @@ esac
else
case "$key" in
- ($'\n')
- search=0
- _nlist_cursor_visibility 0
+ ($'\n'|ENTER)
+ if [ "$NLIST_INSTANT_SELECT" = "1" ]; then
+ if [[ "$NLIST_SEARCH_BUFFER" != "" || "$NLIST_IS_UNIQ_MODE" -eq 1 ||
+ ${NLIST_NONSELECTABLE_ELEMENTS[(r)$current_idx]} != $current_idx ]]
+ then
+ reply=( $current_idx "SELECT" )
+ fi
+ else
+ search=0
+ _nlist_cursor_visibility 0
+ fi
;;
($'\C-L')
- reply=( -1 REDRAW )
+ reply=( -1 "REDRAW" )
;;
#
@@ -192,8 +294,14 @@ case "$key" in
(RIGHT)
hscroll+=7
;;
- (F1|F2|F3|F4|F5|F6|F7|F8|F9|F10)
- # ignore
+ (F1)
+ # This event needs to be enabled
+ if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then
+ reply=( -1 "$key" )
+ fi
+ ;;
+ (F4|F5|F6|F7|F8|F9|F10|DC)
+ # ignore; F2, F3 are used below
;;
#
@@ -214,9 +322,39 @@ case "$key" in
search=0
_nlist_cursor_visibility 0
;;
+ (F3)
+ if [ "$search" = "1" ]; then
+ search=0
+ _nlist_cursor_visibility 0
+ else
+ search=1
+ _nlist_cursor_visibility 1
+ fi
+ ;;
($'\C-O')
uniq_mode=1-uniq_mode
;;
+ ($'\C-F')
+ (( f_mode=(f_mode+1) % 3 ))
+ ;;
+ ($'\x1F'|F2|$'\C-X')
+ _nlist_update_from_keywords
+ ;;
+ ($'\C-T')
+ _nlist_iterate_theme 1
+ ;;
+ ($'\C-G')
+ _nlist_iterate_theme 0
+ ;;
+ ($'\C-E')
+ # This event needs to be enabled
+ if [[ "${NLIST_ENABLED_EVENTS[(r)EDIT]}" = "EDIT" ]]; then
+ reply=( -1 "EDIT" )
+ fi
+ ;;
+ ($'\C-A')
+ _nlist_rotate_buffer
+ ;;
(*)
if [[ $#key == 1 && $((#key)) -lt 31 ]]; then
# ignore all other control keys
@@ -234,5 +372,6 @@ reply[5]="$hscroll"
reply[6]="$search"
reply[7]="$buffer"
reply[8]="$uniq_mode"
+reply[9]="$f_mode"
# vim: set filetype=zsh:
diff --git a/plugins/zsh-navigation-tools/n-options b/plugins/zsh-navigation-tools/n-options
index 91589bd45..b1a934015 100644
--- a/plugins/zsh-navigation-tools/n-options
+++ b/plugins/zsh-navigation-tools/n-options
@@ -14,8 +14,8 @@ local IFS="
unset NLIST_COLORING_PATTERN
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-options.conf ] && . ~/.config/znt/n-options.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-options.conf ] && builtin source ~/.config/znt/n-options.conf
# TODO restore options
unsetopt localoptions
diff --git a/plugins/zsh-navigation-tools/n-panelize b/plugins/zsh-navigation-tools/n-panelize
index 01d01cb9e..e2b567f2e 100644
--- a/plugins/zsh-navigation-tools/n-panelize
+++ b/plugins/zsh-navigation-tools/n-panelize
@@ -17,8 +17,8 @@ local IFS="
unset NLIST_COLORING_PATTERN
-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
-[ -f ~/.config/znt/n-panelize.conf ] && . ~/.config/znt/n-panelize.conf
+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
+[ -f ~/.config/znt/n-panelize.conf ] && builtin source ~/.config/znt/n-panelize.conf
local list
local selected
diff --git a/plugins/zsh-navigation-tools/znt-history-widget b/plugins/zsh-navigation-tools/znt-history-widget
index 9ddae606d..479c2211b 100644
--- a/plugins/zsh-navigation-tools/znt-history-widget
+++ b/plugins/zsh-navigation-tools/znt-history-widget
@@ -1,7 +1,19 @@
autoload znt-usetty-wrapper n-history
local NLIST_START_IN_SEARCH_MODE=1
local NLIST_START_IN_UNIQ_MODE=1
-local NLIST_SET_SEARCH_TO="$BUFFER"
+
+# Only if current $BUFFER doesn't come from history
+if [ "$HISTCMD" = "$HISTNO" ]; then
+ () {
+ setopt localoptions extendedglob
+ local -a match mbegin mend
+ local MATCH; integer MBEGIN MEND
+
+ [ -n "$BUFFER" ] && BUFFER="${BUFFER%% ##} "
+ }
+
+ local NLIST_SET_SEARCH_TO="$BUFFER"
+fi
znt-usetty-wrapper n-history "$@"
diff --git a/plugins/zsh-navigation-tools/znt-tmux.zsh b/plugins/zsh-navigation-tools/znt-tmux.zsh
new file mode 100755
index 000000000..6a96e97a1
--- /dev/null
+++ b/plugins/zsh-navigation-tools/znt-tmux.zsh
@@ -0,0 +1,50 @@
+#!/usr/bin/env zsh
+
+# Copyright (c) 2016, Zsolt Lengyel
+# Modifications copyright (c) 2016, Sebastian Gniazdowski
+
+#
+# This script opens a new, temporary tmux pane and runs n-history. When
+# a selection is made, the result (history entry) is pasted back into
+# original tmux pane, and the temporary pane is closed. This allows to
+# use local history on remote machines.
+#
+# To use, put this line to your ~/.tmux.conf. The tool is invoked with:
+# Ctrl+b h
+#
+# bind h run-shell -b "$ZNT_REPO_DIR/znt-tmux.zsh"
+#
+
+# get and save the current active tmux pane id
+active_pane=$(tmux display -p -F ':#{session_id}:#I:#P:#{pane_active}:#{window_active}:#{session_attached}' )
+a_active_pane=("${(@s/:/)active_pane}")
+
+active_session=${a_active_pane[2]//$}
+active_window=$a_active_pane[3]
+active_pane=$a_active_pane[4]
+
+# set variables for upcoming window
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_MODE" 1
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_SESSION" "$active_session"
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_WINDOW" "$active_window"
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_PANE" "$active_pane"
+
+# create a new window in the active session and call it znt-hist
+tmux new-window -t $active_session: -n znt-hist
+
+# unset the variables, so only above single window has them
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_MODE"
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_SESSION"
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_WINDOW"
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_PANE"
+
+# znt's session id
+znt_active_pane=$(tmux display -p -F ':#{session_id}:#I:#P:#{pane_active}:#{window_active}:#{session_attached}' )
+znt_a_active_pane=("${(@s/:/)znt_active_pane}")
+
+znt_active_session=${znt_a_active_pane[2]//$}
+znt_active_window=$znt_a_active_pane[3]
+znt_active_pane=$znt_a_active_pane[4]
+
+# call znt
+tmux send -t "$znt_active_session:$znt_active_window.$znt_active_pane" n-history ENTER
diff --git a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
index 16247b8db..32b4ca064 100755
--- a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
+++ b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
@@ -1,38 +1,55 @@
#!/usr/bin/env zsh
-REPO_DIR="${0%/*}"
-CONFIG_DIR="$HOME/.config/znt"
+0="${(%):-%N}" # this gives immunity to functionargzero being unset
+export ZNT_REPO_DIR="${0%/*}"
+export ZNT_CONFIG_DIR="$HOME/.config/znt"
#
# Copy configs
#
-if ! test -d "$HOME/.config"; then
- mkdir "$HOME/.config"
+if [[ ! -d "$HOME/.config" ]]; then
+ command mkdir "$HOME/.config"
fi
-if ! test -d "$CONFIG_DIR"; then
- mkdir "$CONFIG_DIR"
+if [[ ! -d "$ZNT_CONFIG_DIR" ]]; then
+ command mkdir "$ZNT_CONFIG_DIR"
fi
-set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
+# 9 files
+unset __ZNT_CONFIG_FILES
+typeset -ga __ZNT_CONFIG_FILES
+set +A __ZNT_CONFIG_FILES n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
+
+# Check for random 2 files if they exist
+# This will shift 0 - 7 elements
+shift $(( RANDOM % 8 )) __ZNT_CONFIG_FILES
+if [[ ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[1]}" || ! -f "$ZNT_CONFIG_DIR/${__ZNT_CONFIG_FILES[2]}" ]]; then
+ # Something changed - examine every file
+ set +A __ZNT_CONFIG_FILES n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
+ unset __ZNT_CONFIG_FILE
+ typeset -g __ZNT_CONFIG_FILE
+ for __ZNT_CONFIG_FILE in "${__ZNT_CONFIG_FILES[@]}"; do
+ if [[ ! -f "$ZNT_CONFIG_DIR/$__ZNT_CONFIG_FILE" ]]; then
+ command cp "$ZNT_REPO_DIR/.config/znt/$__ZNT_CONFIG_FILE" "$ZNT_CONFIG_DIR"
+ fi
+ done
+ unset __ZNT_CONFIG_FILE
+fi
-for i; do
- if ! test -f "$CONFIG_DIR/$i"; then
- cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR"
- fi
-done
+unset __ZNT_CONFIG_FILES
#
# Load functions
#
-autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize
+autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize n-help
autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget
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
+alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help
zle -N znt-history-widget
bindkey '^R' znt-history-widget
setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS
+zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*'
diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
index 2f39308a9..966d7a975 100644
--- a/templates/zshrc.zsh-template
+++ b/templates/zshrc.zsh-template
@@ -1,10 +1,12 @@
+# If you come from bash you might have to change your $PATH.
+# export PATH=$HOME/bin:/usr/local/bin:$PATH
+
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
-# Set name of the theme to load.
-# Look in ~/.oh-my-zsh/themes/
-# Optionally, if you set this to "random", it'll load a random theme each
-# time that oh-my-zsh is loaded.
+# Set name of the theme to load. Optionally, if you set this to "random"
+# it'll load a random theme each time that oh-my-zsh is loaded.
+# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to load
@@ -58,13 +60,12 @@ ZSH_THEME="robbyrussell"
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
+source $ZSH/oh-my-zsh.sh
+
# User configuration
-export PATH=$HOME/bin:/usr/local/bin:$PATH
# export MANPATH="/usr/local/man:$MANPATH"
-source $ZSH/oh-my-zsh.sh
-
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
@@ -79,7 +80,7 @@ source $ZSH/oh-my-zsh.sh
# export ARCHFLAGS="-arch x86_64"
# ssh
-# export SSH_KEY_PATH="~/.ssh/dsa_id"
+# 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
diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme
index 97d142a0f..1c6d1732c 100644
--- a/themes/af-magic.zsh-theme
+++ b/themes/af-magic.zsh-theme
@@ -27,7 +27,7 @@ else
fi
# git settings
-ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075](branch:"
+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%}"
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 103041eef..07546fd34 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -86,7 +86,7 @@ prompt_context() {
# Git: branch/detached head, dirty status
prompt_git() {
-
+ (( $+commands[git] )) || return
local PL_BRANCH_CHAR
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
@@ -127,7 +127,30 @@ prompt_git() {
fi
}
+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
+ fi
+}
+
prompt_hg() {
+ (( $+commands[hg] )) || return
local rev status
if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then
@@ -197,6 +220,7 @@ build_prompt() {
prompt_context
prompt_dir
prompt_git
+ prompt_bzr
prompt_hg
prompt_end
}
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 65466b82f..4f0dcbcc6 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -2,16 +2,25 @@
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
-▶ '
+%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
-PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
+PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
-local _current_dir="%{$fg[blue]%}%3~%{$reset_color%} "
-local _return_status="%{$fg[red]%}%(?..⍉)%{$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%}"
+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
+}
+
function _user_host() {
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
@@ -32,6 +41,8 @@ function _vi_status() {
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
}
@@ -85,13 +96,13 @@ ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
-ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}◒ "
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
-ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}"
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
# LS colors, made with http://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxegedabagacad"
diff --git a/themes/bira.zsh-theme b/themes/bira.zsh-theme
index 215720477..29bda0be8 100644
--- a/themes/bira.zsh-theme
+++ b/themes/bira.zsh-theme
@@ -1,8 +1,16 @@
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
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%}'
+
+if [[ $UID -eq 0 ]]; then
+ 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_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%}'
@@ -14,8 +22,9 @@ fi
local git_branch='$(git_prompt_info)%{$reset_color%}'
PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
-╰─%B$%b "
-RPS1="${return_code}"
+╰─%B${user_symbol}%b "
+RPS1="%B${return_code}%b"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
+
diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme
index 148abec10..3b3bdc80f 100644
--- a/themes/bureau.zsh-theme
+++ b/themes/bureau.zsh-theme
@@ -22,34 +22,44 @@ bureau_git_branch () {
echo "${ref#refs/heads/}"
}
-bureau_git_status () {
- _INDEX=$(command git status --porcelain -b 2> /dev/null)
+bureau_git_status() {
_STATUS=""
- if $(echo "$_INDEX" | grep '^[AMRD]. ' &> /dev/null); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
- fi
- if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
- fi
- if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
- fi
- if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
- fi
- if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
+
+ # check status of files
+ _INDEX=$(command git status --porcelain 2> /dev/null)
+ if [[ -n "$_INDEX" ]]; then
+ if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then
+ _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
+ fi
+ if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then
+ _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
+ fi
+ if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then
+ _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
+ fi
+ if $(echo "$_INDEX" | command grep -q '^UU '); then
+ _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
+ fi
+ else
+ _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
- if $(echo "$_INDEX" | grep '^## .*ahead' &> /dev/null); then
+
+ # check status of local repository
+ _INDEX=$(command git status --porcelain -b 2> /dev/null)
+ if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
- if $(echo "$_INDEX" | grep '^## .*behind' &> /dev/null); then
+ if $(echo "$_INDEX" | command grep -q '^## .*behind'); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
- if $(echo "$_INDEX" | grep '^## .*diverged' &> /dev/null); then
+ if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
+ if $(command git rev-parse --verify refs/stash &> /dev/null); then
+ _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
+ fi
+
echo $_STATUS
}
@@ -84,10 +94,10 @@ _LIBERTY="$_LIBERTY%{$reset_color%}"
get_space () {
local STR=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
- local LENGTH=${#${(S%%)STR//$~zero/}}
+ local LENGTH=${#${(S%%)STR//$~zero/}}
local SPACES=""
(( LENGTH = ${COLUMNS} - $LENGTH - 1))
-
+
for i in {0..$LENGTH}
do
SPACES="$SPACES "
@@ -101,7 +111,7 @@ _1RIGHT="[%*] "
bureau_precmd () {
_1SPACES=`get_space $_1LEFT $_1RIGHT`
- print
+ print
print -rP "$_1LEFT$_1SPACES$_1RIGHT"
}
diff --git a/themes/candy.zsh-theme b/themes/candy.zsh-theme
index bc125c5ce..40e6d411e 100644
--- a/themes/candy.zsh-theme
+++ b/themes/candy.zsh-theme
@@ -1,4 +1,4 @@
-PROMPT=$'%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%I:%M:%S]} %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(git_prompt_info)\
+PROMPT=$'%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%X]} %{$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/dogenpunk.zsh-theme b/themes/dogenpunk.zsh-theme
index d6719281d..6a9921288 100644
--- a/themes/dogenpunk.zsh-theme
+++ b/themes/dogenpunk.zsh-theme
@@ -37,7 +37,7 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
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
+ if git log -n 1 > /dev/null 2>&1; then
# Get the last commit.
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
now=`date +%s`
diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme
index a3c505706..5f987099d 100644
--- a/themes/half-life.zsh-theme
+++ b/themes/half-life.zsh-theme
@@ -17,7 +17,7 @@ setopt prompt_subst
autoload -U add-zsh-hook
autoload -Uz vcs_info
-#use extended color pallete if available
+#use extended color palette if available
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
turquoise="%F{81}"
orange="%F{166}"
diff --git a/themes/kennethreitz.zsh-theme b/themes/kennethreitz.zsh-theme
index 109be0c22..b255a8d66 100644
--- a/themes/kennethreitz.zsh-theme
+++ b/themes/kennethreitz.zsh-theme
@@ -1,13 +1,15 @@
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-PROMPT='%{$fg[green]%}%c \
+PROMPT='$(virtualenv_prompt_info)%{%}%{$fg[green]%}%c \
$(git_prompt_info)\
+\
%{$fg[red]%}%(!.#.»)%{$reset_color%} '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} '
-ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}:: %{$fg[yellow]%}("
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[yellow]%}"
-
+ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$reset_color%}%{%}%{$fg[blue]%}"
+ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="!%{$reset_color%} " \ No newline at end of file
diff --git a/themes/muse.zsh-theme b/themes/muse.zsh-theme
index 4bd8fb825..c7cd9ee30 100644
--- a/themes/muse.zsh-theme
+++ b/themes/muse.zsh-theme
@@ -13,11 +13,11 @@ 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)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} '
+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_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%}✔"
@@ -28,3 +28,6 @@ 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 a5a226b69..e2424465a 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[0,4] ➜ %{$fg_bold[cyan]%}%c "
+HOST_PROMPT_="%{$fg_bold[red]%}@$HOST ➜ %{$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/peepcode.zsh-theme b/themes/peepcode.zsh-theme
index 96e4f1192..b6dfa6870 100644
--- a/themes/peepcode.zsh-theme
+++ b/themes/peepcode.zsh-theme
@@ -41,4 +41,4 @@ PROMPT='
%~
${smiley} %{$reset_color%}'
-RPROMPT='%{$fg[white]%} $(~/.rvm/bin/rvm-prompt)$(git_prompt)%{$reset_color%}'
+RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
diff --git a/themes/pure.zsh-theme b/themes/pure.zsh-theme
index 1473194a5..98c1312af 100644
--- a/themes/pure.zsh-theme
+++ b/themes/pure.zsh-theme
@@ -1,106 +1,10 @@
-#!/usr/bin/env zsh
+print -P '%F{yellow}'Oh My Zsh pure theme:
+cat <<-EOF
-# ------------------------------------------------------------------------------
-#
-# Pure - A minimal and beautiful theme for oh-my-zsh
-#
-# Based on the custom Zsh-prompt of the same name by Sindre Sorhus. A huge
-# thanks goes out to him for designing the fantastic Pure prompt in the first
-# place! I'd also like to thank Julien Nicoulaud for his "nicoulaj" theme from
-# which I've borrowed both some ideas and some actual code. You can find out
-# more about both of these fantastic two people here:
-#
-# Sindre Sorhus
-# Github: https://github.com/sindresorhus
-# Twitter: https://twitter.com/sindresorhus
-#
-# Julien Nicoulaud
-# Github: https://github.com/nicoulaj
-# Twitter: https://twitter.com/nicoulaj
-#
-# ------------------------------------------------------------------------------
+ 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.
-# Set required options
-#
-setopt prompt_subst
+EOF
+print -P '%f'
-# Load required modules
-#
-autoload -Uz vcs_info
-
-# Set vcs_info parameters
-#
-zstyle ':vcs_info:*' enable hg bzr git
-zstyle ':vcs_info:*:*' unstagedstr '!'
-zstyle ':vcs_info:*:*' stagedstr '+'
-zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%%u%c"
-zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%u%c (%a)"
-zstyle ':vcs_info:*:*' nvcsformats "%~" "" ""
-
-# Fastest possible way to check if repo is dirty
-#
-git_dirty() {
- # Check if we're in a git repo
- command git rev-parse --is-inside-work-tree &>/dev/null || return
- # Check if it's dirty
- command git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ] && echo "*"
-}
-
-# Display information about the current repository
-#
-repo_information() {
- echo "%F{blue}${vcs_info_msg_0_%%/.} %F{8}$vcs_info_msg_1_`git_dirty` $vcs_info_msg_2_%f"
-}
-
-# Displays the exec time of the last command if set threshold was exceeded
-#
-cmd_exec_time() {
- local stop=`date +%s`
- local start=${cmd_timestamp:-$stop}
- let local elapsed=$stop-$start
- [ $elapsed -gt 5 ] && echo ${elapsed}s
-}
-
-# Get the intial timestamp for cmd_exec_time
-#
-preexec() {
- cmd_timestamp=`date +%s`
-}
-
-# Output additional information about paths, repos and exec time
-#
-precmd() {
- vcs_info # Get version control info before we start outputting stuff
- print -P "\n$(repo_information) %F{yellow}$(cmd_exec_time)%f"
-}
-
-# Define prompts
-#
-PROMPT="%(?.%F{magenta}.%F{red})❯%f " # Display a red prompt char on failure
-RPROMPT="%F{8}${SSH_TTY:+%n@%m}%f" # Display username if connected via SSH
-
-# ------------------------------------------------------------------------------
-#
-# List of vcs_info format strings:
-#
-# %b => current branch
-# %a => current action (rebase/merge)
-# %s => current version control system
-# %r => name of the root directory of the repository
-# %S => current path relative to the repository root directory
-# %m => in case of Git, show information about stashes
-# %u => show unstaged changes in the repository
-# %c => show staged changes in the repository
-#
-# List of prompt format strings:
-#
-# prompt:
-# %F => color dict
-# %f => reset color
-# %~ => current path
-# %* => time
-# %n => username
-# %m => shortname host
-# %(?..) => prompt conditional - %(condition.true.false)
-#
-# ------------------------------------------------------------------------------
+source ${0:h:A}/refined.zsh-theme
diff --git a/themes/refined.zsh-theme b/themes/refined.zsh-theme
new file mode 100644
index 000000000..0e5681cc7
--- /dev/null
+++ b/themes/refined.zsh-theme
@@ -0,0 +1,106 @@
+#!/usr/bin/env zsh
+
+# ------------------------------------------------------------------------------
+#
+# Pure - A minimal and beautiful theme for oh-my-zsh
+#
+# Based on the custom Zsh-prompt of the same name by Sindre Sorhus. A huge
+# thanks goes out to him for designing the fantastic Pure prompt in the first
+# place! I'd also like to thank Julien Nicoulaud for his "nicoulaj" theme from
+# which I've borrowed both some ideas and some actual code. You can find out
+# more about both of these fantastic two people here:
+#
+# Sindre Sorhus
+# Github: https://github.com/sindresorhus
+# Twitter: https://twitter.com/sindresorhus
+#
+# Julien Nicoulaud
+# Github: https://github.com/nicoulaj
+# Twitter: https://twitter.com/nicoulaj
+#
+# ------------------------------------------------------------------------------
+
+# Set required options
+#
+setopt prompt_subst
+
+# Load required modules
+#
+autoload -Uz vcs_info
+
+# Set vcs_info parameters
+#
+zstyle ':vcs_info:*' enable hg bzr git
+zstyle ':vcs_info:*:*' unstagedstr '!'
+zstyle ':vcs_info:*:*' stagedstr '+'
+zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%%u%c"
+zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%u%c (%a)"
+zstyle ':vcs_info:*:*' nvcsformats "%~" "" ""
+
+# Fastest possible way to check if repo is dirty
+#
+git_dirty() {
+ # Check if we're in a git repo
+ command git rev-parse --is-inside-work-tree &>/dev/null || return
+ # Check if it's dirty
+ command git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ] && echo "*"
+}
+
+# Display information about the current repository
+#
+repo_information() {
+ echo "%F{blue}${vcs_info_msg_0_%%/.} %F{8}$vcs_info_msg_1_`git_dirty` $vcs_info_msg_2_%f"
+}
+
+# Displays the exec time of the last command if set threshold was exceeded
+#
+cmd_exec_time() {
+ local stop=`date +%s`
+ local start=${cmd_timestamp:-$stop}
+ let local elapsed=$stop-$start
+ [ $elapsed -gt 5 ] && echo ${elapsed}s
+}
+
+# Get the initial timestamp for cmd_exec_time
+#
+preexec() {
+ cmd_timestamp=`date +%s`
+}
+
+# Output additional information about paths, repos and exec time
+#
+precmd() {
+ vcs_info # Get version control info before we start outputting stuff
+ print -P "\n$(repo_information) %F{yellow}$(cmd_exec_time)%f"
+}
+
+# Define prompts
+#
+PROMPT="%(?.%F{magenta}.%F{red})❯%f " # Display a red prompt char on failure
+RPROMPT="%F{8}${SSH_TTY:+%n@%m}%f" # Display username if connected via SSH
+
+# ------------------------------------------------------------------------------
+#
+# List of vcs_info format strings:
+#
+# %b => current branch
+# %a => current action (rebase/merge)
+# %s => current version control system
+# %r => name of the root directory of the repository
+# %S => current path relative to the repository root directory
+# %m => in case of Git, show information about stashes
+# %u => show unstaged changes in the repository
+# %c => show staged changes in the repository
+#
+# List of prompt format strings:
+#
+# prompt:
+# %F => color dict
+# %f => reset color
+# %~ => current path
+# %* => time
+# %n => username
+# %m => shortname host
+# %(?..) => prompt conditional - %(condition.true.false)
+#
+# ------------------------------------------------------------------------------
diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme
index a3f1f3dfa..ba2a0dba6 100644
--- a/themes/rkj-repos.zsh-theme
+++ b/themes/rkj-repos.zsh-theme
@@ -23,14 +23,14 @@ function mygit() {
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
- echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_short_sha)$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX "
+ echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_short_sha)$(git_prompt_status)%{$fg_bold[blue]%}$ZSH_THEME_GIT_PROMPT_SUFFIX "
fi
}
function retcode() {}
# alternate prompt with git & hg
-PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
-%{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b '
+PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[white]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}]
+%{$fg_bold[blue]%}└─[%{$fg_bold[magenta]%}%?$(retcode)%{$fg_bold[blue]%}] <$(mygit)$(hg_prompt_info)>%{$reset_color%} '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
index 24e1e8c52..f9eca6a87 100644
--- a/themes/robbyrussell.zsh-theme
+++ b/themes/robbyrussell.zsh-theme
@@ -1,7 +1,7 @@
-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]%} % %{$reset_color%}'
+local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
+PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
-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_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme
index 13dc3ad2f..b72a41c92 100644
--- a/themes/steeef.zsh-theme
+++ b/themes/steeef.zsh-theme
@@ -19,7 +19,7 @@ setopt prompt_subst
autoload -U add-zsh-hook
autoload -Uz vcs_info
-#use extended color pallete if available
+#use extended color palette if available
if [[ $terminfo[colors] -ge 256 ]]; then
turquoise="%F{81}"
orange="%F{166}"
diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme
index 57d2649c6..e3f4019d6 100644
--- a/themes/sunrise.zsh-theme
+++ b/themes/sunrise.zsh-theme
@@ -10,9 +10,9 @@ B=$fg_no_bold[blue]
RESET=$reset_color
if [ "$USER" = "root" ]; then
- PROMPTCOLOR="%{$R%}" PREFIX="-!-";
+ PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-";
else
- PROMPTCOLOR="" PREFIX="---";
+ PROMPTCOLOR="" PROMPTPREFIX="---";
fi
local return_code="%(?..%{$R%}%? ↵%{$RESET%})"
@@ -66,7 +66,7 @@ function custom_git_prompt() {
}
# %B sets bold text
-PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
+PROMPT='%B$PROMPTPREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹"
diff --git a/themes/suvash.zsh-theme b/themes/suvash.zsh-theme
index c87f64558..1680973df 100644
--- a/themes/suvash.zsh-theme
+++ b/themes/suvash.zsh-theme
@@ -5,26 +5,30 @@ function prompt_char {
}
function virtualenv_info {
- [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
+ [[ -n "$VIRTUAL_ENV" ]] && echo '('${VIRTUAL_ENV:t}') '
}
-function collapse_pwd {
- echo $(pwd | sed -e "s,^$HOME,~,")
+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
}
-if which rvm-prompt &> /dev/null; then
- PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%}
-$(virtualenv_info)$(prompt_char) '
-else
- if which rbenv &> /dev/null; then
- PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}
-$(virtualenv_info)$(prompt_char) '
- fi
-fi
+PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)$(ruby_prompt)
+$(virtualenv_info) $(prompt_char) '
+ZSH_THEME_GIT_PROMPT_PREFIX=' on %F{magenta}'
+ZSH_THEME_GIT_PROMPT_SUFFIX='%f'
+ZSH_THEME_GIT_PROMPT_DIRTY='%F{green}!'
+ZSH_THEME_GIT_PROMPT_UNTRACKED='%F{green}?'
+ZSH_THEME_GIT_PROMPT_CLEAN=''
-ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
-ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
-ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
-ZSH_THEME_GIT_PROMPT_CLEAN=""
+ZSH_THEME_RUBY_PROMPT_PREFIX=' using %F{red}'
+ZSH_THEME_RUBY_PROMPT_SUFFIX='%f'
diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme
index ca1676fb5..3fa5d57ab 100644
--- a/themes/trapd00r.zsh-theme
+++ b/themes/trapd00r.zsh-theme
@@ -36,7 +36,7 @@ local c12=$(printf "\e[38;5;142m\e[1m")
local c13=$(printf "\e[38;5;196m\e[1m")
-# We dont want to use the extended colorset in the TTY / VC.
+# We don't want to use the extended colorset in the TTY / VC.
if [ "$TERM" = "linux" ]; then
c1=$( printf "\e[34;1m")
c2=$( printf "\e[35m")
@@ -71,7 +71,7 @@ prompt_jnrowe_precmd () {
PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
> '
-# modified, to be commited
+# 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%}
diff --git a/themes/xiong-chiamiov-plus.zsh-theme b/themes/xiong-chiamiov-plus.zsh-theme
index 095dae290..5fb4fe6f4 100644
--- a/themes/xiong-chiamiov-plus.zsh-theme
+++ b/themes/xiong-chiamiov-plus.zsh-theme
@@ -1,6 +1,6 @@
# user, host, full path, and time/date
# on two lines for easier vgrepping
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
-PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
+PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '
diff --git a/themes/xiong-chiamiov.zsh-theme b/themes/xiong-chiamiov.zsh-theme
index 7c4c2e4f8..0ed335fb5 100644
--- a/themes/xiong-chiamiov.zsh-theme
+++ b/themes/xiong-chiamiov.zsh-theme
@@ -1,6 +1,6 @@
# user, host, full path, and time/date
# on two lines for easier vgrepping
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
-PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
+PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '
diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme
index fd8adc41e..89d5355dc 100644
--- a/themes/ys.zsh-theme
+++ b/themes/ys.zsh-theme
@@ -1,18 +1,9 @@
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
-# It is recommended to use with a dark background and the font Inconsolata.
+# It is recommended to use with a dark background.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
-#
-# http://ysmood.org/wp/2013/03/my-ys-terminal-theme/
-# Mar 2013 ys
-
-# Machine name.
-function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || echo $HOST
-}
-
-# Directory info.
-local current_dir='${PWD/#$HOME/~}'
+#
+# Mar 2013 Yad Smood
# VCS
YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
@@ -21,7 +12,7 @@ YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o"
-# Git info.
+# Git info
local git_info='$(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
@@ -44,29 +35,26 @@ ys_hg_prompt_info() {
fi
}
-# Prompt format: \n # USER at MACHINE in DIRECTORY on git:BRANCH STATE [TIME] \n $
-PROMPT="
-%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
-%{$fg[cyan]%}%n \
-%{$fg[white]%}at \
-%{$fg[green]%}$(box_name) \
-%{$fg[white]%}in \
-%{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\
-${hg_info}\
-${git_info} \
-%{$fg[white]%}[%*]
-%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
+local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
-if [[ "$USER" == "root" ]]; then
+# Prompt format:
+#
+# PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] C:LAST_EXIT_CODE
+# $ COMMAND
+#
+# For example:
+#
+# % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] C:0
+# $
PROMPT="
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
-%{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \
-%{$fg[white]%}at \
-%{$fg[green]%}$(box_name) \
+%(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
+%{$fg[white]%}@ \
+%{$fg[green]%}%m \
%{$fg[white]%}in \
-%{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\
+%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
${hg_info}\
-${git_info} \
-%{$fg[white]%}[%*]
+${git_info}\
+ \
+%{$fg[white]%}[%*] $exit_code
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
-fi
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 881bc6c49..a57f6da0f 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -11,7 +11,7 @@ function _update_zsh_update() {
}
function _upgrade_zsh() {
- env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
+ env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
# update the zsh file
_update_zsh_update
}
@@ -29,31 +29,32 @@ fi
# Cancel upgrade if git is unavailable on the system
whence git >/dev/null || return 0
-if [ -f ~/.zsh-update ]
-then
- . ~/.zsh-update
+if mkdir "$ZSH/log/update.lock" 2>/dev/null; then
+ if [ -f ~/.zsh-update ]; then
+ . ~/.zsh-update
- if [[ -z "$LAST_EPOCH" ]]; then
- _update_zsh_update && return 0;
- fi
+ if [[ -z "$LAST_EPOCH" ]]; then
+ _update_zsh_update && return 0;
+ fi
- 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 check for updates? [Y/n]: \c"
- read line
- if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
+ epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
+ if [ $epoch_diff -gt $epoch_target ]; then
+ if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
_upgrade_zsh
else
- _update_zsh_update
+ echo "[Oh My Zsh] Would you like to check for updates? [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
fi
-else
- # create the zsh file
- _update_zsh_update
+
+ rmdir $ZSH/log/update.lock
fi
diff --git a/tools/install.sh b/tools/install.sh
index 8cba52085..3f4de8681 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -53,11 +53,6 @@ main() {
echo "Error: git is not installed"
exit 1
}
- 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"
- 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
@@ -66,6 +61,11 @@ main() {
exit 1
fi
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"
+ exit 1
+ }
+
printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n"
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
@@ -80,12 +80,6 @@ main() {
" ~/.zshrc > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc
- printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
- sed "/export PATH=/ c\\
- export PATH=\"$PATH\"
- " ~/.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