diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..aa18e0e5c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +[*.sh] +indent_size = 4 +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..076c35544 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + + + +**Describe the bug** + + +**To Reproduce** + + +**Expected behavior** + + +**Screenshots or recordings** + + +**System:** + - OS: [e.g. macOS] + - Zsh version [e.g. 5.6] + - Terminal emulator [e.g. iTerm2] + +**Additional context** + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..d9c324a55 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,26 @@ +--- +name: Feature request +about: Suggest a feature for Oh My Zsh +labels: 'Type: feature' + +--- + + + +**Is your feature request related to a particular plugin or theme? If so, specify it.** + + +**Is your feature request related to a problem? Please describe.** + + +**Describe the solution you'd like** + + +**Describe alternatives you've considered** + + +**Additional context** + diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md new file mode 100644 index 000000000..3c69a7d5e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support.md @@ -0,0 +1,12 @@ +--- +name: Support +about: Request support for any problem you're having with Oh My Zsh +labels: 'Type: support' + +--- + + diff --git a/.gitignore b/.gitignore index b2022081a..87a79cdae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ # custom files custom/ -!custom/plugins/example -!custom/example.zsh # temp files directories cache/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..20ad1ccee --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ohmyzsh@planetargon.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..f575157c2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,125 @@ +# 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. + +First, please take a moment to review our [code of conduct](CODE_OF_CONDUCT.md). + +These guidelines are an attempt at better addressing the huge amount of pending +issues and pull requests. Please read them closely. + +Foremost, be so kind as to [search](#use-the-search-luke). This ensures any contribution +you would make is not already covered. + +* [Issues](#reporting-issues) + * [You have a problem](#you-have-a-problem) + * [You have a suggestion](#you-have-a-suggestion) +* [Pull Requests](#submitting-pull-requests) + * [Getting started](#getting-started) + * [You have a solution](#you-have-a-solution) + * [You have an addition](#you-have-an-addition) +* [Information sources (_aka_ search)](#use-the-search-luke) + +**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/LICENSE.txt b/LICENSE.txt index 42f607f5d..4d465b1c3 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2009-2016 Robby Russell and contributors +Copyright (c) 2009-2019 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 diff --git a/README.md b/README.md index aab1af9fd..2f23febf5 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,24 @@ Oh My Zsh

-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. +Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration. -__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. +Sounds boring. Let's try again. -To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. +__Oh My Zsh will not make you a 10x developer...but you may feel like one.__ + +Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_ + +Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬 + +To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. ## Getting Started ### Prerequisites -__Disclaimer:__ _Oh My Zsh works best on OS X and Linux._ - -* Unix-based operating system (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) +* A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL is preferred, but cygwin or msys also mostly work. +* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (run `zsh --version` to confirm), check the following instructions here: [Installing ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH) * `curl` or `wget` should be installed * `git` should be installed @@ -32,38 +36,63 @@ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/mas #### via wget ```shell -sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" +sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" +``` + +#### Manual inspection + +It's a good idea to inspect the install script from projects you don't yet know. You can do +that by downloading the install script first, looking through it so everything looks normal, +then running it: + +```shell +curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh +sh install.sh ``` ## Using Oh My Zsh ### Plugins -Oh My Zsh comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. +Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. #### 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. - -For example, this line might begin to look like... +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. ```shell -plugins=(git bundler osx rake ruby) +vi ~/.zshrc ``` +For example, this might begin to look like this: + +```shell +plugins=( + git + bundler + dotenv + osx + rake + rbenv + ruby +) +``` + +_Note that the plugins are separated by whitespace. **Do not** use commas between them._ + #### Using Plugins Most plugins (should! we're working on this) include a __README__, which documents how to use them. ### Themes -We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out! +We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes) on the wiki. Check them out! #### 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: +Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like: ```shell ZSH_THEME="robbyrussell" @@ -73,9 +102,12 @@ To use a different theme, simply change the value to match the name of your desi ```shell ZSH_THEME="agnoster" # (this is one of the fancy ones) +# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster ``` -Open up a new terminal window and your prompt should look something like... +_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ + +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) @@ -88,6 +120,14 @@ If you're feeling feisty, you can let the computer select one randomly for you e ZSH_THEME="random" # (...please let it be pie... please be some pie..) ``` +And if you want to pick random theme from a list of your favorite themes: + +```shell +ZSH_THEME_RANDOM_CANDIDATES=( + "robbyrussell" + "agnoster" +) +``` ## Advanced Topics @@ -95,16 +135,52 @@ If you're the type that likes to get their hands dirty, these sections might res ### Advanced Installation -Some users may want to change the default path, or manually install Oh My Zsh. +Some users may want to manually install Oh My Zsh, or change the default path or other settings that +the installer accepts (these settings are also documented at the top of the install script). #### Custom Directory The default location is `~/.oh-my-zsh` (hidden in your home directory) -If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this: +If you'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.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" +ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh +``` + +#### Unattended install + +If you're running the Oh My Zsh install script as part of an automated install, you can pass the +flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change +the default shell, and also won't run `zsh` when the installation has finished. + +```shell +sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended +``` + +#### Installing from a forked repository + +The install script also accepts these variables to allow installation of a different repository: + +- `REPO` (default: `robbyrussell/oh-my-zsh`): this takes the form of `owner/repository`. If you set + this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`. + +- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository + clone. You can use this setting if you want to install from a fork that is not on GitHub (GitLab, + Bitbucket...) or if you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`). + + _NOTE: it's incompatible with setting the `REPO` variable. This setting will take precedence._ + +- `BRANCH` (default: `master`): you can use this setting if you want to change the default branch to be + checked out when cloning the repository. This might be useful for testing a Pull Request, or if you + want to use a branch other than `master`. + +For example: + +```shell +REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh ``` #### Manual Installation @@ -112,7 +188,7 @@ export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubus ##### 1. Clone the repository: ```shell -git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh +git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh ``` ##### 2. *Optionally*, backup your existing `~/.zshrc` file: @@ -123,7 +199,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 @@ -132,9 +208,11 @@ cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc ##### 4. Change your default shell ```shell -chsh -s /bin/zsh +chsh -s $(which zsh) ``` +You must log out from your user session and log back in to see this change. + ##### 5. Initialize your new zsh configuration Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. @@ -143,8 +221,10 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf If you have any hiccups installing, here are a few common fixes. -* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`. -* If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. +* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after +switching to `oh-my-zsh`. +* If you installed manually or changed the install location, check the `ZSH` environment variable in +`~/.zshrc`. ### Custom Plugins and Themes @@ -176,7 +256,7 @@ If you'd like to upgrade at any point in time (maybe someone just released a new upgrade_oh_my_zsh ``` -Magic! +Magic! 🎉 ## Uninstalling Oh My Zsh @@ -184,12 +264,16 @@ Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy b If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration. -## Contributing +## How do I contribute to Oh My Zsh? -I'm far from being a [Zsh](http://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! +Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md). + +I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. +See [Contributing](CONTRIBUTING.md) for more details. + ### Do NOT send us themes We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. @@ -202,11 +286,14 @@ 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 -We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town! +We have [stickers, shirts, and coffee mugs available](https://shop.planetargon.com/collections/oh-my-zsh?utm_source=github) for you to show off your love of Oh My Zsh. Again, you will become the talk of the town! ## License @@ -214,6 +301,6 @@ 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) +![Planet Argon](https://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). +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). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github). diff --git a/custom/themes/example.zsh-theme b/custom/themes/example.zsh-theme new file mode 100644 index 000000000..ef8f1c630 --- /dev/null +++ b/custom/themes/example.zsh-theme @@ -0,0 +1,4 @@ +# Put your custom themes in this folder. +# Example: + +PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% " 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/compfix.zsh b/lib/compfix.zsh index 208aaadb1..b09b283f2 100644 --- a/lib/compfix.zsh +++ b/lib/compfix.zsh @@ -2,10 +2,6 @@ # insecure ownership or permissions) by: # # * Human-readably notifying the user of these insecurities. -# * Moving away all existing completion caches to a temporary directory. Since -# any of these caches may have been generated from insecure directories, they -# are all suspect now. Failing to do so typically causes subsequent compinit() -# calls to fail with "command not found: compdef" errors. (That's bad.) function handle_completion_insecurities() { # List of the absolute paths of all unique insecure directories, split on # newline from compaudit()'s output resembling: @@ -22,39 +18,27 @@ function handle_completion_insecurities() { insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} ) # If no such directories exist, get us out of here. - if (( ! ${#insecure_dirs} )); then - print "[oh-my-zsh] No insecure completion-dependent directories detected." - return - fi + [[ -z "${insecure_dirs}" ]] && return # List ownership and permissions of all insecure directories. print "[oh-my-zsh] Insecure completion-dependent directories detected:" ls -ld "${(@)insecure_dirs}" - print "[oh-my-zsh] For safety, completions will be disabled until you manually fix all" - print "[oh-my-zsh] insecure directory permissions and ownership and restart oh-my-zsh." - print "[oh-my-zsh] See the above list for directories with group or other writability.\n" - # Locally enable the "NULL_GLOB" option, thus removing unmatched filename - # globs from argument lists *AND* printing no warning when doing so. Failing - # to do so prints an unreadable warning if no completion caches exist below. - setopt local_options null_glob + cat </dev/null - else - nohup $open_cmd "$@" &>/dev/null - fi + ${=open_cmd} "$@" &>/dev/null } # @@ -52,8 +46,7 @@ function open_command() { # 1 if it does not exist # function alias_value() { - alias "$1" | sed "s/^$1='\(.*\)'$/\1/" - test $(alias "$1") + (( $+aliases[$1] )) && echo $aliases[$1] } # @@ -81,12 +74,12 @@ function try_alias_value() { # 0 if the variable exists, 3 if it was set # function default() { - test `typeset +m "$1"` && return 0 + (( $+parameters[$1] )) && return 0 typeset -g "$1"="$2" && return 3 } # -# 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 @@ -95,8 +88,8 @@ function default() { # 0 if the env variable exists, 3 if it was set # function env_default() { - env | grep -q "^$1=" && return 0 - export "$1=$2" && return 3 + (( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0 + export "$1=$2" && return 3 } diff --git a/lib/git.zsh b/lib/git.zsh index f7eccb81d..640561e97 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -10,13 +10,10 @@ function git_prompt_info() { # Checks if working tree is dirty function parse_git_dirty() { - local STATUS='' - local FLAGS - FLAGS=('--porcelain') + local STATUS + local -a FLAGS + FLAGS=('--porcelain' '--ignore-submodules=dirty') if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then - if [[ $POST_1_7_2_GIT -gt 0 ]]; then - FLAGS+='--ignore-submodules=dirty' - fi if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then FLAGS+='--untracked-files=no' fi @@ -77,8 +74,8 @@ function git_current_branch() { # Gets the number of commits ahead from remote function git_commits_ahead() { if command git rev-parse --git-dir &>/dev/null; then - local commits="$(git rev-list --count @{upstream}..HEAD)" - if [[ "$commits" != 0 ]]; then + local commits="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)" + if [[ -n "$commits" && "$commits" != 0 ]]; then echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi fi @@ -87,8 +84,8 @@ function git_commits_ahead() { # Gets the number of commits behind remote function git_commits_behind() { if command git rev-parse --git-dir &>/dev/null; then - local commits="$(git rev-list --count HEAD..@{upstream})" - if [[ "$commits" != 0 ]]; then + local commits="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)" + if [[ -n "$commits" && "$commits" != 0 ]]; then echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" fi fi @@ -141,11 +138,15 @@ function git_prompt_status() { STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" + elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" fi if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" + elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" fi @@ -177,28 +178,6 @@ function git_prompt_status() { echo $STATUS } -# Compares the provided version of git to the version installed and on path -# Outputs -1, 0, or 1 if the installed version is less than, equal to, or -# greater than the input version, respectively. -function git_compare_version() { - local INPUT_GIT_VERSION INSTALLED_GIT_VERSION - INPUT_GIT_VERSION=(${(s/./)1}) - INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)) - INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}) - - for i in {1..3}; do - if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then - echo 1 - return 0 - fi - if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then - echo -1 - return 0 - fi - done - echo 0 -} - # Outputs the name of the current user # Usage example: $(git_current_user_name) function git_current_user_name() { @@ -210,8 +189,3 @@ function git_current_user_name() { 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 -unfunction git_compare_version diff --git a/lib/history.zsh b/lib/history.zsh index 5de71c2d3..52e45bf4c 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -1,24 +1,40 @@ -## Command history configuration -if [ -z "$HISTFILE" ]; then - HISTFILE=$HOME/.zsh_history -fi +## History wrapper +function omz_history { + local clear list + zparseopts -E c=clear l=list -HISTSIZE=10000 -SAVEHIST=10000 + if [[ -n "$clear" ]]; then + # if -c provided, clobber the history file + echo -n >| "$HISTFILE" + echo >&2 History file deleted. Reload the session to see its effects. + elif [[ -n "$list" ]]; then + # if -l provided, run as if calling `fc' directly + builtin fc "$@" + else + # unless a number is provided, show all history events (starting from 1) + [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1 + fi +} -# Show history -case $HIST_STAMPS in - "mm/dd/yyyy") alias history='fc -fl 1' ;; - "dd.mm.yyyy") alias history='fc -El 1' ;; - "yyyy-mm-dd") alias history='fc -il 1' ;; - *) alias history='fc -l 1' ;; +# Timestamp format +case ${HIST_STAMPS-} in + "mm/dd/yyyy") alias history='omz_history -f' ;; + "dd.mm.yyyy") alias history='omz_history -E' ;; + "yyyy-mm-dd") alias history='omz_history -i' ;; + "") alias history='omz_history' ;; + *) alias history="omz_history -t '$HIST_STAMPS'" ;; esac -setopt append_history -setopt extended_history -setopt hist_expire_dups_first -setopt hist_ignore_dups # ignore duplication command history list -setopt hist_ignore_space -setopt hist_verify -setopt inc_append_history -setopt share_history # share command history data +## History file configuration +[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" +HISTSIZE=50000 +SAVEHIST=10000 + +## History command configuration +setopt extended_history # record timestamp of command in HISTFILE +setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_ignore_dups # ignore duplicated commands history list +setopt hist_ignore_space # ignore commands that start with space +setopt hist_verify # show command with history expansion to user before running it +setopt inc_append_history # add commands to HISTFILE in order of execution +setopt share_history # share command history data diff --git a/lib/misc.zsh b/lib/misc.zsh index c81dab413..61571afc9 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -1,7 +1,7 @@ -## Load smart urls if available -# bracketed-paste-magic is known buggy in zsh 5.1.1 (only), so skip it there; see #4434 autoload -Uz is-at-least -if [[ $ZSH_VERSION != 5.1.1 ]]; then + +# *-magic is known buggy in some versions; disable if so +if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then for d in $fpath; do if [[ -e "$d/url-quote-magic" ]]; then if is-at-least 5.1; then @@ -18,13 +18,11 @@ fi ## jobs setopt long_list_jobs -## pager -export PAGER="less" -export LESS="-R" +env_default 'PAGER' 'less' +env_default 'LESS' '-R' ## super user alias -alias _='sudo' -alias please='sudo' +alias _='sudo ' ## more intelligent acking for ubuntu users if which ack-grep &> /dev/null; then @@ -33,10 +31,5 @@ else alias afind='ack -il' fi -# only define LC_CTYPE if undefined -if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then - export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG -fi - # recognize comments setopt interactivecomments diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh index 335c02a3d..5069c4b21 100644 --- a/lib/prompt_info_functions.zsh +++ b/lib/prompt_info_functions.zsh @@ -10,9 +10,15 @@ # Dummy implementations that return false to prevent command_not_found # errors with themes, that implement these functions # Real implementations will be used when the respective plugins are loaded -function chruby_prompt_info hg_prompt_info pyenv_prompt_info \ - rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \ - virtualenv_prompt_info { +function chruby_prompt_info \ + rbenv_prompt_info \ + hg_prompt_info \ + pyenv_prompt_info \ + svn_prompt_info \ + vi_mode_prompt_info \ + virtualenv_prompt_info \ + jenv_prompt_info \ +{ return 1 } @@ -22,10 +28,13 @@ function rvm_prompt_info() { [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 local rvm_prompt rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) - [[ "${rvm_prompt}x" == "x" ]] && return 1 - echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" + [[ -z "${rvm_prompt}" ]] && return 1 + echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}" } +ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" + + # use this to enable users to see their ruby version, no matter which # version management system they use function ruby_prompt_info() { diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh index 87092d8ae..312ab2248 100644 --- a/lib/spectrum.zsh +++ b/lib/spectrum.zsh @@ -1,7 +1,7 @@ #! /bin/zsh # A script to make using 256 colors in zsh less painful. # P.C. Shyamshankar -# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ +# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ typeset -AHg FX FG BG diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 871ab28df..aa14f3f07 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -21,7 +21,7 @@ function title { print -Pn "\e]2;$2:q\a" # set window name print -Pn "\e]1;$1:q\a" # set tab name ;; - screen*) + screen*|tmux*) print -Pn "\ek$1:q\e\\" # set screen hardstatus ;; *) @@ -80,7 +80,7 @@ preexec_functions+=(omz_termsupport_preexec) # Keep Apple Terminal.app's current working directory updated -# Based on this answer: http://superuser.com/a/315029 +# Based on this answer: https://superuser.com/a/315029 # With extra fixes to handle multibyte chars and non-UTF-8 locales if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 5c5bb0e6d..5016d86ca 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,45 +1,54 @@ # 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 + 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|freebsd)* ]]; 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 auto_cd setopt multios +setopt prompt_subst -if [[ x$WINDOW != x ]] -then - SCREEN_NO="%B$WINDOW%b " -else - SCREEN_NO="" -fi - -# Apply theming defaults -PS1="%n@%m:%~%# " +[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO="" # git theming default: Variables for theming the git info prompt ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean - -# Setup the prompt with pretty colors -setopt prompt_subst +ZSH_THEME_RUBY_PROMPT_PREFIX="(" +ZSH_THEME_RUBY_PROMPT_SUFFIX=")" diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index ed258f0ea..6b2662d5e 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,6 +1,17 @@ +# Set ZSH_CACHE_DIR to the path where cache files should be created +# or else we will use the default cache/ +if [[ -z "$ZSH_CACHE_DIR" ]]; then + ZSH_CACHE_DIR="$ZSH/cache" +fi + +# Migrate .zsh-update file to $ZSH_CACHE_DIR +if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then + mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update +fi + # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then - env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh + env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh @@ -11,29 +22,12 @@ fpath=($ZSH/functions $ZSH/completions $fpath) # Load all stock functions (from $fpath files) called below. autoload -U compaudit compinit -: ${ZSH_DISABLE_COMPFIX:=true} - # Set ZSH_CUSTOM to the path where your custom config files # and plugins exists, or else we will use the default custom/ if [[ -z "$ZSH_CUSTOM" ]]; then ZSH_CUSTOM="$ZSH/custom" 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" -fi - - -# Load all of the config files in ~/oh-my-zsh that end in .zsh -# TIP: Add files you don't want in git to .gitignore -for config_file ($ZSH/lib/*.zsh); do - custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" - [ -f "${custom_config_file}" ] && config_file=${custom_config_file} - source $config_file -done - is_plugin() { local base_dir=$1 @@ -41,6 +35,7 @@ is_plugin() { test -f $base_dir/plugins/$name/$name.plugin.zsh \ || test -f $base_dir/plugins/$name/_$name } + # Add all defined plugins to fpath. This must be done # before running compinit. for plugin ($plugins); do @@ -48,12 +43,14 @@ for plugin ($plugins); do fpath=($ZSH_CUSTOM/plugins/$plugin $fpath) elif is_plugin $ZSH $plugin; then fpath=($ZSH/plugins/$plugin $fpath) + else + echo "[oh-my-zsh] plugin '$plugin' not found" fi done # 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/.*/} @@ -65,18 +62,25 @@ if [ -z "$ZSH_COMPDUMP" ]; then fi if [[ $ZSH_DISABLE_COMPFIX != true ]]; then - # If completion insecurities exist, warn the user without enabling completions. - if ! compaudit &>/dev/null; then - # This function resides in the "lib/compfix.zsh" script sourced above. - handle_completion_insecurities - # Else, enable and cache completions to the desired file. - else - compinit -d "${ZSH_COMPDUMP}" - fi + source $ZSH/lib/compfix.zsh + # If completion insecurities exist, warn the user + handle_completion_insecurities + # Load only from secure directories + compinit -i -C -d "${ZSH_COMPDUMP}" else - compinit -i -d "${ZSH_COMPDUMP}" + # If the user wants it, load from all found directories + compinit -u -C -d "${ZSH_COMPDUMP}" fi + +# Load all of the config files in ~/oh-my-zsh that end in .zsh +# TIP: Add files you don't want in git to .gitignore +for config_file ($ZSH/lib/*.zsh); do + custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" + [ -f "${custom_config_file}" ] && config_file=${custom_config_file} + source $config_file +done + # Load all of the plugins that were defined in ~/.zshrc for plugin ($plugins); do if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then @@ -93,8 +97,12 @@ done unset config_file # Load the theme -if [ "$ZSH_THEME" = "random" ]; then - themes=($ZSH/themes/*zsh-theme) +if [[ "$ZSH_THEME" == "random" ]]; then + if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then + themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) + else + themes=($ZSH/themes/*zsh-theme) + fi N=${#themes[@]} ((N=(RANDOM%N)+1)) RANDOM_THEME=${themes[$N]} diff --git a/plugins/adb/README.md b/plugins/adb/README.md index 075beec0e..83dcc7288 100644 --- a/plugins/adb/README.md +++ b/plugins/adb/README.md @@ -1,7 +1,7 @@ # adb autocomplete plugin * Adds autocomplete options for all adb commands. - +* Add autocomplete for `adb -s` ## Requirements diff --git a/plugins/adb/_adb b/plugins/adb/_adb index f30f3247f..78c457746 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' ) @@ -38,8 +43,22 @@ local expl local -a pkgs installed_pkgs _arguments \ + '-s[devices]:specify device:->specify_device' \ '*:: :->subcmds' && return 0 +case "$state" in + specify_device) + _values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \ + {sub(/ +/," ",$0); \ + gsub(":","\\:",$1); \ + for(i=1;i<=NF;i++) { + if($i ~ /model:/) { split($i,m,":") } \ + else if($i ~ /product:/) { split($i,p,":") } } \ + printf "%s[%s(%s)] ",$1, p[2], m[2]}'):-""} + return + ;; +esac + if (( CURRENT == 1 )); then _describe -t commands "adb subcommand" _1st_arguments return diff --git a/plugins/alias-finder/README.md b/plugins/alias-finder/README.md new file mode 100644 index 000000000..409f4b653 --- /dev/null +++ b/plugins/alias-finder/README.md @@ -0,0 +1,46 @@ +# alias-finder plugin + +This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier. + +To use it, add `alias-finder` to the `plugins` array of your zshrc file: +``` +plugins=(... alias-finder) +``` + +## Usage +To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this. + +## Options + +- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input). +- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input. + +## Examples +``` +$ alias-finder "git pull" +gl='git pull' +g=git +``` +``` +$ alias-finder "web_search google oh my zsh" +google='web_search google' +``` +``` +$ alias-finder "git commit -v" +gc="git commit -v" +g=git +``` +``` +$ alias-finder -e "git commit -v" +gc='git commit -v' +``` +``` +$ alias-finder -l "git commit -v" +gc='git commit -v' +'gc!'='git commit -v --amend' +gca='git commit -v -a' +'gca!'='git commit -v -a --amend' +'gcan!'='git commit -v -a --no-edit --amend' +'gcans!'='git commit -v -a -s --no-edit --amend' +'gcn!'='git commit -v --no-edit --amend' +``` diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh new file mode 100644 index 000000000..2bfaad597 --- /dev/null +++ b/plugins/alias-finder/alias-finder.plugin.zsh @@ -0,0 +1,46 @@ +alias-finder() { + local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd="" + for i in $@; do + case $i in + -e|--exact) exact=true;; + -l|--longer) longer=true;; + *) + if [[ -z $cmd ]]; then + cmd=$i + else + cmd="$cmd $i" + fi + ;; + esac + done + cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep + if [[ $(wc -l <<< $cmd) == 1 ]]; then + while [[ $cmd != "" ]]; do + if [[ $longer = true ]]; then + wordStart="'{0,1}" + else + wordEnd="$" + multiWordEnd="'$" + fi + if [[ $cmd == *" "* ]]; then + local finder="'$cmd$multiWordEnd" + else + local finder=$wordStart$cmd$wordEnd + fi + alias | grep -E "=$finder" + if [[ $exact = true || $longer = true ]]; then + break + else + cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word + fi + done + fi +} + +preexec_alias-finder() { + if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then + alias-finder $1 + fi +} + +preexec_functions+=(preexec_alias-finder) diff --git a/plugins/ansible/README.md b/plugins/ansible/README.md new file mode 100644 index 000000000..e0e6a19bb --- /dev/null +++ b/plugins/ansible/README.md @@ -0,0 +1,34 @@ +# ansible plugin + +## Introduction + +The `ansible plugin` adds several aliases for useful [ansible](https://docs.ansible.com/ansible/latest/index.html) commands and [aliases](#aliases). + +To use it, add `ansible` to the plugins array of your zshrc file: + +``` +plugins=(... ansible) +``` + +## Aliases + +| Command | Description | +|:-------------------------------------------|:--------------------------------------------------------------------| +| `ansible-version` / `aver` | Show the version on ansible installed in this host | +| `ansible-role-init ` / `arinit` | Creates the Ansible Role as per Ansible Galaxy standard | +| `a` | command `ansible` | +| `aconf` | command `ansible-config` | +| `acon` | command `ansible-console` | +| `ainv` | command `ansible-inventory` | +| `aplaybook` | command `ansible-playbook` | +| `ainv` | command `ansible-inventory` | +| `adoc` | command `ansible-doc` | +| `agal` | command `ansible-galaxy` | +| `apull` | command `ansible-pull` | +| `aval` | command `ansible-vault` | + +## Maintainer + +### [Deepankumar](https://github.com/deepan10) + +[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin) diff --git a/plugins/ansible/ansible.plugin.zsh b/plugins/ansible/ansible.plugin.zsh new file mode 100644 index 000000000..f68ff23a5 --- /dev/null +++ b/plugins/ansible/ansible.plugin.zsh @@ -0,0 +1,28 @@ +# Functions +function ansible-version(){ + ansible --version +} + +function ansible-role-init(){ + if ! [ -z $1] ; then + echo "Ansible Role : $1 Creating...." + ansible-galaxy init $1 + tree $1 + else + echo "Usage : ansible-role-init " + echo "Example : ansible-role-init role1" + fi +} + +# Alias +alias a='ansible ' +alias aconf='ansible-config ' +alias acon='ansible-console ' +alias aver='ansible-version' +alias arinit='ansible-role-init' +alias aplaybook='ansible-playbook ' +alias ainv='ansible-inventory ' +alias adoc='ansible-doc ' +alias agal='ansible-galaxy ' +alias apull='ansible-pull ' +alias aval='ansible-vault' \ No newline at end of file diff --git a/plugins/ant/README.md b/plugins/ant/README.md new file mode 100644 index 000000000..5f88984ac --- /dev/null +++ b/plugins/ant/README.md @@ -0,0 +1,12 @@ +# Ant + +This plugin provides completion for [Ant](https://ant.apache.org/). + +To use it add ant to the plugins array in your zshrc file. + +```bash +plugins=(... ant) +``` + +It caches ant targets in a file named `.ant_targets`, you might want to add that to +your `.gitignore` file. diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index 785538a56..ff2b6a4c4 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -2,6 +2,51 @@ ## Features +#### YAY + +| Alias | Command | Description | +|---------|------------------------------------|---------------------------------------------------------------------| +| yaconf | yay -Pg | Print current configuration | +| yain | yay -S | Install packages from the repositories | +| yains | yay -U | Install a package from a local file | +| yainsd | yay -S --asdeps | Install packages as dependencies of another package | +| yaloc | yay -Qi | Display information about a package in the local database | +| yalocs | yay -Qs | Search for packages in the local database | +| yalst | yay -Qe | List installed packages including from AUR (tagged as "local") | +| yamir | yay -Syy | Force refresh of all package lists after updating mirrorlist | +| yaorph | yay -Qtd | Remove orphans using yay | +| yare | yay -R | Remove packages, keeping its settings and dependencies | +| yarem | yay -Rns | Remove packages, including its settings and unneeded dependencies | +| yarep | yay -Si | Display information about a package in the repositories | +| yareps | yay -Ss | Search for packages in the repositories | +| yaupg | yay -Syu | Sync with repositories before upgrading packages | +| yasu | yay -Syu --no-confirm | Same as `yaupg`, but without confirmation | + +#### TRIZEN + +| Alias | Command | Description | +|---------|------------------------------------|---------------------------------------------------------------------| +| trconf | trizen -C | Fix all configuration files with vimdiff | +| trin | trizen -S | Install packages from the repositories | +| trins | trizen -U | Install a package from a local file | +| trinsd | trizen -S --asdeps | Install packages as dependencies of another package | +| trloc | trizen -Qi | Display information about a package in the local database | +| trlocs | trizen -Qs | Search for packages in the local database | +| trlst | trizen -Qe | List installed packages including from AUR (tagged as "local") | +| trmir | trizen -Syy | Force refresh of all package lists after updating mirrorlist | +| trorph | trizen -Qtd | Remove orphans using yaourt | +| trre | trizen -R | Remove packages, keeping its settings and dependencies | +| trrem | trizen -Rns | Remove packages, including its settings and unneeded dependencies | +| trrep | trizen -Si | Display information about a package in the repositories | +| trreps | trizen -Ss | Search for packages in the repositories | +| trupd | trizen -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases | +| trupd | trizen -Sy && sudo abs | Update and refresh the local package and ABS databases | +| trupd | trizen -Sy && sudo aur | Update and refresh the local package and AUR databases | +| trupd | trizen -Sy | Update and refresh the local package database | +| trupg | trizen -Syua | Sync with repositories before upgrading all packages (from AUR too) | +| trsu | trizen -Syua --no-confirm | Same as `trupg`, but without confirmation | +| upgrade | trizen -Syu | Sync with repositories before upgrading packages | + #### YAOURT | Alias | Command | Description | @@ -27,6 +72,30 @@ | yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation | | upgrade | yaourt -Syu | Sync with repositories before upgrading packages | +#### PACAUR + +| Alias | Command | Description | +|---------|------------------------------------|---------------------------------------------------------------------| +| pain | pacaur -S | Install packages from the repositories | +| pains | pacaur -U | Install a package from a local file | +| painsd | pacaur -S --asdeps | Install packages as dependencies of another package | +| paloc | pacaur -Qi | Display information about a package in the local database | +| palocs | pacaur -Qs | Search for packages in the local database | +| palst | pacaur -Qe | List installed packages including from AUR (tagged as "local") | +| pamir | pacaur -Syy | Force refresh of all package lists after updating mirrorlist | +| paorph | pacaur -Qtd | Remove orphans using pacaur | +| pare | pacaur -R | Remove packages, keeping its settings and dependencies | +| parem | pacaur -Rns | Remove packages, including its settings and unneeded dependencies | +| parep | pacaur -Si | Display information about a package in the repositories | +| pareps | pacaur -Ss | Search for packages in the repositories | +| paupd | pacaur -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases | +| paupd | pacaur -Sy && sudo abs | Update and refresh the local package and ABS databases | +| paupd | pacaur -Sy && sudo aur | Update and refresh the local package and AUR databases | +| paupd | pacaur -Sy | Update and refresh the local package database | +| paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) | +| pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation | +| upgrade | pacaur -Syu | Sync with repositories before upgrading packages | + #### PACMAN | Alias | Command | Description | @@ -49,6 +118,10 @@ | pacupd | sudo pacman -Sy | Update and refresh the local package database | | pacupg | sudo pacman -Syu | Sync with repositories before upgrading packages | | upgrade | sudo pacman -Syu | Sync with repositories before upgrading packages | +| pacfileupg | sudo pacman -Fy | Download fresh package databases from the server | +| pacfiles | pacman -Fs | Search package file names for matching strings | +| pacls | pacman -Ql | List files in a package | +| pacown | pacman -Qo | Show which package owns a file | | Function | Description | |----------------|------------------------------------------------------| @@ -56,6 +129,7 @@ | paclist | List all installed packages with a short description | | pacmanallkeys | Get all keys for developers and trusted users | | pacmansignkeys | Locally trust all keys passed as parameters | +| pacweb | Open the website of an ArchLinux package | --- @@ -67,3 +141,6 @@ - Martin Putniorz - mputniorz@gmail.com - MatthR3D - matthr3d@gmail.com - ornicar - thibault.duplessis@gmail.com +- Juraj Fiala - doctorjellyface@riseup.net +- Majora320 (Moses Miller) - Majora320@gmail.com +- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 1637e8561..e0101c7eb 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -1,12 +1,33 @@ -if ! (( $+commands[yaourt] )); then - upgrade() { - sudo pacman -Syu - } -else - upgrade () { - yaourt -Syu - } +if (( $+commands[trizen] )); then + alias trconf='trizen -C' + alias trupg='trizen -Syua' + alias trsu='trizen -Syua --noconfirm' + alias trin='trizen -S' + alias trins='trizen -U' + alias trre='trizen -R' + alias trrem='trizen -Rns' + alias trrep='trizen -Si' + alias trreps='trizen -Ss' + alias trloc='trizen -Qi' + alias trlocs='trizen -Qs' + alias trlst='trizen -Qe' + alias trorph='trizen -Qtd' + alias trinsd='trizen -S --asdeps' + alias trmir='trizen -Syy' + + if (( $+commands[abs] && $+commands[aur] )); then + alias trupd='trizen -Sy && sudo abs && sudo aur' + elif (( $+commands[abs] )); then + alias trupd='trizen -Sy && sudo abs' + elif (( $+commands[aur] )); then + alias trupd='trizen -Sy && sudo aur' + else + alias trupd='trizen -Sy' + fi +fi + +if (( $+commands[yaourt] )); then alias yaconf='yaourt -C' alias yaupg='yaourt -Syua' alias yasu='yaourt -Syua --noconfirm' @@ -35,6 +56,84 @@ else fi fi +if (( $+commands[yay] )); then + alias yaconf='yay -Pg' + alias yaupg='yay -Syu' + alias yasu='yay -Syu --noconfirm' + alias yain='yay -S' + alias yains='yay -U' + alias yare='yay -R' + alias yarem='yay -Rns' + alias yarep='yay -Si' + alias yareps='yay -Ss' + alias yaloc='yay -Qi' + alias yalocs='yay -Qs' + alias yalst='yay -Qe' + alias yaorph='yay -Qtd' + alias yainsd='yay -S --asdeps' + alias yamir='yay -Syy' + + + if (( $+commands[abs] && $+commands[aur] )); then + alias yaupd='yay -Sy && sudo abs && sudo aur' + elif (( $+commands[abs] )); then + alias yaupd='yay -Sy && sudo abs' + elif (( $+commands[aur] )); then + alias yaupd='yay -Sy && sudo aur' + else + alias yaupd='yay -Sy' + fi +fi + +if (( $+commands[pacaur] )); then + alias paupg='pacaur -Syu' + alias pasu='pacaur -Syu --noconfirm' + alias pain='pacaur -S' + alias pains='pacaur -U' + alias pare='pacaur -R' + alias parem='pacaur -Rns' + alias parep='pacaur -Si' + alias pareps='pacaur -Ss' + alias paloc='pacaur -Qi' + alias palocs='pacaur -Qs' + alias palst='pacaur -Qe' + alias paorph='pacaur -Qtd' + alias painsd='pacaur -S --asdeps' + alias pamir='pacaur -Syy' + + if (( $+commands[abs] && $+commands[aur] )); then + alias paupd='pacaur -Sy && sudo abs && sudo aur' + elif (( $+commands[abs] )); then + alias paupd='pacaur -Sy && sudo abs' + elif (( $+commands[aur] )); then + alias paupd='pacaur -Sy && sudo aur' + else + alias paupd='pacaur -Sy' + fi +fi + +if (( $+commands[trizen] )); then + function upgrade() { + trizen -Syu + } +elif (( $+commands[pacaur] )); then + function upgrade() { + pacaur -Syu + } +elif (( $+commands[yaourt] )); then + function upgrade() { + yaourt -Syu + } +elif (( $+commands[yay] )); then + function upgrade() { + yay -Syu + } +else + function upgrade() { + sudo pacman -Syu + } +fi + # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips alias pacupg='sudo pacman -Syu' alias pacin='sudo pacman -S' @@ -49,6 +148,10 @@ 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 -Fs' +alias pacls='pacman -Ql' +alias pacown='pacman -Qo' if (( $+commands[abs] && $+commands[aur] )); then @@ -61,13 +164,13 @@ else alias pacupd='sudo pacman -Sy' fi -paclist() { +function paclist() { # Source: https://bbs.archlinux.org/viewtopic.php?id=93683 LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \ awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}' } -pacdisowned() { +function pacdisowned() { emulate -L zsh tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ @@ -85,14 +188,14 @@ pacdisowned() { comm -23 "$fs" "$db" } -pacmanallkeys() { +function pacmanallkeys() { emulate -L zsh curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \ awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \ xargs sudo pacman-key --recv-keys } -pacmansignkeys() { +function pacmansignkeys() { emulate -L zsh for key in $*; do sudo pacman-key --recv-keys $key @@ -101,3 +204,16 @@ pacmansignkeys() { --no-permission-warning --command-fd 0 --edit-key $key done } + +if (( $+commands[xdg-open] )); then + function pacweb() { + pkg="$1" + infos="$(pacman -Si "$pkg")" + if [[ -z "$infos" ]]; then + return + fi + repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" + arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" + xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null + } +fi diff --git a/plugins/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh index 8736d2ff8..38b225538 100644 --- a/plugins/asdf/asdf.plugin.zsh +++ b/plugins/asdf/asdf.plugin.zsh @@ -1,7 +1,19 @@ -# Find where asdf should be installed. +# Find where asdf should be installed ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}" +ASDF_COMPLETIONS="$ASDF_DIR/completions" -# Load asdf, if found. -if [ -f $ASDF_DIR/asdf.sh ]; then - . $ASDF_DIR/asdf.sh +# If not found, check for Homebrew package +if [[ ! -f "$ASDF_DIR/asdf.sh" ]] && (( $+commands[brew] )); then + ASDF_DIR="$(brew --prefix asdf)" + ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d" +fi + +# Load command +if [[ -f "$ASDF_DIR/asdf.sh" ]]; then + . "$ASDF_DIR/asdf.sh" + + # Load completions + if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then + . "$ASDF_COMPLETIONS/asdf.bash" + fi fi diff --git a/plugins/autoenv/README.md b/plugins/autoenv/README.md new file mode 100644 index 000000000..de3881774 --- /dev/null +++ b/plugins/autoenv/README.md @@ -0,0 +1,14 @@ +# Autoenv plugin + +This plugin loads the [Autoenv](https://github.com/inishchith/autoenv). + +To use it, add `autoenv` to the plugins array in your zshrc file: + +```zsh +plugins=(... autoenv) +``` +## Requirements + +In order to make this work, you will need to have the autoenv installed. + +More info on the usage and install: https://github.com/inishchith/autoenv 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/autojump/README.md b/plugins/autojump/README.md new file mode 100644 index 000000000..18ff793cd --- /dev/null +++ b/plugins/autojump/README.md @@ -0,0 +1,11 @@ +# Autojump plugin + +This plugin loads the [autojump navigation tool](https://github.com/wting/autojump). + +To use it, add `autojump` to the plugins array in your zshrc file: + +```zsh +plugins=(... autojump) +``` + +More info on the usage: https://github.com/wting/autojump diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index c05c699e1..d80c88822 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,21 +1,34 @@ -if [ $commands[autojump] ]; then # check if autojump is installed - if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation - . $HOME/.autojump/etc/profile.d/autojump.zsh - elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation - . $HOME/.autojump/share/autojump/autojump.zsh - elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation - . $HOME/.nix-profile/etc/profile.d/autojump.zsh - elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package - . /usr/share/autojump/autojump.zsh - elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation - . /etc/profile.d/autojump.zsh - elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation - . /etc/profile.d/autojump.sh - elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation - . /usr/local/share/autojump/autojump.zsh - elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports - . /opt/local/etc/profile.d/autojump.zsh - elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew - . `brew --prefix`/etc/autojump.sh +declare -a autojump_paths +autojump_paths=( + $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation + $HOME/.autojump/share/autojump/autojump.zsh # manual installation + $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation + /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation + /usr/share/autojump/autojump.zsh # Debian and Ubuntu package + /etc/profile.d/autojump.zsh # manual installation + /etc/profile.d/autojump.sh # Gentoo installation + /usr/local/share/autojump/autojump.zsh # FreeBSD installation + /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts + /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) +) + +for file in $autojump_paths; do + if [[ -f "$file" ]]; then + source "$file" + found=1 + break + fi +done + +# if no path found, try Homebrew +if (( ! found && $+commands[brew] )); then + file=$(brew --prefix)/etc/profile.d/autojump.sh + if [[ -f "$file" ]]; then + source "$file" + found=1 fi fi + +(( ! found )) && echo '[oh-my-zsh] autojump script not found' + +unset autojump_paths file found diff --git a/plugins/autopep8/README.md b/plugins/autopep8/README.md new file mode 100644 index 000000000..02bbb9af4 --- /dev/null +++ b/plugins/autopep8/README.md @@ -0,0 +1,8 @@ +# autopep8 plugin + +This plugin adds completion for [autopep8](https://pypi.org/project/autopep8/), a tool that automatically formats Python code to conform to the [PEP 8](http://www.python.org/dev/peps/pep-0008/) style guide. + +To use it, add autopep8 to the plugins array of your zshrc file: +``` +plugins=(... autopep8) +``` diff --git a/plugins/autopep8/autopep8.plugin.zsh b/plugins/autopep8/autopep8.plugin.zsh deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/aws/README.md b/plugins/aws/README.md new file mode 100644 index 000000000..57c3b54ac --- /dev/null +++ b/plugins/aws/README.md @@ -0,0 +1,38 @@ +# aws + +This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html) +and a few utilities to manage AWS profiles and display them in the prompt. + +To use it, add `aws` to the plugins array in your zshrc file. + +```zsh +plugins=(... aws) +``` + +## Plugin commands + +* `asp []`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to ``. + It also sets `$AWS_EB_PROFILE` to `` for the Elastic Beanstalk CLI. + Run `asp` without arguments to clear the profile. + +* `agp`: gets the current value of `$AWS_PROFILE`. + +* `aws_change_access_key`: changes the AWS access key of a profile. + +* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`). + Used to provide completion for the `asp` function. + +## Plugin options + +* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. + Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to + see the AWS profile prompt. + +## Theme + +The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays +the current `$AWS_PROFILE`. It uses two variables to control how that is shown: + +- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to ``. diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d31052f83..231ac5ad2 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,37 +1,96 @@ -_homebrew-installed() { - type brew &> /dev/null +function agp() { + echo $AWS_PROFILE } -_awscli-homebrew-installed() { - brew list awscli &> /dev/null -} +# AWS profile selection +function asp() { + if [[ -z "$1" ]]; then + unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE + echo AWS profile cleared. + return + fi -export AWS_HOME=~/.aws - -function agp { - echo $AWS_DEFAULT_PROFILE -} - -function asp { - local rprompt=${RPROMPT//} + local available_profiles=($(aws_profiles)) + if [[ -z "${available_profiles[(r)$1]}" ]]; then + echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 + echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 + return 1 + fi export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 - - export RPROMPT="$rprompt" + export AWS_EB_PROFILE=$1 } -function aws_profiles { - reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) +function aws_change_access_key() { + if [[ -z "$1" ]]; then + echo "usage: $0 " + return 1 + fi + + echo Insert the credentials when asked. + asp "$1" || return 1 + aws iam create-access-key + aws configure --profile "$1" + + echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\` + echo Your current keys are: + aws iam list-access-keys } -compctl -K aws_profiles asp +function aws_profiles() { + [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 + grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' +} -if _homebrew-installed && _awscli-homebrew-installed ; then - _aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh -else - _aws_zsh_completer_path=$(which aws_zsh_completer.sh) +function _aws_profiles() { + reply=($(aws_profiles)) +} +compctl -K _aws_profiles asp aws_change_access_key + +# AWS prompt +function aws_prompt_info() { + [[ -z $AWS_PROFILE ]] && return + echo "${ZSH_THEME_AWS_PREFIX:=}" +} + +if [ "$SHOW_AWS_PROMPT" != false ]; then + RPROMPT='$(aws_prompt_info)'"$RPROMPT" fi -[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path -unset _aws_zsh_completer_path + +# Load awscli completions + +function _awscli-homebrew-installed() { + # check if Homebrew is installed + (( $+commands[brew] )) || return 1 + + # speculatively check default brew prefix + if [ -h /usr/local/opt/awscli ]; then + _brew_prefix=/usr/local/opt/awscli + else + # ok, it is not in the default prefix + # this call to brew is expensive (about 400 ms), so at least let's make it only once + _brew_prefix=$(brew --prefix awscli) + fi +} + +# get aws_zsh_completer.sh location from $PATH +_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" + +# otherwise check common locations +if [[ -z $_aws_zsh_completer_path ]]; then + # Homebrew + if _awscli-homebrew-installed; then + _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh + # Ubuntu + elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then + _aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli + # RPM + else + _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh + fi +fi + +[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path +unset _aws_zsh_completer_path _brew_prefix diff --git a/plugins/battery/README.md b/plugins/battery/README.md new file mode 100644 index 000000000..b7a13a7ec --- /dev/null +++ b/plugins/battery/README.md @@ -0,0 +1,13 @@ +# Battery Plugin + +This plugin adds some functions you can use to display battery information in your custom theme. + +To use, add `battery` to the list of plugins in your `.zshrc` file: + +`plugins=(... battery)` + +Then, add the `battery_pct_prompt` function to your custom theme. For example: + +``` +RPROMPT='$(battery_pct_prompt)' +``` diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 0bb9e77f0..6b6684716 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -7,6 +7,9 @@ # Email: neuralsandwich@gmail.com # # Modified to add support for Apple Mac # ########################################### +# Author: J (927589452) # +# Modified to add support for FreeBSD # +########################################### if [[ "$OSTYPE" = darwin* ]] ; then @@ -64,7 +67,53 @@ if [[ "$OSTYPE" = darwin* ]] ; then [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] } -elif [[ $(uname) == "Linux" ]] ; then +elif [[ "$OSTYPE" = freebsd* ]] ; then + + function battery_is_charging() { + [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]] + } + + function battery_pct() { + if (( $+commands[sysctl] )) ; then + echo "$(sysctl -n hw.acpi.battery.life)" + fi + } + + function battery_pct_remaining() { + if [ ! $(battery_is_charging) ] ; then + battery_pct + else + echo "External Power" + fi + } + + function battery_time_remaining() { + remaining_time=$(sysctl -n hw.acpi.battery.time) + if [[ $remaining_time -ge 0 ]] ; then + # calculation from https://www.unix.com/shell-programming-and-scripting/23695-convert-minutes-hours-minutes-seconds.html + ((hour=$remaining_time/60)) + ((minute=$remaining_time-$hour*60)) + echo $hour:$minute + fi + } + + function battery_pct_prompt() { + b=$(battery_pct_remaining) + if [ ! $(battery_is_charging) ] ; then + if [ $b -gt 50 ] ; then + color='green' + elif [ $b -gt 20 ] ; then + color='yellow' + else + color='red' + fi + echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" + else + echo "∞" + fi + } + +elif [[ "$OSTYPE" = linux* ]] ; then function battery_is_charging() { ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] @@ -100,7 +149,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/bbedit/README.md b/plugins/bbedit/README.md index ec2b743d6..263c54c47 100644 --- a/plugins/bbedit/README.md +++ b/plugins/bbedit/README.md @@ -1,11 +1,11 @@ ## bbedit -Plugin for BBEdit, an HTML and text editor for Mac OS X +Plugin for BBEdit, an HTML and text editor for Mac OS X ### Requirements - * [BBEdit](http://www.barebones.com/products/bbedit/) - * [BBEdit Command-Line Tools](http://www.barebones.com/support/bbedit/cmd-line-tools.html) + * [BBEdit](https://www.barebones.com/products/bbedit/) + * [BBEdit Command-Line Tools](https://www.barebones.com/support/bbedit/cmd-line-tools.html) ### Usage diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index b154916d6..1d8fac54d 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -10,10 +10,10 @@ Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-ba Just add bgnotify to your plugins list in your `.zshrc` -- On OS X you'll need [terminal-notifer](https://github.com/alloy/terminal-notifier) +- On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier) * `brew install terminal-notifier` (or `gem install terminal-notifier`) - On ubuntu you're already all set! -- On windows you can use [notifu](http://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package +- On windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package ## Screenshots diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh old mode 100755 new mode 100644 index 459f5214e..b3a6890b8 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -42,7 +42,7 @@ bgnotify () { ## args: (title, subtitle) elif hash notify-send 2>/dev/null; then #ubuntu gnome! notify-send "$1" "$2" elif hash kdialog 2>/dev/null; then #ubuntu kde! - kdialog -title "$1" --passivepopup "$2" 5 + kdialog --title "$1" --passivepopup "$2" 5 elif hash notifu 2>/dev/null; then #cygwyn support! notifu /m "$2" /p "$1" fi diff --git a/plugins/bower/README.md b/plugins/bower/README.md new file mode 100644 index 000000000..743b6a0ea --- /dev/null +++ b/plugins/bower/README.md @@ -0,0 +1,18 @@ +# Bower plugin + +This plugin adds completion for [Bower](https://bower.io/) and a few useful aliases for common Bower commands. + +To use it, add `bower` to the plugins array in your zshrc file: + +``` +plugins=(... bower) +``` + +## Aliases + +| Alias | Command | Description | +|-------|-----------------|--------------------------------------------------------| +| bi | `bower install` | Installs the project dependencies listed in bower.json | +| bl | `bower list` | List local packages and possible updates | +| bs | `bower search` | Finds all packages or a specific package. | + diff --git a/plugins/brew/README.md b/plugins/brew/README.md new file mode 100644 index 000000000..c129a7652 --- /dev/null +++ b/plugins/brew/README.md @@ -0,0 +1,21 @@ +# brew plugin + +The plugin adds several aliases for common [brew](https://brew.sh) commands. + +To use it, add `brew` to the plugins array of your zshrc file: +``` +plugins=(... brew) +``` + +## Aliases + +| Alias | Command | Description | +|--------|----------------------|---------------| +| brewp | `brew pin` | Pin a specified formulae, preventing them from being upgraded when issuing the brew upgrade command. | +| brews | `brew list -1` | List installed formulae, one entry per line, or the installed files for a given formulae. | +| brewsp | `brew list --pinned` | Show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. | +| bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. | +| bubc | `brew upgrade && brew cleanup` | Upgrade outdated, unpinned brews (with existing install options), then removes stale lock files and outdated downloads for formulae and casks, and removes old versions of installed formulae. | +| bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. | +| bcubo | `brew update && brew cask outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated casks. | +| bcubc | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Updates outdated casks, then runs cleanup. | \ No newline at end of file diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 5b5847328..cfbaa3480 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,4 +1,24 @@ +alias brewp='brew pin' alias brews='brew list -1' +alias brewsp='brew list --pinned' alias bubo='brew update && brew outdated' alias bubc='brew upgrade && brew cleanup' alias bubu='bubo && bubc' +alias bcubo='brew update && brew cask outdated' +alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup' + +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 04d551447..a7d40cd0a 100644 --- a/plugins/bundler/README.md +++ b/plugins/bundler/README.md @@ -2,7 +2,8 @@ - adds completion for basic bundler commands - adds short aliases for common bundler commands - - `be` aliased to `bundle exec` + - `be` aliased to `bundle exec`. + It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`). - `bl` aliased to `bundle list` - `bp` aliased to `bundle package` - `bo` aliased to `bundle open` @@ -13,7 +14,8 @@ - looks for a binstub under `./bin/` and executes it (if present) - calls `bundle exec ` otherwise -For a full list of *common gems* being wrapped by default please look at the `bundler.plugin.zsh` file. +Common gems wrapped by default (by name of the executable): +`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`. ## Configuration diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index c5284dbb1..665cb5e43 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -14,6 +14,7 @@ bundled_commands=( cucumber foodcritic guard + hanami irb jekyll kitchen @@ -26,6 +27,7 @@ bundled_commands=( rainbows rake rspec + rubocop shotgun sidekiq spec @@ -53,10 +55,14 @@ done ## Functions bundle_install() { - if _bundler-installed && _within-bundled-project; then + if ! _bundler-installed; then + echo "Bundler is not installed" + elif ! _within-bundled-project; then + echo "Can't 'bundle install' outside a bundled project" + else local bundler_version=`bundle version | cut -d' ' -f3` if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then - if [[ "$OSTYPE" = darwin* ]] + if [[ "$OSTYPE" = (darwin|freebsd)* ]] then local cores_num="$(sysctl -n hw.ncpu)" else @@ -66,8 +72,6 @@ bundle_install() { else bundle install $@ fi - else - echo "Can't 'bundle install' outside a bundled project" fi } @@ -78,7 +82,7 @@ _bundler-installed() { _within-bundled-project() { local check_dir="$PWD" while [ "$check_dir" != "/" ]; do - [ -f "$check_dir/Gemfile" ] && return + [ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return check_dir="$(dirname $check_dir)" done false @@ -91,7 +95,7 @@ _binstubbed() { _run-with-bundler() { if _bundler-installed && _within-bundled-project; then if _binstubbed $1; then - ./bin/$@ + ./bin/${^^@} else bundle exec $@ fi diff --git a/plugins/bwana/bwana.plugin.zsh b/plugins/bwana/bwana.plugin.zsh deleted file mode 100644 index 455da8621..000000000 --- a/plugins/bwana/bwana.plugin.zsh +++ /dev/null @@ -1,13 +0,0 @@ -# -# Requires http://www.bruji.com/bwana/ -# -if [[ -e /Applications/Bwana.app ]] || - ( system_profiler -detailLevel mini SPApplicationsDataType | grep -q Bwana ) -then - function man() { - open "man:$1" - } -else - echo "Bwana lets you read man files in Safari through a man: URI scheme" - echo "To use it within Zsh, install it from http://www.bruji.com/bwana/" -fi diff --git a/plugins/cabal/README.md b/plugins/cabal/README.md new file mode 100644 index 000000000..b1106c40f --- /dev/null +++ b/plugins/cabal/README.md @@ -0,0 +1,9 @@ +# Cabal + +This plugin provides completion for [Cabal](https://www.haskell.org/cabal/), a build tool for Haskell. It +also provides a function `cabal_sandbox_info` that prints whether the current working directory is in a sandbox. + +To use it, add cabal to the plugins array of your zshrc file: +``` +plugins=(... cabal) +``` diff --git a/plugins/cake/README.md b/plugins/cake/README.md new file mode 100644 index 000000000..aad92a3ec --- /dev/null +++ b/plugins/cake/README.md @@ -0,0 +1,15 @@ +# Cake + +This plugin provides completion for [CakePHP](https://cakephp.org/). + +To use it add cake to the plugins array in your zshrc file. + +```bash +plugins=(... cake) +``` + +## Note + +This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory. +It is regenerated when the Cakefile is newer than the cache file. It is advised that you add the cake file to your +`.gitignore` files. diff --git a/plugins/cakephp3/README.md b/plugins/cakephp3/README.md new file mode 100644 index 000000000..7e8f6640d --- /dev/null +++ b/plugins/cakephp3/README.md @@ -0,0 +1,16 @@ +# cakephp3 plugin + +The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html). + +To use it, add `cakephp3` to the plugins array of your zshrc file: +``` +plugins=(... cakephp3) +``` + +## Aliases + +| Alias | Command | +|-----------|-------------------------------| +| c3 | `bin/cake` | +| c3cache | `bin/cake orm_cache clear` | +| c3migrate | `bin/cake migrations migrate` | diff --git a/plugins/capistrano/README.md b/plugins/capistrano/README.md new file mode 100644 index 000000000..335b794fa --- /dev/null +++ b/plugins/capistrano/README.md @@ -0,0 +1,14 @@ +# Capistrano + +This plugin provides completion for [Capistrano](https://capistranorb.com/). + +To use it add capistrano to the plugins array in your zshrc file. + +```bash +plugins=(... capistrano) +``` + +For a working completion use the `capit` command instead of `cap`, because cap is a +[reserved word in zsh](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module). + +`capit` automatically runs cap with bundler if a Gemfile is found. diff --git a/plugins/capistrano/capistrano.plugin.zsh b/plugins/capistrano/capistrano.plugin.zsh index 0b5559791..819572825 100644 --- a/plugins/capistrano/capistrano.plugin.zsh +++ b/plugins/capistrano/capistrano.plugin.zsh @@ -1,7 +1,7 @@ -# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work. +# Added `capit` because `cap` is a reserved word. `cap` completion doesn't work. # http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module -func capit() { +function capit() { if [ -f Gemfile ] then bundle exec cap $* diff --git a/plugins/cargo/README.md b/plugins/cargo/README.md new file mode 100644 index 000000000..31bae4efe --- /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 March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0). diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo new file mode 100644 index 000000000..12694901e --- /dev/null +++ b/plugins/cargo/_cargo @@ -0,0 +1,407 @@ +#compdef cargo + +autoload -U regexp-replace + +_cargo() { + local curcontext="$curcontext" ret=1 + local -a command_scope_spec common parallel features msgfmt triple target registry + local -a state line state_descr # These are set by _arguments + typeset -A opt_args + + common=( + '(-q --quiet)*'{-v,--verbose}'[use verbose output]' + '(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]' + '-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags' + '--frozen[require that Cargo.lock and cache are up-to-date]' + '--locked[require that Cargo.lock is up-to-date]' + '--color=[specify colorization option]:coloring:(auto always never)' + '(- 1 *)'{-h,--help}'[show help message]' + ) + + # leading items in parentheses are an exclusion list for the arguments following that arg + # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions + # - => exclude all other options + # 1 => exclude positional arg 1 + # * => exclude all other args + # +blah => exclude +blah + _arguments -s -S -C $common \ + '(- 1 *)--list[list installed commands]' \ + '(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '(+beta +nightly)+stable[use the stable toolchain]' \ + '(+stable +nightly)+beta[use the beta toolchain]' \ + '(+stable +beta)+nightly[use the nightly toolchain]' \ + '1: :_cargo_cmds' \ + '*:: :->args' + + # These flags are mutually exclusive specifiers for the scope of a command; as + # they are used in multiple places without change, they are expanded into the + # appropriate command's `_arguments` where appropriate. + command_scope_spec=( + '(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names' + '(--bench --bin --test --lib)--example=[specify example name]:example name' + '(--bench --example --test --lib)--bin=[specify binary name]:binary name' + '(--bench --bin --example --test)--lib=[specify library name]:library name' + '(--bench --bin --example --lib)--test=[specify test name]:test name' + ) + + parallel=( + '(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]' + ) + + features=( + '(--all-features)--features=[specify features to activate]:feature' + '(--features)--all-features[activate all available features]' + "--no-default-features[don't build the default features]" + ) + + msgfmt='--message-format=[specify error format]:error format [human]:(human json short)' + triple='--target=[specify target triple]:target triple' + target='--target-dir=[specify directory for all generated artifacts]:directory:_directories' + manifest='--manifest-path=[specify path to manifest]:path:_directories' + registry='--registry=[specify registry to use]:registry' + + case $state in + args) + curcontext="${curcontext%:*}-${words[1]}:" + case ${words[1]} in + bench) + _arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \ + "${command_scope_spec[@]}" \ + '--all-targets[benchmark all targets]' \ + "--no-run[compile but don't run]" \ + '(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \ + '--exclude=[exclude packages from the benchmark]:spec' \ + '--no-fail-fast[run all benchmarks regardless of failure]' \ + '1: :_guard "^-*" "bench name"' \ + '*:args:_default' + ;; + + build) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ + "${command_scope_spec[@]}" \ + '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ + '--release[build in release mode]' \ + '--build-plan[output the build plan in JSON]' \ + ;; + + check) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ + "${command_scope_spec[@]}" \ + '(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \ + '--release[check in release mode]' \ + ;; + + clean) + _arguments -s -S $common $triple $target $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \ + '--release[clean release artifacts]' \ + '--doc[clean just the documentation directory]' + ;; + + doc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--no-deps[do not build docs for dependencies]' \ + '--document-private-items[include non-public items in the documentation]' \ + '--open[open docs in browser after the build]' \ + '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \ + '--release[build artifacts in release mode, with optimizations]' \ + ;; + + fetch) + _arguments -s -S $common $triple $manifest + ;; + + fix) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + "${command_scope_spec[@]}" \ + '--broken-code[fix code even if it already has compiler errors]' \ + '--edition[fix in preparation for the next edition]' \ + '--edition-idioms[fix warnings to migrate to the idioms of an edition]' \ + '--allow-no-vcs[fix code even if a VCS was not detected]' \ + '--allow-dirty[fix code even if the working directory is dirty]' \ + '--allow-staged[fix code even if the working directory has staged changes]' + ;; + + generate-lockfile) + _arguments -s -S $common $manifest + ;; + + git-checkout) + _arguments -s -S $common \ + '--reference=:reference' \ + '--url=:url:_urls' + ;; + + help) + _cargo_cmds + ;; + + init) + _arguments -s -S $common $registry \ + '--lib[use library template]' \ + '--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \ + '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \ + '--name=[set the resulting package name]:name' \ + '1:path:_directories' + ;; + + install) + _arguments -s -S $common $parallel $features $triple $registry \ + '(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \ + '--bin=[only install the specified binary]:binary' \ + '--branch=[branch to use when installing from git]:branch' \ + '--debug[build in debug mode instead of release mode]' \ + '--example=[install the specified example instead of binaries]:example' \ + '--git=[specify URL from which to install the crate]:url:_urls' \ + '--path=[local filesystem path to crate to install]: :_directories' \ + '--rev=[specific commit to use when installing from git]:commit' \ + '--root=[directory to install packages into]: :_directories' \ + '--tag=[tag to use when installing from git]:tag' \ + '--vers=[version to install from crates.io]:version' \ + '--list[list all installed packages and their versions]' \ + '*: :_guard "^-*" "crate"' + ;; + + locate-project) + _arguments -s -S $common $manifest + ;; + + login) + _arguments -s -S $common $registry \ + '*: :_guard "^-*" "token"' + ;; + + metadata) + _arguments -s -S $common $features $manifest \ + "--no-deps[output information only about the root package and don't fetch dependencies]" \ + '--format-version=[specify format version]:version [1]:(1)' + ;; + + new) + _arguments -s -S $common $registry \ + '--lib[use library template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '--name=[set the resulting package name]' + ;; + + owner) + _arguments -s -S $common $registry \ + '(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \ + '--index=[specify registry index]:index' \ + '(-l --list)'{-l,--list}'[list owners of a crate]' \ + '(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \ + '--token=[specify API token to use when authenticating]:token' \ + '*: :_guard "^-*" "crate"' + ;; + + package) + _arguments -s -S $common $parallel $features $triple $target $manifest \ + '(-l --list)'{-l,--list}'[print files included in a package without making one]' \ + '--no-metadata[ignore warnings about a lack of human-usable metadata]' \ + '--allow-dirty[allow dirty working directories to be packaged]' \ + "--no-verify[don't build to verify contents]" + ;; + + pkgid) + _arguments -s -S $common $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \ + '*: :_guard "^-*" "spec"' + ;; + + publish) + _arguments -s -S $common $parallel $features $triple $target $manifest $registry \ + '--index=[specify registry index]:index' \ + '--allow-dirty[allow dirty working directories to be packaged]' \ + "--no-verify[don't verify the contents by building them]" \ + '--token=[specify token to use when uploading]:token' \ + '--dry-run[perform all checks without uploading]' + ;; + + read-manifest) + _arguments -s -S $common $manifest + ;; + + run) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--example=[name of the bin target]:name' \ + '--bin=[name of the bin target]:name' \ + '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \ + '--release[build in release mode]' \ + '*: :_default' + ;; + + rustc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ + '--profile=[specify profile to build the selected target for]:profile' \ + '--release[build artifacts in release mode, with optimizations]' \ + "${command_scope_spec[@]}" \ + '*: : _dispatch rustc rustc -default-' + ;; + + rustdoc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--document-private-items[include non-public items in the documentation]' \ + '--open[open the docs in a browser after the operation]' \ + '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \ + '--release[build artifacts in release mode, with optimizations]' \ + "${command_scope_spec[@]}" \ + '*: : _dispatch rustdoc rustdoc -default-' + ;; + + search) + _arguments -s -S $common $registry \ + '--index=[specify registry index]:index' \ + '--limit=[limit the number of results]:results [10]' \ + '*: :_guard "^-*" "query"' + ;; + + test) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--test=[test name]: :_cargo_test_names' \ + '--no-fail-fast[run all tests regardless of failure]' \ + '--no-run[compile but do not run]' \ + '(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \ + '--all[test all packages in the workspace]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '1: :_cargo_test_names' \ + '(--doc --bin --example --test --bench)--lib[only test library]' \ + '(--lib --bin --example --test --bench)--doc[only test documentation]' \ + '(--lib --doc --example --test --bench)--bin=[binary name]' \ + '(--lib --doc --bin --test --bench)--example=[example name]' \ + '(--lib --doc --bin --example --bench)--test=[test name]' \ + '(--lib --doc --bin --example --test)--bench=[benchmark name]' \ + '*: :_default' + ;; + + uninstall) + _arguments -s -S $common \ + '(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \ + '--bin=[only uninstall the specified binary]:name' \ + '--root=[directory to uninstall packages from]: :_files -/' \ + '*:crate:_cargo_installed_crates -F line' + ;; + + update) + _arguments -s -S $common $manifest \ + '--aggressive=[force dependency update]' \ + "--dry-run[don't actually write the lockfile]" \ + '(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \ + '--precise=[update single dependency to precise release]:release' + ;; + + verify-project) + _arguments -s -S $common $manifest + ;; + + version) + _arguments -s -S $common + ;; + + yank) + _arguments -s -S $common $registry \ + '--vers=[specify yank version]:version' \ + '--undo[undo a yank, putting a version back into the index]' \ + '--index=[specify registry index to yank from]:registry index' \ + '--token=[specify API token to use when authenticating]:token' \ + '*: :_guard "^-*" "crate"' + ;; + *) + # allow plugins to define their own functions + if ! _call_function ret _cargo-${words[1]}; then + # fallback on default completion for unknown commands + _default && ret=0 + fi + (( ! ret )) + ;; + esac + ;; + esac +} + +_cargo_unstable_flags() { + local flags + flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } ) + _describe -t flags 'unstable flag' flags +} + +_cargo_installed_crates() { + local expl + _description crates expl 'crate' + compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *} +} + +_cargo_cmds() { + local -a commands + # This uses Parameter Expansion Flags, which are a built-in Zsh feature. + # See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + # and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion + # + # # How this work? + # + # First it splits the result of `cargo --list` at newline, then it removes the first line. + # Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]). + # Then it replaces those spaces between item and description with a `:` + # + # [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns + commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} ) + _describe -t commands 'command' commands +} + + +#FIXME: Disabled until fixed +#gets package names from the manifest file +_cargo_package_names() { + _message -e packages package +} + +# Extracts the values of "name" from the array given in $1 and shows them as +# command line options for completion +_cargo_names_from_array() { + # strip json from the path + local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"} + if [[ -z $manifest ]]; then + return 0 + fi + + local last_line + local -a names; + local in_block=false + local block_name=$1 + names=() + while read -r line; do + if [[ $last_line == "[[$block_name]]" ]]; then + in_block=true + else + if [[ $last_line =~ '\s*\[\[.*' ]]; then + in_block=false + fi + fi + + if [[ $in_block == true ]]; then + if [[ $line =~ '\s*name\s*=' ]]; then + regexp-replace line '^\s*name\s*=\s*|"' '' + names+=( "$line" ) + fi + fi + + last_line=$line + done < "$manifest" + _describe "$block_name" names + +} + +#Gets the test names from the manifest file +_cargo_test_names() { + _cargo_names_from_array "test" +} + +#Gets the bench names from the manifest file +_cargo_benchmark_names() { + _cargo_names_from_array "bench" +} + +_cargo diff --git a/plugins/cask/README.md b/plugins/cask/README.md index 6457fd858..e1335c1b8 100644 --- a/plugins/cask/README.md +++ b/plugins/cask/README.md @@ -1,11 +1,15 @@ -# cask plugin +# Cask plugin -Loads `cask` completion from non-standard locations, such as if installed +[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 the "command not found" error. +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/catimg/README.md b/plugins/catimg/README.md new file mode 100644 index 000000000..2fc28a1c6 --- /dev/null +++ b/plugins/catimg/README.md @@ -0,0 +1,35 @@ +# catimg + +Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg) + +## Requirements + +- `convert` (ImageMagick) + +## Enabling the plugin + +1. Open your `.zshrc` file and add `catimg` in the plugins section: + + ```zsh + plugins=( + # all your enabled plugins + catimg + ) + ``` + +2. Reload the source file or restart your Terminal session: + + ```console + $ source ~/.zshrc + $ + ``` + +## Functions + +| Function | Description | +| -------- | ---------------------------------------- | +| `catimg` | Displays the given image on the terminal | + +## Usage examples + +[![asciicast](https://asciinema.org/a/204702.png)](https://asciinema.org/a/204702) diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh index cb92f5986..ca46444cc 100644 --- a/plugins/catimg/catimg.plugin.zsh +++ b/plugins/catimg/catimg.plugin.zsh @@ -1,10 +1,10 @@ ################################################################################ # catimg script by Eduardo San Martin Morote aka Posva # -# http://posva.net # +# https://posva.net # # # # Ouput the content of an image to the stdout using the 256 colors of the # # terminal. # -# Github: https://github.com/posva/catimg # +# GitHub: https://github.com/posva/catimg # ################################################################################ diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh old mode 100755 new mode 100644 index cd0f2e333..713a03291 --- a/plugins/catimg/catimg.sh +++ b/plugins/catimg/catimg.sh @@ -1,10 +1,10 @@ ################################################################################ # catimg script by Eduardo San Martin Morote aka Posva # -# http://posva.net # +# https://posva.net # # # # Ouput the content of an image to the stdout using the 256 colors of the # # terminal. # -# Github: https://github.com/posva/catimg # +# GitHub: https://github.com/posva/catimg # ################################################################################ function help() { diff --git a/plugins/celery/README.md b/plugins/celery/README.md new file mode 100644 index 000000000..d2597f702 --- /dev/null +++ b/plugins/celery/README.md @@ -0,0 +1,9 @@ +# Celery + +This plugin provides completion for [Celery](http://www.celeryproject.org/). + +To use it add celery to the plugins array in your zshrc file. + +```bash +plugins=(... celery) +``` diff --git a/plugins/chruby/README.md b/plugins/chruby/README.md new file mode 100644 index 000000000..d373006a5 --- /dev/null +++ b/plugins/chruby/README.md @@ -0,0 +1,20 @@ +# chruby plugin + +This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the +current Ruby version, and completion and a prompt function to display the Ruby version. +Supports brew and manual installation of chruby. + +To use it, add `chruby` to the plugins array in your zshrc file: +```zsh +plugins=(... chruby) +``` + +## Usage + +If you'd prefer to specify an explicit path to load chruby from +you can set variables like so: + +``` +zstyle :omz:plugins:chruby path /local/path/to/chruby.sh +zstyle :omz:plugins:chruby auto /local/path/to/auto.sh +``` diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 758b4a56c..f7fedb5f2 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -16,12 +16,28 @@ # rvm and rbenv plugins also provide this alias alias rubies='chruby' + _homebrew-installed() { whence brew &> /dev/null + _xit=$? + if [ $_xit -eq 0 ];then + # ok , we have brew installed + # speculatively we check default brew prefix + if [ -h /usr/local/opt/chruby ];then + _brew_prefix="/usr/local/opt/chruby" + else + # ok , it is not default prefix + # this call to brew is expensive ( about 400 ms ), so at least let's make it only once + _brew_prefix=$(brew --prefix chruby) + fi + return 0 + else + return $_xit + fi } _chruby-from-homebrew-installed() { - [ -r $(brew --prefix chruby) ] &> /dev/null + [ -r _brew_prefix ] &> /dev/null } _ruby-build_installed() { @@ -64,8 +80,8 @@ _chruby_dirs() { } if _homebrew-installed && _chruby-from-homebrew-installed ; then - source $(brew --prefix chruby)/share/chruby/chruby.sh - source $(brew --prefix chruby)/share/chruby/auto.sh + source $_brew_prefix/share/chruby/chruby.sh + source $_brew_prefix/share/chruby/auto.sh _chruby_dirs elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then source /usr/local/share/chruby/chruby.sh @@ -95,5 +111,11 @@ function chruby_prompt_info() { } # complete on installed rubies -_chruby() { compadd $(chruby | tr -d '* ') } +_chruby() { + compadd $(chruby | tr -d '* ') + local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' + if PATH=${default_path} type ruby &> /dev/null; then + compadd system + fi +} compdef _chruby chruby diff --git a/plugins/chucknorris/LICENSE b/plugins/chucknorris/LICENSE deleted file mode 100644 index 5f40edd1e..000000000 --- a/plugins/chucknorris/LICENSE +++ /dev/null @@ -1,2 +0,0 @@ -License: GPL v2 -Thanks to http://www.k-lug.org/~kessler/projects.html for the fortune file. diff --git a/plugins/chucknorris/README.md b/plugins/chucknorris/README.md new file mode 100644 index 000000000..be7b97e24 --- /dev/null +++ b/plugins/chucknorris/README.md @@ -0,0 +1,20 @@ +# chucknorris + +Chuck Norris fortunes plugin for oh-my-zsh + +**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff) + +To use it add `chucknorris` to the plugins array in you zshrc file. + +```zsh +plugins=(... chucknorris) +``` + + +Depends on fortune (and cowsay if using chuck_cow) being installed (available via homebrew, apt, ...). Perfectly suitable as MOTD. + + +| Command | Description | +| ----------- | ------------------------------- | +| `chuck` | Print random Chuck Norris quote | +| `chuck_cow` | Print quote in cowthink | diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris index e705d1c13..2a13b060f 100644 --- a/plugins/chucknorris/fortunes/chucknorris +++ b/plugins/chucknorris/fortunes/chucknorris @@ -1,907 +1,2544 @@ -Chuck Norris' tears cure cancer. Too bad he has never cried. Ever. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -Chuck Norris does not sleep. He waits. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -The chief export of Chuck Norris is pain. +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -If you can see Chuck Norris, he can see you. If you can't see Chuck Norris, you may be only seconds away from death. +Chuck Norris does not sleep. He waits. % -Chuck Norris has counted to infinity. Twice. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -Chuck Norris does not hunt because the word hunting implies the probability of failure. Chuck Norris goes killing. +Chuck Norris is the reason why Waldo is hiding. % -Chuck Norris' blood type is AK+. Ass-Kicking Positive. It is compatible only with heavy construction equipment, tanks, and fighter jets. +Chuck Norris counted to infinity - twice. % -Chuck Norris is 1/8th Cherokee. This has nothing to do with ancestry, the man ate a fucking Indian. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten. +In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten. % There is no chin behind Chuck Norris' beard. There is only another fist. % -Chuck Norris does not teabag the ladies. He potato-sacks them. +Chuck Norris does not teabag the ladies. He potato-sacks them. % -Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face. +Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face. % -When Chuck Norris goes to donate blood, he declines the syringe, and instead requests a hand gun and a bucket. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -There are no steroids in baseball. Just players Chuck Norris has breathed on. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Chuck Norris once challenged Lance Armstrong in a "Who has more testicles?" contest. Chuck Norris won by 5. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -Chuck Norris was the fourth wise man, who gave baby Jesus the gift of beard, which he carried with him until he died. The other three wise men were enraged by the preference that Jesus showed to Chuck's gift, and arranged to have him written out of the bible. All three died soon after of mysterious roundhouse-kick related injuries. +Chuck Norris can lead a horse to water AND make it drink. % -Chuck Norris sheds his skin twice a year. +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -When Chuck Norris calls 1-900 numbers, he doesnt get charged. He holds up the phone and money falls out. +Chuck Norris can slam a revolving door. % -Chuck Norris once ate a whole cake before his friends could tell him there was a stripper in it. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -Some people like to eat frogs' legs. Chuck Norris likes to eat lizard legs. Hence, snakes. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -There are no races, only countries of people Chuck Norris has beaten to different shades of black and blue. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -When Chuck Norris was denied an Egg McMuffin at McDonald's because it was 10:35, he roundhouse kicked the store so hard it became a Wendy's. +If you spell Chuck Norris in Scrabble, you win. Forever. % -Chuck Norris can't finish a "color by numbers" because his markers are filled with the blood of his victims. Unfortunately, all blood is dark red. +Guns don't kill people. Chuck Norris kills people. % -A Chuck Norris-delivered Roundhouse Kick is the preferred method of execution in 16 states. +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -When Chuck Norris falls in water, Chuck Norris doesn't get wet. Water gets Chuck Norris. +The chief export of Chuck Norris is Pain. % -Scientists have estimated that the energy given off during the Big Bang is roughly equal to 1CNRhK (Chuck Norris Roundhouse Kick) +Chuck Norris has two speeds. Walk, and Kill. % -Chuck Norris' house has no doors, only walls that he walks through. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -When Chuck Norris has sex with a man, it won't be because he is gay. It will be because he has run out of women. +Chuck Norris drives an ice cream truck covered in human skulls. % -How much wood would a woodchuck chuck if a woodchuck could Chuck Norris? ...All of it. +Chuck Norris is my Homeboy. % -Chuck Norris doesn't actually write books, the words assemble themselves out of fear. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -In honor of Chuck Norris, all McDonald's in Texas have an even larger size than the super-size. When ordering, just ask to be "Norrisized". +Chuck Norris uses pepper spray to spice up his steaks. % -Chuck Norris CAN believe it's not butter. +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -If tapped, a Chuck Norris roundhouse kick could power the country of Australia for 44 minutes. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -Chuck Norris can divide by zero. +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -The grass is always greener on the other side, unless Chuck Norris has been there. In that case the grass is most likely soaked in blood and tears. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -A picture is worth a thousand words. A Chuck Norris is worth 1 billion words. +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -Newton's Third Law is wrong: Although it states that for each action, there is an equal and opposite reaction, there is no force equal in reaction to a Chuck Norris roundhouse kick. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -Chuck Norris invented his own type of karate. It's called Chuck-Will-Kill. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -When an episode of Walker Texas Ranger was aired in France, the French surrendered to Chuck Norris just to be on the safe side. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -While urinating, Chuck Norris is easily capable of welding titanium. +The quickest way to a man's heart is with Chuck Norris' fist. % -Chuck Norris once sued the Houghton-Mifflin textbook company when it became apparent that their account of the war of 1812 was plagiarized from his autobiography. +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -When Chuck Norris talks, everybody listens. And dies. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part. +Chuck Norris can win a game of Connect Four in only three moves. % -Wilt Chamberlain claims to have slept with more than 20,000 women in his lifetime. Chuck Norris calls this "a slow Tuesday." +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -Contrary to popular belief, there is indeed enough Chuck Norris to go around. +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -Chuck Norris doesnt shave; he kicks himself in the face. The only thing that can cut Chuck Norris is Chuck Norris. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -For some, the left testicle is larger than the right one. For Chuck Norris, each testicle is larger than the other one. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -Chuck Norris always knows the EXACT location of Carmen SanDiego. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000. +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -Chuck Norris invented black. In fact, he invented the entire spectrum of visible light. Except pink. Tom Cruise invented pink. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -When you're Chuck Norris, anything + anything is equal to 1. One roundhouse kick to the face. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -Chuck Norris has the greatest Poker-Face of all time. He won the 1983 World Series of Poker, despite holding only a Joker, a Get out of Jail Free Monopoloy card, a 2 of clubs, 7 of spades and a green #4 card from the game UNO. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -On his birthday, Chuck Norris randomly selects one lucky child to be thrown into the sun. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -Nobody doesn't like Sara Lee. Except Chuck Norris. +Chuck Norris can win in a top spinning tournament with a cube % -Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down! +Beware of dogs... Dogs, beware of Chuck Norris. % -In the beginning there was nothing...then Chuck Norris Roundhouse kicked that nothing in the face and said "Get a job". That is the story of the universe. +Chuck Norris can dig a hole in air. % -Chuck Norris has 12 moons. One of those moons is the Earth. +The apple falls far from the tree, when a roundhouse kick is taken to the trunk. % -Chuck Norris grinds his coffee with his teeth and boils the water with his own rage. +Chuck Norris - the new standard. % -Archeologists unearthed an old english dictionary dating back to the year 1236. It defined "victim" as "one who has encountered Chuck Norris" +Chuck Norris told me to put this here. % -Chuck Norris ordered a Big Mac at Burger King, and got one. +Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs. % -Chuck Norris and Mr. T walked into a bar. The bar was instantly destroyed, as that level of awesome cannot be contained in one building. +Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic % -If you Google search "Chuck Norris getting his ass kicked" you will generate zero results. It just doesn't happen. +When Chuck Norris goes to rodeos, bulls ride him. % -Chuck Norris can drink an entire gallon of milk in thirty-seven seconds. +Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons. % -Little known medical fact: Chuck Norris invented the Caesarean section when he roundhouse-kicked his way out of his monther's womb. +The meaning of life is Chuck Norris % -Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint. +Chuck Norris is the meaning of life. Too bad he's also the meaning of death. % -The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage. +If God doesn't know, Chuck does % -It takes Chuck Norris 20 minutes to watch 60 Minutes. +Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint. % -You know how they say if you die in your dream then you will die in real life? In actuality, if you dream of death then Chuck Norris will find you and kill you. +The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage. % -Chuck Norris has a deep and abiding respect for human life... unless it gets in his way. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -The Bermuda Triangle used to be the Bermuda Square, until Chuck Norris Roundhouse kicked one of the corners off. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -There are no weapons of mass destruction in Iraq, Chuck Norris lives in Oklahoma. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -Chuck Norris doesn't believe in Germany. +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -When Chuck Norris is in a crowded area, he doesn't walk around people. He walks through them. +Chuck Norris does not sleep. He waits. % -Chuck Norris once ate an entire bottle of sleeping pills. They made him blink. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -James Cameron wanted Chuck Norris to play the Terminator. However, upon reflection, he realized that would have turned his movie into a documentary, so he went with Arnold Schwarzenegger. +Chuck Norris is the reason why Waldo is hiding. % -Chuck Norris can touch MC Hammer. +Chuck Norris counted to infinity - twice. % -Thousands of years ago Chuck Norris came across a bear. It was so terrified that it fled north into the arctic. It was also so terrified that all of its decendents now have white hair. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -Chuck Norris played Russian Roulette with a fully loaded gun and won. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -It takes 14 puppeteers to make Chuck Norris smile, but only 2 to make him destroy an orphanage. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Chuck Norris is responsible for China's over-population. He hosted a Karate tournament in Beijing and all women within 1,000 miles became pregnant instantly. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -Some people wear Superman pajamas. Superman wears Chuck Norris pajamas. +Chuck Norris can lead a horse to water AND make it drink. % -Chuck Norris once worked as a weatherman for the San Diego evening news. Every night he would make the same forecast: Partly cloudy with a 75% chance of Pain. +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -Simply by pulling on both ends, Chuck Norris can stretch diamonds back into coal. +Chuck Norris can slam a revolving door. % -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -Chuck Norris invented the bolt-action rifle, liquor, sexual intercourse, and football-- in that order. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -A high tide means Chuck Norris is flying over your coast. The tide is caused by God pissing his pants. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -Chuck Norris keeps his friends close and his enemies closer. Close enough to drop them with one round house kick to the face. +If you spell Chuck Norris in Scrabble, you win. Forever. % -There is in fact an "I" in Norris, but there is no "team"? not even close. +Guns don't kill people. Chuck Norris kills people. % -Scotty in Star Trek often says "Ye cannae change the laws of physics." This is untrue. Chuck Norris can change the laws of physics. With his fists. +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -An anagram for Walker Texas Ranger is KARATE WRANGLER SEX. I don't know what that is, but it sounds AWESOME. +The chief export of Chuck Norris is Pain. % -Chuck Norris doesn't stub his toes. He accidentally destroys chairs, bedframes, and sidewalks. +Chuck Norris has two speeds. Walk, and Kill. % -Using his trademark roundhouse kick, Chuck Norris once made a fieldgoal in RJ Stadium in Tampa Bay from the 50 yard line of Qualcomm stadium in San Diego. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -Chuck Norris roundhouse kicks don't really kill people. They wipe out their entire existence from the space-time continuum. +Chuck Norris drives an ice cream truck covered in human skulls. % -Chuck Norris does not own a stove, oven, or microwave , because revenge is a dish best served cold. +Chuck Norris is my Homeboy. % -Tom Clancy has to pay royalties to Chuck Norris because "The Sum of All Fears" is the name of Chuck Norris' autobiography. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -Chuck Norris can slam a revolving door. +Chuck Norris uses pepper spray to spice up his steaks. % -Chuck Norris is expected to win gold in every swimming competition at the 2008 Beijing Olympics, even though Chuck Norris does not swim. This is because when Chuck Norris enters the water, the water gets out of his way and Chuck Norris simply walks across the pool floor. +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -Chuck Norris built a better mousetrap, but the world was too frightened to beat a path to his door. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -The original draft of The Lord of the Rings featured Chuck Norris instead of Frodo Baggins. It was only 5 pages long, as Chuck roundhouse-kicked Sauron's ass halfway through the first chapter. +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -Hellen Keller's favorite color is Chuck Norris. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -Chuck Norris eats beef jerky and craps gunpowder. Then, he uses that gunpowder to make a bullet, which he uses to kill a cow and make more beef jerky. Some people refer to this as the "Circle of Life." +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -If, by some incredible space-time paradox, Chuck Norris would ever fight himself, he'd win. Period. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -Chuck Norris is currently suing myspace for taking the name of what he calls everything around you. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -The crossing lights in Chuck Norris's home town say "Die slowly" and "die quickly". They each have a picture of Chuck Norris punching or kicking a pedestrian. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -Science Fact: Roundhouse kicks are comprised primarily of an element called Chucktanium. +The quickest way to a man's heart is with Chuck Norris' fist. % -The Sherman tank was originaly called the Norris tank until Chuck Norris decided it wasn't tough enough to be associated with him. The Army, for fear of Chuck Norris, renamed the tank and promised to develop a weapon more fitting of his name. To date, no weapon created has been badass enough to be named after Chuck Norris. +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -Chuck Norris proved that we are alone in the universe. We weren't before his first space expedition. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -Superman once watched an episode of Walker, Texas Ranger. He then cried himself to sleep. +Chuck Norris can win a game of Connect Four in only three moves. % -Chuck Norris doesn't step on toes. Chuck Norris steps on necks. +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -The movie "Delta Force" was extremely hard to make because Chuck had to downplay his abilities. The first few cuts were completely unbelievable. +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -Movie trivia: The movie "Invasion U.S.A." is, in fact, a documentary. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -Chuck Norris does not "style" his hair. It lays perfectly in place out of sheer terror. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -A study showed the leading causes of death in the United States are: -1:Heart disease -2:Chuck Norris -3:Cancer +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -It's widely believed that Jesus was Chuck Norris' stunt double for crucifixion due to the fact that it is impossible for nails to pierce Chuck Norris' skin. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -Chuck Norris did in fact, build Rome in a day. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -Along with his black belt, Chuck Norris often chooses to wear brown shoes. No one has DARED call him on it. Ever. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -Anytime someone is elected president in the United States, they must ask permission from Chuck Norris to live in the White House. The reason for this is because Chuck Norris had won every Federal, State, and Local election since 1777. He just allows others to run the country in his place. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -Once you go Norris, you are physically unable to go back. +When God said "Let there be light!", Chuck Norris said "Only for half the day % -Ninjas want to grow up to be just like Chuck Norris. But usually they grow up just to be killed by Chuck Norris. +Chuck Norris went up the creek without a paddle... or a canoe % -Chuck Norris once sued Burger King after they refused to put razor wire in his Whopper Jr, insisting that that actually is "his" way. +Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf. % -The last thing you hear before Chuck Norris gives you a roundhouse kick? No one knows because dead men tell no tales. +Chuck Norris found the hay in the needle stack. % -Chuck Norris doesn't play god. Playing is for children. +Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach. % -As a teen, Chuck Norris had sex with every nun in a convent tucked away in the hills of Tuscany. Nine months later the nuns gave birth to the 1972 Miami Dolphins, the only undefeated and untied team in professional football history. +Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives % -Chuck Norris is the only person in the world that can actually email a roundhouse kick. +The planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller. % -Chuck Norris won super bowls VII and VIII singlehandedly before unexpectedly retiring to pursue a career in ass-kicking. +Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris. % -Wo hu cang long. The translation from Mandarin Chinese reads: "Crouching Chuck, Hidden Norris" +Chuck Norris Can Play the Theme from the Twilight Zone with His Beard % -Chuck Norris can set ants on fire with a magnifying glass. At night. +Chuck Norris pees Adamantium % -Some kids play Kick the can. Chuck Norris played Kick the keg. +The Beatles are on iTunes because Chuck Norris bought a Mac. % -'Icy-Hot' is too weak for Chuck Norris. After a workout, Chuck Norris rubs his muscles down with liquid-hot MAGMA. +Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet % -Chuck Norris cannot love, he can only not kill. +Chuck Norris yells at Drill Sergeants % -When Chuck Norris was a baby, he didn't suck his mother's breast. His mother served him whiskey, straight out of the bottle. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -According to Einstein's theory of relativity, Chuck Norris can actually roundhouse kick you yesterday. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -Chuck Norris once pulled out a single hair from his beard and skewered three men through the heart with it. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -In an act of great philanthropy, Chuck made a generous donation to the American Cancer Society. He donated 6,000 dead bodies for scientific research. +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -Chuck Norris' favourite cut of meat is the roundhouse. +Chuck Norris does not sleep. He waits. % -When J. Robert Oppenheimer said "I am become death, the destroyer Of worlds", He was not referring to the atomic bomb. He was referring to the Chuck Norris halloween costume he was wearing. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -Chuck Norris recently had the idea to sell his urine as a canned beverage. We know this beverage as Red Bull. +Chuck Norris is the reason why Waldo is hiding. % -In a recent survey it was discovered the 94% of American women lost their virginity to Chuck Norris. The other 6% were incredibly fat or ugly. +Chuck Norris counted to infinity - twice. % -Chuck Norris invented a language that incorporates karate and roundhouse kicks. So next time Chuck Norris is kicking your ass, don't be offended or hurt, he may be just trying to tell you he likes your hat. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -If at first you don't succeed, you're not Chuck Norris. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Fear is not the only emotion Chuck Norris can smell. He can also detect hope, as in "I hope I don't get a roundhouse kick from Chuck Norris." -Too late, asshole. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -Chuck Norris's show is called Walker: Texas Ranger, because Chuck Norris doesn't run. +If at first you don't succeed, you're not Chuck Norris. % -MacGyver can build an airplane out of gum and paper clips, but Chuck Norris can roundhouse-kick his head through a wall and take it. +If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass. % -Behind every successful man, there is a woman. Behind every dead man, there is Chuck Norris. +Chuck Norris can lead a horse to water AND make it drink. % -What's known as the UFC, or Ultimate Fighting Championship, doesn't use its full name, which happens to be "Ultimate Fighting Championship, Non-Chuck-Norris-Division". +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -Chuck Norris brushes his teeth with a mixture of iron shavings, industrial paint remover, and wood-grain alcohol. +Chuck Norris can slam a revolving door. % -The easiest way to determine Chuck Norris' age is to cut him in half and count the rings. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -There is endless debate about the existence of the human soul. Well it does exist, and Chuck Norris finds it delicious. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -Most boots are made for walkin'. Chuck Norris' boots ain't that merciful. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -The US did not boycott the 1980 Summer Olympics in Moscow due to political reasons: Chuck Norris killed the entire US team with a single round-house kick during TaeKwonDo practice. +If you spell Chuck Norris in Scrabble, you win. Forever. % -Chuck Norris wears a live rattlesnake as a condom. +Guns don't kill people. Chuck Norris kills people. % -When the movie Pulp Fiction was filmed they had to borrow Chuck Norris's wallet... It's the one that says "Bad Mother Fucker" on it +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -The Bible was originally titled "Chuck Norris and Friends" +The chief export of Chuck Norris is Pain. % -Chuck Norris began selling the Total Gym as an ill-fated attempt to make his day-to-day opponents less laughably pathetic. +Chuck Norris has two speeds. Walk, and Kill. % -Do you know why Baskin Robbins only has 31 flavors? Because Chuck Norris doesn't like Fudge Ripple. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -When Chuck Norris says "More cowbell", he fucking MEANS it. +Chuck Norris drives an ice cream truck covered in human skulls. % -On the set of Walker Texas Ranger Chuck Norris brought a dying lamb back to life by nuzzling it with his beard. As the onlookers gathered, the lamb sprang to life. Chuck Norris then roundhouse kicked it, killing it instantly. This was just to prove that the good Chuck giveth, and the good Chuck, he taketh away. +Chuck Norris is my Homeboy. % -Chuck Norris was what Willis was talkin' about. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -Google won't search for Chuck Norris because it knows you don't find Chuck Norris, he finds you. +Chuck Norris uses pepper spray to spice up his steaks. % -Chuck Norris can lead a horse to water AND make it drink. +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -Nagasaki never had a bomb dropped on it. Chuck Norris jumped out of a plane and punched the ground. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -It is scientifically impossible for Chuck Norris to have had a mortal father. The most popular theory is that he went back in time and fathered himself. +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -Chuck Norris destroyed the periodic table, because Chuck Norris only recognizes the element of surprise. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -It is believed dinosaurs are extinct due to a giant meteor. That's true if you want to call Chuck Norris a giant meteor. +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -Chuck Norris shot the sheriff, but he round house kicked the deputy. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -That's not Chuck Norris doing push-ups -- that's Chuck Norris moving the Earth away from the path of a deadly asteroid. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -Chuck Norris can judge a book by its cover. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -Nothing can escape the gravity of a black hole, except for Chuck Norris. Chuck Norris eats black holes. They taste like chicken. +The quickest way to a man's heart is with Chuck Norris' fist. % -Chuck Norris does not play the lottery. It doesn't have nearly enough balls. +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -Q: How many Chuck Norris' does it take to change a light bulb? -A: None, Chuck Norris prefers to kill in the dark. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -As President Roosevelt said: "We have nothing to fear but fear itself. And Chuck Norris." +Chuck Norris can win a game of Connect Four in only three moves. % -Chuck Norris just says "no" to drugs. If he said "yes", it would collapse Colombia's infrastructure. +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.? +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -Crime does not pay - unless you are an undertaker following Walker, Texas Ranger, on a routine patrol. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -Chuck Norris invented the internet? just so he had a place to store his porn. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -Chuck Norris does not own a house. He walks into random houses and people move. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -It is better to give than to receive. This is especially true of a Chuck Norris roundhouse kick. +Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.? % -Chuck Norris is the only person to ever win a staring contest against Ray Charles and Stevie Wonder at the same time. +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -Industrial logging isn't the cause of deforestation. Chuck Norris needs toothpicks. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -Chuck Norris smells what the Rock is cooking... because the Rock is Chuck Norris' personal chef. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -When Chuck Norris plays Oregon Trail, his family does not die from cholera or dysentery, but rather, roundhouse kicks to the face. He also requires no wagon, since he carries the oxen, axels, and buffalo meat on his back. He always makes it to Oregon before you. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -Chuck Norris is the reason why Waldo is hiding. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -"Brokeback Mountain" is not just a movie. It's also what Chuck Norris calls the pile of dead ninjas in his front yard. +There is no such thing as being hard its called the Chuck Norris factor. % -When God said, "let there be light", Chuck Norris said, "say 'please'." +When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section. % -Chuck Norris does not eat. Food understands that the only safe haven from Chuck Norris' fists is inside his own body. +Chuck Norris can shoot a person 28 times with an unloaded gun. % -One day Chuck Norris walked down the street with a massive erection. There were no survivors. +Chuck Norris' personal airplane is called Air Force Chuck % -Chuck Norris built a time machine and went back in time to stop the JFK assassination. As Oswald shot, Chuck met all three bullets with his beard, deflecting them. JFK's head exploded out of sheer amazement. +The letters in Chuck Norris cannot be unscrambled. % -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +Cops don't need a badges in their wallets but only a picture of Chuck Norris. % -Chuck Norris uses a night light. Not because Chuck Norris is afraid of the dark, but the dark is afraid of Chuck Norris. +Chuck Norris was the reason why the Great Wall of China was constructed. It failed miserably. % -Chuck Norris is not capable of hitting a target on the broad side of a barn. Every time he tries, the whole damn barn falls down. +If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face. % -Before each filming of Walker: Texas Ranger, Chuck Norris is injected with fourteen times the lethal dose of elephant tranquilzer. This is, of course, to limit his strength and mobility, in an attempt to lower the fatality rate of the actors he fights. +The red phone in the oval office...Rings directly to Chuck Norris Cell Phone % -When Bruce Banner gets mad, he turns into the Hulk. When the Hulk gets mad, he turns into Chuck Norris. +The only way sharks will come near CN underwater is when CN is inside of a cage. % -Chuck Norris kills anyone that asks, "You want fries with that" because by now everyone should know that Chuck doesn't ever want fries with anything. Ever. +Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee. % -Chuck Norris once kicked a horse in the chin. Its decendants are known today as Giraffes. +If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win. % -Sticks and stones may break your bones, but a Chuck Norris glare will liquefy your kidneys. +"2012" is code for, Chuck Norris when he is pissed. % -Human cloning is outlawed because if Chuck Norris were cloned, then it would be possible for a Chuck Norris roundhouse kick to meet another chuck Norris roundhouse kick. Physicists theorize that this contact would end the universe. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -Chuck Norris once went skydiving, but promised never to do it again. One Grand Canyon is enough. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -Chuck Norris's version of a "chocolate milkshake" is a raw porterhouse wrapped around ten Hershey bars, and doused in diesel fuel. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -If Chuck Norris round-house kicks you, you will die. If Chuck Norris' misses you with the round-house kick, the wind behind the kick will tear out your pancreas. +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -In a fight between Batman and Darth Vader, the winner would be Chuck Norris. +Chuck Norris does not sleep. He waits. % -Chuck Norris puts his pants on one leg at a time, just like the rest of us. The only difference is, then he fucking kills people. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -Everybody loves Raymond. Except Chuck Norris. +Chuck Norris is the reason why Waldo is hiding. % -Contrary to popular belief, the Titanic didn't hit an iceberg. The ship was off course and accidentally ran into Chuck Norris while he was doing the backstroke across the Atlantic. +Chuck Norris counted to infinity - twice. % -Chuck Norris got his drivers license at the age of 16. Seconds. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -The original title for Alien vs. Predator was Alien and Predator vs Chuck Norris. The film was cancelled shortly after going into preproduction. No one would pay nine dollars to see a movie fourteen seconds long. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -Chuck Norris' sperm is so badass, he had sex with Nicole Kidman, and 7 months later she prematurely gave birth to a Ford Excursion. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Chuck Norris can win at solitaire with only 18 cards. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -Chuck Norris once shat blood - the blood of 11,940 natives he had killed and eaten. +Chuck Norris can lead a horse to water AND make it drink. % -Maslow's theory of higher needs does not apply to Chuck Norris. He only has two needs: killing people and finding people to kill. +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -The truth will set you free. Unless Chuck Norris has you, in which case, forget it buddy! +Chuck Norris can slam a revolving door. % -For most people, home is where the heart is. For Chuck Norris, home is where he stores his collection of human skulls. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -Kryptonite has been found to contain trace elements of Chuck Norris roundhouse kicks to the face. This is why it is so deadly to Superman. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -Saddam Hussein was not found hiding in a "hole." Saddam was roundhouse-kicked in the head by Chuck Norris in Kansas, which sent him through the earth, stopping just short of the surface of Iraq. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -Coroners refer to dead people as "ABC's". Already Been Chucked. +If you spell Chuck Norris in Scrabble, you win. Forever. % -Chuck Norris doesn't look both ways before he crosses the street... he just roundhouses any cars that get too close. +Guns don't kill people. Chuck Norris kills people. % -Chuck Norris does not have to answer the phone. His beard picks up the incoming electrical impulses and translates them into audible sound. +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -How many roundhouse kicks does it take to get to the center of a tootsie pop? Just one. From Chuck Norris. +The chief export of Chuck Norris is Pain. % -Chuck Norris doesnt wear a watch, HE decides what time it is. +Chuck Norris has two speeds. Walk, and Kill. % -The phrase 'break a leg' was originally coined by Chuck Norris's co-stars in Walker, Texas Ranger as a good luck charm, indicating that a broken leg might be the worst extent of their injuries. This never proved to be the case. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -When chuck Norris does division, there are no remainders. +Chuck Norris drives an ice cream truck covered in human skulls. % -If you rearrange the letters in "Chuck Norris", they also spell "Crush Rock In". The words "with his fists" are understood. +Chuck Norris is my Homeboy. % -Never look a gift Chuck Norris in the mouth, because he will bite your damn eyes off. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -Give a man a fish, and you will feed him for a day. Give a man anything that is better than a fish, and Chuck Norris will beat his ass and take it. +Chuck Norris uses pepper spray to spice up his steaks. % -Chuck Norris used to play baseball. When Babe Ruth was hailed as the better player, Chuck Norris killed him with a baseball bat to the throat. Lou Gehrig got off easy. +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -The original title for Star Wars was "Skywalker: Texas Ranger". Starring Chuck Norris. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -Guantuanamo Bay, Cuba, is the military code-word for "Chuck Norris' basement". +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -The phrase 'balls to the wall' was originally conceived to describe Chuck Norris entering any building smaller than an aircraft hangar. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -Chuck Norris' roundhouse kick is so powerful, it can be seen from outer space by the naked eye. +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -Ozzy Osbourne bites the heads off of bats. Chuck Norris bites the heads off of Siberian Tigers. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -He who lives by the sword, dies by the sword. He who lives by Chuck Norris, dies by the roundhouse kick. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -The best-laid plans of mice and men often go awry. Even the worst-laid plans of Chuck Norris come off without a hitch. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -The phrase 'dead ringer' refers to someone who sits behind Chuck Norris in a movie theater and forgets to turn their cell phone off. +The quickest way to a man's heart is with Chuck Norris' fist. % -Chuck Norris' Roundhouse kick is so powerful, that on the set of Sidekicks he single-footedly destroyed Jonathan Brandis' Career. +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -Chuck Norris can taste lies. +Chuck Norris can win a game of Connect Four in only three moves. % -Chuck Norris does not kick ass and take names. In fact, Chuck Norris kicks ass and assigns the corpse a number. It is currently recorded to be in the billions. +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -One time, Chuck Norris accidentally stubbed his toe. It destroyed the entire state of Ohio. +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -Little Miss Muffet sat on her tuffet, until Chuck Norris roundhouse kicked her into a glacier. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -In 1990, Chuck Norris founded the non-profit organization "Kick Drugs Out of America". If the organization's name were "Roundhouse Kick Drugs out of America", there wouldn't be any drugs in the Western Hemisphere. Anywhere. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -Chuck Norris can blow bubbles with beef jerky. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -They had to edit the first ending of 'Lone Wolf McQuade' after Chuck Norris kicked David Carradine's ass, then proceeded to barbecue and eat him. +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -Chuck Norris does, in fact, live in a round house. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -Chuck Norris was once on Jeopardy. This show is notable in that it was the first occasion in Jeopardy history that Alex Trebek had appeared without a mustache. And a head. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -When Chuck Norris works out on the Total Gym, the Total Gym feels like it's been raped. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -4 out of 5 doctors fail to recommend Chuck Norris as a solution to most problems. Also, 80% of doctors die unexplained, needlessly brutal deaths. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -Chuck Norris can skeletize a cow in two minutes. +In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place." +% +The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them. +% +Chuck Norris once had a pet monkey........his name was KING KONG +% +Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord" +% +Simon doesn't say...Chuck Norris says. +% +When does Chuck Norris run out of shotgun bullets?.....whenever he wants to. % The only sure things are Death and Taxes, and when Chuck Norris goes to work for the IRS, they'll be the same thing. % -Chuck Norris' first job was as a paperboy. There were no survivors. +Chuck Norris' first job was as a paperboy. There were no survivors. % -With the rising cost of gasoline, Chuck Norris is beginning to worry about his drinking habit. +Chuck Norris can turn toast back into bread % -The square root of Chuck Norris is pain. Do not try to square Chuck Norris, the result is death. +Chuck Norris started Chuck Norris. % -Chuck Norris' testicles do not produce sperm. They produce tiny white ninjas that recognize only one mission: seek and destroy. +Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming % -To be or not to be? That is the question. The answer? Chuck Norris. +Chuck Norris killed Kemper % -Chuck Norris has never been in a fight, ever. Do you call one roundhouse kick to the face a fight? +Did you here about the boy who cried Chuck Norris? % -There are two types of people in the world... people that suck, and Chuck Norris. +Chuck Norris can't perform Hadoukens, he IS a Hadouken % -Chuck Norris never wet his bed as a child. The bed wet itself out of fear. +Behind every successful man is Chuck Norris % -If you were somehow able to land a punch on Chuck Norris your entire arm would shatter upon impact. This is only in theory, since, come on, who in their right mind would try this? +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -70% of a human's weight is water. 70% of Chuck Norris' weight is his dick. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -Jean-Claude Van Damme once kicked Chuck Norris' ass. He was then awakened from his dream by a roundhouse kick to the face. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -The pie scene in "American Pie" is based on a dare Chuck Norris took when he was younger. However, in Chuck Norris' case, the "pie" was the molten crater of an active volcano. +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -Chuck Norris uses 8'x10' sheets of plywood as toilet paper. +Chuck Norris does not sleep. He waits. % -Noah was the only man notified before Chuck Norris relieved himself in the Atlantic Ocean. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -Chuck Norris once invited all of the other badasses from TV to duke it out in order to see who was the supreme badass. Only two showed up-- Jack Bauer and MacGyver. +Chuck Norris is the reason why Waldo is hiding. % -MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart. +Chuck Norris counted to infinity - twice. % -Jack Bauer tried to use his detailed knowledge of torture techniques, but to no avail: Chuck Norris thrives on pain. Chuck Norris then ripped off Jack Bauer's arm and beat him to death with it. Game, set, match. +MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart. % -Chuck Norris eats steak for every single meal. Most times he forgets to kill the cow. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -The First Law of Thermodynamics states that energy can neither be created nor destroyed... unless it meets Chuck Norris. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -Chuck Norris doesn't go on the internet, he has every internet site stored in his memory. He refreshes webpages by blinking. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Fact: Chuck Norris doesn't consider it sex if the woman survives. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -It is said that looking into Chuck Norris' eyes will reveal your future. Unfortunately, everybody's future is always the same: death by a roundhouse-kick to the face. +Chuck Norris can lead a horse to water AND make it drink. % -Chuck Norris knows everything there is to know - Except for the definition of mercy. +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -Scientifically speaking, it is impossible to charge Chuck Norris with "obstruction of justice." This is because even Chuck Norris cannot be in two places at the same time. +Chuck Norris can slam a revolving door. % -Chuck Norris never has to wax his skis because they're always slick with blood. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -When you say "no one's perfect", Chuck Norris takes this as a personal insult. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -Chuck Norris can win a game of Trivial Pursuit with one roll of the dice, and without answering a single question... just a nod of the head, and a stroke of the beard. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -182,000 Americans die from Chuck Norris-related accidents every year. +If you spell Chuck Norris in Scrabble, you win. Forever. % -Paper beats rock, rock beats scissors, and scissors beats paper, but Chuck Norris beats all 3 at the same time. +Guns don't kill people. Chuck Norris kills people. % -Jesus can walk on water, but Chuck Norris can walk on Jesus. +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -All roads lead to Chuck Norris. And by the transitive property, a roundhouse kick to the face. +The chief export of Chuck Norris is Pain. % -If you're driving down the road and you think Chuck Norris just cut you off, you better thank your lucky stars it wasn't the other way around. +Chuck Norris has two speeds. Walk, and Kill. % -July 4th is Independence day. And the day Chuck Norris was born. Coincidence? i think not. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -Chuck Norris never goes to the dentist because his teeth are unbreakable. His enemies never go to the dentist because they have no teeth. +Chuck Norris drives an ice cream truck covered in human skulls. % -In the medical community, death is referred to as "Chuck Norris Disease" +Chuck Norris is my Homeboy. % -Chuck Norris was once in a knife fight, and the knife lost. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -If you work in an office with Chuck Norris, don't ask him for his three-hole-punch. +Chuck Norris uses pepper spray to spice up his steaks. % -In the Words of Julius Caesar, "Veni, Vidi, Vici, Chuck Norris". Translation: I came, I saw, and I was roundhouse-kicked inthe face by Chuck Norris. +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -The First rule of Chuck Norris is: you do not talk about Chuck Norris. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -Chuck Norris is widely predicted to be first black president. If you're thinking to yourself, "But Chuck Norris isn't black", then you are dead wrong. And stop being a racist. +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -When Chuck Norris plays Monopoly, it affects the actual world economy. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -Chuck Norris can be unlocked on the hardest level of Tekken. But only Chuck Norris is skilled enough to unlock himself. Then he roundhouse kicks the Playstation back to Japan. +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -Chuck Norris drinks napalm to quell his heartburn. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -Every time someone uses the word "intense", Chuck Norris always replies "you know what else is intense?" followed by a roundhouse kick to the face. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -As an infant, Chuck Norris' parents gave him a toy hammer. He gave the world Stonehenge. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -Chuck Norris once ordered a steak in a restaurant. The steak did what it was told. +The quickest way to a man's heart is with Chuck Norris' fist. % -Most people fear the Reaper. Chuck Norris considers him "a promising Rookie". +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -There are only two things that can cut diamonds: other diamonds, and Chuck Norris. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -President Roosevelt once rode his horse 100 miles. Chuck Norris carried his the same distance in half the time. +Chuck Norris can win a game of Connect Four in only three moves. % -Chuck Norris once ate four 30lb bowling balls without chewing. +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -What many people dont know is chuck norris is the founder of planned parenthood. Not even unborn children can escape his wrath. +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -Chuck Norris was banned from competitive bullriding after a 1992 exhibition in San Antonio, when he rode the bull 1,346 miles from Texas to Milwaukee Wisconsin to pick up his dry cleaning. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -Chuck Norris qualified with a top speed of 324 mph at the Daytona 500, without a car. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -Chuck Norris likes his coffee half and half: half coffee grounds, half wood-grain alcohol. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -Chuck Norris uses tabasco sauce instead of visine. +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -The chemical formula for the highly toxic cyanide ion is CN-. These are also Chuck Norris' initials. This is not a coincidence. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -Chuck Norris' credit cards have no limit. Last weekend, he maxed them out. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -Think of a hot woman. Chuck Norris did her. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -A man once claimed Chuck Norris kicked his ass twice, but it was promptly dismissed as false - no one could survive it the first time. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -Chuck Norris sleeps with a pillow under his gun. +The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death % -Chuck Norris owns a chain of fast-food restaurants throughout the southwest. They serve nothing but barbecue-flavored ice cream and Hot Pockets. +Chuck Norris doesn't read. He just stares at the book until he gets the information he wants. % -Chuck Norris doesn't chew gum. Chuck Norris chews tin foil. +Why didn't the chicken cross the road? Because Chuck Norris got to it first. % -Aliens DO indeed exist. They just know better than to visit a planet that Chuck Norris is on. +When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000. % -When in a bar, you can order a drink called a "Chuck Norris". It is also known as a "Bloody Mary", if your name happens to be Mary. +Chuck Norris can milk an alligator % -Every time Chuck Norris smiles, someone dies. Unless he smiles while he's roundhouse kicking someone in the face. Then two people die. +Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it % -Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag. +Chuck Norris once proved p^~p by induction on his beard hairs. % -There's an order to the universe: space, time, Chuck Norris.... Just kidding, Chuck Norris is first. +The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon. % -A man once asked Chuck Norris if his real name is "Charles". Chuck Norris did not respond, he simply stared at him until he exploded. +Chuck Norris can bake in a Freezer. % -Chuck Norris starts everyday with a protein shake made from Carnation Instant Breakfast, one dozen eggs, pure Colombian cocaine, and rattlesnake venom. He injects it directly into his neck with a syringe. +Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick. % -In a tagteam match, Chuck Norris was teamed with Hulk Hogan against King Kong Bundy and Andre The Giant. He pinned all 3 at the same time. +Chuck Norris once had a weak moment, just to know what it felt like. % -Chuck Norris doesn't see dead people. He makes people dead. +Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima? % -Chuck Norris is the only person who can simultaneously hold and fire FIVE Uzis: One in each hand, one in each foot -- and the 5th one he roundhouse-kicks into the air, so that it sprays bullets. +Chuck Norris has made a 148 break a snooker. % -For undercover police work, Chuck Norris pins his badge underneath his shirt, directly into his chest. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -In the X-Men movies, none of the X-Men super-powers are done with special effects. Chuck Norris is the stuntman for every character. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -We live in an expanding universe. All of it is trying to get away from Chuck Norris. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -Chuck Norris went looking for a bar but couldn't find one. He walked to a vacant lot and sat there. Sure enough within an hour an a half someone constructed a bar around him. He then ordered a shot, drank it, and then burned the place to the ground. Chuck Norris yelled over the roar of the flames, "always leave things the way you found em!" +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -It is said that every time you masturbate, God kills a kitten. Every time God masturbates, Chuck Norris kills a lion. +Chuck Norris does not sleep. He waits. % -The word 'Kill' was invented by Chuck Norris. Other words were 'Die', 'Beer', and 'What'. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -Chuck Norris is a vegetarian. Meaning, he does not eat animals until first he puts them into vegetative state with his fists. +Chuck Norris is the reason why Waldo is hiding. % -The 11th commandment is "Thou shalt not piss off Chuck Norris" This commandment is rarely enforced, as it is impossible to accomplish. +Chuck Norris counted to infinity - twice. % -Chuck Norris is his own line at the DMV. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -Two wrongs don't make a right. Unless you're Chuck Norris. Then two wrongs make a roundhouse kick to the face. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -Who let the dogs out? Chuck Norris let the dogs out... and then roundhouse kicked them through an Oldsmobile. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Chuck Norris can do a roundhouse kick faster than the speed of light. This means that if you turn on a light switch, you will be dead before the lightbulb turns on. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -When Chuck Norris goes to out to eat, he orders a whole chicken, but he only eats its soul. +Chuck Norris can lead a horse to water AND make it drink. % -Chuck Norris sold his soul to the devil for his rugged good looks and unparalleled martial arts ability. Shortly after the transaction was finalized, Chuck roundhouse-kicked the devil in the face and took his soul back. The devil, who appreciates irony, couldn't stay mad and admitted he should have seen it coming. They now play poker every second Wednesday of the month. +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -Chuck Norris has never won an Academy Award for acting... because he's not acting. +Chuck Norris can slam a revolving door. % -If Chuck Norris wants your opinion, he'll beat it into you. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -Not everyone that Chuck Norris is mad at gets killed. Some get away. They are called astronauts. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -Chuck Norris has to register every part of his body as a separate lethal weapon. His spleen is considered a concealed weapon in over 50 states. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -A movie scene depicting Chuck Norris losing a fight with Bruce Lee was the product of history's most expensive visual effect. When adjusted for inflation, the effect cost more than the Gross National Product of Paraguay. +If you spell Chuck Norris in Scrabble, you win. Forever. % -Godzilla is a Japanese rendition of Chuck Norris' first visit to Tokyo. +Guns don't kill people. Chuck Norris kills people. % -They once made a Chuck Norris toilet paper, but there was a problem-- It wouldn't take shit from anybody. +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -Chuck Norris once rode a nine foot grizzly bear through an automatic car wash, instead of taking a shower. +The chief export of Chuck Norris is Pain. % -"Sweating bullets" is literally what happens when Chuck Norris gets too hot. +Chuck Norris has two speeds. Walk, and Kill. % -Chuck Norris' sperm can be seen with the naked eye. Each one is the size of a quarter. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -After taking a steroids test doctors informed Chuck Norris that he had tested positive. He laughed upon receiving this information, and said "of course my urine tested positive, what do you think they make steroids from?" +Chuck Norris drives an ice cream truck covered in human skulls. % -Chuck Norris doesn't daydream. He's too busy giving other people nightmares. +Chuck Norris is my Homeboy. % -When Arnold says the line "I'll be back" in the first Terminator movie it is implied that is he going to ask Chuck Norris for help. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -There are no such things as tornados. Chuck Norris just hates trailer parks. +Chuck Norris uses pepper spray to spice up his steaks. % -Chuck Norris' Penis is a third degree blackbelt, and an honorable 32nd-degree mason. +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -Chuck Norris does not follow fashion trends, they follow him. But then he turns around and kicks their ass. Nobody follows Chuck Norris. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -The phrase 'break a leg' was originally coined by Chuck Norris's co-stars in Walker, Texas Ranger as a good luck charm indicating that a broken leg might be the worst extent of their injuries. This never proved to be the case. +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -Chuck Norris' roundhouse kick is so powerful, it can be seen from outer space by the naked eye. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -Diamonds are not, despite popular belief, carbon. They are, in fact, Chuck Norris fecal matter. This was proven a recently, when scientific analysis revealed what appeared to be Jean-Claude Van Damme bone fragments inside the Hope Diamond. +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -Chuck Norris once participated in the running of the bulls. He walked. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -The Drummer for Def Leppard's only got one arm. Chuck Norris needed a back scratcher. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -Chuck Norris was the orginal sculptor of Mount Rushmore. He completed the entire project using only a bottle opener and a drywall trowel. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -Chuck Norris once rode a bull, and nine months later it had a calf. +The quickest way to a man's heart is with Chuck Norris' fist. % -Chuck Norris once lost the remote, but maintained control of the TV by yelling at it in between bites of his "Filet of Child" sandwich. +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -For Spring Break '05, Chuck Norris drove to Madagascar, riding a chariot pulled by two electric eels. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -The Manhattan Project was not intended to create nuclear weapons, it was meant to recreate the destructive power in a Chuck Norris Roundhouse Kick. They didn't even come close. +Chuck Norris can win a game of Connect Four in only three moves. % -Chuck Norris has banned rainbows from the state of North Dakota. +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -Divide Chuck Norris by zero and you will in fact get one........one bad-ass motherfucker that is. +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -TNT was originally developed by Chuck Norris to cure indigestion. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -After returning from World War 2 unscathed, Bob Dole was congratulated by Chuck Norris with a handshake. The rest is history. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -Chuck Norris runs on batteries. Specifically, Die Hards. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -"Let the Bodies Hit the Floor" was originally written as Chuck Norris' theme song. +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -Chuck Norris will never have a heart attack. His heart isn't nearly foolish enough to attack him. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -Only Chuck Norris can prevent forest fires. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -When Chuck Norris makes a burrito, its main ingredient is real toes. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -Chuck Norris is not Irish. His hair is soaked in the blood of his victims. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -In the movie "The Matrix", Chuck Norris is the Matrix. If you pay close attention in the green "falling code" scenes, you can make out the faint texture of his beard. +http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one. % -Chuck Norris' dick is so big, it has it's own dick, and that dick is still bigger than yours. +The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender". % -They say curiosity killed the cat. This is false. Chuck Norris killed the cat. Every single one of them. +Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you. % -There is no such thing as a lesbian, just a woman who has never met Chuck Norris. +World War II began because Chuck Norris took a nap. When he woke up, Hitler found out and killed himself out of fear Chuck Norris would kill him. % -Chuck Norris crossed the road. No one has ever dared question his motives. +The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live. % -When Chuck Norris was born, he immediately had sex with the first nurse he saw. He was her first. She was his third. That afternoon. +Only Chuck Norris can win the mind game, 'cause he never minds. % -One time, at band camp, Chuck Norris ate a percussionist. +Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning. % -Chuck Norris doesn't say "who's your daddy", because he knows the answer. +Bruce Lee didn't defeat Chuck Norris. Chuck hit Bruce with a Delayed roundhouse kick that was so fast that Lee only felt the impact a year later! % -Chuck Norris originally wrote the first dictionary. The definition for each word is as follows - A swift roundhouse kick to the face. +Chuck Norris doesn't need a bulletproof vest to be bulletproof % -Love does not hurt. Chuck Norris does. +When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just give him stacks of money. % -The term "Cleveland Steamer" got its name from Chuck Norris, when he took a dump while visiting the Rock and Roll Hall of fame and buried northern Ohio under a glacier of fecal matter. +Merlin was Chuck Norris' assistant. % -Chuck Norris once round-house kicked a salesman. Over the phone. +If you put in the correct cheat code in Halo 2, you can have Master Cheif play without his helmet; revealing to be Chuck Norris. % -The pen is mighter than the sword, but only if the pen is held by Chuck Norris. +Those who ignore history, are doomed by Chuck Norris. % -Chuck Norris doesn't kill two birds with one stone. Chuck Norris kills all birds, with two stones. The ones in his pants. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -Chuck Norris knows the last digit of pi. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -Those aren't credits that roll after Walker Texas Ranger. It is actually a list of fatalities that occurred during the making of the episode. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. % -The air around Chuck Norris is always a balmy 78 degrees. +Outer space exists because it's afraid to be on the same planet with Chuck Norris. % -When Chuck Norris wants an egg, he cracks open a chicken. +Chuck Norris does not sleep. He waits. % -Chuck Norris plays racquetball with a waffle iron and a bowling ball. +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. % -According to the Bible, God created the universe in six days. Before that, Chuck Norris created God by snapping his fingers. +Chuck Norris is the reason why Waldo is hiding. % -Chuck Norris doesn't believe in ravioli. He stuffs a live turtle with beef and smothers it in pig's blood. +Chuck Norris counted to infinity - twice. % -Count from one to ten. That's how long it would take Chuck Norris to kill you...Fourty seven times. +There is no chin behind Chuck Norris’ beard. There is only another fist. % -The 1972 Miami Dolphins lost one game, it was an exhibition game vs. Chuck Norris and three seven year old girls. Chuck Norris won with a roundhouse-kick to the face in overtime. +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. % -Chuck Norris is not Politically Correct. He is just Correct. Always. +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. % -Mr. T pities the fool. Chuck Norris rips the fool's fucking head off. +Chuck Norris' hand is the only hand that can beat a Royal Flush. % -Chuck Norris had to stop washing his clothes in the ocean. The tsunamis were killing people. +Chuck Norris can lead a horse to water AND make it drink. % -Chuck Norris has volunteered to remain on earth after the Rapture; he will spend his time fighting the Anti-Christ. +Chuck Norris doesn’t wear a watch. HE decides what time it is. % -They were going to release a Chuck Norris edition of Clue, but the answer always turns out to be "Chuck Norris. In The Library. With a Roundhouse Kick." +Chuck Norris can slam a revolving door. % -Chuck Norris is the only known mammal in history to have an opposable thumb. On his penis. +Chuck Norris does not get frostbite. Chuck Norris bites frost. % -A man once taunted Chuck Norris with a bag of Lay's potato chips, saying "Betcha can't eat just one!" Chuck Norris proceeded to eat the chips, the bag, and the man in one deft move. +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. % -Chuck Norris' favorite cereal is Kellogg's Nails 'N' Gravel. +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. % -In the first Jurassic Park movie, the Tyrannosaurus Rex wasn't chasing the jeep. Chuck Norris was chasing the Tyrannosaurus AND the jeep. +If you spell Chuck Norris in Scrabble, you win. Forever. % -Chuck Norris has never been accused of murder for the simple fact that his roundhouse kicks are recognized world-wide as "acts of God." +Guns don't kill people. Chuck Norris kills people. % -"Brokeback Mountain" is not just a movie. It's also what Chuck Norris calls the pile of dead ninjas in his front yard. +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. % -Chuck Norris does not wear a condom. Because there is no such thing as protection from Chuck Norris. +The chief export of Chuck Norris is Pain. % -Chuck Norris once had sex with a cigarette machine in the Osaka airport. +Chuck Norris has two speeds. Walk, and Kill. % -Rules of fighting: 1) Don't bring a knife to a gun fight. 2) Don't bring a gun to a Chuck Norris fight. +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % -Chuck Norris is the only man who has, literally, beaten the odds. With his fists. +Chuck Norris drives an ice cream truck covered in human skulls. % -In ancient China there is a legend that one day a child will be born from a dragon, grow to be a man, and vanquish evil from the land. That man is not Chuck Norris, because Chuck Norris killed that man. +Chuck Norris is my Homeboy. % -Chuck Norris wipes his ass with chain mail and sandpaper. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -When you play Monopoly with Chuck Norris, you do not pass go, and you do not collect two hundred dollars. You will be lucky if you make it out alive. +Chuck Norris uses pepper spray to spice up his steaks. % -Chuck Norris describes human beings as "a sociable holder for blood and guts". +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. % -Chuck Norris once got into a fight with a one-armed Ninja. Seeing that he had an unfair advantage, Chuck Norris ripped both of his arms off and one of his legs. He then roundhouse-kicked the ninja in the head, killing him instantly, and proceeded to sow his limbs back on using only a rusty tent spike and bailing wire. +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. % -Chuck Norris likes his ice like he likes his skulls: crushed. +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. % -Chuck Norris can kick through all 6 degrees of separation, hitting anyone, anywhere, in the face, at any time. +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. % -Most tough men eat nails for breakfast. chuck Norris does all of his grocery shopping at Home Depot. +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. % -Chuck Norris did not "lose" his virginity, he stalked it and then destroyed it with extreme prejudice. +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. % -Everything King Midas touches turnes to gold. Everything Chuck Norris touches turns up dead. +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. % -Chuck Norris' pulse is measured on the richter scale. +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. % -Most people know that Descarte said, "I think, therefore I am." What most people don't know is that that quote continues, "...afraid of Chuck Norris." +The quickest way to a man's heart is with Chuck Norris' fist. % -Chuck Norris once roundhouse-kicked a ten dollar bill into 200 nickels. +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. % -For every movie about Vietnam starring Chuck Norris, the historical duration of the war decreases. Just 3 more "Missing in Action" sequels, and that war will have never actually existed. +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -Chuck Norris' penis has a Hemi. +Chuck Norris can win a game of Connect Four in only three moves. % -Chuck Norris enjoys a good practical joke. His favorite is where he removes your lower intestine and pretends to make a balloon animal out of it. Then he cracks your skull open with a Volvo for not complimenting him on his balloon animal. +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. % -Chuck Norris CAN in fact 'raise the roof'. And he can do it with one hand. +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. % -Kenny G is allowed to live because Chuck Norris doesn't kill women. +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. % -Life is not, in fact, like a box of chocolates. It is more like a box of Chuck Norris, roundhouse kicking you in the face. And if you receive a box of Chuck Norris, you ALWAYS know what you are going to get. +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -For Chuck Norris, every street is "one way". HIS WAY. +Chuck Norris doesn’t wash his clothes, he disembowels them. % -There are now five cup sizes at Starbucks: Short, Tall, Grande, Venti, and Chuck Norris. +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -During the Vietnam War, Chuck Norris allowed himself to be captured. For torture, they made him eat his own entrails. He asked for seconds. +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. % -Chuck Norris once created a flamethrower by urinating into a lighter. +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. % -Instead of having a cigarette after sex, Chuck Norris heads outside and brands his cattle. +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." % -Chuck Norris actually built the stairway to heaven. +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. % -Whoever said "only the good die young" was probably in Chuck Norris's kindergarten class. +Some kids pee their name in snow. Chuck Norris pees his name in concrete. % -Chuck Norris once skewered a man with the Eiffel tower. +The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.” % -The best part of waking up, is not Folgers in your cup, but knowing that Chuck Norris didn't kill you in your sleep. +Chuck Norris created Heavy Metal when he was upset % -Chuck Norris doesn't own a can opener, he just chews through the can. +Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag. % -Occam's Razor says that the simplest answer tends to be the correct one. Norris' Razor involves a flick of the wrist and a Columbian Necktie. +When things go bump in the night.... it's Chuck Norris % -Chuck Norris needs a monkeywrench and a blowtorch to masturbate. +Chuck Norris fed the Hunger Games % -Proponents of higher-order theories of consciousness argue that consciousness is explained by the relation between two levels of mental states in which a higher-order mental state takes another mental state. If you mention this to Chuck Norris, expect an explosive roundhouse kick to the face for spouting too much fancy-talk. +Chuck Norris played "Got your Nose" with Voldemort and won. % -Chuck Norris invented all 32 letters of the alphabet. +Chuck Norris had a knife thrown at him............ the knife didn't impale him, he impaled the knife % -Remember The Ultimate Warrior? He quit wrestling because Chuck Norris wanted his nickname back. +Chuck Norris doesn't let it go. % -If a tree falls in the forest, does anybody hear? Yes. Chuck Norris hears it. Chuck Norris can hear everything. Chuck Norris can hear the shrieking terror in your soul. +You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well. % -Chuck Norris actually owns IBM. It was an extremely hostile takeover. +Whatever Chuck Norris wants, it will instantly appear. % -He, who laughs last, laughs best. He who laughs at Chuck Norris ? dies. +Chuck Norris once cut a knife with a stick of butter. % -Chuck Norris is like a dog, not only because he can smell fear, but because he can piss on whatever the fuck he wants. +Chuck Norris shops at Sam's Club, but leaves without having his receipt checked % -Chuck Norris can jump-start a car using jumper cables attached to his nipples. +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. % -Chuck Norris neither melts in your mouth nor in your hand. He shreds your trachea before ravaging your soul with a combination of chocolate, whickey, roundhouse kicks and death. Oh, and pain. Lots of pain. +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. % -Chuck Norris doesn't have blood. He is filled with magma. +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese. +% +One glance from Chuck Norris and snow turns itself yellow. +% +Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly. +% +Chuck Norris was the image used for Papa Smurf. +% +Chuck Norris is so scary he makes Sharks swim backwards away from him +% +When Chuck Norris tosses a coin, it lands on both head and tail. +% +Chuck Norris found the last digit of pie +% +Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel +% +James Bond has a license to kill. He got it from Chuck Norris. +% +Chuck Norris is Chuck Norris +% +"The Big Chuck Norris Roundhouse-Kick Theory" +% +That's not an eclipse....that's the sun hiding from Chuck Norris. +% +Chuck Norris doesn't like Mudkipz +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Chuck Norris doesn’t eat salad, he eats vegetarians +% +Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling. +% +Chuck Norris wasn't born on his birthday +% +One time a test cheated on Chuck Norris. +% +Chuck Norris won a stepdance contest by standing on his hands +% +Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white. +% +When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part. +% +Chuck Norris is the life of parties he dosen't attend +% +Chuck Norris can rub two fires together and make a stick! +% +Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris. +% +Chuck Norris rolled a 20 on a 6 sided die. +% +When chuck Norris was in school, he made his PE teacher run laps. +% +Chuck Norris wins NASCAR races with all right turns. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time. +% +Chuck Norris is overra... +% +Chuck Norris was originally in Mortal Kombat, but that version was deleted because no one can beat Chuck Norris in a fight. +% +Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead... +% +Chunk Norris can make sour milk turn fresh +% +There is no limbo, only a world that doesn't know of Chuck Norris +% +Chuck Norris CAN believe it's not butter +% +Dog the Bounty Hunter can't track Chuck Norris down. +% +Abraham Lincoln didn't die because he was shot, Chuck Norris roundhouse-kicked so fast his foot went back in time and killed Abraham Lincoln. +% +When Chuck Norris inhales helium, his voice doesn't change. +% +When Chuck Norris drinks water, the water automatically pasteurized. +% +Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill +% +Chuck Norris can play the death waltz with his chin. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win? +% +Chuck Norris once round-house kicked a salesman. Over the phone. +% +Chuck Norris can grill a popsicle +% +Chuck Norris' films are factual documentaries. +% +Casinos pay Chuck Norris not to play at anything or wish anyone good luck. +% +Chuck Norris once got a 200 yard punt return +% +Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables. +% +An angry glare from Chuck Norris is known to kill on the spot. +% +Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris. +% +When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris. +% +Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon. +% +In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris Sized. It is a cup made of a human skull. +% +After Chuck counted to infinity the first time, he vowed to count to infinity a second time....by counting the bodies of those previously roundhoused. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Taking Karate Lessons = $100, Buying MMA DVD's= $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS +% +Chuck Norris played the game of thrones and won +% +Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses +% +Chuck Norris doesn't call the wrong number, you just answer the wrong phone. +% +Chuck Norris once won the tour de france riding a " big wheel" +% +May the Force be with Chuck Norris... for it's own good. +% +Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade +% +During the Civil War Chuck Norris was a slave, his master would often beg him for mercy +% +Chuck Norris' glass is never half full or half empty. It stays full even after he takes a drink. +% + King Kong climbed the Empire State building in fear of Chuck Norris who was downstairs at the time. +% +Chuck Norris can French kiss his elbow. +% +Chuck Norris never trains, because he's Chuck Norris. +% +Every phobia known to man has a phobia of Chuck Norris +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store. +% +Chuck Norris Can Power Solar Panels. At Night. +% +When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris. +% +Chuck Norris is so hard, he uses diamonds as stress balls. +% +Chuck Norris can roundhouse kick someone through a window without breaking the glass +% +Chuck Norris. Enough said. +% +The letters in Chuck Norris cannot be unscrambled. +% +Chuck Norris once taught a class of martial arts.Unfortunately Chuck had forgiven to take elephant tranquilizers and killed every one just by saluting +% +Chuck Norris was heard in a soundproof room! +% +Chuck Norris can see in 3D with just one eye. +% +Chuck Norris owns all number 1 pencils. +% +Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face. +% +Chuck Norris doesn’t brew up tea. He sucks the bag. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +They say death by a 1000 lashes was the most painful way to die, that was before they got roundhouse kicked in the face by Chuck Norris +% +Chuck Norris made a statue bleed. +% +Dead bodies were found of people that are still alive. These people will cross Chuck Norris in the future and will be round-house kicked back in time. +% +The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon. +% +The kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened. +% +Chuck Norris can roundhouse-kick round houses into squares. +% +Chuck Norris is allowed two carry-ons. +% +Chuck Norris can divide by zero. +% +Chuck Norris does not have a cell phone because he hears everything +% +Chuck Norris isn't appropriate...appropriate isn't Chuck Norris +% +Earth's rotation is purely governed by the direction that Chuck Norris is walking. +% +Chuck Norris drowned a man ON LAND. +% +The Jone's are trying to keep up with Chuck Norris +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Chuck Norris bowled a 301 after constructing another pin out of his beard hair +% +The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there. +% +Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast. +% +There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up. +% +Chuck Norris' dog pick up after him. +% +Jedis are now taught to use the "Chuck" +% +Chuck Norris dosent carry a list. He always knows what to do. +% +When Chuck Norris performs a roundhouse kick, he's actually measuring the circumference of the universe. +% +Walker: Texas Ranger went into syndication before the first episode was shot. +% +Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down! +% +"Walker Texas Ranger: The Movie 3-D" was considered by Warner Brothers; however the technology to create the visual effects will never be possible. +% +When Chuck Norris creates a login, it tells him "password not strong enough", he types in his name and it tells him "password too strong." +% +Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Aliens fear that Chuck Norris might abduct them. +% +Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick! +% +How much wood could a woodchuck chuck if a woodchuck could chuck wood? No woodchuck could chuck Chuck's wood! +% +The sun only rises every morning because Chuck Norris allows it to. +% +Chuck Norris can do a regime change with a roundhouse kick. +% +Chuck Norris CAN spell with an I before E even after C. +% +Ghosts can see Chuck Norris +% +The answer to life, the universe and everything isnt 42. It's Chuck Norris. +% +When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter. +% +Chuck Norris once thought he was wrong. He was, however, mistaken. +% +Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming +% +"The wind cries Chuck Norris" +% +Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Chuck Norris: even Naruto can't believe it +% +Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket +% +Chuck Norris roundhouse kicks people in the face first and asks questions later. +% +Chuck Norris is the only one who can tear a facebook page! +% +Chuck Norris doesn't need air, he is air +% +Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal. +% +Achievement Unlocked: Chuck Norris of Death +% +Chuck Norris is the ghost in paranormal activity. +% +Chuck Norris can't get fired by Donald Trump +% +Ozzy Osbourne once accidentally bit the head off a live bat - Chuck Norris once deliberately bit the head off a live pterodactyl. +% +Note to self: Don’t be the cashier to tell Chuck Norris his coupons have expired. +% +Chuck Norris was what Willis was talking about. +% +Chuck Norris is entitiled to his own facts. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon. +% +When Chuck Norris played the card game War with a friend, France surrendered. +% +If Goliath listened to Chuck Norris he would have won. +% +Chuck Norris can defuse bomb even if he cut the wrong wire +% +Chuck Norris sleeps in Seattle. +% +Chuck Norris shot a man with a knife +% +The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship. +% +Chuck Norris CAN balance the light-switch between ON and OFF. +% +If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else! +% +In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him. +% +Chuck Norris is the reason tumbleweeds tumble +% +The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norris roundhouse kicked it into the Sun. +% +Chuck Norris can terminate a repeating decimal. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Chuck Norris doesn't look for fun. The fun looks for Chuck Norris. +% +Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury +% +The only word that rhymes with orange is Chuck Norris +% +Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should +% +gmail@chucknorris.com +% +Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month +% +Chuck Norris has killed the Dead Sea +% +On the keyboard there is no control button because Chuck Norris is always in control. +% +The truth hurts dosen't it, Chuck Norris' truth kills. +% +Chuck Norris sent a BBM to an iphone. +% +When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens. +% +Chuck Norris once cried just to see what it was like. The end result was the creation of life. +% +Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris counted to infinity - twice. +% +There is no chin behind Chuck Norris’ beard. There is only another fist. +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris doesn’t wear a watch. HE decides what time it is. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +Guns don't kill people. Chuck Norris kills people. +% +There is no theory of evolution. Just a list of animals Chuck Norris allows to live. +% +The chief export of Chuck Norris is Pain. +% +Chuck Norris has two speeds. Walk, and Kill. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris is my Homeboy. +% +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. +% +Chuck Norris doesn’t wash his clothes, he disembowels them. +% +A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Only Chuck Norris is stronger than an Altoid. +% +Chuck Norris has a battlecruiser AND a car. +% +Chuck Norris burnt a fire proof vest, UNDERWATER! +% +Chuck Norris was once turned down for American Idol. When Simon was questioned about it, he replied "I'm retiring after this season". I wonder why? +% +Chuck Norris doesn't cheat death, he beats it fair and square. +% +When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact . +% +Chuck Norris made the big bang just by clicking his fingers +% +Trick me once, shame on you, trick Chuck Norris.....rest in peace. +% +Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face. +% +This one time at band camp... BAM! Chuck Norris. +% +Chuck Norris protects his body guards. +% +Chuck Norris watched the first steps on the moon... From his summer home on Mars +% +The Earth is made up of two-thirds water and one-third Chuck Norris. % diff --git a/plugins/cloudapp/README.md b/plugins/cloudapp/README.md new file mode 100644 index 000000000..62975a631 --- /dev/null +++ b/plugins/cloudapp/README.md @@ -0,0 +1,24 @@ +# CloudApp plugin + +[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line. + +To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file: + +``` +plugins=(... dash) +``` + +## Requirements + +1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation) + +2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below: + ``` + email + password + ``` + +## Usage + +- `cloudapp `: uploads `` to your CloudApp account, and if you're using + macOS, copies the URL to your clipboard. diff --git a/plugins/cloudapp/cloudapp.plugin.zsh b/plugins/cloudapp/cloudapp.plugin.zsh index 99252f690..3b363c81b 100644 --- a/plugins/cloudapp/cloudapp.plugin.zsh +++ b/plugins/cloudapp/cloudapp.plugin.zsh @@ -1,2 +1,6 @@ -#!/bin/zsh -alias cloudapp=$ZSH/plugins/cloudapp/cloudapp.rb +alias cloudapp="${0:a:h}/cloudapp.rb" + +# Ensure only the owner can access the credentials file +if [[ -f ~/.cloudapp ]]; then + chmod 600 ~/.cloudapp +fi diff --git a/plugins/cloudfoundry/README.md b/plugins/cloudfoundry/README.md new file mode 100644 index 000000000..89dd9d1ce --- /dev/null +++ b/plugins/cloudfoundry/README.md @@ -0,0 +1,58 @@ +# Cloudfoundry Plugin + +This plugin is intended to offer a few simple aliases for regular users of the [Cloud Foundry Cli][1]. Most are just simple aliases that will save a bit of typing. Others include mini functions and or accept parameters. Take a look at the table below for details. + +| Alias | Command | Description | +|----------|-----------------------------|--------------------------------------------------------------------------| +| cfl | `cf login` | Login to Cloud Foundry | +| cft | `cf target` | Target the cli at a specific Org/Space in Cloud Foundry | +| cfa | `cf apps` | List all applications in the current Org/Space | +| cfs | `cf services` | List all services in the current Org/Space | +| cfm | `cf marketplace` | List the services available in the Marketplace | +| cfp | `cf push` | Push your application code to Cloud Foundry | +| cfcs | `cf create-service` | Create a service based on a Marketplace offering | +| cfbs | `cf bind-service` | Bind an application to a service you created | +| cfus | `cf unbind-service` | Unbind a service from an application | +| cfds | `cf delete-service` | Delete a service you no longer have bound | +| cfup | `cf cups` | Create a "user-provided-service" | +| cflg | `cf logs` | Tail the logs of an application (requires ) | +| cfr | `cf routes` | List all the routes in the current Space | +| cfe | `cf env` | Show the environment variables for an application (requires ) | +| cfsh | `cf ssh` | Attach to a running container (requires an etc.) | +| cfsc | `cf scale` | Scale an application (requires an etc.) | +| cfev | `cf events` | Show the application events (requires ) | +| cfdor | `cf delete-orphaned-routes` | Delete routes that are no longer bound to applications | +| cfbpk | `cf buildpacks` | List the available buildpacks | +| cfdm | `cf domains` | List the domains associates with this Cloud Foundry foundation | +| cfsp | `cf spaces` | List all the Spaces in the current Org | +| cfap | `cf app` | Show the details of a deployed application (requires ) | +| cfh. | `export CF_HOME=$PWD/.cf` | Set the current directory as CF_HOME | +| cfh~ | `export CF_HOME=~/.cf` | Set the user's root directory as CF_HOME | +| cfhu | `unset CF_HOME` | Unsets CF_HOME | +| cfpm | `cf push -f` | Push an application using a manifest (requires location) | +| cflr | `cf logs --recent` | Show the recent logs (requires ) | +| cfsrt | `cf start` | Start an application (requires ) | +| cfstp | `cf stop` | Stop an application (requires ) | +| cfstg | `cf restage` | Restage an application (requires ) | +| cfdel | `cf delete` | Delete an application (requires ) | +| cfsrtall | - | Start all apps that are currently in the "Stopped" state | +| cfstpall | - | Stop all apps that are currently in the "Started" state | + +For help and advice on what any of the commands does, consult the built in `cf` help functions as follows:- + +```bash +cf help # List the most popular and commonly used commands +cf help -a # Complete list of all possible commands +cf --help # Help on a specific command including arguments and examples +``` + +Alternatively, seek out the [online documentation][3]. And don't forget, there are loads of great [community plugins for the cf-cli][4] command line tool that can greatly extend its power and usefulness. + +## Contributors + +Contributed to `oh_my_zsh` by [benwilcock][2]. + +[1]: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html +[2]: https://github.com/benwilcock +[3]: https://docs.cloudfoundry.org/cf-cli/getting-started.html +[4]: https://plugins.cloudfoundry.org/ diff --git a/plugins/cloudfoundry/cloudfoundry.plugin.zsh b/plugins/cloudfoundry/cloudfoundry.plugin.zsh new file mode 100644 index 000000000..b6715787e --- /dev/null +++ b/plugins/cloudfoundry/cloudfoundry.plugin.zsh @@ -0,0 +1,34 @@ +# Some Useful CloudFoundry Aliases & Functions +alias cfl="cf login" +alias cft="cf target" +alias cfa="cf apps" +alias cfs="cf services" +alias cfm="cf marketplace" +alias cfp="cf push" +alias cfcs="cf create-service" +alias cfbs="cf bind-service" +alias cfus="cf unbind-service" +alias cfds="cf delete-service" +alias cfup="cf cups" +alias cflg="cf logs" +alias cfr="cf routes" +alias cfe="cf env" +alias cfsh="cf ssh" +alias cfsc="cf scale" +alias cfev="cf events" +alias cfdor="cf delete-orphaned-routes" +alias cfbpk="cf buildpacks" +alias cfdm="cf domains" +alias cfsp="cf spaces" +function cfap() { cf app $1 } +function cfh.() { export CF_HOME=$PWD/.cf } +function cfh~() { export CF_HOME=~/.cf } +function cfhu() { unset CF_HOME } +function cfpm() { cf push -f $1 } +function cflr() { cf logs $1 --recent } +function cfsrt() { cf start $1 } +function cfstp() { cf stop $1 } +function cfstg() { cf restage $1 } +function cfdel() { cf delete $1 } +function cfsrtall() {cf apps | awk '/stopped/ { system("cf start " $1)}'} +function cfstpall() {cf apps | awk '/started/ { system("cf stop " $1)}'} diff --git a/plugins/coffee/_coffee b/plugins/coffee/_coffee index 10b6b8164..5e52b30e6 100644 --- a/plugins/coffee/_coffee +++ b/plugins/coffee/_coffee @@ -1,6 +1,6 @@ #compdef coffee # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,7 +28,7 @@ # Description # ----------- # -# Completion script for Coffee.js v0.6.11 (http://coffeejs.org) +# Completion script for Coffee.js v0.6.11 (https://coffeescript.org) # # ------------------------------------------------------------------------------ # Authors diff --git a/plugins/colemak/README.md b/plugins/colemak/README.md new file mode 100644 index 000000000..4da4bc126 --- /dev/null +++ b/plugins/colemak/README.md @@ -0,0 +1,48 @@ +# Colemak plugin + +This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps) +for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position: + +![Colemak layout on a US keyboard](https://colemak.com/wiki/images/6/6c/Colemak2.png) + +To use it, add it to the plugins array in your `~/.zshrc` file: + +``` +plugins=(... colemak) +``` + +You will also need to enable `vi` mode, so add another line to `~/.zshrc`: +``` +bindkey -v +``` + +Restart your shell and hit the `` key to activate `vicmd` (navigation) mode, +and start navigating `zsh` with your new keybindings! + +## Key bindings for vicmd + +| Old | New | Binding | Description | +|------------|------------|---------------------------|----------------------------------------------------| +| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line | +| `j` | `n` | down-line-or-history | Move one line down or command history forwards | +| `k` | `e` | up-line-or-history | Move one line up or command history backwards | +| `l` | `i` | vi-forward-char | Move one character to the right | +| `n` | `k` | vi-repeat-search | Repeat command search forwards | +| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards | +| `i` | `u` | vi-insert | Enter insert mode | +| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode | +| `` | `l` | vi-undo-change | Undo change | +| `J` | `N` | vi-join | Join the current line with the next one | +| `e` | `j` | vi-forward-word-end | Move to the end of the next word | +| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word | + +## Key bindings for less + +| Keyboard shortcut | `less` key binding | +|-------------------|--------------------| +| `n` | forw-line | +| `e` | back-line | +| `k` | repeat-search | +| `ESC`+`k` | repeat-search-all | +| `K` | reverse-search | +| `ESC`+`K` | reverse-search-all | diff --git a/plugins/colored-man-pages/README.md b/plugins/colored-man-pages/README.md new file mode 100644 index 000000000..d9f6acb2a --- /dev/null +++ b/plugins/colored-man-pages/README.md @@ -0,0 +1,15 @@ +# Colored man pages plugin + +This plugin adds colors to man pages. + +To use it, add `colored-man-pages` to the plugins array in your zshrc file: + +```zsh +plugins=(... colored-man-pages) +``` + +You can also try to color other pages by prefixing the respective command with `colored`: + +```zsh +colored git help clone +``` diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 54f0bdda9..ac6a94654 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -16,7 +16,7 @@ EOF fi fi -man() { +function colored() { env \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \ @@ -28,5 +28,9 @@ man() { PAGER="${commands[less]:-$PAGER}" \ _NROFF_U=1 \ PATH="$HOME/bin:$PATH" \ - man "$@" + "$@" +} + +function man() { + colored man "$@" } diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md new file mode 100644 index 000000000..d1f878e62 --- /dev/null +++ b/plugins/colorize/README.md @@ -0,0 +1,35 @@ +# colorize + +With this plugin you can syntax-highlight file contents of over 300 supported languages and other text formats. + +Colorize will highlight the content based on the filename extension. If it can't find a syntax-highlighting +method for a given extension, it will try to find one by looking at the file contents. If no highlight method +is found it will just cat the file normally, without syntax highlighting. + +To use it, add colorize to the plugins array of your zshrc file: +``` +plugins=(... colorize) +``` + +## Styles + +Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: + +`ZSH_COLORIZE_STYLE="colorful"` + +## Usage + +* `ccat [files]`: colorize the contents of the file (or files, if more than one are provided). + If no arguments are passed it will colorize the standard input or stdin. + +* `cless [files]`: colorize the contents of the file (or files, if more than one are provided) and + open less. If no arguments are passed it will colorize the standard input or stdin. + +Note that `cless` will behave as less when provided more than one file: you have to navigate files with +the commands `:n` for next and `:p` for previous. The downside is that less options are not supported. +But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`. +In the latter form, the file contents will be concatenated and presented by less as a single file. + +## Requirements + +You have to install Pygments first: [pygments.org](http://pygments.org/download/) diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 11b58e69d..565ba5a36 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -1,28 +1,57 @@ -# Plugin for highlighting file content -# Plugin highlights file content based on the filename extension. -# If no highlighting method supported for given extension then it tries -# guess it by looking for file content. - -alias colorize='colorize_via_pygmentize' +# easier alias to use the plugin +alias ccat='colorize_via_pygmentize' +alias cless='colorize_via_pygmentize_less' colorize_via_pygmentize() { - if [ ! -x "$(which pygmentize)" ]; then - echo "package \'pygmentize\' is not installed!" - return -1 + if ! (( $+commands[pygmentize] )); then + echo "package 'Pygments' is not installed!" + return 1 fi + # If the environment varianle ZSH_COLORIZE_STYLE + # is set, use that theme instead. Otherwise, + # use the default. + if [ -z $ZSH_COLORIZE_STYLE ]; then + ZSH_COLORIZE_STYLE="default" + fi + + # pygmentize stdin if no arguments passed if [ $# -eq 0 ]; then - pygmentize -g $@ + pygmentize -O style="$ZSH_COLORIZE_STYLE" -g + return $? fi - for FNAME in $@ + # guess lexer from file extension, or + # guess it from file contents if unsuccessful + + local FNAME lexer + for FNAME in "$@" do - filename=$(basename "$FNAME") - lexer=`pygmentize -N \"$filename\"` - if [ "Z$lexer" != "Ztext" ]; then - pygmentize -l $lexer "$FNAME" + lexer=$(pygmentize -N "$FNAME") + if [[ $lexer != text ]]; then + pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" else - pygmentize -g "$FNAME" + pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" fi done } + +colorize_via_pygmentize_less() ( + # this function is a subshell so tmp_files can be shared to cleanup function + declare -a tmp_files + + cleanup () { + [[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}" + exit + } + trap 'cleanup' EXIT HUP TERM INT + + while (( $# != 0 )); do #TODO: filter out less opts + tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" + tmp_files+=("$tmp_file") + colorize_via_pygmentize "$1" > "$tmp_file" + shift 1 + done + + less -f "${tmp_files[@]}" +) diff --git a/plugins/command-not-found/README.md b/plugins/command-not-found/README.md new file mode 100644 index 000000000..1cf4ba66e --- /dev/null +++ b/plugins/command-not-found/README.md @@ -0,0 +1,32 @@ +# command-not-found plugin + +This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found. + +To use it, add `command-not-found` to the plugins array of your zshrc file: + +```zsh +plugins=(... command-not-found) +``` + +An example of how this plugin works in Ubuntu: +``` +$ mutt +The program 'mutt' can be found in the following packages: + * mutt + * mutt-kz + * mutt-patched +Try: sudo apt install +``` + +### Supported platforms + +It works out of the box with the command-not-found packages for: + +- [Ubuntu](https://www.porcheron.info/command-not-found-for-zsh/) +- [Debian](https://packages.debian.org/search?keywords=command-not-found) +- [Arch Linux](https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found) +- [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found) +- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound) +- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found) + +You can add support for other platforms by submitting a Pull Request. diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh index 0e2f2133f..dd1186e44 100644 --- a/plugins/command-not-found/command-not-found.plugin.zsh +++ b/plugins/command-not-found/command-not-found.plugin.zsh @@ -1,5 +1,5 @@ # Uses the command-not-found package zsh support -# as seen in http://www.porcheron.info/command-not-found-for-zsh/ +# as seen in https://www.porcheron.info/command-not-found-for-zsh/ # this is installed in Ubuntu [[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found @@ -31,3 +31,10 @@ if type brew &> /dev/null; then eval "$(brew command-not-found-init)"; fi fi + +# NixOS command-not-found support +if [ -x /run/current-system/sw/bin/command-not-found ]; then + command_not_found_handler () { + /run/current-system/sw/bin/command-not-found $@ + } +fi diff --git a/plugins/common-aliases/README.md b/plugins/common-aliases/README.md new file mode 100644 index 000000000..d198a29ac --- /dev/null +++ b/plugins/common-aliases/README.md @@ -0,0 +1,121 @@ +# Common Aliases Plugin + +This plugin creates helpful shortcut aliases for many commonly used commands. + +To use it add `common-aliases` to the plugins array in your zshrc file: + +```zsh +plugins=(... common-aliases) +``` + +## Aliases + +### ls command + +| Alias | Command | Description | +|-------|---------------|--------------------------------------------------------------------------------| +| l | `ls -lFh` | List files as a long list, show size, type, human-readable | +| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable | +| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable | +| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable | +| ll | `ls -l` | List files as a long list | +| ldot | `ls -ld .*` | List dot files as a long list | +| lS | `ls -1FSsh` | List files showing only size and name sorted by size | +| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) | +| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) | + +### File handling + +| Alias | Command | Description | +|-------|-----------------------|------------------------------------------------------------------------------------| +| rm | `rm -i` | Remove a file | +| cp | `cp -i` | Copy a file | +| mv | `mv -i` | Move a file | +| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file | +| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form | +| duf | `du -sh` | Display the size of files in current location in human-readable form | +| t | `tail -f` | Shorthand for tail which outputs the last part of a file | + +### find and grep + +| Alias | Command | Description | +|-------|-----------------------------------------------------|-----------------------------------------| +| fd | `find . -type d -name` | Find a directory with the given name | +| ff | `find . -type f -name` | Find a file with the given name | +| grep | `grep --color` | Searches for a query string | +| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files | + +### Other Aliases + +| Alias | Command | Description | +|-----------|---------------------|-------------------------------------------------------------| +| h | `history` | Lists all recently used commands | +| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands | +| help | `man` | Opens up the man page for a command | +| p | `ps -f` | Displays currently executing processes | +| sortnr | `sort -n -r` | Used to sort the lines of a text file | +| unexport | `unset` | Used to unset an environment variable | + +## Global aliases + +These aliases are expanded in any position in the command line, meaning you can use them even at the +end of the command you've typed. Examples: + +Quickly pipe to less: +```zsh +$ ls -l /var/log L +# will run +$ ls -l /var/log | less +``` +Silences stderr output: +```zsh +$ find . -type f NE +# will run +$ find . -type f 2>/dev/null +``` + +| Alias | Command | Description | +|-------|-----------------------------|-------------------------------------------------------------| +| H | `\| head` | Pipes output to head which outputs the first part of a file | +| T | `\| tail` | Pipes output to tail which outputs the last part of a file | +| G | `\| grep` | Pipes output to grep to search for some word | +| L | `\| less` | Pipes output to less, useful for paging | +| M | `\| most` | Pipes output to more, useful for paging | +| LL | `2>&1 \| less` | Writes stderr to stdout and passes it to less | +| CA | `2>&1 \| cat -A` | Writes stderr to stdout and passes it to cat | +| NE | `2 > /dev/null` | Silences stderr | +| NUL | `> /dev/null 2>&1` | Silences both stdout and stderr | +| P | `2>&1\| pygmentize -l pytb` | Writes stderr to stdout and passes it to pygmentize | + +## File extension aliases + +These are special aliases that are triggered when a file name is passed as the command. For example, +if the pdf file extension is aliased to `acroread` (a popular Linux pdf reader), when running `file.pdf` +that file will be open with `acroread`. + +### Reading Docs + +| Alias | Command | Description | +|-------|-------------|-------------------------------------| +| pdf | `acroread` | Opens up a document using acroread | +| ps | `gv` | Opens up a .ps file using gv | +| dvi | `xdvi` | Opens up a .dvi file using xdvi | +| chm | `xchm` | Opens up a .chm file using xchm | +| djvu | `djview` | Opens up a .djvu file using djview | + +### Listing files inside a packed file + +| Alias | Command | Description | +|---------|-------------|-------------------------------------| +| zip | `unzip -l` | Lists files inside a .zip file | +| rar | `unrar l` | Lists files inside a .rar file | +| tar | `tar tf` | Lists files inside a .tar file | +| tar.gz | `echo` | Lists files inside a .tar.gz file | +| ace | `unace l` | Lists files inside a .ace file | + +### Some other features + +- Opens urls in terminal using browser specified by the variable `$BROWSER` +- Opens C, C++, Tex and text files using editor specified by the variable `$EDITOR` +- Opens images using image viewer specified by the variable `$XIVIEWER` +- Opens videos and other media using mplayer diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index c7aafd8b8..785a09c63 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -13,7 +13,7 @@ alias lS='ls -1FSsh' alias lart='ls -1Fcart' alias lrt='ls -1Fcrt' -alias zshrc='$EDITOR ~/.zshrc' # Quick access to the ~/.zshrc file +alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file alias grep='grep --color' alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' @@ -44,8 +44,6 @@ alias p='ps -f' alias sortnr='sort -n -r' alias unexport='unset' -alias whereami=display_info - alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' @@ -54,17 +52,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 +85,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/compleat/README.md b/plugins/compleat/README.md new file mode 100644 index 000000000..630c91503 --- /dev/null +++ b/plugins/compleat/README.md @@ -0,0 +1,8 @@ +# compleat plugin + +This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion. + +To use it, add compleat to the plugins array in your zshrc file: +``` +plugins=(... compleat) +``` diff --git a/plugins/composer/README.md b/plugins/composer/README.md new file mode 100644 index 000000000..2b4bae579 --- /dev/null +++ b/plugins/composer/README.md @@ -0,0 +1,29 @@ +# composer + +This plugin provides completion for [composer](https://getcomposer.org/), as well as aliases +for frequent composer commands. It also adds Composer's global binaries to the PATH, using +Composer if available. + +To use it add `composer` to the plugins array in your zshrc file. + +```zsh +plugins=(... composer) +``` + +## Aliases + +| Alias | Command | Description | +| ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- | +| `c` | composer | Starts composer | +| `csu` | composer self-update | Updates composer to the latest version | +| `cu` | composer update | Updates composer dependencies and `composer.lock` file | +| `cr` | composer require | Adds new packages to `composer.json` | +| `crm` | composer remove | Removes packages from `composer.json` | +| `ci` | composer install | Resolves and installs dependencies from `composer.json` | +| `ccp` | composer create-project | Create new project from an existing package | +| `cdu` | composer dump-autoload | Updates the autoloader | +| `cdo` | composer dump-autoload --optimize-autoloader | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) | +| `cgu` | composer global update | Allows update command to run on COMPOSER_HOME directory | +| `cgr` | composer global require | Allows require command to run on COMPOSER_HOME directory | +| `cgrm` | composer global remove | Allows remove command to run on COMPOSER_HOME directory | +| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory | diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 07eb1de88..634961023 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -39,14 +39,22 @@ 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 +# Add Composer's global binaries to PATH, using Composer if available. +if (( $+commands[composer] )); then + export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null) +else + [ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin + [ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin +fi diff --git a/plugins/copydir/README.md b/plugins/copydir/README.md new file mode 100644 index 000000000..594bf1065 --- /dev/null +++ b/plugins/copydir/README.md @@ -0,0 +1,10 @@ +# copydir plugin + +Copies the path of your current folder to the system clipboard. + +To use, add `copydir` to your plugins array: +``` +plugins=(... copydir) +``` + +Then use the command `copydir` to copy the $PWD. diff --git a/plugins/copyfile/README.md b/plugins/copyfile/README.md new file mode 100644 index 000000000..53138ad06 --- /dev/null +++ b/plugins/copyfile/README.md @@ -0,0 +1,10 @@ +# copyfile plugin + +Puts the contents of a file in your system clipboard so you can paste it anywhere. + +To use, add `copyfile` to your plugins array: +``` +plugins=(... copyfile) +``` + +Then you can run the command `copyfile ` to copy the file named `filename`. 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/cpanm/README.md b/plugins/cpanm/README.md new file mode 100644 index 000000000..3803e3e00 --- /dev/null +++ b/plugins/cpanm/README.md @@ -0,0 +1,9 @@ +# Cpanm + +This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminus) ([docs](https://metacpan.org/pod/App::cpanminus)). + +To use it add cpanm to the plugins array in your zshrc file. + + ```bash +plugins=(... cpanm) +``` diff --git a/plugins/cpanm/_cpanm b/plugins/cpanm/_cpanm index 58451d35a..ff9ae1c15 100644 --- a/plugins/cpanm/_cpanm +++ b/plugins/cpanm/_cpanm @@ -6,9 +6,6 @@ # # Current supported cpanm version: 1.4000 (Tue Mar 8 01:00:49 PST 2011) # -# The latest code is always located at: -# https://github.com/rshhh/cpanminus/blob/master/etc/_cpanm -# local arguments curcontext="$curcontext" typeset -A opt_args diff --git a/plugins/dash/README.md b/plugins/dash/README.md new file mode 100644 index 000000000..0ca3e4e44 --- /dev/null +++ b/plugins/dash/README.md @@ -0,0 +1,28 @@ +# Dash plugin + +This plugin adds command line functionality for [Dash](https://kapeli.com/dash), +an API Documentation Browser for macOS. This plugin requires Dash to be installed +to work. + +To use it, add `dash` to the plugins array in your zshrc file: + +```zsh +plugins=(... dash) +``` + +## Usage + +- Open and switch to the dash application. +``` +dash +``` + +- Query for something in dash app: `dash query` +``` +dash golang +``` + +- You can optionally provide a keyword: `dash [keyword:]query` +``` +dash python:tuple +``` diff --git a/plugins/dash/dash.plugin.zsh b/plugins/dash/dash.plugin.zsh new file mode 100644 index 000000000..ace2e33c1 --- /dev/null +++ b/plugins/dash/dash.plugin.zsh @@ -0,0 +1,80 @@ +# Usage: dash [keyword:]query +dash() { open dash://"$*" } +compdef _dash dash + +_dash() { + # No sense doing this for anything except the 2nd position and if we haven't + # specified which docset to query against + if [[ $CURRENT -eq 2 && ! "$words[2]" =~ ":" ]]; then + local -a _all_docsets + _all_docsets=() + # Use defaults to get the array of docsets from preferences + # Have to smash it into one big line so that each docset is an element of + # our DOCSETS array + DOCSETS=("${(@f)$(defaults read com.kapeli.dashdoc docsets | tr -d '\n' | grep -oE '\{.*?\}')}") + + # remove all newlines since defaults prints so pretty like + # Now get each docset and output each on their own line + for doc in "$DOCSETS[@]"; do + # Only output docsets that are actually enabled + if [[ "`echo $doc | grep -Eo \"isEnabled = .*?;\" | sed 's/[^01]//g'`" == "0" ]]; then + continue + fi + + keyword='' + + # Order of preference as explained to me by @kapeli via email + KEYWORD_LOCATORS=(keyword suggestedKeyword platform) + for locator in "$KEYWORD_LOCATORS[@]"; do + # Echo the docset, try to find the appropriate keyword + # Strip doublequotes and colon from any keyword so that everything has the + # same format when output (we'll add the colon in the completion) + keyword=`echo $doc | grep -Eo "$locator = .*?;" | sed -e "s/$locator = \(.*\);/\1/" -e "s/[\":]//g"` + if [[ ! -z "$keyword" ]]; then + # if we fall back to platform, we should do some checking per @kapeli + if [[ "$locator" == "platform" ]]; then + # Since these are the only special cases right now, let's not do the + # expensive processing unless we have to + if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then + docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"` + case "$keyword" in + python) + case "$docsetName" in + "Python 2") keyword="python2" ;; + "Python 3") keyword="python3" ;; + esac ;; + java) + case "$docsetName" in + "Java SE7") keyword="java7" ;; + "Java SE6") keyword="java6" ;; + "Java SE8") keyword="java8" ;; + esac ;; + qt) + case "$docsetName" in + "Qt 5") keyword="qt5" ;; + "Qt 4"|Qt) keyword="qt4" ;; + esac ;; + cocos2d) + case "$docsetName" in + Cocos3D) keyword="cocos3d" ;; + esac ;; + esac + fi + fi + + # Bail once we have a match + break + fi + done + + # If we have a keyword, add it to the list! + if [[ ! -z "$keyword" ]]; then + _all_docsets+=($keyword) + fi + done + + # special thanks to [arx] on #zsh for getting me sorted on this piece + compadd -qS: -- "$_all_docsets[@]" + return + fi +} diff --git a/plugins/debian/README.md b/plugins/debian/README.md new file mode 100644 index 000000000..da5675c66 --- /dev/null +++ b/plugins/debian/README.md @@ -0,0 +1,85 @@ +# debian + +This plugin provides Debian-related aliases and functions for zsh. + +To use it add `debian` to the plugins array in your zshrc file. + +```zsh +plugins=(... debian) +``` + +## Settings + +- `$apt_pref`: use apt or aptitude if installed, fallback is apt-get. +- `$apt_upgr`: use upgrade or safe-upgrade (for aptitude). + +Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior. + +## Common Aliases + +| Alias | Command | Description | +| ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- | +| `age` | `apt-get` | Command line tool for handling packages | +| `api` | `aptitude` | Same functionality as `apt-get`, provides extra options | +| `acs` | `apt-cache search` | Command line tool for searching apt software package cache | +| `aps` | `aptitude search` | Searches installed packages using aptitude | +| `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format | +| `afs` | `apt-file search --regexp` | Search file in packages | +| `asrc` | `apt-get source` | Fetch source packages through `apt-get` | +| `app` | `apt-cache policy` | Displays priority of package sources | + +## Superuser Operations Aliases + +| Alias | Command | Description | +| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files | +| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages | +| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files | +| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages | +| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages | +| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies | +| `afu` | `sudo apt-file update` | Update the files in packages | +| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades | +| `ai` | `sudo $apt_pref install` | Command-line tool to install package | +| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line | +| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files | +| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files | +| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list | +| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory | +| `di` | `sudo dpkg -i` | Install all .deb files in the current directory | +| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use | + +## Aliases - Commands using `su` + +| Alias | Command | +| ----- | --------------------------------------------------------- | +| `aac` | `su -ls "$apt_pref autoclean" root` | +| `ac` | `su -ls "$apt_pref clean" root` | +| `ad` | `su -lc "$apt_pref update" root` | +| `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` | +| `adu` | `su -lc "$apt_pref update && aptitude dist-upgrade" root` | +| `afu` | `su -lc "apt-file update"` | +| `au` | `su -lc "$apt_pref $apt_upgr" root` | +| `dia` | `su -lc "dpkg -i ./*.deb" root` | + +## Miscellaneous Aliases + +| Alias | Command | Description | +| --------- | ---------------------------------------------- | ------------------------------ | +| `allpkgs` | `aptitude search -F "%p" --disable-columns ~i` | Display all installed packages | +| `mydeb` | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package | + +## Functions + +| Function | Description | +| ------------------- | --------------------------------------------------------------- | +| `apt-copy` | Create a simple script that can be used to 'duplicate' a system | +| `apt-history` | Displays apt history for a command | +| `kerndeb` | Builds kernel packages | +| `apt-list-packages` | List packages by size | + +## Authors + +- [@AlexBio](https://github.com/AlexBio) +- [@dbb](https://github.com/dbb) +- [@Mappleconfusers](https://github.com/Mappleconfusers) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 31a772d60..68c6df1ae 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -1,22 +1,21 @@ -# Authors: -# https://github.com/AlexBio -# https://github.com/dbb -# https://github.com/Mappleconfusers -# -# Debian-related zsh aliases and functions for zsh - -# Use aptitude if installed, or apt-get if not. +# Use apt or aptitude if installed, fallback is apt-get # You can just set apt_pref='apt-get' to override it. -if [[ -e $( which -p aptitude 2>&1 ) ]]; then - apt_pref='aptitude' - apt_upgr='safe-upgrade' -else - apt_pref='apt-get' - apt_upgr='upgrade' + +if [[ -z $apt_pref || -z $apt_upgr ]]; then + if [[ -e $commands[apt] ]]; then + apt_pref='apt' + apt_upgr='upgrade' + elif [[ -e $commands[aptitude] ]]; then + apt_pref='aptitude' + apt_upgr='safe-upgrade' + else + apt_pref='apt-get' + apt_upgr='upgrade' + fi fi # Use sudo by default if it's installed -if [[ -e $( which -p sudo 2>&1 ) ]]; then +if [[ -e $commands[sudo] ]]; then use_sudo=1 fi @@ -29,8 +28,7 @@ alias api='aptitude' # Some self-explanatory aliases alias acs="apt-cache search" alias aps='aptitude search' -alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \ - --no-gui --disable-columns search" # search package +alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search" # apt-file alias afs='apt-file search --regexp' @@ -43,60 +41,59 @@ alias app='apt-cache policy' # superuser operations ###################################################### if [[ $use_sudo -eq 1 ]]; then # commands using sudo ####### - alias aac='sudo $apt_pref autoclean' - alias abd='sudo $apt_pref build-dep' - alias ac='sudo $apt_pref clean' - alias ad='sudo $apt_pref update' - alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr' - alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade' - alias afu='sudo apt-file update' - alias ag='sudo $apt_pref $apt_upgr' - alias ai='sudo $apt_pref install' + alias aac="sudo $apt_pref autoclean" + alias abd="sudo $apt_pref build-dep" + alias ac="sudo $apt_pref clean" + alias ad="sudo $apt_pref update" + alias adg="sudo $apt_pref update && sudo $apt_pref $apt_upgr" + alias adu="sudo $apt_pref update && sudo $apt_pref dist-upgrade" + alias afu="sudo apt-file update" + alias au="sudo $apt_pref $apt_upgr" + alias ai="sudo $apt_pref install" # Install all packages given on the command line while using only the first word of each line: # acs ... | ail - alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install' - alias ap='sudo $apt_pref purge' - alias ar='sudo $apt_pref remove' + alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install" + alias ap="sudo $apt_pref purge" + alias ar="sudo $apt_pref remove" # apt-get only - alias ads='sudo apt-get dselect-upgrade' + alias ads="sudo apt-get dselect-upgrade" # Install all .deb files in the current directory. # Warning: you will need to put the glob in single quotes if you use: # glob_subst - alias dia='sudo dpkg -i ./*.deb' - alias di='sudo dpkg -i' + alias dia="sudo dpkg -i ./*.deb" + alias di="sudo dpkg -i" # Remove ALL kernel images and headers EXCEPT the one in use - alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))' + alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))' # commands using su ######### else - alias aac='su -ls \'$apt_pref autoclean\' root' - abd() { + alias aac="su -ls '$apt_pref autoclean' root" + function abd() { cmd="su -lc '$apt_pref build-dep $@' root" print "$cmd" eval "$cmd" } - alias ac='su -ls \'$apt_pref clean\' root' - alias ad='su -lc \'$apt_pref update\' root' - alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root' - alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root' - alias afu='su -lc "apt-file update"' - alias ag='su -lc \'$apt_pref $apt_upgr\' root' - ai() { + alias ac="su -ls '$apt_pref clean' root" + alias ad="su -lc '$apt_pref update' root" + alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root" + alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root" + alias afu="su -lc '$apt-file update'" + alias au="su -lc '$apt_pref $apt_upgr' root" + function ai() { cmd="su -lc 'aptitude -P install $@' root" print "$cmd" eval "$cmd" } - ap() { + function ap() { cmd="su -lc '$apt_pref -P purge $@' root" print "$cmd" eval "$cmd" } - ar() { + function ar() { cmd="su -lc '$apt_pref -P remove $@' root" print "$cmd" eval "$cmd" @@ -108,8 +105,7 @@ else alias di='su -lc "dpkg -i" root' # Remove ALL kernel images and headers EXCEPT the one in use - alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))'\'' root' + alias kclean='su -lc "aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))" root' fi # Completion ################################################################ @@ -118,16 +114,16 @@ fi # Registers a compdef for $1 that calls $apt_pref with the commands $2 # To do that it creates a new completion function called _apt_pref_$2 # -apt_pref_compdef() { +function apt_pref_compdef() { local f fb f="_apt_pref_${2}" eval "function ${f}() { - shift words; - service=\"\$apt_pref\"; - words=(\"\$apt_pref\" '$2' \$words); - ((CURRENT++)) - test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt + shift words; + service=\"\$apt_pref\"; + words=(\"\$apt_pref\" '$2' \$words); + ((CURRENT++)) + test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt }" compdef "$f" "$1" @@ -138,7 +134,7 @@ apt_pref_compdef abd "build-dep" apt_pref_compdef ac "clean" apt_pref_compdef ad "update" apt_pref_compdef afu "update" -apt_pref_compdef ag "$apt_upgr" +apt_pref_compdef au "$apt_upgr" apt_pref_compdef ai "install" apt_pref_compdef ail "install" apt_pref_compdef ap "purge" @@ -155,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' # Functions ################################################################# # create a simple script that can be used to 'duplicate' a system -apt-copy() { +function apt-copy() { print '#!/bin/sh'"\n" > apt-copy.sh cmd='$apt_pref install' @@ -176,8 +172,8 @@ apt-copy() { # apt-history remove # apt-history rollback # apt-history list -# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html -apt-history () { +# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html +function apt-history() { case "$1" in install) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) @@ -192,7 +188,7 @@ apt-history () { awk '{print $4"="$5}' ;; list) - zcat $(ls -rt /var/log/dpkg*) + zgrep --no-filename '' $(ls -rt /var/log/dpkg*) ;; *) echo "Parameters:" @@ -206,11 +202,11 @@ apt-history () { } # Kernel-package building shortcut -kerndeb () { +function kerndeb() { # temporarily unset MAKEFLAGS ( '-j3' will fail ) MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) print '$MAKEFLAGS set to '"'$MAKEFLAGS'" - appendage='-custom' # this shows up in $ (uname -r ) + appendage='-custom' # this shows up in $(uname -r ) revision=$(date +"%Y%m%d") # this shows up in the .deb file name make-kpkg clean @@ -220,10 +216,9 @@ kerndeb () { } # List packages by size -function apt-list-packages { +function apt-list-packages() { dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ grep -v deinstall | \ sort -n | \ awk '{print $1" "$2}' } - diff --git a/plugins/dircycle/README.md b/plugins/dircycle/README.md new file mode 100644 index 000000000..3ac162f05 --- /dev/null +++ b/plugins/dircycle/README.md @@ -0,0 +1,78 @@ +# dircycle + +Plugin for cycling through the directory stack + +This plugin enables directory navigation similar to using back and forward on browsers or common file explorers like Finder or Nautilus. It uses a small zle trick that lets you cycle through your directory stack left or right using Ctrl + Shift + Left / Right . This is useful when moving back and forth between directories in development environments, and can be thought of as kind of a nondestructive pushd/popd. + +## Enabling the plugin + +1. Open your `.zshrc` file and add `dircycle` in the plugins section: + + ```zsh + plugins=( + # all your enabled plugins + dircycle + ) + ``` + +2. Reload the source file or restart your Terminal session: + + ```console + $ source ~/.zshrc + $ + ``` + +## Usage Examples + +Say you opened these directories on the terminal: + +```console +~$ cd Projects +~/Projects$ cd Hacktoberfest +~/Projects/Hacktoberfest$ cd oh-my-zsh +~/Projects/Hacktoberfest/oh-my-zsh$ dirs -v +0 ~/Projects/Hacktoberfest/oh-my-zsh +1 ~/Projects/Hacktoberfest +2 ~/Projects +3 ~ +``` + +By pressing Ctrl + Shift + Left, the current working directory or `$CWD` will be from `oh-my-zsh` to `Hacktoberfest`. Press it again and it will be at `Projects`. + +And by pressing Ctrl + Shift + Right, the `$CWD` will be from `Projects` to `Hacktoberfest`. Press it again and it will be at `oh-my-zsh`. + +Here's a example history table with the same accessed directories like above: + +| Current `$CWD` | Key press | New `$CWD` | +| --------------- | ----------------------------------------------------- | --------------- | +| `oh-my-zsh` | Ctrl + Shift + Left | `Hacktoberfest` | +| `Hacktoberfest` | Ctrl + Shift + Left | `Projects` | +| `Projects` | Ctrl + Shift + Left | `~` | +| `~` | Ctrl + Shift + Right | `Projects` | +| `Projects` | Ctrl + Shift + Right | `Hacktoberfest` | +| `Hacktoberfest` | Ctrl + Shift + Right | `oh-my-zsh` | +| `oh-my-zsh` | Ctrl + Shift + Right | `~` | + +Note the last traversal, when pressing Ctrl + Shift + Right on a last known `$CWD`, it will change back to the first known `$CWD`, which in the example is `~`. + +Here's an asciinema cast demonstrating the example above: + +[![asciicast](https://asciinema.org/a/204406.png)](https://asciinema.org/a/204406) + +## Functions + +| Function | Description | +| -------------------- | --------------------------------------------------------------------------------------------------------- | +| `insert-cycledleft` | Change `$CWD` to the previous known stack, binded on Ctrl + Shift + Left | +| `insert-cycledright` | Change `$CWD` to the next known stack, binded on Ctrl + Shift + Right | + +## Rebinding keys + +You can bind these functions to other key sequences, as long as you know the bindkey sequence. For example, these commands bind to Alt + Shift + Left / Right in `xterm-256color`: + +```zsh +bindkey '^[[1;4D' insert-cycledleft +bindkey '^[[1;4C' insert-cycledright +``` + +You can get the bindkey sequence by pressing Ctrl + V, then pressing the keyboard shortcut you want to use. diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh index 2f32277cf..bb69f6b3f 100644 --- a/plugins/dircycle/dircycle.plugin.zsh +++ b/plugins/dircycle/dircycle.plugin.zsh @@ -9,29 +9,36 @@ # pushd -N: start counting from right of `dirs' output switch-to-dir () { + setopt localoptions nopushdminus + [[ ${#dirstack} -eq 0 ]] && return 1 + 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 + [[ ${#dirstack} -eq 0 ]] && return 1 done } insert-cycledleft () { - emulate -L zsh - setopt nopushdminus + switch-to-dir +1 || return - switch-to-dir +1 + local fn + for fn (chpwd $chpwd_functions precmd $precmd_functions); do + (( $+functions[$fn] )) && $fn + done zle reset-prompt } zle -N insert-cycledleft insert-cycledright () { - emulate -L zsh - setopt nopushdminus + switch-to-dir -0 || return - switch-to-dir -0 + local fn + for fn (chpwd $chpwd_functions precmd $precmd_functions); do + (( $+functions[$fn] )) && $fn + done zle reset-prompt } zle -N insert-cycledright diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md new file mode 100644 index 000000000..511f2be17 --- /dev/null +++ b/plugins/dirhistory/README.md @@ -0,0 +1,17 @@ +# Dirhistory plugin + +This plugin adds keyboard shortcuts for navigating directory history and hierarchy. + +To use it, add `dirhistory` to the plugins array in your zshrc file: + +```zsh +plugins=(... dirhistory) +``` +## Keyboard Shortcuts + +| Shortcut | Description | +|-----------------------------------|-----------------------------------------------------------| +| alt + left | Go to previous directory | +| alt + right | Undo alt + left | +| alt + up | Move into the parent directory | +| alt + down | Move into the first child directory by alphabetical order | diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 0209981e3..239915e48 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -2,6 +2,10 @@ # Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # +# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented) +# ALT-UP moves to higher hierarchy (cd ..) +# ALT-DOWN moves into the first directory found in alphabetical order +# dirhistory_past=($PWD) dirhistory_future=() @@ -119,6 +123,10 @@ zle -N dirhistory_zle_dirhistory_back # xterm in normal mode bindkey "\e[3D" dirhistory_zle_dirhistory_back bindkey "\e[1;3D" dirhistory_zle_dirhistory_back +# Mac teminal (alt+left/right) +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + bindkey "^[b" dirhistory_zle_dirhistory_back +fi # Putty: bindkey "\e\e[D" dirhistory_zle_dirhistory_back # GNU screen: @@ -127,7 +135,56 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back zle -N dirhistory_zle_dirhistory_future bindkey "\e[3C" dirhistory_zle_dirhistory_future bindkey "\e[1;3C" dirhistory_zle_dirhistory_future +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + bindkey "^[f" dirhistory_zle_dirhistory_future +fi bindkey "\e\e[C" dirhistory_zle_dirhistory_future bindkey "\eO3C" dirhistory_zle_dirhistory_future +# +# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings +# + +# Move up in hierarchy +function dirhistory_up() { + cd .. || return 1 +} + +# Move down in hierarchy +function dirhistory_down() { + cd "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return 1 +} + + +# Bind keys to hierarchy navigation +function dirhistory_zle_dirhistory_up() { + zle kill-buffer # Erase current line in buffer + dirhistory_up + zle accept-line +} + +function dirhistory_zle_dirhistory_down() { + zle kill-buffer # Erase current line in buffer + dirhistory_down + zle accept-line +} + +zle -N dirhistory_zle_dirhistory_up +# xterm in normal mode +bindkey "\e[3A" dirhistory_zle_dirhistory_up +bindkey "\e[1;3A" dirhistory_zle_dirhistory_up +# Mac teminal (alt+up) + #bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it +# Putty: +bindkey "\e\e[A" dirhistory_zle_dirhistory_up +# GNU screen: +bindkey "\eO3A" dirhistory_zle_dirhistory_up + +zle -N dirhistory_zle_dirhistory_down +bindkey "\e[3B" dirhistory_zle_dirhistory_down +bindkey "\e[1;3B" dirhistory_zle_dirhistory_down +# Mac teminal (alt+down) + #bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it +bindkey "\e\e[B" dirhistory_zle_dirhistory_down +bindkey "\eO3B" dirhistory_zle_dirhistory_down diff --git a/plugins/dirpersist/README.md b/plugins/dirpersist/README.md new file mode 100644 index 000000000..9880bc563 --- /dev/null +++ b/plugins/dirpersist/README.md @@ -0,0 +1,9 @@ +# Dirpersist plugin + +This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file. + +To use it, add `dirpersist` to the plugins array in your zshrc file: + +```zsh +plugins=(... dirpersist) +``` diff --git a/plugins/django/README.md b/plugins/django/README.md new file mode 100644 index 000000000..415f6b7ea --- /dev/null +++ b/plugins/django/README.md @@ -0,0 +1,56 @@ +# Django plugin + +This plugin adds completion and hints for the [Django Project](https://www.djangoproject.com/) `manage.py` commands +and options. + +To use it, add `django` to the plugins array in your zshrc file: + +```zsh +plugins=(... django) +``` + +## Usage + +```zsh +$> python manage.py (press here) +``` + +Would result in: + +```zsh +cleanup -- remove old data from the database +compilemessages -- compile .po files to .mo for use with gettext +createcachetable -- creates table for SQL cache backend +createsuperuser -- create a superuser +dbshell -- run command-line client for the current database +diffsettings -- display differences between the current settings and Django defaults +dumpdata -- output contents of database as a fixture +flush -- execute 'sqlflush' on the current database +inspectdb -- output Django model module for tables in database +loaddata -- install the named fixture(s) in the database +makemessages -- pull out all strings marked for translation +reset -- executes 'sqlreset' for the given app(s) +runfcgi -- run this project as a fastcgi +runserver -- start a lightweight web server for development +... +``` + +If you want to see the options available for a specific command, try: + +```zsh +$> python manage.py makemessages (press here) +``` + +And that would result in: + +```zsh +--all -a -- re-examine all code and templates +--domain -d -- domain of the message files (default: "django") +--extensions -e -- file extension(s) to examine (default: ".html") +--help -- display help information +--locale -l -- locale to process (default: all) +--pythonpath -- directory to add to the Python path +--settings -- python path to settings module +... +``` + diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh index 35865a692..86558ff2e 100644 --- a/plugins/django/django.plugin.zsh +++ b/plugins/django/django.plugin.zsh @@ -154,7 +154,7 @@ _managepy-makemessages(){ "--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \ "--no-wrap[Don't break long message lines into several lines.]" \ "--no-location[Don't write '#: filename:line' lines.]" \ - '--no-obsolete[emove obsolete message strings.]' \ + '--no-obsolete[Remove obsolete message strings.]' \ '--keep-pot[Keep .pot file after making messages.]' \ $nul_args && ret=0 } @@ -349,6 +349,7 @@ _managepy-commands() { 'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,' 'runserver:Starts a lightweight Web server for development.' 'shell:Runs a Python interactive interpreter.' + 'showmigrations:Shows all available migrations for the current project.' 'sql:Prints the CREATE TABLE SQL statements for the given app name(s).' 'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).' 'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).' diff --git a/plugins/dnf/README.md b/plugins/dnf/README.md old mode 100755 new mode 100644 diff --git a/plugins/dnote/README.md b/plugins/dnote/README.md new file mode 100644 index 000000000..e1b9b7044 --- /dev/null +++ b/plugins/dnote/README.md @@ -0,0 +1,51 @@ +# Dnote Plugin + +This plugin adds auto-completion for [Dnote](https://dnote.io) project. + +To use it, add `dnote` to the plugins array in your zshrc file: + +```zsh +plugins=(dnote) +``` + +## Usage + +At the basic level, this plugin completes all Dnote commands. + +```zsh +$ dnote a(press here) +``` + +would result in: + +```zsh +$ dnote add +``` + +For some commands, this plugin dynamically suggests matching book names. + +For instance, if you have three books that begin with 'j': 'javascript', 'job', 'js', + +```zsh +$ dnote view j(press here) +``` + +would result in: + +```zsh +$ dnote v j +javascript job js +``` + +As another example, + +```zsh +$ dnote edit ja(press here) +``` + +would result in: + + +```zsh +$ dnote v javascript +`````` diff --git a/plugins/dnote/_dnote b/plugins/dnote/_dnote new file mode 100644 index 000000000..c8b33486a --- /dev/null +++ b/plugins/dnote/_dnote @@ -0,0 +1,39 @@ +#compdef dnote + +local -a _1st_arguments + +_1st_arguments=( + 'add:add a new note' + 'view:list books, notes, or view a content' + 'edit:edit a note or a book' + 'remove:remove a note or a book' + 'find:find notes by keywords' + 'sync:sync data with the server' + 'login:login to the dnote server' + 'logout:logout from the dnote server' + 'version:print the current version' + 'help:get help about any command' +) + +get_booknames() { + local names=$(dnote view --name-only) + local -a ret + + while read -r line; do + ret+=("${line}") + done <<< "$names" + + echo "$ret" +} + +if (( CURRENT == 2 )); then + _describe -t commands "dnote subcommand" _1st_arguments + return +elif (( CURRENT == 3 )); then + case "$words[2]" in + v|view|a|add) + _alternative \ + "names:book names:($(get_booknames))" + esac +fi + diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index d3fcb29fe..07a87bc81 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -1,4 +1,29 @@ -# Docker-compose plugin for oh my zsh +# Docker-compose -A copy of the completion script from the [docker-compose](https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose) git repo. +This plugin provides completion for [docker-compose](https://docs.docker.com/compose/) as well as some +aliases for frequent docker-compose commands. +To use it, add docker-compose to the plugins array of your zshrc file: +``` +plugins=(... docker-compose) +``` + +## Aliases + +| Alias | Command | Description | +|-----------|--------------------------|------------------------------------------------------------------| +| dco | `docker-compose` | Docker-compose main command | +| dcb | `docker-compose build` | Build containers | +| dce | `docker-compose exec` | Execute command inside a container | +| dcps | `docker-compose ps` | List containers | +| dcrestart | `docker-compose restart` | Restart container | +| dcrm | `docker-compose rm` | Remove container | +| dcr | `docker-compose run` | Run a command in container | +| dcstop | `docker-compose stop` | Stop a container | +| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service | +| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon | +| dcdn | `docker-compose down` | Stop and remove containers | +| dcl | `docker-compose logs` | Show logs of container | +| dclf | `docker-compose logs -f` | Show logs and follow output | +| dcpull | `docker-compose pull` | Pull image of a service | +| dcstart | `docker-compose start` | Start a container | diff --git a/plugins/docker-compose/_docker-compose b/plugins/docker-compose/_docker-compose index 2947cef38..808b068a3 100644 --- a/plugins/docker-compose/_docker-compose +++ b/plugins/docker-compose/_docker-compose @@ -3,11 +3,6 @@ # Description # ----------- # zsh completion for docker-compose -# https://github.com/sdurrheimer/docker-compose-zsh-completion -# ------------------------------------------------------------------------- -# Version -# ------- -# 1.5.0 # ------------------------------------------------------------------------- # Authors # ------- @@ -28,7 +23,7 @@ __docker-compose_all_services_in_compose_file() { local already_selected local -a services already_selected=$(echo $words | tr " " "|") - __docker-compose_q config --services \ + __docker-compose_q ps --services "$@" \ | grep -Ev "^(${already_selected})$" } @@ -36,125 +31,42 @@ __docker-compose_all_services_in_compose_file() { __docker-compose_services_all() { [[ $PREFIX = -* ]] && return 1 integer ret=1 - services=$(__docker-compose_all_services_in_compose_file) + services=$(__docker-compose_all_services_in_compose_file "$@") _alternative "args:services:($services)" && ret=0 return ret } -# All services that have an entry with the given key in their docker-compose.yml section -__docker-compose_services_with_key() { - local already_selected - local -a buildable - already_selected=$(echo $words | tr " " "|") - # flatten sections to one line, then filter lines containing the key and return section name. - __docker-compose_q config \ - | sed -n -e '/^services:/,/^[^ ]/p' \ - | sed -n 's/^ //p' \ - | awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \ - | grep " \+$1:" \ - | cut -d: -f1 \ - | grep -Ev "^(${already_selected})$" -} - # All services that are defined by a Dockerfile reference __docker-compose_services_from_build() { [[ $PREFIX = -* ]] && return 1 - integer ret=1 - buildable=$(__docker-compose_services_with_key build) - _alternative "args:buildable services:($buildable)" && ret=0 - - return ret + __docker-compose_services_all --filter source=build } # All services that are defined by an image __docker-compose_services_from_image() { [[ $PREFIX = -* ]] && return 1 - integer ret=1 - pullable=$(__docker-compose_services_with_key image) - _alternative "args:pullable services:($pullable)" && ret=0 - - return ret -} - -__docker-compose_get_services() { - [[ $PREFIX = -* ]] && return 1 - integer ret=1 - local kind - declare -a running paused stopped lines args services - - docker_status=$(docker ps > /dev/null 2>&1) - if [ $? -ne 0 ]; then - _message "Error! Docker is not running." - return 1 - fi - - kind=$1 - shift - [[ $kind =~ (stopped|all) ]] && args=($args -a) - - lines=(${(f)"$(_call_program commands docker $docker_options ps $args)"}) - services=(${(f)"$(_call_program commands docker-compose 2>/dev/null $compose_options ps -q)"}) - - # Parse header line to find columns - local i=1 j=1 k header=${lines[1]} - declare -A begin end - while (( j < ${#header} - 1 )); do - i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) - j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) - k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) - begin[${header[$i,$((j-1))]}]=$i - end[${header[$i,$((j-1))]}]=$k - done - lines=(${lines[2,-1]}) - - # Container ID - local line s name - local -a names - for line in $lines; do - if [[ ${services[@]} == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then - names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}}) - for name in $names; do - s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" - s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}" - s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}" - if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then - stopped=($stopped $s) - else - if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = *\(Paused\)* ]]; then - paused=($paused $s) - fi - running=($running $s) - fi - done - fi - done - - [[ $kind =~ (running|all) ]] && _describe -t services-running "running services" running "$@" && ret=0 - [[ $kind =~ (paused|all) ]] && _describe -t services-paused "paused services" paused "$@" && ret=0 - [[ $kind =~ (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped "$@" && ret=0 - - return ret + __docker-compose_services_all --filter source=image } __docker-compose_pausedservices() { [[ $PREFIX = -* ]] && return 1 - __docker-compose_get_services paused "$@" + __docker-compose_services_all --filter status=paused } __docker-compose_stoppedservices() { [[ $PREFIX = -* ]] && return 1 - __docker-compose_get_services stopped "$@" + __docker-compose_services_all --filter status=stopped } __docker-compose_runningservices() { [[ $PREFIX = -* ]] && return 1 - __docker-compose_get_services running "$@" + __docker-compose_services_all --filter status=running } __docker-compose_services() { [[ $PREFIX = -* ]] && return 1 - __docker-compose_get_services all "$@" + __docker-compose_services_all } __docker-compose_caching_policy() { @@ -199,21 +111,30 @@ __docker-compose_subcommand() { (build) _arguments \ $opts_help \ + "*--build-arg=[Set build-time variables for one service.]:=: " \ '--force-rm[Always remove intermediate containers.]' \ + '(--quiet -q)'{--quiet,-q}'[Curb build output]' \ + '(--memory -m)'{--memory,-m}'[Memory limit for the build container.]' \ '--no-cache[Do not use cache when building the image.]' \ '--pull[Always attempt to pull a newer version of the image.]' \ + '--compress[Compress the build context using gzip.]' \ + '--parallel[Build images in parallel.]' \ '*:services:__docker-compose_services_from_build' && ret=0 ;; (bundle) _arguments \ $opts_help \ + '--push-images[Automatically push images for any services which have a `build` option specified.]' \ '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to ".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 + '--resolve-image-digests[Pin image tags to digests.]' \ + '--services[Print the service names, one per line.]' \ + '--volumes[Print the volume names, one per line.]' \ + '--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0 ;; (create) _arguments \ @@ -222,11 +143,12 @@ __docker-compose_subcommand() { $opts_no_recreate \ $opts_no_build \ "(--no-build)--build[Build images before creating containers.]" \ - '*:services:__docker-compose_services_all' && ret=0 + '*:services:__docker-compose_services' && ret=0 ;; (down) _arguments \ $opts_help \ + $opts_timeout \ "--rmi[Remove images. Type must be one of: 'all': Remove all images used by any service. 'local': Remove only images that don't have a custom tag set by the \`image\` field.]:type:(all local)" \ '(-v --volumes)'{-v,--volumes}"[Remove named volumes declared in the \`volumes\` section of the Compose file and anonymous volumes attached to containers.]" \ $opts_remove_orphans && ret=0 @@ -235,16 +157,18 @@ __docker-compose_subcommand() { _arguments \ $opts_help \ '--json[Output events as a stream of json objects]' \ - '*:services:__docker-compose_services_all' && ret=0 + '*:services:__docker-compose_services' && ret=0 ;; (exec) _arguments \ $opts_help \ '-d[Detached mode: Run command in the background.]' \ '--privileged[Give extended privileges to the process.]' \ - '--user=[Run the command as this user.]:username:_users' \ + '(-u --user)'{-u,--user=}'[Run the command as this user.]:username:_users' \ '-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \ '--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \ + '*'{-e,--env}'[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \ + '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \ '(-):running services:__docker-compose_runningservices' \ '(-):command: _command_names -e' \ '*::arguments: _normal' && ret=0 @@ -252,6 +176,12 @@ __docker-compose_subcommand() { (help) _arguments ':subcommand:__docker-compose_commands' && ret=0 ;; + (images) + _arguments \ + $opts_help \ + '-q[Only display IDs]' \ + '*:services:__docker-compose_services' && ret=0 + ;; (kill) _arguments \ $opts_help \ @@ -265,7 +195,7 @@ __docker-compose_subcommand() { $opts_no_color \ '--tail=[Number of lines to show from the end of the logs for each container.]:number of lines: ' \ '(-t --timestamps)'{-t,--timestamps}'[Show timestamps]' \ - '*:services:__docker-compose_services_all' && ret=0 + '*:services:__docker-compose_services' && ret=0 ;; (pause) _arguments \ @@ -284,12 +214,16 @@ __docker-compose_subcommand() { _arguments \ $opts_help \ '-q[Only display IDs]' \ - '*:services:__docker-compose_services_all' && ret=0 + '--filter KEY=VAL[Filter services by a property]:=:' \ + '*:services:__docker-compose_services' && ret=0 ;; (pull) _arguments \ $opts_help \ '--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \ + '--no-parallel[Disable parallel pulling]' \ + '(-q --quiet)'{-q,--quiet}'[Pull without printing progress information]' \ + '--include-deps[Also pull services declared as dependencies]' \ '*:services:__docker-compose_services_from_image' && ret=0 ;; (push) @@ -308,17 +242,20 @@ __docker-compose_subcommand() { (run) _arguments \ $opts_help \ + $opts_no_deps \ '-d[Detached mode: Run container in the background, print new container name.]' \ '*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \ + '*'{-l,--label}'[KEY=VAL Add or override a label (can be used multiple times)]:label KEY=VAL: ' \ '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \ '--name=[Assign a name to the container]:name: ' \ - $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' \ + '(-v --volume)*'{-v,--volume=}'[Bind mount a volume]:volume: ' \ '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \ + "--use-aliases[Use the services network aliases in the network(s) the container connects to]" \ '(-):services:__docker-compose_services' \ '(-):command: _command_names -e' \ '*::arguments: _normal' && ret=0 @@ -340,6 +277,11 @@ __docker-compose_subcommand() { $opts_timeout \ '*:running services:__docker-compose_runningservices' && ret=0 ;; + (top) + _arguments \ + $opts_help \ + '*:running services:__docker-compose_runningservices' && ret=0 + ;; (unpause) _arguments \ $opts_help \ @@ -357,8 +299,10 @@ __docker-compose_subcommand() { "(--no-build)--build[Build images before starting containers.]" \ "(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \ '(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \ + '--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \ + '--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \ $opts_remove_orphans \ - '*:services:__docker-compose_services_all' && ret=0 + '*:services:__docker-compose_services' && ret=0 ;; (version) _arguments \ @@ -385,12 +329,23 @@ _docker-compose() { integer ret=1 typeset -A opt_args + local file_description + + if [[ -n ${words[(r)-f]} || -n ${words[(r)--file]} ]] ; then + file_description="Specify an override docker-compose file (default: docker-compose.override.yml)" + else + file_description="Specify an alternate docker-compose file (default: docker-compose.yml)" + fi + _arguments -C \ '(- :)'{-h,--help}'[Get help]' \ - '(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \ + '*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \ '(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \ - '--verbose[Show more output]' \ + "--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \ '(- :)'{-v,--version}'[Print version and exit]' \ + '--verbose[Show more output]' \ + '--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \ + '--no-ansi[Do not print ANSI control characters]' \ '(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \ '--tls[Use TLS; implied by --tlsverify]' \ '--tlscacert=[Trust certs signed only by this CA]:ca path:' \ @@ -401,7 +356,7 @@ _docker-compose() { '(-): :->command' \ '(-)*:: :->option-or-argument' && ret=0 - local -a relevant_compose_flags relevant_docker_flags compose_options docker_options + local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options relevant_compose_flags=( "--file" "-f" @@ -415,6 +370,10 @@ _docker-compose() { "--skip-hostname-check" ) + relevant_compose_repeatable_flags=( + "--file" "-f" + ) + relevant_docker_flags=( "--host" "-H" "--tls" @@ -432,9 +391,18 @@ _docker-compose() { fi fi if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then - compose_options+=$k - if [[ -n "$opt_args[$k]" ]]; then - compose_options+=$opt_args[$k] + if [[ -n "${relevant_compose_repeatable_flags[(r)$k]}" ]]; then + values=("${(@s/:/)opt_args[$k]}") + for value in $values + do + compose_options+=$k + compose_options+=$value + done + else + compose_options+=$k + if [[ -n "$opt_args[$k]" ]]; then + compose_options+=$opt_args[$k] + fi fi fi done diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 351e77824..9ffe1edf6 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -5,9 +5,22 @@ # Aliases ################################################################### -alias dcup='docker-compose up' +# 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 dcrm='docker-compose rm' +alias dce='docker-compose exec' alias dcps='docker-compose ps' -alias dcstop='docker-compose stop' alias dcrestart='docker-compose restart' +alias dcrm='docker-compose rm' +alias dcr='docker-compose run' +alias dcstop='docker-compose stop' +alias dcup='docker-compose up' +alias dcupd='docker-compose up -d' +alias dcdn='docker-compose down' +alias dcl='docker-compose logs' +alias dclf='docker-compose logs -f' +alias dcpull='docker-compose pull' +alias dcstart='docker-compose start' diff --git a/plugins/docker-machine/README.md b/plugins/docker-machine/README.md new file mode 100644 index 000000000..308a6cfdb --- /dev/null +++ b/plugins/docker-machine/README.md @@ -0,0 +1,19 @@ +# docker-machine plugin for oh my zsh + +### Usage + +#### docker-vm +Will create a docker-machine with the name "dev" (required only once) +To create a second machine call "docker-vm foobar" or pass any other name + +#### docker-up +This will start your "dev" docker-machine (if necessary) and set it as the active one +To start a named machine use "docker-up foobar" + +#### docker-switch dev +Use this to activate a running docker-machine (or to switch between multiple machines) +You need to call either this or docker-up when opening a new terminal + +#### docker-stop +This will stop your "dev" docker-machine +To stop a named machine use "docker-stop foobar" \ No newline at end of file diff --git a/plugins/docker-machine/_docker-machine b/plugins/docker-machine/_docker-machine new file mode 100644 index 000000000..7c19ba8e7 --- /dev/null +++ b/plugins/docker-machine/_docker-machine @@ -0,0 +1,359 @@ +#compdef docker-machine +# Description +# ----------- +# zsh completion for docker-machine +# https://github.com/leonhartX/docker-machine-zsh-completion +# ------------------------------------------------------------------------- +# Version +# ------- +# 0.1.1 +# ------------------------------------------------------------------------- +# Authors +# ------- +# * Ke Xu +# ------------------------------------------------------------------------- +# Inspiration +# ----------- +# * @sdurrheimer docker-compose-zsh-completion https://github.com/sdurrheimer/docker-compose-zsh-completion +# * @ilkka _docker-machine + + +__docker-machine_get_hosts() { + [[ $PREFIX = -* ]] && return 1 + local state + declare -a hosts + state=$1; shift + if [[ $state != all ]]; then + hosts=(${(f)"$(_call_program commands docker-machine ls -q --filter state=$state)"}) + else + hosts=(${(f)"$(_call_program commands docker-machine ls -q)"}) + fi + _describe 'host' hosts "$@" && ret=0 + return ret +} + +__docker-machine_hosts_with_state() { + declare -a hosts + hosts=(${(f)"$(_call_program commands docker-machine ls -f '{{.Name}}\:{{.DriverName}}\({{.State}}\)\ {{.URL}}')"}) + _describe 'host' hosts +} + +__docker-machine_hosts_all() { + __docker-machine_get_hosts all "$@" +} + +__docker-machine_hosts_running() { + __docker-machine_get_hosts Running "$@" +} + +__docker-machine_get_swarm() { + declare -a swarms + swarms=(${(f)"$(_call_program commands docker-machine ls -f {{.Swarm}} | awk '{print $1}')"}) + _describe 'swarm' swarms +} + +__docker-machine_hosts_and_files() { + _alternative "hosts:host:__docker-machine_hosts_all -qS ':'" 'files:files:_path_files' +} + +__docker-machine_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (driver) + _describe -t driver-filter-opts "driver filter" opts_driver && ret=0 + ;; + (swarm) + __docker-machine_get_swarm && ret=0 + ;; + (state) + opts_state=('Running' 'Paused' 'Saved' 'Stopped' 'Stopping' 'Starting' 'Error') + _describe -t state-filter-opts "state filter" opts_state && ret=0 + ;; + (name) + __docker-machine_hosts_all && ret=0 + ;; + (label) + _message 'label' && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('driver' 'swarm' 'state' 'name' 'label') + _describe -t filter-opts "filter" opts -qS "=" && ret=0 + fi + return ret +} + +__get_swarm_discovery() { + declare -a masters serivces + local service + services=() + masters=($(docker-machine ls -f {{.Swarm}} |grep '(master)' |awk '{print $1}')) + for master in $masters; do + service=${${${(f)"$(_call_program commands docker-machine inspect -f '{{.HostOptions.SwarmOptions.Discovery}}:{{.Name}}' $master)"}/:/\\:}} + services=($services $service) + done + _describe -t services "swarm service" services && ret=0 + return ret +} + +__get_create_argument() { + typeset -g docker_machine_driver + if [[ CURRENT -le 2 ]]; then + docker_machine_driver="none" + elif [[ CURRENT > 2 && $words[CURRENT-2] = '-d' || $words[CURRENT-2] = '--driver' ]]; then + docker_machine_driver=$words[CURRENT-1] + elif [[ $words[CURRENT-1] =~ '^(-d|--driver)=' ]]; then + docker_machine_driver=${${words[CURRENT-1]}/*=/} + fi + local driver_opt_cmd + local -a opts_provider opts_common opts_read_argument + opts_read_argument=( + ": :->argument" + ) + opts_common=( + $opts_help \ + '(--driver -d)'{--driver=,-d=}'[Driver to create machine with]:dirver:->driver-option' \ + '--engine-install-url=[Custom URL to use for engine installation]:url' \ + '*--engine-opt=[Specify arbitrary flags to include with the created engine in the form flag=value]:flag' \ + '*--engine-insecure-registry=[Specify insecure registries to allow with the created engine]:registry' \ + '*--engine-registry-mirror=[Specify registry mirrors to use]:mirror' \ + '*--engine-label=[Specify labels for the created engine]:label' \ + '--engine-storage-driver=[Specify a storage driver to use with the engine]:storage-driver:->storage-driver-option' \ + '*--engine-env=[Specify environment variables to set in the engine]:environment' \ + '--swarm[Configure Machine with Swarm]' \ + '--swarm-image=[Specify Docker image to use for Swarm]:image' \ + '--swarm-master[Configure Machine to be a Swarm master]' \ + '--swarm-discovery=[Discovery service to use with Swarm]:service:->swarm-service' \ + '--swarm-strategy=[Define a default scheduling strategy for Swarm]:strategy:(spread binpack random)' \ + '*--swarm-opt=[Define arbitrary flags for swarm]:flag' \ + '*--swarm-join-opt=[Define arbitrary flags for Swarm join]:flag' \ + '--swarm-host=[ip/socket to listen on for Swarm master]:host' \ + '--swarm-addr=[addr to advertise for Swarm (default: detect and use the machine IP)]:address' \ + '--swarm-experimental[Enable Swarm experimental features]' \ + '*--tls-san=[Support extra SANs for TLS certs]:option' + ) + driver_opt_cmd="docker-machine create -d $docker_machine_driver | grep $docker_machine_driver | sed -e 's/\(--.*\)\ *\[\1[^]]*\]/*\1/g' -e 's/\(\[[^]]*\)/\\\\\\1\\\\/g' -e 's/\".*\"\(.*\)/\1/g' | awk '{printf \"%s[\", \$1; for(i=2;i<=NF;i++) {printf \"%s \", \$i}; print \"]\"}'" + if [[ $docker_machine_driver != "none" ]]; then + opts_provider=(${(f)"$(_call_program commands $driver_opt_cmd)"}) + _arguments \ + $opts_provider \ + $opts_read_argument \ + $opts_common && ret=0 + else + _arguments $opts_common && ret=0 + fi + case $state in + (driver-option) + _describe -t driver-option "driver" opts_driver && ret=0 + ;; + (storage-driver-option) + _describe -t storage-driver-option "storage driver" opts_storage_driver && ret=0 + ;; + (swarm-service) + __get_swarm_discovery && ret=0 + ;; + (argument) + ret=0 + ;; + esac + return ret +} + + +__docker-machine_subcommand() { + local -a opts_help + opts_help=("(- :)--help[Print usage]") + local -a opts_only_host opts_driver opts_storage_driver opts_stragery + opts_only_host=( + "$opts_help" + "*:host:__docker-machine_hosts_all" + ) + opts_driver=('amazonec2' 'azure' 'digitalocean' 'exoscale' 'generic' 'google' 'hyperv' 'none' 'openstack' 'rackspace' 'softlayer' 'virtualbox' 'vmwarefusion' 'vmwarevcloudair' 'vmwarevsphere') + opts_storage_driver=('overlay' 'aufs' 'btrfs' 'devicemapper' 'vfs' 'zfs') + integer ret=1 + + case "$words[1]" in + (active) + _arguments \ + $opts_help \ + '(--timeout -t)'{--timeout=,-t=}'[Timeout in seconds, default to 10s]:seconds' && ret=0 + ;; + (config) + _arguments \ + $opts_help \ + '--swarm[Display the Swarm config instead of the Docker daemon]' \ + "*:host:__docker-machine_hosts_all" && ret=0 + ;; + (create) + __get_create_argument + ;; + (env) + _arguments \ + $opts_help \ + '--swarm[Display the Swarm config instead of the Docker daemon]' \ + '--shell=[Force environment to be configured for a specified shell: \[fish, cmd, powershell\], default is auto-detect]:shell' \ + '(--unset -u)'{--unset,-u}'[Unset variables instead of setting them]' \ + '--no-proxy[Add machine IP to NO_PROXY environment variable]' \ + '*:host:__docker-machine_hosts_running' && ret=0 + ;; + (help) + _arguments ':subcommand:__docker-machine_commands' && ret=0 + ;; + (inspect) + _arguments \ + $opts_help \ + '(--format -f)'{--format=,-f=}'[Format the output using the given go template]:template' \ + '*:host:__docker-machine_hosts_all' && ret=0 + ;; + (ip) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_running' && ret=0 + ;; + (kill) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_with_state' && ret=0 + ;; + (ls) + _arguments \ + $opts_help \ + '(--quiet -q)'{--quiet,-q}'[Enable quiet mode]' \ + '*--filter=[Filter output based on conditions provided]:filter:->filter-options' \ + '(--timeout -t)'{--timeout=,-t=}'[Timeout in seconds, default to 10s]:seconds' \ + '(--format -f)'{--format=,-f=}'[Pretty-print machines using a Go template]:template' && ret=0 + case $state in + (filter-options) + __docker-machine_filters && ret=0 + ;; + esac + ;; + (provision) + _arguments $opts_only_host && ret=0 + ;; + (regenerate-certs) + _arguments \ + $opts_help \ + '(--force -f)'{--force,-f}'[Force rebuild and do not prompt]' \ + '*:host:__docker-machine_hosts_all' && ret=0 + ;; + (restart) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_with_state' && ret=0 + ;; + (rm) + _arguments \ + $opts_help \ + '(--force -f)'{--force,-f}'[Remove local configuration even if machine cannot be removed, also implies an automatic yes (`-y`)]' \ + '-y[Assumes automatic yes to proceed with remove, without prompting further user confirmation]' \ + '*:host:__docker-machine_hosts_with_state' && ret=0 + ;; + (scp) + _arguments \ + $opts_help \ + '(--recursive -r)'{--recursive,-r}'[Copy files recursively (required to copy directories))]' \ + '*:files:__docker-machine_hosts_and_files' && ret=0 + ;; + (ssh) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_running' && ret=0 + ;; + (start) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_with_state' && ret=0 + ;; + (status) + _arguments $opts_only_host && ret=0 + ;; + (stop) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_with_state' && ret=0 + ;; + (upgrade) + _arguments $opts_only_host && ret=0 + ;; + (url) + _arguments \ + $opts_help \ + '*:host:__docker-machine_hosts_running' && ret=0 + ;; + esac + + return ret +} + + +__docker-machine_commands() { + local cache_policy + + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __docker-machine_caching_policy + fi + + if ( [[ ${+_docker_machine_subcommands} -eq 0 ]] || _cache_invalid docker_machine_subcommands) \ + && ! _retrieve_cache docker_machine_subcommands; + then + local -a lines + lines=(${(f)"$(_call_program commands docker-machine 2>&1)"}) + _docker_machine_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/$'\t'##/:}) + (( $#_docker_machine_subcommands > 0 )) && _store_cache docker_machine_subcommands _docker_machine_subcommands + fi + _describe -t docker-machine-commands "docker-machine command" _docker_machine_subcommands +} + +__docker-machine_caching_policy() { + oldp=( "$1"(Nmh+1) ) + (( $#oldp )) +} + +_docker-machine() { + if [[ $service != docker-machine ]]; then + _call_function - _$service + return + fi + + local curcontext="$curcontext" state line + integer ret=1 + typeset -A opt_args + + _arguments -C \ + "(- :)"{-h,--help}"[Show help]" \ + "(-D --debug)"{-D,--debug}"[Enable debug mode]" \ + '(-s --stroage-path)'{-s,--storage-path}'[Configures storage path]:file:_files' \ + '--tls-ca-cert[CA to verify remotes against]:file:_files' \ + '--tls-ca-key[Private key to generate certificates]:file:_files' \ + '--tls-client-cert[Client cert to use for TLS]:file:_files' \ + '--tls-client-key[Private key used in client TLS auth]:file:_files' \ + '--github-api-token[Token to use for requests to the Github API]' \ + '--native-ssh[Use the native (Go-based) SSH implementation.]' \ + '--bugsnag-api-token[BugSnag API token for crash reporting]' \ + '(- :)'{-v,--version}'[Print the version]' \ + "(-): :->command" \ + "(-)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker-machine_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-machine-$words[1]: + __docker-machine_subcommand && ret=0 + ret=0 + ;; + esac + + return ret +} + +_docker-machine "$@" diff --git a/plugins/docker-machine/docker-machine.plugin.zsh b/plugins/docker-machine/docker-machine.plugin.zsh new file mode 100644 index 000000000..235d90ee8 --- /dev/null +++ b/plugins/docker-machine/docker-machine.plugin.zsh @@ -0,0 +1,33 @@ +DEFAULT_MACHINE="default" + +docker-up() { + if [ -z "$1" ] + then + docker-machine start "${DEFAULT_MACHINE}" + eval $(docker-machine env "${DEFAULT_MACHINE}") + else + docker-machine start $1 + eval $(docker-machine env $1) + fi + echo $DOCKER_HOST +} +docker-stop() { + if [ -z "$1" ] + then + docker-machine stop "${DEFAULT_MACHINE}" + else + docker-machine stop $1 + fi +} +docker-switch() { + eval $(docker-machine env $1) + echo $DOCKER_HOST +} +docker-vm() { + if [ -z "$1" ] + then + docker-machine create -d virtualbox --virtualbox-disk-size 20000 --virtualbox-memory 4096 --virtualbox-cpu-count 2 "${DEFAULT_MACHINE}" + else + docker-machine create -d virtualbox --virtualbox-disk-size 20000 --virtualbox-memory 4096 --virtualbox-cpu-count 2 $1 + fi +} \ No newline at end of file diff --git a/plugins/docker/README.md b/plugins/docker/README.md index 1615f75f5..4d9f3ae9b 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -1,5 +1,11 @@ -## Docker autocomplete plugin +# Docker plugin -A copy of the completion script from the -[docker](https://github.com/docker/docker/tree/master/contrib/completion/zsh) -git repo. +This plugin adds auto-completion for [docker](https://www.docker.com/). + +To use it add `docker` to the plugins array in your zshrc file. +```zsh +plugins=(... docker) +``` + +A copy of the completion script from the docker/cli git repo: +https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 1366fd61b..54b5e59c5 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -57,7 +57,7 @@ __docker_get_containers() { type=$1; shift [[ $kind = (stopped|all) ]] && args=($args -a) - lines=(${(f)"$(_call_program commands docker $docker_options ps --format 'table' --no-trunc $args)"}) + 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]} @@ -78,7 +78,7 @@ __docker_get_containers() { 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 + if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = (Exit*|Created*) ]]; then stopped=($stopped $s) else running=($running $s) @@ -100,7 +100,7 @@ __docker_get_containers() { (( $#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 + if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = (Exit*|Created*) ]]; then stopped=($stopped $s) else running=($running $s) @@ -113,27 +113,27 @@ __docker_get_containers() { return ret } -__docker_stoppedcontainers() { +__docker_complete_stopped_containers() { [[ $PREFIX = -* ]] && return 1 __docker_get_containers stopped all "$@" } -__docker_runningcontainers() { +__docker_complete_running_containers() { [[ $PREFIX = -* ]] && return 1 __docker_get_containers running all "$@" } -__docker_containers() { +__docker_complete_containers() { [[ $PREFIX = -* ]] && return 1 __docker_get_containers all all "$@" } -__docker_containers_ids() { +__docker_complete_containers_ids() { [[ $PREFIX = -* ]] && return 1 __docker_get_containers all ids "$@" } -__docker_containers_names() { +__docker_complete_containers_names() { [[ $PREFIX = -* ]] && return 1 __docker_get_containers all names "$@" } @@ -149,30 +149,32 @@ __docker_complete_info_plugins() { return ret } -__docker_images() { +__docker_complete_images() { [[ $PREFIX = -* ]] && return 1 integer ret=1 declare -a images - images=(${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}}) + 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_repositories_with_tags && ret=0 + __docker_complete_repositories_with_tags && ret=0 return ret } -__docker_repositories() { +__docker_complete_repositories() { [[ $PREFIX = -* ]] && return 1 + integer ret=1 declare -a repos - repos=(${${${(f)"$(_call_program commands docker $docker_options images)"}%% *}[2,-1]}) + repos=(${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}%% *}[2,-1]}) repos=(${repos#}) - _describe -t docker-repos "repositories" repos + _describe -t docker-repos "repositories" repos && ret=0 + return ret } -__docker_repositories_with_tags() { +__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)"}[2,-1]}/ ##/:::}%% *}) + repos=(${${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}[2,-1]}/ ##/:::}%% *}) repos=(${${repos%:::}#}) # Check if we have a prefix-match for the current prefix. onlyrepos=(${repos%::*}) @@ -208,7 +210,7 @@ __docker_search() { 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)"}%% *}[2,-1]}) + 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 @@ -219,16 +221,19 @@ __docker_get_log_options() { integer ret=1 local log_driver=${opt_args[--log-driver]:-"all"} - local -a awslogs_options fluentd_options gelf_options journald_options json_file_options syslog_options splunk_options + local -a common_options common_options2 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") - 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") + common_options=("max-buffer-size" "mode") + common_options2=("env" "env-regex" "labels") + awslogs_options=($common_options "awslogs-create-group" "awslogs-datetime-format" "awslogs-group" "awslogs-multiline-pattern" "awslogs-region" "awslogs-stream" "tag") + fluentd_options=($common_options $common_options2 "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "fluentd-sub-second-precision" "tag") + gcplogs_options=($common_options $common_options2 "gcp-log-cmd" "gcp-meta-id" "gcp-meta-name" "gcp-meta-zone" "gcp-project") + gelf_options=($common_options $common_options2 "gelf-address" "gelf-compression-level" "gelf-compression-type" "tag") + journald_options=($common_options $common_options2 "tag") + json_file_options=($common_options $common_options2 "max-file" "max-size") + logentries_options=($common_options $common_options2 "logentries-token" "tag") + syslog_options=($common_options $common_options2 "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") + splunk_options=($common_options $common_options2 "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 @@ -236,13 +241,14 @@ __docker_get_log_options() { [[ $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_log_drivers() { +__docker_complete_log_drivers() { [[ $PREFIX = -* ]] && return 1 integer ret=1 drivers=(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog) @@ -250,15 +256,19 @@ __docker_log_drivers() { return ret } -__docker_log_options() { +__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 + local opts=('rfc3164' 'rfc5424' 'rfc5424micro') + _describe -t syslog-format-opts "syslog format options" opts && ret=0 + ;; + (mode) + local opts=('blocking' 'non-blocking') + _describe -t mode-opts "mode options" opts && ret=0 ;; *) _message 'value' && ret=0 @@ -293,7 +303,7 @@ __docker_complete_pid() { if compset -P '*:'; then case "${${words[-1]%:*}#*=}" in (container) - __docker_runningcontainers && ret=0 + __docker_complete_running_containers && ret=0 ;; *) _message 'value' && ret=0 @@ -325,33 +335,40 @@ __docker_complete_ps_filters() { if compset -P '*='; then case "${${words[-1]%=*}#*=}" in (ancestor) - __docker_images && ret=0 + __docker_complete_images && ret=0 ;; (before|since) - __docker_containers && ret=0 + __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_containers_ids && ret=0 + __docker_complete_containers_ids && ret=0 + ;; + (is-task) + _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 ;; (name) - __docker_containers_names && ret=0 + __docker_complete_containers_names && ret=0 ;; (network) - __docker_networks && ret=0 + __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 + _describe -t status-filter-opts "status filter options" status_opts && ret=0 ;; (volume) - __docker_volumes && ret=0 + __docker_complete_volumes && ret=0 ;; *) _message 'value' && ret=0 ;; esac else - opts=('ancestor' 'before' 'exited' 'id' 'label' 'name' 'network' 'since' 'status' 'volume') + opts=('ancestor' 'before' 'exited' 'expose' 'health' 'id' 'label' 'name' 'network' 'publish' 'since' 'status' 'volume') _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 fi @@ -388,12 +405,12 @@ __docker_complete_images_filters() { declare -a boolean_opts opts boolean_opts=('true' 'false') - opts=('before' 'dangling' 'label' 'since') + opts=('before' 'dangling' 'label' 'reference' 'since') if compset -P '*='; then case "${${words[-1]%=*}#*=}" in - (before|since) - __docker_images && ret=0 + (before|reference|since) + __docker_complete_images && ret=0 ;; (dangling) _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 @@ -414,12 +431,12 @@ __docker_complete_events_filter() { integer ret=1 declare -a opts - opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'type' 'volume') + opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'scope' 'type' 'volume') if compset -P '*='; then case "${${words[-1]%=*}#*=}" in (container) - __docker_containers && ret=0 + __docker_complete_containers && ret=0 ;; (daemon) emulate -L zsh @@ -433,16 +450,21 @@ __docker_complete_events_filter() { ;; (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') + event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disable' 'disconnect' 'enable' 'exec_create' 'exec_detach' + 'exec_start' 'export' 'health_status' 'import' 'install' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'remove' '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_images && ret=0 + __docker_complete_images && ret=0 ;; (network) - __docker_networks && ret=0 + __docker_complete_networks && ret=0 + ;; + (scope) + local -a scope_opts + scope_opts=('local' 'swarm') + _describe -t scope-filter-opts "scope filter options" scope_opts && ret=0 ;; (type) local -a type_opts @@ -450,7 +472,7 @@ __docker_complete_events_filter() { _describe -t type-filter-opts "type filter options" type_opts && ret=0 ;; (volume) - __docker_volumes && ret=0 + __docker_complete_volumes && ret=0 ;; *) _message 'value' && ret=0 @@ -463,6 +485,629 @@ __docker_complete_events_filter() { return ret } +__docker_complete_prune_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a opts + + opts=('until') + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret +} + +# BO checkpoint + +__docker_checkpoint_commands() { + local -a _docker_checkpoint_subcommands + _docker_checkpoint_subcommands=( + "create:Create a checkpoint from a running container" + "ls:List checkpoints for a container" + "rm:Remove a checkpoint" + ) + _describe -t docker-checkpoint-commands "docker checkpoint command" _docker_checkpoint_subcommands +} + +__docker_checkpoint_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)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \ + "($help)--leave-running[Leave the container running after checkpoint]" \ + "($help -)1:container:__docker_complete_running_containers" \ + "($help -)2:checkpoint: " && ret=0 + ;; + (ls|list) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \ + "($help -)1:container:__docker_complete_containers" && ret=0 + ;; + (rm|remove) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \ + "($help -)1:container:__docker_complete_containers" \ + "($help -)2:checkpoint: " && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_checkpoint_commands" && ret=0 + ;; + esac + + return ret +} + +# EO checkpoint + +# 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-cgroup-rule=[Add a rule to the cgroup allowed devices list]:device:cgroup: " + "($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)*--domainname=[Container NIS domain name]:domainname:_hosts" + "($help)*"{-e=,--env=}"[Environment variables]:environment variable: " + "($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: " + "($help)*--env-file=[Read environment variables from a file]:environment file:_files" + "($help)*--expose=[Expose a port from the container without publishing it]: " + "($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups" + "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts" + "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" + "($help)--init[Run an init inside the container that forwards signals and reaps processes]" + "($help)--ip=[IPv4 address]:IPv4: " + "($help)--ip6=[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=[Container IPv4/IPv6 link-local addresses]: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)*--mount=[Attach a filesystem mount to the container]:mount: " + "($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 '')]:shm size: " + "($help)--stop-signal=[Signal to kill a container]:signal:_signals" + "($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 -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" \ + "($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)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ + "($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)--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 stdin]" \ + "($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)--no-trunc[Do not truncate output]" \ + "($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)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: " \ + "($help)*--build-arg=[Build-time variables]:=: " \ + "($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 '')]:shm size: " \ + "($help)--squash[Squash newly built layers into a single new layer]" \ + "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_complete_repositories_with_tags" \ + "($help)*--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:__docker_complete_images_filters" \ + "($help)--format=[Pretty-print images using a Go template]:template: " \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -): :__docker_complete_repositories" && ret=0 + ;; + (prune) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Remove all unused images, not just dangling ones]" \ + "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ + "($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() { @@ -475,21 +1120,25 @@ __docker_network_complete_ls_filters() { __docker_complete_info_plugins Network && ret=0 ;; (id) - __docker_networks_ids && ret=0 + __docker_complete_networks_ids && ret=0 ;; (name) - __docker_networks_names && ret=0 + __docker_complete_networks_names && ret=0 + ;; + (scope) + opts=('global' 'local' 'swarm') + _describe -t scope-filter-opts "Scope filter options" opts && ret=0 ;; (type) - type_opts=('builtin' 'custom') - _describe -t type-filter-opts "Type Filter Options" type_opts && ret=0 + opts=('builtin' 'custom') + _describe -t type-filter-opts "Type filter options" opts && ret=0 ;; *) _message 'value' && ret=0 ;; esac else - opts=('driver' 'id' 'label' 'name' 'type') + opts=('driver' 'id' 'label' 'name' 'scope' 'type') _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 fi @@ -504,7 +1153,7 @@ __docker_get_networks() { type=$1; shift - lines=(${(f)"$(_call_program commands docker $docker_options network ls)"}) + 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]} @@ -524,6 +1173,7 @@ __docker_get_networks() { 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 @@ -533,6 +1183,7 @@ __docker_get_networks() { 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 @@ -541,17 +1192,17 @@ __docker_get_networks() { return ret } -__docker_networks() { +__docker_complete_networks() { [[ $PREFIX = -* ]] && return 1 __docker_get_networks all "$@" } -__docker_networks_ids() { +__docker_complete_networks_ids() { [[ $PREFIX = -* ]] && return 1 __docker_get_networks ids "$@" } -__docker_networks_names() { +__docker_complete_networks_names() { [[ $PREFIX = -* ]] && return 1 __docker_get_networks names "$@" } @@ -564,6 +1215,7 @@ __docker_network_commands() { "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 @@ -581,19 +1233,19 @@ __docker_network_subcommand() { _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)--ip=[IPv4 address]:IPv4: " \ + "($help)--ip6=[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_networks" \ - "($help -)2:containers:__docker_containers" && ret=0 + "($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_runningcontainers -qS ":" && ret=0 + __docker_complete_running_containers -qS ":" && ret=0 fi ;; esac @@ -601,6 +1253,7 @@ __docker_network_subcommand() { (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: " \ @@ -617,32 +1270,34 @@ __docker_network_subcommand() { (disconnect) _arguments $(__docker_arguments) \ $opts_help \ - "($help -)1:network:__docker_networks" \ - "($help -)2:containers:__docker_containers" && ret=0 + "($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_networks" && ret=0 + "($help)--verbose[Show detailed information]" \ + "($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)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \ "($help)--format=[Pretty-print networks using a Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 - case $state in - (filter-options) - __docker_network_complete_ls_filters && ret=0 - ;; - esac + ;; + (prune) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ + "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 ;; (rm) _arguments $(__docker_arguments) \ $opts_help \ - "($help -)*:network:__docker_networks" && ret=0 + "($help -)*:network:__docker_complete_networks" && ret=0 ;; (help) _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0 @@ -695,7 +1350,7 @@ __docker_node_complete_ps_filters() { if compset -P '*='; then case "${${words[-1]%=*}#*=}" in (desired-state) - state_opts=('accepted' 'running') + state_opts=('accepted' 'running' 'shutdown') _describe -t state-opts "desired state options" state_opts && ret=0 ;; *) @@ -720,7 +1375,7 @@ __docker_nodes() { filter=$1; shift [[ $filter != "none" ]] && args=("-f $filter") - lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"}) + 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 @@ -745,7 +1400,7 @@ __docker_nodes() { # Names if [[ $type = (names|all) ]]; then for line in $lines; do - s="${line[${begin[NAME]},${end[NAME]}]%% ##}" + s="${line[${begin[HOSTNAME]},${end[HOSTNAME]}]%% ##}" nodes=($nodes $s) done fi @@ -792,7 +1447,7 @@ __docker_node_commands() { "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 a node, defaults to current node" + "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 @@ -809,7 +1464,7 @@ __docker_node_subcommand() { (rm|remove) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--force[Force remove an active node]" \ + "($help -f --force)"{-f,--force}"[Force remove a node from the swarm]" \ "($help -)*:node:__docker_complete_pending_nodes" && ret=0 ;; (demote) @@ -827,13 +1482,8 @@ __docker_node_subcommand() { (ls|list) _arguments $(__docker_arguments) \ $opts_help \ - "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_node_complete_ls_filters" \ "($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) \ @@ -844,15 +1494,12 @@ __docker_node_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -a --all)"{-a,--all}"[Display all instances]" \ - "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_node_complete_ps_filters" \ + "($help)--format=[Format the output using the given go template]:template: " \ "($help)--no-resolve[Do not map IDs to Names]" \ "($help)--no-trunc[Do not truncate output]" \ - "($help -)1:node:__docker_complete_nodes" && ret=0 - case $state in - (filter-options) - __docker_node_complete_ps_filters && ret=0 - ;; - esac + "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \ + "($help -)*:node:__docker_complete_nodes" && ret=0 ;; (update) _arguments $(__docker_arguments) \ @@ -875,13 +1522,42 @@ __docker_node_subcommand() { # BO plugin -__docker_complete_plugins() { +__docker_plugin_complete_ls_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (capability) + opts=('authz' 'ipamdriver' 'logdriver' 'metricscollector' 'networkdriver' 'volumedriver') + _describe -t capability-opts "capability options" opts && ret=0 + ;; + (enabled) + opts=('false' 'true') + _describe -t enabled-opts "enabled options" opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('capability' 'enabled') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret +} + +__docker_plugins() { [[ $PREFIX = -* ]] && return 1 integer ret=1 local line s - declare -a lines plugins + declare -a lines plugins args - lines=(${(f)"$(_call_program commands docker $docker_options plugin ls)"}) + filter=$1; shift + [[ $filter != "none" ]] && args=("-f $filter") + + lines=(${(f)${:-"$(_call_program commands docker $docker_options plugin ls $args)"$'\n'}}) # Parse header line to find columns local i=1 j=1 k header=${lines[1]} @@ -907,6 +1583,21 @@ __docker_complete_plugins() { return ret } +__docker_complete_plugins() { + [[ $PREFIX = -* ]] && return 1 + __docker_plugins none "$@" +} + +__docker_complete_enabled_plugins() { + [[ $PREFIX = -* ]] && return 1 + __docker_plugins enabled=true "$@" +} + +__docker_complete_disabled_plugins() { + [[ $PREFIX = -* ]] && return 1 + __docker_plugins enabled=false "$@" +} + __docker_plugin_commands() { local -a _docker_plugin_subcommands _docker_plugin_subcommands=( @@ -918,6 +1609,7 @@ __docker_plugin_commands() { "push:Push a plugin" "rm:Remove a plugin" "set:Change settings for a plugin" + "upgrade:Upgrade an existing plugin" ) _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands } @@ -930,16 +1622,68 @@ __docker_plugin_subcommand() { opts_help=("(: -)--help[Print usage]") case "$words[1]" in - (disable|enable|inspect|install|ls|push|rm) + (disable) _arguments $(__docker_arguments) \ $opts_help \ + "($help -f --force)"{-f,--force}"[Force the disable of an active plugin]" \ + "($help -)1:plugin:__docker_complete_enabled_plugins" && ret=0 + ;; + (enable) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--timeout=[HTTP client timeout (in seconds)]:timeout: " \ + "($help -)1:plugin:__docker_complete_disabled_plugins" && ret=0 + ;; + (inspect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given Go template]:template: " \ + "($help -)*:plugin:__docker_complete_plugins" && ret=0 + ;; + (install) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--alias=[Local name for plugin]:alias: " \ + "($help)--disable[Do not enable the plugin on install]" \ + "($help)--disable-content-trust[Skip image verification (default true)]" \ + "($help)--grant-all-permissions[Grant all permissions necessary to run the plugin]" \ + "($help -)1:plugin:__docker_complete_plugins" \ + "($help -)*:key=value: " && ret=0 + ;; + (ls|list) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_plugin_complete_ls_filters" \ + "($help --format)--format=[Format the output using the given Go template]:template: " \ + "($help)--no-trunc[Don't truncate output]" \ + "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 + ;; + (push) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--disable-content-trust[Skip image verification (default true)]" \ "($help -)1:plugin:__docker_complete_plugins" && ret=0 ;; + (rm|remove) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --force)"{-f,--force}"[Force the removal of an active plugin]" \ + "($help -)*:plugin:__docker_complete_plugins" && ret=0 + ;; (set) _arguments $(__docker_arguments) \ $opts_help \ "($help -)1:plugin:__docker_complete_plugins" \ - "($help-)*:key=value: " && ret=0 + "($help -)*:key=value: " && ret=0 + ;; + (upgrade) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--disable-content-trust[Skip image verification (default true)]" \ + "($help)--grant-all-permissions[Grant all permissions necessary to run the plugin]" \ + "($help)--skip-remote-check[Do not check if specified remote plugin matches existing plugin image]" \ + "($help -)1:plugin:__docker_complete_plugins" \ + "($help -):remote: " && ret=0 ;; (help) _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0 @@ -951,6 +1695,108 @@ __docker_plugin_subcommand() { # 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 +} + +__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) -A '-*' \ + $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)--format=[Format the output using the given go template]:template: " \ + "($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 +} + +# EO secret + # BO service __docker_service_complete_ls_filters() { @@ -962,6 +1808,10 @@ __docker_service_complete_ls_filters() { (id) __docker_complete_services_ids && ret=0 ;; + (mode) + opts=('global' 'replicated') + _describe -t mode-opts "mode options" opts && ret=0 + ;; (name) __docker_complete_services_names && ret=0 ;; @@ -970,7 +1820,7 @@ __docker_service_complete_ls_filters() { ;; esac else - opts=('id' 'label' 'name') + opts=('id' 'label' 'mode' 'name') _describe -t filter-opts "filter options" opts -qS "=" && ret=0 fi @@ -984,7 +1834,7 @@ __docker_service_complete_ps_filters() { if compset -P '*='; then case "${${words[-1]%=*}#*=}" in (desired-state) - state_opts=('accepted' 'running') + state_opts=('accepted' 'running' 'shutdown') _describe -t state-opts "desired state options" state_opts && ret=0 ;; *) @@ -999,6 +1849,28 @@ __docker_service_complete_ps_filters() { return ret } +__docker_service_complete_placement_pref() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (spread) + opts=('engine.labels' 'node.labels') + _describe -t spread-opts "spread options" opts -qS "." && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('spread') + _describe -t pref-opts "placement pref options" opts -qS "=" && ret=0 + fi + + return ret +} + __docker_services() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -1007,7 +1879,7 @@ __docker_services() { type=$1; shift - lines=(${(f)"$(_call_program commands docker $docker_options service ls)"}) + 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]} @@ -1064,9 +1936,11 @@ __docker_service_commands() { _docker_service_subcommands=( "create:Create a new service" "inspect:Display detailed information on one or more services" + "logs:Fetch the logs of a service or task" "ls:List services" "rm:Remove one or more services" - "scale:Scale one or multiple services" + "rollback:Revert changes to a service's configuration" + "scale:Scale one or multiple replicated services" "ps:List the tasks of a service" "update:Update a service" ) @@ -1083,26 +1957,41 @@ __docker_service_subcommand() { "($help)*--constraint=[Placement constraints]:constraint: " "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" "($help)*"{-e=,--env=}"[Set environment variables]:env: " - "($help)*--group-add=[Add additional user groups to the container]:group:_groups" + "($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)--isolation=[Service container isolation mode]:isolation:(default process hyperv)" \ "($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_log_drivers" - "($help)*--log-opt=[Logging driver options]:log driver options:__docker_log_options" - "($help)*--mount=[Attach a mount to the service]:mount: " - "($help)--name=[Service name]:name: " + "($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)*"{-p=,--publish=}"[Publish a port as a node port]:port: " + "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" + "($help)--read-only[Mount the container's root filesystem as read only]" "($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)--restart-window=[Window used to evaluate the restart policy]:duration: " + "($help)--rollback-delay=[Delay between task rollbacks]:duration: " + "($help)--rollback-failure-action=[Action on rollback failure]:action:(continue pause)" + "($help)--rollback-max-failure-ratio=[Failure rate to tolerate during a rollback]:failure rate: " + "($help)--rollback-monitor=[Duration after each task rollback to monitor for failure]:duration: " + "($help)--rollback-parallelism=[Maximum number of tasks rolled back simultaneously]:number: " + "($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)--stop-signal=[Signal to stop the container]:signal:_signals" + "($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-failure-action=[Action on update failure]:mode:(continue pause rollback)" + "($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]" @@ -1115,8 +2004,15 @@ __docker_service_subcommand() { $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 -): :__docker_images" \ + "($help)--name=[Service name]:name: " \ + "($help)*--placement-pref=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \ + "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: " \ + "($help -): :__docker_complete_images" \ "($help -):command: _command_names -e" \ "($help -)*::arguments: _normal" && ret=0 ;; @@ -1127,25 +2023,41 @@ __docker_service_subcommand() { "($help)--pretty[Print the information in a human friendly format]" \ "($help -)*:service:__docker_complete_services" && ret=0 ;; + (logs) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --follow)"{-f,--follow}"[Follow log output]" \ + "($help)--no-resolve[Do not map IDs to Names]" \ + "($help)--no-task-ids[Do not include task IDs]" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help)--since=[Show logs since timestamp]:timestamp: " \ + "($help)--tail=[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \ + "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \ + "($help -)1: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)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_service_complete_ls_filters" \ + "($help)--format=[Pretty-print services using a Go template]:template: " \ "($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 ;; + (rollback) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -d --detach)"{-d=false,--detach=false}"[Disable detached mode]" \ + "($help -q --quiet)"{-q,--quiet}"[Suppress progress output]" \ + "($help -)*:service:__docker_complete_services" && ret=0 + ;; (scale) _arguments $(__docker_arguments) \ $opts_help \ + "($help -d --detach)"{-d=false,--detach=false}"[Disable detached mode]" \ "($help -)*:service:->values" && ret=0 case $state in (values) @@ -1160,16 +2072,12 @@ __docker_service_subcommand() { (ps) _arguments $(__docker_arguments) \ $opts_help \ - "($help -a --all)"{-a,--all}"[Display all tasks]" \ - "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_service_complete_ps_filters" \ + "($help)--format=[Format the output using the given go template]:template: " \ "($help)--no-resolve[Do not map IDs to Names]" \ "($help)--no-trunc[Do not truncate output]" \ - "($help -)1:service:__docker_complete_services" && ret=0 - case $state in - (filter-options) - __docker_service_complete_ps_filters && ret=0 - ;; - esac + "($help -q --quiet)"{-q,--quiet}"[Only display task IDs]" \ + "($help -)*:service:__docker_complete_services" && ret=0 ;; (update) _arguments $(__docker_arguments) \ @@ -1178,8 +2086,21 @@ __docker_service_subcommand() { "($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)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \ - "($help)--image=[Service image tag]:image:__docker_repositories" \ + "($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)*--placement-pref-add=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \ + "($help)*--placement-pref-rm=[Remove a placement preference]:pref:__docker_service_complete_placement_pref" \ + "($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) @@ -1192,6 +2113,150 @@ __docker_service_subcommand() { # 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' 'shutdown') + _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 NAME + for line in $lines; do + s="${line[${begin[NAME]},${end[NAME]}]%% ##}" + stacks=($stacks $s) + done + + _describe -t stacks-list "stacks" stacks "$@" && ret=0 + return ret +} + +__docker_complete_stacks() { + [[ $PREFIX = -* ]] && return 1 + __docker_stacks "$@" +} + +__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, or '-' to read from stdin]:compose file:_files -g \"*.(yml|yaml)\"" \ + "($help)--with-registry-auth[Send registry authentication details to Swarm agents]" \ + "($help -):stack:__docker_complete_stacks" && ret=0 + ;; + (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)--format=[Format the output using the given go template]:template: " \ + "($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 -):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)--format=[Pretty-print services using a Go template]:template: " \ + "($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 +} + +# EO stack + # BO swarm __docker_swarm_commands() { @@ -1201,6 +2266,8 @@ __docker_swarm_commands() { "join:Join a swarm as a node and/or manager" "join-token:Manage join tokens" "leave:Leave a swarm" + "unlock:Unlock swarm" + "unlock-key:Manage the unlock key" "update:Update the swarm" ) _describe -t docker-swarm-commands "docker swarm command" _docker_swarm_subcommands @@ -1217,15 +2284,28 @@ __docker_swarm_subcommand() { (init) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--advertise-addr[Advertised address]:ip\:port: " \ + "($help)--advertise-addr=[Advertised address]:ip\:port: " \ + "($help)--data-path-addr=[Data path IP or interface]:ip " \ + "($help)--data-path-port=[Data Path Port]:port " \ + "($help)--default-addr-pool=[Default address pool]" \ + "($help)--default-addr-pool-mask-length=[Default address pool subnet mask length]" \ + "($help)--autolock[Enable manager autolocking]" \ + "($help)--availability=[Availability of the node]:availability:(active drain pause)" \ + "($help)--cert-expiry=[Validity period for node certificates]:duration: " \ + "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \ "($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: " && ret=0 + "($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) \ + _arguments $(__docker_arguments) -A '-*' \ $opts_help \ - "($help)--advertise-addr[Advertised address]:ip\:port: " \ + "($help)--advertise-addr=[Advertised address]:ip\:port: " \ + "($help)--data-path-addr=[Data path IP or interface]:ip " \ + "($help)--availability=[Availability of the node]:availability:(active drain pause)" \ "($help)--listen-addr=[Listen address]:ip\:port: " \ "($help)--token=[Token for entry into the swarm]:secret: " \ "($help -):host\:port: " && ret=0 @@ -1238,14 +2318,29 @@ __docker_swarm_subcommand() { "($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 + ;; + (unlock) _arguments $(__docker_arguments) \ $opts_help && ret=0 ;; + (unlock-key) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -q --quiet)"{-q,--quiet}"[Only display token]" \ + "($help)--rotate[Rotate unlock token]" && ret=0 + ;; (update) _arguments $(__docker_arguments) \ $opts_help \ + "($help)--autolock[Enable manager autolocking]" \ "($help)--cert-expiry=[Validity period for node certificates]:duration: " \ "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \ + "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \ + "($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) @@ -1258,6 +2353,63 @@ __docker_swarm_subcommand() { # 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)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ + "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" \ + "($help)--volumes=[Remove all unused volumes]" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0 + ;; + esac + + return ret +} + +# EO system + # BO volume __docker_volume_complete_ls_filters() { @@ -1274,7 +2426,7 @@ __docker_volume_complete_ls_filters() { __docker_complete_info_plugins Volume && ret=0 ;; (name) - __docker_volumes && ret=0 + __docker_complete_volumes && ret=0 ;; *) _message 'value' && ret=0 @@ -1288,12 +2440,12 @@ __docker_volume_complete_ls_filters() { return ret } -__docker_volumes() { +__docker_complete_volumes() { [[ $PREFIX = -* ]] && return 1 integer ret=1 declare -a lines volumes - lines=(${(f)"$(_call_program commands docker $docker_options volume ls)"}) + 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]} @@ -1326,6 +2478,7 @@ __docker_volume_commands() { "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 @@ -1351,25 +2504,25 @@ __docker_volume_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ - "($help -)1:volume:__docker_volumes" && ret=0 + "($help -)1:volume:__docker_complete_volumes" && ret=0 ;; (ls) _arguments $(__docker_arguments) \ $opts_help \ - "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_volume_complete_ls_filters" \ "($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_volumes" && ret=0 + "($help -):volume:__docker_complete_volumes" && ret=0 ;; (help) _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0 @@ -1388,18 +2541,32 @@ __docker_caching_policy() { __docker_commands() { local cache_policy + integer force_invalidation=0 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; + if ( (( ! ${+_docker_hide_legacy_commands} )) || _cache_invalid docker_hide_legacy_commands ) \ + && ! _retrieve_cache docker_hide_legacy_commands; + then + _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}" + _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands + fi + + if [[ "${_docker_hide_legacy_commands}" != "${DOCKER_HIDE_LEGACY_COMMANDS}" ]]; then + force_invalidation=1 + _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}" + _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands + fi + + if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands ) \ + && ! _retrieve_cache docker_subcommands || [[ ${force_invalidation} -eq 1 ]]; then local -a lines lines=(${(f)"$(_call_program commands docker 2>&1)"}) - _docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) + _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 @@ -1407,193 +2574,87 @@ __docker_commands() { } __docker_subcommand() { - local -a _command_args opts_help opts_build_create_run opts_build_create_run_update opts_create_run opts_create_run_update + local -a _command_args opts_help local expl help="--help" integer ret=1 opts_help=("(: -)--help[Print usage]") - opts_build_create_run=( - "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " - "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" - "($help)--disable-content-trust[Skip image verification]" - "($help)*--shm-size=[Size of '/dev/shm' (format is '')]:shm size: " - "($help)*--ulimit=[ulimit options]:ulimit: " - "($help)--userns=[Container user namespace]:user namespace:(host)" - ) - opts_build_create_run_update=( - "($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)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " - "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " - "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " - "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " - ) - 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)--cidfile=[Write the container ID to the file]:CID file:_files" - "($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)*--dns=[Custom DNS servers]:DNS server: " - "($help)*--dns-opt=[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-add=[Add additional groups to run as]: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)*--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_log_drivers" - "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_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)*--sysctl=-[sysctl options]:sysctl: " - "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" - "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" - "($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)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: " - "($help)--memory-reservation=[Memory soft limit]:Memory limit: " - "($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)" - ) - opts_attach_exec_run_start=( - "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys" - ) 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_runningcontainers" && ret=0 + (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) - _arguments $(__docker_arguments) \ - $opts_help \ - $opts_build_create_run \ - $opts_build_create_run_update \ - "($help)*--build-arg[Build-time variables]:=: " \ - "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \ - "($help)--force-rm[Always remove intermediate containers]" \ - "($help)*--label=[Set metadata for an image]:label=value: " \ - "($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 -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_repositories_with_tags" \ - "($help -):path or URL:_directories" && ret=0 + (build|history|import|load|pull|push|save|tag) + __docker_image_subcommand && ret=0 ;; - (commit) + (checkpoint) + local curcontext="$curcontext" state _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_containers" \ - "($help -): :__docker_repositories_with_tags" && ret=0 - ;; - (cp) - _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 + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + case $state in - (container) - if compset -P "*:"; then - _files && ret=0 - else - __docker_containers -qS ":" && ret=0 - fi + (command) + __docker_checkpoint_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_checkpoint_subcommand && ret=0 ;; esac ;; - (create) + (container) + local curcontext="$curcontext" state _arguments $(__docker_arguments) \ $opts_help \ - $opts_build_create_run \ - $opts_build_create_run_update \ - $opts_create_run \ - $opts_create_run_update \ - "($help -): :__docker_images" \ - "($help -):command: _command_names -e" \ - "($help -)*::arguments: _normal" && ret=0 + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 case $state in - (link) - if compset -P "*:"; then - _wanted alias expl "Alias" compadd -E "" && ret=0 - else - __docker_runningcontainers -qS ":" && ret=0 - fi + (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 remote API]:CORS headers: " \ + "($help)*--allow-nondistributable-artifacts=[Push nondistributable artifacts to specified registries]:registry: " \ + "($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)--data-root=[Root directory of persisted Docker data]:path:_directories" \ "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \ "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \ - "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \ - "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \ - "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \ - "($help)*--dns=[DNS server to use]:DNS: " \ - "($help)*--dns-search=[DNS search domains to use]:DNS search: " \ - "($help)*--dns-opt=[DNS options to use]:DNS option: " \ + "($help)--default-shm-size=[Default shm size for containers]:size:" \ "($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[Run an init inside containers to forward signals and reap processes]" \ + "($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]" \ @@ -1603,8 +2664,8 @@ __docker_subcommand() { "($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_log_drivers" \ - "($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_log_options" \ + "($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)" \ @@ -1612,8 +2673,10 @@ __docker_subcommand() { "($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)\"" \ @@ -1621,7 +2684,8 @@ __docker_subcommand() { "($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]" && ret=0 + "($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) @@ -1650,83 +2714,29 @@ __docker_subcommand() { ;; esac ;; - (diff) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -)*:containers:__docker_containers" && ret=0 + (events|info) + __docker_system_subcommand && ret=0 ;; - (events) + (image) + local curcontext="$curcontext" state _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 - ;; - (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 -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_runningcontainers" \ - "($help -)*::command:->anycommand" && ret=0 + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 case $state in - (anycommand) - shift 1 words - (( CURRENT-- )) - _normal && ret=0 + (command) + __docker_image_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_image_subcommand && 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_containers" && 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_images" && ret=0 - ;; (images) - _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_repositories" && ret=0 - - case $state in - (filter-options) - __docker_complete_images_filters && ret=0 - ;; - esac - ;; - (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_repositories_with_tags" && ret=0 - ;; - (info|version) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0 + words[1]='ls' + __docker_image_subcommand && ret=0 ;; (inspect) local state @@ -1734,55 +2744,53 @@ __docker_subcommand() { $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:(image 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_containers && ret=0 + __docker_complete_containers && ret=0 elif [[ ${words[(r)--type=image]} == --type=image ]]; then - __docker_images && ret=0 + __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=secrets ]]; then + __docker_complete_secrets && 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_images && __docker_containers && ret=0 + __docker_complete_containers + __docker_complete_images + __docker_complete_networks + __docker_complete_nodes + __docker_complete_plugins + __docker_complete_secrets + __docker_complete_services + __docker_complete_volumes && ret=0 fi ;; esac ;; - (kill) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \ - "($help -)*:containers:__docker_runningcontainers" && 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 - ;; (login) - _arguments $(__docker_arguments) \ + _arguments $(__docker_arguments) -A '-*' \ $opts_help \ "($help -p --password)"{-p=,--password=}"[Password]:password: " \ + "($help)--password-stdin[Read password from stdin]" \ "($help -u --user)"{-u=,--user=}"[Username]:username: " \ "($help -)1:server: " && ret=0 ;; (logout) - _arguments $(__docker_arguments) \ + _arguments $(__docker_arguments) -A '-*' \ $opts_help \ "($help -)1:server: " && 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_containers" && ret=0 - ;; (network) local curcontext="$curcontext" state _arguments $(__docker_arguments) \ @@ -1817,11 +2825,6 @@ __docker_subcommand() { ;; esac ;; - (pause|unpause) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -)*:containers:__docker_runningcontainers" && ret=0 - ;; (plugin) local curcontext="$curcontext" state _arguments $(__docker_arguments) \ @@ -1839,134 +2842,36 @@ __docker_subcommand() { ;; esac ;; - (port) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -)1:containers:__docker_runningcontainers" \ - "($help -)2:port:_ports" && ret=0 - ;; (ps) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -a --all)"{-a,--all}"[Show all containers]" \ - "($help)--before=[Show only container created before...]:containers:__docker_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_containers" && 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_images" && ret=0 - ;; - (rename) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -):old name:__docker_containers" \ - "($help -):new name: " && ret=0 - ;; - (restart|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_runningcontainers" && ret=0 - ;; - (rm) - _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_containers && ret=0 - else - __docker_stoppedcontainers && ret=0 - fi - ;; - esac + words[1]='ls' + __docker_container_subcommand && ret=0 ;; (rmi) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -f --force)"{-f,--force}"[Force removal]" \ - "($help)--no-prune[Do not delete untagged parents]" \ - "($help -)*: :__docker_images" && ret=0 - ;; - (run) - _arguments $(__docker_arguments) \ - $opts_help \ - $opts_build_create_run \ - $opts_build_create_run_update \ - $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_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_runningcontainers -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 - - ;; - (save) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -o --output)"{-o=,--output=}"[Write to file]:file:_files" \ - "($help -)*: :__docker_images" && ret=0 + words[1]='rm' + __docker_image_subcommand && ret=0 ;; (search) - _arguments $(__docker_arguments) \ + _arguments $(__docker_arguments) -A '-*' \ $opts_help \ - "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ + "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_search_filters" \ "($help)--limit=[Maximum returned search results]:limit:(1 5 10 25 50)" \ "($help)--no-trunc[Do not truncate output]" \ "($help -):term: " && ret=0 + ;; + (secret) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 case $state in - (filter-options) - __docker_complete_search_filters && ret=0 + (command) + __docker_secret_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_secret_subcommand && ret=0 ;; esac ;; @@ -1987,20 +2892,22 @@ __docker_subcommand() { ;; esac ;; - (start) + (stack) + local curcontext="$curcontext" state _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_stoppedcontainers" && ret=0 - ;; - (stats) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ - "($help)--no-stream[Disable streaming stats and only pull the first result]" \ - "($help -)*:containers:__docker_runningcontainers" && ret=0 + "($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 @@ -2019,41 +2926,28 @@ __docker_subcommand() { ;; esac ;; - (tag) + (system) + local curcontext="$curcontext" state _arguments $(__docker_arguments) \ $opts_help \ - "($help -):source:__docker_images"\ - "($help -):destination:__docker_repositories_with_tags" && ret=0 - ;; - (top) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -)1:containers:__docker_runningcontainers" \ - "($help -)*:: :->ps-arguments" && ret=0 - case $state in - (ps-arguments) - _ps && ret=0 - ;; - esac - - ;; - (update) - _arguments $(__docker_arguments) \ - $opts_help \ - $opts_create_run_update \ - $opts_build_create_run_update \ - "($help -)*: :->values" && ret=0 + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 case $state in - (values) - if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then - __docker_stoppedcontainers && ret=0 - else - __docker_containers && ret=0 - fi + (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) \ @@ -2071,11 +2965,6 @@ __docker_subcommand() { ;; esac ;; - (wait) - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -)*:containers:__docker_runningcontainers" && ret=0 - ;; (help) _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0 ;; diff --git a/plugins/doctl/README.md b/plugins/doctl/README.md new file mode 100644 index 000000000..a81e90b0a --- /dev/null +++ b/plugins/doctl/README.md @@ -0,0 +1,9 @@ +# Doctl + +This plugin provides completion for [Doctl](https://github.com/digitalocean/doctl). + +To use it add doctl to the plugins array in your zshrc file. + +```bash +plugins=(... doctl) +``` diff --git a/plugins/doctl/doctl.plugin.zsh b/plugins/doctl/doctl.plugin.zsh new file mode 100644 index 000000000..d23ed085c --- /dev/null +++ b/plugins/doctl/doctl.plugin.zsh @@ -0,0 +1,9 @@ +# Autocompletion for doctl, the command line tool for DigitalOcean service +# +# doctl project: https://github.com/digitalocean/doctl +# +# Author: https://github.com/HalisCz + +if [ $commands[doctl] ]; then + source <(doctl completion zsh) +fi diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md new file mode 100644 index 000000000..cac552485 --- /dev/null +++ b/plugins/dotenv/README.md @@ -0,0 +1,56 @@ +# 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](https://www.12factor.net). Anything that is likely to change between deployment environments, such as resource handles for databases or credentials for external services, should be extracted from the code into environment variables. + +## Installation + +Just add the plugin to your `.zshrc`: + +```sh +plugins=(... dotenv) +``` + +## Usage + +Create `.env` file inside your project root directory and put your ENV variables there. + +For example: +```sh +export AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a +export SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f +export MONGO_URI=mongodb://127.0.0.1:27017 +export PORT=3001 +``` +`export` is optional. This format works as well: +```sh +AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a +SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f +MONGO_URI=mongodb://127.0.0.1:27017 +PORT=3001 +``` +You can even mix both formats, although it's probably a bad idea. + +### ZSH_DOTENV_FILE + +You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`. +If the variable isn't set, the plugin will default to use `.env`. +For example, this will make the plugin look for files named `.dotenv` and load them: + +``` +# in ~/.zshrc, before Oh My Zsh is sourced: +ZSH_DOTENV_FILE=.dotenv +``` + +## Version Control + +**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only. + +## Disclaimer + +This plugin only sources the `.env` file. Nothing less, nothing more. It doesn't do any checks. It's designed to be the fastest and simplest option. You're responsible for the `.env` file content. You can put some code (or weird symbols) there, but do it on your own risk. `dotenv` is the basic tool, yet it does the job. + +If you need more advanced and feature-rich ENV management, check out these awesome projects: +* [direnv](https://github.com/direnv/direnv) +* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh new file mode 100644 index 000000000..89763d0ee --- /dev/null +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -0,0 +1,23 @@ +source_env() { + if [[ -f $ZSH_DOTENV_FILE ]]; then + # test .env syntax + zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + + if [[ -o a ]]; then + source $ZSH_DOTENV_FILE + else + set -a + source $ZSH_DOTENV_FILE + set +a + fi + fi +} + +autoload -U add-zsh-hook +add-zsh-hook chpwd source_env + +if [[ -z $ZSH_DOTENV_FILE ]]; then + ZSH_DOTENV_FILE=.env +fi + +source_env diff --git a/plugins/droplr/README.md b/plugins/droplr/README.md index cfbec25ed..6daa2540d 100644 --- a/plugins/droplr/README.md +++ b/plugins/droplr/README.md @@ -1,6 +1,6 @@ # droplr -Use [Droplr](https://droplr.com/) from the comand line to upload files and shorten +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. @@ -16,4 +16,4 @@ Author: [Fabio Fernandes](https://github.com/fabiofl) - Upload a file: `droplr ./path/to/file/` -- Shorten a link: `droplr http://example.com` +- Shorten a link: `droplr https://example.com` diff --git a/plugins/droplr/droplr.plugin.zsh b/plugins/droplr/droplr.plugin.zsh index 296a8b98b..af0a21299 100644 --- a/plugins/droplr/droplr.plugin.zsh +++ b/plugins/droplr/droplr.plugin.zsh @@ -7,8 +7,8 @@ droplr() { return 1 fi - if [[ "$1" =~ ^http[|s]:// ]]; then - osascript -e "tell app 'Droplr' to shorten '$1'" + if [[ "$1" =~ ^https?:// ]]; then + osascript -e 'tell app "Droplr" to shorten "'"$1"'"' else open -ga /Applications/Droplr.app "$1" fi diff --git a/plugins/drush/README.md b/plugins/drush/README.md new file mode 100644 index 000000000..df7b82bdd --- /dev/null +++ b/plugins/drush/README.md @@ -0,0 +1,83 @@ +# Drush + +## Description +This plugin offers aliases and functions to make the work with drush easier and more productive. + +To enable it, add the `drush` to your `plugins` array in `~/.zshrc`: + +``` +plugins=(... drush) +``` + +## Aliases +| Alias | Description | Command | +|-------|-----------------------------------------------------------------------|-----------------------------| +| dr | Display drush help | drush | +| drca | Clear all drupal caches. | drush cc all | +| drcb | Clear block cache. | drush cc block | +| drcg | Clear registry cache. | drush cc registry | +| drcj | Clear css-js cache. | drush cc css-js | +| drcm | Clear menu cache. | drush cc menu | +| drcml | Clear module-list cache. | drush cc module-list | +| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron | +| drct | Clear theme-registry cache. | drush cc theme-registry | +| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views | +| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql| +| drf | Display features status | drush features | +| drfr | Revert a feature module on your site. | drush features-revert -y | +| drfu | Update a feature module on your site. | drush features-update -y | +| drfra | Revert all enabled feature module on your site. | drush features-revert-all | +| drif | Flush all derived images. | drush image-flush --all | +| drpm | Show a list of available modules. | drush pm-list --type=module | +| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status | +| drup | Apply any database updates required (as with running update.php). | drush updatedb | +| drups | List any pending database updates. | drush updatedb-status | +| drv | Show drush version. | drush version | +| drvd | Delete a variable. | drush variable-del | +| drvg | Get a list of some or all site variables and values. | drush variable-get | +| drvs | Set a variable. | drush variable-set | + +## Functions + +### dren +Download and enable one or more extensions (modules or themes). +Must be invoked with one or more parameters. e.g.: +`dren devel` or `dren devel module_filter views` + +### drf +Edit drushrc, site alias, and Drupal settings.php files. +Can be invoked with one or without parameters. e.g.: +`drf 1` + +### dris +Disable one or more extensions (modules or themes) +Must be invoked with one or more parameters. e.g.: +`dris devel` or `dris devel module_filter views` + +### drpu +Uninstall one or more modules. +Must be invoked with one or more parameters. e.g.: +`drpu devel` or `drpu devel module_filter views` + +### drnew +Creates a brand new drupal website. +Note: As soon as the installation is complete, drush will print a username and a random password into the terminal: +``` +Installation complete. User name: admin User password: cf7t8yqNEm +``` + +## Additional features + +### Autocomplete +The [completion script for drush](https://github.com/drush-ops/drush/blob/8.0.1/drush.complete.sh) comes enabled with this plugin. +So, it is possible to type a command: +``` +drush sql +``` + +And as soon as the tab key is pressed, the script will display the available commands: +``` +drush sql +sqlc sql-conf sql-create sql-dump sql-query sql-sanitize +sql-cli sql-connect sql-drop sqlq sqlsan sql-sync +``` diff --git a/plugins/drush/drush.complete.sh b/plugins/drush/drush.complete.sh new file mode 100644 index 000000000..38b882ec3 --- /dev/null +++ b/plugins/drush/drush.complete.sh @@ -0,0 +1,50 @@ +# BASH completion script for Drush. +# +# Place this in your /etc/bash_completion.d/ directory or source it from your +# ~/.bash_completion or ~/.bash_profile files. Alternatively, source +# examples/example.bashrc instead, as it will automatically find and source +# this file. +# +# If you're using ZSH instead of BASH, add the following to your ~/.zshrc file +# and source it. +# +# autoload bashcompinit +# bashcompinit +# source /path/to/your/drush.complete.sh + +# Ensure drush is available. +which drush > /dev/null || alias drush &> /dev/null || return + +__drush_ps1() { + f="${TMPDIR:-/tmp/}/drush-env-${USER}/drush-drupal-site-$$" + if [ -f $f ] + then + __DRUPAL_SITE=$(cat "$f") + else + __DRUPAL_SITE="$DRUPAL_SITE" + fi + + # Set DRUSH_PS1_SHOWCOLORHINTS to a non-empty value and define a + # __drush_ps1_colorize_alias() function for color hints in your Drush PS1 + # prompt. See example.prompt.sh for an example implementation. + if [ -n "${__DRUPAL_SITE-}" ] && [ -n "${DRUSH_PS1_SHOWCOLORHINTS-}" ]; then + __drush_ps1_colorize_alias + fi + + [[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE" +} + +# Completion function, uses the "drush complete" command to retrieve +# completions for a specific command line COMP_WORDS. +_drush_completion() { + # Set IFS to newline (locally), since we only use newline separators, and + # need to retain spaces (or not) after completions. + local IFS=$'\n' + # The '< /dev/null' is a work around for a bug in php libedit stdin handling. + # Note that libedit in place of libreadline in some distributions. See: + # https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214 + COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) ) +} + +# Register our completion function. We include common short aliases for Drush. +complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush7 drush8 drush.php diff --git a/plugins/drush/drush.plugin.zsh b/plugins/drush/drush.plugin.zsh new file mode 100644 index 000000000..8a20d79f2 --- /dev/null +++ b/plugins/drush/drush.plugin.zsh @@ -0,0 +1,104 @@ +# Drush support. + +function dren() { + drush en $@ -y +} + +function dris() { + drush pm-disable $@ -y +} + +function drpu() { + drush pm-uninstall $@ -y +} + +function drf() { + if [[ $1 == "" ]] then + drush core-config + else + drush core-config --choice=$1 + fi +} + +function drfi() { + if [[ $1 == "fields" ]]; then + drush field-info fields + elif [[ $1 == "types" ]]; then + drush field-info types + else + drush field-info + fi +} + +function drnew() { + + cd ~ + echo "Website's name: " + read WEBSITE_NAME + + HOST=http://$(hostname -i)/ + + if [[ $WEBSITE_NAME == "" ]] then + MINUTES=$(date +%M:%S) + WEBSITE_NAME="Drupal-$MINUTES" + echo "Your website will be named: $WEBSITE_NAME" + fi + + drush dl drupal --drupal-project-rename=$WEBSITE_NAME + + echo "Type your localhost directory: (Leave empty for /var/www/html/)" + read DIRECTORY + + if [[ $DIRECTORY == "" ]] then + DIRECTORY="/var/www/html/" + fi + + echo "Moving to $DIRECTORY$WEBSITE_NAME" + sudo mv $WEBSITE_NAME $DIRECTORY + cd $DIRECTORY$WEBSITE_NAME + + echo "Database's user: " + read DATABASE_USR + echo "Database's password: " + read -s DATABASE_PWD + echo "Database's name for your project: " + read DATABASE + + DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE" + drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME + + open_command $HOST$WEBSITE_NAME + echo "Done" + +} + +# Aliases, sorted alphabetically. +alias dr="drush" +alias drca="drush cc all" # Deprecated for Drush 8 +alias drcb="drush cc block" # Deprecated for Drush 8 +alias drcg="drush cc registry" # Deprecated for Drush 8 +alias drcj="drush cc css-js" +alias drcm="drush cc menu" +alias drcml="drush cc module-list" +alias drcr="drush core-cron" +alias drct="drush cc theme-registry" +alias drcv="drush cc views" +alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql" +alias drf="drush features" +alias drfr="drush features-revert -y" +alias drfu="drush features-update -y" +alias drfra="drush features-revert-all" +alias drif="drush image-flush --all" +alias drpm="drush pm-list --type=module" +alias drst="drush core-status" +alias drup="drush updatedb" +alias drups="drush updatedb-status" +alias drv="drush version" +alias drvd="drush variable-del" +alias drvg="drush variable-get" +alias drvs="drush variable-set" + +# Enable drush autocomplete support +autoload bashcompinit +bashcompinit +source $(dirname $0)/drush.complete.sh diff --git a/plugins/eecms/README.md b/plugins/eecms/README.md new file mode 100644 index 000000000..c53835521 --- /dev/null +++ b/plugins/eecms/README.md @@ -0,0 +1,11 @@ +# eecms plugin + +This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine). + +To use it, add `eecms` to the plugins array of your `.zshrc` file: +``` +plugins=(... eecms) +``` + +It also adds the alias `eecms` which finds the eecms file in the current project +and runs it with php. diff --git a/plugins/eecms/eecms.plugin.zsh b/plugins/eecms/eecms.plugin.zsh new file mode 100644 index 000000000..ee10fbb7e --- /dev/null +++ b/plugins/eecms/eecms.plugin.zsh @@ -0,0 +1,20 @@ +# ExpressionEngine CMS basic command completion + +_eecms_console () { + echo "php $(find . -maxdepth 3 -mindepth 1 -name 'eecms' -type f | head -n 1)" +} + +_eecms_get_command_list () { + `_eecms_console` | sed "/Available commands/,/^/d" | sed "s/[[:space:]].*//g" +} + +_eecms () { + compadd `_eecms_get_command_list` +} + +compdef _eecms '`_eecms_console`' +compdef _eecms 'system/ee/eecms' +compdef _eecms eecms + +#Alias +alias eecms='`_eecms_console`' diff --git a/plugins/emacs/README.md b/plugins/emacs/README.md new file mode 100644 index 000000000..c8e33b5ab --- /dev/null +++ b/plugins/emacs/README.md @@ -0,0 +1,30 @@ +# Emacs plugin + +This plugin utilizes the Emacs daemon capability, allowing the user to quickly open frames, whether they are opened in a terminal via a ssh connection, or X frames opened on the same host. The plugin also provides some aliases for such operations. + +- You don't have the cost of starting Emacs all the time anymore +- Opening a file is as fast as Emacs does not have anything else to do. +- You can share opened buffered across opened frames. +- Configuration changes made at runtime are applied to all frames. + +**NOTE:** requires Emacs 24 and newer. + +To use it, add emacs to the plugins array in your zshrc file: + +```zsh +plugins=(... emacs) +``` + +## Aliases + +The plugin uses a custom launcher (which we'll call here `$EMACS_LAUNCHER`) that is just a wrapper around [`emacsclient`](https://www.emacswiki.org/emacs/EmacsClient). + +| Alias | Command | Description | +|--------|----------------------------------------------------|----------------------------------------------------------------| +| emacs | `$EMACS_LAUNCHER --no-wait` | Opens a temporary emacsclient frame | +| e | `emacs` | Same as emacs alias | +| te | `$EMACS_LAUNCHER -nw` | Open terminal emacsclient | +| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs | +| eframe | `emacsclient --alternate-editor "" --create-frame` | Create new X frame | +| efile | - | Print the path to the file open in the current buffer | +| ecd | - | Print the directory of the file open in the the current buffer | diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index c102a5a1e..db0ab13af 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 24 2>/dev/null ; then +if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" # set EDITOR if not already defined. diff --git a/plugins/ember-cli/README.md b/plugins/ember-cli/README.md index 1f92bba32..b46373619 100644 --- a/plugins/ember-cli/README.md +++ b/plugins/ember-cli/README.md @@ -1,8 +1,8 @@ # Ember CLI -**Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa) +**Maintainers:** [BilalBudhani](https://github.com/BilalBudhani), [eubenesa](https://github.com/eubenesa), [scottkidder](https://github.com/scottkidder] -Ember CLI (http://www.ember-cli.com/) +Ember CLI (https://www.ember-cli.com/) ### List of Aliases @@ -17,5 +17,6 @@ Alias | Ember-CLI command **ein** | *ember init* **ei** | *ember install* **et** | *ember test* +**ets** | *ember test --serve* **eu** | *ember update* **ev** | *ember version* diff --git a/plugins/ember-cli/ember-cli.plugin.zsh b/plugins/ember-cli/ember-cli.plugin.zsh index a0f346829..67842c120 100644 --- a/plugins/ember-cli/ember-cli.plugin.zsh +++ b/plugins/ember-cli/ember-cli.plugin.zsh @@ -1,5 +1,5 @@ # Ember CLI -# Visit http://www.ember-cli.com/ to view user guide +# Visit https://www.ember-cli.com/ to view user guide alias es='ember serve' alias ea='ember addon' @@ -10,6 +10,7 @@ alias eh='ember help' alias ein='ember init' alias ei='ember install' alias et='ember test' +alias ets='ember test --serve' alias eu='ember update' # version diff --git a/plugins/emoji-clock/README.md b/plugins/emoji-clock/README.md new file mode 100644 index 000000000..4934f380b --- /dev/null +++ b/plugins/emoji-clock/README.md @@ -0,0 +1,14 @@ +# emoji-clock + +The plugin displays current time as an emoji symbol with half hour accuracy. + +To use it, add `emoji-clock` to the plugins array of your zshrc file: +``` +plugins=(... emoji-clock) +``` + +## Features + +| Function | Description | +|-------------------|----------------------------------------------------------------------| +| `emoji-clock` | Displays current time in clock emoji symbol with half hour accuracy | diff --git a/plugins/emoji/README.md b/plugins/emoji/README.md index 889e567e6..8b8860a86 100644 --- a/plugins/emoji/README.md +++ b/plugins/emoji/README.md @@ -71,7 +71,7 @@ PROMPT="$surfer > " ## Technical Details -The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at http://www.unicode.org/reports/tr51/index.html. +The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at https://www.unicode.org/reports/tr51/index.html. The group definitions are added by this OMZ plugin. They are not based on external definitions. (As far as I can tell. -apjanke) @@ -108,7 +108,7 @@ The `$emoji_skintone` associative array maps skin tone IDs to the variation sele echo "$emoji[smiling_face_with_open_mouth]$emoji_skintone[4]" ``` -Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](http://www.unicode.org/reports/tr51/index.html#Diversity) for details. +Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](https://www.unicode.org/reports/tr51/index.html#Diversity) for details. ## TODO @@ -130,6 +130,6 @@ This does *not* mean that it should use Gemoji at run time. None of the `zsh` pl #### ZWJ combining function -One of the newer features of Unicode emoji is the ability to use the "Zero-Width Joiner" character to compose multiple emoji characters in to a single "emoji ligature" glyph. For example, this is [how Apple supports "family" emoji with various genders and skin tones](http://www.unicode.org/reports/tr51/index.html#ZWJ_Sequences). +One of the newer features of Unicode emoji is the ability to use the "Zero-Width Joiner" character to compose multiple emoji characters in to a single "emoji ligature" glyph. For example, this is [how Apple supports "family" emoji with various genders and skin tones](https://www.unicode.org/reports/tr51/index.html#ZWJ_Sequences). These are a pain to write out (and probably worse to read), and it might be convenient to have a couple functions for concisely composing them, if wider support for them appears. diff --git a/plugins/emoji/emoji-data.txt b/plugins/emoji/emoji-data.txt index 7b4c015f7..2d6d64e2b 100644 --- a/plugins/emoji/emoji-data.txt +++ b/plugins/emoji/emoji-data.txt @@ -17,7 +17,7 @@ # none: not applicable # Field 4 — Emoji_Sources: # one or more values from {z, a, j, w, x} -# see the key in http://www.unicode.org/draft/reports/tr51/tr51.html#Major_Sources +# see the key in https://www.unicode.org/draft/reports/tr51/tr51.html#Major_Sources # NA: not applicable # Comment — currently contains the version where the character was first encoded, # followed by: @@ -1200,7 +1200,7 @@ 1F1F2 1F1ED ; emoji ; L2 ; none ; x # V6.0 (🇲🇭) flag for Marshall Islands 1F1F2 1F1F0 ; emoji ; L2 ; none ; x # V6.0 (🇲🇰) flag for Macedonia 1F1F2 1F1F1 ; emoji ; L2 ; none ; x # V6.0 (🇲🇱) flag for Mali -1F1F2 1F1F2 ; emoji ; L2 ; none ; x # V6.0 (🇲🇲) flag for Myanmar +1F1F2 1F1F2 ; emoji ; L2 ; none ; x # V6.0 (🇲🇲) flag for Myanmar 1F1F2 1F1F3 ; emoji ; L2 ; none ; x # V6.0 (🇲🇳) flag for Mongolia 1F1F2 1F1F4 ; emoji ; L2 ; none ; x # V6.0 (🇲🇴) flag for Macau 1F1F2 1F1F5 ; emoji ; L2 ; none ; x # V6.0 (🇲🇵) flag for Northern Mariana Islands diff --git a/plugins/emoji/update_emoji.pl b/plugins/emoji/update_emoji.pl index 04f3ce8e7..8034052b7 100644 --- a/plugins/emoji/update_emoji.pl +++ b/plugins/emoji/update_emoji.pl @@ -5,15 +5,15 @@ # This script generates the emoji.plugin.zsh emoji definitions from the Unicode # character data for the emoji characters. # -# The data file can be found at http://unicode.org/Public/emoji/latest/emoji-data.txt -# as referenced in Unicode TR51 (http://www.unicode.org/reports/tr51/index.html). +# The data file can be found at https://unicode.org/Public/emoji/latest/emoji-data.txt +# as referenced in Unicode TR51 (https://www.unicode.org/reports/tr51/index.html). # # This is known to work with the data file from version 1.0. It may not work with later # versions if the format changes. In particular, this reads line comments to get the # emoji character name and unicode version. # # Country names have punctuation and other non-letter characters removed from their name, -# to avoid possible complications with having to escape the strings when using them as +# to avoid possible complications with having to escape the strings when using them as # array subscripts. The definition file seems to use some combining characters like accents # that get stripped during this process. @@ -41,7 +41,7 @@ sub process_emoji_data_file { # # This contains the definition for: # \$emoji - which maps character names to Unicode characters -# \$emoji_flags - maps country names to Unicode flag characters using region indicators +# \$emoji_flags - maps country names to Unicode flag characters using region indicators # Main emoji typeset -gAH emoji @@ -63,7 +63,7 @@ typeset -gAH emoji_mod next if /^\s*#/ or /^\s*$/; if (/^(\S.*?\S)\s*;\s*(\w+)\s*;\s*(\w+)\s*;\s*(\w+)\s*;\s*(\w.*?)\s*#\s*V(\S+)\s\(.*?\)\s*(\w.*\S)\s*$/) { - my ($code, $style, $level, $modifier_status, $sources, $version, $keycap_name) + my ($code, $style, $level, $modifier_status, $sources, $version, $keycap_name) = ($1, $2, $3, $4, $5, $6, $7); #print "code=$code style=$style level=$level modifier_status=$modifier_status sources=$sources version=$version name=$keycap_name\n"; my @code_points = split /\s+/, $code; @@ -84,7 +84,7 @@ typeset -gAH emoji_mod if ($flag_country) { $outfh->print("emoji_flags[$zsh_flag_country]=\$'$zsh_code'\n"); } else { - $outfh->print("emoji[$omz_name]=\$'$zsh_code'\n"); + $outfh->print("emoji[$omz_name]=\$'$zsh_code'\n"); } # Modifiers are included in both the main set and their separate map, # because they have a standalone representation as a color swatch. diff --git a/plugins/emotty/README.md b/plugins/emotty/README.md new file mode 100644 index 000000000..2cfbe120c --- /dev/null +++ b/plugins/emotty/README.md @@ -0,0 +1,39 @@ +# emotty plugin + +This plugin returns an emoji for the current $TTY number so it can be used +in a prompt. + +To use it, add emotty to the plugins array in your zshrc file: +``` +plugins=(... emotty) +``` + +**NOTE:** it requires the [emoji plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/emoji). + +## Usage + +The function `emotty` displays an emoji from the current character set (default: `emoji`), based +on the number associated to the `$TTY`. + +There are different sets of emoji characters available, to choose a different +set, set `$emotty_set` to the name of the set you would like to use, e.g.: +``` +emotty_set=nature +``` + +### Character Sets + +- emoji +- loral +- love +- nature +- stellar +- zodiac + +Use the `display_emotty` function to list the emojis in the current character set, or +the character set passed as the first argument. For example: + +``` +$ display_emotty zodiac + +``` diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh index b32dd1a4c..e288b5cfb 100644 --- a/plugins/emotty/emotty.plugin.zsh +++ b/plugins/emotty/emotty.plugin.zsh @@ -25,14 +25,21 @@ emotty_default_set=emoji function emotty() { # Use emotty set defined by user, fallback to default local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]} - # Parse $TTY number, normalizing it to an emotty set index - (( tty = (${TTY##/dev/ttys} % ${#${=emotty}}) + 1 )) + + # Parse tty number via prompt expansion. %l equals: + # - N if tty = /dev/ttyN + # - pts/N if tty = /dev/pts/N + local tty = ${${(%):-%l}##pts/} + # Normalize it to an emotty set index + (( tty = (tty % ${#${=emotty}}) + 1 )) + local character_name=${${=emotty}[tty]} echo "${emoji[${character_name}]}${emoji2[emoji_style]}" } function display_emotty() { - local name=$1 + local name=${1:-$emotty_set} + echo $name for i in ${=_emotty_sets[$name]}; do printf "${emoji[$i]}${emoji2[emoji_style]} " done diff --git a/plugins/encode64/README.md b/plugins/encode64/README.md new file mode 100644 index 000000000..9850da85f --- /dev/null +++ b/plugins/encode64/README.md @@ -0,0 +1,69 @@ +# encode64 + +Alias plugin for encoding or decoding using `base64` command + +## Functions and Aliases + +| Function | Alias | Description | +| ---------- | ----- | ------------------------------ | +| `encode64` | `e64` | Encodes given data to base64 | +| `decode64` | `d64` | Decodes given data from base64 | + +## Enabling plugin + +1. Edit your `.zshrc` file and add `encode64` to the list of plugins: + + ```sh + plugins=( + # ...other enabled plugins + encode64 + ) + ``` + +2. Restart your terminal session or reload configuration by running: + + ```sh + source ~/.zshrc + ``` + +## Usage and examples + +### Encoding + +- From parameter + + ```console + $ encode64 "oh-my-zsh" + b2gtbXktenNo + $ e64 "oh-my-zsh" + b2gtbXktenNo + ``` + +- From piping + + ```console + $ echo "oh-my-zsh" | encode64 + b2gtbXktenNo== + $ echo "oh-my-zsh" | e64 + b2gtbXktenNo== + ``` + +### Decoding + +- From parameter + + ```console + $ decode64 b2gtbXktenNo + oh-my-zsh% + $ d64 b2gtbXktenNo + oh-my-zsh% + ``` + +- From piping + + ```console + $ echo "b2gtbXktenNoCg==" | decode64 + oh-my-zsh + $ echo "b2gtbXktenNoCg==" | decode64 + oh-my-zsh + ``` diff --git a/plugins/extract/README.md b/plugins/extract/README.md new file mode 100644 index 000000000..83b878c32 --- /dev/null +++ b/plugins/extract/README.md @@ -0,0 +1,47 @@ +# 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 ` 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 | +| `aar` | Android library 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..33d49fcc5 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|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \ + && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 5d0809e9a..5e9b9ff24 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 -# ------------------------------------------------------------------------------ - - -function extract() { - local remove_archive - local success - local file_name - local extract_dir - - if (( $# == 0 )); then - echo "Usage: extract [-option] [file ...]" - echo - echo Options: - echo " -r, --remove Remove archive." - echo - echo "Report bugs to ." - 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 - - 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 = $success > 0 ? $success : $? )) - (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" - shift - done -} - alias x=extract +extract() { + local remove_archive + local success + local extract_dir + + if (( $# == 0 )); then + cat <<-'EOF' >&2 + Usage: extract [-option] [file ...] + + Options: + -r, --remove Remove archive after unpacking. + EOF + 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" >&2 + shift + continue + fi + + success=0 + extract_dir="${1:t:r}" + case "${1:l}" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$1" \ + || xzcat "$1" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$1" \ + || lzcat "$1" | tar xvf - ;; + (*.tar) 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|*.aar|*.whl) 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 +} diff --git a/plugins/fabric/README.md b/plugins/fabric/README.md new file mode 100644 index 000000000..cf0fa81f4 --- /dev/null +++ b/plugins/fabric/README.md @@ -0,0 +1,9 @@ +# Fabric + +This plugin provides completion for [Fabric](https://www.fabfile.org/). + +To use it add fabric to the plugins array in your zshrc file. + +```bash +plugins=(... fabric) +``` diff --git a/plugins/fabric/fabric.plugin.zsh b/plugins/fabric/fabric.plugin.zsh index aca411329..e69de29bb 100644 --- a/plugins/fabric/fabric.plugin.zsh +++ b/plugins/fabric/fabric.plugin.zsh @@ -1 +0,0 @@ -# DECLARION: This plugin was created by vhbit. What I did is just making a portal from https://github.com/vhbit/fabric-zsh-autocomplete. diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md index a7670fa2c..f1b1dfa5c 100644 --- a/plugins/fancy-ctrl-z/README.md +++ b/plugins/fancy-ctrl-z/README.md @@ -1,10 +1,10 @@ # Use Ctrl-Z to switch back to Vim -I frequently need to execute random command in my shell. To achieve it I pause +I frequently need to execute random commands in my shell. To achieve it I pause Vim by pressing Ctrl-z, type command and press fg to switch back to Vim. -The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back +The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back to Vim. I could not find a solution, so I developed one on my own that -works wonderfully with ZSH +works wonderfully with ZSH. Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ diff --git a/plugins/fasd/fasd.plugin.zsh b/plugins/fasd/fasd.plugin.zsh index 2c302f74d..ec2e5183a 100644 --- a/plugins/fasd/fasd.plugin.zsh +++ b/plugins/fasd/fasd.plugin.zsh @@ -6,6 +6,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed source "$fasd_cache" unset fasd_cache - alias v="f -e $EDITOR" - alias o='a -e open_command' + alias v='f -e "$EDITOR"' + alias o='a -e xdg-open' + alias j='zz' fi diff --git a/plugins/fbterm/README.md b/plugins/fbterm/README.md new file mode 100644 index 000000000..eec33d7ee --- /dev/null +++ b/plugins/fbterm/README.md @@ -0,0 +1,9 @@ +# fbterm + +This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm) +if on a real TTY (`/dev/tty*`). + +To use it, add fbterm to the plugins array of your zshrc file: +``` +plugins=(... fbterm) +``` diff --git a/plugins/fd/README.md b/plugins/fd/README.md new file mode 100644 index 000000000..aabd624b8 --- /dev/null +++ b/plugins/fd/README.md @@ -0,0 +1,13 @@ +# fd + +This plugin adds completion for the file search tool [`fd`](https://github.com/sharkdp/fd), also known as `fd-find`. + +To use it, add `fd` to the plugins array in your zshrc file: + +```zsh +plugins=(... fd) +``` + +Completion is taken from the fd release [`7.3.0`](https://github.com/sharkdp/fd/releases/tag/v7.3.0). + +Updated on Febrary 13th, 2019. diff --git a/plugins/fd/_fd b/plugins/fd/_fd new file mode 100644 index 000000000..7a4c38753 --- /dev/null +++ b/plugins/fd/_fd @@ -0,0 +1,83 @@ +#compdef fd fdfind + +autoload -U is-at-least + +_fd() { + typeset -A opt_args + typeset -a _arguments_options + local ret=1 + + if is-at-least 5.2; then + _arguments_options=(-s -S -C) + else + _arguments_options=(-s -C) + fi + + local context curcontext="$curcontext" state line + _arguments "${_arguments_options[@]}" \ +'-d+[Set maximum search depth (default: none)]' \ +'--max-depth=[Set maximum search depth (default: none)]' \ +'--maxdepth=[See --max-depth]' \ +'*-t+[Filter by type: file (f), directory (d), symlink (l), +executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \ +'*--type=[Filter by type: file (f), directory (d), symlink (l), +executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \ +'*-e+[Filter by file extension]' \ +'*--extension=[Filter by file extension]' \ +'-x+[Execute a command for each search result]' \ +'--exec=[Execute a command for each search result]' \ +'(-x --exec)-X+[Execute a command with all search results at once]' \ +'(-x --exec)--exec-batch=[Execute a command with all search results at once]' \ +'*-E+[Exclude entries that match the given glob pattern]' \ +'*--exclude=[Exclude entries that match the given glob pattern]' \ +'*--ignore-file=[Add a custom ignore-file in .gitignore format]' \ +'-c+[When to use colors: never, *auto*, always]: :(never auto always)' \ +'--color=[When to use colors: never, *auto*, always]: :(never auto always)' \ +'-j+[Set number of threads to use for searching & executing]' \ +'--threads=[Set number of threads to use for searching & executing]' \ +'*-S+[Limit results based on the size of files.]' \ +'*--size=[Limit results based on the size of files.]' \ +'--max-buffer-time=[the time (in ms) to buffer, before streaming to the console]' \ +'--changed-within=[Filter by file modification time (newer than)]' \ +'--changed-before=[Filter by file modification time (older than)]' \ +'*--search-path=[(hidden)]' \ +'-H[Search hidden files and directories]' \ +'--hidden[Search hidden files and directories]' \ +'-I[Do not respect .(git|fd)ignore files]' \ +'--no-ignore[Do not respect .(git|fd)ignore files]' \ +'--no-ignore-vcs[Do not respect .gitignore files]' \ +'*-u[Alias for no-ignore and/or hidden]' \ +'-s[Case-sensitive search (default: smart case)]' \ +'--case-sensitive[Case-sensitive search (default: smart case)]' \ +'-i[Case-insensitive search (default: smart case)]' \ +'--ignore-case[Case-insensitive search (default: smart case)]' \ +'-F[Treat the pattern as a literal string]' \ +'--fixed-strings[Treat the pattern as a literal string]' \ +'-a[Show absolute instead of relative paths]' \ +'--absolute-path[Show absolute instead of relative paths]' \ +'-L[Follow symbolic links]' \ +'--follow[Follow symbolic links]' \ +'-p[Search full path (default: file-/dirname only)]' \ +'--full-path[Search full path (default: file-/dirname only)]' \ +'-0[Separate results by the null character]' \ +'--print0[Separate results by the null character]' \ +'--show-errors[Enable display of filesystem errors]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::pattern -- the search pattern, a regular expression (optional):_files' \ +'::path -- the root directory for the filesystem search (optional):_files' \ +&& ret=0 + +} + +(( $+functions[_fd_commands] )) || +_fd_commands() { + local commands; commands=( + + ) + _describe -t commands 'fd commands' commands "$@" +} + +_fd "$@" diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md index f384b0ffd..6594799b3 100644 --- a/plugins/fedora/README.md +++ b/plugins/fedora/README.md @@ -1,3 +1 @@ -This is a plugin based on yum plugin, but using dnf as main frontend -(from Fedora 22 onwards, yum is deprecated in favor of dnf). - +The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead. diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh deleted file mode 100644 index eddc3627b..000000000 --- a/plugins/fedora/fedora.plugin.zsh +++ /dev/null @@ -1,16 +0,0 @@ -## Aliases - -alias dnfs="dnf search" # search package -alias dnfp="dnf info" # show package info -alias dnfl="dnf list" # list packages -alias dnfgl="dnf grouplist" # list package groups -alias dnfli="dnf list installed" # print all installed packages -alias dnfmc="dnf makecache" # rebuilds the dnf package list - -alias dnfu="sudo dnf upgrade" # upgrade packages -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 pagage group -alias dnfrl="sudo dnf remove --remove-leaves" # remove package and leaves -alias dnfc="sudo dnf clean all" # clean cache diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh new file mode 120000 index 000000000..16a214313 --- /dev/null +++ b/plugins/fedora/fedora.plugin.zsh @@ -0,0 +1 @@ +../dnf/dnf.plugin.zsh \ No newline at end of file diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh index bfbf6f48f..5b1090636 100644 --- a/plugins/firewalld/firewalld.plugin.zsh +++ b/plugins/firewalld/firewalld.plugin.zsh @@ -6,7 +6,7 @@ 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)}") + zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v 'interfaces\|sources')}") for i in $zones; do sudo firewall-cmd --zone $i --list-all diff --git a/plugins/flutter/README.md b/plugins/flutter/README.md new file mode 100644 index 000000000..be419144f --- /dev/null +++ b/plugins/flutter/README.md @@ -0,0 +1,21 @@ +## Flutter plugin + +The Flutter plugin provides completion and useful aliases + +To use it, add flutter to the plugins array of your zshrc file: + +``` +plugins=(... flutter) +``` + +## Aliases + +| Alias | Command | Description | +| :--------- | :--------------------- | :------------------------------------------------------------------------- | +| `fl` | `flutter` | Shorthand for flutter command | +| `flr` | `flutter run` | Runs flutter app | +| `fldoc` | `flutter doctor` | Runs flutter doctor | +| `flb` | `flutter build` | Build flutter application | +| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory | +| `flget` | `flutter packages get` | Installs dependencies | +| `flc` | `flutter clean` | Cleans flutter porject | diff --git a/plugins/flutter/_flutter b/plugins/flutter/_flutter new file mode 100644 index 000000000..ab6ce4265 --- /dev/null +++ b/plugins/flutter/_flutter @@ -0,0 +1,37 @@ +#compdef flutter +#autoload + +local -a _1st_arguments +_1st_arguments=( + "analyze":"Analyze the project's Dart code." + "assemble":"Assemble and build flutter resources." + "attach":"Attach to a running application." + "build":"Flutter build commands." + "channel":"List or switch flutter channels." + "clean":"Delete the build/ and .dart_tool/ directories." + "config":"Configure Flutter settings." + "create":"Create a new Flutter project." + "devices":"List all connected devices." + "doctor":"Show information about the installed tooling." + "drive":"Runs Flutter Driver tests for the current project." + "emulators":"List, launch and create emulators." + "format":" Format one or more dart files." + "help":"Display help information for flutter." + "install":"Install a Flutter app on an attached device." + "logs":"Show log output for running Flutter apps." + "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers." + "precache":"Populates the Flutter tool's cache of binary artifacts." + "pub":"Commands for managing Flutter packages." + "run":"Run your Flutter app on an attached device." + "screenshot":"Take a screenshot from a connected device." + "test":"Run Flutter unit tests for the current project." + "upgrade":"Upgrade your copy of Flutter." + "version":"List or switch flutter versions." +) + +_arguments -C '*:: :->subcmds' + +if (( CURRENT == 1 )); then + _describe -t commands "flutter command" _1st_arguments + return +fi diff --git a/plugins/flutter/flutter.plugin.zsh b/plugins/flutter/flutter.plugin.zsh new file mode 100644 index 000000000..01c4c9f5f --- /dev/null +++ b/plugins/flutter/flutter.plugin.zsh @@ -0,0 +1,7 @@ +alias fl="flutter" +alias flr="flutter run" +alias fldoc="flutter doctor" +alias flb="flutter build" +alias flattach="flutter attach" +alias flget="flutter packages get" +alias flc="flutter clean" diff --git a/plugins/forklift/README.md b/plugins/forklift/README.md index 6c5cbab23..6c4ce1e81 100644 --- a/plugins/forklift/README.md +++ b/plugins/forklift/README.md @@ -4,7 +4,7 @@ Plugin for ForkLift, an FTP application for OS X. ### Requirements -* [ForkLift](http://www.binarynights.com/forklift/) +* [ForkLift](https://binarynights.com/) ### Usage diff --git a/plugins/forklift/forklift.plugin.zsh b/plugins/forklift/forklift.plugin.zsh index 692ca5790..274c4a822 100644 --- a/plugins/forklift/forklift.plugin.zsh +++ b/plugins/forklift/forklift.plugin.zsh @@ -1,6 +1,6 @@ # Open folder in ForkLift.app or ForkLift2.app from console # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de -# Updated to support ForkLift2 by Johan Kaving +# Updated to support ForkLift 2 and ForkLift 3 by Johan Kaving # # Usage: # fl [] @@ -24,46 +24,84 @@ function fl { fi osascript 2>&1 1>/dev/null < Searches for your frontend web development made easier - -## Installation ## +## Installation Open your `~/.zshrc` file and enable the `frontend-search` plugin: @@ -13,53 +12,63 @@ plugins=( ... frontend-search) ``` - -## Usage ## +## Usage You can use the frontend-search plugin in these two forms: -* `frontend [more terms if you want]` -* ` [more terms if you want]` +- `frontend [more terms if you want]` +- ` [more terms if you want]` For example, these two are equivalent: ```zsh -$ frontend angularjs dependency injection -$ angularjs dependency injection +$ angular dependency injection +# Will turn into ... +$ frontend angular dependency injection ``` Available search contexts are: -| context | URL | -|---------------|--------------------------------------------------------------------------| -| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` | -| aurajs | `http://aurajs.com/api/#stq=` | -| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` | -| bootsnipp | `http://bootsnipp.com/search?q=` | -| caniuse | `http://caniuse.com/#search=` | -| codepen | `http://codepen.io/search?q=` | -| compassdoc | `http://compass-style.org/search?q=` | -| cssflow | `http://www.cssflow.com/search?q=` | -| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` | -| emberjs | `http://emberjs.com/api/#stp=1&stq=` | -| fontello | `http://fontello.com/#search=` | -| html5please | `http://html5please.com/#` | -| jquery | `https://api.jquery.com/?s=` | -| lodash | `https://devdocs.io/lodash/index#` | -| mdn | `https://developer.mozilla.org/search?q=` | -| npmjs | `https://www.npmjs.com/search?q=` | -| qunit | `https://api.qunitjs.com/?s=` | -| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` | -| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` | -| stackoverflow | `http://stackoverflow.com/search?q=` | -| unheap | `http://www.unheap.com/?s=` | +| context | URL | +| ------------- | --------------------------------------------------------------------------- | +| angular | `https://angular.io/?search=` | +| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` | +| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` | +| bootsnipp | `https://bootsnipp.com/search?q=` | +| bundlephobia | `https://bundlephobia.com/result?p=` | +| caniuse | `https://caniuse.com/#search=` | +| codepen | `https://codepen.io/search?q=` | +| compassdoc | `http://compass-style.org/search?q=` | +| cssflow | `http://www.cssflow.com/search?q=` | +| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` | +| emberjs | `https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=` | +| flowtype | `https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=` | +| fontello | `http://fontello.com/#search=` | +| github | `https://github.com/search?q=` | +| html5please | `https://html5please.com/#` | +| jestjs | `https://www.google.com/search?as_sitesearch=jestjs.io&as_q=` | +| jquery | `https://api.jquery.com/?s=` | +| lodash | `https://devdocs.io/lodash/index#` | +| mdn | `https://developer.mozilla.org/search?q=` | +| nodejs | `https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=` | +| npmjs | `https://www.npmjs.com/search?q=` | +| qunit | `https://api.qunitjs.com/?s=` | +| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` | +| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` | +| stackoverflow | `https://stackoverflow.com/search?q=` | +| typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` | +| unheap | `http://www.unheap.com/?s=` | +| vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` | If you want to have another context, open an Issue and tell us! +## Fallback search behaviour + +The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced. ## Author **Wilson Mendes (willmendesneto)** -+ -+ -+ + +- +- diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh index 9aad76f76..c59640e74 100644 --- a/plugins/frontend-search/_frontend-search.sh +++ b/plugins/frontend-search/_frontend-search.sh @@ -17,27 +17,34 @@ function _frontend() { frontend_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" ) commands=( - 'jquery: Search in jQuery website' - 'mdn: Search in MDN website' - 'compassdoc: Search in COMPASS website' - 'html5please: Search in HTML5 Please website' - 'caniuse: Search in Can I Use website' - 'aurajs: Search in AuraJs website' - 'dartlang: Search in Dart website' - 'lodash: Search in Lo-Dash website' - 'qunit: Search in Qunit website' - 'fontello: Search in fontello website' - 'bootsnipp: Search in bootsnipp website' - 'cssflow: Search in cssflow website' - 'codepen: Search in codepen website' - 'unheap: Search in unheap website' + 'angular: Search in Angular.io website' + 'angularjs: Search in docs.angularjs.org website' 'bem: Search in BEM website' - 'smacss: Search in SMACSS website' - 'angularjs: Search in Angular website' - 'reactjs: Search in React website' + 'bootsnipp: Search in bootsnipp website' + 'bundlephobia: Search in Bundlephobia website' + 'caniuse: Search in Can I Use website' + 'codepen: Search in codepen website' + 'compassdoc: Search in COMPASS website' + 'cssflow: Search in cssflow website' + 'dartlang: Search in Dart website' 'emberjs: Search in Ember website' - 'stackoverflow: Search in StackOverflow website' + 'flowtype: Search in Flowtype website' + 'fontello: Search in fontello website' + 'github: Search in GitHub website' + 'html5please: Search in HTML5 Please website' + 'jestjs: Search in Jest website' + 'jquery: Search in jQuery website' + 'lodash: Search in Lo-Dash website' + 'mdn: Search in MDN website' + 'nodejs: Search in NodeJS website' 'npmjs: Search in NPMJS website' + 'qunit: Search in Qunit website' + 'reactjs: Search in React website' + 'smacss: Search in SMACSS website' + 'stackoverflow: Search in StackOverflow website' + 'typescript: Search in TypeScript website' + 'unheap: Search in unheap website' + 'vuejs: Search in VueJS website' ) _arguments -C \ @@ -66,9 +73,6 @@ function _frontend() { caniuse) _describe -t points "Warp points" frontend_points && ret=0 ;; - aurajs) - _describe -t points "Warp points" frontend_points && ret=0 - ;; dartlang) _describe -t points "Warp points" frontend_points && ret=0 ;; @@ -81,6 +85,9 @@ function _frontend() { fontello) _describe -t points "Warp points" frontend_points && ret=0 ;; + github) + _describe -t points "Warp points" frontend_points && ret=0 + ;; bootsnipp) _describe -t points "Warp points" frontend_points && ret=0 ;; @@ -114,6 +121,24 @@ function _frontend() { npmjs) _describe -t points "Warp points" frontend_points && ret=0 ;; + bundlephobia) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + flowtype) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + typescript) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + vuejs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + nodejs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + jestjs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; esac ;; esac diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 3fd49ab8e..ed19280c4 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,24 +1,42 @@ +alias angular='frontend angular' alias angularjs='frontend angularjs' -alias aurajs='frontend aurajs' alias bem='frontend bem' alias bootsnipp='frontend bootsnipp' +alias bundlephobia='frontend bundlephobia' alias caniuse='frontend caniuse' alias codepen='frontend codepen' alias compassdoc='frontend compassdoc' alias cssflow='frontend cssflow' alias dartlang='frontend dartlang' alias emberjs='frontend emberjs' +alias flowtype='frontend flowtype' alias fontello='frontend fontello' +alias github='frontend github' alias html5please='frontend html5please' +alias jestjs='frontend jestjs' alias jquery='frontend jquery' alias lodash='frontend lodash' alias mdn='frontend mdn' +alias nodejs='frontend nodejs' alias npmjs='frontend npmjs' alias qunit='frontend qunit' alias reactjs='frontend reactjs' alias smacss='frontend smacss' alias stackoverflow='frontend stackoverflow' +alias typescript='frontend typescript' alias unheap='frontend unheap' +alias vuejs='frontend vuejs' + +function _frontend_fallback() { + local url + if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then + url="https://duckduckgo.com/?sites=$1&q=" + else + url="https://google.com/search?as_sitesearch=$1&as_q=" + fi + + echo "$url" +} function frontend() { emulate -L zsh @@ -26,27 +44,34 @@ function frontend() { # define search context URLS typeset -A urls urls=( - angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' - aurajs 'http://aurajs.com/api/#stq=' - bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' - bootsnipp 'http://bootsnipp.com/search?q=' - caniuse 'http://caniuse.com/#search=' - codepen 'http://codepen.io/search?q=' + angular 'https://angular.io/?search=' + angularjs $(_frontend_fallback 'angularjs.org') + bem $(_frontend_fallback 'bem.info') + bootsnipp 'https://bootsnipp.com/search?q=' + bundlephobia 'https://bundlephobia.com/result?p=' + caniuse 'https://caniuse.com/#search=' + codepen 'https://codepen.io/search?q=' compassdoc 'http://compass-style.org/search?q=' cssflow 'http://www.cssflow.com/search?q=' dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' - emberjs 'http://emberjs.com/api/#stp=1&stq=' + emberjs $(_frontend_fallback 'emberjs.com/') + flowtype $(_frontend_fallback 'flow.org/en/docs/') fontello 'http://fontello.com/#search=' - html5please 'http://html5please.com/#' + github 'https://github.com/search?q=' + html5please 'https://html5please.com/#' + jestjs $(_frontend_fallback 'jestjs.io') jquery 'https://api.jquery.com/?s=' lodash 'https://devdocs.io/lodash/index#' mdn 'https://developer.mozilla.org/search?q=' + nodejs $(_frontend_fallback 'nodejs.org/en/docs/') npmjs 'https://www.npmjs.com/search?q=' qunit 'https://api.qunitjs.com/?s=' - reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' - smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' - stackoverflow 'http://stackoverflow.com/search?q=' + reactjs $(_frontend_fallback 'reactjs.org/') + smacss $(_frontend_fallback 'smacss.com') + stackoverflow 'https://stackoverflow.com/search?q=' + typescript $(_frontend_fallback 'www.typescriptlang.org/docs') unheap 'http://www.unheap.com/?s=' + vuejs $(_frontend_fallback 'vuejs.org') ) # show help for command list @@ -57,9 +82,9 @@ function frontend() { print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," print -P "and %Ucontext%u is one of the following:" print -P "" - print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow," - print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs," - print -P " qunit, reactjs, smacss, stackoverflow, unheap" + print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow," + print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," + print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" print -P "" print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." print -P "" @@ -73,17 +98,17 @@ function frontend() { echo "" echo "Valid contexts are:" echo "" - echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, " - echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, " - echo " qunit, reactjs, smacss, stackoverflow, unheap" + echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow," + echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash," + echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" echo "" return 1 fi # build search url: - # join arguments passed with '+', then append to search context URL + # join arguments passed with '%20', then append to search context URL # TODO substitute for proper urlencode method - url="${urls[$1]}${(j:+:)@[2,-1]}" + url="${urls[$1]}${(j:%20:)@[2,-1]}" echo "Opening $url ..." diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md new file mode 100644 index 000000000..b3a434347 --- /dev/null +++ b/plugins/fzf/README.md @@ -0,0 +1,19 @@ +# fzf + +This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings + +```zsh +# Set fzf installation directory path +export FZF_BASE=/path/to/fzf/install/dir + +# Uncomment the following line to disable fuzzy completion +# export DISABLE_FZF_AUTO_COMPLETION="true" + +# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C) +# export DISABLE_FZF_KEY_BINDINGS="true" + +plugins=( + ... + fzf +) +``` diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh new file mode 100644 index 000000000..fe471a363 --- /dev/null +++ b/plugins/fzf/fzf.plugin.zsh @@ -0,0 +1,95 @@ +function setup_using_base_dir() { + # Declare all variables local not no mess with outside env in any way + local fzf_base + local fzf_shell + local fzfdirs + local dir + + test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" + + if [[ -z "${fzf_base}" ]]; then + fzfdirs=( + "${HOME}/.fzf" + "/usr/local/opt/fzf" + "/usr/share/fzf" + ) + for dir in ${fzfdirs}; do + if [[ -d "${dir}" ]]; then + fzf_base="${dir}" + break + fi + done + + if [[ -z "${fzf_base}" ]]; then + if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then + if [[ -d "${dir}" ]]; then + fzf_base="${dir}" + fi + fi + fi + fi + + if [[ -d "${fzf_base}" ]]; then + # Fix fzf shell directory for Archlinux package + if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then + fzf_shell="${fzf_base}" + else + fzf_shell="${fzf_base}/shell" + fi + + # Setup fzf binary path + if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then + export PATH="$PATH:$fzf_base/bin" + fi + + # Auto-completion + if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then + [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null + fi + + # Key bindings + if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then + source "${fzf_shell}/key-bindings.zsh" + fi + else + return 1 + fi +} + + +function setup_using_debian_package() { + (( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null + if (( $? )); then + # Either not a debian based distro, or no fzf installed. In any case skip ahead + return 1 + fi + + # NOTE: There is no need to configure PATH for debian package, all binaries + # are installed to /usr/bin by default + + local completions="/usr/share/zsh/vendor-completions/_fzf" + local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh" + + # Auto-completion + if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then + source $completions 2> /dev/null + fi + + # Key bindings + if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then + source $key_bindings + fi + + return 0 +} + +function indicate_error() { + print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\ + "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2 +} + +# Check for debian package first, because it easy to short cut +# Indicate to user that fzf installation not found if nothing worked +setup_using_debian_package || setup_using_base_dir || indicate_error + +unset -f setup_using_debian_package setup_using_base_dir indicate_error diff --git a/plugins/gatsby/README.md b/plugins/gatsby/README.md new file mode 100644 index 000000000..36846a228 --- /dev/null +++ b/plugins/gatsby/README.md @@ -0,0 +1,7 @@ +# gatsby autocomplete plugin + +* Adds autocomplete options for all gatsby commands. + +## Requirements + +In order to make this work, you will need to have gatsby set up in your path. diff --git a/plugins/gatsby/_gatsby b/plugins/gatsby/_gatsby new file mode 100644 index 000000000..66eb02f00 --- /dev/null +++ b/plugins/gatsby/_gatsby @@ -0,0 +1,24 @@ +#compdef gatsby +#autoload + +# in order to make this work, you will need to have gatsby +# https://www.gatsbyjs.org/ + +local -a _1st_arguments +_1st_arguments=( +'develop:Start development server. Watches files, rebuilds, and hot reloads if something changes' +'build:Build a Gatsby project.' +'serve:Serve previously built Gatsby site.' +'info:Get environment information for debugging and issue reporting' +'clean:Wipe the local gatsby environment including built assets and cache' +'repl:Get a node repl with context of Gatsby environment, see (add docs link here)' +'new: [rootPath] [starter] Create new Gatsby project.' +'telemetry:Enable or disable Gatsby anonymous analytics collection.' +) + +_arguments -C '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "gatsby subcommand" _1st_arguments + return +fi diff --git a/plugins/gcloud/README.md b/plugins/gcloud/README.md new file mode 100644 index 000000000..e7ce0e0f1 --- /dev/null +++ b/plugins/gcloud/README.md @@ -0,0 +1,24 @@ +# gcloud + +This plugin provides completion support for the +[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/). + +To use it, add `gcloud` to the plugins array in your zshrc file. + +```zsh +plugins=(... gcloud) +``` + +It relies on you having installed the SDK using one of the supported options +listed [here](https://cloud.google.com/sdk/install). + +## Plugin Options + +* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have +your GCloud SDK installed in a non-standard location. The plugin will use this +as the base for your SDK if it finds it set already. + +* If you do not have a `python2` in your `PATH` you'll also need to set the +`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is +used by the SDK to call a compatible interpreter when you run one of the +SDK commands. diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh new file mode 100644 index 000000000..c7aebe697 --- /dev/null +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -0,0 +1,33 @@ +##################################################### +# gcloud plugin for oh-my-zsh # +# Author: Ian Chesal (github.com/ianchesal) # +##################################################### + +if [[ -z "${CLOUDSDK_HOME}" ]]; then + search_locations=( + "$HOME/google-cloud-sdk" + "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" + "/usr/share/google-cloud-sdk" + "/snap/google-cloud-sdk/current" + "/usr/lib64/google-cloud-sdk/" + "/opt/google-cloud-sdk" + ) + + for gcloud_sdk_location in $search_locations; do + if [[ -d "${gcloud_sdk_location}" ]]; then + CLOUDSDK_HOME="${gcloud_sdk_location}" + break + fi + done +fi + +if (( ${+CLOUDSDK_HOME} )); then + if (( ! $+commands[gcloud] )); then + # Only source this if GCloud isn't already on the path + if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then + source "${CLOUDSDK_HOME}/path.zsh.inc" + fi + fi + source "${CLOUDSDK_HOME}/completion.zsh.inc" + export CLOUDSDK_HOME +fi diff --git a/plugins/geeknote/README.md b/plugins/geeknote/README.md index a6b50e27f..3f2353112 100644 --- a/plugins/geeknote/README.md +++ b/plugins/geeknote/README.md @@ -1,6 +1,6 @@ ## ZSH-Geeknote -[Geeknote](https://github.com/VitaliyRodnenko/geeknote) plugin for [oh-my-zsh framework](http://github.com/robbyrussell/oh-my-zsh). +[Geeknote](https://github.com/VitaliyRodnenko/geeknote) plugin for oh-my-zsh. Plugins provides: diff --git a/plugins/gem/README.md b/plugins/gem/README.md new file mode 100644 index 000000000..decd87ba3 --- /dev/null +++ b/plugins/gem/README.md @@ -0,0 +1,17 @@ +# Gem plugin + +This plugin adds completions and aliases for [Gem](https://rubygems.org/). The completions include the common `gem` subcommands as well as the installed gems in the current directory. + +To use it, add `gem` to the plugins array in your zshrc file: + +```zsh +plugins=(... gem) +``` + +## Aliases + +| Alias | Command | Description | +|----------------------|-------------------------------|--------------------------------------------| +| gemb | `gem build *.gemspec` | Build a gem from a gemspec | +| gemp | `gem push *.gem` | Push a gem up to the gem server | +| gemy [gem] [version] | `gem yank [gem] -v [version]` | Remove a pushed gem version from the index | diff --git a/plugins/git-auto-fetch/README.md b/plugins/git-auto-fetch/README.md new file mode 100644 index 000000000..35f3c2f71 --- /dev/null +++ b/plugins/git-auto-fetch/README.md @@ -0,0 +1,31 @@ +# Git auto-fetch + +Automatically fetches all changes from all remotes while you are working in git-initialized directory. + +#### Usage + +Add `git-auto-fetch` to the plugins array in your zshrc file: + +```shell +plugins=(... git-auto-fetch) +``` + +Every time you launch a command in your shell all remotes will be fetched in background. +By default autofetch will be triggered only if last fetch was done at least 60 seconds ago. +You can change fetch interval in your .zshrc: +``` +GIT_AUTO_FETCH_INTERVAL=1200 #in seconds +``` +Log of `git fetch --all` will be saved into `.git/FETCH_LOG` + + +#### Toggle auto fetch per folder +If you are using mobile connection or for any other reason you can disable git-auto-fetch for any folder: + +```shell +$ cd to/your/project +$ git-auto-fetch +disabled +$ git-auto-fetch +enabled +``` diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh new file mode 100644 index 000000000..56ab86dbe --- /dev/null +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -0,0 +1,35 @@ +GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60} + +function git-fetch-all { + (`git rev-parse --is-inside-work-tree 2>/dev/null` && + dir=`git rev-parse --git-dir` && + [[ ! -f $dir/NO_AUTO_FETCH ]] && + (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) && + git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &) +} + +function git-auto-fetch { + `git rev-parse --is-inside-work-tree 2>/dev/null` || return + guard="`git rev-parse --git-dir`/NO_AUTO_FETCH" + + (rm $guard 2>/dev/null && + echo "${fg_bold[green]}enabled${reset_color}") || + (touch $guard && + echo "${fg_bold[red]}disabled${reset_color}") +} + +# Override zle-line-init if it exists +if (( $+functions[zle-line-init] )); then + eval "override-git-auto-fetch-$(declare -f zle-line-init)" + + function zle-line-init () { + git-fetch-all + override-git-auto-fetch-zle-line-init + } +else + function zle-line-init () { + git-fetch-all + } +fi + +zle -N zle-line-init diff --git a/plugins/git-escape-magic/README.md b/plugins/git-escape-magic/README.md new file mode 100644 index 000000000..7fefed39d --- /dev/null +++ b/plugins/git-escape-magic/README.md @@ -0,0 +1,16 @@ +# Git Escape Magic + +This plugin is copied from the original at +https://github.com/knu/zsh-git-escape-magic. All credit for the +functionality enabled by this plugin should go to @knu. + +An excerpt from that project's readme explains its purpose. + +> It eliminates the need for manually escaping those meta-characters. The zle function it provides is context aware and recognizes the characteristics of each subcommand of git. Every time you type one of these meta-characters on a git command line, it automatically escapes the meta-character with a backslash as necessary and as appropriate. + +## Usage + +To use this plugin, add it to your list of plugins in your `.zshrc` file. + +**NOTE**: If you use url-quote-magic, it must be included before this +plugin runs to prevent any conflicts. diff --git a/plugins/git-escape-magic/git-escape-magic b/plugins/git-escape-magic/git-escape-magic new file mode 100644 index 000000000..94a8d7b0f --- /dev/null +++ b/plugins/git-escape-magic/git-escape-magic @@ -0,0 +1,135 @@ +# -*- mode: sh -*- +# +# git-escape-magic - zle tweak for git command line arguments +# +# Copyright (c) 2011, 2012, 2014 Akinori MUSHA +# Licensed under the 2-clause BSD license. +# +# This tweak eliminates the need for manually escaping shell +# meta-characters such as [~^{}] that are used for specifying a git +# object (commit or tree). Every time you type one of these +# characters on a git command line, it is automatically escaped with a +# backslash as necessary and as appropriate. +# +# If you want to use this with url-quote-magic, make sure to enable it +# first. +# +# Usage: +# autoload -Uz git-escape-magic +# git-escape-magic +# + +git-escape-magic.self-insert() { + emulate -L zsh + setopt extendedglob + local self_insert_function + zstyle -s ':git-escape-magic' self-insert-function self_insert_function + + if [[ "$KEYS" == [{}~^]* ]] && { + local qkey="${(q)KEYS}" + [[ "$KEYS" != "$qkey" ]] + } && { + local lbuf="$LBUFFER$qkey" + [[ "${(Q)LBUFFER}$KEYS" == "${(Q)lbuf}" ]] + } && { + local -a words + words=("${(@Q)${(z)lbuf}}") + [[ "$words[(i)(*/|)git(|-[^/]##)]" -le $#words ]] + } + then + local i + i="$words[(I)([;(){\&]|\&[\&\!]|\|\||[=<>]\(*)]" + if [[ $i -gt 0 ]]; then + shift $((i-1)) words + if [[ "$words[1]" == [\=\<\>]\(* ]]; then + words[1]="${words[1]#[=<>]\(}" + else + [[ "$words[1]" == \; && $words[2] == (then|else|elif|do) ]] && shift words + shift words + fi + fi + while [[ "$words[1]" == (if|while|until|\!) ]]; do + shift words + done + while [[ "$words[1]" == [A-Za-z_][A-Za-z0-9_]#=* ]]; do + shift words + done + [[ "$words[1]" == (*/|)git(|-[^/]##) ]] && { + local subcommand + subcommand="${words[1]##*/git-}" + if [[ -z "$subcommand" ]]; then + shift words + subcommand="$words[1]" + fi + [[ $#words -ge 2 ]] + } && + case "$subcommand" in + # commands that may take pathspec but never take refspec with [{}~^] + (add|rm|am|apply|check-attr|checkout-index|clean|clone|config|diff-files|hash-object|help|index-pack|mailinfo|mailsplit|merge-file|merge-index|mergetool|mktag|mv|pack-objects|pack-redundant|relink|send-email|show-index|show-ref|stage|status|verify-pack) + false ;; + # commands that may take pathspec but rarely take refspec with [{}~^] + (for-each-ref|grep|ls-files|update-index) + false ;; + (archive|ls-tree) + ! [[ $#words -ge 3 && + "$words[-2]" == [^-]* ]] ;; + (diff-tree) + ! [[ $#words -ge 4 && + "$words[-2]" == [^-]* && + "$words[-3]" == [^-]* ]] ;; + (*) + [[ $words[(i)--] -gt $#words ]] ;; + esac && + case "${words[-1]%%"$KEYS"}" in + (*[@^]) + [[ "$KEYS" == [{~^]* ]] ;; + (*[@^]\{[^}]##) + [[ "$KEYS" == \}* ]] ;; + (?*) + [[ "$KEYS" == [~^]* ]] ;; + (*) + false ;; + esac && + LBUFFER="$LBUFFER\\" + fi + + zle "$self_insert_function" +} + +git-escape-magic.on() { + emulate -L zsh + local self_insert_function="${$(zle -lL | awk \ + '$1=="zle"&&$2=="-N"&&$3=="self-insert"{print $4;exit}'):-.self-insert}" + + [[ "$self_insert_function" == git-escape-magic.self-insert ]] && + return 0 + + # For url-quote-magic which does not zle -N itself + zle -la "$self_insert_function" || zle -N "$self_insert_function" + + zstyle ':git-escape-magic' self-insert-function "$self_insert_function" + + zle -A git-escape-magic.self-insert self-insert + return 0 +} + +git-escape-magic.off() { + emulate -L zsh + local self_insert_function + zstyle -s ':git-escape-magic' self-insert-function self_insert_function + + [[ -n "$self_insert_function" ]] && + zle -A "$self_insert_function" self-insert + return 0 +} + +zle -N git-escape-magic.self-insert +zle -N git-escape-magic.on +zle -N git-escape-magic.off + +git-escape-magic() { + git-escape-magic.on +} + +[[ -o kshautoload ]] || git-escape-magic "$@" + diff --git a/plugins/git-escape-magic/git-escape-magic.plugin.zsh b/plugins/git-escape-magic/git-escape-magic.plugin.zsh new file mode 100644 index 000000000..c021ea707 --- /dev/null +++ b/plugins/git-escape-magic/git-escape-magic.plugin.zsh @@ -0,0 +1,9 @@ +# Automatically detect and escape zsh globbing meta-characters when used with +# git refspec characters like `[^~{}]`. NOTE: This must be loaded _after_ +# url-quote-magic. +# +# This trick is detailed at https://github.com/knu/zsh-git-escape-magic and is +# what allowed this plugin to exist. + +autoload -Uz git-escape-magic +git-escape-magic diff --git a/plugins/git-extras/README.md b/plugins/git-extras/README.md index 8f12e297e..987f0d800 100644 --- a/plugins/git-extras/README.md +++ b/plugins/git-extras/README.md @@ -1,6 +1,6 @@ # git-extras -This plugin provides completion definitions for some of the commands defined by [git-extras](http://github.com/tj/git-extras). +This plugin provides completion definitions for some of the commands defined by [git-extras](https://github.com/tj/git-extras). ## Setup notes diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh index 0dcd630e8..b86d7c5b6 100644 --- a/plugins/git-extras/git-extras.plugin.zsh +++ b/plugins/git-extras/git-extras.plugin.zsh @@ -2,7 +2,7 @@ # Description # ----------- # -# Completion script for git-extras (http://github.com/tj/git-extras). +# Completion script for git-extras (https://github.com/tj/git-extras). # # This depends on and reuses some of the internals of the _git completion # function that ships with zsh itself. It will not work with the _git that ships @@ -19,8 +19,8 @@ # Inspirations # ----------- # -# * git-extras (http://github.com/tj/git-extras) -# * git-flow-completion (http://github.com/bobthecow/git-flow-completion) +# * git-extras (https://github.com/tj/git-extras) +# * git-flow-completion (https://github.com/bobthecow/git-flow-completion) # # ------------------------------------------------------------------------------ @@ -47,6 +47,14 @@ __gitex_commits() { _describe -t commits commit commits && ret=0 } +__gitex_remote_names() { + local expl + declare -a remote_names + remote_names=(${(f)"$(_call_program remotes git remote 2>/dev/null)"}) + __git_command_successful || return + _wanted remote-names expl remote-name compadd $* - $remote_names +} + __gitex_tag_names() { local expl declare -a tag_names @@ -69,7 +77,11 @@ __gitex_specific_branch_names() { declare -a branch_names branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/}) __git_command_successful || return - _wanted branch-names expl branch-name compadd $* - $branch_names + _wanted branch-names expl branch-name compadd - $branch_names +} + +__gitex_chore_branch_names() { + __gitex_specific_branch_names 'chore' } __gitex_feature_branch_names() { @@ -102,6 +114,11 @@ __gitex_author_names() { } # subcommands +_git-authors() { + _arguments -C \ + '(--list -l)'{--list,-l}'[show authors]' \ + '--no-email[without email]' \ +} _git-bug() { local curcontext=$curcontext state line ret=1 @@ -126,8 +143,16 @@ _git-bug() { _arguments -C \ ':branch-name:__gitex_bug_branch_names' ;; + -r|--remote ) + _arguments -C \ + ':remote-name:__gitex_remote_names' + ;; esac + return 0 esac + + _arguments \ + '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' } @@ -136,6 +161,40 @@ _git-changelog() { '(-l --list)'{-l,--list}'[list commits]' \ } +_git-chore() { + local curcontext=$curcontext state line ret=1 + declare -A opt_args + + _arguments -C \ + ': :->command' \ + '*:: :->option-or-argument' && ret=0 + + case $state in + (command) + declare -a commands + commands=( + 'finish:merge and delete the chore branch' + ) + _describe -t commands command commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + case $line[1] in + (finish) + _arguments -C \ + ':branch-name:__gitex_chore_branch_names' + ;; + -r|--remote ) + _arguments -C \ + ':remote-name:__gitex_remote_names' + ;; + esac + return 0 + esac + + _arguments \ + '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' +} _git-contrib() { @@ -149,6 +208,27 @@ _git-count() { '--all[detailed commit count]' } +_git-create-branch() { + local curcontext=$curcontext state line + _arguments -C \ + ': :->command' \ + '*:: :->option-or-argument' + + case "$state" in + (command) + _arguments \ + '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' + ;; + (option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + case $line[1] in + -r|--remote ) + _arguments -C \ + ':remote-name:__gitex_remote_names' + ;; + esac + esac +} _git-delete-branch() { _arguments \ @@ -220,10 +300,17 @@ _git-feature() { _arguments -C \ ':branch-name:__gitex_feature_branch_names' ;; + -r|--remote ) + _arguments -C \ + ':remote-name:__gitex_remote_names' + ;; esac + return 0 esac -} + _arguments \ + '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' +} _git-graft() { _arguments \ @@ -231,14 +318,39 @@ _git-graft() { ':dest-branch-name:__gitex_branch_names' } +_git-guilt() { + _arguments -C \ + '(--email -e)'{--email,-e}'[display author emails instead of names]' \ + '(--ignore-whitespace -w)'{--ignore-whitespace,-w}'[ignore whitespace only changes]' \ + '(--debug -d)'{--debug,-d}'[output debug information]' \ + '-h[output usage information]' +} _git-ignore() { _arguments -C \ '(--local -l)'{--local,-l}'[show local gitignore]' \ - '(--global -g)'{--global,-g}'[show global gitignore]' + '(--global -g)'{--global,-g}'[show global gitignore]' \ + '(--private -p)'{--private,-p}'[show repo gitignore]' } +_git-ignore() { + _arguments -C \ + '(--append -a)'{--append,-a}'[append .gitignore]' \ + '(--replace -r)'{--replace,-r}'[replace .gitignore]' \ + '(--list-in-table -l)'{--list-in-table,-l}'[print available types in table format]' \ + '(--list-alphabetically -L)'{--list-alphabetically,-L}'[print available types in alphabetical order]' \ + '(--search -s)'{--search,-s}'[search word in available types]' +} + + +_git-merge-into() { + _arguments '--ff-only[merge only fast-forward]' + _arguments \ + ':src:__gitex_branch_names' \ + ':dest:__gitex_branch_names' +} + _git-missing() { _arguments \ ':first-branch-name:__gitex_branch_names' \ @@ -269,8 +381,16 @@ _git-refactor() { _arguments -C \ ':branch-name:__gitex_refactor_branch_names' ;; + -r|--remote ) + _arguments -C \ + ':remote-name:__gitex_remote_names' + ;; esac + return 0 esac + + _arguments \ + '(--remote -r)'{--remote,-r}'[setup remote tracking branch]' } @@ -279,6 +399,23 @@ _git-squash() { ':branch-name:__gitex_branch_names' } +_git-stamp() { + _arguments -C \ + '(--replace -r)'{--replace,-r}'[replace stamps with same id]' +} + +_git-standup() { + _arguments -C \ + '-a[Specify the author of commits. Use "all" to specify all authors.]' \ + '-d[Show history since N days ago]' \ + '-D[Specify the date format displayed in commit history]' \ + '-f[Fetch commits before showing history]' \ + '-g[Display GPG signed info]' \ + '-h[Display help message]' \ + '-L[Enable the inclusion of symbolic links]' \ + '-m[The depth of recursive directory search]' +} + _git-summary() { _arguments '--line[summarize with lines rather than commits]' __gitex_commits @@ -291,45 +428,71 @@ _git-undo(){ '(--hard -h)'{--hard,-h}'[wipes your commit(s)]' } -zstyle ':completion:*:*:git:*' user-commands \ +zstyle -g existing_user_commands ':completion:*:*:git:*' user-commands + +zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ alias:'define, search and show aliases' \ - archive-file:'export the current HEAD of the git repository to a archive' \ + archive-file:'export the current head of the git repository to an archive' \ + authors:'generate authors report' \ back:'undo and stage latest commits' \ - bug:'create a bug branch' \ - changelog:'populate changelog file with commits since the previous tag' \ - commits-since:'list commits since a given date' \ - contrib:'display author contributions' \ - count:'count commits' \ - create-branch:'create local and remote branch' \ - delete-branch:'delete local and remote branch' \ - delete-merged-branches:'delete merged branches'\ - delete-submodule:'delete submodule' \ - delete-tag:'delete local and remote tag' \ - effort:'display effort statistics' \ - extras:'git-extras' \ - feature:'create a feature branch' \ - fork:'fork a repo on github' \ - fresh-branch:'create empty local branch' \ - gh-pages:'create the GitHub Pages branch' \ - graft:'merge commits from source branch to destination branch' \ - ignore:'add patterns to .gitignore' \ - info:'show info about the repository' \ - local-commits:'list unpushed commits on the local branch' \ + bug:'create bug branch' \ + bulk:'run bulk commands' \ + changelog:'generate a changelog report' \ + chore:'create chore branch' \ + clear-soft:'soft clean up a repository' \ + clear:'rigorously clean up a repository' \ + commits-since:'show commit logs since some date' \ + contrib:'show user contributions' \ + count:'show commit count' \ + create-branch:'create branches' \ + delete-branch:'delete branches' \ + delete-merged-branches:'delete merged branches' \ + delete-submodule:'delete submodules' \ + delete-tag:'delete tags' \ + delta:'lists changed files' \ + effort:'show effort statistics on file(s)' \ + extras:'awesome git utilities' \ + feature:'create/merge feature branch' \ + force-clone:'overwrite local repositories with clone' \ + fork:'fork a repo on GitHub' \ + fresh-branch:'create fresh branches' \ + gh-pages:'create the GitHub pages branch' \ + graft:'merge and destroy a given branch' \ + guilt:'calculate change between two revisions' \ + ignore-io:'get sample gitignore file' \ + ignore:'add .gitignore patterns' \ + info:'returns information on current repository' \ + local-commits:'list local commits' \ lock:'lock a file excluded from version control' \ locked:'ls files that have been locked' \ + merge-into:'merge one branch into another' \ + merge-repo:'merge two repo histories' \ missing:'show commits missing from another branch' \ + mr:'checks out a merge request locally' \ + obliterate:'rewrite past commits to remove some files' \ pr:'checks out a pull request locally' \ + psykorebase:'rebase a branch with a merge commit' \ + pull-request:'create pull request to GitHub project' \ + reauthor:'replace the author and/or committer identities in commits and tags' \ rebase-patch:'rebases a patch' \ - refactor:'create a refactor branch' \ + refactor:'create refactor branch' \ release:'commit, tag and push changes to the repository' \ + rename-branch:'rename a branch' \ rename-tag:'rename a tag' \ - repl:'read-eval-print-loop' \ + repl:'git read-eval-print-loop' \ reset-file:'reset one file' \ root:'show path of root' \ - setup:'setup a git repository' \ + scp:'copy files to ssh compatible `git-remote`' \ + sed:'replace patterns in git-controlled files' \ + setup:'set up a git repository' \ + show-merged-branches:'show merged branches' \ show-tree:'show branch tree of commit history' \ - squash:'merge commits from source branch into the current one as a single commit' \ - summary:'repository summary' \ - touch:'one step creation of new files' \ - undo:'remove the latest commit' \ + show-unmerged-branches:'show unmerged branches' \ + squash:'import changes from a branch' \ + stamp:'stamp the last commit message' \ + standup:'recall the commit history' \ + summary:'show repository summary' \ + sync:'sync local branch with remote branch' \ + touch:'touch and add file to the index' \ + undo:'remove latest commits' \ unlock:'unlock a file excluded from version control' diff --git a/plugins/git-flow-avh/README.md b/plugins/git-flow-avh/README.md new file mode 100644 index 000000000..0768d93ea --- /dev/null +++ b/plugins/git-flow-avh/README.md @@ -0,0 +1,19 @@ +# git-flow (AVH Edition) plugin + +This plugin adds completion for the [git-flow (AVH Edition)](https://github.com/petervanderdoes/gitflow-avh). +The AVH Edition of the git extensions that provides high-level repository operations for [Vincent Driessen's branching model](https://nvie.com/posts/a-successful-git-branching-model/). + +To use it, add `git-flow-avh` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-flow-avh) +``` + +## Requirements + +1. The git-flow tool has to be [installed](https://github.com/petervanderdoes/gitflow-avh#installing-git-flow) + separately. + +2. You have to use zsh's git completion instead of the git project's git completion. This is typically + done by default so you don't need to do anything else. If you installed git with Homebrew you + might have to uninstall the git completion it's bundled with. diff --git a/plugins/git-flow-avh/git-flow-avh.plugin.zsh b/plugins/git-flow-avh/git-flow-avh.plugin.zsh index ba98fff01..860ca55c5 100644 --- a/plugins/git-flow-avh/git-flow-avh.plugin.zsh +++ b/plugins/git-flow-avh/git-flow-avh.plugin.zsh @@ -1,419 +1,526 @@ -#!zsh -# -# Installation -# ------------ -# -# To achieve git-flow completion nirvana: -# -# 0. Update your zsh's git-completion module to the newest verion. -# From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD -# -# 1. Install this file. Either: -# -# a. Place it in your .zshrc: -# -# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in -# your .zshrc: -# -# source ~/.git-flow-completion.zsh -# -# c. Or, use this file as a oh-my-zsh plugin. -# - _git-flow () { - local curcontext="$curcontext" state line - typeset -A opt_args + local curcontext="$curcontext" state line + typeset -A opt_args - _arguments -C \ - ':command:->command' \ - '*::options:->options' + _arguments -C \ + ':command:->command' \ + '*::options:->options' - case $state in - (command) + case $state in + (command) - local -a subcommands - subcommands=( - 'init:Initialize a new git repo with support for the branching model.' - 'feature:Manage your feature branches.' - 'config:Manage your configuration.' - 'release:Manage your release branches.' - 'hotfix:Manage your hotfix branches.' - 'support:Manage your support branches.' - 'version:Shows version information.' - 'finish:Finish the branch you are currently on.' - 'delete:Delete the branch you are currently on.' - 'publish:Publish the branch you are currently on.' - ) - _describe -t commands 'git flow' subcommands - ;; + local -a subcommands + subcommands=( + 'init:Initialize a new git repo with support for the branching model.' + 'feature:Manage your feature branches.' + 'bugfix:Manage your bugfix branches.' + 'config:Manage your configuration.' + 'release:Manage your release branches.' + 'hotfix:Manage your hotfix branches.' + 'support:Manage your support branches.' + 'version:Shows version information.' + 'finish:Finish the branch you are currently on.' + 'delete:Delete the branch you are currently on.' + 'publish:Publish the branch you are currently on.' + 'rebase:Rebase the branch you are currently on.' + ) + _describe -t commands 'git flow' subcommands + ;; - (options) - case $line[1] in + (options) + case $line[1] in - (init) - _arguments \ - -f'[Force setting of gitflow branches, even if already configured]' - ;; + (init) + _arguments \ + -f'[Force setting of gitflow branches, even if already configured]' + ;; - (version) - ;; + (version) + ;; - (hotfix) - __git-flow-hotfix - ;; + (hotfix) + __git-flow-hotfix + ;; - (release) - __git-flow-release - ;; + (release) + __git-flow-release + ;; - (feature) - __git-flow-feature - ;; - (config) - __git-flow-config - ;; + (feature) + __git-flow-feature + ;; + (bugfix) + __git-flow-bugfix + ;; - esac - ;; - esac + (config) + __git-flow-config + ;; + + esac + ;; + esac } __git-flow-release () { - local curcontext="$curcontext" state line - typeset -A opt_args + local curcontext="$curcontext" state line + typeset -A opt_args - _arguments -C \ - ':command:->command' \ - '*::options:->options' + _arguments -C \ + ':command:->command' \ + '*::options:->options' - case $state in - (command) + case $state in + (command) - local -a subcommands - subcommands=( - 'start:Start a new release branch.' - 'finish:Finish a release branch.' - 'list:List all your release branches. (Alias to `git flow release`)' - 'publish:Publish release branch to remote.' - 'track:Checkout remote release branch.' - 'delete:Delete a release branch.' - ) - _describe -t commands 'git flow release' subcommands - _arguments \ - -v'[Verbose (more) output]' - ;; + local -a subcommands + subcommands=( + 'start:Start a new release branch.' + 'finish:Finish a release branch.' + 'list:List all your release branches. (Alias to `git flow release`)' + 'publish:Publish release branch to remote.' + 'track:Checkout remote release branch.' + 'rebase:Rebase from integration branch.' + 'delete:Delete a release branch.' + ) + _describe -t commands 'git flow release' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; - (options) - case $line[1] in + (options) + case $line[1] in - (start) - _arguments \ - -F'[Fetch from origin before performing finish]'\ - ':version:__git_flow_version_list' - ;; + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':version:__git_flow_version_list' + ;; - (finish) - _arguments \ - -F'[Fetch from origin before performing finish]' \ - -s'[Sign the release tag cryptographically]'\ - -u'[Use the given GPG-key for the digital signature (implies -s)]'\ - -m'[Use the given tag message]'\ - -p'[Push to $ORIGIN after performing finish]'\ - ':version:__git_flow_version_list' - ;; + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -s'[Sign the release tag cryptographically]'\ + -u'[Use the given GPG-key for the digital signature (implies -s)]'\ + -m'[Use the given tag message]'\ + -p'[Push to $ORIGIN after performing finish]'\ + ':version:__git_flow_version_list' + ;; - (delete) - _arguments \ - -f'[Force deletion]' \ - -r'[Delete remote branch]' \ - ':version:__git_flow_version_list' - ;; + (delete) + _arguments \ + -f'[Force deletion]' \ + -r'[Delete remote branch]' \ + ':version:__git_flow_version_list' + ;; - (publish) - _arguments \ - ':version:__git_flow_version_list' - ;; + (publish) + _arguments \ + ':version:__git_flow_version_list' + ;; - (track) - _arguments \ - ':version:__git_flow_version_list' - ;; + (track) + _arguments \ + ':version:__git_flow_version_list' + ;; - *) - _arguments \ - -v'[Verbose (more) output]' - ;; - esac - ;; - esac + (rebase) + _arguments \ + -i'[Do an interactive rebase]' \ + ':branch:__git_branch_names' + ;; + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac } __git-flow-hotfix () { - local curcontext="$curcontext" state line - typeset -A opt_args + local curcontext="$curcontext" state line + typeset -A opt_args - _arguments -C \ - ':command:->command' \ - '*::options:->options' + _arguments -C \ + ':command:->command' \ + '*::options:->options' - case $state in - (command) + case $state in + (command) - local -a subcommands - subcommands=( - 'start:Start a new hotfix branch.' - 'finish:Finish a hotfix branch.' - 'delete:Delete a hotfix branch.' - 'list:List all your hotfix branches. (Alias to `git flow hotfix`)' - ) - _describe -t commands 'git flow hotfix' subcommands - _arguments \ - -v'[Verbose (more) output]' - ;; + local -a subcommands + subcommands=( + 'start:Start a new hotfix branch.' + 'finish:Finish a hotfix branch.' + 'delete:Delete a hotfix branch.' + 'rebase:Rebase from integration branch.' + 'list:List all your hotfix branches. (Alias to `git flow hotfix`)' + 'rename:Rename a hotfix branch.' + ) + _describe -t commands 'git flow hotfix' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; - (options) - case $line[1] in + (options) + case $line[1] in - (start) - _arguments \ - -F'[Fetch from origin before performing finish]'\ - ':hotfix:__git_flow_version_list'\ - ':branch-name:__git_branch_names' - ;; + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':hotfix:__git_flow_version_list'\ + ':branch-name:__git_branch_names' + ;; - (finish) - _arguments \ - -F'[Fetch from origin before performing finish]' \ - -s'[Sign the release tag cryptographically]'\ - -u'[Use the given GPG-key for the digital signature (implies -s)]'\ - -m'[Use the given tag message]'\ - -p'[Push to $ORIGIN after performing finish]'\ - ':hotfix:__git_flow_hotfix_list' - ;; + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -s'[Sign the release tag cryptographically]'\ + -u'[Use the given GPG-key for the digital signature (implies -s)]'\ + -m'[Use the given tag message]'\ + -p'[Push to $ORIGIN after performing finish]'\ + ':hotfix:__git_flow_hotfix_list' + ;; - (delete) - _arguments \ - -f'[Force deletion]' \ - -r'[Delete remote branch]' \ - ':hotfix:__git_flow_hotfix_list' - ;; + (delete) + _arguments \ + -f'[Force deletion]' \ + -r'[Delete remote branch]' \ + ':hotfix:__git_flow_hotfix_list' + ;; - *) - _arguments \ - -v'[Verbose (more) output]' - ;; - esac - ;; - esac + (rebase) + _arguments \ + -i'[Do an interactive rebase]' \ + ':branch:__git_branch_names' + ;; + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac } __git-flow-feature () { - local curcontext="$curcontext" state line - typeset -A opt_args + local curcontext="$curcontext" state line + typeset -A opt_args - _arguments -C \ - ':command:->command' \ - '*::options:->options' + _arguments -C \ + ':command:->command' \ + '*::options:->options' - case $state in - (command) + case $state in + (command) - local -a subcommands - subcommands=( - 'start:Start a new feature branch.' - 'finish:Finish a feature branch.' - 'delete:Delete a feature branch.' - 'list:List all your feature branches. (Alias to `git flow feature`)' - 'publish:Publish feature branch to remote.' - 'track:Checkout remote feature branch.' - 'diff:Show all changes.' - 'rebase:Rebase from integration branch.' - 'checkout:Checkout local feature branch.' - 'pull:Pull changes from remote.' - ) - _describe -t commands 'git flow feature' subcommands - _arguments \ - -v'[Verbose (more) output]' - ;; + local -a subcommands + subcommands=( + 'start:Start a new feature branch.' + 'finish:Finish a feature branch.' + 'delete:Delete a feature branch.' + 'list:List all your feature branches. (Alias to `git flow feature`)' + 'publish:Publish feature branch to remote.' + 'track:Checkout remote feature branch.' + 'diff:Show all changes.' + 'rebase:Rebase from integration branch.' + 'checkout:Checkout local feature branch.' + 'pull:Pull changes from remote.' + 'rename:Rename a feature branch.' + ) + _describe -t commands 'git flow feature' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; - (options) - case $line[1] in + (options) + case $line[1] in - (start) - _arguments \ - -F'[Fetch from origin before performing finish]'\ - ':feature:__git_flow_feature_list'\ - ':branch-name:__git_branch_names' - ;; + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':feature:__git_flow_feature_list'\ + ':branch-name:__git_branch_names' + ;; - (finish) - _arguments \ - -F'[Fetch from origin before performing finish]' \ - -r'[Rebase instead of merge]'\ - ':feature:__git_flow_feature_list' - ;; + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -r'[Rebase instead of merge]'\ + ':feature:__git_flow_feature_list' + ;; - (delete) - _arguments \ - -f'[Force deletion]' \ - -r'[Delete remote branch]' \ - ':feature:__git_flow_feature_list' - ;; + (delete) + _arguments \ + -f'[Force deletion]' \ + -r'[Delete remote branch]' \ + ':feature:__git_flow_feature_list' + ;; - (publish) - _arguments \ - ':feature:__git_flow_feature_list'\ - ;; + (publish) + _arguments \ + ':feature:__git_flow_feature_list'\ + ;; - (track) - _arguments \ - ':feature:__git_flow_feature_list'\ - ;; + (track) + _arguments \ + ':feature:__git_flow_feature_list'\ + ;; - (diff) - _arguments \ - ':branch:__git_branch_names'\ - ;; + (diff) + _arguments \ + ':branch:__git_branch_names'\ + ;; - (rebase) - _arguments \ - -i'[Do an interactive rebase]' \ - ':branch:__git_branch_names' - ;; + (rebase) + _arguments \ + -i'[Do an interactive rebase]' \ + ':branch:__git_branch_names' + ;; - (checkout) - _arguments \ - ':branch:__git_flow_feature_list'\ - ;; + (checkout) + _arguments \ + ':branch:__git_flow_feature_list'\ + ;; - (pull) - _arguments \ - ':remote:__git_remotes'\ - ':branch:__git_branch_names' - ;; + (pull) + _arguments \ + ':remote:__git_remotes'\ + ':branch:__git_branch_names' + ;; - *) - _arguments \ - -v'[Verbose (more) output]' - ;; - esac - ;; - esac + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac +} + +__git-flow-bugfix () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'start:Start a new bugfix branch.' + 'finish:Finish a bugfix branch.' + 'delete:Delete a bugfix branch.' + 'list:List all your bugfix branches. (Alias to `git flow bugfix`)' + 'publish:Publish bugfix branch to remote.' + 'track:Checkout remote bugfix branch.' + 'diff:Show all changes.' + 'rebase:Rebase from integration branch.' + 'checkout:Checkout local bugfix branch.' + 'pull:Pull changes from remote.' + 'rename:Rename a bugfix branch.' + ) + _describe -t commands 'git flow bugfix' subcommands + _arguments \ + -v'[Verbose (more) output]' + ;; + + (options) + case $line[1] in + + (start) + _arguments \ + -F'[Fetch from origin before performing finish]'\ + ':bugfix:__git_flow_bugfix_list'\ + ':branch-name:__git_branch_names' + ;; + + (finish) + _arguments \ + -F'[Fetch from origin before performing finish]' \ + -r'[Rebase instead of merge]'\ + ':bugfix:__git_flow_bugfix_list' + ;; + + (delete) + _arguments \ + -f'[Force deletion]' \ + -r'[Delete remote branch]' \ + ':bugfix:__git_flow_bugfix_list' + ;; + + (publish) + _arguments \ + ':bugfix:__git_flow_bugfix_list'\ + ;; + + (track) + _arguments \ + ':bugfix:__git_flow_bugfix_list'\ + ;; + + (diff) + _arguments \ + ':branch:__git_branch_names'\ + ;; + + (rebase) + _arguments \ + -i'[Do an interactive rebase]' \ + ':branch:__git_branch_names' + ;; + + (checkout) + _arguments \ + ':branch:__git_flow_bugfix_list'\ + ;; + + (pull) + _arguments \ + ':remote:__git_remotes'\ + ':branch:__git_branch_names' + ;; + + *) + _arguments \ + -v'[Verbose (more) output]' + ;; + esac + ;; + esac } __git-flow-config () { - local curcontext="$curcontext" state line - typeset -A opt_args + local curcontext="$curcontext" state line + typeset -A opt_args - _arguments -C \ - ':command:->command' \ - '*::options:->options' + _arguments -C \ + ':command:->command' \ + '*::options:->options' - case $state in - (command) + case $state in + (command) - local -a subcommands - subcommands=( - 'list:List the configuration. (Alias to `git flow config`)' - 'set:Set the configuration option' - ) - _describe -t commands 'git flow config' subcommands - ;; + local -a subcommands + subcommands=( + 'list:List the configuration. (Alias to `git flow config`)' + 'set:Set the configuration option' + ) + _describe -t commands 'git flow config' subcommands + ;; - (options) - case $line[1] in + (options) + case $line[1] in - (set) - _arguments \ - --local'[Use repository config file]' \ - --global'[Use global config file]'\ - --system'[Use system config file]'\ - --file'[Use given config file]'\ - ':option:(master develop feature hotfix release support versiontagprefix)' - ;; + (set) + _arguments \ + --local'[Use repository config file]' \ + --global'[Use global config file]'\ + --system'[Use system config file]'\ + --file'[Use given config file]'\ + ':option:(master develop feature hotfix release support versiontagprefix)' + ;; - *) - _arguments \ - --local'[Use repository config file]' \ - --global'[Use global config file]'\ - --system'[Use system config file]'\ - --file'[Use given config file]' - ;; - esac - ;; - esac + *) + _arguments \ + --local'[Use repository config file]' \ + --global'[Use global config file]'\ + --system'[Use system config file]'\ + --file'[Use given config file]' + ;; + esac + ;; + esac } __git_flow_version_list () { - local expl - declare -a versions + local expl + declare -a versions - versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}}) - __git_command_successful || return + versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return - _wanted versions expl 'version' compadd $versions + _wanted versions expl 'version' compadd $versions } __git_flow_feature_list () { - local expl - declare -a features + local expl + declare -a features - features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}}) - __git_command_successful || return + features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return - _wanted features expl 'feature' compadd $features + _wanted features expl 'feature' compadd $features +} + +__git_flow_bugfix_list () +{ + local expl + declare -a bugfixes + + bugfixes=(${${(f)"$(_call_program bugfixes git flow bugfix list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return + + _wanted bugfixes expl 'bugfix' compadd $bugfixes } __git_remotes () { - local expl gitdir remotes + local expl gitdir remotes - gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) - __git_command_successful || return + gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) + __git_command_successful || return - remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) - __git_command_successful || return + remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) + __git_command_successful || return - # TODO: Should combine the two instead of either or. - if (( $#remotes > 0 )); then - _wanted remotes expl remote compadd $* - $remotes - else - _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" - fi + # TODO: Should combine the two instead of either or. + if (( $#remotes > 0 )); then + _wanted remotes expl remote compadd $* - $remotes + else + _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" + fi } __git_flow_hotfix_list () { - local expl - declare -a hotfixes + local expl + declare -a hotfixes - hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}}) - __git_command_successful || return + hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}}) + __git_command_successful || return - _wanted hotfixes expl 'hotfix' compadd $hotfixes + _wanted hotfixes expl 'hotfix' compadd $hotfixes } __git_branch_names () { - local expl - declare -a branch_names + local expl + declare -a branch_names - branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) - __git_command_successful || return + branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) + __git_command_successful || return - _wanted branch-names expl branch-name compadd $* - $branch_names + _wanted branch-names expl branch-name compadd $* - $branch_names } __git_command_successful () { - if (( ${#pipestatus:#0} > 0 )); then - _message 'not a git repository' - return 1 - fi - return 0 + if (( ${#pipestatus:#0} > 0 )); then + _message 'not a git repository' + return 1 + fi + return 0 } zstyle ':completion:*:*:git:*' user-commands flow:'provide high-level repository operations' diff --git a/plugins/git-flow/README.md b/plugins/git-flow/README.md index f37f418db..5d8049e3b 100644 --- a/plugins/git-flow/README.md +++ b/plugins/git-flow/README.md @@ -10,22 +10,23 @@ plugins=(... git-flow) ## Aliases -More information about `git-flow` commands: +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 ` | -| `gflhs` | `git flow hotfix start` | Start a new hotfix: `gflhs ` | -| `gflrs` | `git flow release start` | Start a new release: `gflrs ` | -| `gflff` | `git flow feature finish` | Finish feature: `gflff ` | -| `gflhf` | `git flow hotfix finish` | Finish hotfix: `gflhf ` | -| `gflrf` | `git flow release finish` | Finish release: `gflrf ` | +| 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 ` | +| `gflhs` | `git flow hotfix start` | Start a new hotfix: `gflhs ` | +| `gflrs` | `git flow release start` | Start a new release: `gflrs ` | +| `gflff` | `git flow feature finish` | Finish feature: `gflff ` | +| `gflfp` | `git flow feature publish` | Publish feature: `gflfp ` | +| `gflhf` | `git flow hotfix finish` | Finish hotfix: `gflhf ` | +| `gflrf` | `git flow release finish` | Finish release: `gflrf ` | diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh index bda050725..eab969d8a 100644 --- a/plugins/git-flow/git-flow.plugin.zsh +++ b/plugins/git-flow/git-flow.plugin.zsh @@ -33,8 +33,13 @@ 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 gflfp='git flow feature publish' alias gflhf='git flow hotfix finish' alias gflrf='git flow release finish' +alias gflfp='git flow feature publish' +alias gflhp='git flow hotfix publish' +alias gflrp='git flow release publish' +alias gflfpll='git flow feature pull' _git-flow () { diff --git a/plugins/git-hubflow/README.md b/plugins/git-hubflow/README.md new file mode 100644 index 000000000..dada60d78 --- /dev/null +++ b/plugins/git-hubflow/README.md @@ -0,0 +1,24 @@ +# git-hubflow plugin + +This plugin adds completion for [HubFlow](https://datasift.github.io/gitflow/) (GitFlow for GitHub), as well as some +aliases for common commands. HubFlow is a git extension to make it easy to use GitFlow with GitHub. Based on the +original gitflow extension for git. + +The hubflow tool has to be [installed](https://github.com/datasift/gitflow#installation) separately. + +To use it, add `git-hubflow` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-hubflow) +``` + +## Aliases + +| Alias | Command | Description | +|-------|------------------|------------------------------------------------------------------| +| ghf | `git hf` | Print command overview | +| ghff | `git hf feature` | Manage your feature branches | +| ghfr | `git hf release` | Manage your release branches | +| ghfh | `git hf hotfix` | Manage your hotfix branches | +| ghfs | `git hf support` | Manage your support branches | +| ghfu | `git hf update` | Pull upstream changes down into your master and develop branches | diff --git a/plugins/git-hubflow/git-hubflow.plugin.zsh b/plugins/git-hubflow/git-hubflow.plugin.zsh index b0157c7a1..50d7b23ce 100644 --- a/plugins/git-hubflow/git-hubflow.plugin.zsh +++ b/plugins/git-hubflow/git-hubflow.plugin.zsh @@ -1,25 +1,3 @@ -#!zsh -# -# Installation -# ------------ -# -# To achieve git-hubflow completion nirvana: -# -# 0. Update your zsh's git-completion module to the newest version. -# From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD -# -# 1. Install this file. Either: -# -# a. Place it in your .zshrc: -# -# b. Or, copy it somewhere (e.g. ~/.git-hubflow-completion.zsh) and put the following line in -# your .zshrc: -# -# source ~/.git-hubflow-completion.zsh -# -# c. Or, use this file as an oh-my-zsh plugin. -# - alias ghf='git hf' alias ghff='git hf feature' alias ghfr='git hf release' @@ -97,8 +75,8 @@ __git-hf-release () 'finish:Finish a release branch.' 'list:List all your release branches. (Alias to `git hf release`)' 'cancel:Cancel release' - 'push:Push release to github' - 'pull:Pull release from github' + 'push:Push release to GitHub' + 'pull:Pull release from GitHub' 'track:Track release' ) _describe -t commands 'git hf release' subcommands @@ -155,8 +133,8 @@ __git-hf-hotfix () 'list:List all your hotfix branches. (Alias to `git hf hotfix`)' 'publish:Publish the hotfix branch.' 'track:Track the hotfix branch.' - 'pull:Pull the hotfix from github.' - 'push:Push the hotfix to github.' + 'pull:Pull the hotfix from GitHub.' + 'push:Push the hotfix to GitHub.' 'cancel:Cancel the hotfix.' ) _describe -t commands 'git hf hotfix' subcommands @@ -217,8 +195,8 @@ __git-hf-feature () 'diff:Diff' 'rebase:Rebase feature branch against develop' 'checkout:Checkout feature' - 'pull:Pull feature branch from github' - 'push:Push feature branch to github' + 'pull:Pull feature branch from GitHub' + 'push:Push feature branch to GitHub' 'cancel:Cancel feature' ) _describe -t commands 'git hf feature' subcommands diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md new file mode 100644 index 000000000..e3b2d623a --- /dev/null +++ b/plugins/git-prompt/README.md @@ -0,0 +1,61 @@ +# git-prompt plugin + +A `zsh` prompt that displays information about the current git repository. In particular: +the branch name, difference with remote branch, number of files staged or changed, etc. + +To use it, add `git-prompt` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-prompt) +``` + +See the [original repository](https://github.com/olivierverdier/zsh-git-prompt). + +## Examples + +The prompt may look like the following: + +- `(master↑3|✚1)`: on branch `master`, ahead of remote by 3 commits, 1 file changed but not staged +- `(status|●2)`: on branch `status`, 2 files staged +- `(master|✚7…)`: on branch `master`, 7 files changed, some files untracked +- `(master|✖2✚3)`: on branch `master`, 2 conflicts, 3 files changed +- `(experimental↓2↑3|✔)`: on branch `experimental`; your branch has diverged by 3 commits, remote by 2 commits; the repository is otherwise clean +- `(:70c2952|✔)`: not on any branch; parent commit has hash `70c2952`; the repository is otherwise clean + +## Prompt Structure + +By default, the general appearance of the prompt is: + +``` +(|) +``` + +The symbols are as follows: + +### Local Status Symbols + +| Symbol | Meaning | +|--------|--------------------------------| +| ✔ | repository clean | +| ●n | there are `n` staged files | +| ✖n | there are `n` unmerged files | +| ✚n | there are `n` unstaged files | +| … | there are some untracked files | + +### Branch Tracking Symbols + +| Symbol | Meaning | +|--------|---------------------------------------------------------------| +| ↑n | ahead of remote by `n` commits | +| ↓n | behind remote by `n` commits | +| ↓m↑n | branches diverged: other by `m` commits, yours by `n` commits | + +## Customisation + +- Set the variable `ZSH_THEME_GIT_PROMPT_CACHE` to any value in order to enable caching. +- You may also change a number of variables (whose name start with `ZSH_THEME_GIT_PROMPT_`) + to change the appearance of the prompt. Take a look at the bottom of the [plugin file](git-prompt.plugin.zsh)` + to see what variables are available. + + +**Enjoy!** diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 5175bf70f..76ac2e62b 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,6 +1,3 @@ -# ZSH Git Prompt Plugin from: -# http://github.com/olivierverdier/zsh-git-prompt - __GIT_PROMPT_DIR="${0:A:h}" ## Hook function definitions diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index a8eb8284b..390a50a6f 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +import os import sys import re import shlex @@ -22,7 +23,7 @@ def get_tagname_or_hash(): tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1] if tagname: - return tagname + return tagname.replace(' ', '') elif hash_: return hash_ return None @@ -30,7 +31,7 @@ def get_tagname_or_hash(): # `git status --porcelain --branch` can collect all information # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind -po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) +po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE) stdout, sterr = po.communicate() if po.returncode != 0: sys.exit(0) # Not a git repository @@ -41,7 +42,7 @@ ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': - if re.search('Initial commit on', st[2]): + if re.search('Initial commit on', st[2]) or re.search('No commits yet on', st[2]): branch = st[2].split(' ')[-1] elif re.search('no branch', st[2]): # detached status branch = get_tagname_or_hash() diff --git a/plugins/git-remote-branch/README.md b/plugins/git-remote-branch/README.md new file mode 100644 index 000000000..bd73e5dec --- /dev/null +++ b/plugins/git-remote-branch/README.md @@ -0,0 +1,14 @@ +# git-remote-branch plugin + +This plugin adds completion for [`grb`](https://github.com/webmat/git_remote_branch), +or `git_remote_branch`. + +To use it, add `git-remote-branch` to the plugins array of your `.zshrc` file: +``` +plugins=(... git-remote-branch) +``` + +## Deprecation + +[git_remote_branch was archived in 2018](https://github.com/webmat/git_remote_branch#archived), +meaning it's not actively maintained anymore. Use at your own risk. diff --git a/plugins/git/README.md b/plugins/git/README.md index 76da2a8ae..7878f747b 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -1,10 +1,216 @@ -## git +# git plugin -**Maintainer:** [@ncanceill](https://github.com/ncanceill) +The git plugin provides many [aliases](#aliases) and a few useful [functions](#functions). -This plugin adds many useful aliases and functions. +To use it, add `git` to the plugins array in your zshrc file: -### Usage +```zsh +plugins=(... git) +``` -See the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git) for a list of aliases and functions provided by the plugin. +## Aliases +| Alias | Command | +|:---------------------|:------------------------------------------------------------------------------------------------------------------------------| +| g | git | +| ga | git add | +| gaa | git add --all | +| gapa | git add --patch | +| gau | git add --update | +| gav | git add --verbose | +| gap | git apply | +| gb | git branch | +| gba | git branch -a | +| gbd | git branch -d | +| gbda | git branch --no-color --merged \| command grep -vE "^(\+|\*\|\s*(master\|develop\|dev)\s*$)" \| command xargs -n 1 git branch -d | +| gbD | git branch -D | +| gbl | git blame -b -w | +| gbnm | git branch --no-merged | +| gbr | git branch --remote | +| gbs | git bisect | +| gbsb | git bisect bad | +| gbsg | git bisect good | +| gbsr | git bisect reset | +| gbss | git bisect start | +| gc | git commit -v | +| gc! | git commit -v --amend | +| gcn! | git commit -v --no-edit --amend | +| gca | git commit -v -a | +| gca! | git commit -v -a --amend | +| gcan! | git commit -v -a --no-edit --amend | +| gcans! | git commit -v -a -s --no-edit --amend | +| gcam | git commit -a -m | +| gcsm | git commit -s -m | +| gcb | git checkout -b | +| gcf | git config --list | +| gcl | git clone --recurse-submodules | +| gclean | git clean -id | +| gpristine | git reset --hard && git clean -dfx | +| gcm | git checkout master | +| gcd | git checkout develop | +| gcmsg | git commit -m | +| gco | git checkout | +| gcount | git shortlog -sn | +| gcp | git cherry-pick | +| gcpa | git cherry-pick --abort | +| gcpc | git cherry-pick --continue | +| gcs | git commit -S | +| gd | git diff | +| gdca | git diff --cached | +| gdcw | git diff --cached --word-diff | +| gdct | git describe --tags $(git rev-list --tags --max-count=1) | +| gds | git diff --staged | +| gdt | git diff-tree --no-commit-id --name-only -r | +| gdv | git diff -w $@ \| view - | +| gdw | git diff --word-diff | +| gf | git fetch | +| gfa | git fetch --all --prune | +| gfg | git ls-files \| grep | +| gfo | git fetch origin | +| gg | git gui citool | +| gga | git gui citool --amend | +| ggf | git push --force origin $(current_branch) | +| ggfl | git push --force-with-lease origin $(current_branch) | +| ggl | git pull origin $(current_branch) | +| ggp | git push origin $(current_branch) | +| ggpnp | ggl && ggp | +| ggpull | git pull origin "$(git_current_branch)" | +| ggpur | ggu | +| ggpush | git push origin "$(git_current_branch)" | +| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | +| ggu | git pull --rebase origin $(current_branch) | +| gpsup | git push --set-upstream origin $(git_current_branch) | +| ghh | git help | +| gignore | git update-index --assume-unchanged | +| gignored | git ls-files -v \| grep "^[[:lower:]]" | +| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk | +| gk | gitk --all --branches | +| gke | gitk --all $(git log -g --pretty=%h) | +| gl | git pull | +| glg | git log --stat | +| glgp | git log --stat -p | +| glgg | git log --graph | +| glgga | git log --graph --decorate --all | +| glgm | git log --graph --max-count=10 | +| glo | git log --oneline --decorate | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | +| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | +| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | +| glog | git log --oneline --decorate --graph | +| gloga | git log --oneline --decorate --graph --all | +| glp | `_git_log_prettily` | +| gm | git merge | +| gmom | git merge origin/master | +| gmt | git mergetool --no-prompt | +| gmtvim | git mergetool --no-prompt --tool=vimdiff | +| gmum | git merge upstream/master | +| gma | git merge --abort | +| gp | git push | +| gpd | git push --dry-run | +| gpf | git push --force-with-lease | +| gpf! | git push --force | +| gpoat | git push origin --all && git push origin --tags | +| gpu | git push upstream | +| gpv | git push -v | +| gr | git remote | +| gra | git remote add | +| grb | git rebase | +| grba | git rebase --abort | +| grbc | git rebase --continue | +| grbd | git rebase develop | +| grbi | git rebase -i | +| grbm | git rebase master | +| grbs | git rebase --skip | +| grev | git revert | +| grh | git reset | +| grhh | git reset --hard | +| groh | git reset origin/$(git_current_branch) --hard | +| grm | git rm | +| grmc | git rm --cached | +| grmv | git remote rename | +| grrm | git remote remove | +| grs | git restore | +| grset | git remote set-url | +| grss | git restore --source | +| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | +| gru | git reset -- | +| grup | git remote update | +| grv | git remote -v | +| gsb | git status -sb | +| gsd | git svn dcommit | +| gsh | git show | +| gsi | git submodule init | +| gsps | git show --pretty=short --show-signature | +| gsr | git svn rebase | +| gss | git status -s | +| gst | git status | +| gsta | git stash push | +| gsta | git stash save | +| gstaa | git stash apply | +| gstc | git stash clear | +| gstd | git stash drop | +| gstl | git stash list | +| gstp | git stash pop | +| gsts | git stash show --text | +| gstall | git stash --all | +| gsu | git submodule update | +| gsw | git switch | +| gswc | git switch -c | +| gts | git tag -s | +| gtv | git tag \| sort -V | +| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | +| gunignore | git update-index --no-assume-unchanged | +| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | +| gup | git pull --rebase | +| gupv | git pull --rebase -v | +| gupa | git pull --rebase --autostash | +| gupav | git pull --rebase --autostash -v | +| glum | git pull upstream master | +| gwch | git whatchanged -p --abbrev-commit --pretty=medium | +| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | + +### Deprecated + +These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. + +| Alias | Command | Modification | +| :----- | :----------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------- | +| gap | git add --patch | new alias `gapa` | +| gcl | git config --list | new alias `gcf` | +| gdc | git diff --cached | new alias `gdca` | +| gdt | git difftool | no replacement | +| ggpull | git pull origin $(current_branch) | new alias `ggl` (`ggpull` still exists for now though) | +| ggpur | git pull --rebase origin $(current_branch) | new alias `ggu` (`ggpur` still exists for now though) | +| ggpush | git push origin $(current_branch) | new alias `ggp` (`ggpush` still exists for now though) | +| gk | gitk --all --branches | now aliased to `gitk --all --branches` | +| glg | git log --stat --max-count = 10 | now aliased to `git log --stat --color` | +| glgg | git log --graph --max-count = 10 | now aliased to `git log --graph --color` | +| gwc | git whatchanged -p --abbrev-commit --pretty = medium | new alias `gwch` | + +## Functions + +### Current + +| Command | Description | +|:-----------------------|:----------------------------------------| +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | + +### Work in Progress (WIP) + +These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it. + +| Command | Description | +|:-----------------|:------------------------------------------------| +| work_in_progress | Echoes a warning if the current branch is a wip | +| gwip | Commit wip branch | +| gunwip | Uncommit wip branch | + +### Deprecated + +| Command | Description | Reason | +|:-----------------------|:----------------------------------------|:----------------------------------------------------------------| +| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 25da03509..d8c4cffd1 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -1,7 +1,3 @@ -# Query/use custom command for `git`. -zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd -: ${_omz_git_git_cmd:=git} - # # Functions # @@ -13,19 +9,15 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd function current_branch() { git_current_branch } -# The list of remotes -function current_repository() { - if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then - return - fi - echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2) -} + # Pretty log messages function _git_log_prettily(){ if ! [ -z $1 ]; then git log --pretty=$1 fi } +compdef _git _git_log_prettily=git-log + # Warn if the current branch is a WIP function work_in_progress() { if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then @@ -43,11 +35,15 @@ alias g='git' alias ga='git add' alias gaa='git add --all' alias gapa='git add --patch' +alias gau='git add --update' +alias gav='git add --verbose' +alias gap='git apply' alias gb='git branch' alias gba='git branch -a' alias gbd='git branch -d' -alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' +alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' +alias gbD='git branch -D' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' @@ -65,17 +61,17 @@ alias gca!='git commit -v -a --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 gcl='git clone --recurse-submodules' +alias gclean='git clean -id' 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 alias gcp='git cherry-pick' alias gcpa='git cherry-pick --abort' alias gcpc='git cherry-pick --continue' @@ -83,30 +79,36 @@ 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 gdcw='git diff --cached --word-diff' +alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' +alias gds='git diff --staged' alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdw='git diff --word-diff' -gdv() { git diff -w "$@" | view - } +function gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff alias gf='git fetch' alias gfa='git fetch --all --prune' alias gfo='git fetch origin' -function gfg() { git ls-files | grep $@ } -compdef _grep gfg +alias gfg='git ls-files | grep' alias gg='git gui citool' alias gga='git gui citool --amend' -ggf() { +function ggf() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git push --force origin "${b:=$1}" } compdef _git ggf=git-checkout +function ggfl() { + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git push --force-with-lease origin "${b:=$1}" +} +compdef _git ggfl=git-checkout -ggl() { +function ggl() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git pull origin "${*}" else @@ -116,7 +118,7 @@ ggl() { } compdef _git ggl=git-checkout -ggp() { +function ggp() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git push origin "${*}" else @@ -126,7 +128,7 @@ ggp() { } compdef _git ggp=git-checkout -ggpnp() { +function ggpnp() { if [[ "$#" == 0 ]]; then ggl && ggp else @@ -135,20 +137,15 @@ ggpnp() { } compdef _git ggpnp=git-checkout -ggu() { +function ggu() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git pull --rebase origin "${b:=$1}" } compdef _git ggu=git-checkout alias ggpur='ggu' -compdef _git ggpur=git-checkout - -alias ggpull='git pull origin $(git_current_branch)' -compdef _git ggpull=git-checkout - -alias ggpush='git push origin $(git_current_branch)' -compdef _git ggpush=git-checkout +alias ggpull='git pull origin "$(git_current_branch)"' +alias ggpush='git push origin "$(git_current_branch)"' alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' alias gpsup='git push --set-upstream origin $(git_current_branch)' @@ -158,12 +155,9 @@ 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 alias gk='\gitk --all --branches' -compdef _git gk='gitk' alias gke='\gitk --all $(git log -g --pretty=%h)' -compdef _git gke='gitk' alias gl='git pull' alias glg='git log --stat' @@ -172,23 +166,27 @@ alias glgg='git log --graph' alias glgga='git log --graph --decorate --all' alias glgm='git log --graph --max-count=10' alias glo='git log --oneline --decorate' -alias glol="git log --graph --pretty='%Cred%h%Creset -%C(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 glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" +alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat" +alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'" +alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short" +alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all" alias glog='git log --oneline --decorate --graph' alias gloga='git log --oneline --decorate --graph --all' alias glp="_git_log_prettily" -compdef _git glp=git-log alias gm='git merge' alias gmom='git merge origin/master' alias gmt='git mergetool --no-prompt' alias gmtvim='git mergetool --no-prompt --tool=vimdiff' alias gmum='git merge upstream/master' +alias gma='git merge --abort' alias gp='git push' alias gpd='git push --dry-run' +alias gpf='git push --force-with-lease' +alias gpf!='git push --force' alias gpoat='git push origin --all && git push origin --tags' -compdef _git gpoat=git-push alias gpu='git push upstream' alias gpv='git push -v' @@ -197,43 +195,63 @@ alias gra='git remote add' alias grb='git rebase' alias grba='git rebase --abort' alias grbc='git rebase --continue' +alias grbd='git rebase develop' alias grbi='git rebase -i' alias grbm='git rebase master' alias grbs='git rebase --skip' -alias grh='git reset HEAD' -alias grhh='git reset HEAD --hard' +alias grev='git revert' +alias grh='git reset' +alias grhh='git reset --hard' +alias groh='git reset origin/$(git_current_branch) --hard' +alias grm='git rm' +alias grmc='git rm --cached' alias grmv='git remote rename' alias grrm='git remote remove' +alias grs='git restore' alias grset='git remote set-url' -alias grt='cd $(git rev-parse --show-toplevel || echo ".")' +alias grss='git restore --source' +alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' alias gru='git reset --' alias grup='git remote update' alias grv='git remote -v' alias gsb='git status -sb' alias gsd='git svn dcommit' +alias gsh='git show' alias gsi='git submodule init' alias gsps='git show --pretty=short --show-signature' alias gsr='git svn rebase' alias gss='git status -s' alias gst='git status' -alias gsta='git stash save' + +# use the default stash push on git 2.13 and newer +autoload -Uz is-at-least +is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \ + && alias gsta='git stash push' \ + || alias gsta='git stash save' + alias gstaa='git stash apply' alias gstc='git stash clear' alias gstd='git stash drop' alias gstl='git stash list' alias gstp='git stash pop' alias gsts='git stash show --text' +alias gstall='git stash --all' alias gsu='git submodule update' +alias gsw='git switch' +alias gswc='git switch -c' alias gts='git tag -s' alias gtv='git tag | sort -V' +alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' alias gunignore='git update-index --no-assume-unchanged' alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' alias gup='git pull --rebase' alias gupv='git pull --rebase -v' +alias gupa='git pull --rebase --autostash' +alias gupav='git pull --rebase --autostash -v' alias glum='git pull upstream master' alias 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 --no-gpg-sign -m "--wip-- [skip ci]"' diff --git a/plugins/gitfast/README.md b/plugins/gitfast/README.md new file mode 100644 index 000000000..84e35d77c --- /dev/null +++ b/plugins/gitfast/README.md @@ -0,0 +1,15 @@ +# Gitfast plugin + +This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version.. + +To use it, add `gitfast` to the plugins array in your zshrc file: + +```zsh +plugins=(... gitfast) +``` + +## Aliases + +An earlier version of the plugin also loaded the git plugin. If you want to keep those +aliases enable the [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git) +as well. diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git index 6d1b4ecc7..886bf95d1 100644 --- a/plugins/gitfast/_git +++ b/plugins/gitfast/_git @@ -9,7 +9,7 @@ # # If your script is somewhere else, you can configure it on your ~/.zshrc: # -# zstyle ':completion:*:*:git:*' script ~/.git-completion.sh +# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh # # The recommended way to install this script is to copy to '~/.zsh/_git', and # then add the following to your ~/.zshrc file: @@ -30,7 +30,7 @@ if [ -z "$script" ]; then local -a locations local e locations=( - "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash" + $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash '/etc/bash_completion.d/git' # fedora, old debian '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian '/usr/share/bash-completion/git' # gentoo @@ -39,7 +39,7 @@ if [ -z "$script" ]; then test -f $e && script="$e" && break done fi -ZSH_VERSION='' . "$script" +GIT_SOURCING_ZSH_COMPLETION=y . "$script" __gitcomp () { @@ -67,6 +67,15 @@ __gitcomp () esac } +__gitcomp_direct () +{ + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -- ${=1} && _ret=0 +} + __gitcomp_nl () { emulate -L zsh @@ -84,13 +93,22 @@ __gitcomp_nl_append () compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } +__gitcomp_file_direct () +{ + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -f -- ${=1} && _ret=0 +} + __gitcomp_file () { emulate -L zsh local IFS=$'\n' compset -P '*[=:]' - compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 + compadd -p "${2-}" -f -- ${=1} && _ret=0 } __git_zsh_bash_func () @@ -214,10 +232,8 @@ _git () if (( $+functions[__${service}_zsh_main] )); then __${service}_zsh_main - elif (( $+functions[__${service}_main] )); then + else 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 e3918c87e..e087c4bf0 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -28,27 +28,58 @@ # completion style. For example '!f() { : git commit ; ... }; f' will # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". +# +# Compatible with bash 3.2.57. +# +# You can set the following environment variables to influence the behavior of +# the completion routines: +# +# GIT_COMPLETION_CHECKOUT_NO_GUESS +# +# When set to "1", do not include "DWIM" suggestions in git-checkout +# and git-switch completion (e.g., completing "foo" when "origin/foo" +# exists). case "$COMP_WORDBREAKS" in *:*) : great ;; *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" esac +# Discovers the path to the git repository taking any '--git-dir=' and +# '-C ' options into account and stores it in the $__git_repo_path +# variable. +__git_find_repo_path () +{ + if [ -n "$__git_repo_path" ]; then + # we already know where it is + return + fi + + if [ -n "${__git_C_args-}" ]; then + __git_repo_path="$(git "${__git_C_args[@]}" \ + ${__git_dir:+--git-dir="$__git_dir"} \ + rev-parse --absolute-git-dir 2>/dev/null)" + elif [ -n "${__git_dir-}" ]; then + test -d "$__git_dir" && + __git_repo_path="$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" && + __git_repo_path="$GIT_DIR" + elif [ -d .git ]; then + __git_repo_path=.git + else + __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" + fi +} + +# Deprecated: use __git_find_repo_path() and $__git_repo_path instead # __gitdir accepts 0 or 1 arguments (i.e., location) # returns location of .git repo __gitdir () { if [ -z "${1-}" ]; then - if [ -n "${__git_dir-}" ]; then - echo "$__git_dir" - elif [ -n "${GIT_DIR-}" ]; then - test -d "${GIT_DIR-}" || return 1 - echo "$GIT_DIR" - elif [ -d .git ]; then - echo .git - else - git rev-parse --git-dir 2>/dev/null - fi + __git_find_repo_path || return 1 + echo "$__git_repo_path" elif [ -d "$1/.git" ]; then echo "$1/.git" else @@ -56,6 +87,78 @@ __gitdir () fi } +# Runs git with all the options given as argument, respecting any +# '--git-dir=' and '-C ' options present on the command line +__git () +{ + git ${__git_C_args:+"${__git_C_args[@]}"} \ + ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null +} + +# Removes backslash escaping, single quotes and double quotes from a word, +# stores the result in the variable $dequoted_word. +# 1: The word to dequote. +__git_dequote () +{ + local rest="$1" len ch + + dequoted_word="" + + while test -n "$rest"; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + $'\n') + ;; + *) + dequoted_word="$dequoted_word$ch" + ;; + esac + rest="${rest:2}" + ;; + \') + rest="${rest:1}" + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%\'*}" + rest="${rest:$((${#dequoted_word}-$len+1))}" + ;; + \") + rest="${rest:1}" + while test -n "$rest" ; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + \"|\\|\$|\`) + dequoted_word="$dequoted_word$ch" + ;; + $'\n') + ;; + *) + dequoted_word="$dequoted_word\\$ch" + ;; + esac + rest="${rest:2}" + ;; + \") + rest="${rest:1}" + break + ;; + esac + done + ;; + esac + done +} + # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ @@ -75,8 +178,7 @@ __gitdir () # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# along with this program; if not, see . # # The latest version of this software can be obtained here: # @@ -185,6 +287,20 @@ _get_comp_words_by_ref () } fi +# Fills the COMPREPLY array with prefiltered words without any additional +# processing. +# Callers must take care of providing only words that match the current word +# to be completed and adding any prefix and/or suffix (trailing space!), if +# necessary. +# 1: List of newline-separated matching completion words, complete with +# prefix and suffix. +__gitcomp_direct () +{ + local IFS=$'\n' + + COMPREPLY=($1) +} + __gitcompappend () { local x i=${#COMPREPLY[@]} @@ -215,9 +331,32 @@ __gitcomp () case "$cur_" in --*=) ;; + --no-*) + local c i=0 IFS=$' \t\n' + for c in $1; do + if [[ $c == "--" ]]; then + continue + fi + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; *) local c i=0 IFS=$' \t\n' for c in $1; do + if [[ $c == "--" ]]; then + c="--no-...${4-}" + if [[ $c == "$cur_"* ]]; then + COMPREPLY[i++]="${2-}$c " + fi + break + fi c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in @@ -231,6 +370,48 @@ __gitcomp () esac } +# Clear the variables caching builtins' options when (re-)sourcing +# the completion script. +if [[ -n ${ZSH_VERSION-} ]]; then + unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null +else + unset $(compgen -v __gitcomp_builtin_) +fi + +# This function is equivalent to +# +# __gitcomp "$(git xxx --git-completion-helper) ..." +# +# except that the output is cached. Accept 1-3 arguments: +# 1: the git command to execute, this is also the cache key +# 2: extra options to be added on top (e.g. negative forms) +# 3: options to be excluded +__gitcomp_builtin () +{ + # spaces must be replaced with underscore for multi-word + # commands, e.g. "git remote add" becomes remote_add. + local cmd="$1" + local incl="$2" + local excl="$3" + + local var=__gitcomp_builtin_"${cmd/-/_}" + local options + eval "options=\$$var" + + if [ -z "$options" ]; then + # leading and trailing spaces are significant to make + # option removal work correctly. + options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return + + for i in $excl; do + options="${options/ $i / }" + done + eval "$var=\"$options\"" + fi + + __gitcomp "$options" +} + # Variation of __gitcomp_nl () that appends to the existing list of # completion candidates, COMPREPLY. __gitcomp_nl_append () @@ -254,6 +435,24 @@ __gitcomp_nl () __gitcomp_nl_append "$@" } +# Fills the COMPREPLY array with prefiltered paths without any additional +# processing. +# Callers must take care of providing only paths that match the current path +# to be completed and adding any prefix path components, if necessary. +# 1: List of newline-separated matching paths, complete with all prefix +# path components. +__gitcomp_file_direct () +{ + local IFS=$'\n' + + COMPREPLY=($1) + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + # Generates completion reply with compgen from newline-separated possible # completion filenames. # It accepts 1 to 3 arguments: @@ -273,7 +472,8 @@ __gitcomp_file () # use a hack to enable file mode in bash < 4 compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ > /dev/null + compgen -f /non-existing-dir/ >/dev/null || + true } # Execute 'git ls-files', unless the --committable option is specified, in @@ -283,11 +483,13 @@ __gitcomp_file () __git_ls_files_helper () { if [ "$2" == "--committable" ]; then - git -C "$1" diff-index --name-only --relative HEAD + __git -C "$1" -c core.quotePath=false diff-index \ + --name-only --relative HEAD -- "${3//\\/\\\\}*" else # NOTE: $2 is not quoted in order to support multiple options - git -C "$1" ls-files --exclude-standard $2 - fi 2>/dev/null + __git -C "$1" -c core.quotePath=false ls-files \ + --exclude-standard $2 -- "${3//\\/\\\\}*" + fi } @@ -297,101 +499,283 @@ __git_ls_files_helper () # If provided, only files within the specified directory are listed. # Sub directories are never recursed. Path must have a trailing # slash. +# 3: List only paths matching this path component (optional). __git_index_files () { - local dir="$(__gitdir)" root="${2-.}" file + local root="$2" match="$3" - if [ -d "$dir" ]; then - __git_ls_files_helper "$root" "$1" | - while read -r file; do - case "$file" in - ?*/*) echo "${file%%/*}" ;; - *) echo "$file" ;; - esac - done | sort | uniq - fi + __git_ls_files_helper "$root" "$1" "$match" | + awk -F / -v pfx="${2//\\/\\\\}" '{ + paths[$1] = 1 + } + END { + for (p in paths) { + if (substr(p, 1, 1) != "\"") { + # No special characters, easy! + print pfx p + continue + } + + # The path is quoted. + p = dequote(p) + if (p == "") + continue + + # Even when a directory name itself does not contain + # any special characters, it will still be quoted if + # any of its (stripped) trailing path components do. + # Because of this we may have seen the same direcory + # both quoted and unquoted. + if (p in paths) + # We have seen the same directory unquoted, + # skip it. + continue + else + print pfx p + } + } + function dequote(p, bs_idx, out, esc, esc_idx, dec) { + # Skip opening double quote. + p = substr(p, 2) + + # Interpret backslash escape sequences. + while ((bs_idx = index(p, "\\")) != 0) { + out = out substr(p, 1, bs_idx - 1) + esc = substr(p, bs_idx + 1, 1) + p = substr(p, bs_idx + 2) + + if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { + # C-style one-character escape sequence. + out = out substr("\a\b\t\v\f\r\"\\", + esc_idx, 1) + } else if (esc == "n") { + # Uh-oh, a newline character. + # We cant reliably put a pathname + # containing a newline into COMPREPLY, + # and the newline would create a mess. + # Skip this path. + return "" + } else { + # Must be a \nnn octal value, then. + dec = esc * 64 + \ + substr(p, 1, 1) * 8 + \ + substr(p, 2, 1) + out = out sprintf("%c", dec) + p = substr(p, 3) + } + } + # Drop closing double quote, if there is one. + # (There isnt any if this is a directory, as it was + # already stripped with the trailing path components.) + if (substr(p, length(p), 1) == "\"") + out = out substr(p, 1, length(p) - 1) + else + out = out p + + return out + }' } +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local dequoted_word pfx="" cur_ + + __git_dequote "$cur" + + case "$dequoted_word" in + ?*/*) + pfx="${dequoted_word%/*}/" + cur_="${dequoted_word##*/}" + ;; + *) + cur_="$dequoted_word" + esac + + __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" +} + +# Lists branches from the local repository. +# 1: A prefix to be added to each listed branch (optional). +# 2: List only branches matching this word (optional; list all branches if +# unset or empty). +# 3: A suffix to be appended to each listed branch (optional). __git_heads () { - local dir="$(__gitdir)" - if [ -d "$dir" ]; then - git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ - refs/heads - return - fi + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/heads/$cur_*" "refs/heads/$cur_*/**" } +# Lists tags from the local repository. +# Accepts the same positional parameters as __git_heads() above. __git_tags () { - local dir="$(__gitdir)" - if [ -d "$dir" ]; then - git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ - refs/tags - return - fi + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/tags/$cur_*" "refs/tags/$cur_*/**" } -# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments -# presence of 2nd argument means use the guess heuristic employed -# by checkout for tracking branches +# Lists refs from the local (by default) or from a remote repository. +# It accepts 0, 1 or 2 arguments: +# 1: The remote to list refs from (optional; ignored, if set but empty). +# Can be the name of a configured remote, a path, or a URL. +# 2: In addition to local refs, list unique branches from refs/remotes/ for +# 'git checkout's tracking DWIMery (optional; ignored, if set but empty). +# 3: A prefix to be added to each listed ref (optional). +# 4: List only refs matching this word (optional; list all refs if unset or +# empty). +# 5: A suffix to be appended to each listed ref (optional; ignored, if set +# but empty). +# +# Use __git_complete_refs() instead. __git_refs () { - local i hash dir="$(__gitdir "${1-}")" track="${2-}" + local i hash dir track="${2-}" + local list_refs_from=path remote="${1-}" local format refs - if [ -d "$dir" ]; then - case "$cur" in + local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" + local match="${4-}" + local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers + + __git_find_repo_path + dir="$__git_repo_path" + + if [ -z "$remote" ]; then + if [ -z "$dir" ]; then + return + fi + else + if __git_is_configured_remote "$remote"; then + # configured remote takes precedence over a + # local directory with the same name + list_refs_from=remote + elif [ -d "$remote/.git" ]; then + dir="$remote/.git" + elif [ -d "$remote" ]; then + dir="$remote" + else + list_refs_from=url + fi + fi + + if [ "$list_refs_from" = path ]; then + if [[ "$cur_" == ^* ]]; then + pfx="$pfx^" + fer_pfx="$fer_pfx^" + cur_=${cur_#^} + match=${match#^} + fi + case "$cur_" in refs|refs/*) format="refname" - refs="${cur%/*}" + refs=("$match*" "$match*/**") track="" ;; *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do - if [ -e "$dir/$i" ]; then echo $i; fi + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do + case "$i" in + $match*) + if [ -e "$dir/$i" ]; then + echo "$pfx$i$sfx" + fi + ;; + esac done - format="refname:short" - refs="refs/tags refs/heads refs/remotes" + format="refname:strip=2" + refs=("refs/tags/$match*" "refs/tags/$match*/**" + "refs/heads/$match*" "refs/heads/$match*/**" + "refs/remotes/$match*" "refs/remotes/$match*/**") ;; esac - git --git-dir="$dir" for-each-ref --format="%($format)" \ - $refs + __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ + "${refs[@]}" if [ -n "$track" ]; then # employ the heuristic used by git checkout # Try to find a remote branch that matches the completion word # but only output if the branch name is unique - local ref entry - git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ - "refs/remotes/" | \ - while read -r entry; do - eval "$entry" - ref="${ref#*/}" - if [[ "$ref" == "$cur"* ]]; then - echo "$ref" - fi - done | sort | uniq -u + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + --sort="refname:strip=3" \ + "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ + uniq -u fi return fi - case "$cur" in + case "$cur_" in refs|refs/*) - git ls-remote "$dir" "$cur*" 2>/dev/null | \ + __git ls-remote "$remote" "$match*" | \ while read -r hash i; do case "$i" in *^{}) ;; - *) echo "$i" ;; + *) echo "$pfx$i$sfx" ;; esac done ;; *) - echo "HEAD" - git for-each-ref --format="%(refname:short)" -- \ - "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" + if [ "$list_refs_from" = remote ]; then + case "HEAD" in + $match*) echo "${pfx}HEAD$sfx" ;; + esac + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + "refs/remotes/$remote/$match*" \ + "refs/remotes/$remote/$match*/**" + else + local query_symref + case "HEAD" in + $match*) query_symref="HEAD" ;; + esac + __git ls-remote "$remote" $query_symref \ + "refs/tags/$match*" "refs/heads/$match*" \ + "refs/remotes/$match*" | + while read -r hash i; do + case "$i" in + *^{}) ;; + refs/*) echo "$pfx${i#refs/*/}$sfx" ;; + *) echo "$pfx$i$sfx" ;; # symbolic refs + esac + done + fi ;; esac } +# Completes refs, short and long, local and remote, symbolic and pseudo. +# +# Usage: __git_complete_refs [