Commit 238d8e65a1eb2d20db0cfd84bf647b2cbfd188f0

Authored by mj
1 parent 3de415e652
Exists in master and in 2 other branches 02-merge, dev

Squashed 'repos/robbyrussell/oh-my-zsh/' changes from 1400346..599831b

599831b Merge pull request #4058 from ncanceill/plugin-git
d24196c git plugin: fix ggl to avoid empty string see https://github.com/robbyrussell/oh-my-zsh/pull/2790#issuecomment-112716330
ed6645a Fix plugin/git ggpull and ggpush backward compatibility
ab18795 Merge pull request #4002 from aliafshar/patch-1
f66a54f Add missing space causing parse error.
8921902 Merge pull request #3852 from sachin21/add_alias_of_bundle_clean
5d214af Merge pull request #3858 from muchweb/muchweb-patch-1-editor
7daf740 Merge pull request #3874 from diraol/patch-2
0665ece Merge pull request #3973 from moul/pr-boot2docker-update
31b351c Merge pull request #3947 from mkwmms/patch-1
0a8ca6a Merge pull request #3918 from cbazin/master
b55effd Merge pull request #3919 from delphij/history-extendedglob
34d3680 Merge pull request #3838 from forivall/hyphen-insensitive
3a57076 Merge pull request #3813 from ziegs/fix_gradle_tasks
628c1fe Merge pull request #3848 from tristola/master
058def3 Merge pull request #3798 from dnixx/vundle-update
5fba46a Merge pull request #3821 from tresni/fix_minimal
c0b283c Merge pull request #3833 from coopermaruyama/master
6a340d9 Merge pull request #3988 from UserTaken/docker_update
ea5ff03 Merge pull request #3759 from mikeokner/master
04c301b Merge pull request #3975 from wernerb/patch-1
a1e722d Merge pull request #3976 from rodrigoargumedo/patch-1
422db48 Merge pull request #3986 from evilhamsterman/master
3d2bf22 Merge pull request #4001 from ivanfoo/fixOddCharsOnMac
a778463 Merge pull request #3929 from GunfighterJ/GunfighterJ-patch-sublime3
78bbf7a Merge pull request #3809 from ncanceill/easymerge
c6460ef Fixed odd chars on mac for agnoster theme
a7e7982 Add mix-fast plugin (similar to rake-fast)
55b1a2b Update _docker
3d670c0 Adding quotes to git completion discovery path
4cc0a26 A paver (Python build and configuration utility) plugin
26c7adf Revert "Added migration notification for rails plugin"
8b95bdb Added github in web_search plugin.
83295ec last-working-dir working with spaces in dirnames
d0b690b use local options to set no_equals before sourcing bash completion script
9eaf511 Merge pull request #3990 from ncanceill/plugin-git
f1a43da git plugin: new/changed aliases gaa was brought back by popular demand — see #3535 gap was replaced with gapa — see #3682 gdc was replaced with gdca — see #3977
e55d84f Add reference to bundler plugin issue in README
763cef8 Add `leaves` command to `brew` completion
4b76b74 remove trash command from osx plugin
cf3fb87 Added README.md file for ForkLift plugin
81da076 Added README.md file for atom plugin
a2d7d36 Added README.md file
c28b226 Fix README.md for sst command
0e35bd4 Plugins: vi-mode: Add first README file
0f96e8e Plugins: archlinux - add basic README.
e592968 Plugins: archlinux - use command -v in favor of which
e0ce876 Plugins: apache2-macports - add README
3f92985 Added references to the `external themes` wiki page.
8eb31a6 git plugin: fix ggpnp when called without argument also allow multiple arguments for ggp and ggl aliases
81eec40 * Added header with help and information * Moved git information to left prompt, with   support for:     * +ZSH_THEME_GIT_PROMPT_UNTRACKED, MODIFIED,     STASHED, ADDED, UPSTREAM STATUS     (if applicable) * Removed right prompt * Refactored following Google's guidelines for   scripts [ http://goo.gl/oJSXH2 ]     * Using local variables where applicable
1f008b4 Update Mix complition upto 1.0.4
02c2b74 Update aliases in laravel5.plugin.zsh file
266894c Update taskwarrior.plugin.zsh
1a4dc0d Renamed 'ss' alias to 'sstat' (to avoid collision with /bin/ss).
69dee65 Fixed typo in README
8791d7e Update bgnotify.plugin.zsh
980528f fix typo
af4ffe5 adb: add more commands
c838b9a Update README.markdown
fb5b83d Fixed jump pluging to display the right mark name on 'mark . '
563e105 Added README for mercurial plugin
4ab4300 Add git to prerequisites
23ac32d add help link to install zsh
4c409b0 sublime: Make subl a function so it can be called from functions in other modules
e8ac8b9 Added support for detecting Sublime Text 3 on Arch Linux
6bec3c6 Update history-substring-search README
83c3316 Added the tugboat autocompletion plugin
f513999 git plugin: make b local in gg* functions because it leaked, and led to #3991
6ff96da git plugin: fix error msg in gwip alias because git rm will fail when no files were deleted
6c29041 git plugin: global var for git command due to issues like #3962 until a proper plugin-loading system is implemented
a570f4b git plugin: bring back olg gg aliases by popular demand, see #3972
557dc09 More run and create options
2fb3265 Only load url-quote-magic if it is available. Partially fixes #3614
25df9f3 Disable globbing when executing `zeus rake` aliases to enable use of square brackets without escaping
2d40cc0 Add git_prompt_behind and git_prompt_exists
f21a672 add kitchen completion plugin from @petere
70c4a27 Added a possibility to display the remote branch and the number of commits you are ahead or behind
41104f8 Fix homebrew directory in aws plugin.
1653545 Recognize comments by default.
a28dbc8 Move custon *.zsh file sourcing up so that they can load plugins and other things that come after.
8652fd6 added comment functionality
de56943 Improved the `_git_time_since_commit` function.
729b19c Remove docker insert command
45e3f62 Add README for httpie plugin
3cc3084 Fix typo in $VCS_CLEAN_COLOR in adben theme
a98501d Grep bug in Agnoster
d686f8a generate with 'pod --completion-script' /cc thx to @ajmccall
a2f782e updated the command list to the latest cocoapod version (0.33.0)
6a1b832 No input for Update Check defaults to Yes
b7d041c Add rdrs method to reset the database(s)
5770ad5 Set AWS_PROFILE and use existing RPROMPT
3a77433 Add new boot2docker options
4224c2a Merge pull request #3494 from AlexTalker/short-host
51e366e Merge pull request #3339 from Xophmeister/master
4c21557 Merge pull request #3320 from moul/pr-boot2docker
3e88e53 Merge pull request #2999 from nicorevin/master
dac07b2 Merge pull request #2736 from felipec/fc/gitfast
35c7b7b Merge pull request #1951 from Neal/extract-ipsw
cb89fcd Merge pull request #2836 from ptamarit/chsh-etc-shells
11c7baf Merge pull request #3651 from mcornella/batch-close-3
a449d53 Merge pull request #2790 from ncanceill/plugin-git
da21092 Merge pull request #3945 from nicolas-brousse/homebrew-plugin
1b625af Merge pull request #3952 from lbraun/patch-1
cffeefd Add installation instructions to README
cc63928 Round 3 of batch-closing obsolete issues
7f232f6 Respect $ZSH_CACHE_DIR when creating fasd's cache
9c75551 Merge pull request #3887 from jadb/add-cakephp3-plugin
7416018 Create new aliases for homebrew plugin
0c8cb11 Add sublime text 3 paths to check list
743be91 Don't leak extendedglob to global environment.
7b478d7 Detect the .venv in any parent directory of the current directory
6504a2d Add CakePHP3 plugin
4d0aca4 Differing upgrade and safe-upgrade
5b75cc7 Many updates to git plugin (see #2790)
9a5e1a0 Use $EDITOR
03b8c19 Fix 'chsh' by checking '/etc/shells' instead of using 'which'
d60d4f6 Add alias of bundle clean
83cf909 Added aliases for docker compose
d80918b add markdown extension to README
24552f0 Add readme and add new alias cfpc: paste+compile+copy
4512161 Update template zshrc with HYPHEN_INSENSITIVE
a315ddc typofix
8e8cdc0 Add coffeescript aliases: cf, cfc, cfp
66052e2 Add hyphen insensitivity
5c9c373 Fix minimal.zsh-theme's check for in_svn and add support for mercurial
551d68a Fixes gradle autocomplete. Regex did not include subproject tasks before.
7f0b577 Use the newest Vundle commands
8cf04ed Fix echo nothing if $SHORT_HOST doesn't exist.
f1d12c5 Add .ipsw to the extract plugin.
663d432 Minor cosmetic fix to minimal theme
95d5f2c [boot2docker plugin] Initial version
8a43d35 fix paclist() for non-english locales
5918d91 gitfast: back-port prompt fix
6a5c8fb gitfast: update to upstream v1.9.2

git-subtree-dir: repos/robbyrussell/oh-my-zsh
git-subtree-split: 599831b85a5fd4564ab820530e2bb45f37ca3f99

Showing 79 changed files with 2018 additions and 935 deletions Inline Diff

1 ![Oh My Zsh](https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png) 1 ![Oh My Zsh](https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png)
2 2
3 3
4 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. 4 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.
5 5
6 __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 interface with your command prompt, you'll be able 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. 6 __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 interface with your command prompt, you'll be able 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.
7 7
8 To learn more, visit http://ohmyz.sh and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on twitter. 8 To learn more, visit http://ohmyz.sh and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on twitter.
9 9
10 ## Getting Started 10 ## Getting Started
11 11
12 12
13 ### Prerequisites 13 ### Prerequisites
14 14
15 __Disclaimer:__ _Oh My Zsh works best on Mac OS X and Linux._ 15 __Disclaimer:__ _Oh My Zsh works best on Mac OS X and Linux._
16 16
17 * Unix-based operating system (Mac OS X or Linux) 17 * Unix-based operating system (Mac OS X or Linux)
18 * [Zsh](http://www.zsh.org) should be installed (v4.3.9 or more recent) 18 * [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)
19 * This is commonly pre-installed. (`zsh --version` to confirm)
20 * `curl` or `wget` should be installed 19 * `curl` or `wget` should be installed
20 * `git` should be installed
21 21
22 ### Basic Installation 22 ### Basic Installation
23 23
24 Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`. 24 Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`.
25 25
26 #### via curl 26 #### via curl
27 27
28 `curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh` 28 `sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"`
29 29
30 #### via wget 30 #### via wget
31 31
32 `wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh` 32 `sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"`
33 33
34 ## Using Oh My Zsh 34 ## Using Oh My Zsh
35 35
36 ### Plugins 36 ### Plugins
37 37
38 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. 38 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.
39 39
40 #### Enabling Plugins 40 #### Enabling Plugins
41 41
42 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. 42 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.
43 43
44 For example, this line might begin to look like... 44 For example, this line might begin to look like...
45 45
46 `plugins=(git bundler osx rake ruby)` 46 `plugins=(git bundler osx rake ruby)`
47 47
48 #### Using Plugins 48 #### Using Plugins
49 49
50 Most plugins (should! we're working on this) include a __README__, which documents how to use them. 50 Most plugins (should! we're working on this) include a __README__, which documents how to use them.
51 51
52 ### Themes 52 ### Themes
53 53
54 We'll admit it. Early in the Oh My Zsh world... we may have gotten a far 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! 54 We'll admit it. Early in the Oh My Zsh world... we may have gotten far 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!
55 55
56 #### Selecting a Theme 56 #### Selecting a Theme
57 57
58 _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)._ 58 _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)._
59 59
60 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: 60 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:
61 61
62 `ZSH_THEME="robbyrussell"` 62 `ZSH_THEME="robbyrussell"`
63 63
64 To use a different theme, simple change the value to match the name of your desired theme. For example: 64 To use a different theme, simple change the value to match the name of your desired theme. For example:
65 65
66 `ZSH_THEME="agnoster"` (this is one of the fancy ones) 66 `ZSH_THEME="agnoster"` (this is one of the fancy ones)
67 67
68 Open up a new terminal window and your prompt should look something like... 68 Open up a new terminal window and your prompt should look something like...
69 69
70 In case you did not find a suitable theme for your needs, please have a look at the wiki for [more themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes).
71
70 ## Advanced Topics 72 ## Advanced Topics
71 73
72 If you're the type that likes to get their hands dirty... these sections might resonate. 74 If you're the type that likes to get their hands dirty... these sections might resonate.
73 75
74 ### Advanced Installation 76 ### Advanced Installation
75 77
76 For those who want to install this manually and/or set custom paths. 78 For those who want to install this manually and/or set custom paths.
77 79
78 #### Custom Directory 80 #### Custom Directory
79 81
80 The default location is `~/.oh-my-zsh` (hidden in your home directory) 82 The default location is `~/.oh-my-zsh` (hidden in your home directory)
81 83
82 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: 84 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:
83 85
84 `curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh` 86 `curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh`
85 87
86 #### Manual Installation 88 #### Manual Installation
87 89
88 ##### 1. Clone the repository: 90 ##### 1. Clone the repository:
89 91
90 `git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh` 92 `git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh`
91 93
92 ##### 2. *Optionally*, backup your existing @~/.zshrc@ file: 94 ##### 2. *Optionally*, backup your existing @~/.zshrc@ file:
93 95
94 `cp ~/.zshrc ~/.zshrc.orig` 96 `cp ~/.zshrc ~/.zshrc.orig`
95 97
96 ##### 3. Create a new zsh configuration file 98 ##### 3. Create a new zsh configuration file
97 99
98 You can create a new zsh config file by copying the template that we included for you. 100 You can create a new zsh config file by copying the template that we included for you.
99 101
100 `cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc` 102 `cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc`
101 103
102 ##### 4. Change your default shell 104 ##### 4. Change your default shell
103 105
104 `chsh -s /bin/zsh` 106 `chsh -s /bin/zsh`
105 107
106 ##### 5. Initialize your new zsh configuration 108 ##### 5. Initialize your new zsh configuration
107 109
108 Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. 110 Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
109 111
110 ### Installation Problems 112 ### Installation Problems
111 113
112 If you have any hiccups installing, here are a few common fixes. 114 If you have any hiccups installing, here are a few common fixes.
113 115
114 * You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`. 116 * You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
115 * If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. 117 * If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
116 118
117 ### Custom Plugins and Themes 119 ### Custom Plugins and Themes
118 120
119 If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory. 121 If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
120 122
121 If you have many functions that go well together, you can put them as a `abcyzeae.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin. 123 If you have many functions that go well together, you can put them as a `abcyzeae.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin.
122 124
123 If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`. 125 If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
124 126
125 ## Getting Updates 127 ## Getting Updates
126 128
127 By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`: 129 By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`:
128 130
129 `DISABLE_UPDATE_PROMPT=true` 131 `DISABLE_UPDATE_PROMPT=true`
130 132
131 To disable automatic upgrades, set the following in your `~/.zshrc`: 133 To disable automatic upgrades, set the following in your `~/.zshrc`:
132 134
133 `DISABLE_AUTO_UPDATE=true` 135 `DISABLE_AUTO_UPDATE=true`
134 136
135 ### Manual Updates 137 ### Manual Updates
136 138
137 If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?)... you just need to run: 139 If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?)... you just need to run:
138 140
139 `upgrade_oh_my_zsh` 141 `upgrade_oh_my_zsh`
140 142
141 Magic! 143 Magic!
142 144
143 ## Uninstalling Oh My Zsh 145 ## Uninstalling Oh My Zsh
144 146
145 Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup. 147 Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
146 148
147 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. 149 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.
148 150
149 ## Contributing 151 ## Contributing
150 152
151 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! 153 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!
152 154
153 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. 155 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.
154 156
155 ### Do NOT Send Us Themes 157 ### Do NOT Send Us Themes
156 158
157 We have (more than) enough themes for the time being. Please fork the project and add one in there – you can let people know how to grab it from there. 159 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.
158 160
159 ## Contributors 161 ## Contributors
160 162
161 Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help from our contributors, it wouldn't be so awesome. 163 Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help from our contributors, it wouldn't be so awesome.
162 164
163 Thank you so much! 165 Thank you so much!
164 166
165 ## Follow Us 167 ## Follow Us
166 168
167 We have an [ohmyzsh](https://twitter.com/ohmyzsh) account. You should follow it. 169 We have an [ohmyzsh](https://twitter.com/ohmyzsh) account. You should follow it.
168 170
169 ## Merchandise 171 ## Merchandise
170 172
171 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! 173 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!
172 174
173 ## LICENSE 175 ## LICENSE
174 176
175 Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt). 177 Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt).
1 # fixme - the load process here seems a bit bizarre 1 # fixme - the load process here seems a bit bizarre
2 2
3 unsetopt menu_complete # do not autoselect the first completion entry 3 unsetopt menu_complete # do not autoselect the first completion entry
4 unsetopt flowcontrol 4 unsetopt flowcontrol
5 setopt auto_menu # show completion menu on succesive tab press 5 setopt auto_menu # show completion menu on succesive tab press
6 setopt complete_in_word 6 setopt complete_in_word
7 setopt always_to_end 7 setopt always_to_end
8 8
9 WORDCHARS='' 9 WORDCHARS=''
10 10
11 zmodload -i zsh/complist 11 zmodload -i zsh/complist
12 12
13 ## case-insensitive (all),partial-word and then substring completion 13 ## case-insensitive (all),partial-word and then substring completion
14 if [ "x$CASE_SENSITIVE" = "xtrue" ]; then 14 if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
15 zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' 15 zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
16 unset CASE_SENSITIVE 16 unset CASE_SENSITIVE
17 else 17 else
18 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' 18 if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then
19 zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
20 unset HYPHEN_INSENSITIVE
21 else
22 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
23 fi
19 fi 24 fi
20 25
21 zstyle ':completion:*' list-colors '' 26 zstyle ':completion:*' list-colors ''
22 27
23 # should this be in keybindings? 28 # should this be in keybindings?
24 bindkey -M menuselect '^o' accept-and-infer-next-history 29 bindkey -M menuselect '^o' accept-and-infer-next-history
25 30
26 zstyle ':completion:*:*:*:*:*' menu select 31 zstyle ':completion:*:*:*:*:*' menu select
27 zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' 32 zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
28 if [ "$OSTYPE[0,7]" = "solaris" ] 33 if [ "$OSTYPE[0,7]" = "solaris" ]
29 then 34 then
30 zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" 35 zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
31 else 36 else
32 zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" 37 zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
33 fi 38 fi
34 39
35 # disable named-directories autocompletion 40 # disable named-directories autocompletion
36 zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories 41 zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
37 42
38 # Use caching so that commands like apt and dpkg complete are useable 43 # Use caching so that commands like apt and dpkg complete are useable
39 zstyle ':completion::complete:*' use-cache 1 44 zstyle ':completion::complete:*' use-cache 1
40 zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR 45 zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
41 46
42 # Don't complete uninteresting users 47 # Don't complete uninteresting users
43 zstyle ':completion:*:*:*:users' ignored-patterns \ 48 zstyle ':completion:*:*:*:users' ignored-patterns \
44 adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ 49 adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
45 clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ 50 clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
46 gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ 51 gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
47 ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \ 52 ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
48 named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ 53 named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
49 operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ 54 operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
50 rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ 55 rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
51 usbmux uucp vcsa wwwrun xfs '_*' 56 usbmux uucp vcsa wwwrun xfs '_*'
52 57
53 # ... unless we really want to. 58 # ... unless we really want to.
54 zstyle '*' single-ignored show 59 zstyle '*' single-ignored show
55 60
56 if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then 61 if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
57 expand-or-complete-with-dots() { 62 expand-or-complete-with-dots() {
58 echo -n "\e[31m......\e[0m" 63 echo -n "\e[31m......\e[0m"
59 zle expand-or-complete 64 zle expand-or-complete
60 zle redisplay 65 zle redisplay
61 } 66 }
62 zle -N expand-or-complete-with-dots 67 zle -N expand-or-complete-with-dots
63 bindkey "^I" expand-or-complete-with-dots 68 bindkey "^I" expand-or-complete-with-dots
64 fi 69 fi
65 70
1 # get the name of the branch we are on 1 # get the name of the branch we are on
2 function git_prompt_info() { 2 function git_prompt_info() {
3 if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then 3 if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
4 ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ 4 ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
5 ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 5 ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
6 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" 6 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
7 fi 7 fi
8 } 8 }
9 9
10 10
11 # Checks if working tree is dirty 11 # Checks if working tree is dirty
12 parse_git_dirty() { 12 parse_git_dirty() {
13 local STATUS='' 13 local STATUS=''
14 local FLAGS 14 local FLAGS
15 FLAGS=('--porcelain') 15 FLAGS=('--porcelain')
16 if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then 16 if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
17 if [[ $POST_1_7_2_GIT -gt 0 ]]; then 17 if [[ $POST_1_7_2_GIT -gt 0 ]]; then
18 FLAGS+='--ignore-submodules=dirty' 18 FLAGS+='--ignore-submodules=dirty'
19 fi 19 fi
20 if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then 20 if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
21 FLAGS+='--untracked-files=no' 21 FLAGS+='--untracked-files=no'
22 fi 22 fi
23 STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) 23 STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
24 fi 24 fi
25 if [[ -n $STATUS ]]; then 25 if [[ -n $STATUS ]]; then
26 echo "$ZSH_THEME_GIT_PROMPT_DIRTY" 26 echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
27 else 27 else
28 echo "$ZSH_THEME_GIT_PROMPT_CLEAN" 28 echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
29 fi 29 fi
30 } 30 }
31 31
32 # get the difference between the local and remote branches 32 # get the difference between the local and remote branches
33 git_remote_status() { 33 git_remote_status() {
34 remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} 34 remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
35 if [[ -n ${remote} ]] ; then 35 if [[ -n ${remote} ]] ; then
36 ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) 36 ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
37 behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) 37 behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
38 38
39 if [ $ahead -eq 0 ] && [ $behind -gt 0 ] 39 if [ $ahead -gt 0 ] && [ $behind -eq 0 ]
40 then 40 then
41 echo "$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE" 41 git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
42 elif [ $ahead -gt 0 ] && [ $behind -eq 0 ] 42 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
43 elif [ $behind -gt 0 ] && [ $ahead -eq 0 ]
43 then 44 then
44 echo "$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE" 45 git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
46 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
45 elif [ $ahead -gt 0 ] && [ $behind -gt 0 ] 47 elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
46 then 48 then
47 echo "$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE" 49 git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
50 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
48 fi 51 fi
49 fi
50 }
51 52
52 # Checks if there are commits ahead from remote 53 if [ $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]
53 function git_prompt_ahead() { 54 then
54 if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then 55 git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
55 echo "$ZSH_THEME_GIT_PROMPT_AHEAD" 56 fi
56 fi 57
58 echo $git_remote_status
59 fi
57 } 60 }
58 61
59 # Gets the number of commits ahead from remote 62 # Gets the number of commits ahead from remote
60 function git_commits_ahead() { 63 function git_commits_ahead() {
61 if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then 64 if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
62 COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') 65 COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
63 echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" 66 echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
64 fi 67 fi
65 } 68 }
66 69
70 # Outputs if current branch is ahead of remote
71 function git_prompt_ahead() {
72 if [[ -n "$(command git rev-list origin/$(current_branch)..HEAD 2> /dev/null)" ]]; then
73 echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
74 fi
75 }
76
77 # Outputs if current branch is behind remote
78 function git_prompt_behind() {
79 if [[ -n "$(command git rev-list HEAD..origin/$(current_branch) 2> /dev/null)" ]]; then
80 echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
81 fi
82 }
83
84 # Outputs if current branch exists on remote or not
85 function git_prompt_remote() {
86 if [[ -n "$(command git show-ref origin/$(current_branch) 2> /dev/null)" ]]; then
87 echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
88 else
89 echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
90 fi
91 }
92
67 # Formats prompt string for current git commit short SHA 93 # Formats prompt string for current git commit short SHA
68 function git_prompt_short_sha() { 94 function git_prompt_short_sha() {
69 SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" 95 SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
70 } 96 }
71 97
72 # Formats prompt string for current git commit long SHA 98 # Formats prompt string for current git commit long SHA
73 function git_prompt_long_sha() { 99 function git_prompt_long_sha() {
74 SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" 100 SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
75 } 101 }
76 102
77 # Get the status of the working tree 103 # Get the status of the working tree
78 git_prompt_status() { 104 git_prompt_status() {
79 INDEX=$(command git status --porcelain -b 2> /dev/null) 105 INDEX=$(command git status --porcelain -b 2> /dev/null)
80 STATUS="" 106 STATUS=""
81 if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then 107 if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
82 STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" 108 STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
83 fi 109 fi
84 if $(echo "$INDEX" | grep '^A ' &> /dev/null); then 110 if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
85 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" 111 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
86 elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then 112 elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
87 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" 113 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
88 fi 114 fi
89 if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then 115 if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
90 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 116 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
91 elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then 117 elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
92 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 118 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
93 elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then 119 elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
94 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 120 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
95 fi 121 fi
96 if $(echo "$INDEX" | grep '^R ' &> /dev/null); then 122 if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
97 STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" 123 STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
98 fi 124 fi
99 if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then 125 if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
100 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 126 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
101 elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then 127 elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
102 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 128 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
103 elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then 129 elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
104 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 130 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
105 fi 131 fi
106 if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then 132 if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
107 STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" 133 STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
108 fi 134 fi
109 if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then 135 if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
110 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" 136 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
111 fi 137 fi
112 if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then 138 if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then
113 STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" 139 STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
114 fi 140 fi
115 if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then 141 if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then
116 STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" 142 STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
117 fi 143 fi
118 if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then 144 if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then
119 STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" 145 STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
120 fi 146 fi
121 echo $STATUS 147 echo $STATUS
122 } 148 }
123 149
124 #compare the provided version of git to the version installed and on path 150 #compare the provided version of git to the version installed and on path
125 #prints 1 if input version <= installed version 151 #prints 1 if input version <= installed version
126 #prints -1 otherwise 152 #prints -1 otherwise
127 function git_compare_version() { 153 function git_compare_version() {
128 local INPUT_GIT_VERSION=$1; 154 local INPUT_GIT_VERSION=$1;
129 local INSTALLED_GIT_VERSION 155 local INSTALLED_GIT_VERSION
130 INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION}); 156 INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
131 INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)); 157 INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
132 INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}); 158 INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
133 159
134 for i in {1..3}; do 160 for i in {1..3}; do
135 if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then 161 if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then
136 echo 1 162 echo 1
137 return 0 163 return 0
138 fi 164 fi
139 if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then 165 if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
140 echo -1 166 echo -1
141 return 0 167 return 0
142 fi 168 fi
143 done 169 done
144 echo 0 170 echo 0
145 } 171 }
146 172
147 #this is unlikely to change so make it all statically assigned 173 #this is unlikely to change so make it all statically assigned
148 POST_1_7_2_GIT=$(git_compare_version "1.7.2") 174 POST_1_7_2_GIT=$(git_compare_version "1.7.2")
149 #clean up the namespace slightly by removing the checker function 175 #clean up the namespace slightly by removing the checker function
1 ## smart urls 1 ## Load smart urls if available
2 autoload -U url-quote-magic 2 for d in $fpath; do
3 zle -N self-insert url-quote-magic 3 if [[ -e "$d/url-quote-magic" ]]; then
4 autoload -U url-quote-magic
5 zle -N self-insert url-quote-magic
6 fi
7 done
4 8
5 ## jobs 9 ## jobs
6 setopt long_list_jobs 10 setopt long_list_jobs
7 11
8 ## pager 12 ## pager
9 export PAGER="less" 13 export PAGER="less"
10 export LESS="-R" 14 export LESS="-R"
11 15
12 ## super user alias 16 ## super user alias
13 alias _='sudo' 17 alias _='sudo'
14 alias please='sudo' 18 alias please='sudo'
15 19
16 ## more intelligent acking for ubuntu users 20 ## more intelligent acking for ubuntu users
17 alias afind='ack-grep -il' 21 alias afind='ack-grep -il'
18 22
19 # only define LC_CTYPE if undefined 23 # only define LC_CTYPE if undefined
20 if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then 24 if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
21 export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG 25 export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
22 fi 26 fi
27
28 # recognize comments
29 setopt interactivecomments
23 30
1 # Check for updates on initial load... 1 # Check for updates on initial load...
2 if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then 2 if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
3 env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh 3 env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
4 fi 4 fi
5 5
6 # Initializes Oh My Zsh 6 # Initializes Oh My Zsh
7 7
8 # add a function path 8 # add a function path
9 fpath=($ZSH/functions $ZSH/completions $fpath) 9 fpath=($ZSH/functions $ZSH/completions $fpath)
10 10
11 # Set ZSH_CUSTOM to the path where your custom config files 11 # Set ZSH_CUSTOM to the path where your custom config files
12 # and plugins exists, or else we will use the default custom/ 12 # and plugins exists, or else we will use the default custom/
13 if [[ -z "$ZSH_CUSTOM" ]]; then 13 if [[ -z "$ZSH_CUSTOM" ]]; then
14 ZSH_CUSTOM="$ZSH/custom" 14 ZSH_CUSTOM="$ZSH/custom"
15 fi 15 fi
16 16
17 # Set ZSH_CACHE_DIR to the path where cache files sould be created 17 # Set ZSH_CACHE_DIR to the path where cache files should be created
18 # or else we will use the default cache/ 18 # or else we will use the default cache/
19 if [[ -z "$ZSH_CACHE_DIR" ]]; then 19 if [[ -z "$ZSH_CACHE_DIR" ]]; then
20 ZSH_CACHE_DIR="$ZSH/cache/" 20 ZSH_CACHE_DIR="$ZSH/cache/"
21 fi 21 fi
22 22
23 23
24 # Load all of the config files in ~/oh-my-zsh that end in .zsh 24 # Load all of the config files in ~/oh-my-zsh that end in .zsh
25 # TIP: Add files you don't want in git to .gitignore 25 # TIP: Add files you don't want in git to .gitignore
26 for config_file ($ZSH/lib/*.zsh); do 26 for config_file ($ZSH/lib/*.zsh); do
27 custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" 27 custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
28 [ -f "${custom_config_file}" ] && config_file=${custom_config_file} 28 [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
29 source $config_file 29 source $config_file
30 done 30 done
31 31
32 # Load all of your custom configurations from custom/
33 for config_file ($ZSH_CUSTOM/*.zsh(N)); do
34 source $config_file
35 done
36 unset config_file
32 37
33 is_plugin() { 38 is_plugin() {
34 local base_dir=$1 39 local base_dir=$1
35 local name=$2 40 local name=$2
36 test -f $base_dir/plugins/$name/$name.plugin.zsh \ 41 test -f $base_dir/plugins/$name/$name.plugin.zsh \
37 || test -f $base_dir/plugins/$name/_$name 42 || test -f $base_dir/plugins/$name/_$name
38 } 43 }
39 # Add all defined plugins to fpath. This must be done 44 # Add all defined plugins to fpath. This must be done
40 # before running compinit. 45 # before running compinit.
41 for plugin ($plugins); do 46 for plugin ($plugins); do
42 if is_plugin $ZSH_CUSTOM $plugin; then 47 if is_plugin $ZSH_CUSTOM $plugin; then
43 fpath=($ZSH_CUSTOM/plugins/$plugin $fpath) 48 fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
44 elif is_plugin $ZSH $plugin; then 49 elif is_plugin $ZSH $plugin; then
45 fpath=($ZSH/plugins/$plugin $fpath) 50 fpath=($ZSH/plugins/$plugin $fpath)
46 fi 51 fi
47 done 52 done
48 53
49 # Figure out the SHORT hostname 54 # Figure out the SHORT hostname
50 if [[ "$OSTYPE" = darwin* ]]; then 55 if [[ "$OSTYPE" = darwin* ]]; then
51 # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible. 56 # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
52 SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} 57 SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
53 else 58 else
54 SHORT_HOST=${HOST/.*/} 59 SHORT_HOST=${HOST/.*/}
55 fi 60 fi
56 61
57 # Save the location of the current completion dump file. 62 # Save the location of the current completion dump file.
58 if [ -z "$ZSH_COMPDUMP" ]; then 63 if [ -z "$ZSH_COMPDUMP" ]; then
59 ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" 64 ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
60 fi 65 fi
61 66
62 # Load and run compinit 67 # Load and run compinit
63 autoload -U compinit 68 autoload -U compinit
64 compinit -i -d "${ZSH_COMPDUMP}" 69 compinit -i -d "${ZSH_COMPDUMP}"
65 70
66 # Load all of the plugins that were defined in ~/.zshrc 71 # Load all of the plugins that were defined in ~/.zshrc
67 for plugin ($plugins); do 72 for plugin ($plugins); do
68 if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then 73 if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
69 source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh 74 source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
70 elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then 75 elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
71 source $ZSH/plugins/$plugin/$plugin.plugin.zsh 76 source $ZSH/plugins/$plugin/$plugin.plugin.zsh
72 fi 77 fi
73 done 78 done
74 79
75 # Load all of your custom configurations from custom/
76 for config_file ($ZSH_CUSTOM/*.zsh(N)); do
77 source $config_file
78 done
79 unset config_file
80
81 # Load the theme 80 # Load the theme
82 if [ "$ZSH_THEME" = "random" ]; then 81 if [ "$ZSH_THEME" = "random" ]; then
83 themes=($ZSH/themes/*zsh-theme) 82 themes=($ZSH/themes/*zsh-theme)
84 N=${#themes[@]} 83 N=${#themes[@]}
85 ((N=(RANDOM%N)+1)) 84 ((N=(RANDOM%N)+1))
86 RANDOM_THEME=${themes[$N]} 85 RANDOM_THEME=${themes[$N]}
87 source "$RANDOM_THEME" 86 source "$RANDOM_THEME"
88 echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." 87 echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
89 else 88 else
90 if [ ! "$ZSH_THEME" = "" ]; then 89 if [ ! "$ZSH_THEME" = "" ]; then
91 if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then 90 if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
92 source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" 91 source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
93 elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then 92 elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
94 source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" 93 source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
95 else 94 else
1 #compdef adb 1 #compdef adb
2 #autoload 2 #autoload
3 3
4 # in order to make this work, you will need to have the android adb tools 4 # in order to make this work, you will need to have the android adb tools
5 5
6 # adb zsh completion, based on homebrew completion 6 # adb zsh completion, based on homebrew completion
7 7
8 local -a _1st_arguments 8 local -a _1st_arguments
9 _1st_arguments=( 9 _1st_arguments=(
10 'bugreport:return all information from the device that should be included in a bug report.' 10 'bugreport:return all information from the device that should be included in a bug report.'
11 'connect:connect to a device via TCP/IP Port 5555 is default.' 11 'connect:connect to a device via TCP/IP Port 5555 is default.'
12 'devices:list all connected devices' 12 'devices:list all connected devices'
13 'disconnect:disconnect from a TCP/IP device. Port 5555 is default.' 13 'disconnect:disconnect from a TCP/IP device. Port 5555 is default.'
14 'emu:run emulator console command' 14 'emu:run emulator console command'
15 'forward:forward socket connections' 15 'forward:forward socket connections'
16 'help:show the help message' 16 'help:show the help message'
17 'install:push this package file to the device and install it' 17 'install:push this package file to the device and install it'
18 'jdwp:list PIDs of processes hosting a JDWP transport' 18 'jdwp:list PIDs of processes hosting a JDWP transport'
19 'logcat:View device log' 19 'kill-server:kill the server if it is running'
20 'logcat:view device log'
20 'pull:copy file/dir from device' 21 'pull:copy file/dir from device'
21 'push:copy file/dir to device' 22 'push:copy file/dir to device'
23 'reboot:reboots the device, optionally into the bootloader or recovery program'
24 'reboot-bootloader:reboots the device into the bootloader'
25 'remount:remounts the partitions on the device read-write'
26 'root:restarts the adbd daemon with root permissions'
27 'sideload:push a ZIP to device and install it'
22 'shell:run remote shell interactively' 28 'shell:run remote shell interactively'
23 'sync:copy host->device only if changed (-l means list but dont copy)' 29 'sync:copy host->device only if changed (-l means list but dont copy)'
24 ‘tcpip:restart host adb in tcpip mode’ 30 'start-server:ensure that there is a server running'
31 'tcpip:restart host adb in tcpip mode'
25 'uninstall:remove this app package from the device' 32 'uninstall:remove this app package from the device'
26 'version:show version num' 33 'version:show version num'
34 'wait-for-device:block until device is online'
27 ) 35 )
28 36
29 local expl 37 local expl
30 local -a pkgs installed_pkgs 38 local -a pkgs installed_pkgs
31 39
32 _arguments \ 40 _arguments \
33 '*:: :->subcmds' && return 0 41 '*:: :->subcmds' && return 0
34 42
35 if (( CURRENT == 1 )); then 43 if (( CURRENT == 1 )); then
36 _describe -t commands "adb subcommand" _1st_arguments 44 _describe -t commands "adb subcommand" _1st_arguments
37 return 45 return
38 fi 46 fi
39 47
40 _files 48 _files
41 49
plugins/apache2-macports/README.md
File was created 1 ## APACHE2 MACPORTS PLUGIN
2
3
4 ---
5
6 ### FEATURES
7
8 | Alias | Function | Description |
9 |:--------------:|:-------------------------------------------------------------------------------|----------------------:|
10 | apache2restart | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart | Restart apache daemon |
11 | apache2start | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start | Start apache daemon |
12 | apache2stop | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop | Stop apache daemon |
13
14 ---
15
16 ### CONTRIBUTORS
17 - Alexander Rinass (alex@rinass.net)
18
19 ---
20
plugins/archlinux/README.md
File was created 1 ## ARCHLINUX PLUGIN
2
3
4 ---
5
6 ### FEATURES
7
8 | Alias | Function | Description |
9 |:------------:|-----------------------------------------|:--------------------------------------------------------------------------------------------------------------------|
10 | pacin | sudo pacman -S | Install specific package(s) from the repositories |
11 | pacins | sudo pacman -U | Install specific package not from the repositories but from a file |
12 | pacinsd | sudo pacman -S --asdeps | Install given package(s) as dependencies of another package |
13 | pacloc | pacman -Qi | Display information about a given package in the local database |
14 | paclocs | pacman -Qs | Search for package(s) in the local database |
15 | paclsorphans | sudo pacman -Qdt' | List all orphaned packages |
16 | pacmir | sudo pacman -Syy | Force refresh of all package lists after updating /etc/pacman.d/mirrorlist |
17 | pacre | sudo pacman -R | Remove the specified package(s), retaining its configuration(s) and required dependencies |
18 | pacrem | sudo pacman -Rns | Remove the specified package(s), its configuration(s) and unneeded dependencies |
19 | pacrep | pacman -Si | Display information about a given package in the repositories |
20 | pacreps | pacman -Ss | Search for package(s) in the repositories |
21 | pacrmorphans | sudo pacman -Rs $(pacman -Qtdq)' | Delete all orphaned packages |
22 | pacupd | sudo pacman -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases against repositories |
23 | pacupd | sudo pacman -Sy && sudo abs | Update and refresh the local package and ABS databases against repositories |
24 | pacupd | sudo pacman -Sy && sudo aur | Update and refresh the local package and AUR databases against repositories |
25 | pacupd | sudo pacman -Sy | Update and refresh the local package database against repositories |
26 | pacupg | sudo pacman -Syu | Synchronize with repositories before upgrading packages that are out of date on the local system. |
27 | yaconf | yaourt -C | Fix all configuration files with vimdiff |
28 | yain | yaourt -S | Install specific package(s) from the repositories |
29 | yains | yaourt -U | Install specific package not from the repositories but from a file |
30 | yainsd | yaourt -S --asdeps | Install given package(s) as dependencies of another package |
31 | yaloc | yaourt -Qi | Display information about a given package in the local database |
32 | yalocs | yaourt -Qs | Search for package(s) in the local database |
33 | yalst | yaourt -Qe | List installed packages, even those installed from AUR (they're tagged as "local") |
34 | yamir | yaourt -Syy | Force refresh of all package lists after updating /etc/pacman.d/mirrorlist |
35 | yaorph | yaourt -Qtd | Remove orphans using yaourt |
36 | yare | yaourt -R | Remove the specified package(s), retaining its configuration(s) and required dependencies |
37 | yarem | yaourt -Rns | Remove the specified package(s), its configuration(s) and unneeded dependencies |
38 | yarep | yaourt -Si | Display information about a given package in the repositories |
39 | yareps | yaourt -Ss | Search for package(s) in the repositories |
40 | yasu | yaourt --sucre | Same as yaupg, but without confirmation |
41 | yaupd | yaourt -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases against repositories |
42 | yaupd | yaourt -Sy && sudo abs | Update and refresh the local package and ABS databases against repositories |
43 | yaupd | yaourt -Sy && sudo aur | Update and refresh the local package and AUR databases against repositories |
44 | yaupd | yaourt -Sy | Update and refresh the local package database against repositories |
45 | yaupg | yaourt -Syua | Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system |
46
47 | Function | Description |
48 |----------------|:------------------------------------------------------------------------------------------------------------------|
49 | pacdisowned | List all disowned files in your system |
50 | paclist | List all installed packages with a short description - [Source](https://bbs.archlinux.org/viewtopic.php?id=93683) |
51 | pacmanallkeys | Get all keys for developers and trusted users |
52 | pacmansignkeys | |
53
54 ---
55
56 ### CONTRIBUTORS
57 - Benjamin Boudreau - dreurmail@gmail.com
58 - Celso Miranda - contacto@celsomiranda.net
59 - KhasMek - Boushh@gmail.com
60 - Martin Putniorz - mputniorz@gmail.com
61 - MatthR3D - matthr3d@gmail.com
62 - ornicar - thibault.duplessis@gmail.com
63
64 ---
65
plugins/archlinux/archlinux.plugin.zsh
1 # Archlinux zsh aliases and functions 1 # Archlinux zsh aliases and functions
2 # Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins 2 # Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
3 3
4 # Look for yaourt, and add some useful functions if we have it. 4 # Look for yaourt, and add some useful functions if we have it.
5 if [[ -x `which yaourt` ]]; then 5 if [[ -x `command -v yaourt` ]]; then
6 upgrade () { 6 upgrade () {
7 yaourt -Syu 7 yaourt -Syu
8 } 8 }
9 alias yaconf='yaourt -C' # Fix all configuration files with vimdiff 9 alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
10 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips 10 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
11 alias yaupg='yaourt -Syua' # Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system. 11 alias yaupg='yaourt -Syua' # Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system.
12 alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation 12 alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation
13 alias yain='yaourt -S' # Install specific package(s) from the repositories 13 alias yain='yaourt -S' # Install specific package(s) from the repositories
14 alias yains='yaourt -U' # Install specific package not from the repositories but from a file 14 alias yains='yaourt -U' # Install specific package not from the repositories but from a file
15 alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies 15 alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
16 alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies 16 alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
17 alias yarep='yaourt -Si' # Display information about a given package in the repositories 17 alias yarep='yaourt -Si' # Display information about a given package in the repositories
18 alias yareps='yaourt -Ss' # Search for package(s) in the repositories 18 alias yareps='yaourt -Ss' # Search for package(s) in the repositories
19 alias yaloc='yaourt -Qi' # Display information about a given package in the local database 19 alias yaloc='yaourt -Qi' # Display information about a given package in the local database
20 alias yalocs='yaourt -Qs' # Search for package(s) in the local database 20 alias yalocs='yaourt -Qs' # Search for package(s) in the local database
21 alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local") 21 alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
22 alias yaorph='yaourt -Qtd' # Remove orphans using yaourt 22 alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
23 # Additional yaourt alias examples 23 # Additional yaourt alias examples
24 if [[ -x `which abs` && -x `which aur` ]]; then 24 if [[ -x `command -v abs` && -x `command -v aur` ]]; then
25 alias yaupd='yaourt -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories 25 alias yaupd='yaourt -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
26 elif [[ -x `which abs` ]]; then 26 elif [[ -x `command -v abs` ]]; then
27 alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories 27 alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
28 elif [[ -x `which aur` ]]; then 28 elif [[ -x `command -v aur` ]]; then
29 alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories 29 alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
30 else 30 else
31 alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories 31 alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories
32 fi 32 fi
33 alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package 33 alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package
34 alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist 34 alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
35 else 35 else
36 upgrade() { 36 upgrade() {
37 sudo pacman -Syu 37 sudo pacman -Syu
38 } 38 }
39 fi 39 fi
40 40
41 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips 41 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
42 alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system. 42 alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
43 alias pacin='sudo pacman -S' # Install specific package(s) from the repositories 43 alias pacin='sudo pacman -S' # Install specific package(s) from the repositories
44 alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file 44 alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file
45 alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies 45 alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
46 alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies 46 alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
47 alias pacrep='pacman -Si' # Display information about a given package in the repositories 47 alias pacrep='pacman -Si' # Display information about a given package in the repositories
48 alias pacreps='pacman -Ss' # Search for package(s) in the repositories 48 alias pacreps='pacman -Ss' # Search for package(s) in the repositories
49 alias pacloc='pacman -Qi' # Display information about a given package in the local database 49 alias pacloc='pacman -Qi' # Display information about a given package in the local database
50 alias paclocs='pacman -Qs' # Search for package(s) in the local database 50 alias paclocs='pacman -Qs' # Search for package(s) in the local database
51 # Additional pacman alias examples 51 # Additional pacman alias examples
52 if [[ -x `which abs` && -x `which aur` ]]; then 52 if [[ -x `command -v abs` && -x `command -v aur` ]]; then
53 alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories 53 alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
54 elif [[ -x `which abs` ]]; then 54 elif [[ -x `command -v abs` ]]; then
55 alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories 55 alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
56 elif [[ -x `which aur` ]]; then 56 elif [[ -x `command -v aur` ]]; then
57 alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories 57 alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
58 else 58 else
59 alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories 59 alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories
60 fi 60 fi
61 alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package 61 alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package
62 alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist 62 alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
63 63
64 # https://bbs.archlinux.org/viewtopic.php?id=93683 64 # https://bbs.archlinux.org/viewtopic.php?id=93683
65 paclist() { 65 paclist() {
66 sudo pacman -Qei $(pacman -Qu|cut -d" " -f 1)|awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}' 66 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}'
67 } 67 }
68 68
69 alias paclsorphans='sudo pacman -Qdt' 69 alias paclsorphans='sudo pacman -Qdt'
70 alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)' 70 alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
71 71
72 pacdisowned() { 72 pacdisowned() {
73 tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ 73 tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
74 db=$tmp/db 74 db=$tmp/db
75 fs=$tmp/fs 75 fs=$tmp/fs
76 76
77 mkdir "$tmp" 77 mkdir "$tmp"
78 trap 'rm -rf "$tmp"' EXIT 78 trap 'rm -rf "$tmp"' EXIT
79 79
80 pacman -Qlq | sort -u > "$db" 80 pacman -Qlq | sort -u > "$db"
81 81
82 find /bin /etc /lib /sbin /usr \ 82 find /bin /etc /lib /sbin /usr \
83 ! -name lost+found \ 83 ! -name lost+found \
84 \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" 84 \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
85 85
86 comm -23 "$fs" "$db" 86 comm -23 "$fs" "$db"
87 } 87 }
88 88
89 pacmanallkeys() { 89 pacmanallkeys() {
90 # Get all keys for developers and trusted users 90 # Get all keys for developers and trusted users
91 curl https://www.archlinux.org/{developers,trustedusers}/ | 91 curl https://www.archlinux.org/{developers,trustedusers}/ |
92 awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' | 92 awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' |
93 xargs sudo pacman-key --recv-keys 93 xargs sudo pacman-key --recv-keys
94 } 94 }
95 95
96 pacmansignkeys() { 96 pacmansignkeys() {
97 for key in $*; do 97 for key in $*; do
98 sudo pacman-key --recv-keys $key 98 sudo pacman-key --recv-keys $key
99 sudo pacman-key --lsign-key $key 99 sudo pacman-key --lsign-key $key
100 printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \ 100 printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
101 --no-permission-warning --command-fd 0 --edit-key $key 101 --no-permission-warning --command-fd 0 --edit-key $key
102 done 102 done
103 } 103 }
104 104
plugins/atom/README.md
File was created 1 ## atom
2
3 Plugin for Atom, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
4
5 ### Requirements
6
7 * [Atom](https://atom.io/)
8
9 ### Usage
10
11 * If `at` command is called without an argument, launch Atom
12
13 * If `at` is passed a directory, `cd` to it and open it in Atom
14
15 * If `at` is passed a file, open it in Atom
16
17 * if `att` command is called, it is equivalent to `at .`, opening the current folder in Atom
18
plugins/aws/aws.plugin.zsh
1 _homebrew-installed() { 1 _homebrew-installed() {
2 type brew &> /dev/null 2 type brew &> /dev/null
3 } 3 }
4 4
5 _awscli-homebrew-installed() { 5 _awscli-homebrew-installed() {
6 brew list awscli &> /dev/null 6 brew list awscli &> /dev/null
7 } 7 }
8 8
9 export AWS_HOME=~/.aws 9 export AWS_HOME=~/.aws
10 10
11 function agp { 11 function agp {
12 echo $AWS_DEFAULT_PROFILE 12 echo $AWS_DEFAULT_PROFILE
13 } 13 }
14 function asp { 14 function asp {
15 export AWS_DEFAULT_PROFILE=$1 15 export AWS_DEFAULT_PROFILE=$1
16 export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>" 16 export AWS_PROFILE=$1
17 export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>$RPROMPT"
17 } 18 }
18 function aws_profiles { 19 function aws_profiles {
19 reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) 20 reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
20 } 21 }
21 22
22 compctl -K aws_profiles asp 23 compctl -K aws_profiles asp
23 24
24 if _homebrew-installed && _awscli-homebrew-installed ; then 25 if _homebrew-installed && _awscli-homebrew-installed ; then
25 _aws_zsh_completer_path=$(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh 26 _aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh
26 else 27 else
27 _aws_zsh_completer_path=$(which aws_zsh_completer.sh) 28 _aws_zsh_completer_path=$(which aws_zsh_completer.sh)
28 fi 29 fi
29 30
30 [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path 31 [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
31 unset _aws_zsh_completer_path 32 unset _aws_zsh_completer_path
32 33
plugins/bgnotify/bgnotify.plugin.zsh
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 2
3 ## setup ## 3 ## setup ##
4 4
5 [[ -o interactive ]] || return #interactive only! 5 [[ -o interactive ]] || return #interactive only!
6 zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date() 6 zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date()
7 autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } 7 autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return }
8 8
9 (( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds 9 (( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds
10 10
11 11
12 ## definitions ## 12 ## definitions ##
13 13
14 if ! (type bgnotify_formatted | grep -q 'function'); then 14 if ! (type bgnotify_formatted | grep -q 'function'); then
15 function bgnotify_formatted { 15 function bgnotify_formatted {
16 ## exit_status, command, elapsed_time 16 ## exit_status, command, elapsed_time
17 [ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)" 17 [ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)"
18 bgnotify "$title" "$2" 18 bgnotify "$title" "$2"
19 } 19 }
20 fi 20 fi
21 21
22 currentWindowId () { 22 currentWindowId () {
23 if hash osascript 2>/dev/null; then #osx 23 if hash osascript 2>/dev/null; then #osx
24 osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" 24 osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
25 elif hash notify-send 2>/dev/null; then #ubuntu! 25 elif hash notify-send 2>/dev/null; then #ubuntu!
26 xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }' 26 xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }'
27 else 27 else
28 echo $EPOCHSECONDS #fallback for windows 28 echo $EPOCHSECONDS #fallback for windows
29 fi 29 fi
30 } 30 }
31 31
32 bgnotify () { 32 bgnotify () {
33 if hash terminal-notifier 2>/dev/null; then #osx 33 if hash terminal-notifier 2>/dev/null; then #osx
34 terminal-notifier -message "$2" -title "$1" 34 terminal-notifier -message "$2" -title "$1"
35 elif hash growlnotify 2>/dev/null; then #osx growl 35 elif hash growlnotify 2>/dev/null; then #osx growl
36 growlnotify -m $1 $2 36 growlnotify -m "$1" "$2"
37 elif hash notify-send 2>/dev/null; then #ubuntu! 37 elif hash notify-send 2>/dev/null; then #ubuntu!
38 notify-send $1 $2 38 notify-send "$1" "$2"
39 elif hash notifu 2>/dev/null; then #cygwyn support! 39 elif hash notifu 2>/dev/null; then #cygwyn support!
40 notifu /m "$2" /p "$1" 40 notifu /m "$2" /p "$1"
41 fi 41 fi
42 } 42 }
43 43
44 44
45 ## Zsh hooks ## 45 ## Zsh hooks ##
46 46
47 bgnotify_begin() { 47 bgnotify_begin() {
48 bgnotify_timestamp=$EPOCHSECONDS 48 bgnotify_timestamp=$EPOCHSECONDS
49 bgnotify_lastcmd=$1 49 bgnotify_lastcmd=$1
50 bgnotify_windowid=$(currentWindowId) 50 bgnotify_windowid=$(currentWindowId)
51 } 51 }
52 52
53 bgnotify_end() { 53 bgnotify_end() {
54 didexit=$? 54 didexit=$?
55 elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) 55 elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
56 past_threshold=$(( elapsed >= bgnotify_threshold )) 56 past_threshold=$(( elapsed >= bgnotify_threshold ))
57 if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then 57 if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
58 if [ $(currentWindowId) != "$bgnotify_windowid" ]; then 58 if [ $(currentWindowId) != "$bgnotify_windowid" ]; then
59 print -n "\a" 59 print -n "\a"
60 bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" 60 bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
61 fi 61 fi
62 fi 62 fi
63 bgnotify_timestamp=0 #reset it to 0! 63 bgnotify_timestamp=0 #reset it to 0!
64 } 64 }
65 65
66 add-zsh-hook preexec bgnotify_begin 66 add-zsh-hook preexec bgnotify_begin
67 add-zsh-hook precmd bgnotify_end 67 add-zsh-hook precmd bgnotify_end
68 68
plugins/boot2docker/README.md
File was created 1 ## Boot2docker autocomplete plugin
2
3 - Adds autocomplete options for all boot2docker commands.
4
5
6 Maintainer : Manfred Touron ([@moul](https://github.com/moul))
7
plugins/boot2docker/_boot2docker
File was created 1 #compdef boot2docker
2
3 # Boot2docker autocompletion for oh-my-zsh
4 # Requires: Boot2docker installed
5 # Author: Manfred Touron (@moul)
6
7 local -a _1st_arguments
8 _1st_arguments=(
9 "init":"Create a new Boot2Docker VM."
10 "up":"Start VM from any states."
11 "start":"Start VM from any states."
12 "boot":"Start VM from any states."
13 "ssh":"[ssh-command] Login to VM via SSH."
14 "save":"Suspend VM and save state to disk."
15 "suspend":"Suspend VM and save state to disk."
16 "down":"Gracefully shutdown the VM."
17 "stop":"Gracefully shutdown the VM."
18 "halt":"Gracefully shutdown the VM."
19 "restart":"Gracefully reboot the VM."
20 "poweroff":"Forcefully power off the VM (may corrupt disk image)."
21 "reset":"Forcefully power cycle the VM (may corrupt disk image)."
22 "delete":"Delete Boot2Docker VM and its disk image."
23 "destroy":"Delete Boot2Docker VM and its disk image."
24 "config":"Show selected profile file settings."
25 "cfg":"Show selected profile file settings."
26 "info":"Display detailed information of VM."
27 "ip":"Display the IP address of the VM's Host-only network."
28 "socket":"Display the DOCKER_HOST socket to connect to."
29 "shellinit":"Display the shell command to set up the Docker client."
30 "status":"Display current state of VM."
31 "download":"Download Boot2Docker ISO image."
32 "upgrade":"Upgrade the Boot2Docker ISO image (restart if running)."
33 "version":"Display version information."
34 )
35
36 _arguments \
37 '(--basevmdk)--basevmdk[Path to VMDK to use as base for persistent partition]' \
38 '(--cpus)'{-c,--cpus}'[number of CPUs for boot2docker.]' \
39 '(--clobber)--clobber[overwrite Docker client binary on boot2docker upgrade]' \
40 '(--dhcp)--dhcp[enable VirtualBox host-only network DHCP.]' \
41 '(--dhcpip)--dhcpip[VirtualBox host-only network DHCP server address.]' \
42 '(-s --disksize)'{-s,--disksize}'[boot2docker disk image size (in MB).]' \
43 '(--dockerport)--dockerport[host Docker port (forward to port 2376 in VM). (deprecated - use with care)]' \
44 '(--driver)--driver[hypervisor driver.]' \
45 '(--force-upgrade-download)--force-upgrade-download[always download on boot2docker upgrade, never skip.]' \
46 '(--hostip)--hostip[VirtualBox host-only network IP address.]' \
47 '(--iso)--iso[path to boot2docker ISO image.]' \
48 '(--iso-url)--iso-url[/api.github.com/repos/boot2docker/boot2docker/releases": source URL to provision the boot2docker ISO image.]' \
49 '(--lowerip)--lowerip[VirtualBox host-only network DHCP lower bound.]' \
50 '(--memory)'{-m,--memory}'[virtual machine memory size (in MB).]' \
51 '(--netmask)--netmask[VirtualBox host-only network mask.]' \
52 '(--no-dummy)--no-dummy[Example parameter for the dummy driver.]' \
53 '(--retries)--retries[number of port knocking retries during 'start']' \
54 '(--serial)--serial[try serial console to get IP address (experimental)]' \
55 '(--serialfile)--serialfile[path to the serial socket/pipe.]' \
56 '(--ssh)--ssh[path to SSH client utility.]' \
57 '(--ssh-keygen)--ssh-keygen[path to ssh-keygen utility.]' \
58 '(--sshkey)--sshkey[path to SSH key to use.]' \
59 '(--sshport)--sshport[host SSH port (forward to port 22 in VM).]' \
60 '(--upperip)--upperip[VirtualBox host-only network DHCP upper bound.]' \
61 '(--vbm)--vbm[path to VirtualBox management utility.]' \
62 '(--vbox-share)--vbox-share[(defaults to "/Users=Users" if no shares are specified; use "disable" to explicitly prevent any shares from being created) List of directories to share during "up|start|boot" via VirtualBox Guest Additions, with optional labels]' \
63 '(--verbose)'{-v,--verbose}'[display verbose command invocations.]' \
64 '(--vm)--vm[virtual machine name.]' \
65 '(--waittime)--waittime[Time in milliseconds to wait between port knocking retries during 'start']' \
66 '*:: :->subcmds' && return 0
67
68 #_arguments '*:: :->command'
69
70 if (( CURRENT == 1 )); then
71 _describe -t commands "boot2docker command" _1st_arguments
72 return
73 fi
74
1 #compdef brew 1 #compdef brew
2 #autoload 2 #autoload
3 3
4 # imported from the latest homebrew contributions 4 # imported from the latest homebrew contributions
5 5
6 _brew_all_formulae() { 6 _brew_all_formulae() {
7 formulae=(`brew search`) 7 formulae=(`brew search`)
8 } 8 }
9 9
10 _brew_installed_formulae() { 10 _brew_installed_formulae() {
11 installed_formulae=(`brew list`) 11 installed_formulae=(`brew list`)
12 } 12 }
13 13
14 _brew_installed_taps() { 14 _brew_installed_taps() {
15 installed_taps=(`brew tap`) 15 installed_taps=(`brew tap`)
16 } 16 }
17 17
18 _brew_outdated_formulae() { 18 _brew_outdated_formulae() {
19 outdated_formulae=(`brew outdated`) 19 outdated_formulae=(`brew outdated`)
20 } 20 }
21 21
22 local -a _1st_arguments 22 local -a _1st_arguments
23 _1st_arguments=( 23 _1st_arguments=(
24 'audit:check formulae for Homebrew coding style' 24 'audit:check formulae for Homebrew coding style'
25 'cat:display formula file for a formula' 25 'cat:display formula file for a formula'
26 'cleanup:uninstall unused and old versions of packages' 26 'cleanup:uninstall unused and old versions of packages'
27 'commands:show a list of commands' 27 'commands:show a list of commands'
28 'create:create a new formula' 28 'create:create a new formula'
29 'deps:list dependencies of a formula' 29 'deps:list dependencies of a formula'
30 'doctor:audits your installation for common issues' 30 'doctor:audits your installation for common issues'
31 'edit:edit a formula' 31 'edit:edit a formula'
32 'fetch:download formula resources to the cache' 32 'fetch:download formula resources to the cache'
33 'gist-logs:generate a gist of the full build logs' 33 'gist-logs:generate a gist of the full build logs'
34 'home:visit the homepage of a formula or the brew project' 34 'home:visit the homepage of a formula or the brew project'
35 'info:information about a formula' 35 'info:information about a formula'
36 'install:install a formula' 36 'install:install a formula'
37 'reinstall:install a formula anew; re-using its current options' 37 'reinstall:install a formula anew; re-using its current options'
38 'leaves:show installed formulae that are not dependencies of another installed formula'
38 'link:link a formula' 39 'link:link a formula'
39 'list:list files in a formula or not-installed formulae' 40 'list:list files in a formula or not-installed formulae'
40 'log:git commit log for a formula' 41 'log:git commit log for a formula'
41 'missing:check all installed formuale for missing dependencies.' 42 'missing:check all installed formuale for missing dependencies.'
42 'outdated:list formulae for which a newer version is available' 43 'outdated:list formulae for which a newer version is available'
43 'pin:pin specified formulae' 44 'pin:pin specified formulae'
44 'postinstall:perform post_install for a given formula' 45 'postinstall:perform post_install for a given formula'
45 'prune:remove dead links' 46 'prune:remove dead links'
46 'remove:remove a formula' 47 'remove:remove a formula'
47 'search:search for a formula (/regex/ or string)' 48 'search:search for a formula (/regex/ or string)'
48 'switch:switch linkage between installed versions of a formula' 49 'switch:switch linkage between installed versions of a formula'
49 'tap:tap a new formula repository from GitHub, or list existing taps' 50 'tap:tap a new formula repository from GitHub, or list existing taps'
50 'test-bot:test a formula and build a bottle' 51 'test-bot:test a formula and build a bottle'
51 'uninstall:uninstall a formula' 52 'uninstall:uninstall a formula'
52 'unlink:unlink a formula' 53 'unlink:unlink a formula'
53 'unpin:unpin specified formulae' 54 'unpin:unpin specified formulae'
54 'untap:remove a tapped repository' 55 'untap:remove a tapped repository'
55 'update:pull latest repository' 56 'update:pull latest repository'
56 'upgrade:upgrade outdated formulae' 57 'upgrade:upgrade outdated formulae'
57 'uses:show formulae which depend on a formula' 58 'uses:show formulae which depend on a formula'
58 ) 59 )
59 60
60 local expl 61 local expl
61 local -a formulae installed_formulae installed_taps outdated_formulae 62 local -a formulae installed_formulae installed_taps outdated_formulae
62 63
63 _arguments \ 64 _arguments \
64 '(-v)-v[verbose]' \ 65 '(-v)-v[verbose]' \
65 '(--cellar)--cellar[brew cellar]' \ 66 '(--cellar)--cellar[brew cellar]' \
66 '(--config)--config[brew configuration]' \ 67 '(--config)--config[brew configuration]' \
67 '(--env)--env[brew environment]' \ 68 '(--env)--env[brew environment]' \
68 '(--repository)--repository[brew repository]' \ 69 '(--repository)--repository[brew repository]' \
69 '(--version)--version[version information]' \ 70 '(--version)--version[version information]' \
70 '(--prefix)--prefix[where brew lives on this system]' \ 71 '(--prefix)--prefix[where brew lives on this system]' \
71 '(--cache)--cache[brew cache]' \ 72 '(--cache)--cache[brew cache]' \
72 '(--force)--force[brew force]' \ 73 '(--force)--force[brew force]' \
73 '*:: :->subcmds' && return 0 74 '*:: :->subcmds' && return 0
74 75
75 if (( CURRENT == 1 )); then 76 if (( CURRENT == 1 )); then
76 _describe -t commands "brew subcommand" _1st_arguments 77 _describe -t commands "brew subcommand" _1st_arguments
77 return 78 return
78 fi 79 fi
79 80
80 case "$words[1]" in 81 case "$words[1]" in
81 install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options) 82 install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options)
82 _brew_all_formulae 83 _brew_all_formulae
83 _wanted formulae expl 'all formulae' compadd -a formulae ;; 84 _wanted formulae expl 'all formulae' compadd -a formulae ;;
84 list|ls) 85 list|ls)
85 _arguments \ 86 _arguments \
86 '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ 87 '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
87 '(--pinned)--pinned[list all versions of pinned formulae]' \ 88 '(--pinned)--pinned[list all versions of pinned formulae]' \
88 '(--versions)--versions[list all installed versions of a formula]' \ 89 '(--versions)--versions[list all installed versions of a formula]' \
89 '1: :->forms' && return 0 90 '1: :->forms' && return 0
90 91
91 if [[ "$state" == forms ]]; then 92 if [[ "$state" == forms ]]; then
92 _brew_installed_formulae 93 _brew_installed_formulae
93 _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae 94 _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
94 fi ;; 95 fi ;;
95 remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin) 96 remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
96 _brew_installed_formulae 97 _brew_installed_formulae
97 _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; 98 _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
98 search|-S) 99 search|-S)
99 _arguments \ 100 _arguments \
100 '(--macports)--macports[search the macports repository]' \ 101 '(--macports)--macports[search the macports repository]' \
101 '(--fink)--fink[search the fink repository]' ;; 102 '(--fink)--fink[search the fink repository]' ;;
102 untap) 103 untap)
103 _brew_installed_taps 104 _brew_installed_taps
104 _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; 105 _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
105 upgrade) 106 upgrade)
106 _brew_outdated_formulae 107 _brew_outdated_formulae
107 _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; 108 _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
108 esac 109 esac
109 110
plugins/brew/brew.plugin.zsh
1 alias brews='brew list -1' 1 alias brews='brew list -1'
2 alias bubu="brew update && brew upgrade && brew cleanup" 2 alias bubo='brew update && brew outdated'
3 alias bubc='brew upgrade && brew cleanup'
4 alias bubu='bubo && bubc'
3 5
plugins/bundler/README.md
1 # Bundler 1 # Bundler
2 2
3 - adds completion for basic bundler commands 3 - adds completion for basic bundler commands
4 - adds short aliases for common bundler commands 4 - adds short aliases for common bundler commands
5 - `be` aliased to `bundle exec` 5 - `be` aliased to `bundle exec`
6 - `bl` aliased to `bundle list` 6 - `bl` aliased to `bundle list`
7 - `bp` aliased to `bundle package` 7 - `bp` aliased to `bundle package`
8 - `bo` aliased to `bundle open` 8 - `bo` aliased to `bundle open`
9 - `bu` aliased to `bundle update` 9 - `bu` aliased to `bundle update`
10 - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`) 10 - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`)
11 - adds a wrapper for common gems: 11 - adds a wrapper for common gems:
12 - looks for a binstub under `./bin/` and executes it (if present) 12 - looks for a binstub under `./bin/` and executes it (if present)
13 - calls `bundle exec <gem executable>` otherwise 13 - calls `bundle exec <gem executable>` otherwise
14 14
15 For a full list of *common gems* being wrapped by default please look at the `bundler.plugin.zsh` file. 15 For a full list of *common gems* being wrapped by default please look at the `bundler.plugin.zsh` file.
16 16
17 ## Configuration 17 ## Configuration
18 18
19 Please use the exact name of the executable and not the gem name. 19 Please use the exact name of the executable and not the gem name.
20 20
21 ### Add additional gems to be wrapped 21 ### Add additional gems to be wrapped
22 22
23 Add this before the plugin-list in your `.zshrc`: 23 Add this before the plugin-list in your `.zshrc`:
24 ```sh 24 ```sh
25 BUNDLED_COMMANDS=(rubocop) 25 BUNDLED_COMMANDS=(rubocop)
26 plugins=(... bundler ...) 26 plugins=(... bundler ...)
27 ``` 27 ```
28 This will add the wrapper for the `rubocop` gem (i.e. the executable). 28 This will add the wrapper for the `rubocop` gem (i.e. the executable).
29 29
30 30
31 ### Exclude gems from being wrapped 31 ### Exclude gems from being wrapped
32 32
33 Add this before the plugin-list in your `.zshrc`: 33 Add this before the plugin-list in your `.zshrc`:
34 ```sh 34 ```sh
35 UNBUNDLED_COMMANDS=(foreman spin) 35 UNBUNDLED_COMMANDS=(foreman spin)
36 plugins=(... bundler ...) 36 plugins=(... bundler ...)
37 ``` 37 ```
38 This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped. 38 This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
39 39
40 ## Excluded gems 40 ## Excluded gems
41 41
42 These gems should not be called with `bundle exec`. Please see the Issues on GitHub for clarification. 42 These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/robbyrussell/oh-my-zsh/pull/2923) on GitHub for clarification.
43 43
44 `berks` 44 `berks`
45 `foreman` 45 `foreman`
46 `mailcatcher` 46 `mailcatcher`
47 `rails` 47 `rails`
48 `ruby` 48 `ruby`
49 `spin` 49 `spin`
50 50
plugins/bundler/bundler.plugin.zsh
1 alias be="bundle exec" 1 alias be="bundle exec"
2 alias bl="bundle list" 2 alias bl="bundle list"
3 alias bp="bundle package" 3 alias bp="bundle package"
4 alias bo="bundle open" 4 alias bo="bundle open"
5 alias bu="bundle update" 5 alias bu="bundle update"
6 alias bi="bundle_install" 6 alias bi="bundle_install"
7 alias bcn="bundle clean"
7 8
8 bundled_commands=( 9 bundled_commands=(
9 annotate 10 annotate
10 cap 11 cap
11 capify 12 capify
12 cucumber 13 cucumber
13 foodcritic 14 foodcritic
14 guard 15 guard
15 irb 16 irb
16 jekyll 17 jekyll
17 kitchen 18 kitchen
18 knife 19 knife
19 middleman 20 middleman
20 nanoc 21 nanoc
21 pry 22 pry
22 puma 23 puma
23 rackup 24 rackup
24 rainbows 25 rainbows
25 rake 26 rake
26 rspec 27 rspec
27 shotgun 28 shotgun
28 sidekiq 29 sidekiq
29 spec 30 spec
30 spork 31 spork
31 spring 32 spring
32 strainer 33 strainer
33 tailor 34 tailor
34 taps 35 taps
35 thin 36 thin
36 thor 37 thor
37 unicorn 38 unicorn
38 unicorn_rails 39 unicorn_rails
39 ) 40 )
40 41
41 # Remove $UNBUNDLED_COMMANDS from the bundled_commands list 42 # Remove $UNBUNDLED_COMMANDS from the bundled_commands list
42 for cmd in $UNBUNDLED_COMMANDS; do 43 for cmd in $UNBUNDLED_COMMANDS; do
43 bundled_commands=(${bundled_commands#$cmd}); 44 bundled_commands=(${bundled_commands#$cmd});
44 done 45 done
45 46
46 # Add $BUNDLED_COMMANDS to the bundled_commands list 47 # Add $BUNDLED_COMMANDS to the bundled_commands list
47 for cmd in $BUNDLED_COMMANDS; do 48 for cmd in $BUNDLED_COMMANDS; do
48 bundled_commands+=($cmd); 49 bundled_commands+=($cmd);
49 done 50 done
50 51
51 ## Functions 52 ## Functions
52 53
53 bundle_install() { 54 bundle_install() {
54 if _bundler-installed && _within-bundled-project; then 55 if _bundler-installed && _within-bundled-project; then
55 local bundler_version=`bundle version | cut -d' ' -f3` 56 local bundler_version=`bundle version | cut -d' ' -f3`
56 if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then 57 if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
57 if [[ "$OSTYPE" = darwin* ]] 58 if [[ "$OSTYPE" = darwin* ]]
58 then 59 then
59 local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" 60 local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
60 else 61 else
61 local cores_num="$(nproc)" 62 local cores_num="$(nproc)"
62 fi 63 fi
63 bundle install --jobs=$cores_num $@ 64 bundle install --jobs=$cores_num $@
64 else 65 else
65 bundle install $@ 66 bundle install $@
66 fi 67 fi
67 else 68 else
68 echo "Can't 'bundle install' outside a bundled project" 69 echo "Can't 'bundle install' outside a bundled project"
69 fi 70 fi
70 } 71 }
71 72
72 _bundler-installed() { 73 _bundler-installed() {
73 which bundle > /dev/null 2>&1 74 which bundle > /dev/null 2>&1
74 } 75 }
75 76
76 _within-bundled-project() { 77 _within-bundled-project() {
77 local check_dir="$PWD" 78 local check_dir="$PWD"
78 while [ "$check_dir" != "/" ]; do 79 while [ "$check_dir" != "/" ]; do
79 [ -f "$check_dir/Gemfile" ] && return 80 [ -f "$check_dir/Gemfile" ] && return
80 check_dir="$(dirname $check_dir)" 81 check_dir="$(dirname $check_dir)"
81 done 82 done
82 false 83 false
83 } 84 }
84 85
85 _binstubbed() { 86 _binstubbed() {
86 [ -f "./bin/${1}" ] 87 [ -f "./bin/${1}" ]
87 } 88 }
88 89
89 _run-with-bundler() { 90 _run-with-bundler() {
90 if _bundler-installed && _within-bundled-project; then 91 if _bundler-installed && _within-bundled-project; then
91 if _binstubbed $1; then 92 if _binstubbed $1; then
92 ./bin/$@ 93 ./bin/$@
93 else 94 else
94 bundle exec $@ 95 bundle exec $@
95 fi 96 fi
96 else 97 else
97 $@ 98 $@
98 fi 99 fi
99 } 100 }
100 101
101 ## Main program 102 ## Main program
102 for cmd in $bundled_commands; do 103 for cmd in $bundled_commands; do
103 eval "function unbundled_$cmd () { $cmd \$@ }" 104 eval "function unbundled_$cmd () { $cmd \$@ }"
104 eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}" 105 eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
105 alias $cmd=bundled_$cmd 106 alias $cmd=bundled_$cmd
106 107
107 if which _$cmd > /dev/null 2>&1; then 108 if which _$cmd > /dev/null 2>&1; then
108 compdef _$cmd bundled_$cmd=$cmd 109 compdef _$cmd bundled_$cmd=$cmd
109 fi 110 fi
110 done 111 done
111 112
plugins/cakephp3/cakephp3.plugin.zsh
File was created 1 # CakePHP 3 basic command completion
2 _cakephp3_get_command_list () {
3 cakephp3commands=($(bin/cake completion commands));printf "%s\n" "${cakephp3commands[@]}"
4 }
5
6 _cakephp3 () {
7 if [ -f bin/cake ]; then
8 compadd `_cakephp3_get_command_list`
9 fi
10 }
11
12 compdef _cakephp3 bin/cake
13 compdef _cakephp3 cake
14
15 #Alias
16 alias c3='bin/cake'
17
18 alias c3cache='bin/cake orm_cache clear'
19 alias c3migrate='bin/cake migrations migrate'
20
plugins/coffee/README.md
File was created 1 ## Coffeescript Plugin
2
3 This plugin provides aliases for quickly compiling and previewing your
4 cofeescript code.
5
6 When writing Coffeescript it's very common to want to preview the output of a
7 certain snippet of code, either because you want to test the output or because
8 you'd like to execute it in a browser console which doesn't accept Coffeescript.
9
10 Preview the compiled result of your coffeescript with `cf "code"` as per the
11 following:
12
13 ```zsh
14 $ cf 'if a then be else c'
15 if (a) {
16 b;
17 } else {
18 c;
19 }
20 ```
21
22 Also provides the following aliases:
23
24 * **cfc:** Copies the compiled JS to your clipboard. Very useful when you want
25 to run the code in a JS console.
26
27 * **cfp:** Compiles from your currently copied clipboard. Useful when you want
28 to compile large/multi-line snippets
29
30 * **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the
31 the result back to clipboard.
32
plugins/coffee/coffee.plugin.zsh
File was created 1 #!/bin/zsh
2
3 # compile a string of coffeescript and print to output
4 cf () {
5 coffee -peb $1
6 }
7 # compile & copy to clipboard
8 cfc () {
9 cf $1 | pbcopy
10 }
11
12 # compile from pasteboard & print
13 alias cfp='coffeeMe "$(pbpaste)"'
14
15 # compile from pasteboard and copy to clipboard
16 alias cfpc='cfp | pbcopy'
17
plugins/common-aliases/common-aliases.plugin.zsh
1 # Advanced Aliases. 1 # Advanced Aliases.
2 # Use with caution 2 # Use with caution
3 # 3 #
4 4
5 # ls, the common ones I use a lot shortened for rapid fire usage 5 # ls, the common ones I use a lot shortened for rapid fire usage
6 alias l='ls -lFh' #size,show type,human readable 6 alias l='ls -lFh' #size,show type,human readable
7 alias la='ls -lAFh' #long list,show almost all,show type,human readable 7 alias la='ls -lAFh' #long list,show almost all,show type,human readable
8 alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable 8 alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable
9 alias lt='ls -ltFh' #long list,sorted by date,show type,human readable 9 alias lt='ls -ltFh' #long list,sorted by date,show type,human readable
10 alias ll='ls -l' #long list 10 alias ll='ls -l' #long list
11 alias ldot='ls -ld .*' 11 alias ldot='ls -ld .*'
12 alias lS='ls -1FSsh' 12 alias lS='ls -1FSsh'
13 alias lart='ls -1Fcart' 13 alias lart='ls -1Fcart'
14 alias lrt='ls -1Fcrt' 14 alias lrt='ls -1Fcrt'
15 15
16 alias zshrc='vim ~/.zshrc' # Quick access to the ~/.zshrc file 16 alias zshrc='$EDITOR ~/.zshrc' # Quick access to the ~/.zshrc file
17 17
18 alias grep='grep --color' 18 alias grep='grep --color'
19 alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' 19 alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
20 20
21 alias t='tail -f' 21 alias t='tail -f'
22 22
23 # Command line head / tail shortcuts 23 # Command line head / tail shortcuts
24 alias -g H='| head' 24 alias -g H='| head'
25 alias -g T='| tail' 25 alias -g T='| tail'
26 alias -g G='| grep' 26 alias -g G='| grep'
27 alias -g L="| less" 27 alias -g L="| less"
28 alias -g M="| most" 28 alias -g M="| most"
29 alias -g LL="2>&1 | less" 29 alias -g LL="2>&1 | less"
30 alias -g CA="2>&1 | cat -A" 30 alias -g CA="2>&1 | cat -A"
31 alias -g NE="2> /dev/null" 31 alias -g NE="2> /dev/null"
32 alias -g NUL="> /dev/null 2>&1" 32 alias -g NUL="> /dev/null 2>&1"
33 alias -g P="2>&1| pygmentize -l pytb" 33 alias -g P="2>&1| pygmentize -l pytb"
34 34
35 alias dud='du -d 1 -h' 35 alias dud='du -d 1 -h'
36 alias duf='du -sh *' 36 alias duf='du -sh *'
37 alias fd='find . -type d -name' 37 alias fd='find . -type d -name'
38 alias ff='find . -type f -name' 38 alias ff='find . -type f -name'
39 39
40 alias h='history' 40 alias h='history'
41 alias hgrep="fc -El 0 | grep" 41 alias hgrep="fc -El 0 | grep"
42 alias help='man' 42 alias help='man'
43 alias p='ps -f' 43 alias p='ps -f'
44 alias sortnr='sort -n -r' 44 alias sortnr='sort -n -r'
45 alias unexport='unset' 45 alias unexport='unset'
46 46
47 alias whereami=display_info 47 alias whereami=display_info
48 48
49 alias rm='rm -i' 49 alias rm='rm -i'
50 alias cp='cp -i' 50 alias cp='cp -i'
51 alias mv='mv -i' 51 alias mv='mv -i'
52 52
53 # zsh is able to auto-do some kungfoo 53 # zsh is able to auto-do some kungfoo
54 # depends on the SUFFIX :) 54 # depends on the SUFFIX :)
55 if [ ${ZSH_VERSION//\./} -ge 420 ]; then 55 if [ ${ZSH_VERSION//\./} -ge 420 ]; then
56 # open browser on urls 56 # open browser on urls
57 _browser_fts=(htm html de org net com at cx nl se dk dk php) 57 _browser_fts=(htm html de org net com at cx nl se dk dk php)
58 for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done 58 for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done
59 59
60 _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) 60 _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
61 for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done 61 for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done
62 62
63 _image_fts=(jpg jpeg png gif mng tiff tif xpm) 63 _image_fts=(jpg jpeg png gif mng tiff tif xpm)
64 for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done 64 for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done
65 65
66 _media_fts=(ape avi flv mkv mov mp3 mpeg mpg ogg ogm rm wav webm) 66 _media_fts=(ape avi flv mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
67 for ft in $_media_fts ; do alias -s $ft=mplayer ; done 67 for ft in $_media_fts ; do alias -s $ft=mplayer ; done
68 68
69 #read documents 69 #read documents
70 alias -s pdf=acroread 70 alias -s pdf=acroread
71 alias -s ps=gv 71 alias -s ps=gv
72 alias -s dvi=xdvi 72 alias -s dvi=xdvi
73 alias -s chm=xchm 73 alias -s chm=xchm
74 alias -s djvu=djview 74 alias -s djvu=djview
75 75
76 #list whats inside packed file 76 #list whats inside packed file
77 alias -s zip="unzip -l" 77 alias -s zip="unzip -l"
78 alias -s rar="unrar l" 78 alias -s rar="unrar l"
79 alias -s tar="tar tf" 79 alias -s tar="tar tf"
80 alias -s tar.gz="echo " 80 alias -s tar.gz="echo "
81 alias -s ace="unace l" 81 alias -s ace="unace l"
82 fi 82 fi
83 83
84 # Make zsh know about hosts already accessed by SSH 84 # Make zsh know about hosts already accessed by SSH
85 zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' 85 zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
86 86
87 87
plugins/debian/debian.plugin.zsh
1 # Authors: 1 # Authors:
2 # https://github.com/AlexBio 2 # https://github.com/AlexBio
3 # https://github.com/dbb 3 # https://github.com/dbb
4 # https://github.com/Mappleconfusers 4 # https://github.com/Mappleconfusers
5 # 5 #
6 # Debian-related zsh aliases and functions for zsh 6 # Debian-related zsh aliases and functions for zsh
7 7
8 # Use aptitude if installed, or apt-get if not. 8 # Use aptitude if installed, or apt-get if not.
9 # You can just set apt_pref='apt-get' to override it. 9 # You can just set apt_pref='apt-get' to override it.
10 if [[ -e $( which -p aptitude 2>&1 ) ]]; then 10 if [[ -e $( which -p aptitude 2>&1 ) ]]; then
11 apt_pref='aptitude' 11 apt_pref='aptitude'
12 apt_upgr='safe-upgrade'
12 else 13 else
13 apt_pref='apt-get' 14 apt_pref='apt-get'
15 apt_upgr='upgrade'
14 fi 16 fi
15 17
16 # Use sudo by default if it's installed 18 # Use sudo by default if it's installed
17 if [[ -e $( which -p sudo 2>&1 ) ]]; then 19 if [[ -e $( which -p sudo 2>&1 ) ]]; then
18 use_sudo=1 20 use_sudo=1
19 fi 21 fi
20 22
21 # Aliases ################################################################### 23 # Aliases ###################################################################
22 # These are for more obscure uses of apt-get and aptitude that aren't covered 24 # These are for more obscure uses of apt-get and aptitude that aren't covered
23 # below. 25 # below.
24 alias age='apt-get' 26 alias age='apt-get'
25 alias api='aptitude' 27 alias api='aptitude'
26 28
27 # Some self-explanatory aliases 29 # Some self-explanatory aliases
28 alias acs="apt-cache search" 30 alias acs="apt-cache search"
29 alias aps='aptitude search' 31 alias aps='aptitude search'
30 alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \ 32 alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \
31 --no-gui --disable-columns search" # search package 33 --no-gui --disable-columns search" # search package
32 34
33 # apt-file 35 # apt-file
34 alias afs='apt-file search --regexp' 36 alias afs='apt-file search --regexp'
35 37
36 38
37 # These are apt-get only 39 # These are apt-get only
38 alias asrc='apt-get source' 40 alias asrc='apt-get source'
39 alias app='apt-cache policy' 41 alias app='apt-cache policy'
40 42
41 # superuser operations ###################################################### 43 # superuser operations ######################################################
42 if [[ $use_sudo -eq 1 ]]; then 44 if [[ $use_sudo -eq 1 ]]; then
43 # commands using sudo ####### 45 # commands using sudo #######
44 alias aac='sudo $apt_pref autoclean' 46 alias aac='sudo $apt_pref autoclean'
45 alias abd='sudo $apt_pref build-dep' 47 alias abd='sudo $apt_pref build-dep'
46 alias ac='sudo $apt_pref clean' 48 alias ac='sudo $apt_pref clean'
47 alias ad='sudo $apt_pref update' 49 alias ad='sudo $apt_pref update'
48 alias adg='sudo $apt_pref update && sudo $apt_pref upgrade' 50 alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr'
49 alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade' 51 alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade'
50 alias afu='sudo apt-file update' 52 alias afu='sudo apt-file update'
51 alias ag='sudo $apt_pref upgrade' 53 alias ag='sudo $apt_pref $apt_upgr'
52 alias ai='sudo $apt_pref install' 54 alias ai='sudo $apt_pref install'
53 # Install all packages given on the command line while using only the first word of each line: 55 # Install all packages given on the command line while using only the first word of each line:
54 # acs ... | ail 56 # acs ... | ail
55 alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install' 57 alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install'
56 alias ap='sudo $apt_pref purge' 58 alias ap='sudo $apt_pref purge'
57 alias ar='sudo $apt_pref remove' 59 alias ar='sudo $apt_pref remove'
58 60
59 # apt-get only 61 # apt-get only
60 alias ads='sudo apt-get dselect-upgrade' 62 alias ads='sudo apt-get dselect-upgrade'
61 63
62 # Install all .deb files in the current directory. 64 # Install all .deb files in the current directory.
63 # Warning: you will need to put the glob in single quotes if you use: 65 # Warning: you will need to put the glob in single quotes if you use:
64 # glob_subst 66 # glob_subst
65 alias dia='sudo dpkg -i ./*.deb' 67 alias dia='sudo dpkg -i ./*.deb'
66 alias di='sudo dpkg -i' 68 alias di='sudo dpkg -i'
67 69
68 # Remove ALL kernel images and headers EXCEPT the one in use 70 # Remove ALL kernel images and headers EXCEPT the one in use
69 alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ 71 alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
70 ?not(~n`uname -r`))' 72 ?not(~n`uname -r`))'
71 73
72 74
73 # commands using su ######### 75 # commands using su #########
74 else 76 else
75 alias aac='su -ls \'$apt_pref autoclean\' root' 77 alias aac='su -ls \'$apt_pref autoclean\' root'
76 abd() { 78 abd() {
77 cmd="su -lc '$apt_pref build-dep $@' root" 79 cmd="su -lc '$apt_pref build-dep $@' root"
78 print "$cmd" 80 print "$cmd"
79 eval "$cmd" 81 eval "$cmd"
80 } 82 }
81 alias ac='su -ls \'$apt_pref clean\' root' 83 alias ac='su -ls \'$apt_pref clean\' root'
82 alias ad='su -lc \'$apt_pref update\' root' 84 alias ad='su -lc \'$apt_pref update\' root'
83 alias adg='su -lc \'$apt_pref update && aptitude safe-upgrade\' root' 85 alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root'
84 alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root' 86 alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root'
85 alias afu='su -lc "apt-file update"' 87 alias afu='su -lc "apt-file update"'
86 alias ag='su -lc \'$apt_pref safe-upgrade\' root' 88 alias ag='su -lc \'$apt_pref $apt_upgr\' root'
87 ai() { 89 ai() {
88 cmd="su -lc 'aptitude -P install $@' root" 90 cmd="su -lc 'aptitude -P install $@' root"
89 print "$cmd" 91 print "$cmd"
90 eval "$cmd" 92 eval "$cmd"
91 } 93 }
92 ap() { 94 ap() {
93 cmd="su -lc '$apt_pref -P purge $@' root" 95 cmd="su -lc '$apt_pref -P purge $@' root"
94 print "$cmd" 96 print "$cmd"
95 eval "$cmd" 97 eval "$cmd"
96 } 98 }
97 ar() { 99 ar() {
98 cmd="su -lc '$apt_pref -P remove $@' root" 100 cmd="su -lc '$apt_pref -P remove $@' root"
99 print "$cmd" 101 print "$cmd"
100 eval "$cmd" 102 eval "$cmd"
101 } 103 }
102 104
103 # Install all .deb files in the current directory 105 # Install all .deb files in the current directory
104 # Assumes glob_subst is off 106 # Assumes glob_subst is off
105 alias dia='su -lc "dpkg -i ./*.deb" root' 107 alias dia='su -lc "dpkg -i ./*.deb" root'
106 alias di='su -lc "dpkg -i" root' 108 alias di='su -lc "dpkg -i" root'
107 109
108 # Remove ALL kernel images and headers EXCEPT the one in use 110 # Remove ALL kernel images and headers EXCEPT the one in use
109 alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \ 111 alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \
110 ?not(~n`uname -r`))'\'' root' 112 ?not(~n`uname -r`))'\'' root'
111 fi 113 fi
112 114
113 # Completion ################################################################ 115 # Completion ################################################################
114 116
115 # 117 #
116 # Registers a compdef for $1 that calls $apt_pref with the commands $2 118 # Registers a compdef for $1 that calls $apt_pref with the commands $2
117 # To do that it creates a new completion function called _apt_pref_$2 119 # To do that it creates a new completion function called _apt_pref_$2
118 # 120 #
119 apt_pref_compdef() { 121 apt_pref_compdef() {
120 local f fb 122 local f fb
121 f="_apt_pref_${2}" 123 f="_apt_pref_${2}"
122 124
123 eval "function ${f}() { 125 eval "function ${f}() {
124 shift words; 126 shift words;
125 service=\"\$apt_pref\"; 127 service=\"\$apt_pref\";
126 words=(\"\$apt_pref\" '$2' \$words); 128 words=(\"\$apt_pref\" '$2' \$words);
127 ((CURRENT++)) 129 ((CURRENT++))
128 test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt 130 test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
129 }" 131 }"
130 132
131 compdef "$f" "$1" 133 compdef "$f" "$1"
132 } 134 }
133 135
134 apt_pref_compdef aac "autoclean" 136 apt_pref_compdef aac "autoclean"
135 apt_pref_compdef abd "build-dep" 137 apt_pref_compdef abd "build-dep"
136 apt_pref_compdef ac "clean" 138 apt_pref_compdef ac "clean"
137 apt_pref_compdef ad "update" 139 apt_pref_compdef ad "update"
138 apt_pref_compdef afu "update" 140 apt_pref_compdef afu "update"
139 apt_pref_compdef ag "upgrade" 141 apt_pref_compdef ag "$apt_upgr"
140 apt_pref_compdef ai "install" 142 apt_pref_compdef ai "install"
141 apt_pref_compdef ail "install" 143 apt_pref_compdef ail "install"
142 apt_pref_compdef ap "purge" 144 apt_pref_compdef ap "purge"
143 apt_pref_compdef ar "remove" 145 apt_pref_compdef ar "remove"
144 apt_pref_compdef ads "dselect-upgrade" 146 apt_pref_compdef ads "dselect-upgrade"
145 147
146 # Misc. ##################################################################### 148 # Misc. #####################################################################
147 # print all installed packages 149 # print all installed packages
148 alias allpkgs='aptitude search -F "%p" --disable-columns ~i' 150 alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
149 151
150 # Create a basic .deb package 152 # Create a basic .deb package
151 alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' 153 alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
152 154
153 155
154 # Functions ################################################################# 156 # Functions #################################################################
155 # create a simple script that can be used to 'duplicate' a system 157 # create a simple script that can be used to 'duplicate' a system
156 apt-copy() { 158 apt-copy() {
157 print '#!/bin/sh'"\n" > apt-copy.sh 159 print '#!/bin/sh'"\n" > apt-copy.sh
158 160
159 cmd='$apt_pref install' 161 cmd='$apt_pref install'
160 162
161 for p in ${(f)"$(aptitude search -F "%p" --disable-columns \~i)"}; { 163 for p in ${(f)"$(aptitude search -F "%p" --disable-columns \~i)"}; {
162 cmd="${cmd} ${p}" 164 cmd="${cmd} ${p}"
163 } 165 }
164 166
165 print $cmd "\n" >> apt-copy.sh 167 print $cmd "\n" >> apt-copy.sh
166 168
167 chmod +x apt-copy.sh 169 chmod +x apt-copy.sh
168 } 170 }
169 171
170 # Prints apt history 172 # Prints apt history
171 # Usage: 173 # Usage:
172 # apt-history install 174 # apt-history install
173 # apt-history upgrade 175 # apt-history upgrade
174 # apt-history remove 176 # apt-history remove
175 # apt-history rollback 177 # apt-history rollback
176 # apt-history list 178 # apt-history list
177 # Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html 179 # Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
178 apt-history () { 180 apt-history () {
179 case "$1" in 181 case "$1" in
180 install) 182 install)
181 zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) 183 zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
182 ;; 184 ;;
183 upgrade|remove) 185 upgrade|remove)
184 zgrep --no-filename $1 $(ls -rt /var/log/dpkg*) 186 zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
185 ;; 187 ;;
186 rollback) 188 rollback)
187 zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \ 189 zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
188 grep "$2" -A10000000 | \ 190 grep "$2" -A10000000 | \
189 grep "$3" -B10000000 | \ 191 grep "$3" -B10000000 | \
190 awk '{print $4"="$5}' 192 awk '{print $4"="$5}'
191 ;; 193 ;;
192 list) 194 list)
193 zcat $(ls -rt /var/log/dpkg*) 195 zcat $(ls -rt /var/log/dpkg*)
194 ;; 196 ;;
195 *) 197 *)
196 echo "Parameters:" 198 echo "Parameters:"
197 echo " install - Lists all packages that have been installed." 199 echo " install - Lists all packages that have been installed."
198 echo " upgrade - Lists all packages that have been upgraded." 200 echo " upgrade - Lists all packages that have been upgraded."
199 echo " remove - Lists all packages that have been removed." 201 echo " remove - Lists all packages that have been removed."
200 echo " rollback - Lists rollback information." 202 echo " rollback - Lists rollback information."
201 echo " list - Lists all contains of dpkg logs." 203 echo " list - Lists all contains of dpkg logs."
202 ;; 204 ;;
203 esac 205 esac
204 } 206 }
205 207
206 # Kernel-package building shortcut 208 # Kernel-package building shortcut
207 kerndeb () { 209 kerndeb () {
208 # temporarily unset MAKEFLAGS ( '-j3' will fail ) 210 # temporarily unset MAKEFLAGS ( '-j3' will fail )
209 MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) 211 MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
210 print '$MAKEFLAGS set to '"'$MAKEFLAGS'" 212 print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
211 appendage='-custom' # this shows up in $ (uname -r ) 213 appendage='-custom' # this shows up in $ (uname -r )
212 revision=$(date +"%Y%m%d") # this shows up in the .deb file name 214 revision=$(date +"%Y%m%d") # this shows up in the .deb file name
213 215
214 make-kpkg clean 216 make-kpkg clean
215 217
216 time fakeroot make-kpkg --append-to-version "$appendage" --revision \ 218 time fakeroot make-kpkg --append-to-version "$appendage" --revision \
217 "$revision" kernel_image kernel_headers 219 "$revision" kernel_image kernel_headers
218 } 220 }
219 221
220 # List packages by size 222 # List packages by size
221 function apt-list-packages { 223 function apt-list-packages {
222 dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ 224 dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
223 grep -v deinstall | \ 225 grep -v deinstall | \
224 sort -n | \ 226 sort -n | \
225 awk '{print $1" "$2}' 227 awk '{print $1" "$2}'
226 } 228 }
227 229
228 230
plugins/docker-compose/README.md
File was created 1 # Docker-compose plugin for oh my zsh
2
plugins/docker-compose/docker-compose.plugin.zsh
File was created 1 # Authors:
2 # https://github.com/tristola
3 #
4 # Docker-compose related zsh aliases
5
6 # Aliases ###################################################################
7
8 alias dcup='docker-compose up'
9 alias dcb='docker-compose build'
10 alias dcrm='docker-compose rm'
11 alias dcps='docker-compose ps'
12 alias dcstop='docker-compose stop'
13 alias dcrestart='docker-compose restart'
14
15
plugins/docker/_docker
1 #compdef docker 1 #compdef docker
2 2
3 # Docker autocompletion for oh-my-zsh 3 # Docker autocompletion for oh-my-zsh
4 # Requires: Docker installed 4 # Requires: Docker installed
5 # Author: Azaan (@aeonazaan) 5 # Author: Azaan (@aeonazaan)
6 # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ 6 # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
7 # Paul van den Berg (@bergvandenp) for Docker v1.3+ 7 # Paul van den Berg (@bergvandenp) for Docker v1.3+
8 8
9 9
10 # ----- Helper functions 10 # ----- Helper functions
11 # Output a selectable list of all running docker containers 11 # Output a selectable list of all running docker containers
12 __docker_containers() { 12 __docker_containers() {
13 declare -a cont_cmd 13 declare -a cont_cmd
14 cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) 14 cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
15 if [[ 'X$cont_cmd' != 'X' ]] 15 if [[ 'X$cont_cmd' != 'X' ]]
16 _describe 'containers' cont_cmd 16 _describe 'containers' cont_cmd
17 } 17 }
18 18
19 # Output a selectable list of all containers, even not running 19 # Output a selectable list of all containers, even not running
20 __docker_all_containers() { 20 __docker_all_containers() {
21 declare -a cont_cmd 21 declare -a cont_cmd
22 cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) 22 cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
23 if [[ 'X$cont_cmd' != 'X' ]] 23 if [[ 'X$cont_cmd' != 'X' ]]
24 _describe 'containers' cont_cmd 24 _describe 'containers' cont_cmd
25 } 25 }
26 26
27 # output a selectable list of all docker images 27 # output a selectable list of all docker images
28 __docker_images() { 28 __docker_images() {
29 declare -a img_cmd 29 declare -a img_cmd
30 img_cmd=($(docker images | awk 'NR>1{print $1}')) 30 img_cmd=($(docker images | awk 'NR>1{print $1}'))
31 _describe 'images' img_cmd 31 _describe 'images' img_cmd
32 } 32 }
33 33
34 # ----- Commands 34 # ----- Commands
35 # Seperate function for each command, makes extension easier later 35 # Seperate function for each command, makes extension easier later
36 # --------------------------- 36 # ---------------------------
37 __attach() { 37 __attach() {
38 _arguments \ 38 _arguments \
39 '--no-stdin[Do not attach stdin]' \ 39 '--no-stdin[Do not attach STDIN]' \
40 '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]' 40 '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]'
41 __docker_containers 41 __docker_containers
42 } 42 }
43 43
44 __build() { 44 __build() {
45 _arguments \ 45 _arguments \
46 '--no-cache[Do not use cache when building the image]' \ 46 '--no-cache[Do not use cache when building the image]' \
47 '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \ 47 '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \
48 '--rm[Remove intermediate containers after a successful build]' \ 48 '--rm[Remove intermediate containers after a successful build]' \
49 '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \ 49 '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \
50 '*:files:_files' 50 '*:files:_files'
51 } 51 }
52 52
53 __commit() { 53 __commit() {
54 _arguments \ 54 _arguments \
55 '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith <hannibal@a-team.com>"]' \ 55 '(-a,--author=)'{-a,--author=}'[Author (e.g. "John Hannibal Smith <hannibal@a-team.com>")]' \
56 '(-c,--change=)'{-c,--change=}'[Apply Dockerfile instruction to the created image]' \
56 '(-m,--message=)'{-m,--message=}'[Commit message]' \ 57 '(-m,--message=)'{-m,--message=}'[Commit message]' \
57 '--run=[Config automatically applied when the image is run.]' 58 '(-p,--pause=)'{-p,--pause=}'[Pause container during commit]' \
58 __docker_containers
59 } 59 }
60 60
61 __cp() { 61 __cp() {
62 __docker_containers 62 __docker_containers
63 } 63 }
64 64
65 __create() {
66 _arguments \
67 '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
68 '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \
69 '--add-host=[Add a custom host-to-IP mapping]' \
70 '--cap-add=[Add Linux capabilities]' \
71 '--cap-drop=[Drop Linux capabilities]' \
72 '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \
73 '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \
74 '--cidfile=[Write the container ID to the file]' \
75 '--device=[Add a host device to the container]' \
76 '--dns=[Set custom dns servers]' \
77 '--dns-search=[Set custom DNS search domains]' \
78 '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
79 '--env-file=[Read in a file of environment variables]' \
80 '--entrypoint=[Overwrite the default entrypoint of the image]' \
81 '--expose=[Expose a port from the container without publishing it to your host]' \
82 '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
83 '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
84 '--ipc=[IPC namespace to use]' \
85 '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \
86 '--link=[Add link to another container (name:alias)]' \
87 '--log-driver=[Logging driver for the container]' \
88 '--lxc-conf=[Add custom LXC options]' \
89 '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \
90 '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
91 '--net=[Set the Network mode for the container]' \
92 '--name=[Assign a name to the container]' \
93 '--pid=[PID namespace to use]' \
94 '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \
95 '--privileged=[Give extended privileges to this container]' \
96 '--restart=[Restart policy to apply when a container exits]' \
97 '--security-opt=[Security Options]' \
98 '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
99 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
100 '(-u,--user=)'{-u,--user=}'[Username or UID]' \
101 '--ulimit=[Ulimit options]' \
102 '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \
103 '--volumes-from=[Mount volumes from the specified container(s)]' \
104 '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
105 __docker_images
106 }
107
65 __diff() { 108 __diff() {
66 __docker_containers 109 __docker_containers
67 } 110 }
68 111
69 __events() { 112 __events() {
70 _arguments \ 113 _arguments \
71 '--since=[Show previously created events and then stream.]' 114 '--since=[Show previously created events and then stream.]'
72 } 115 }
73 116
74 __export() { 117 __export() {
75 __docker_containers 118 __docker_containers
76 } 119 }
77 120
78 __history() { 121 __history() {
79 _arguments \ 122 _arguments \
80 '--no-trunc=[Don''t truncate output]' \ 123 '--no-trunc=[Don''t truncate output]' \
81 '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]' 124 '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]'
82 __docker_images 125 __docker_images
83 } 126 }
84 127
85 __images() { 128 __images() {
86 _arguments \ 129 _arguments \
87 '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \ 130 '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \
88 '--no-trunc[Don''t truncate output]' \ 131 '--no-trunc[Don''t truncate output]' \
89 '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \ 132 '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \
90 '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \ 133 '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \
91 '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]' 134 '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]'
92 __docker_images 135 __docker_images
93 } 136 }
94 137
95 __import() { 138 __import() {
96 _arguments '*:files:_files' 139 _arguments '*:files:_files'
97 } 140 }
98 141
99 __info() { 142 __info() {
100 # no arguments 143 # no arguments
101 } 144 }
102 145
103 __insert() {
104 __docker_images
105 _arguments '*:files:_files'
106 }
107
108 __inspect() { 146 __inspect() {
109 __docker_images 147 __docker_images
110 __docker_all_containers 148 __docker_all_containers
111 } 149 }
112 150
113 __kill() { 151 __kill() {
114 _arguments \ 152 _arguments \
115 '(-s,--signal=)'{-s,--signal=}'[KILL Signal]' 153 '(-s,--signal=)'{-s,--signal=}'[KILL Signal]'
116 __docker_containers 154 __docker_containers
117 } 155 }
118 156
119 __load() { 157 __load() {
120 _arguments '*:files:_files' 158 _arguments '*:files:_files'
121 } 159 }
122 160
123 __login() { 161 __login() {
124 _arguments \ 162 _arguments \
125 '(-e,--email=)'{-e,-email=}'[Email]' \ 163 '(-e,--email=)'{-e,-email=}'[Email]' \
126 '(-p,--password=)'{-p,-password=}'[Password]' \ 164 '(-p,--password=)'{-p,-password=}'[Password]' \
127 '(-u,--username=)'{-u,-username=}'[Username]' 165 '(-u,--username=)'{-u,-username=}'[Username]'
128 } 166 }
129 167
130 __logs() { 168 __logs() {
131 _arguments \ 169 _arguments \
132 '(-f,--follow)'{-f,-follow}'[Follow log output]' 170 '(-f,--follow)'{-f,-follow}'[Follow log output]'
133 __docker_containers 171 __docker_containers
134 } 172 }
135 173
136 __port() { 174 __port() {
137 __docker_containers 175 __docker_containers
138 } 176 }
139 177
140 __top() { 178 __top() {
141 __docker_containers 179 __docker_containers
142 } 180 }
143 181
144 __ps() { 182 __ps() {
145 _arguments \ 183 _arguments \
146 '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \ 184 '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \
147 '--before-id=[Show only container created before Id, include non-running ones.]' \ 185 '--before-id=[Show only container created before Id, include non-running ones.]' \
148 '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \ 186 '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \
149 '-n=[Show n last created containers, include non-running ones. default=-1.]' \ 187 '-n=[Show n last created containers, include non-running ones. default=-1.]' \
150 '--no-trunc[Don''t truncate output]' \ 188 '--no-trunc[Don''t truncate output]' \
151 '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \ 189 '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \
152 '(-s,--size)'{-s,--size}'[Display sizes]' \ 190 '(-s,--size)'{-s,--size}'[Display sizes]' \
153 '--since-id=[Show only containers created since Id, include non-running ones.]' 191 '--since-id=[Show only containers created since Id, include non-running ones.]'
154 } 192 }
155 193
156 __pull() { 194 __pull() {
157 _arguments \ 195 _arguments \
158 '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]' 196 '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]'
159 } 197 }
160 198
161 __push() { 199 __push() {
162 # no arguments 200 # no arguments
163 } 201 }
164 202
165 __restart() { 203 __restart() {
166 _arguments \ 204 _arguments \
167 '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]' 205 '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]'
168 __docker_containers 206 __docker_containers
169 } 207 }
170 208
171 __rm() { 209 __rm() {
172 _arguments \ 210 _arguments \
173 '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ 211 '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
174 '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ 212 '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
175 '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' 213 '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
176 __docker_all_containers 214 __docker_all_containers
177 } 215 }
178 216
179 __rmi() { 217 __rmi() {
180 _arguments \ 218 _arguments \
181 '(-f,--force=)'{-f,--force=}'[Force]' 219 '(-f,--force=)'{-f,--force=}'[Force]'
182 __docker_images 220 __docker_images
183 } 221 }
184 222
185 __run() { 223 __run() {
186 _arguments \ 224 _arguments \
187 '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ 225 '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
188 '(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \ 226 '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \
189 '(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \ 227 '--add-host=[Add a custom host-to-IP mapping]' \
228 '--cap-add=[Add Linux capabilities]' \
229 '--cap-drop=[Drop Linux capabilities]' \
230 '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \
231 '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \
190 '--cidfile=[Write the container ID to the file]' \ 232 '--cidfile=[Write the container ID to the file]' \
191 '(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \ 233 '(-d,--detach=)'{-d,--detach=}'[Run container in the background, print new container id]' \
234 '--device=[Add a host device to the container]' \
192 '--dns=[Set custom dns servers]' \ 235 '--dns=[Set custom dns servers]' \
236 '--dns-search=[Set custom DNS search domains]' \
193 '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ 237 '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
238 '--env-file=[Read in a file of environment variables]' \
194 '--entrypoint=[Overwrite the default entrypoint of the image]' \ 239 '--entrypoint=[Overwrite the default entrypoint of the image]' \
195 '--expose=[Expose a port from the container without publishing it to your host]' \ 240 '--expose=[Expose a port from the container without publishing it to your host]' \
196 '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ 241 '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
197 '(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \ 242 '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
243 '--ipc=[IPC namespace to use]' \
244 '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \
198 '--link=[Add link to another container (name:alias)]' \ 245 '--link=[Add link to another container (name:alias)]' \
199 '--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \ 246 '--log-driver=[Logging driver for the container]' \
247 '--lxc-conf=[Add custom LXC options]' \
248 '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \
200 '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \ 249 '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
201 '(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \ 250 '--net=[Set the Network mode for the container]' \
202 '--name=[Assign a name to the container]' \ 251 '--name=[Assign a name to the container]' \
203 '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \ 252 '--pid=[PID namespace to use]' \
253 '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \
204 '--privileged=[Give extended privileges to this container]' \ 254 '--privileged=[Give extended privileges to this container]' \
255 '--restart=[Restart policy to apply when a container exits]' \
205 '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \ 256 '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \
257 '--security-opt=[Security Options]' \
206 '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ 258 '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
207 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ 259 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
208 '(-u,--user=)'{-u,--user=}'[Username or UID]' \ 260 '(-u,--user=)'{-u,--user=}'[Username or UID]' \
209 '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ 261 '--ulimit=[Ulimit options]' \
262 '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \
210 '--volumes-from=[Mount volumes from the specified container(s)]' \ 263 '--volumes-from=[Mount volumes from the specified container(s)]' \
211 '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' 264 '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
212 __docker_images 265 __docker_images
213 } 266 }
214 267
215 __search() { 268 __search() {
216 _arguments \ 269 _arguments \
217 '--no-trunc=[Don''t truncate output]' \ 270 '--no-trunc=[Don''t truncate output]' \
218 '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \ 271 '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \
219 '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]' 272 '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]'
220 } 273 }
221 274
222 __save() { 275 __save() {
223 __docker_images 276 __docker_images
224 } 277 }
225 278
226 __start() { 279 __start() {
227 _arguments \ 280 _arguments \
228 '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ 281 '(-a,--attach=)'{-a,--attach=}'[Attach container''s STDOUT/STDERR and forward all signals to the process]' \
229 '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]' 282 '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s STDIN]'
230 __docker_all_containers 283 __docker_all_containers
231 } 284 }
232 285
233 __stats() { 286 __stats() {
234 __docker_containers 287 __docker_containers
235 } 288 }
236 289
237 __stop() { 290 __stop() {
238 _arguments \ 291 _arguments \
239 '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]' 292 '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]'
240 __docker_containers 293 __docker_containers
241 } 294 }
242 295
243 __tag() { 296 __tag() {
244 _arguments \ 297 _arguments \
245 '(-f,--force=)'{-f,--force=}'[Force]' 298 '(-f,--force=)'{-f,--force=}'[Force]'
246 __docker_images 299 __docker_images
247 } 300 }
248 301
249 __version() { 302 __version() {
250 # no arguments 303 # no arguments
251 } 304 }
252 305
253 __wait() { 306 __wait() {
254 __docker_containers 307 __docker_containers
255 } 308 }
256 309
257 __exec() { 310 __exec() {
258 _arguments \ 311 _arguments \
259 '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \ 312 '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
260 '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ 313 '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
261 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]' 314 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
262 __docker_containers 315 __docker_containers
263 } 316 }
264 317
265 # end commands --------- 318 # end commands ---------
266 # ---------------------- 319 # ----------------------
267 320
268 local -a _1st_arguments 321 local -a _1st_arguments
269 _1st_arguments=( 322 _1st_arguments=(
270 "attach":"Attach to a running container" 323 "attach":"Attach to a running container"
271 "build":"Build a container from a Dockerfile" 324 "build":"Build a container from a Dockerfile"
272 "commit":"Create a new image from a container's changes" 325 "commit":"Create a new image from a container's changes"
273 "cp":"Copy files/folders from the containers filesystem to the host path" 326 "cp":"Copy files/folders from the containers filesystem to the host path"
327 "create":"Create new container without running it"
274 "diff":"Inspect changes on a container's filesystem" 328 "diff":"Inspect changes on a container's filesystem"
275 "events":"Get real time events from the server" 329 "events":"Get real time events from the server"
276 "export":"Stream the contents of a container as a tar archive" 330 "export":"Stream the contents of a container as a tar archive"
277 "history":"Show the history of an image" 331 "history":"Show the history of an image"
278 "images":"List images" 332 "images":"List images"
279 "import":"Create a new filesystem image from the contents of a tarball" 333 "import":"Create a new filesystem image from the contents of a tarball"
280 "info":"Display system-wide information" 334 "info":"Display system-wide information"
281 "insert":"Insert a file in an image"
282 "inspect":"Return low-level information on a container" 335 "inspect":"Return low-level information on a container"
283 "kill":"Kill a running container" 336 "kill":"Kill a running container"
284 "load":"Load an image from a tar archive" 337 "load":"Load an image from a tar archive"
285 "login":"Register or Login to the docker registry server" 338 "login":"Register or Login to the docker registry server"
286 "logs":"Fetch the logs of a container" 339 "logs":"Fetch the logs of a container"
287 "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT" 340 "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"
288 "ps":"List containers" 341 "ps":"List containers"
289 "pull":"Pull an image or a repository from the docker registry server" 342 "pull":"Pull an image or a repository from the docker registry server"
290 "push":"Push an image or a repository to the docker registry server" 343 "push":"Push an image or a repository to the docker registry server"
291 "restart":"Restart a running container" 344 "restart":"Restart a running container"
292 "rm":"Remove one or more containers" 345 "rm":"Remove one or more containers"
293 "rmi":"Remove one or more images" 346 "rmi":"Remove one or more images"
294 "run":"Run a command in a new container" 347 "run":"Run a command in a new container"
295 "save":"Save an image to a tar archive" 348 "save":"Save an image to a tar archive"
296 "search":"Search for an image in the docker index" 349 "search":"Search for an image in the docker index"
297 "start":"Start a stopped container" 350 "start":"Start a stopped container"
298 "stats":"Display a live stream of one or more containers' resource usage statistics" 351 "stats":"Display a live stream of one or more containers' resource usage statistics"
299 "stop":"Stop a running container" 352 "stop":"Stop a running container"
300 "tag":"Tag an image into a repository" 353 "tag":"Tag an image into a repository"
301 "top":"Lookup the running processes of a container" 354 "top":"Lookup the running processes of a container"
302 "version":"Show the docker version information" 355 "version":"Show the docker version information"
303 "wait":"Block until a container stops, then print its exit code" 356 "wait":"Block until a container stops, then print its exit code"
304 "exec":"Run a task inside a running container" 357 "exec":"Run a task inside a running container"
305 ) 358 )
306 359
307 _arguments '*:: :->command' 360 _arguments '*:: :->command'
308 361
309 if (( CURRENT == 1 )); then 362 if (( CURRENT == 1 )); then
310 _describe -t commands "docker command" _1st_arguments 363 _describe -t commands "docker command" _1st_arguments
311 return 364 return
312 fi 365 fi
313 366
314 local -a _command_args 367 local -a _command_args
315 case "$words[1]" in 368 case "$words[1]" in
316 attach) 369 attach)
317 __attach ;; 370 __attach ;;
318 build) 371 build)
319 __build ;; 372 __build ;;
320 commit) 373 commit)
321 __commit ;; 374 __commit ;;
322 cp) 375 cp)
323 __cp ;; 376 __cp ;;
377 create)
378 __create ;;
324 diff) 379 diff)
325 __diff ;; 380 __diff ;;
326 events) 381 events)
327 __events ;; 382 __events ;;
328 export) 383 export)
329 __export ;; 384 __export ;;
330 history) 385 history)
331 __history ;; 386 __history ;;
332 images) 387 images)
333 __images ;; 388 __images ;;
334 import) 389 import)
335 __import ;; 390 __import ;;
336 info) 391 info)
337 __info ;; 392 __info ;;
338 insert)
339 __insert ;;
340 inspect) 393 inspect)
341 __inspect ;; 394 __inspect ;;
342 kill) 395 kill)
343 __kill ;; 396 __kill ;;
344 load) 397 load)
345 __load ;; 398 __load ;;
346 login) 399 login)
347 __login ;; 400 __login ;;
348 logs) 401 logs)
349 __logs ;; 402 __logs ;;
350 port) 403 port)
351 __port ;; 404 __port ;;
352 ps) 405 ps)
353 __ps ;; 406 __ps ;;
354 pull) 407 pull)
355 __pull ;; 408 __pull ;;
356 push) 409 push)
357 __push ;; 410 __push ;;
358 restart) 411 restart)
359 __restart ;; 412 __restart ;;
360 rm) 413 rm)
361 __rm ;; 414 __rm ;;
362 rmi) 415 rmi)
363 __rmi ;; 416 __rmi ;;
364 run) 417 run)
365 __run ;; 418 __run ;;
366 save) 419 save)
367 __save ;; 420 __save ;;
368 search) 421 search)
369 __search ;; 422 __search ;;
370 stats) 423 stats)
371 __stats ;; 424 __stats ;;
372 start) 425 start)
373 __start ;; 426 __start ;;
374 stop) 427 stop)
375 __stop ;; 428 __stop ;;
376 tag) 429 tag)
377 __tag ;; 430 __tag ;;
378 top) 431 top)
plugins/extract/_extract
1 #compdef extract 1 #compdef extract
2 #autoload 2 #autoload
3 3
4 _arguments \ 4 _arguments \
5 '(-r --remove)'{-r,--remove}'[Remove archive.]' \ 5 '(-r --remove)'{-r,--remove}'[Remove archive.]' \
6 "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z|deb)(-.)'" && return 0 6 "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0
7 7
8 8
9 9
plugins/extract/extract.plugin.zsh
1 # ------------------------------------------------------------------------------ 1 # ------------------------------------------------------------------------------
2 # FILE: extract.plugin.zsh 2 # FILE: extract.plugin.zsh
3 # DESCRIPTION: oh-my-zsh plugin file. 3 # DESCRIPTION: oh-my-zsh plugin file.
4 # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) 4 # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
5 # VERSION: 1.0.1 5 # VERSION: 1.0.1
6 # ------------------------------------------------------------------------------ 6 # ------------------------------------------------------------------------------
7 7
8 8
9 function extract() { 9 function extract() {
10 local remove_archive 10 local remove_archive
11 local success 11 local success
12 local file_name 12 local file_name
13 local extract_dir 13 local extract_dir
14 14
15 if (( $# == 0 )); then 15 if (( $# == 0 )); then
16 echo "Usage: extract [-option] [file ...]" 16 echo "Usage: extract [-option] [file ...]"
17 echo 17 echo
18 echo Options: 18 echo Options:
19 echo " -r, --remove Remove archive." 19 echo " -r, --remove Remove archive."
20 echo 20 echo
21 echo "Report bugs to <sorin.ionescu@gmail.com>." 21 echo "Report bugs to <sorin.ionescu@gmail.com>."
22 fi 22 fi
23 23
24 remove_archive=1 24 remove_archive=1
25 if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then 25 if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
26 remove_archive=0 26 remove_archive=0
27 shift 27 shift
28 fi 28 fi
29 29
30 while (( $# > 0 )); do 30 while (( $# > 0 )); do
31 if [[ ! -f "$1" ]]; then 31 if [[ ! -f "$1" ]]; then
32 echo "extract: '$1' is not a valid file" 1>&2 32 echo "extract: '$1' is not a valid file" 1>&2
33 shift 33 shift
34 continue 34 continue
35 fi 35 fi
36 36
37 success=0 37 success=0
38 file_name="$( basename "$1" )" 38 file_name="$( basename "$1" )"
39 extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" 39 extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
40 case "$1" in 40 case "$1" in
41 (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;; 41 (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;;
42 (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; 42 (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
43 (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ 43 (*.tar.xz|*.txz) tar --xz --help &> /dev/null \
44 && tar --xz -xvf "$1" \ 44 && tar --xz -xvf "$1" \
45 || xzcat "$1" | tar xvf - ;; 45 || xzcat "$1" | tar xvf - ;;
46 (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ 46 (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
47 && tar --lzma -xvf "$1" \ 47 && tar --lzma -xvf "$1" \
48 || lzcat "$1" | tar xvf - ;; 48 || lzcat "$1" | tar xvf - ;;
49 (*.tar) tar xvf "$1" ;; 49 (*.tar) tar xvf "$1" ;;
50 (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;; 50 (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;;
51 (*.bz2) bunzip2 "$1" ;; 51 (*.bz2) bunzip2 "$1" ;;
52 (*.xz) unxz "$1" ;; 52 (*.xz) unxz "$1" ;;
53 (*.lzma) unlzma "$1" ;; 53 (*.lzma) unlzma "$1" ;;
54 (*.Z) uncompress "$1" ;; 54 (*.Z) uncompress "$1" ;;
55 (*.zip|*.war|*.jar|*.sublime-package) unzip "$1" -d $extract_dir ;; 55 (*.zip|*.war|*.jar|*.sublime-package|*.ipsw) unzip "$1" -d $extract_dir ;;
56 (*.rar) unrar x -ad "$1" ;; 56 (*.rar) unrar x -ad "$1" ;;
57 (*.7z) 7za x "$1" ;; 57 (*.7z) 7za x "$1" ;;
58 (*.deb) 58 (*.deb)
59 mkdir -p "$extract_dir/control" 59 mkdir -p "$extract_dir/control"
60 mkdir -p "$extract_dir/data" 60 mkdir -p "$extract_dir/data"
61 cd "$extract_dir"; ar vx "../${1}" > /dev/null 61 cd "$extract_dir"; ar vx "../${1}" > /dev/null
62 cd control; tar xzvf ../control.tar.gz 62 cd control; tar xzvf ../control.tar.gz
63 cd ../data; tar xzvf ../data.tar.gz 63 cd ../data; tar xzvf ../data.tar.gz
64 cd ..; rm *.tar.gz debian-binary 64 cd ..; rm *.tar.gz debian-binary
65 cd .. 65 cd ..
66 ;; 66 ;;
67 (*) 67 (*)
68 echo "extract: '$1' cannot be extracted" 1>&2 68 echo "extract: '$1' cannot be extracted" 1>&2
69 success=1 69 success=1
70 ;; 70 ;;
71 esac 71 esac
72 72
73 (( success = $success > 0 ? $success : $? )) 73 (( success = $success > 0 ? $success : $? ))
74 (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" 74 (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
75 shift 75 shift
76 done 76 done
77 } 77 }
78 78
79 alias x=extract 79 alias x=extract
80 80
81 81
plugins/fasd/fasd.plugin.zsh
1 if [ $commands[fasd] ]; then # check if fasd is installed 1 if [ $commands[fasd] ]; then # check if fasd is installed
2 fasd_cache="$HOME/.fasd-init-cache" 2 fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache"
3 if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then 3 if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
4 fasd --init auto >| "$fasd_cache" 4 fasd --init auto >| "$fasd_cache"
5 fi 5 fi
6 source "$fasd_cache" 6 source "$fasd_cache"
7 unset fasd_cache 7 unset fasd_cache
8 alias v='f -e vim' 8 alias v='f -e vim'
9 alias o='a -e open' 9 alias o='a -e open'
10 fi 10 fi
11 11
12 12
plugins/forklift/README.md
File was created 1 ## forklift
2
3 Plugin for ForkLift, an FTP application for OS X.
4
5 ### Requirements
6
7 * [ForkLift](http://forkliftapp.com/forklift/)
8
9 ### Usage
10
11 * If `fl` is called without arguments then the current folder is opened in ForkLift. Is equivalent to `fl .`
12
13 * If `fl` is called with a directory as the argument, then that directory is opened in ForkLift
plugins/git/README.md
1 ## git 1 ## git
2 **Maintainer:** [Stibbons](https://github.com/Stibbons)
3 2
4 This plugin adds several git aliases and increase the completion function provided by zsh 3 **Maintainer:** [@ncanceill](https://github.com/ncanceill)
4
5 This plugin adds many useful aliases and functions.
6
7 ### Usage
8
9 See the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git) for a list of aliases and functions provided by the plugin.
10
plugins/git/_git-branch
1 #compdef git-branch File was deleted
2
3 _git-branch ()
4 {
5 declare l c m d
6
7 l='--color --no-color -r -a --all -v --verbose --abbrev --no-abbrev'
8 c='-l -f --force -t --track --no-track --set-upstream --contains --merged --no-merged'
9 m='-m -M'
10 d='-d -D'
11
12 declare -a dependent_creation_args
13 if (( words[(I)-r] == 0 )); then
14 dependent_creation_args=(
15 "($l $m $d): :__git_branch_names"
16 "::start-point:__git_revisions")
17 fi
18
19 declare -a dependent_deletion_args
20 if (( words[(I)-d] || words[(I)-D] )); then
21 dependent_creation_args=
22 dependent_deletion_args=(
23 '-r[delete only remote-tracking branches]')
24 if (( words[(I)-r] )); then
25 dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_remote_branch_names'
26 else
27 dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names'
28 fi
29 fi
30
31 declare -a dependent_modification_args
32 if (( words[(I)-m] || words[(I)-M] )); then
33 dependent_creation_args=
34 dependent_modification_args=(
35 ':old or new branch name:__git_branch_names'
36 '::new branch name:__git_branch_names')
37 fi
38
39 _arguments -w -S -s \
40 "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
41 "($c $m $d : --color)--no-color[turn off branch coloring]" \
42 "($c $m -a --all)-r[list or delete only remote-tracking branches]" \
43 "($c $m $d : -r)"{-a,--all}"[list both remote-tracking branches and local branches]" \
44 "($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
45 "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
46 "($c $m $d :)--no-abbrev[do not abbreviate sha1s]" \
47 "($l $m $d)-l[create the branch's reflog]" \
48 "($l $m $d -f --force)"{-f,--force}"[force the creation of a new branch]" \
49 "($l $m $d -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
50 "($l $m $d)--no-track[override the branch.autosetupmerge configuration variable]" \
51 "($l $m $d)--set-upstream[set up configuration so that pull merges]" \
52 "($l $m $d)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
53 "($l $m $d)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
54 "($l $m $d)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
55 $dependent_creation_args \
56 "($l $c $d -M)-m[rename a branch and the corresponding reflog]" \
57 "($l $c $d -m)-M[rename a branch even if the new branch-name already exists]" \
58 $dependent_modification_args \
59 "($l $c $m -D)-d[delete a fully merged branch]" \
60 "($l $c $m -d)-D[delete a branch]" \
61 $dependent_deletion_args
62 }
63
64 (( $+functions[__git_ignore_line] )) ||
65 __git_ignore_line () {
66 declare -a ignored
67 ignored=()
68 ((CURRENT > 1)) &&
69 ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
70 ((CURRENT < $#line)) &&
71 ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
72 $* -F ignored
73 }
74
75 (( $+functions[__git_ignore_line_inside_arguments] )) ||
76 __git_ignore_line_inside_arguments () {
77 declare -a compadd_opts
78
79 zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
80
81 __git_ignore_line $* $compadd_opts
82 }
83
84 1 #compdef git-branch
plugins/git/_git-remote
1 #compdef git-remote File was deleted
2
3 # NOTE: --track is undocumented.
4 # TODO: --track, -t, --master, and -m should take remote branches, I guess.
5 # NOTE: --master is undocumented.
6 # NOTE: --fetch is undocumented.
7 _git-remote () {
8 local curcontext=$curcontext state line
9 declare -A opt_args
10
11 _arguments -C \
12 ':command:->command' \
13 '*::options:->options' && ret=0
14
15 case $state in
16 (command)
17 declare -a commands
18
19 commands=(
20 'add:add a new remote'
21 'show:show information about a given remote'
22 'prune:delete all stale tracking branches for a given remote'
23 'update:fetch updates for a set of remotes'
24 'rm:remove a remote from .git/config and all associated tracking branches'
25 'rename:rename a remote from .git/config and update all associated tracking branches'
26 'set-head:sets or deletes the default branch'
27 'set-branches:changes the list of branches tracked by the named remote.'
28 'set-url:changes URL remote points to.'
29 )
30
31 _describe -t commands 'sub-command' commands && ret=0
32 ;;
33 (options)
34 case $line[1] in
35 (add)
36 _arguments \
37 '*'{--track,-t}'[track given branch instead of default glob refspec]:branch:__git_branch_names' \
38 '(--master -m)'{--master,-m}'[set the remote'\''s HEAD to point to given master branch]:branch:__git_branch_names' \
39 '(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote after it has been created]' \
40 ':branch name:__git_remotes' \
41 ':url:_urls' && ret=0
42 ;;
43 (show)
44 _arguments \
45 '-n[do not contact the remote for a list of branches]' \
46 ':remote:__git_remotes' && ret=0
47 ;;
48 (prune)
49 _arguments \
50 '(--dry-run -n)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \
51 ':remote:__git_remotes' && ret=0
52 ;;
53 (update)
54 __git_remote-groups && ret=0
55 ;;
56 (rm)
57 __git_remotes && ret=0
58 ;;
59 (rename)
60 __git_remotes && ret=0
61 ;;
62 (set-url)
63 _arguments \
64 '*--push[manipulate push URLs]' \
65 '(--add)--add[add URL]' \
66 '(--delete)--delete[delete URLs]' \
67 ':branch name:__git_remotes' \
68 ':url:_urls' && ret=0
69 ;;
70
71 esac
72 ;;
73 esac
74 }
75 1 #compdef git-remote
plugins/git/git.plugin.zsh
1 # Query/use custom command for `git`.
2 zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
3 : ${_omz_git_git_cmd:=git}
4
5 #
6 # Functions
7 #
8
9 # The current branch name
10 # Usage example: git pull origin $(current_branch)
11 # Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
12 # it's not a symbolic ref, but in a Git repo.
13 function current_branch() {
14 local ref
15 ref=$($_omz_git_git_cmd symbolic-ref --quiet HEAD 2> /dev/null)
16 local ret=$?
17 if [[ $ret != 0 ]]; then
18 [[ $ret == 128 ]] && return # no git repo.
19 ref=$($_omz_git_git_cmd rev-parse --short HEAD 2> /dev/null) || return
20 fi
21 echo ${ref#refs/heads/}
22 }
23 # The list of remotes
24 function current_repository() {
25 if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
26 return
27 fi
28 echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
29 }
30 # Pretty log messages
31 function _git_log_prettily(){
32 if ! [ -z $1 ]; then
33 git log --pretty=$1
34 fi
35 }
36 # Warn if the current branch is a WIP
37 function work_in_progress() {
38 if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
39 echo "WIP!!"
40 fi
41 }
42
43 #
1 # Aliases 44 # Aliases
45 # (sorted alphabetically)
46 #
47
2 alias g='git' 48 alias g='git'
3 compdef g=git 49
4 alias gst='git status' 50 alias ga='git add'
5 compdef _git gst=git-status 51 alias gaa='git add --all'
6 alias gd='git diff' 52 alias gapa='git add --patch'
7 compdef _git gd=git-diff 53
8 alias gdc='git diff --cached' 54 alias gb='git branch'
9 compdef _git gdc=git-diff 55 alias gba='git branch -a'
10 alias gdt='git diff-tree --no-commit-id --name-only -r' 56 alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d'
11 compdef _git gdc=git diff-tree --no-commit-id --name-only -r 57 alias gbl='git blame -b -w'
12 alias gl='git pull' 58 alias gbnm='git branch --no-merged'
13 compdef _git gl=git-pull 59 alias gbr='git branch --remote'
14 alias gup='git pull --rebase' 60 alias gbs='git bisect'
15 compdef _git gup=git-fetch 61 alias gbsb='git bisect bad'
16 alias gp='git push' 62 alias gbsg='git bisect good'
17 compdef _git gp=git-push 63 alias gbsr='git bisect reset'
18 alias gd='git diff' 64 alias gbss='git bisect start'
19 gdv() { git diff -w "$@" | view - } 65
20 compdef _git gdv=git-diff
21 alias gdt='git difftool'
22 alias gc='git commit -v' 66 alias gc='git commit -v'
23 compdef _git gc=git-commit
24 alias gc!='git commit -v --amend' 67 alias gc!='git commit -v --amend'
25 compdef _git gc!=git-commit
26 alias gca='git commit -v -a' 68 alias gca='git commit -v -a'
27 compdef _git gc=git-commit
28 alias gca!='git commit -v -a --amend' 69 alias gca!='git commit -v -a --amend'
29 compdef _git gca!=git-commit 70 alias gcan!='git commit -v -a -s --no-edit --amend'
71 alias gcb='git checkout -b'
72 alias gcf='git config --list'
73 alias gcl='git clone --recursive'
74 alias gclean='git reset --hard && git clean -dfx'
75 alias gcm='git checkout master'
30 alias gcmsg='git commit -m' 76 alias gcmsg='git commit -m'
31 compdef _git gcmsg=git-commit
32 alias gco='git checkout' 77 alias gco='git checkout'
33 compdef _git gco=git-checkout
34 alias gcm='git checkout master'
35 alias gr='git remote'
36 compdef _git gr=git-remote
37 alias grv='git remote -v'
38 compdef _git grv=git-remote
39 alias grmv='git remote rename'
40 compdef _git grmv=git-remote
41 alias grrm='git remote remove'
42 compdef _git grrm=git-remote
43 alias grset='git remote set-url'
44 compdef _git grset=git-remote
45 alias grup='git remote update'
46 compdef _git grset=git-remote
47 alias grbi='git rebase -i'
48 compdef _git grbi=git-rebase
49 alias grbc='git rebase --continue'
50 compdef _git grbc=git-rebase
51 alias grba='git rebase --abort'
52 compdef _git grba=git-rebase
53 alias gb='git branch'
54 compdef _git gb=git-branch
55 alias gba='git branch -a'
56 compdef _git gba=git-branch
57 alias gbr='git branch --remote'
58 alias gcount='git shortlog -sn' 78 alias gcount='git shortlog -sn'
59 compdef gcount=git 79 compdef gcount=git
60 alias gcl='git config --list'
61 alias gcp='git cherry-pick' 80 alias gcp='git cherry-pick'
62 compdef _git gcp=git-cherry-pick
63 alias glg='git log --stat --max-count=10'
64 compdef _git glg=git-log
65 alias glgg='git log --graph --max-count=10'
66 compdef _git glgg=git-log
67 alias glgga='git log --graph --decorate --all'
68 compdef _git glgga=git-log
69 alias glo='git log --oneline --decorate --color'
70 compdef _git glo=git-log
71 alias glog='git log --oneline --decorate --color --graph'
72 compdef _git glog=git-log
73 alias gss='git status -s'
74 compdef _git gss=git-status
75 alias ga='git add'
76 compdef _git ga=git-add
77 alias gap='git add --patch'
78 alias gaa='git add --all'
79 alias gm='git merge'
80 compdef _git gm=git-merge
81 alias grh='git reset HEAD'
82 alias grhh='git reset HEAD --hard'
83 alias gclean='git reset --hard && git clean -dfx'
84 alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
85
86 # Sign and verify commits with GPG
87 alias gcs='git commit -S' 81 alias gcs='git commit -S'
88 compdef _git gcs=git-commit
89 alias gsps='git show --pretty=short --show-signature'
90 compdef _git gsps=git-show
91
92 # Sign and verify tags with GPG
93 alias gts='git tag -s'
94 compdef _git gts=git-tag
95 alias gvt='git verify-tag'
96 compdef _git gvt=git verify-tag
97 82
98 #remove the gf alias 83 alias gd='git diff'
99 #alias gf='git ls-files | grep' 84 alias gdca='git diff --cached'
85 alias gdt='git diff-tree --no-commit-id --name-only -r'
86 gdv() { git diff -w "$@" | view - }
87 compdef _git gdv=git-diff
88 alias gdw='git diff --word-diff'
100 89
101 alias gpoat='git push origin --all && git push origin --tags' 90 alias gf='git fetch'
102 alias gmt='git mergetool --no-prompt' 91 alias gfa='git fetch --all --prune'
103 compdef _git gmt=git-mergetool 92 function gfg() { git ls-files | grep $@ }
93 compdef gfg=grep
94 alias gfo='git fetch origin'
104 95
105 alias gg='git gui citool' 96 alias gg='git gui citool'
106 alias gga='git gui citool --amend' 97 alias gga='git gui citool --amend'
107 alias gk='gitk --all --branches' 98 ggf() {
108 99 [[ "$#" != 1 ]] && local b="$(current_branch)"
109 alias gsts='git stash show --text' 100 git push --force origin "${b:=$1}"
110 alias gsta='git stash'
111 alias gstp='git stash pop'
112 alias gstd='git stash drop'
113
114 # Will cd into the top of the current repository
115 # or submodule.
116 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
117
118 # Git and svn mix
119 alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
120 compdef git-svn-dcommit-push=git
121
122 alias gsr='git svn rebase'
123 alias gsd='git svn dcommit'
124 #
125 # Will return the current branch name
126 # Usage example: git pull origin $(current_branch)
127 #
128 function current_branch() {
129 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
130 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
131 echo ${ref#refs/heads/}
132 } 101 }
133 102 compdef _git ggf=git-checkout
134 function current_repository() { 103 ggl() {
135 ref=$(git symbolic-ref HEAD 2> /dev/null) || \ 104 if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
136 ref=$(git rev-parse --short HEAD 2> /dev/null) || return 105 git pull origin "${*}"
137 echo $(git remote -v | cut -d':' -f 2) 106 else
107 [[ "$#" == 0 ]] && local b="$(current_branch)"
108 git pull origin "${b:=$1}"
109 fi
138 } 110 }
139 111 compdef _git ggl=git-checkout
140 # these aliases take advantage of the previous function
141 alias ggpull='git pull origin $(current_branch)' 112 alias ggpull='git pull origin $(current_branch)'
142 compdef ggpull=git 113 compdef _git ggpull=git-checkout
143 alias ggpur='git pull --rebase origin $(current_branch)' 114 ggp() {
144 compdef ggpur=git 115 if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
116 git push origin "${*}"
117 else
118 [[ "$#" == 0 ]] && local b="$(current_branch)"
119 git push origin "${b:=$1}"
120 fi
121 }
122 compdef _git ggp=git-checkout
145 alias ggpush='git push origin $(current_branch)' 123 alias ggpush='git push origin $(current_branch)'
146 compdef ggpush=git 124 compdef _git ggpush=git-checkout
147 alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' 125 ggpnp() {
148 compdef ggpnp=git 126 if [[ "$#" == 0 ]]; then
149 127 ggl && ggp
150 # Pretty log messages 128 else
151 function _git_log_prettily(){ 129 ggl "${*}" && ggp "${*}"
152 if ! [ -z $1 ]; then 130 fi
153 git log --pretty=$1
154 fi
155 } 131 }
plugins/gitfast/_git
1 #compdef git gitk 1 #compdef git gitk
2 2
3 # zsh completion wrapper for git 3 # zsh completion wrapper for git
4 # 4 #
5 # Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com> 5 # Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
6 # 6 #
7 # You need git's bash completion script installed somewhere, by default it 7 # You need git's bash completion script installed somewhere, by default it
8 # would be the location bash-completion uses. 8 # would be the location bash-completion uses.
9 # 9 #
10 # If your script is somewhere else, you can configure it on your ~/.zshrc: 10 # If your script is somewhere else, you can configure it on your ~/.zshrc:
11 # 11 #
12 # zstyle ':completion:*:*:git:*' script ~/.git-completion.sh 12 # zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
13 # 13 #
14 # The recommended way to install this script is to copy to '~/.zsh/_git', and 14 # The recommended way to install this script is to copy to '~/.zsh/_git', and
15 # then add the following to your ~/.zshrc file: 15 # then add the following to your ~/.zshrc file:
16 # 16 #
17 # fpath=(~/.zsh $fpath) 17 # fpath=(~/.zsh $fpath)
18 18
19 complete () 19 complete ()
20 { 20 {
21 # do nothing 21 # do nothing
22 return 0 22 return 0
23 } 23 }
24 24
25 zstyle -T ':completion:*:*:git:*' tag-order && \ 25 zstyle -T ':completion:*:*:git:*' tag-order && \
26 zstyle ':completion:*:*:git:*' tag-order 'common-commands' 26 zstyle ':completion:*:*:git:*' tag-order 'common-commands'
27 27
28 zstyle -s ":completion:*:*:git:*" script script 28 zstyle -s ":completion:*:*:git:*" script script
29 if [ -z "$script" ]; then 29 if [ -z "$script" ]; then
30 local -a locations 30 local -a locations
31 local e 31 local e
32 locations=( 32 locations=(
33 "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
33 '/etc/bash_completion.d/git' # fedora, old debian 34 '/etc/bash_completion.d/git' # fedora, old debian
34 '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian 35 '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
35 '/usr/share/bash-completion/git' # gentoo 36 '/usr/share/bash-completion/git' # gentoo
36 $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
37 ) 37 )
38 for e in $locations; do 38 for e in $locations; do
39 test -f $e && script="$e" && break 39 test -f $e && script="$e" && break
40 done 40 done
41 fi 41 fi
42 ZSH_VERSION='' . "$script" 42 ZSH_VERSION='' . "$script"
43 43
44 __gitcomp () 44 __gitcomp ()
45 { 45 {
46 emulate -L zsh 46 emulate -L zsh
47 47
48 local cur_="${3-$cur}" 48 local cur_="${3-$cur}"
49 49
50 case "$cur_" in 50 case "$cur_" in
51 --*=) 51 --*=)
52 ;; 52 ;;
53 *) 53 *)
54 local c IFS=$' \t\n' 54 local c IFS=$' \t\n'
55 local -a array 55 local -a array
56 for c in ${=1}; do 56 for c in ${=1}; do
57 c="$c${4-}" 57 c="$c${4-}"
58 case $c in 58 case $c in
59 --*=*|*.) ;; 59 --*=*|*.) ;;
60 *) c="$c " ;; 60 *) c="$c " ;;
61 esac 61 esac
62 array+=("$c") 62 array+=("$c")
63 done 63 done
64 compset -P '*[=:]' 64 compset -P '*[=:]'
65 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 65 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
66 ;; 66 ;;
67 esac 67 esac
68 } 68 }
69 69
70 __gitcomp_nl () 70 __gitcomp_nl ()
71 { 71 {
72 emulate -L zsh 72 emulate -L zsh
73 73
74 local IFS=$'\n' 74 local IFS=$'\n'
75 compset -P '*[=:]' 75 compset -P '*[=:]'
76 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 76 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
77 } 77 }
78 78
79 __gitcomp_nl_append ()
80 {
81 emulate -L zsh
82
83 local IFS=$'\n'
84 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
85 }
86
79 __gitcomp_file () 87 __gitcomp_file ()
80 { 88 {
81 emulate -L zsh 89 emulate -L zsh
82 90
83 local IFS=$'\n' 91 local IFS=$'\n'
84 compset -P '*[=:]' 92 compset -P '*[=:]'
85 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 93 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
86 } 94 }
87 95
88 __git_zsh_bash_func () 96 __git_zsh_bash_func ()
89 { 97 {
90 emulate -L ksh 98 emulate -L ksh
91 99
92 local command=$1 100 local command=$1
93 101
94 local completion_func="_git_${command//-/_}" 102 local completion_func="_git_${command//-/_}"
95 declare -f $completion_func >/dev/null && $completion_func && return 103 declare -f $completion_func >/dev/null && $completion_func && return
96 104
97 local expansion=$(__git_aliased_command "$command") 105 local expansion=$(__git_aliased_command "$command")
98 if [ -n "$expansion" ]; then 106 if [ -n "$expansion" ]; then
99 completion_func="_git_${expansion//-/_}" 107 completion_func="_git_${expansion//-/_}"
100 declare -f $completion_func >/dev/null && $completion_func 108 declare -f $completion_func >/dev/null && $completion_func
101 fi 109 fi
102 } 110 }
103 111
104 __git_zsh_cmd_common () 112 __git_zsh_cmd_common ()
105 { 113 {
106 local -a list 114 local -a list
107 list=( 115 list=(
108 add:'add file contents to the index' 116 add:'add file contents to the index'
109 bisect:'find by binary search the change that introduced a bug' 117 bisect:'find by binary search the change that introduced a bug'
110 branch:'list, create, or delete branches' 118 branch:'list, create, or delete branches'
111 checkout:'checkout a branch or paths to the working tree' 119 checkout:'checkout a branch or paths to the working tree'
112 clone:'clone a repository into a new directory' 120 clone:'clone a repository into a new directory'
113 commit:'record changes to the repository' 121 commit:'record changes to the repository'
114 diff:'show changes between commits, commit and working tree, etc' 122 diff:'show changes between commits, commit and working tree, etc'
115 fetch:'download objects and refs from another repository' 123 fetch:'download objects and refs from another repository'
116 grep:'print lines matching a pattern' 124 grep:'print lines matching a pattern'
117 init:'create an empty Git repository or reinitialize an existing one' 125 init:'create an empty Git repository or reinitialize an existing one'
118 log:'show commit logs' 126 log:'show commit logs'
119 merge:'join two or more development histories together' 127 merge:'join two or more development histories together'
120 mv:'move or rename a file, a directory, or a symlink' 128 mv:'move or rename a file, a directory, or a symlink'
121 pull:'fetch from and merge with another repository or a local branch' 129 pull:'fetch from and merge with another repository or a local branch'
122 push:'update remote refs along with associated objects' 130 push:'update remote refs along with associated objects'
123 rebase:'forward-port local commits to the updated upstream head' 131 rebase:'forward-port local commits to the updated upstream head'
124 reset:'reset current HEAD to the specified state' 132 reset:'reset current HEAD to the specified state'
125 rm:'remove files from the working tree and from the index' 133 rm:'remove files from the working tree and from the index'
126 show:'show various types of objects' 134 show:'show various types of objects'
127 status:'show the working tree status' 135 status:'show the working tree status'
128 tag:'create, list, delete or verify a tag object signed with GPG') 136 tag:'create, list, delete or verify a tag object signed with GPG')
129 _describe -t common-commands 'common commands' list && _ret=0 137 _describe -t common-commands 'common commands' list && _ret=0
130 } 138 }
131 139
132 __git_zsh_cmd_alias () 140 __git_zsh_cmd_alias ()
133 { 141 {
134 local -a list 142 local -a list
135 list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*}) 143 list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
136 _describe -t alias-commands 'aliases' list $* && _ret=0 144 _describe -t alias-commands 'aliases' list $* && _ret=0
137 } 145 }
138 146
139 __git_zsh_cmd_all () 147 __git_zsh_cmd_all ()
140 { 148 {
141 local -a list 149 local -a list
142 emulate ksh -c __git_compute_all_commands 150 emulate ksh -c __git_compute_all_commands
143 list=( ${=__git_all_commands} ) 151 list=( ${=__git_all_commands} )
144 _describe -t all-commands 'all commands' list && _ret=0 152 _describe -t all-commands 'all commands' list && _ret=0
145 } 153 }
146 154
147 __git_zsh_main () 155 __git_zsh_main ()
148 { 156 {
149 local curcontext="$curcontext" state state_descr line 157 local curcontext="$curcontext" state state_descr line
150 typeset -A opt_args 158 typeset -A opt_args
151 local -a orig_words 159 local -a orig_words
152 160
153 orig_words=( ${words[@]} ) 161 orig_words=( ${words[@]} )
154 162
155 _arguments -C \ 163 _arguments -C \
156 '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ 164 '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
157 '(-p --paginate)--no-pager[do not pipe git output into a pager]' \ 165 '(-p --paginate)--no-pager[do not pipe git output into a pager]' \
158 '--git-dir=-[set the path to the repository]: :_directories' \ 166 '--git-dir=-[set the path to the repository]: :_directories' \
159 '--bare[treat the repository as a bare repository]' \ 167 '--bare[treat the repository as a bare repository]' \
160 '(- :)--version[prints the git suite version]' \ 168 '(- :)--version[prints the git suite version]' \
161 '--exec-path=-[path to where your core git programs are installed]:: :_directories' \ 169 '--exec-path=-[path to where your core git programs are installed]:: :_directories' \
162 '--html-path[print the path where git''s HTML documentation is installed]' \ 170 '--html-path[print the path where git''s HTML documentation is installed]' \
163 '--info-path[print the path where the Info files are installed]' \ 171 '--info-path[print the path where the Info files are installed]' \
164 '--man-path[print the manpath (see `man(1)`) for the man pages]' \ 172 '--man-path[print the manpath (see `man(1)`) for the man pages]' \
165 '--work-tree=-[set the path to the working tree]: :_directories' \ 173 '--work-tree=-[set the path to the working tree]: :_directories' \
166 '--namespace=-[set the git namespace]' \ 174 '--namespace=-[set the git namespace]' \
167 '--no-replace-objects[do not use replacement refs to replace git objects]' \ 175 '--no-replace-objects[do not use replacement refs to replace git objects]' \
168 '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ 176 '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
169 '(-): :->command' \ 177 '(-): :->command' \
170 '(-)*:: :->arg' && return 178 '(-)*:: :->arg' && return
171 179
172 case $state in 180 case $state in
173 (command) 181 (command)
174 _alternative \ 182 _alternative \
175 'alias-commands:alias:__git_zsh_cmd_alias' \ 183 'alias-commands:alias:__git_zsh_cmd_alias' \
176 'common-commands:common:__git_zsh_cmd_common' \ 184 'common-commands:common:__git_zsh_cmd_common' \
177 'all-commands:all:__git_zsh_cmd_all' && _ret=0 185 'all-commands:all:__git_zsh_cmd_all' && _ret=0
178 ;; 186 ;;
179 (arg) 187 (arg)
180 local command="${words[1]}" __git_dir 188 local command="${words[1]}" __git_dir
181 189
182 if (( $+opt_args[--bare] )); then 190 if (( $+opt_args[--bare] )); then
183 __git_dir='.' 191 __git_dir='.'
184 else 192 else
185 __git_dir=${opt_args[--git-dir]} 193 __git_dir=${opt_args[--git-dir]}
186 fi 194 fi
187 195
188 (( $+opt_args[--help] )) && command='help' 196 (( $+opt_args[--help] )) && command='help'
189 197
190 words=( ${orig_words[@]} ) 198 words=( ${orig_words[@]} )
191 199
192 __git_zsh_bash_func $command 200 __git_zsh_bash_func $command
193 ;; 201 ;;
194 esac 202 esac
195 } 203 }
196 204
197 _git () 205 _git ()
198 { 206 {
199 local _ret=1 207 local _ret=1
200 local cur cword prev 208 local cur cword prev
201 209
202 cur=${words[CURRENT]} 210 cur=${words[CURRENT]}
203 prev=${words[CURRENT-1]} 211 prev=${words[CURRENT-1]}
204 let cword=CURRENT-1 212 let cword=CURRENT-1
205 213
206 if (( $+functions[__${service}_zsh_main] )); then 214 if (( $+functions[__${service}_zsh_main] )); then
207 __${service}_zsh_main 215 __${service}_zsh_main
208 else 216 else
209 emulate ksh -c __${service}_main 217 emulate ksh -c __${service}_main
210 fi 218 fi
211 219
212 let _ret && _default && _ret=0 220 let _ret && _default && _ret=0
213 return _ret 221 return _ret
214 } 222 }
215 223
216 _git 224 _git
plugins/gitfast/git-completion.bash
1 #!bash
2 #
3 # bash/zsh completion support for core Git. 1 # bash/zsh completion support for core Git.
4 # 2 #
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> 3 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). 4 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0. 5 # Distributed under the GNU General Public License, version 2.0.
8 # 6 #
9 # The contained completion routines provide support for completing: 7 # The contained completion routines provide support for completing:
10 # 8 #
11 # *) local and remote branch names 9 # *) local and remote branch names
12 # *) local and remote tag names 10 # *) local and remote tag names
13 # *) .git/remotes file names 11 # *) .git/remotes file names
14 # *) git 'subcommands' 12 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions 13 # *) tree paths within 'ref:path/to/file' expressions
16 # *) file paths within current working directory and index 14 # *) file paths within current working directory and index
17 # *) common --long-options 15 # *) common --long-options
18 # 16 #
19 # To use these routines: 17 # To use these routines:
20 # 18 #
21 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). 19 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
22 # 2) Add the following line to your .bashrc/.zshrc: 20 # 2) Add the following line to your .bashrc/.zshrc:
23 # source ~/.git-completion.sh 21 # source ~/.git-completion.sh
24 # 3) Consider changing your PS1 to also show the current branch, 22 # 3) Consider changing your PS1 to also show the current branch,
25 # see git-prompt.sh for details. 23 # see git-prompt.sh for details.
26 24
27 case "$COMP_WORDBREAKS" in 25 case "$COMP_WORDBREAKS" in
28 *:*) : great ;; 26 *:*) : great ;;
29 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" 27 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
30 esac 28 esac
31 29
32 # __gitdir accepts 0 or 1 arguments (i.e., location) 30 # __gitdir accepts 0 or 1 arguments (i.e., location)
33 # returns location of .git repo 31 # returns location of .git repo
34 __gitdir () 32 __gitdir ()
35 { 33 {
36 if [ -z "${1-}" ]; then 34 if [ -z "${1-}" ]; then
37 if [ -n "${__git_dir-}" ]; then 35 if [ -n "${__git_dir-}" ]; then
38 echo "$__git_dir" 36 echo "$__git_dir"
39 elif [ -n "${GIT_DIR-}" ]; then 37 elif [ -n "${GIT_DIR-}" ]; then
40 test -d "${GIT_DIR-}" || return 1 38 test -d "${GIT_DIR-}" || return 1
41 echo "$GIT_DIR" 39 echo "$GIT_DIR"
42 elif [ -d .git ]; then 40 elif [ -d .git ]; then
43 echo .git 41 echo .git
44 else 42 else
45 git rev-parse --git-dir 2>/dev/null 43 git rev-parse --git-dir 2>/dev/null
46 fi 44 fi
47 elif [ -d "$1/.git" ]; then 45 elif [ -d "$1/.git" ]; then
48 echo "$1/.git" 46 echo "$1/.git"
49 else 47 else
50 echo "$1" 48 echo "$1"
51 fi 49 fi
52 } 50 }
53 51
54 # The following function is based on code from: 52 # The following function is based on code from:
55 # 53 #
56 # bash_completion - programmable completion functions for bash 3.2+ 54 # bash_completion - programmable completion functions for bash 3.2+
57 # 55 #
58 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> 56 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
59 # © 2009-2010, Bash Completion Maintainers 57 # © 2009-2010, Bash Completion Maintainers
60 # <bash-completion-devel@lists.alioth.debian.org> 58 # <bash-completion-devel@lists.alioth.debian.org>
61 # 59 #
62 # This program is free software; you can redistribute it and/or modify 60 # This program is free software; you can redistribute it and/or modify
63 # it under the terms of the GNU General Public License as published by 61 # it under the terms of the GNU General Public License as published by
64 # the Free Software Foundation; either version 2, or (at your option) 62 # the Free Software Foundation; either version 2, or (at your option)
65 # any later version. 63 # any later version.
66 # 64 #
67 # This program is distributed in the hope that it will be useful, 65 # This program is distributed in the hope that it will be useful,
68 # but WITHOUT ANY WARRANTY; without even the implied warranty of 66 # but WITHOUT ANY WARRANTY; without even the implied warranty of
69 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 67 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70 # GNU General Public License for more details. 68 # GNU General Public License for more details.
71 # 69 #
72 # You should have received a copy of the GNU General Public License 70 # You should have received a copy of the GNU General Public License
73 # along with this program; if not, write to the Free Software Foundation, 71 # along with this program; if not, write to the Free Software Foundation,
74 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 72 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
75 # 73 #
76 # The latest version of this software can be obtained here: 74 # The latest version of this software can be obtained here:
77 # 75 #
78 # http://bash-completion.alioth.debian.org/ 76 # http://bash-completion.alioth.debian.org/
79 # 77 #
80 # RELEASE: 2.x 78 # RELEASE: 2.x
81 79
82 # This function can be used to access a tokenized list of words 80 # This function can be used to access a tokenized list of words
83 # on the command line: 81 # on the command line:
84 # 82 #
85 # __git_reassemble_comp_words_by_ref '=:' 83 # __git_reassemble_comp_words_by_ref '=:'
86 # if test "${words_[cword_-1]}" = -w 84 # if test "${words_[cword_-1]}" = -w
87 # then 85 # then
88 # ... 86 # ...
89 # fi 87 # fi
90 # 88 #
91 # The argument should be a collection of characters from the list of 89 # The argument should be a collection of characters from the list of
92 # word completion separators (COMP_WORDBREAKS) to treat as ordinary 90 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
93 # characters. 91 # characters.
94 # 92 #
95 # This is roughly equivalent to going back in time and setting 93 # This is roughly equivalent to going back in time and setting
96 # COMP_WORDBREAKS to exclude those characters. The intent is to 94 # COMP_WORDBREAKS to exclude those characters. The intent is to
97 # make option types like --date=<type> and <rev>:<path> easy to 95 # make option types like --date=<type> and <rev>:<path> easy to
98 # recognize by treating each shell word as a single token. 96 # recognize by treating each shell word as a single token.
99 # 97 #
100 # It is best not to set COMP_WORDBREAKS directly because the value is 98 # It is best not to set COMP_WORDBREAKS directly because the value is
101 # shared with other completion scripts. By the time the completion 99 # shared with other completion scripts. By the time the completion
102 # function gets called, COMP_WORDS has already been populated so local 100 # function gets called, COMP_WORDS has already been populated so local
103 # changes to COMP_WORDBREAKS have no effect. 101 # changes to COMP_WORDBREAKS have no effect.
104 # 102 #
105 # Output: words_, cword_, cur_. 103 # Output: words_, cword_, cur_.
106 104
107 __git_reassemble_comp_words_by_ref() 105 __git_reassemble_comp_words_by_ref()
108 { 106 {
109 local exclude i j first 107 local exclude i j first
110 # Which word separators to exclude? 108 # Which word separators to exclude?
111 exclude="${1//[^$COMP_WORDBREAKS]}" 109 exclude="${1//[^$COMP_WORDBREAKS]}"
112 cword_=$COMP_CWORD 110 cword_=$COMP_CWORD
113 if [ -z "$exclude" ]; then 111 if [ -z "$exclude" ]; then
114 words_=("${COMP_WORDS[@]}") 112 words_=("${COMP_WORDS[@]}")
115 return 113 return
116 fi 114 fi
117 # List of word completion separators has shrunk; 115 # List of word completion separators has shrunk;
118 # re-assemble words to complete. 116 # re-assemble words to complete.
119 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do 117 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
120 # Append each nonempty word consisting of just 118 # Append each nonempty word consisting of just
121 # word separator characters to the current word. 119 # word separator characters to the current word.
122 first=t 120 first=t
123 while 121 while
124 [ $i -gt 0 ] && 122 [ $i -gt 0 ] &&
125 [ -n "${COMP_WORDS[$i]}" ] && 123 [ -n "${COMP_WORDS[$i]}" ] &&
126 # word consists of excluded word separators 124 # word consists of excluded word separators
127 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] 125 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
128 do 126 do
129 # Attach to the previous token, 127 # Attach to the previous token,
130 # unless the previous token is the command name. 128 # unless the previous token is the command name.
131 if [ $j -ge 2 ] && [ -n "$first" ]; then 129 if [ $j -ge 2 ] && [ -n "$first" ]; then
132 ((j--)) 130 ((j--))
133 fi 131 fi
134 first= 132 first=
135 words_[$j]=${words_[j]}${COMP_WORDS[i]} 133 words_[$j]=${words_[j]}${COMP_WORDS[i]}
136 if [ $i = $COMP_CWORD ]; then 134 if [ $i = $COMP_CWORD ]; then
137 cword_=$j 135 cword_=$j
138 fi 136 fi
139 if (($i < ${#COMP_WORDS[@]} - 1)); then 137 if (($i < ${#COMP_WORDS[@]} - 1)); then
140 ((i++)) 138 ((i++))
141 else 139 else
142 # Done. 140 # Done.
143 return 141 return
144 fi 142 fi
145 done 143 done
146 words_[$j]=${words_[j]}${COMP_WORDS[i]} 144 words_[$j]=${words_[j]}${COMP_WORDS[i]}
147 if [ $i = $COMP_CWORD ]; then 145 if [ $i = $COMP_CWORD ]; then
148 cword_=$j 146 cword_=$j
149 fi 147 fi
150 done 148 done
151 } 149 }
152 150
153 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then 151 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
154 _get_comp_words_by_ref () 152 _get_comp_words_by_ref ()
155 { 153 {
156 local exclude cur_ words_ cword_ 154 local exclude cur_ words_ cword_
157 if [ "$1" = "-n" ]; then 155 if [ "$1" = "-n" ]; then
158 exclude=$2 156 exclude=$2
159 shift 2 157 shift 2
160 fi 158 fi
161 __git_reassemble_comp_words_by_ref "$exclude" 159 __git_reassemble_comp_words_by_ref "$exclude"
162 cur_=${words_[cword_]} 160 cur_=${words_[cword_]}
163 while [ $# -gt 0 ]; do 161 while [ $# -gt 0 ]; do
164 case "$1" in 162 case "$1" in
165 cur) 163 cur)
166 cur=$cur_ 164 cur=$cur_
167 ;; 165 ;;
168 prev) 166 prev)
169 prev=${words_[$cword_-1]} 167 prev=${words_[$cword_-1]}
170 ;; 168 ;;
171 words) 169 words)
172 words=("${words_[@]}") 170 words=("${words_[@]}")
173 ;; 171 ;;
174 cword) 172 cword)
175 cword=$cword_ 173 cword=$cword_
176 ;; 174 ;;
177 esac 175 esac
178 shift 176 shift
179 done 177 done
180 } 178 }
181 fi 179 fi
182 180
183 __gitcompadd () 181 __gitcompappend ()
184 { 182 {
185 local i=0 183 local i=${#COMPREPLY[@]}
186 for x in $1; do 184 for x in $1; do
187 if [[ "$x" == "$3"* ]]; then 185 if [[ "$x" == "$3"* ]]; then
188 COMPREPLY[i++]="$2$x$4" 186 COMPREPLY[i++]="$2$x$4"
189 fi 187 fi
190 done 188 done
191 } 189 }
192 190
191 __gitcompadd ()
192 {
193 COMPREPLY=()
194 __gitcompappend "$@"
195 }
196
193 # Generates completion reply, appending a space to possible completion words, 197 # Generates completion reply, appending a space to possible completion words,
194 # if necessary. 198 # if necessary.
195 # It accepts 1 to 4 arguments: 199 # It accepts 1 to 4 arguments:
196 # 1: List of possible completion words. 200 # 1: List of possible completion words.
197 # 2: A prefix to be added to each possible completion word (optional). 201 # 2: A prefix to be added to each possible completion word (optional).
198 # 3: Generate possible completion matches for this word (optional). 202 # 3: Generate possible completion matches for this word (optional).
199 # 4: A suffix to be appended to each possible completion word (optional). 203 # 4: A suffix to be appended to each possible completion word (optional).
200 __gitcomp () 204 __gitcomp ()
201 { 205 {
202 local cur_="${3-$cur}" 206 local cur_="${3-$cur}"
203 207
204 case "$cur_" in 208 case "$cur_" in
205 --*=) 209 --*=)
206 ;; 210 ;;
207 *) 211 *)
208 local c i=0 IFS=$' \t\n' 212 local c i=0 IFS=$' \t\n'
209 for c in $1; do 213 for c in $1; do
210 c="$c${4-}" 214 c="$c${4-}"
211 if [[ $c == "$cur_"* ]]; then 215 if [[ $c == "$cur_"* ]]; then
212 case $c in 216 case $c in
213 --*=*|*.) ;; 217 --*=*|*.) ;;
214 *) c="$c " ;; 218 *) c="$c " ;;
215 esac 219 esac
216 COMPREPLY[i++]="${2-}$c" 220 COMPREPLY[i++]="${2-}$c"
217 fi 221 fi
218 done 222 done
219 ;; 223 ;;
220 esac 224 esac
221 } 225 }
222 226
227 # Variation of __gitcomp_nl () that appends to the existing list of
228 # completion candidates, COMPREPLY.
229 __gitcomp_nl_append ()
230 {
231 local IFS=$'\n'
232 __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
233 }
234
223 # Generates completion reply from newline-separated possible completion words 235 # Generates completion reply from newline-separated possible completion words
224 # by appending a space to all of them. 236 # by appending a space to all of them.
225 # It accepts 1 to 4 arguments: 237 # It accepts 1 to 4 arguments:
226 # 1: List of possible completion words, separated by a single newline. 238 # 1: List of possible completion words, separated by a single newline.
227 # 2: A prefix to be added to each possible completion word (optional). 239 # 2: A prefix to be added to each possible completion word (optional).
228 # 3: Generate possible completion matches for this word (optional). 240 # 3: Generate possible completion matches for this word (optional).
229 # 4: A suffix to be appended to each possible completion word instead of 241 # 4: A suffix to be appended to each possible completion word instead of
230 # the default space (optional). If specified but empty, nothing is 242 # the default space (optional). If specified but empty, nothing is
231 # appended. 243 # appended.
232 __gitcomp_nl () 244 __gitcomp_nl ()
233 { 245 {
234 local IFS=$'\n' 246 COMPREPLY=()
235 __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" 247 __gitcomp_nl_append "$@"
236 } 248 }
237 249
238 # Generates completion reply with compgen from newline-separated possible 250 # Generates completion reply with compgen from newline-separated possible
239 # completion filenames. 251 # completion filenames.
240 # It accepts 1 to 3 arguments: 252 # It accepts 1 to 3 arguments:
241 # 1: List of possible completion filenames, separated by a single newline. 253 # 1: List of possible completion filenames, separated by a single newline.
242 # 2: A directory prefix to be added to each possible completion filename 254 # 2: A directory prefix to be added to each possible completion filename
243 # (optional). 255 # (optional).
244 # 3: Generate possible completion matches for this word (optional). 256 # 3: Generate possible completion matches for this word (optional).
245 __gitcomp_file () 257 __gitcomp_file ()
246 { 258 {
247 local IFS=$'\n' 259 local IFS=$'\n'
248 260
249 # XXX does not work when the directory prefix contains a tilde, 261 # XXX does not work when the directory prefix contains a tilde,
250 # since tilde expansion is not applied. 262 # since tilde expansion is not applied.
251 # This means that COMPREPLY will be empty and Bash default 263 # This means that COMPREPLY will be empty and Bash default
252 # completion will be used. 264 # completion will be used.
253 __gitcompadd "$1" "${2-}" "${3-$cur}" "" 265 __gitcompadd "$1" "${2-}" "${3-$cur}" ""
254 266
255 # use a hack to enable file mode in bash < 4 267 # use a hack to enable file mode in bash < 4
256 compopt -o filenames +o nospace 2>/dev/null || 268 compopt -o filenames +o nospace 2>/dev/null ||
257 compgen -f /non-existing-dir/ > /dev/null 269 compgen -f /non-existing-dir/ > /dev/null
258 } 270 }
259 271
260 # Execute 'git ls-files', unless the --committable option is specified, in 272 # Execute 'git ls-files', unless the --committable option is specified, in
261 # which case it runs 'git diff-index' to find out the files that can be 273 # which case it runs 'git diff-index' to find out the files that can be
262 # committed. It return paths relative to the directory specified in the first 274 # committed. It return paths relative to the directory specified in the first
263 # argument, and using the options specified in the second argument. 275 # argument, and using the options specified in the second argument.
264 __git_ls_files_helper () 276 __git_ls_files_helper ()
265 { 277 {
266 ( 278 (
267 test -n "${CDPATH+set}" && unset CDPATH 279 test -n "${CDPATH+set}" && unset CDPATH
268 cd "$1" 280 cd "$1"
269 if [ "$2" == "--committable" ]; then 281 if [ "$2" == "--committable" ]; then
270 git diff-index --name-only --relative HEAD 282 git diff-index --name-only --relative HEAD
271 else 283 else
272 # NOTE: $2 is not quoted in order to support multiple options 284 # NOTE: $2 is not quoted in order to support multiple options
273 git ls-files --exclude-standard $2 285 git ls-files --exclude-standard $2
274 fi 286 fi
275 ) 2>/dev/null 287 ) 2>/dev/null
276 } 288 }
277 289
278 290
279 # __git_index_files accepts 1 or 2 arguments: 291 # __git_index_files accepts 1 or 2 arguments:
280 # 1: Options to pass to ls-files (required). 292 # 1: Options to pass to ls-files (required).
281 # 2: A directory path (optional). 293 # 2: A directory path (optional).
282 # If provided, only files within the specified directory are listed. 294 # If provided, only files within the specified directory are listed.
283 # Sub directories are never recursed. Path must have a trailing 295 # Sub directories are never recursed. Path must have a trailing
284 # slash. 296 # slash.
285 __git_index_files () 297 __git_index_files ()
286 { 298 {
287 local dir="$(__gitdir)" root="${2-.}" file 299 local dir="$(__gitdir)" root="${2-.}" file
288 300
289 if [ -d "$dir" ]; then 301 if [ -d "$dir" ]; then
290 __git_ls_files_helper "$root" "$1" | 302 __git_ls_files_helper "$root" "$1" |
291 while read -r file; do 303 while read -r file; do
292 case "$file" in 304 case "$file" in
293 ?*/*) echo "${file%%/*}" ;; 305 ?*/*) echo "${file%%/*}" ;;
294 *) echo "$file" ;; 306 *) echo "$file" ;;
295 esac 307 esac
296 done | sort | uniq 308 done | sort | uniq
297 fi 309 fi
298 } 310 }
299 311
300 __git_heads () 312 __git_heads ()
301 { 313 {
302 local dir="$(__gitdir)" 314 local dir="$(__gitdir)"
303 if [ -d "$dir" ]; then 315 if [ -d "$dir" ]; then
304 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ 316 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
305 refs/heads 317 refs/heads
306 return 318 return
307 fi 319 fi
308 } 320 }
309 321
310 __git_tags () 322 __git_tags ()
311 { 323 {
312 local dir="$(__gitdir)" 324 local dir="$(__gitdir)"
313 if [ -d "$dir" ]; then 325 if [ -d "$dir" ]; then
314 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ 326 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
315 refs/tags 327 refs/tags
316 return 328 return
317 fi 329 fi
318 } 330 }
319 331
320 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments 332 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
321 # presence of 2nd argument means use the guess heuristic employed 333 # presence of 2nd argument means use the guess heuristic employed
322 # by checkout for tracking branches 334 # by checkout for tracking branches
323 __git_refs () 335 __git_refs ()
324 { 336 {
325 local i hash dir="$(__gitdir "${1-}")" track="${2-}" 337 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
326 local format refs 338 local format refs
327 if [ -d "$dir" ]; then 339 if [ -d "$dir" ]; then
328 case "$cur" in 340 case "$cur" in
329 refs|refs/*) 341 refs|refs/*)
330 format="refname" 342 format="refname"
331 refs="${cur%/*}" 343 refs="${cur%/*}"
332 track="" 344 track=""
333 ;; 345 ;;
334 *) 346 *)
335 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do 347 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
336 if [ -e "$dir/$i" ]; then echo $i; fi 348 if [ -e "$dir/$i" ]; then echo $i; fi
337 done 349 done
338 format="refname:short" 350 format="refname:short"
339 refs="refs/tags refs/heads refs/remotes" 351 refs="refs/tags refs/heads refs/remotes"
340 ;; 352 ;;
341 esac 353 esac
342 git --git-dir="$dir" for-each-ref --format="%($format)" \ 354 git --git-dir="$dir" for-each-ref --format="%($format)" \
343 $refs 355 $refs
344 if [ -n "$track" ]; then 356 if [ -n "$track" ]; then
345 # employ the heuristic used by git checkout 357 # employ the heuristic used by git checkout
346 # Try to find a remote branch that matches the completion word 358 # Try to find a remote branch that matches the completion word
347 # but only output if the branch name is unique 359 # but only output if the branch name is unique
348 local ref entry 360 local ref entry
349 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ 361 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
350 "refs/remotes/" | \ 362 "refs/remotes/" | \
351 while read -r entry; do 363 while read -r entry; do
352 eval "$entry" 364 eval "$entry"
353 ref="${ref#*/}" 365 ref="${ref#*/}"
354 if [[ "$ref" == "$cur"* ]]; then 366 if [[ "$ref" == "$cur"* ]]; then
355 echo "$ref" 367 echo "$ref"
356 fi 368 fi
357 done | sort | uniq -u 369 done | sort | uniq -u
358 fi 370 fi
359 return 371 return
360 fi 372 fi
361 case "$cur" in 373 case "$cur" in
362 refs|refs/*) 374 refs|refs/*)
363 git ls-remote "$dir" "$cur*" 2>/dev/null | \ 375 git ls-remote "$dir" "$cur*" 2>/dev/null | \
364 while read -r hash i; do 376 while read -r hash i; do
365 case "$i" in 377 case "$i" in
366 *^{}) ;; 378 *^{}) ;;
367 *) echo "$i" ;; 379 *) echo "$i" ;;
368 esac 380 esac
369 done 381 done
370 ;; 382 ;;
371 *) 383 *)
372 echo "HEAD" 384 echo "HEAD"
373 git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" 385 git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
374 ;; 386 ;;
375 esac 387 esac
376 } 388 }
377 389
378 # __git_refs2 requires 1 argument (to pass to __git_refs) 390 # __git_refs2 requires 1 argument (to pass to __git_refs)
379 __git_refs2 () 391 __git_refs2 ()
380 { 392 {
381 local i 393 local i
382 for i in $(__git_refs "$1"); do 394 for i in $(__git_refs "$1"); do
383 echo "$i:$i" 395 echo "$i:$i"
384 done 396 done
385 } 397 }
386 398
387 # __git_refs_remotes requires 1 argument (to pass to ls-remote) 399 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
388 __git_refs_remotes () 400 __git_refs_remotes ()
389 { 401 {
390 local i hash 402 local i hash
391 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \ 403 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
392 while read -r hash i; do 404 while read -r hash i; do
393 echo "$i:refs/remotes/$1/${i#refs/heads/}" 405 echo "$i:refs/remotes/$1/${i#refs/heads/}"
394 done 406 done
395 } 407 }
396 408
397 __git_remotes () 409 __git_remotes ()
398 { 410 {
399 local i IFS=$'\n' d="$(__gitdir)" 411 local i IFS=$'\n' d="$(__gitdir)"
400 test -d "$d/remotes" && ls -1 "$d/remotes" 412 test -d "$d/remotes" && ls -1 "$d/remotes"
401 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do 413 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
402 i="${i#remote.}" 414 i="${i#remote.}"
403 echo "${i/.url*/}" 415 echo "${i/.url*/}"
404 done 416 done
405 } 417 }
406 418
407 __git_list_merge_strategies () 419 __git_list_merge_strategies ()
408 { 420 {
409 git merge -s help 2>&1 | 421 git merge -s help 2>&1 |
410 sed -n -e '/[Aa]vailable strategies are: /,/^$/{ 422 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
411 s/\.$// 423 s/\.$//
412 s/.*:// 424 s/.*://
413 s/^[ ]*// 425 s/^[ ]*//
414 s/[ ]*$// 426 s/[ ]*$//
415 p 427 p
416 }' 428 }'
417 } 429 }
418 430
419 __git_merge_strategies= 431 __git_merge_strategies=
420 # 'git merge -s help' (and thus detection of the merge strategy 432 # 'git merge -s help' (and thus detection of the merge strategy
421 # list) fails, unfortunately, if run outside of any git working 433 # list) fails, unfortunately, if run outside of any git working
422 # tree. __git_merge_strategies is set to the empty string in 434 # tree. __git_merge_strategies is set to the empty string in
423 # that case, and the detection will be repeated the next time it 435 # that case, and the detection will be repeated the next time it
424 # is needed. 436 # is needed.
425 __git_compute_merge_strategies () 437 __git_compute_merge_strategies ()
426 { 438 {
427 test -n "$__git_merge_strategies" || 439 test -n "$__git_merge_strategies" ||
428 __git_merge_strategies=$(__git_list_merge_strategies) 440 __git_merge_strategies=$(__git_list_merge_strategies)
429 } 441 }
430 442
431 __git_complete_revlist_file () 443 __git_complete_revlist_file ()
432 { 444 {
433 local pfx ls ref cur_="$cur" 445 local pfx ls ref cur_="$cur"
434 case "$cur_" in 446 case "$cur_" in
435 *..?*:*) 447 *..?*:*)
436 return 448 return
437 ;; 449 ;;
438 ?*:*) 450 ?*:*)
439 ref="${cur_%%:*}" 451 ref="${cur_%%:*}"
440 cur_="${cur_#*:}" 452 cur_="${cur_#*:}"
441 case "$cur_" in 453 case "$cur_" in
442 ?*/*) 454 ?*/*)
443 pfx="${cur_%/*}" 455 pfx="${cur_%/*}"
444 cur_="${cur_##*/}" 456 cur_="${cur_##*/}"
445 ls="$ref:$pfx" 457 ls="$ref:$pfx"
446 pfx="$pfx/" 458 pfx="$pfx/"
447 ;; 459 ;;
448 *) 460 *)
449 ls="$ref" 461 ls="$ref"
450 ;; 462 ;;
451 esac 463 esac
452 464
453 case "$COMP_WORDBREAKS" in 465 case "$COMP_WORDBREAKS" in
454 *:*) : great ;; 466 *:*) : great ;;
455 *) pfx="$ref:$pfx" ;; 467 *) pfx="$ref:$pfx" ;;
456 esac 468 esac
457 469
458 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \ 470 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
459 | sed '/^100... blob /{ 471 | sed '/^100... blob /{
460 s,^.* ,, 472 s,^.* ,,
461 s,$, , 473 s,$, ,
462 } 474 }
463 /^120000 blob /{ 475 /^120000 blob /{
464 s,^.* ,, 476 s,^.* ,,
465 s,$, , 477 s,$, ,
466 } 478 }
467 /^040000 tree /{ 479 /^040000 tree /{
468 s,^.* ,, 480 s,^.* ,,
469 s,$,/, 481 s,$,/,
470 } 482 }
471 s/^.* //')" \ 483 s/^.* //')" \
472 "$pfx" "$cur_" "" 484 "$pfx" "$cur_" ""
473 ;; 485 ;;
474 *...*) 486 *...*)
475 pfx="${cur_%...*}..." 487 pfx="${cur_%...*}..."
476 cur_="${cur_#*...}" 488 cur_="${cur_#*...}"
477 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" 489 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
478 ;; 490 ;;
479 *..*) 491 *..*)
480 pfx="${cur_%..*}.." 492 pfx="${cur_%..*}.."
481 cur_="${cur_#*..}" 493 cur_="${cur_#*..}"
482 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" 494 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
483 ;; 495 ;;
484 *) 496 *)
485 __gitcomp_nl "$(__git_refs)" 497 __gitcomp_nl "$(__git_refs)"
486 ;; 498 ;;
487 esac 499 esac
488 } 500 }
489 501
490 502
491 # __git_complete_index_file requires 1 argument: 503 # __git_complete_index_file requires 1 argument:
492 # 1: the options to pass to ls-file 504 # 1: the options to pass to ls-file
493 # 505 #
494 # The exception is --committable, which finds the files appropriate commit. 506 # The exception is --committable, which finds the files appropriate commit.
495 __git_complete_index_file () 507 __git_complete_index_file ()
496 { 508 {
497 local pfx="" cur_="$cur" 509 local pfx="" cur_="$cur"
498 510
499 case "$cur_" in 511 case "$cur_" in
500 ?*/*) 512 ?*/*)
501 pfx="${cur_%/*}" 513 pfx="${cur_%/*}"
502 cur_="${cur_##*/}" 514 cur_="${cur_##*/}"
503 pfx="${pfx}/" 515 pfx="${pfx}/"
504 ;; 516 ;;
505 esac 517 esac
506 518
507 __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" 519 __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
508 } 520 }
509 521
510 __git_complete_file () 522 __git_complete_file ()
511 { 523 {
512 __git_complete_revlist_file 524 __git_complete_revlist_file
513 } 525 }
514 526
515 __git_complete_revlist () 527 __git_complete_revlist ()
516 { 528 {
517 __git_complete_revlist_file 529 __git_complete_revlist_file
518 } 530 }
519 531
520 __git_complete_remote_or_refspec () 532 __git_complete_remote_or_refspec ()
521 { 533 {
522 local cur_="$cur" cmd="${words[1]}" 534 local cur_="$cur" cmd="${words[1]}"
523 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 535 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
524 if [ "$cmd" = "remote" ]; then 536 if [ "$cmd" = "remote" ]; then
525 ((c++)) 537 ((c++))
526 fi 538 fi
527 while [ $c -lt $cword ]; do 539 while [ $c -lt $cword ]; do
528 i="${words[c]}" 540 i="${words[c]}"
529 case "$i" in 541 case "$i" in
530 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; 542 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
531 --all) 543 --all)
532 case "$cmd" in 544 case "$cmd" in
533 push) no_complete_refspec=1 ;; 545 push) no_complete_refspec=1 ;;
534 fetch) 546 fetch)
535 return 547 return
536 ;; 548 ;;
537 *) ;; 549 *) ;;
538 esac 550 esac
539 ;; 551 ;;
540 -*) ;; 552 -*) ;;
541 *) remote="$i"; break ;; 553 *) remote="$i"; break ;;
542 esac 554 esac
543 ((c++)) 555 ((c++))
544 done 556 done
545 if [ -z "$remote" ]; then 557 if [ -z "$remote" ]; then
546 __gitcomp_nl "$(__git_remotes)" 558 __gitcomp_nl "$(__git_remotes)"
547 return 559 return
548 fi 560 fi
549 if [ $no_complete_refspec = 1 ]; then 561 if [ $no_complete_refspec = 1 ]; then
550 return 562 return
551 fi 563 fi
552 [ "$remote" = "." ] && remote= 564 [ "$remote" = "." ] && remote=
553 case "$cur_" in 565 case "$cur_" in
554 *:*) 566 *:*)
555 case "$COMP_WORDBREAKS" in 567 case "$COMP_WORDBREAKS" in
556 *:*) : great ;; 568 *:*) : great ;;
557 *) pfx="${cur_%%:*}:" ;; 569 *) pfx="${cur_%%:*}:" ;;
558 esac 570 esac
559 cur_="${cur_#*:}" 571 cur_="${cur_#*:}"
560 lhs=0 572 lhs=0
561 ;; 573 ;;
562 +*) 574 +*)
563 pfx="+" 575 pfx="+"
564 cur_="${cur_#+}" 576 cur_="${cur_#+}"
565 ;; 577 ;;
566 esac 578 esac
567 case "$cmd" in 579 case "$cmd" in
568 fetch) 580 fetch)
569 if [ $lhs = 1 ]; then 581 if [ $lhs = 1 ]; then
570 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_" 582 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
571 else 583 else
572 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" 584 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
573 fi 585 fi
574 ;; 586 ;;
575 pull|remote) 587 pull|remote)
576 if [ $lhs = 1 ]; then 588 if [ $lhs = 1 ]; then
577 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" 589 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
578 else 590 else
579 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" 591 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
580 fi 592 fi
581 ;; 593 ;;
582 push) 594 push)
583 if [ $lhs = 1 ]; then 595 if [ $lhs = 1 ]; then
584 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" 596 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
585 else 597 else
586 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" 598 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
587 fi 599 fi
588 ;; 600 ;;
589 esac 601 esac
590 } 602 }
591 603
592 __git_complete_strategy () 604 __git_complete_strategy ()
593 { 605 {
594 __git_compute_merge_strategies 606 __git_compute_merge_strategies
595 case "$prev" in 607 case "$prev" in
596 -s|--strategy) 608 -s|--strategy)
597 __gitcomp "$__git_merge_strategies" 609 __gitcomp "$__git_merge_strategies"
598 return 0 610 return 0
599 esac 611 esac
600 case "$cur" in 612 case "$cur" in
601 --strategy=*) 613 --strategy=*)
602 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" 614 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
603 return 0 615 return 0
604 ;; 616 ;;
605 esac 617 esac
606 return 1 618 return 1
607 } 619 }
608 620
609 __git_commands () { 621 __git_commands () {
610 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" 622 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
611 then 623 then
612 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" 624 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
613 else 625 else
614 git help -a|egrep '^ [a-zA-Z0-9]' 626 git help -a|egrep '^ [a-zA-Z0-9]'
615 fi 627 fi
616 } 628 }
617 629
618 __git_list_all_commands () 630 __git_list_all_commands ()
619 { 631 {
620 local i IFS=" "$'\n' 632 local i IFS=" "$'\n'
621 for i in $(__git_commands) 633 for i in $(__git_commands)
622 do 634 do
623 case $i in 635 case $i in
624 *--*) : helper pattern;; 636 *--*) : helper pattern;;
625 *) echo $i;; 637 *) echo $i;;
626 esac 638 esac
627 done 639 done
628 } 640 }
629 641
630 __git_all_commands= 642 __git_all_commands=
631 __git_compute_all_commands () 643 __git_compute_all_commands ()
632 { 644 {
633 test -n "$__git_all_commands" || 645 test -n "$__git_all_commands" ||
634 __git_all_commands=$(__git_list_all_commands) 646 __git_all_commands=$(__git_list_all_commands)
635 } 647 }
636 648
637 __git_list_porcelain_commands () 649 __git_list_porcelain_commands ()
638 { 650 {
639 local i IFS=" "$'\n' 651 local i IFS=" "$'\n'
640 __git_compute_all_commands 652 __git_compute_all_commands
641 for i in $__git_all_commands 653 for i in $__git_all_commands
642 do 654 do
643 case $i in 655 case $i in
644 *--*) : helper pattern;; 656 *--*) : helper pattern;;
645 applymbox) : ask gittus;; 657 applymbox) : ask gittus;;
646 applypatch) : ask gittus;; 658 applypatch) : ask gittus;;
647 archimport) : import;; 659 archimport) : import;;
648 cat-file) : plumbing;; 660 cat-file) : plumbing;;
649 check-attr) : plumbing;; 661 check-attr) : plumbing;;
650 check-ignore) : plumbing;; 662 check-ignore) : plumbing;;
651 check-mailmap) : plumbing;; 663 check-mailmap) : plumbing;;
652 check-ref-format) : plumbing;; 664 check-ref-format) : plumbing;;
653 checkout-index) : plumbing;; 665 checkout-index) : plumbing;;
654 commit-tree) : plumbing;; 666 commit-tree) : plumbing;;
655 count-objects) : infrequent;; 667 count-objects) : infrequent;;
656 credential-cache) : credentials helper;; 668 credential-cache) : credentials helper;;
657 credential-store) : credentials helper;; 669 credential-store) : credentials helper;;
658 cvsexportcommit) : export;; 670 cvsexportcommit) : export;;
659 cvsimport) : import;; 671 cvsimport) : import;;
660 cvsserver) : daemon;; 672 cvsserver) : daemon;;
661 daemon) : daemon;; 673 daemon) : daemon;;
662 diff-files) : plumbing;; 674 diff-files) : plumbing;;
663 diff-index) : plumbing;; 675 diff-index) : plumbing;;
664 diff-tree) : plumbing;; 676 diff-tree) : plumbing;;
665 fast-import) : import;; 677 fast-import) : import;;
666 fast-export) : export;; 678 fast-export) : export;;
667 fsck-objects) : plumbing;; 679 fsck-objects) : plumbing;;
668 fetch-pack) : plumbing;; 680 fetch-pack) : plumbing;;
669 fmt-merge-msg) : plumbing;; 681 fmt-merge-msg) : plumbing;;
670 for-each-ref) : plumbing;; 682 for-each-ref) : plumbing;;
671 hash-object) : plumbing;; 683 hash-object) : plumbing;;
672 http-*) : transport;; 684 http-*) : transport;;
673 index-pack) : plumbing;; 685 index-pack) : plumbing;;
674 init-db) : deprecated;; 686 init-db) : deprecated;;
675 local-fetch) : plumbing;; 687 local-fetch) : plumbing;;
676 lost-found) : infrequent;;
677 ls-files) : plumbing;; 688 ls-files) : plumbing;;
678 ls-remote) : plumbing;; 689 ls-remote) : plumbing;;
679 ls-tree) : plumbing;; 690 ls-tree) : plumbing;;
680 mailinfo) : plumbing;; 691 mailinfo) : plumbing;;
681 mailsplit) : plumbing;; 692 mailsplit) : plumbing;;
682 merge-*) : plumbing;; 693 merge-*) : plumbing;;
683 mktree) : plumbing;; 694 mktree) : plumbing;;
684 mktag) : plumbing;; 695 mktag) : plumbing;;
685 pack-objects) : plumbing;; 696 pack-objects) : plumbing;;
686 pack-redundant) : plumbing;; 697 pack-redundant) : plumbing;;
687 pack-refs) : plumbing;; 698 pack-refs) : plumbing;;
688 parse-remote) : plumbing;; 699 parse-remote) : plumbing;;
689 patch-id) : plumbing;; 700 patch-id) : plumbing;;
690 peek-remote) : plumbing;;
691 prune) : plumbing;; 701 prune) : plumbing;;
692 prune-packed) : plumbing;; 702 prune-packed) : plumbing;;
693 quiltimport) : import;; 703 quiltimport) : import;;
694 read-tree) : plumbing;; 704 read-tree) : plumbing;;
695 receive-pack) : plumbing;; 705 receive-pack) : plumbing;;
696 remote-*) : transport;; 706 remote-*) : transport;;
697 repo-config) : deprecated;;
698 rerere) : plumbing;; 707 rerere) : plumbing;;
699 rev-list) : plumbing;; 708 rev-list) : plumbing;;
700 rev-parse) : plumbing;; 709 rev-parse) : plumbing;;
701 runstatus) : plumbing;; 710 runstatus) : plumbing;;
702 sh-setup) : internal;; 711 sh-setup) : internal;;
703 shell) : daemon;; 712 shell) : daemon;;
704 show-ref) : plumbing;; 713 show-ref) : plumbing;;
705 send-pack) : plumbing;; 714 send-pack) : plumbing;;
706 show-index) : plumbing;; 715 show-index) : plumbing;;
707 ssh-*) : transport;; 716 ssh-*) : transport;;
708 stripspace) : plumbing;; 717 stripspace) : plumbing;;
709 symbolic-ref) : plumbing;; 718 symbolic-ref) : plumbing;;
710 tar-tree) : deprecated;;
711 unpack-file) : plumbing;; 719 unpack-file) : plumbing;;
712 unpack-objects) : plumbing;; 720 unpack-objects) : plumbing;;
713 update-index) : plumbing;; 721 update-index) : plumbing;;
714 update-ref) : plumbing;; 722 update-ref) : plumbing;;
715 update-server-info) : daemon;; 723 update-server-info) : daemon;;
716 upload-archive) : plumbing;; 724 upload-archive) : plumbing;;
717 upload-pack) : plumbing;; 725 upload-pack) : plumbing;;
718 write-tree) : plumbing;; 726 write-tree) : plumbing;;
719 var) : infrequent;; 727 var) : infrequent;;
720 verify-pack) : infrequent;; 728 verify-pack) : infrequent;;
721 verify-tag) : plumbing;; 729 verify-tag) : plumbing;;
722 *) echo $i;; 730 *) echo $i;;
723 esac 731 esac
724 done 732 done
725 } 733 }
726 734
727 __git_porcelain_commands= 735 __git_porcelain_commands=
728 __git_compute_porcelain_commands () 736 __git_compute_porcelain_commands ()
729 { 737 {
730 __git_compute_all_commands 738 __git_compute_all_commands
731 test -n "$__git_porcelain_commands" || 739 test -n "$__git_porcelain_commands" ||
732 __git_porcelain_commands=$(__git_list_porcelain_commands) 740 __git_porcelain_commands=$(__git_list_porcelain_commands)
733 } 741 }
734 742
735 __git_pretty_aliases () 743 __git_pretty_aliases ()
736 { 744 {
737 local i IFS=$'\n' 745 local i IFS=$'\n'
738 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do 746 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
739 case "$i" in 747 case "$i" in
740 pretty.*) 748 pretty.*)
741 i="${i#pretty.}" 749 i="${i#pretty.}"
742 echo "${i/ */}" 750 echo "${i/ */}"
743 ;; 751 ;;
744 esac 752 esac
745 done 753 done
746 } 754 }
747 755
748 __git_aliases () 756 __git_aliases ()
749 { 757 {
750 local i IFS=$'\n' 758 local i IFS=$'\n'
751 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do 759 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
752 case "$i" in 760 case "$i" in
753 alias.*) 761 alias.*)
754 i="${i#alias.}" 762 i="${i#alias.}"
755 echo "${i/ */}" 763 echo "${i/ */}"
756 ;; 764 ;;
757 esac 765 esac
758 done 766 done
759 } 767 }
760 768
761 # __git_aliased_command requires 1 argument 769 # __git_aliased_command requires 1 argument
762 __git_aliased_command () 770 __git_aliased_command ()
763 { 771 {
764 local word cmdline=$(git --git-dir="$(__gitdir)" \ 772 local word cmdline=$(git --git-dir="$(__gitdir)" \
765 config --get "alias.$1") 773 config --get "alias.$1")
766 for word in $cmdline; do 774 for word in $cmdline; do
767 case "$word" in 775 case "$word" in
768 \!gitk|gitk) 776 \!gitk|gitk)
769 echo "gitk" 777 echo "gitk"
770 return 778 return
771 ;; 779 ;;
772 \!*) : shell command alias ;; 780 \!*) : shell command alias ;;
773 -*) : option ;; 781 -*) : option ;;
774 *=*) : setting env ;; 782 *=*) : setting env ;;
775 git) : git itself ;; 783 git) : git itself ;;
776 *) 784 *)
777 echo "$word" 785 echo "$word"
778 return 786 return
779 esac 787 esac
780 done 788 done
781 } 789 }
782 790
783 # __git_find_on_cmdline requires 1 argument 791 # __git_find_on_cmdline requires 1 argument
784 __git_find_on_cmdline () 792 __git_find_on_cmdline ()
785 { 793 {
786 local word subcommand c=1 794 local word subcommand c=1
787 while [ $c -lt $cword ]; do 795 while [ $c -lt $cword ]; do
788 word="${words[c]}" 796 word="${words[c]}"
789 for subcommand in $1; do 797 for subcommand in $1; do
790 if [ "$subcommand" = "$word" ]; then 798 if [ "$subcommand" = "$word" ]; then
791 echo "$subcommand" 799 echo "$subcommand"
792 return 800 return
793 fi 801 fi
794 done 802 done
795 ((c++)) 803 ((c++))
796 done 804 done
797 } 805 }
798 806
799 __git_has_doubledash () 807 __git_has_doubledash ()
800 { 808 {
801 local c=1 809 local c=1
802 while [ $c -lt $cword ]; do 810 while [ $c -lt $cword ]; do
803 if [ "--" = "${words[c]}" ]; then 811 if [ "--" = "${words[c]}" ]; then
804 return 0 812 return 0
805 fi 813 fi
806 ((c++)) 814 ((c++))
807 done 815 done
808 return 1 816 return 1
809 } 817 }
810 818
811 # Try to count non option arguments passed on the command line for the 819 # Try to count non option arguments passed on the command line for the
812 # specified git command. 820 # specified git command.
813 # When options are used, it is necessary to use the special -- option to 821 # When options are used, it is necessary to use the special -- option to
814 # tell the implementation were non option arguments begin. 822 # tell the implementation were non option arguments begin.
815 # XXX this can not be improved, since options can appear everywhere, as 823 # XXX this can not be improved, since options can appear everywhere, as
816 # an example: 824 # an example:
817 # git mv x -n y 825 # git mv x -n y
818 # 826 #
819 # __git_count_arguments requires 1 argument: the git command executed. 827 # __git_count_arguments requires 1 argument: the git command executed.
820 __git_count_arguments () 828 __git_count_arguments ()
821 { 829 {
822 local word i c=0 830 local word i c=0
823 831
824 # Skip "git" (first argument) 832 # Skip "git" (first argument)
825 for ((i=1; i < ${#words[@]}; i++)); do 833 for ((i=1; i < ${#words[@]}; i++)); do
826 word="${words[i]}" 834 word="${words[i]}"
827 835
828 case "$word" in 836 case "$word" in
829 --) 837 --)
830 # Good; we can assume that the following are only non 838 # Good; we can assume that the following are only non
831 # option arguments. 839 # option arguments.
832 ((c = 0)) 840 ((c = 0))
833 ;; 841 ;;
834 "$1") 842 "$1")
835 # Skip the specified git command and discard git 843 # Skip the specified git command and discard git
836 # main options 844 # main options
837 ((c = 0)) 845 ((c = 0))
838 ;; 846 ;;
839 ?*) 847 ?*)
840 ((c++)) 848 ((c++))
841 ;; 849 ;;
842 esac 850 esac
843 done 851 done
844 852
845 printf "%d" $c 853 printf "%d" $c
846 } 854 }
847 855
848 __git_whitespacelist="nowarn warn error error-all fix" 856 __git_whitespacelist="nowarn warn error error-all fix"
849 857
850 _git_am () 858 _git_am ()
851 { 859 {
852 local dir="$(__gitdir)" 860 local dir="$(__gitdir)"
853 if [ -d "$dir"/rebase-apply ]; then 861 if [ -d "$dir"/rebase-apply ]; then
854 __gitcomp "--skip --continue --resolved --abort" 862 __gitcomp "--skip --continue --resolved --abort"
855 return 863 return
856 fi 864 fi
857 case "$cur" in 865 case "$cur" in
858 --whitespace=*) 866 --whitespace=*)
859 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 867 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
860 return 868 return
861 ;; 869 ;;
862 --*) 870 --*)
863 __gitcomp " 871 __gitcomp "
864 --3way --committer-date-is-author-date --ignore-date 872 --3way --committer-date-is-author-date --ignore-date
865 --ignore-whitespace --ignore-space-change 873 --ignore-whitespace --ignore-space-change
866 --interactive --keep --no-utf8 --signoff --utf8 874 --interactive --keep --no-utf8 --signoff --utf8
867 --whitespace= --scissors 875 --whitespace= --scissors
868 " 876 "
869 return 877 return
870 esac 878 esac
871 } 879 }
872 880
873 _git_apply () 881 _git_apply ()
874 { 882 {
875 case "$cur" in 883 case "$cur" in
876 --whitespace=*) 884 --whitespace=*)
877 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 885 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
878 return 886 return
879 ;; 887 ;;
880 --*) 888 --*)
881 __gitcomp " 889 __gitcomp "
882 --stat --numstat --summary --check --index 890 --stat --numstat --summary --check --index
883 --cached --index-info --reverse --reject --unidiff-zero 891 --cached --index-info --reverse --reject --unidiff-zero
884 --apply --no-add --exclude= 892 --apply --no-add --exclude=
885 --ignore-whitespace --ignore-space-change 893 --ignore-whitespace --ignore-space-change
886 --whitespace= --inaccurate-eof --verbose 894 --whitespace= --inaccurate-eof --verbose
887 " 895 "
888 return 896 return
889 esac 897 esac
890 } 898 }
891 899
892 _git_add () 900 _git_add ()
893 { 901 {
894 case "$cur" in 902 case "$cur" in
895 --*) 903 --*)
896 __gitcomp " 904 __gitcomp "
897 --interactive --refresh --patch --update --dry-run 905 --interactive --refresh --patch --update --dry-run
898 --ignore-errors --intent-to-add 906 --ignore-errors --intent-to-add
899 " 907 "
900 return 908 return
901 esac 909 esac
902 910
903 # XXX should we check for --update and --all options ? 911 # XXX should we check for --update and --all options ?
904 __git_complete_index_file "--others --modified" 912 __git_complete_index_file "--others --modified --directory --no-empty-directory"
905 } 913 }
906 914
907 _git_archive () 915 _git_archive ()
908 { 916 {
909 case "$cur" in 917 case "$cur" in
910 --format=*) 918 --format=*)
911 __gitcomp "$(git archive --list)" "" "${cur##--format=}" 919 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
912 return 920 return
913 ;; 921 ;;
914 --remote=*) 922 --remote=*)
915 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}" 923 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
916 return 924 return
917 ;; 925 ;;
918 --*) 926 --*)
919 __gitcomp " 927 __gitcomp "
920 --format= --list --verbose 928 --format= --list --verbose
921 --prefix= --remote= --exec= 929 --prefix= --remote= --exec=
922 " 930 "
923 return 931 return
924 ;; 932 ;;
925 esac 933 esac
926 __git_complete_file 934 __git_complete_file
927 } 935 }
928 936
929 _git_bisect () 937 _git_bisect ()
930 { 938 {
931 __git_has_doubledash && return 939 __git_has_doubledash && return
932 940
933 local subcommands="start bad good skip reset visualize replay log run" 941 local subcommands="start bad good skip reset visualize replay log run"
934 local subcommand="$(__git_find_on_cmdline "$subcommands")" 942 local subcommand="$(__git_find_on_cmdline "$subcommands")"
935 if [ -z "$subcommand" ]; then 943 if [ -z "$subcommand" ]; then
936 if [ -f "$(__gitdir)"/BISECT_START ]; then 944 if [ -f "$(__gitdir)"/BISECT_START ]; then
937 __gitcomp "$subcommands" 945 __gitcomp "$subcommands"
938 else 946 else
939 __gitcomp "replay start" 947 __gitcomp "replay start"
940 fi 948 fi
941 return 949 return
942 fi 950 fi
943 951
944 case "$subcommand" in 952 case "$subcommand" in
945 bad|good|reset|skip|start) 953 bad|good|reset|skip|start)
946 __gitcomp_nl "$(__git_refs)" 954 __gitcomp_nl "$(__git_refs)"
947 ;; 955 ;;
948 *) 956 *)
949 ;; 957 ;;
950 esac 958 esac
951 } 959 }
952 960
953 _git_branch () 961 _git_branch ()
954 { 962 {
955 local i c=1 only_local_ref="n" has_r="n" 963 local i c=1 only_local_ref="n" has_r="n"
956 964
957 while [ $c -lt $cword ]; do 965 while [ $c -lt $cword ]; do
958 i="${words[c]}" 966 i="${words[c]}"
959 case "$i" in 967 case "$i" in
960 -d|-m) only_local_ref="y" ;; 968 -d|-m) only_local_ref="y" ;;
961 -r) has_r="y" ;; 969 -r) has_r="y" ;;
962 esac 970 esac
963 ((c++)) 971 ((c++))
964 done 972 done
965 973
966 case "$cur" in 974 case "$cur" in
967 --set-upstream-to=*) 975 --set-upstream-to=*)
968 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" 976 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
969 ;; 977 ;;
970 --*) 978 --*)
971 __gitcomp " 979 __gitcomp "
972 --color --no-color --verbose --abbrev= --no-abbrev 980 --color --no-color --verbose --abbrev= --no-abbrev
973 --track --no-track --contains --merged --no-merged 981 --track --no-track --contains --merged --no-merged
974 --set-upstream-to= --edit-description --list 982 --set-upstream-to= --edit-description --list
975 --unset-upstream 983 --unset-upstream
976 " 984 "
977 ;; 985 ;;
978 *) 986 *)
979 if [ $only_local_ref = "y" -a $has_r = "n" ]; then 987 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
980 __gitcomp_nl "$(__git_heads)" 988 __gitcomp_nl "$(__git_heads)"
981 else 989 else
982 __gitcomp_nl "$(__git_refs)" 990 __gitcomp_nl "$(__git_refs)"
983 fi 991 fi
984 ;; 992 ;;
985 esac 993 esac
986 } 994 }
987 995
988 _git_bundle () 996 _git_bundle ()
989 { 997 {
990 local cmd="${words[2]}" 998 local cmd="${words[2]}"
991 case "$cword" in 999 case "$cword" in
992 2) 1000 2)
993 __gitcomp "create list-heads verify unbundle" 1001 __gitcomp "create list-heads verify unbundle"
994 ;; 1002 ;;
995 3) 1003 3)
996 # looking for a file 1004 # looking for a file
997 ;; 1005 ;;
998 *) 1006 *)
999 case "$cmd" in 1007 case "$cmd" in
1000 create) 1008 create)
1001 __git_complete_revlist 1009 __git_complete_revlist
1002 ;; 1010 ;;
1003 esac 1011 esac
1004 ;; 1012 ;;
1005 esac 1013 esac
1006 } 1014 }
1007 1015
1008 _git_checkout () 1016 _git_checkout ()
1009 { 1017 {
1010 __git_has_doubledash && return 1018 __git_has_doubledash && return
1011 1019
1012 case "$cur" in 1020 case "$cur" in
1013 --conflict=*) 1021 --conflict=*)
1014 __gitcomp "diff3 merge" "" "${cur##--conflict=}" 1022 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
1015 ;; 1023 ;;
1016 --*) 1024 --*)
1017 __gitcomp " 1025 __gitcomp "
1018 --quiet --ours --theirs --track --no-track --merge 1026 --quiet --ours --theirs --track --no-track --merge
1019 --conflict= --orphan --patch 1027 --conflict= --orphan --patch
1020 " 1028 "
1021 ;; 1029 ;;
1022 *) 1030 *)
1023 # check if --track, --no-track, or --no-guess was specified 1031 # check if --track, --no-track, or --no-guess was specified
1024 # if so, disable DWIM mode 1032 # if so, disable DWIM mode
1025 local flags="--track --no-track --no-guess" track=1 1033 local flags="--track --no-track --no-guess" track=1
1026 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then 1034 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1027 track='' 1035 track=''
1028 fi 1036 fi
1029 __gitcomp_nl "$(__git_refs '' $track)" 1037 __gitcomp_nl "$(__git_refs '' $track)"
1030 ;; 1038 ;;
1031 esac 1039 esac
1032 } 1040 }
1033 1041
1034 _git_cherry () 1042 _git_cherry ()
1035 { 1043 {
1036 __gitcomp "$(__git_refs)" 1044 __gitcomp "$(__git_refs)"
1037 } 1045 }
1038 1046
1039 _git_cherry_pick () 1047 _git_cherry_pick ()
1040 { 1048 {
1041 local dir="$(__gitdir)" 1049 local dir="$(__gitdir)"
1042 if [ -f "$dir"/CHERRY_PICK_HEAD ]; then 1050 if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
1043 __gitcomp "--continue --quit --abort" 1051 __gitcomp "--continue --quit --abort"
1044 return 1052 return
1045 fi 1053 fi
1046 case "$cur" in 1054 case "$cur" in
1047 --*) 1055 --*)
1048 __gitcomp "--edit --no-commit --signoff --strategy= --mainline" 1056 __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
1049 ;; 1057 ;;
1050 *) 1058 *)
1051 __gitcomp_nl "$(__git_refs)" 1059 __gitcomp_nl "$(__git_refs)"
1052 ;; 1060 ;;
1053 esac 1061 esac
1054 } 1062 }
1055 1063
1056 _git_clean () 1064 _git_clean ()
1057 { 1065 {
1058 case "$cur" in 1066 case "$cur" in
1059 --*) 1067 --*)
1060 __gitcomp "--dry-run --quiet" 1068 __gitcomp "--dry-run --quiet"
1061 return 1069 return
1062 ;; 1070 ;;
1063 esac 1071 esac
1064 1072
1065 # XXX should we check for -x option ? 1073 # XXX should we check for -x option ?
1066 __git_complete_index_file "--others" 1074 __git_complete_index_file "--others --directory"
1067 } 1075 }
1068 1076
1069 _git_clone () 1077 _git_clone ()
1070 { 1078 {
1071 case "$cur" in 1079 case "$cur" in
1072 --*) 1080 --*)
1073 __gitcomp " 1081 __gitcomp "
1074 --local 1082 --local
1075 --no-hardlinks 1083 --no-hardlinks
1076 --shared 1084 --shared
1077 --reference 1085 --reference
1078 --quiet 1086 --quiet
1079 --no-checkout 1087 --no-checkout
1080 --bare 1088 --bare
1081 --mirror 1089 --mirror
1082 --origin 1090 --origin
1083 --upload-pack 1091 --upload-pack
1084 --template= 1092 --template=
1085 --depth 1093 --depth
1086 --single-branch 1094 --single-branch
1087 --branch 1095 --branch
1088 " 1096 "
1089 return 1097 return
1090 ;; 1098 ;;
1091 esac 1099 esac
1092 } 1100 }
1093 1101
1094 _git_commit () 1102 _git_commit ()
1095 { 1103 {
1096 case "$prev" in 1104 case "$prev" in
1097 -c|-C) 1105 -c|-C)
1098 __gitcomp_nl "$(__git_refs)" "" "${cur}" 1106 __gitcomp_nl "$(__git_refs)" "" "${cur}"
1099 return 1107 return
1100 ;; 1108 ;;
1101 esac 1109 esac
1102 1110
1103 case "$cur" in 1111 case "$cur" in
1104 --cleanup=*) 1112 --cleanup=*)
1105 __gitcomp "default strip verbatim whitespace 1113 __gitcomp "default strip verbatim whitespace
1106 " "" "${cur##--cleanup=}" 1114 " "" "${cur##--cleanup=}"
1107 return 1115 return
1108 ;; 1116 ;;
1109 --reuse-message=*|--reedit-message=*|\ 1117 --reuse-message=*|--reedit-message=*|\
1110 --fixup=*|--squash=*) 1118 --fixup=*|--squash=*)
1111 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" 1119 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1112 return 1120 return
1113 ;; 1121 ;;
1114 --untracked-files=*) 1122 --untracked-files=*)
1115 __gitcomp "all no normal" "" "${cur##--untracked-files=}" 1123 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
1116 return 1124 return
1117 ;; 1125 ;;
1118 --*) 1126 --*)
1119 __gitcomp " 1127 __gitcomp "
1120 --all --author= --signoff --verify --no-verify 1128 --all --author= --signoff --verify --no-verify
1121 --edit --no-edit 1129 --edit --no-edit
1122 --amend --include --only --interactive 1130 --amend --include --only --interactive
1123 --dry-run --reuse-message= --reedit-message= 1131 --dry-run --reuse-message= --reedit-message=
1124 --reset-author --file= --message= --template= 1132 --reset-author --file= --message= --template=
1125 --cleanup= --untracked-files --untracked-files= 1133 --cleanup= --untracked-files --untracked-files=
1126 --verbose --quiet --fixup= --squash= 1134 --verbose --quiet --fixup= --squash=
1127 " 1135 "
1128 return 1136 return
1129 esac 1137 esac
1130 1138
1131 if git rev-parse --verify --quiet HEAD >/dev/null; then 1139 if git rev-parse --verify --quiet HEAD >/dev/null; then
1132 __git_complete_index_file "--committable" 1140 __git_complete_index_file "--committable"
1133 else 1141 else
1134 # This is the first commit 1142 # This is the first commit
1135 __git_complete_index_file "--cached" 1143 __git_complete_index_file "--cached"
1136 fi 1144 fi
1137 } 1145 }
1138 1146
1139 _git_describe () 1147 _git_describe ()
1140 { 1148 {
1141 case "$cur" in 1149 case "$cur" in
1142 --*) 1150 --*)
1143 __gitcomp " 1151 __gitcomp "
1144 --all --tags --contains --abbrev= --candidates= 1152 --all --tags --contains --abbrev= --candidates=
1145 --exact-match --debug --long --match --always 1153 --exact-match --debug --long --match --always
1146 " 1154 "
1147 return 1155 return
1148 esac 1156 esac
1149 __gitcomp_nl "$(__git_refs)" 1157 __gitcomp_nl "$(__git_refs)"
1150 } 1158 }
1151 1159
1152 __git_diff_algorithms="myers minimal patience histogram" 1160 __git_diff_algorithms="myers minimal patience histogram"
1153 1161
1154 __git_diff_common_options="--stat --numstat --shortstat --summary 1162 __git_diff_common_options="--stat --numstat --shortstat --summary
1155 --patch-with-stat --name-only --name-status --color 1163 --patch-with-stat --name-only --name-status --color
1156 --no-color --color-words --no-renames --check 1164 --no-color --color-words --no-renames --check
1157 --full-index --binary --abbrev --diff-filter= 1165 --full-index --binary --abbrev --diff-filter=
1158 --find-copies-harder 1166 --find-copies-harder
1159 --text --ignore-space-at-eol --ignore-space-change 1167 --text --ignore-space-at-eol --ignore-space-change
1160 --ignore-all-space --exit-code --quiet --ext-diff 1168 --ignore-all-space --exit-code --quiet --ext-diff
1161 --no-ext-diff 1169 --no-ext-diff
1162 --no-prefix --src-prefix= --dst-prefix= 1170 --no-prefix --src-prefix= --dst-prefix=
1163 --inter-hunk-context= 1171 --inter-hunk-context=
1164 --patience --histogram --minimal 1172 --patience --histogram --minimal
1165 --raw --word-diff 1173 --raw --word-diff
1166 --dirstat --dirstat= --dirstat-by-file 1174 --dirstat --dirstat= --dirstat-by-file
1167 --dirstat-by-file= --cumulative 1175 --dirstat-by-file= --cumulative
1168 --diff-algorithm= 1176 --diff-algorithm=
1169 " 1177 "
1170 1178
1171 _git_diff () 1179 _git_diff ()
1172 { 1180 {
1173 __git_has_doubledash && return 1181 __git_has_doubledash && return
1174 1182
1175 case "$cur" in 1183 case "$cur" in
1176 --diff-algorithm=*) 1184 --diff-algorithm=*)
1177 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" 1185 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1178 return 1186 return
1179 ;; 1187 ;;
1180 --*) 1188 --*)
1181 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex 1189 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1182 --base --ours --theirs --no-index 1190 --base --ours --theirs --no-index
1183 $__git_diff_common_options 1191 $__git_diff_common_options
1184 " 1192 "
1185 return 1193 return
1186 ;; 1194 ;;
1187 esac 1195 esac
1188 __git_complete_revlist_file 1196 __git_complete_revlist_file
1189 } 1197 }
1190 1198
1191 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff 1199 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1192 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare 1200 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
1193 " 1201 "
1194 1202
1195 _git_difftool () 1203 _git_difftool ()
1196 { 1204 {
1197 __git_has_doubledash && return 1205 __git_has_doubledash && return
1198 1206
1199 case "$cur" in 1207 case "$cur" in
1200 --tool=*) 1208 --tool=*)
1201 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" 1209 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1202 return 1210 return
1203 ;; 1211 ;;
1204 --*) 1212 --*)
1205 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex 1213 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1206 --base --ours --theirs 1214 --base --ours --theirs
1207 --no-renames --diff-filter= --find-copies-harder 1215 --no-renames --diff-filter= --find-copies-harder
1208 --relative --ignore-submodules 1216 --relative --ignore-submodules
1209 --tool=" 1217 --tool="
1210 return 1218 return
1211 ;; 1219 ;;
1212 esac 1220 esac
1213 __git_complete_revlist_file 1221 __git_complete_revlist_file
1214 } 1222 }
1215 1223
1216 __git_fetch_options=" 1224 __git_fetch_options="
1217 --quiet --verbose --append --upload-pack --force --keep --depth= 1225 --quiet --verbose --append --upload-pack --force --keep --depth=
1218 --tags --no-tags --all --prune --dry-run 1226 --tags --no-tags --all --prune --dry-run
1219 " 1227 "
1220 1228
1221 _git_fetch () 1229 _git_fetch ()
1222 { 1230 {
1223 case "$cur" in 1231 case "$cur" in
1224 --*) 1232 --*)
1225 __gitcomp "$__git_fetch_options" 1233 __gitcomp "$__git_fetch_options"
1226 return 1234 return
1227 ;; 1235 ;;
1228 esac 1236 esac
1229 __git_complete_remote_or_refspec 1237 __git_complete_remote_or_refspec
1230 } 1238 }
1231 1239
1232 __git_format_patch_options=" 1240 __git_format_patch_options="
1233 --stdout --attach --no-attach --thread --thread= --no-thread 1241 --stdout --attach --no-attach --thread --thread= --no-thread
1234 --numbered --start-number --numbered-files --keep-subject --signoff 1242 --numbered --start-number --numbered-files --keep-subject --signoff
1235 --signature --no-signature --in-reply-to= --cc= --full-index --binary 1243 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1236 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= 1244 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1237 --inline --suffix= --ignore-if-in-upstream --subject-prefix= 1245 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1238 --output-directory --reroll-count --to= --quiet --notes 1246 --output-directory --reroll-count --to= --quiet --notes
1239 " 1247 "
1240 1248
1241 _git_format_patch () 1249 _git_format_patch ()
1242 { 1250 {
1243 case "$cur" in 1251 case "$cur" in
1244 --thread=*) 1252 --thread=*)
1245 __gitcomp " 1253 __gitcomp "
1246 deep shallow 1254 deep shallow
1247 " "" "${cur##--thread=}" 1255 " "" "${cur##--thread=}"
1248 return 1256 return
1249 ;; 1257 ;;
1250 --*) 1258 --*)
1251 __gitcomp "$__git_format_patch_options" 1259 __gitcomp "$__git_format_patch_options"
1252 return 1260 return
1253 ;; 1261 ;;
1254 esac 1262 esac
1255 __git_complete_revlist 1263 __git_complete_revlist
1256 } 1264 }
1257 1265
1258 _git_fsck () 1266 _git_fsck ()
1259 { 1267 {
1260 case "$cur" in 1268 case "$cur" in
1261 --*) 1269 --*)
1262 __gitcomp " 1270 __gitcomp "
1263 --tags --root --unreachable --cache --no-reflogs --full 1271 --tags --root --unreachable --cache --no-reflogs --full
1264 --strict --verbose --lost-found 1272 --strict --verbose --lost-found
1265 " 1273 "
1266 return 1274 return
1267 ;; 1275 ;;
1268 esac 1276 esac
1269 } 1277 }
1270 1278
1271 _git_gc () 1279 _git_gc ()
1272 { 1280 {
1273 case "$cur" in 1281 case "$cur" in
1274 --*) 1282 --*)
1275 __gitcomp "--prune --aggressive" 1283 __gitcomp "--prune --aggressive"
1276 return 1284 return
1277 ;; 1285 ;;
1278 esac 1286 esac
1279 } 1287 }
1280 1288
1281 _git_gitk () 1289 _git_gitk ()
1282 { 1290 {
1283 _gitk 1291 _gitk
1284 } 1292 }
1285 1293
1286 __git_match_ctag() { 1294 __git_match_ctag() {
1287 awk "/^${1////\\/}/ { print \$1 }" "$2" 1295 awk "/^${1////\\/}/ { print \$1 }" "$2"
1288 } 1296 }
1289 1297
1290 _git_grep () 1298 _git_grep ()
1291 { 1299 {
1292 __git_has_doubledash && return 1300 __git_has_doubledash && return
1293 1301
1294 case "$cur" in 1302 case "$cur" in
1295 --*) 1303 --*)
1296 __gitcomp " 1304 __gitcomp "
1297 --cached 1305 --cached
1298 --text --ignore-case --word-regexp --invert-match 1306 --text --ignore-case --word-regexp --invert-match
1299 --full-name --line-number 1307 --full-name --line-number
1300 --extended-regexp --basic-regexp --fixed-strings 1308 --extended-regexp --basic-regexp --fixed-strings
1301 --perl-regexp 1309 --perl-regexp
1302 --files-with-matches --name-only 1310 --files-with-matches --name-only
1303 --files-without-match 1311 --files-without-match
1304 --max-depth 1312 --max-depth
1305 --count 1313 --count
1306 --and --or --not --all-match 1314 --and --or --not --all-match
1307 " 1315 "
1308 return 1316 return
1309 ;; 1317 ;;
1310 esac 1318 esac
1311 1319
1312 case "$cword,$prev" in 1320 case "$cword,$prev" in
1313 2,*|*,-*) 1321 2,*|*,-*)
1314 if test -r tags; then 1322 if test -r tags; then
1315 __gitcomp_nl "$(__git_match_ctag "$cur" tags)" 1323 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1316 return 1324 return
1317 fi 1325 fi
1318 ;; 1326 ;;
1319 esac 1327 esac
1320 1328
1321 __gitcomp_nl "$(__git_refs)" 1329 __gitcomp_nl "$(__git_refs)"
1322 } 1330 }
1323 1331
1324 _git_help () 1332 _git_help ()
1325 { 1333 {
1326 case "$cur" in 1334 case "$cur" in
1327 --*) 1335 --*)
1328 __gitcomp "--all --info --man --web" 1336 __gitcomp "--all --info --man --web"
1329 return 1337 return
1330 ;; 1338 ;;
1331 esac 1339 esac
1332 __git_compute_all_commands 1340 __git_compute_all_commands
1333 __gitcomp "$__git_all_commands $(__git_aliases) 1341 __gitcomp "$__git_all_commands $(__git_aliases)
1334 attributes cli core-tutorial cvs-migration 1342 attributes cli core-tutorial cvs-migration
1335 diffcore gitk glossary hooks ignore modules 1343 diffcore gitk glossary hooks ignore modules
1336 namespaces repository-layout tutorial tutorial-2 1344 namespaces repository-layout tutorial tutorial-2
1337 workflows 1345 workflows
1338 " 1346 "
1339 } 1347 }
1340 1348
1341 _git_init () 1349 _git_init ()
1342 { 1350 {
1343 case "$cur" in 1351 case "$cur" in
1344 --shared=*) 1352 --shared=*)
1345 __gitcomp " 1353 __gitcomp "
1346 false true umask group all world everybody 1354 false true umask group all world everybody
1347 " "" "${cur##--shared=}" 1355 " "" "${cur##--shared=}"
1348 return 1356 return
1349 ;; 1357 ;;
1350 --*) 1358 --*)
1351 __gitcomp "--quiet --bare --template= --shared --shared=" 1359 __gitcomp "--quiet --bare --template= --shared --shared="
1352 return 1360 return
1353 ;; 1361 ;;
1354 esac 1362 esac
1355 } 1363 }
1356 1364
1357 _git_ls_files () 1365 _git_ls_files ()
1358 { 1366 {
1359 case "$cur" in 1367 case "$cur" in
1360 --*) 1368 --*)
1361 __gitcomp "--cached --deleted --modified --others --ignored 1369 __gitcomp "--cached --deleted --modified --others --ignored
1362 --stage --directory --no-empty-directory --unmerged 1370 --stage --directory --no-empty-directory --unmerged
1363 --killed --exclude= --exclude-from= 1371 --killed --exclude= --exclude-from=
1364 --exclude-per-directory= --exclude-standard 1372 --exclude-per-directory= --exclude-standard
1365 --error-unmatch --with-tree= --full-name 1373 --error-unmatch --with-tree= --full-name
1366 --abbrev --ignored --exclude-per-directory 1374 --abbrev --ignored --exclude-per-directory
1367 " 1375 "
1368 return 1376 return
1369 ;; 1377 ;;
1370 esac 1378 esac
1371 1379
1372 # XXX ignore options like --modified and always suggest all cached 1380 # XXX ignore options like --modified and always suggest all cached
1373 # files. 1381 # files.
1374 __git_complete_index_file "--cached" 1382 __git_complete_index_file "--cached"
1375 } 1383 }
1376 1384
1377 _git_ls_remote () 1385 _git_ls_remote ()
1378 { 1386 {
1379 __gitcomp_nl "$(__git_remotes)" 1387 __gitcomp_nl "$(__git_remotes)"
1380 } 1388 }
1381 1389
1382 _git_ls_tree () 1390 _git_ls_tree ()
1383 { 1391 {
1384 __git_complete_file 1392 __git_complete_file
1385 } 1393 }
1386 1394
1387 # Options that go well for log, shortlog and gitk 1395 # Options that go well for log, shortlog and gitk
1388 __git_log_common_options=" 1396 __git_log_common_options="
1389 --not --all 1397 --not --all
1390 --branches --tags --remotes 1398 --branches --tags --remotes
1391 --first-parent --merges --no-merges 1399 --first-parent --merges --no-merges
1392 --max-count= 1400 --max-count=
1393 --max-age= --since= --after= 1401 --max-age= --since= --after=
1394 --min-age= --until= --before= 1402 --min-age= --until= --before=
1395 --min-parents= --max-parents= 1403 --min-parents= --max-parents=
1396 --no-min-parents --no-max-parents 1404 --no-min-parents --no-max-parents
1397 " 1405 "
1398 # Options that go well for log and gitk (not shortlog) 1406 # Options that go well for log and gitk (not shortlog)
1399 __git_log_gitk_options=" 1407 __git_log_gitk_options="
1400 --dense --sparse --full-history 1408 --dense --sparse --full-history
1401 --simplify-merges --simplify-by-decoration 1409 --simplify-merges --simplify-by-decoration
1402 --left-right --notes --no-notes 1410 --left-right --notes --no-notes
1403 " 1411 "
1404 # Options that go well for log and shortlog (not gitk) 1412 # Options that go well for log and shortlog (not gitk)
1405 __git_log_shortlog_options=" 1413 __git_log_shortlog_options="
1406 --author= --committer= --grep= 1414 --author= --committer= --grep=
1407 --all-match 1415 --all-match
1408 " 1416 "
1409 1417
1410 __git_log_pretty_formats="oneline short medium full fuller email raw format:" 1418 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1411 __git_log_date_formats="relative iso8601 rfc2822 short local default raw" 1419 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1412 1420
1413 _git_log () 1421 _git_log ()
1414 { 1422 {
1415 __git_has_doubledash && return 1423 __git_has_doubledash && return
1416 1424
1417 local g="$(git rev-parse --git-dir 2>/dev/null)" 1425 local g="$(git rev-parse --git-dir 2>/dev/null)"
1418 local merge="" 1426 local merge=""
1419 if [ -f "$g/MERGE_HEAD" ]; then 1427 if [ -f "$g/MERGE_HEAD" ]; then
1420 merge="--merge" 1428 merge="--merge"
1421 fi 1429 fi
1422 case "$cur" in 1430 case "$cur" in
1423 --pretty=*|--format=*) 1431 --pretty=*|--format=*)
1424 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) 1432 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1425 " "" "${cur#*=}" 1433 " "" "${cur#*=}"
1426 return 1434 return
1427 ;; 1435 ;;
1428 --date=*) 1436 --date=*)
1429 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" 1437 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1430 return 1438 return
1431 ;; 1439 ;;
1432 --decorate=*) 1440 --decorate=*)
1433 __gitcomp "long short" "" "${cur##--decorate=}" 1441 __gitcomp "long short" "" "${cur##--decorate=}"
1434 return 1442 return
1435 ;; 1443 ;;
1436 --*) 1444 --*)
1437 __gitcomp " 1445 __gitcomp "
1438 $__git_log_common_options 1446 $__git_log_common_options
1439 $__git_log_shortlog_options 1447 $__git_log_shortlog_options
1440 $__git_log_gitk_options 1448 $__git_log_gitk_options
1441 --root --topo-order --date-order --reverse 1449 --root --topo-order --date-order --reverse
1442 --follow --full-diff 1450 --follow --full-diff
1443 --abbrev-commit --abbrev= 1451 --abbrev-commit --abbrev=
1444 --relative-date --date= 1452 --relative-date --date=
1445 --pretty= --format= --oneline 1453 --pretty= --format= --oneline
1446 --cherry-pick 1454 --cherry-pick
1447 --graph 1455 --graph
1448 --decorate --decorate= 1456 --decorate --decorate=
1449 --walk-reflogs 1457 --walk-reflogs
1450 --parents --children 1458 --parents --children
1451 $merge 1459 $merge
1452 $__git_diff_common_options 1460 $__git_diff_common_options
1453 --pickaxe-all --pickaxe-regex 1461 --pickaxe-all --pickaxe-regex
1454 " 1462 "
1455 return 1463 return
1456 ;; 1464 ;;
1457 esac 1465 esac
1458 __git_complete_revlist 1466 __git_complete_revlist
1459 } 1467 }
1460 1468
1461 __git_merge_options=" 1469 __git_merge_options="
1462 --no-commit --no-stat --log --no-log --squash --strategy 1470 --no-commit --no-stat --log --no-log --squash --strategy
1463 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit 1471 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1464 " 1472 "
1465 1473
1466 _git_merge () 1474 _git_merge ()
1467 { 1475 {
1468 __git_complete_strategy && return 1476 __git_complete_strategy && return
1469 1477
1470 case "$cur" in 1478 case "$cur" in
1471 --*) 1479 --*)
1472 __gitcomp "$__git_merge_options" 1480 __gitcomp "$__git_merge_options"
1473 return 1481 return
1474 esac 1482 esac
1475 __gitcomp_nl "$(__git_refs)" 1483 __gitcomp_nl "$(__git_refs)"
1476 } 1484 }
1477 1485
1478 _git_mergetool () 1486 _git_mergetool ()
1479 { 1487 {
1480 case "$cur" in 1488 case "$cur" in
1481 --tool=*) 1489 --tool=*)
1482 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" 1490 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1483 return 1491 return
1484 ;; 1492 ;;
1485 --*) 1493 --*)
1486 __gitcomp "--tool=" 1494 __gitcomp "--tool="
1487 return 1495 return
1488 ;; 1496 ;;
1489 esac 1497 esac
1490 } 1498 }
1491 1499
1492 _git_merge_base () 1500 _git_merge_base ()
1493 { 1501 {
1502 case "$cur" in
1503 --*)
1504 __gitcomp "--octopus --independent --is-ancestor --fork-point"
1505 return
1506 ;;
1507 esac
1494 __gitcomp_nl "$(__git_refs)" 1508 __gitcomp_nl "$(__git_refs)"
1495 } 1509 }
1496 1510
1497 _git_mv () 1511 _git_mv ()
1498 { 1512 {
1499 case "$cur" in 1513 case "$cur" in
1500 --*) 1514 --*)
1501 __gitcomp "--dry-run" 1515 __gitcomp "--dry-run"
1502 return 1516 return
1503 ;; 1517 ;;
1504 esac 1518 esac
1505 1519
1506 if [ $(__git_count_arguments "mv") -gt 0 ]; then 1520 if [ $(__git_count_arguments "mv") -gt 0 ]; then
1507 # We need to show both cached and untracked files (including 1521 # We need to show both cached and untracked files (including
1508 # empty directories) since this may not be the last argument. 1522 # empty directories) since this may not be the last argument.
1509 __git_complete_index_file "--cached --others --directory" 1523 __git_complete_index_file "--cached --others --directory"
1510 else 1524 else
1511 __git_complete_index_file "--cached" 1525 __git_complete_index_file "--cached"
1512 fi 1526 fi
1513 } 1527 }
1514 1528
1515 _git_name_rev () 1529 _git_name_rev ()
1516 { 1530 {
1517 __gitcomp "--tags --all --stdin" 1531 __gitcomp "--tags --all --stdin"
1518 } 1532 }
1519 1533
1520 _git_notes () 1534 _git_notes ()
1521 { 1535 {
1522 local subcommands='add append copy edit list prune remove show' 1536 local subcommands='add append copy edit list prune remove show'
1523 local subcommand="$(__git_find_on_cmdline "$subcommands")" 1537 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1524 1538
1525 case "$subcommand,$cur" in 1539 case "$subcommand,$cur" in
1526 ,--*) 1540 ,--*)
1527 __gitcomp '--ref' 1541 __gitcomp '--ref'
1528 ;; 1542 ;;
1529 ,*) 1543 ,*)
1530 case "$prev" in 1544 case "$prev" in
1531 --ref) 1545 --ref)
1532 __gitcomp_nl "$(__git_refs)" 1546 __gitcomp_nl "$(__git_refs)"
1533 ;; 1547 ;;
1534 *) 1548 *)
1535 __gitcomp "$subcommands --ref" 1549 __gitcomp "$subcommands --ref"
1536 ;; 1550 ;;
1537 esac 1551 esac
1538 ;; 1552 ;;
1539 add,--reuse-message=*|append,--reuse-message=*|\ 1553 add,--reuse-message=*|append,--reuse-message=*|\
1540 add,--reedit-message=*|append,--reedit-message=*) 1554 add,--reedit-message=*|append,--reedit-message=*)
1541 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" 1555 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1542 ;; 1556 ;;
1543 add,--*|append,--*) 1557 add,--*|append,--*)
1544 __gitcomp '--file= --message= --reedit-message= 1558 __gitcomp '--file= --message= --reedit-message=
1545 --reuse-message=' 1559 --reuse-message='
1546 ;; 1560 ;;
1547 copy,--*) 1561 copy,--*)
1548 __gitcomp '--stdin' 1562 __gitcomp '--stdin'
1549 ;; 1563 ;;
1550 prune,--*) 1564 prune,--*)
1551 __gitcomp '--dry-run --verbose' 1565 __gitcomp '--dry-run --verbose'
1552 ;; 1566 ;;
1553 prune,*) 1567 prune,*)
1554 ;; 1568 ;;
1555 *) 1569 *)
1556 case "$prev" in 1570 case "$prev" in
1557 -m|-F) 1571 -m|-F)
1558 ;; 1572 ;;
1559 *) 1573 *)
1560 __gitcomp_nl "$(__git_refs)" 1574 __gitcomp_nl "$(__git_refs)"
1561 ;; 1575 ;;
1562 esac 1576 esac
1563 ;; 1577 ;;
1564 esac 1578 esac
1565 } 1579 }
1566 1580
1567 _git_pull () 1581 _git_pull ()
1568 { 1582 {
1569 __git_complete_strategy && return 1583 __git_complete_strategy && return
1570 1584
1571 case "$cur" in 1585 case "$cur" in
1572 --*) 1586 --*)
1573 __gitcomp " 1587 __gitcomp "
1574 --rebase --no-rebase 1588 --rebase --no-rebase
1575 $__git_merge_options 1589 $__git_merge_options
1576 $__git_fetch_options 1590 $__git_fetch_options
1577 " 1591 "
1578 return 1592 return
1579 ;; 1593 ;;
1580 esac 1594 esac
1581 __git_complete_remote_or_refspec 1595 __git_complete_remote_or_refspec
1582 } 1596 }
1583 1597
1584 _git_push () 1598 _git_push ()
1585 { 1599 {
1586 case "$prev" in 1600 case "$prev" in
1587 --repo) 1601 --repo)
1588 __gitcomp_nl "$(__git_remotes)" 1602 __gitcomp_nl "$(__git_remotes)"
1589 return 1603 return
1590 esac 1604 esac
1591 case "$cur" in 1605 case "$cur" in
1592 --repo=*) 1606 --repo=*)
1593 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" 1607 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1594 return 1608 return
1595 ;; 1609 ;;
1596 --*) 1610 --*)
1597 __gitcomp " 1611 __gitcomp "
1598 --all --mirror --tags --dry-run --force --verbose 1612 --all --mirror --tags --dry-run --force --verbose
1599 --receive-pack= --repo= --set-upstream 1613 --receive-pack= --repo= --set-upstream
1600 " 1614 "
1601 return 1615 return
1602 ;; 1616 ;;
1603 esac 1617 esac
1604 __git_complete_remote_or_refspec 1618 __git_complete_remote_or_refspec
1605 } 1619 }
1606 1620
1607 _git_rebase () 1621 _git_rebase ()
1608 { 1622 {
1609 local dir="$(__gitdir)" 1623 local dir="$(__gitdir)"
1610 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then 1624 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1611 __gitcomp "--continue --skip --abort" 1625 __gitcomp "--continue --skip --abort"
1612 return 1626 return
1613 fi 1627 fi
1614 __git_complete_strategy && return 1628 __git_complete_strategy && return
1615 case "$cur" in 1629 case "$cur" in
1616 --whitespace=*) 1630 --whitespace=*)
1617 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 1631 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1618 return 1632 return
1619 ;; 1633 ;;
1620 --*) 1634 --*)
1621 __gitcomp " 1635 __gitcomp "
1622 --onto --merge --strategy --interactive 1636 --onto --merge --strategy --interactive
1623 --preserve-merges --stat --no-stat 1637 --preserve-merges --stat --no-stat
1624 --committer-date-is-author-date --ignore-date 1638 --committer-date-is-author-date --ignore-date
1625 --ignore-whitespace --whitespace= 1639 --ignore-whitespace --whitespace=
1626 --autosquash 1640 --autosquash --fork-point --no-fork-point
1627 " 1641 "
1628 1642
1629 return 1643 return
1630 esac 1644 esac
1631 __gitcomp_nl "$(__git_refs)" 1645 __gitcomp_nl "$(__git_refs)"
1632 } 1646 }
1633 1647
1634 _git_reflog () 1648 _git_reflog ()
1635 { 1649 {
1636 local subcommands="show delete expire" 1650 local subcommands="show delete expire"
1637 local subcommand="$(__git_find_on_cmdline "$subcommands")" 1651 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1638 1652
1639 if [ -z "$subcommand" ]; then 1653 if [ -z "$subcommand" ]; then
1640 __gitcomp "$subcommands" 1654 __gitcomp "$subcommands"
1641 else 1655 else
1642 __gitcomp_nl "$(__git_refs)" 1656 __gitcomp_nl "$(__git_refs)"
1643 fi 1657 fi
1644 } 1658 }
1645 1659
1646 __git_send_email_confirm_options="always never auto cc compose" 1660 __git_send_email_confirm_options="always never auto cc compose"
1647 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" 1661 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1648 1662
1649 _git_send_email () 1663 _git_send_email ()
1650 { 1664 {
1651 case "$cur" in 1665 case "$cur" in
1652 --confirm=*) 1666 --confirm=*)
1653 __gitcomp " 1667 __gitcomp "
1654 $__git_send_email_confirm_options 1668 $__git_send_email_confirm_options
1655 " "" "${cur##--confirm=}" 1669 " "" "${cur##--confirm=}"
1656 return 1670 return
1657 ;; 1671 ;;
1658 --suppress-cc=*) 1672 --suppress-cc=*)
1659 __gitcomp " 1673 __gitcomp "
1660 $__git_send_email_suppresscc_options 1674 $__git_send_email_suppresscc_options
1661 " "" "${cur##--suppress-cc=}" 1675 " "" "${cur##--suppress-cc=}"
1662 1676
1663 return 1677 return
1664 ;; 1678 ;;
1665 --smtp-encryption=*) 1679 --smtp-encryption=*)
1666 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" 1680 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1667 return 1681 return
1668 ;; 1682 ;;
1669 --thread=*) 1683 --thread=*)
1670 __gitcomp " 1684 __gitcomp "
1671 deep shallow 1685 deep shallow
1672 " "" "${cur##--thread=}" 1686 " "" "${cur##--thread=}"
1673 return 1687 return
1674 ;; 1688 ;;
1675 --*) 1689 --*)
1676 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to 1690 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1677 --compose --confirm= --dry-run --envelope-sender 1691 --compose --confirm= --dry-run --envelope-sender
1678 --from --identity 1692 --from --identity
1679 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc 1693 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1680 --no-suppress-from --no-thread --quiet 1694 --no-suppress-from --no-thread --quiet
1681 --signed-off-by-cc --smtp-pass --smtp-server 1695 --signed-off-by-cc --smtp-pass --smtp-server
1682 --smtp-server-port --smtp-encryption= --smtp-user 1696 --smtp-server-port --smtp-encryption= --smtp-user
1683 --subject --suppress-cc= --suppress-from --thread --to 1697 --subject --suppress-cc= --suppress-from --thread --to
1684 --validate --no-validate 1698 --validate --no-validate
1685 $__git_format_patch_options" 1699 $__git_format_patch_options"
1686 return 1700 return
1687 ;; 1701 ;;
1688 esac 1702 esac
1689 __git_complete_revlist 1703 __git_complete_revlist
1690 } 1704 }
1691 1705
1692 _git_stage () 1706 _git_stage ()
1693 { 1707 {
1694 _git_add 1708 _git_add
1695 } 1709 }
1696 1710
1697 __git_config_get_set_variables () 1711 __git_config_get_set_variables ()
1698 { 1712 {
1699 local prevword word config_file= c=$cword 1713 local prevword word config_file= c=$cword
1700 while [ $c -gt 1 ]; do 1714 while [ $c -gt 1 ]; do
1701 word="${words[c]}" 1715 word="${words[c]}"
1702 case "$word" in 1716 case "$word" in
1703 --system|--global|--local|--file=*) 1717 --system|--global|--local|--file=*)
1704 config_file="$word" 1718 config_file="$word"
1705 break 1719 break
1706 ;; 1720 ;;
1707 -f|--file) 1721 -f|--file)
1708 config_file="$word $prevword" 1722 config_file="$word $prevword"
1709 break 1723 break
1710 ;; 1724 ;;
1711 esac 1725 esac
1712 prevword=$word 1726 prevword=$word
1713 c=$((--c)) 1727 c=$((--c))
1714 done 1728 done
1715 1729
1716 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | 1730 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1717 while read -r line 1731 while read -r line
1718 do 1732 do
1719 case "$line" in 1733 case "$line" in
1720 *.*=*) 1734 *.*=*)
1721 echo "${line/=*/}" 1735 echo "${line/=*/}"
1722 ;; 1736 ;;
1723 esac 1737 esac
1724 done 1738 done
1725 } 1739 }
1726 1740
1727 _git_config () 1741 _git_config ()
1728 { 1742 {
1729 case "$prev" in 1743 case "$prev" in
1730 branch.*.remote|branch.*.pushremote) 1744 branch.*.remote|branch.*.pushremote)
1731 __gitcomp_nl "$(__git_remotes)" 1745 __gitcomp_nl "$(__git_remotes)"
1732 return 1746 return
1733 ;; 1747 ;;
1734 branch.*.merge) 1748 branch.*.merge)
1735 __gitcomp_nl "$(__git_refs)" 1749 __gitcomp_nl "$(__git_refs)"
1736 return 1750 return
1737 ;; 1751 ;;
1738 branch.*.rebase) 1752 branch.*.rebase)
1739 __gitcomp "false true" 1753 __gitcomp "false true"
1740 return 1754 return
1741 ;; 1755 ;;
1742 remote.pushdefault) 1756 remote.pushdefault)
1743 __gitcomp_nl "$(__git_remotes)" 1757 __gitcomp_nl "$(__git_remotes)"
1744 return 1758 return
1745 ;; 1759 ;;
1746 remote.*.fetch) 1760 remote.*.fetch)
1747 local remote="${prev#remote.}" 1761 local remote="${prev#remote.}"
1748 remote="${remote%.fetch}" 1762 remote="${remote%.fetch}"
1749 if [ -z "$cur" ]; then 1763 if [ -z "$cur" ]; then
1750 __gitcomp_nl "refs/heads/" "" "" "" 1764 __gitcomp_nl "refs/heads/" "" "" ""
1751 return 1765 return
1752 fi 1766 fi
1753 __gitcomp_nl "$(__git_refs_remotes "$remote")" 1767 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1754 return 1768 return
1755 ;; 1769 ;;
1756 remote.*.push) 1770 remote.*.push)
1757 local remote="${prev#remote.}" 1771 local remote="${prev#remote.}"
1758 remote="${remote%.push}" 1772 remote="${remote%.push}"
1759 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \ 1773 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1760 for-each-ref --format='%(refname):%(refname)' \ 1774 for-each-ref --format='%(refname):%(refname)' \
1761 refs/heads)" 1775 refs/heads)"
1762 return 1776 return
1763 ;; 1777 ;;
1764 pull.twohead|pull.octopus) 1778 pull.twohead|pull.octopus)
1765 __git_compute_merge_strategies 1779 __git_compute_merge_strategies
1766 __gitcomp "$__git_merge_strategies" 1780 __gitcomp "$__git_merge_strategies"
1767 return 1781 return
1768 ;; 1782 ;;
1769 color.branch|color.diff|color.interactive|\ 1783 color.branch|color.diff|color.interactive|\
1770 color.showbranch|color.status|color.ui) 1784 color.showbranch|color.status|color.ui)
1771 __gitcomp "always never auto" 1785 __gitcomp "always never auto"
1772 return 1786 return
1773 ;; 1787 ;;
1774 color.pager) 1788 color.pager)
1775 __gitcomp "false true" 1789 __gitcomp "false true"
1776 return 1790 return
1777 ;; 1791 ;;
1778 color.*.*) 1792 color.*.*)
1779 __gitcomp " 1793 __gitcomp "
1780 normal black red green yellow blue magenta cyan white 1794 normal black red green yellow blue magenta cyan white
1781 bold dim ul blink reverse 1795 bold dim ul blink reverse
1782 " 1796 "
1783 return 1797 return
1784 ;; 1798 ;;
1785 diff.submodule) 1799 diff.submodule)
1786 __gitcomp "log short" 1800 __gitcomp "log short"
1787 return 1801 return
1788 ;; 1802 ;;
1789 help.format) 1803 help.format)
1790 __gitcomp "man info web html" 1804 __gitcomp "man info web html"
1791 return 1805 return
1792 ;; 1806 ;;
1793 log.date) 1807 log.date)
1794 __gitcomp "$__git_log_date_formats" 1808 __gitcomp "$__git_log_date_formats"
1795 return 1809 return
1796 ;; 1810 ;;
1797 sendemail.aliasesfiletype) 1811 sendemail.aliasesfiletype)
1798 __gitcomp "mutt mailrc pine elm gnus" 1812 __gitcomp "mutt mailrc pine elm gnus"
1799 return 1813 return
1800 ;; 1814 ;;
1801 sendemail.confirm) 1815 sendemail.confirm)
1802 __gitcomp "$__git_send_email_confirm_options" 1816 __gitcomp "$__git_send_email_confirm_options"
1803 return 1817 return
1804 ;; 1818 ;;
1805 sendemail.suppresscc) 1819 sendemail.suppresscc)
1806 __gitcomp "$__git_send_email_suppresscc_options" 1820 __gitcomp "$__git_send_email_suppresscc_options"
1807 return 1821 return
1808 ;; 1822 ;;
1809 --get|--get-all|--unset|--unset-all) 1823 --get|--get-all|--unset|--unset-all)
1810 __gitcomp_nl "$(__git_config_get_set_variables)" 1824 __gitcomp_nl "$(__git_config_get_set_variables)"
1811 return 1825 return
1812 ;; 1826 ;;
1813 *.*) 1827 *.*)
1814 return 1828 return
1815 ;; 1829 ;;
1816 esac 1830 esac
1817 case "$cur" in 1831 case "$cur" in
1818 --*) 1832 --*)
1819 __gitcomp " 1833 __gitcomp "
1820 --system --global --local --file= 1834 --system --global --local --file=
1821 --list --replace-all 1835 --list --replace-all
1822 --get --get-all --get-regexp 1836 --get --get-all --get-regexp
1823 --add --unset --unset-all 1837 --add --unset --unset-all
1824 --remove-section --rename-section 1838 --remove-section --rename-section
1825 " 1839 "
1826 return 1840 return
1827 ;; 1841 ;;
1828 branch.*.*) 1842 branch.*.*)
1829 local pfx="${cur%.*}." cur_="${cur##*.}" 1843 local pfx="${cur%.*}." cur_="${cur##*.}"
1830 __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" 1844 __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
1831 return 1845 return
1832 ;; 1846 ;;
1833 branch.*) 1847 branch.*)
1834 local pfx="${cur%.*}." cur_="${cur#*.}" 1848 local pfx="${cur%.*}." cur_="${cur#*.}"
1835 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." 1849 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1850 __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
1836 return 1851 return
1837 ;; 1852 ;;
1838 guitool.*.*) 1853 guitool.*.*)
1839 local pfx="${cur%.*}." cur_="${cur##*.}" 1854 local pfx="${cur%.*}." cur_="${cur##*.}"
1840 __gitcomp " 1855 __gitcomp "
1841 argprompt cmd confirm needsfile noconsole norescan 1856 argprompt cmd confirm needsfile noconsole norescan
1842 prompt revprompt revunmerged title 1857 prompt revprompt revunmerged title
1843 " "$pfx" "$cur_" 1858 " "$pfx" "$cur_"
1844 return 1859 return
1845 ;; 1860 ;;
1846 difftool.*.*) 1861 difftool.*.*)
1847 local pfx="${cur%.*}." cur_="${cur##*.}" 1862 local pfx="${cur%.*}." cur_="${cur##*.}"
1848 __gitcomp "cmd path" "$pfx" "$cur_" 1863 __gitcomp "cmd path" "$pfx" "$cur_"
1849 return 1864 return
1850 ;; 1865 ;;
1851 man.*.*) 1866 man.*.*)
1852 local pfx="${cur%.*}." cur_="${cur##*.}" 1867 local pfx="${cur%.*}." cur_="${cur##*.}"
1853 __gitcomp "cmd path" "$pfx" "$cur_" 1868 __gitcomp "cmd path" "$pfx" "$cur_"
1854 return 1869 return
1855 ;; 1870 ;;
1856 mergetool.*.*) 1871 mergetool.*.*)
1857 local pfx="${cur%.*}." cur_="${cur##*.}" 1872 local pfx="${cur%.*}." cur_="${cur##*.}"
1858 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" 1873 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1859 return 1874 return
1860 ;; 1875 ;;
1861 pager.*) 1876 pager.*)
1862 local pfx="${cur%.*}." cur_="${cur#*.}" 1877 local pfx="${cur%.*}." cur_="${cur#*.}"
1863 __git_compute_all_commands 1878 __git_compute_all_commands
1864 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" 1879 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1865 return 1880 return
1866 ;; 1881 ;;
1867 remote.*.*) 1882 remote.*.*)
1868 local pfx="${cur%.*}." cur_="${cur##*.}" 1883 local pfx="${cur%.*}." cur_="${cur##*.}"
1869 __gitcomp " 1884 __gitcomp "
1870 url proxy fetch push mirror skipDefaultUpdate 1885 url proxy fetch push mirror skipDefaultUpdate
1871 receivepack uploadpack tagopt pushurl 1886 receivepack uploadpack tagopt pushurl
1872 " "$pfx" "$cur_" 1887 " "$pfx" "$cur_"
1873 return 1888 return
1874 ;; 1889 ;;
1875 remote.*) 1890 remote.*)
1876 local pfx="${cur%.*}." cur_="${cur#*.}" 1891 local pfx="${cur%.*}." cur_="${cur#*.}"
1877 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." 1892 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1893 __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
1878 return 1894 return
1879 ;; 1895 ;;
1880 url.*.*) 1896 url.*.*)
1881 local pfx="${cur%.*}." cur_="${cur##*.}" 1897 local pfx="${cur%.*}." cur_="${cur##*.}"
1882 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" 1898 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1883 return 1899 return
1884 ;; 1900 ;;
1885 esac 1901 esac
1886 __gitcomp " 1902 __gitcomp "
1887 add.ignoreErrors 1903 add.ignoreErrors
1888 advice.commitBeforeMerge 1904 advice.commitBeforeMerge
1889 advice.detachedHead 1905 advice.detachedHead
1890 advice.implicitIdentity 1906 advice.implicitIdentity
1891 advice.pushNonFastForward 1907 advice.pushNonFastForward
1892 advice.resolveConflict 1908 advice.resolveConflict
1893 advice.statusHints 1909 advice.statusHints
1894 alias. 1910 alias.
1895 am.keepcr 1911 am.keepcr
1896 apply.ignorewhitespace 1912 apply.ignorewhitespace
1897 apply.whitespace 1913 apply.whitespace
1898 branch.autosetupmerge 1914 branch.autosetupmerge
1899 branch.autosetuprebase 1915 branch.autosetuprebase
1900 browser. 1916 browser.
1901 clean.requireForce 1917 clean.requireForce
1902 color.branch 1918 color.branch
1903 color.branch.current 1919 color.branch.current
1904 color.branch.local 1920 color.branch.local
1905 color.branch.plain 1921 color.branch.plain
1906 color.branch.remote 1922 color.branch.remote
1907 color.decorate.HEAD 1923 color.decorate.HEAD
1908 color.decorate.branch 1924 color.decorate.branch
1909 color.decorate.remoteBranch 1925 color.decorate.remoteBranch
1910 color.decorate.stash 1926 color.decorate.stash
1911 color.decorate.tag 1927 color.decorate.tag
1912 color.diff 1928 color.diff
1913 color.diff.commit 1929 color.diff.commit
1914 color.diff.frag 1930 color.diff.frag
1915 color.diff.func 1931 color.diff.func
1916 color.diff.meta 1932 color.diff.meta
1917 color.diff.new 1933 color.diff.new
1918 color.diff.old 1934 color.diff.old
1919 color.diff.plain 1935 color.diff.plain
1920 color.diff.whitespace 1936 color.diff.whitespace
1921 color.grep 1937 color.grep
1922 color.grep.context 1938 color.grep.context
1923 color.grep.filename 1939 color.grep.filename
1924 color.grep.function 1940 color.grep.function
1925 color.grep.linenumber 1941 color.grep.linenumber
1926 color.grep.match 1942 color.grep.match
1927 color.grep.selected 1943 color.grep.selected
1928 color.grep.separator 1944 color.grep.separator
1929 color.interactive 1945 color.interactive
1930 color.interactive.error 1946 color.interactive.error
1931 color.interactive.header 1947 color.interactive.header
1932 color.interactive.help 1948 color.interactive.help
1933 color.interactive.prompt 1949 color.interactive.prompt
1934 color.pager 1950 color.pager
1935 color.showbranch 1951 color.showbranch
1936 color.status 1952 color.status
1937 color.status.added 1953 color.status.added
1938 color.status.changed 1954 color.status.changed
1939 color.status.header 1955 color.status.header
1940 color.status.nobranch 1956 color.status.nobranch
1941 color.status.untracked 1957 color.status.untracked
1942 color.status.updated 1958 color.status.updated
1943 color.ui 1959 color.ui
1944 commit.status 1960 commit.status
1945 commit.template 1961 commit.template
1946 core.abbrev 1962 core.abbrev
1947 core.askpass 1963 core.askpass
1948 core.attributesfile 1964 core.attributesfile
1949 core.autocrlf 1965 core.autocrlf
1950 core.bare 1966 core.bare
1951 core.bigFileThreshold 1967 core.bigFileThreshold
1952 core.compression 1968 core.compression
1953 core.createObject 1969 core.createObject
1954 core.deltaBaseCacheLimit 1970 core.deltaBaseCacheLimit
1955 core.editor 1971 core.editor
1956 core.eol 1972 core.eol
1957 core.excludesfile 1973 core.excludesfile
1958 core.fileMode 1974 core.fileMode
1959 core.fsyncobjectfiles 1975 core.fsyncobjectfiles
1960 core.gitProxy 1976 core.gitProxy
1961 core.ignoreStat 1977 core.ignoreStat
1962 core.ignorecase 1978 core.ignorecase
1963 core.logAllRefUpdates 1979 core.logAllRefUpdates
1964 core.loosecompression 1980 core.loosecompression
1965 core.notesRef 1981 core.notesRef
1966 core.packedGitLimit 1982 core.packedGitLimit
1967 core.packedGitWindowSize 1983 core.packedGitWindowSize
1968 core.pager 1984 core.pager
1969 core.preferSymlinkRefs 1985 core.preferSymlinkRefs
1970 core.preloadindex 1986 core.preloadindex
1971 core.quotepath 1987 core.quotepath
1972 core.repositoryFormatVersion 1988 core.repositoryFormatVersion
1973 core.safecrlf 1989 core.safecrlf
1974 core.sharedRepository 1990 core.sharedRepository
1975 core.sparseCheckout 1991 core.sparseCheckout
1976 core.symlinks 1992 core.symlinks
1977 core.trustctime 1993 core.trustctime
1978 core.warnAmbiguousRefs 1994 core.warnAmbiguousRefs
1979 core.whitespace 1995 core.whitespace
1980 core.worktree 1996 core.worktree
1981 diff.autorefreshindex 1997 diff.autorefreshindex
1982 diff.external 1998 diff.external
1983 diff.ignoreSubmodules 1999 diff.ignoreSubmodules
1984 diff.mnemonicprefix 2000 diff.mnemonicprefix
1985 diff.noprefix 2001 diff.noprefix
1986 diff.renameLimit 2002 diff.renameLimit
1987 diff.renames 2003 diff.renames
1988 diff.statGraphWidth 2004 diff.statGraphWidth
1989 diff.submodule 2005 diff.submodule
1990 diff.suppressBlankEmpty 2006 diff.suppressBlankEmpty
1991 diff.tool 2007 diff.tool
1992 diff.wordRegex 2008 diff.wordRegex
1993 diff.algorithm 2009 diff.algorithm
1994 difftool. 2010 difftool.
1995 difftool.prompt 2011 difftool.prompt
1996 fetch.recurseSubmodules 2012 fetch.recurseSubmodules
1997 fetch.unpackLimit 2013 fetch.unpackLimit
1998 format.attach 2014 format.attach
1999 format.cc 2015 format.cc
2016 format.coverLetter
2000 format.headers 2017 format.headers
2001 format.numbered 2018 format.numbered
2002 format.pretty 2019 format.pretty
2003 format.signature 2020 format.signature
2004 format.signoff 2021 format.signoff
2005 format.subjectprefix 2022 format.subjectprefix
2006 format.suffix 2023 format.suffix
2007 format.thread 2024 format.thread
2008 format.to 2025 format.to
2009 gc. 2026 gc.
2010 gc.aggressiveWindow 2027 gc.aggressiveWindow
2011 gc.auto 2028 gc.auto
2012 gc.autopacklimit 2029 gc.autopacklimit
2013 gc.packrefs 2030 gc.packrefs
2014 gc.pruneexpire 2031 gc.pruneexpire
2015 gc.reflogexpire 2032 gc.reflogexpire
2016 gc.reflogexpireunreachable 2033 gc.reflogexpireunreachable
2017 gc.rerereresolved 2034 gc.rerereresolved
2018 gc.rerereunresolved 2035 gc.rerereunresolved
2019 gitcvs.allbinary 2036 gitcvs.allbinary
2020 gitcvs.commitmsgannotation 2037 gitcvs.commitmsgannotation
2021 gitcvs.dbTableNamePrefix 2038 gitcvs.dbTableNamePrefix
2022 gitcvs.dbdriver 2039 gitcvs.dbdriver
2023 gitcvs.dbname 2040 gitcvs.dbname
2024 gitcvs.dbpass 2041 gitcvs.dbpass
2025 gitcvs.dbuser 2042 gitcvs.dbuser
2026 gitcvs.enabled 2043 gitcvs.enabled
2027 gitcvs.logfile 2044 gitcvs.logfile
2028 gitcvs.usecrlfattr 2045 gitcvs.usecrlfattr
2029 guitool. 2046 guitool.
2030 gui.blamehistoryctx 2047 gui.blamehistoryctx
2031 gui.commitmsgwidth 2048 gui.commitmsgwidth
2032 gui.copyblamethreshold 2049 gui.copyblamethreshold
2033 gui.diffcontext 2050 gui.diffcontext
2034 gui.encoding 2051 gui.encoding
2035 gui.fastcopyblame 2052 gui.fastcopyblame
2036 gui.matchtrackingbranch 2053 gui.matchtrackingbranch
2037 gui.newbranchtemplate 2054 gui.newbranchtemplate
2038 gui.pruneduringfetch 2055 gui.pruneduringfetch
2039 gui.spellingdictionary 2056 gui.spellingdictionary
2040 gui.trustmtime 2057 gui.trustmtime
2041 help.autocorrect 2058 help.autocorrect
2042 help.browser 2059 help.browser
2043 help.format 2060 help.format
2044 http.lowSpeedLimit 2061 http.lowSpeedLimit
2045 http.lowSpeedTime 2062 http.lowSpeedTime
2046 http.maxRequests 2063 http.maxRequests
2047 http.minSessions 2064 http.minSessions
2048 http.noEPSV 2065 http.noEPSV
2049 http.postBuffer 2066 http.postBuffer
2050 http.proxy 2067 http.proxy
2051 http.sslCAInfo 2068 http.sslCAInfo
2052 http.sslCAPath 2069 http.sslCAPath
2053 http.sslCert 2070 http.sslCert
2054 http.sslCertPasswordProtected 2071 http.sslCertPasswordProtected
2055 http.sslKey 2072 http.sslKey
2056 http.sslVerify 2073 http.sslVerify
2057 http.useragent 2074 http.useragent
2058 i18n.commitEncoding 2075 i18n.commitEncoding
2059 i18n.logOutputEncoding 2076 i18n.logOutputEncoding
2060 imap.authMethod 2077 imap.authMethod
2061 imap.folder 2078 imap.folder
2062 imap.host 2079 imap.host
2063 imap.pass 2080 imap.pass
2064 imap.port 2081 imap.port
2065 imap.preformattedHTML 2082 imap.preformattedHTML
2066 imap.sslverify 2083 imap.sslverify
2067 imap.tunnel 2084 imap.tunnel
2068 imap.user 2085 imap.user
2069 init.templatedir 2086 init.templatedir
2070 instaweb.browser 2087 instaweb.browser
2071 instaweb.httpd 2088 instaweb.httpd
2072 instaweb.local 2089 instaweb.local
2073 instaweb.modulepath 2090 instaweb.modulepath
2074 instaweb.port 2091 instaweb.port
2075 interactive.singlekey 2092 interactive.singlekey
2076 log.date 2093 log.date
2077 log.decorate 2094 log.decorate
2078 log.showroot 2095 log.showroot
2079 mailmap.file 2096 mailmap.file
2080 man. 2097 man.
2081 man.viewer 2098 man.viewer
2082 merge. 2099 merge.
2083 merge.conflictstyle 2100 merge.conflictstyle
2084 merge.log 2101 merge.log
2085 merge.renameLimit 2102 merge.renameLimit
2086 merge.renormalize 2103 merge.renormalize
2087 merge.stat 2104 merge.stat
2088 merge.tool 2105 merge.tool
2089 merge.verbosity 2106 merge.verbosity
2090 mergetool. 2107 mergetool.
2091 mergetool.keepBackup 2108 mergetool.keepBackup
2092 mergetool.keepTemporaries 2109 mergetool.keepTemporaries
2093 mergetool.prompt 2110 mergetool.prompt
2094 notes.displayRef 2111 notes.displayRef
2095 notes.rewrite. 2112 notes.rewrite.
2096 notes.rewrite.amend 2113 notes.rewrite.amend
2097 notes.rewrite.rebase 2114 notes.rewrite.rebase
2098 notes.rewriteMode 2115 notes.rewriteMode
2099 notes.rewriteRef 2116 notes.rewriteRef
2100 pack.compression 2117 pack.compression
2101 pack.deltaCacheLimit 2118 pack.deltaCacheLimit
2102 pack.deltaCacheSize 2119 pack.deltaCacheSize
2103 pack.depth 2120 pack.depth
2104 pack.indexVersion 2121 pack.indexVersion
2105 pack.packSizeLimit 2122 pack.packSizeLimit
2106 pack.threads 2123 pack.threads
2107 pack.window 2124 pack.window
2108 pack.windowMemory 2125 pack.windowMemory
2109 pager. 2126 pager.
2110 pretty. 2127 pretty.
2111 pull.octopus 2128 pull.octopus
2112 pull.twohead 2129 pull.twohead
2113 push.default 2130 push.default
2114 rebase.autosquash 2131 rebase.autosquash
2115 rebase.stat 2132 rebase.stat
2116 receive.autogc 2133 receive.autogc
2117 receive.denyCurrentBranch 2134 receive.denyCurrentBranch
2118 receive.denyDeleteCurrent 2135 receive.denyDeleteCurrent
2119 receive.denyDeletes 2136 receive.denyDeletes
2120 receive.denyNonFastForwards 2137 receive.denyNonFastForwards
2121 receive.fsckObjects 2138 receive.fsckObjects
2122 receive.unpackLimit 2139 receive.unpackLimit
2123 receive.updateserverinfo 2140 receive.updateserverinfo
2124 remote.pushdefault 2141 remote.pushdefault
2125 remotes. 2142 remotes.
2126 repack.usedeltabaseoffset 2143 repack.usedeltabaseoffset
2127 rerere.autoupdate 2144 rerere.autoupdate
2128 rerere.enabled 2145 rerere.enabled
2129 sendemail. 2146 sendemail.
2130 sendemail.aliasesfile 2147 sendemail.aliasesfile
2131 sendemail.aliasfiletype 2148 sendemail.aliasfiletype
2132 sendemail.bcc 2149 sendemail.bcc
2133 sendemail.cc 2150 sendemail.cc
2134 sendemail.cccmd 2151 sendemail.cccmd
2135 sendemail.chainreplyto 2152 sendemail.chainreplyto
2136 sendemail.confirm 2153 sendemail.confirm
2137 sendemail.envelopesender 2154 sendemail.envelopesender
2138 sendemail.from 2155 sendemail.from
2139 sendemail.identity 2156 sendemail.identity
2140 sendemail.multiedit 2157 sendemail.multiedit
2141 sendemail.signedoffbycc 2158 sendemail.signedoffbycc
2142 sendemail.smtpdomain 2159 sendemail.smtpdomain
2143 sendemail.smtpencryption 2160 sendemail.smtpencryption
2144 sendemail.smtppass 2161 sendemail.smtppass
2145 sendemail.smtpserver 2162 sendemail.smtpserver
2146 sendemail.smtpserveroption 2163 sendemail.smtpserveroption
2147 sendemail.smtpserverport 2164 sendemail.smtpserverport
2148 sendemail.smtpuser 2165 sendemail.smtpuser
2149 sendemail.suppresscc 2166 sendemail.suppresscc
2150 sendemail.suppressfrom 2167 sendemail.suppressfrom
2151 sendemail.thread 2168 sendemail.thread
2152 sendemail.to 2169 sendemail.to
2153 sendemail.validate 2170 sendemail.validate
2154 showbranch.default 2171 showbranch.default
2155 status.relativePaths 2172 status.relativePaths
2156 status.showUntrackedFiles 2173 status.showUntrackedFiles
2157 status.submodulesummary 2174 status.submodulesummary
2158 submodule. 2175 submodule.
2159 tar.umask 2176 tar.umask
2160 transfer.unpackLimit 2177 transfer.unpackLimit
2161 url. 2178 url.
2162 user.email 2179 user.email
2163 user.name 2180 user.name
2164 user.signingkey 2181 user.signingkey
2165 web.browser 2182 web.browser
2166 branch. remote. 2183 branch. remote.
2167 " 2184 "
2168 } 2185 }
2169 2186
2170 _git_remote () 2187 _git_remote ()
2171 { 2188 {
2172 local subcommands="add rename remove set-head set-branches set-url show prune update" 2189 local subcommands="add rename remove set-head set-branches set-url show prune update"
2173 local subcommand="$(__git_find_on_cmdline "$subcommands")" 2190 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2174 if [ -z "$subcommand" ]; then 2191 if [ -z "$subcommand" ]; then
2175 __gitcomp "$subcommands" 2192 __gitcomp "$subcommands"
2176 return 2193 return
2177 fi 2194 fi
2178 2195
2179 case "$subcommand" in 2196 case "$subcommand" in
2180 rename|remove|set-url|show|prune) 2197 rename|remove|set-url|show|prune)
2181 __gitcomp_nl "$(__git_remotes)" 2198 __gitcomp_nl "$(__git_remotes)"
2182 ;; 2199 ;;
2183 set-head|set-branches) 2200 set-head|set-branches)
2184 __git_complete_remote_or_refspec 2201 __git_complete_remote_or_refspec
2185 ;; 2202 ;;
2186 update) 2203 update)
2187 local i c='' IFS=$'\n' 2204 local i c='' IFS=$'\n'
2188 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do 2205 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2189 i="${i#remotes.}" 2206 i="${i#remotes.}"
2190 c="$c ${i/ */}" 2207 c="$c ${i/ */}"
2191 done 2208 done
2192 __gitcomp "$c" 2209 __gitcomp "$c"
2193 ;; 2210 ;;
2194 *) 2211 *)
2195 ;; 2212 ;;
2196 esac 2213 esac
2197 } 2214 }
2198 2215
2199 _git_replace () 2216 _git_replace ()
2200 { 2217 {
2201 __gitcomp_nl "$(__git_refs)" 2218 __gitcomp_nl "$(__git_refs)"
2202 } 2219 }
2203 2220
2204 _git_reset () 2221 _git_reset ()
2205 { 2222 {
2206 __git_has_doubledash && return 2223 __git_has_doubledash && return
2207 2224
2208 case "$cur" in 2225 case "$cur" in
2209 --*) 2226 --*)
2210 __gitcomp "--merge --mixed --hard --soft --patch" 2227 __gitcomp "--merge --mixed --hard --soft --patch"
2211 return 2228 return
2212 ;; 2229 ;;
2213 esac 2230 esac
2214 __gitcomp_nl "$(__git_refs)" 2231 __gitcomp_nl "$(__git_refs)"
2215 } 2232 }
2216 2233
2217 _git_revert () 2234 _git_revert ()
2218 { 2235 {
2219 case "$cur" in 2236 case "$cur" in
2220 --*) 2237 --*)
2221 __gitcomp "--edit --mainline --no-edit --no-commit --signoff" 2238 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2222 return 2239 return
2223 ;; 2240 ;;
2224 esac 2241 esac
2225 __gitcomp_nl "$(__git_refs)" 2242 __gitcomp_nl "$(__git_refs)"
2226 } 2243 }
2227 2244
2228 _git_rm () 2245 _git_rm ()
2229 { 2246 {
2230 case "$cur" in 2247 case "$cur" in
2231 --*) 2248 --*)
2232 __gitcomp "--cached --dry-run --ignore-unmatch --quiet" 2249 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2233 return 2250 return
2234 ;; 2251 ;;
2235 esac 2252 esac
2236 2253
2237 __git_complete_index_file "--cached" 2254 __git_complete_index_file "--cached"
2238 } 2255 }
2239 2256
2240 _git_shortlog () 2257 _git_shortlog ()
2241 { 2258 {
2242 __git_has_doubledash && return 2259 __git_has_doubledash && return
2243 2260
2244 case "$cur" in 2261 case "$cur" in
2245 --*) 2262 --*)
2246 __gitcomp " 2263 __gitcomp "
2247 $__git_log_common_options 2264 $__git_log_common_options
2248 $__git_log_shortlog_options 2265 $__git_log_shortlog_options
2249 --numbered --summary 2266 --numbered --summary
2250 " 2267 "
2251 return 2268 return
2252 ;; 2269 ;;
2253 esac 2270 esac
2254 __git_complete_revlist 2271 __git_complete_revlist
2255 } 2272 }
2256 2273
2257 _git_show () 2274 _git_show ()
2258 { 2275 {
2259 __git_has_doubledash && return 2276 __git_has_doubledash && return
2260 2277
2261 case "$cur" in 2278 case "$cur" in
2262 --pretty=*|--format=*) 2279 --pretty=*|--format=*)
2263 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) 2280 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2264 " "" "${cur#*=}" 2281 " "" "${cur#*=}"
2265 return 2282 return
2266 ;; 2283 ;;
2267 --diff-algorithm=*) 2284 --diff-algorithm=*)
2268 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" 2285 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2269 return 2286 return
2270 ;; 2287 ;;
2271 --*) 2288 --*)
2272 __gitcomp "--pretty= --format= --abbrev-commit --oneline 2289 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2273 $__git_diff_common_options 2290 $__git_diff_common_options
2274 " 2291 "
2275 return 2292 return
2276 ;; 2293 ;;
2277 esac 2294 esac
2278 __git_complete_revlist_file 2295 __git_complete_revlist_file
2279 } 2296 }
2280 2297
2281 _git_show_branch () 2298 _git_show_branch ()
2282 { 2299 {
2283 case "$cur" in 2300 case "$cur" in
2284 --*) 2301 --*)
2285 __gitcomp " 2302 __gitcomp "
2286 --all --remotes --topo-order --current --more= 2303 --all --remotes --topo-order --current --more=
2287 --list --independent --merge-base --no-name 2304 --list --independent --merge-base --no-name
2288 --color --no-color 2305 --color --no-color
2289 --sha1-name --sparse --topics --reflog 2306 --sha1-name --sparse --topics --reflog
2290 " 2307 "
2291 return 2308 return
2292 ;; 2309 ;;
2293 esac 2310 esac
2294 __git_complete_revlist 2311 __git_complete_revlist
2295 } 2312 }
2296 2313
2297 _git_stash () 2314 _git_stash ()
2298 { 2315 {
2299 local save_opts='--keep-index --no-keep-index --quiet --patch' 2316 local save_opts='--keep-index --no-keep-index --quiet --patch'
2300 local subcommands='save list show apply clear drop pop create branch' 2317 local subcommands='save list show apply clear drop pop create branch'
2301 local subcommand="$(__git_find_on_cmdline "$subcommands")" 2318 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2302 if [ -z "$subcommand" ]; then 2319 if [ -z "$subcommand" ]; then
2303 case "$cur" in 2320 case "$cur" in
2304 --*) 2321 --*)
2305 __gitcomp "$save_opts" 2322 __gitcomp "$save_opts"
2306 ;; 2323 ;;
2307 *) 2324 *)
2308 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then 2325 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2309 __gitcomp "$subcommands" 2326 __gitcomp "$subcommands"
2310 fi 2327 fi
2311 ;; 2328 ;;
2312 esac 2329 esac
2313 else 2330 else
2314 case "$subcommand,$cur" in 2331 case "$subcommand,$cur" in
2315 save,--*) 2332 save,--*)
2316 __gitcomp "$save_opts" 2333 __gitcomp "$save_opts"
2317 ;; 2334 ;;
2318 apply,--*|pop,--*) 2335 apply,--*|pop,--*)
2319 __gitcomp "--index --quiet" 2336 __gitcomp "--index --quiet"
2320 ;; 2337 ;;
2321 show,--*|drop,--*|branch,--*) 2338 show,--*|drop,--*|branch,--*)
2322 ;; 2339 ;;
2323 show,*|apply,*|drop,*|pop,*|branch,*) 2340 show,*|apply,*|drop,*|pop,*|branch,*)
2324 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ 2341 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2325 | sed -n -e 's/:.*//p')" 2342 | sed -n -e 's/:.*//p')"
2326 ;; 2343 ;;
2327 *) 2344 *)
2328 ;; 2345 ;;
2329 esac 2346 esac
2330 fi 2347 fi
2331 } 2348 }
2332 2349
2333 _git_submodule () 2350 _git_submodule ()
2334 { 2351 {
2335 __git_has_doubledash && return 2352 __git_has_doubledash && return
2336 2353
2337 local subcommands="add status init deinit update summary foreach sync" 2354 local subcommands="add status init deinit update summary foreach sync"
2338 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then 2355 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2339 case "$cur" in 2356 case "$cur" in
2340 --*) 2357 --*)
2341 __gitcomp "--quiet --cached" 2358 __gitcomp "--quiet --cached"
2342 ;; 2359 ;;
2343 *) 2360 *)
2344 __gitcomp "$subcommands" 2361 __gitcomp "$subcommands"
2345 ;; 2362 ;;
2346 esac 2363 esac
2347 return 2364 return
2348 fi 2365 fi
2349 } 2366 }
2350 2367
2351 _git_svn () 2368 _git_svn ()
2352 { 2369 {
2353 local subcommands=" 2370 local subcommands="
2354 init fetch clone rebase dcommit log find-rev 2371 init fetch clone rebase dcommit log find-rev
2355 set-tree commit-diff info create-ignore propget 2372 set-tree commit-diff info create-ignore propget
2356 proplist show-ignore show-externals branch tag blame 2373 proplist show-ignore show-externals branch tag blame
2357 migrate mkdirs reset gc 2374 migrate mkdirs reset gc
2358 " 2375 "
2359 local subcommand="$(__git_find_on_cmdline "$subcommands")" 2376 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2360 if [ -z "$subcommand" ]; then 2377 if [ -z "$subcommand" ]; then
2361 __gitcomp "$subcommands" 2378 __gitcomp "$subcommands"
2362 else 2379 else
2363 local remote_opts="--username= --config-dir= --no-auth-cache" 2380 local remote_opts="--username= --config-dir= --no-auth-cache"
2364 local fc_opts=" 2381 local fc_opts="
2365 --follow-parent --authors-file= --repack= 2382 --follow-parent --authors-file= --repack=
2366 --no-metadata --use-svm-props --use-svnsync-props 2383 --no-metadata --use-svm-props --use-svnsync-props
2367 --log-window-size= --no-checkout --quiet 2384 --log-window-size= --no-checkout --quiet
2368 --repack-flags --use-log-author --localtime 2385 --repack-flags --use-log-author --localtime
2369 --ignore-paths= --include-paths= $remote_opts 2386 --ignore-paths= --include-paths= $remote_opts
2370 " 2387 "
2371 local init_opts=" 2388 local init_opts="
2372 --template= --shared= --trunk= --tags= 2389 --template= --shared= --trunk= --tags=
2373 --branches= --stdlayout --minimize-url 2390 --branches= --stdlayout --minimize-url
2374 --no-metadata --use-svm-props --use-svnsync-props 2391 --no-metadata --use-svm-props --use-svnsync-props
2375 --rewrite-root= --prefix= --use-log-author 2392 --rewrite-root= --prefix= --use-log-author
2376 --add-author-from $remote_opts 2393 --add-author-from $remote_opts
2377 " 2394 "
2378 local cmt_opts=" 2395 local cmt_opts="
2379 --edit --rmdir --find-copies-harder --copy-similarity= 2396 --edit --rmdir --find-copies-harder --copy-similarity=
2380 " 2397 "
2381 2398
2382 case "$subcommand,$cur" in 2399 case "$subcommand,$cur" in
2383 fetch,--*) 2400 fetch,--*)
2384 __gitcomp "--revision= --fetch-all $fc_opts" 2401 __gitcomp "--revision= --fetch-all $fc_opts"
2385 ;; 2402 ;;
2386 clone,--*) 2403 clone,--*)
2387 __gitcomp "--revision= $fc_opts $init_opts" 2404 __gitcomp "--revision= $fc_opts $init_opts"
2388 ;; 2405 ;;
2389 init,--*) 2406 init,--*)
2390 __gitcomp "$init_opts" 2407 __gitcomp "$init_opts"
2391 ;; 2408 ;;
2392 dcommit,--*) 2409 dcommit,--*)
2393 __gitcomp " 2410 __gitcomp "
2394 --merge --strategy= --verbose --dry-run 2411 --merge --strategy= --verbose --dry-run
2395 --fetch-all --no-rebase --commit-url 2412 --fetch-all --no-rebase --commit-url
2396 --revision --interactive $cmt_opts $fc_opts 2413 --revision --interactive $cmt_opts $fc_opts
2397 " 2414 "
2398 ;; 2415 ;;
2399 set-tree,--*) 2416 set-tree,--*)
2400 __gitcomp "--stdin $cmt_opts $fc_opts" 2417 __gitcomp "--stdin $cmt_opts $fc_opts"
2401 ;; 2418 ;;
2402 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ 2419 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2403 show-externals,--*|mkdirs,--*) 2420 show-externals,--*|mkdirs,--*)
2404 __gitcomp "--revision=" 2421 __gitcomp "--revision="
2405 ;; 2422 ;;
2406 log,--*) 2423 log,--*)
2407 __gitcomp " 2424 __gitcomp "
2408 --limit= --revision= --verbose --incremental 2425 --limit= --revision= --verbose --incremental
2409 --oneline --show-commit --non-recursive 2426 --oneline --show-commit --non-recursive
2410 --authors-file= --color 2427 --authors-file= --color
2411 " 2428 "
2412 ;; 2429 ;;
2413 rebase,--*) 2430 rebase,--*)
2414 __gitcomp " 2431 __gitcomp "
2415 --merge --verbose --strategy= --local 2432 --merge --verbose --strategy= --local
2416 --fetch-all --dry-run $fc_opts 2433 --fetch-all --dry-run $fc_opts
2417 " 2434 "
2418 ;; 2435 ;;
2419 commit-diff,--*) 2436 commit-diff,--*)
2420 __gitcomp "--message= --file= --revision= $cmt_opts" 2437 __gitcomp "--message= --file= --revision= $cmt_opts"
2421 ;; 2438 ;;
2422 info,--*) 2439 info,--*)
2423 __gitcomp "--url" 2440 __gitcomp "--url"
2424 ;; 2441 ;;
2425 branch,--*) 2442 branch,--*)
2426 __gitcomp "--dry-run --message --tag" 2443 __gitcomp "--dry-run --message --tag"
2427 ;; 2444 ;;
2428 tag,--*) 2445 tag,--*)
2429 __gitcomp "--dry-run --message" 2446 __gitcomp "--dry-run --message"
2430 ;; 2447 ;;
2431 blame,--*) 2448 blame,--*)
2432 __gitcomp "--git-format" 2449 __gitcomp "--git-format"
2433 ;; 2450 ;;
2434 migrate,--*) 2451 migrate,--*)
2435 __gitcomp " 2452 __gitcomp "
2436 --config-dir= --ignore-paths= --minimize 2453 --config-dir= --ignore-paths= --minimize
2437 --no-auth-cache --username= 2454 --no-auth-cache --username=
2438 " 2455 "
2439 ;; 2456 ;;
2440 reset,--*) 2457 reset,--*)
2441 __gitcomp "--revision= --parent" 2458 __gitcomp "--revision= --parent"
2442 ;; 2459 ;;
2443 *) 2460 *)
2444 ;; 2461 ;;
2445 esac 2462 esac
2446 fi 2463 fi
2447 } 2464 }
2448 2465
2449 _git_tag () 2466 _git_tag ()
2450 { 2467 {
2451 local i c=1 f=0 2468 local i c=1 f=0
2452 while [ $c -lt $cword ]; do 2469 while [ $c -lt $cword ]; do
2453 i="${words[c]}" 2470 i="${words[c]}"
2454 case "$i" in 2471 case "$i" in
2455 -d|-v) 2472 -d|-v)
2456 __gitcomp_nl "$(__git_tags)" 2473 __gitcomp_nl "$(__git_tags)"
2457 return 2474 return
2458 ;; 2475 ;;
2459 -f) 2476 -f)
2460 f=1 2477 f=1
2461 ;; 2478 ;;
2462 esac 2479 esac
2463 ((c++)) 2480 ((c++))
2464 done 2481 done
2465 2482
2466 case "$prev" in 2483 case "$prev" in
2467 -m|-F) 2484 -m|-F)
2468 ;; 2485 ;;
2469 -*|tag) 2486 -*|tag)
2470 if [ $f = 1 ]; then 2487 if [ $f = 1 ]; then
2471 __gitcomp_nl "$(__git_tags)" 2488 __gitcomp_nl "$(__git_tags)"
2472 fi 2489 fi
2473 ;; 2490 ;;
2474 *) 2491 *)
2475 __gitcomp_nl "$(__git_refs)" 2492 __gitcomp_nl "$(__git_refs)"
2476 ;; 2493 ;;
2477 esac 2494 esac
2478 } 2495 }
2479 2496
2480 _git_whatchanged () 2497 _git_whatchanged ()
2481 { 2498 {
2482 _git_log 2499 _git_log
2483 } 2500 }
2484 2501
2485 __git_main () 2502 __git_main ()
2486 { 2503 {
2487 local i c=1 command __git_dir 2504 local i c=1 command __git_dir
2488 2505
2489 while [ $c -lt $cword ]; do 2506 while [ $c -lt $cword ]; do
2490 i="${words[c]}" 2507 i="${words[c]}"
2491 case "$i" in 2508 case "$i" in
2492 --git-dir=*) __git_dir="${i#--git-dir=}" ;; 2509 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2493 --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; 2510 --git-dir) ((c++)) ; __git_dir="${words[c]}" ;;
2494 --bare) __git_dir="." ;; 2511 --bare) __git_dir="." ;;
2495 --help) command="help"; break ;; 2512 --help) command="help"; break ;;
2496 -c|--work-tree|--namespace) ((c++)) ;; 2513 -c|--work-tree|--namespace) ((c++)) ;;
2497 -*) ;; 2514 -*) ;;
2498 *) command="$i"; break ;; 2515 *) command="$i"; break ;;
2499 esac 2516 esac
2500 ((c++)) 2517 ((c++))
2501 done 2518 done
2502 2519
2503 if [ -z "$command" ]; then 2520 if [ -z "$command" ]; then
2504 case "$cur" in 2521 case "$cur" in
2505 --*) __gitcomp " 2522 --*) __gitcomp "
2506 --paginate 2523 --paginate
2507 --no-pager 2524 --no-pager
2508 --git-dir= 2525 --git-dir=
2509 --bare 2526 --bare
2510 --version 2527 --version
2511 --exec-path 2528 --exec-path
2512 --exec-path= 2529 --exec-path=
2513 --html-path 2530 --html-path
2514 --man-path 2531 --man-path
2515 --info-path 2532 --info-path
2516 --work-tree= 2533 --work-tree=
2517 --namespace= 2534 --namespace=
2518 --no-replace-objects 2535 --no-replace-objects
2519 --help 2536 --help
2520 " 2537 "
2521 ;; 2538 ;;
2522 *) __git_compute_porcelain_commands 2539 *) __git_compute_porcelain_commands
2523 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; 2540 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2524 esac 2541 esac
2525 return 2542 return
2526 fi 2543 fi
2527 2544
2528 local completion_func="_git_${command//-/_}" 2545 local completion_func="_git_${command//-/_}"
2529 declare -f $completion_func >/dev/null && $completion_func && return 2546 declare -f $completion_func >/dev/null && $completion_func && return
2530 2547
2531 local expansion=$(__git_aliased_command "$command") 2548 local expansion=$(__git_aliased_command "$command")
2532 if [ -n "$expansion" ]; then 2549 if [ -n "$expansion" ]; then
2533 completion_func="_git_${expansion//-/_}" 2550 completion_func="_git_${expansion//-/_}"
2534 declare -f $completion_func >/dev/null && $completion_func 2551 declare -f $completion_func >/dev/null && $completion_func
2535 fi 2552 fi
2536 } 2553 }
2537 2554
2538 __gitk_main () 2555 __gitk_main ()
2539 { 2556 {
2540 __git_has_doubledash && return 2557 __git_has_doubledash && return
2541 2558
2542 local g="$(__gitdir)" 2559 local g="$(__gitdir)"
2543 local merge="" 2560 local merge=""
2544 if [ -f "$g/MERGE_HEAD" ]; then 2561 if [ -f "$g/MERGE_HEAD" ]; then
2545 merge="--merge" 2562 merge="--merge"
2546 fi 2563 fi
2547 case "$cur" in 2564 case "$cur" in
2548 --*) 2565 --*)
2549 __gitcomp " 2566 __gitcomp "
2550 $__git_log_common_options 2567 $__git_log_common_options
2551 $__git_log_gitk_options 2568 $__git_log_gitk_options
2552 $merge 2569 $merge
2553 " 2570 "
2554 return 2571 return
2555 ;; 2572 ;;
2556 esac 2573 esac
2557 __git_complete_revlist 2574 __git_complete_revlist
2558 } 2575 }
2559 2576
2560 if [[ -n ${ZSH_VERSION-} ]]; then 2577 if [[ -n ${ZSH_VERSION-} ]]; then
2561 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 2578 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2562 2579
2563 autoload -U +X compinit && compinit 2580 autoload -U +X compinit && compinit
2564 2581
2565 __gitcomp () 2582 __gitcomp ()
2566 { 2583 {
2567 emulate -L zsh 2584 emulate -L zsh
2568 2585
2569 local cur_="${3-$cur}" 2586 local cur_="${3-$cur}"
2570 2587
2571 case "$cur_" in 2588 case "$cur_" in
2572 --*=) 2589 --*=)
2573 ;; 2590 ;;
2574 *) 2591 *)
2575 local c IFS=$' \t\n' 2592 local c IFS=$' \t\n'
2576 local -a array 2593 local -a array
2577 for c in ${=1}; do 2594 for c in ${=1}; do
2578 c="$c${4-}" 2595 c="$c${4-}"
2579 case $c in 2596 case $c in
2580 --*=*|*.) ;; 2597 --*=*|*.) ;;
2581 *) c="$c " ;; 2598 *) c="$c " ;;
2582 esac 2599 esac
2583 array[$#array+1]="$c" 2600 array[${#array[@]}+1]="$c"
2584 done 2601 done
2585 compset -P '*[=:]' 2602 compset -P '*[=:]'
2586 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 2603 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2587 ;; 2604 ;;
2588 esac 2605 esac
2589 } 2606 }
2590 2607
2591 __gitcomp_nl () 2608 __gitcomp_nl ()
2592 { 2609 {
2593 emulate -L zsh 2610 emulate -L zsh
2594 2611
2595 local IFS=$'\n' 2612 local IFS=$'\n'
2596 compset -P '*[=:]' 2613 compset -P '*[=:]'
2597 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 2614 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2598 } 2615 }
2599 2616
2600 __gitcomp_file () 2617 __gitcomp_file ()
2601 { 2618 {
2602 emulate -L zsh 2619 emulate -L zsh
2603 2620
2604 local IFS=$'\n' 2621 local IFS=$'\n'
2605 compset -P '*[=:]' 2622 compset -P '*[=:]'
2606 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 2623 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2607 } 2624 }
2608 2625
2609 _git () 2626 _git ()
2610 { 2627 {
2611 local _ret=1 cur cword prev 2628 local _ret=1 cur cword prev
2612 cur=${words[CURRENT]} 2629 cur=${words[CURRENT]}
2613 prev=${words[CURRENT-1]} 2630 prev=${words[CURRENT-1]}
2614 let cword=CURRENT-1 2631 let cword=CURRENT-1
2615 emulate ksh -c __${service}_main 2632 emulate ksh -c __${service}_main
2616 let _ret && _default && _ret=0 2633 let _ret && _default && _ret=0
2617 return _ret 2634 return _ret
2618 } 2635 }
2619 2636
2620 compdef _git git gitk 2637 compdef _git git gitk
2621 return 2638 return
2622 fi 2639 fi
2623 2640
2624 __git_func_wrap () 2641 __git_func_wrap ()
2625 { 2642 {
2626 local cur words cword prev 2643 local cur words cword prev
2627 _get_comp_words_by_ref -n =: cur words cword prev 2644 _get_comp_words_by_ref -n =: cur words cword prev
2628 $1 2645 $1
2629 } 2646 }
2630 2647
2631 # Setup completion for certain functions defined above by setting common 2648 # Setup completion for certain functions defined above by setting common
2632 # variables and workarounds. 2649 # variables and workarounds.
2633 # This is NOT a public function; use at your own risk. 2650 # This is NOT a public function; use at your own risk.
2634 __git_complete () 2651 __git_complete ()
2635 { 2652 {
2636 local wrapper="__git_wrap${2}" 2653 local wrapper="__git_wrap${2}"
2637 eval "$wrapper () { __git_func_wrap $2 ; }" 2654 eval "$wrapper () { __git_func_wrap $2 ; }"
2638 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ 2655 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2639 || complete -o default -o nospace -F $wrapper $1 2656 || complete -o default -o nospace -F $wrapper $1
2640 } 2657 }
2641 2658
2642 # wrapper for backwards compatibility 2659 # wrapper for backwards compatibility
2643 _git () 2660 _git ()
2644 { 2661 {
2645 __git_wrap__git_main 2662 __git_wrap__git_main
2646 } 2663 }
2647 2664
2648 # wrapper for backwards compatibility 2665 # wrapper for backwards compatibility
2649 _gitk () 2666 _gitk ()
2650 { 2667 {
2651 __git_wrap__gitk_main 2668 __git_wrap__gitk_main
2652 } 2669 }
2653 2670
2654 __git_complete git __git_main 2671 __git_complete git __git_main
2655 __git_complete gitk __gitk_main 2672 __git_complete gitk __gitk_main
2656 2673
2657 # The following are necessary only for Cygwin, and only are needed 2674 # The following are necessary only for Cygwin, and only are needed
2658 # when the user has tab-completed the executable name and consequently 2675 # when the user has tab-completed the executable name and consequently
plugins/gitfast/git-prompt.sh
1 # bash/zsh git prompt support 1 # bash/zsh git prompt support
2 # 2 #
3 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> 3 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
4 # Distributed under the GNU General Public License, version 2.0. 4 # Distributed under the GNU General Public License, version 2.0.
5 # 5 #
6 # This script allows you to see repository status in your prompt. 6 # This script allows you to see repository status in your prompt.
7 # 7 #
8 # To enable: 8 # To enable:
9 # 9 #
10 # 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). 10 # 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
11 # 2) Add the following line to your .bashrc/.zshrc: 11 # 2) Add the following line to your .bashrc/.zshrc:
12 # source ~/.git-prompt.sh 12 # source ~/.git-prompt.sh
13 # 3a) Change your PS1 to call __git_ps1 as 13 # 3a) Change your PS1 to call __git_ps1 as
14 # command-substitution: 14 # command-substitution:
15 # Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' 15 # Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
16 # ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' 16 # ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
17 # the optional argument will be used as format string. 17 # the optional argument will be used as format string.
18 # 3b) Alternatively, for a slightly faster prompt, __git_ps1 can 18 # 3b) Alternatively, for a slightly faster prompt, __git_ps1 can
19 # be used for PROMPT_COMMAND in Bash or for precmd() in Zsh 19 # be used for PROMPT_COMMAND in Bash or for precmd() in Zsh
20 # with two parameters, <pre> and <post>, which are strings 20 # with two parameters, <pre> and <post>, which are strings
21 # you would put in $PS1 before and after the status string 21 # you would put in $PS1 before and after the status string
22 # generated by the git-prompt machinery. e.g. 22 # generated by the git-prompt machinery. e.g.
23 # Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "' 23 # Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
24 # will show username, at-sign, host, colon, cwd, then 24 # will show username, at-sign, host, colon, cwd, then
25 # various status string, followed by dollar and SP, as 25 # various status string, followed by dollar and SP, as
26 # your prompt. 26 # your prompt.
27 # ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" } 27 # ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
28 # will show username, pipe, then various status string, 28 # will show username, pipe, then various status string,
29 # followed by colon, cwd, dollar and SP, as your prompt. 29 # followed by colon, cwd, dollar and SP, as your prompt.
30 # Optionally, you can supply a third argument with a printf 30 # Optionally, you can supply a third argument with a printf
31 # format string to finetune the output of the branch status 31 # format string to finetune the output of the branch status
32 # 32 #
33 # The repository status will be displayed only if you are currently in a 33 # The repository status will be displayed only if you are currently in a
34 # git repository. The %s token is the placeholder for the shown status. 34 # git repository. The %s token is the placeholder for the shown status.
35 # 35 #
36 # The prompt status always includes the current branch name. 36 # The prompt status always includes the current branch name.
37 # 37 #
38 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value, 38 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
39 # unstaged (*) and staged (+) changes will be shown next to the branch 39 # unstaged (*) and staged (+) changes will be shown next to the branch
40 # name. You can configure this per-repository with the 40 # name. You can configure this per-repository with the
41 # bash.showDirtyState variable, which defaults to true once 41 # bash.showDirtyState variable, which defaults to true once
42 # GIT_PS1_SHOWDIRTYSTATE is enabled. 42 # GIT_PS1_SHOWDIRTYSTATE is enabled.
43 # 43 #
44 # You can also see if currently something is stashed, by setting 44 # You can also see if currently something is stashed, by setting
45 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, 45 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
46 # then a '$' will be shown next to the branch name. 46 # then a '$' will be shown next to the branch name.
47 # 47 #
48 # If you would like to see if there're untracked files, then you can set 48 # If you would like to see if there're untracked files, then you can set
49 # GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked 49 # GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
50 # files, then a '%' will be shown next to the branch name. You can 50 # files, then a '%' will be shown next to the branch name. You can
51 # configure this per-repository with the bash.showUntrackedFiles 51 # configure this per-repository with the bash.showUntrackedFiles
52 # variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is 52 # variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is
53 # enabled. 53 # enabled.
54 # 54 #
55 # If you would like to see the difference between HEAD and its upstream, 55 # If you would like to see the difference between HEAD and its upstream,
56 # set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">" 56 # set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">"
57 # indicates you are ahead, "<>" indicates you have diverged and "=" 57 # indicates you are ahead, "<>" indicates you have diverged and "="
58 # indicates that there is no difference. You can further control 58 # indicates that there is no difference. You can further control
59 # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list 59 # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list
60 # of values: 60 # of values:
61 # 61 #
62 # verbose show number of commits ahead/behind (+/-) upstream 62 # verbose show number of commits ahead/behind (+/-) upstream
63 # name if verbose, then also show the upstream abbrev name
63 # legacy don't use the '--count' option available in recent 64 # legacy don't use the '--count' option available in recent
64 # versions of git-rev-list 65 # versions of git-rev-list
65 # git always compare HEAD to @{upstream} 66 # git always compare HEAD to @{upstream}
66 # svn always compare HEAD to your SVN upstream 67 # svn always compare HEAD to your SVN upstream
67 # 68 #
68 # By default, __git_ps1 will compare HEAD to your SVN upstream if it can 69 # By default, __git_ps1 will compare HEAD to your SVN upstream if it can
69 # find one, or @{upstream} otherwise. Once you have set 70 # find one, or @{upstream} otherwise. Once you have set
70 # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by 71 # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
71 # setting the bash.showUpstream config variable. 72 # setting the bash.showUpstream config variable.
72 # 73 #
73 # If you would like to see more information about the identity of 74 # If you would like to see more information about the identity of
74 # commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE 75 # commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
75 # to one of these values: 76 # to one of these values:
76 # 77 #
77 # contains relative to newer annotated tag (v1.6.3.2~35) 78 # contains relative to newer annotated tag (v1.6.3.2~35)
78 # branch relative to newer tag or branch (master~4) 79 # branch relative to newer tag or branch (master~4)
79 # describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f) 80 # describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
80 # default exactly matching tag 81 # default exactly matching tag
81 # 82 #
82 # If you would like a colored hint about the current dirty state, set 83 # If you would like a colored hint about the current dirty state, set
83 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on 84 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
84 # the colored output of "git status -sb" and are available only when 85 # the colored output of "git status -sb" and are available only when
85 # using __git_ps1 for PROMPT_COMMAND or precmd. 86 # using __git_ps1 for PROMPT_COMMAND or precmd.
86 87
88 # check whether printf supports -v
89 __git_printf_supports_v=
90 printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
91
87 # stores the divergence from upstream in $p 92 # stores the divergence from upstream in $p
88 # used by GIT_PS1_SHOWUPSTREAM 93 # used by GIT_PS1_SHOWUPSTREAM
89 __git_ps1_show_upstream () 94 __git_ps1_show_upstream ()
90 { 95 {
91 local key value 96 local key value
92 local svn_remote svn_url_pattern count n 97 local svn_remote svn_url_pattern count n
93 local upstream=git legacy="" verbose="" 98 local upstream=git legacy="" verbose="" name=""
94 99
95 svn_remote=() 100 svn_remote=()
96 # get some config options from git-config 101 # get some config options from git-config
97 local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" 102 local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
98 while read -r key value; do 103 while read -r key value; do
99 case "$key" in 104 case "$key" in
100 bash.showupstream) 105 bash.showupstream)
101 GIT_PS1_SHOWUPSTREAM="$value" 106 GIT_PS1_SHOWUPSTREAM="$value"
102 if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then 107 if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
103 p="" 108 p=""
104 return 109 return
105 fi 110 fi
106 ;; 111 ;;
107 svn-remote.*.url) 112 svn-remote.*.url)
108 svn_remote[$((${#svn_remote[@]} + 1))]="$value" 113 svn_remote[$((${#svn_remote[@]} + 1))]="$value"
109 svn_url_pattern+="\\|$value" 114 svn_url_pattern="$svn_url_pattern\\|$value"
110 upstream=svn+git # default upstream is SVN if available, else git 115 upstream=svn+git # default upstream is SVN if available, else git
111 ;; 116 ;;
112 esac 117 esac
113 done <<< "$output" 118 done <<< "$output"
114 119
115 # parse configuration values 120 # parse configuration values
116 for option in ${GIT_PS1_SHOWUPSTREAM}; do 121 for option in ${GIT_PS1_SHOWUPSTREAM}; do
117 case "$option" in 122 case "$option" in
118 git|svn) upstream="$option" ;; 123 git|svn) upstream="$option" ;;
119 verbose) verbose=1 ;; 124 verbose) verbose=1 ;;
120 legacy) legacy=1 ;; 125 legacy) legacy=1 ;;
126 name) name=1 ;;
121 esac 127 esac
122 done 128 done
123 129
124 # Find our upstream 130 # Find our upstream
125 case "$upstream" in 131 case "$upstream" in
126 git) upstream="@{upstream}" ;; 132 git) upstream="@{upstream}" ;;
127 svn*) 133 svn*)
128 # get the upstream from the "git-svn-id: ..." in a commit message 134 # get the upstream from the "git-svn-id: ..." in a commit message
129 # (git-svn uses essentially the same procedure internally) 135 # (git-svn uses essentially the same procedure internally)
130 local -a svn_upstream 136 local -a svn_upstream
131 svn_upstream=($(git log --first-parent -1 \ 137 svn_upstream=($(git log --first-parent -1 \
132 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) 138 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
133 if [[ 0 -ne ${#svn_upstream[@]} ]]; then 139 if [[ 0 -ne ${#svn_upstream[@]} ]]; then
134 svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} 140 svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}
135 svn_upstream=${svn_upstream%@*} 141 svn_upstream=${svn_upstream%@*}
136 local n_stop="${#svn_remote[@]}" 142 local n_stop="${#svn_remote[@]}"
137 for ((n=1; n <= n_stop; n++)); do 143 for ((n=1; n <= n_stop; n++)); do
138 svn_upstream=${svn_upstream#${svn_remote[$n]}} 144 svn_upstream=${svn_upstream#${svn_remote[$n]}}
139 done 145 done
140 146
141 if [[ -z "$svn_upstream" ]]; then 147 if [[ -z "$svn_upstream" ]]; then
142 # default branch name for checkouts with no layout: 148 # default branch name for checkouts with no layout:
143 upstream=${GIT_SVN_ID:-git-svn} 149 upstream=${GIT_SVN_ID:-git-svn}
144 else 150 else
145 upstream=${svn_upstream#/} 151 upstream=${svn_upstream#/}
146 fi 152 fi
147 elif [[ "svn+git" = "$upstream" ]]; then 153 elif [[ "svn+git" = "$upstream" ]]; then
148 upstream="@{upstream}" 154 upstream="@{upstream}"
149 fi 155 fi
150 ;; 156 ;;
151 esac 157 esac
152 158
153 # Find how many commits we are ahead/behind our upstream 159 # Find how many commits we are ahead/behind our upstream
154 if [[ -z "$legacy" ]]; then 160 if [[ -z "$legacy" ]]; then
155 count="$(git rev-list --count --left-right \ 161 count="$(git rev-list --count --left-right \
156 "$upstream"...HEAD 2>/dev/null)" 162 "$upstream"...HEAD 2>/dev/null)"
157 else 163 else
158 # produce equivalent output to --count for older versions of git 164 # produce equivalent output to --count for older versions of git
159 local commits 165 local commits
160 if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)" 166 if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
161 then 167 then
162 local commit behind=0 ahead=0 168 local commit behind=0 ahead=0
163 for commit in $commits 169 for commit in $commits
164 do 170 do
165 case "$commit" in 171 case "$commit" in
166 "<"*) ((behind++)) ;; 172 "<"*) ((behind++)) ;;
167 *) ((ahead++)) ;; 173 *) ((ahead++)) ;;
168 esac 174 esac
169 done 175 done
170 count="$behind $ahead" 176 count="$behind $ahead"
171 else 177 else
172 count="" 178 count=""
173 fi 179 fi
174 fi 180 fi
175 181
176 # calculate the result 182 # calculate the result
177 if [[ -z "$verbose" ]]; then 183 if [[ -z "$verbose" ]]; then
178 case "$count" in 184 case "$count" in
179 "") # no upstream 185 "") # no upstream
180 p="" ;; 186 p="" ;;
181 "0 0") # equal to upstream 187 "0 0") # equal to upstream
182 p="=" ;; 188 p="=" ;;
183 "0 "*) # ahead of upstream 189 "0 "*) # ahead of upstream
184 p=">" ;; 190 p=">" ;;
185 *" 0") # behind upstream 191 *" 0") # behind upstream
186 p="<" ;; 192 p="<" ;;
187 *) # diverged from upstream 193 *) # diverged from upstream
188 p="<>" ;; 194 p="<>" ;;
189 esac 195 esac
190 else 196 else
191 case "$count" in 197 case "$count" in
192 "") # no upstream 198 "") # no upstream
193 p="" ;; 199 p="" ;;
194 "0 0") # equal to upstream 200 "0 0") # equal to upstream
195 p=" u=" ;; 201 p=" u=" ;;
196 "0 "*) # ahead of upstream 202 "0 "*) # ahead of upstream
197 p=" u+${count#0 }" ;; 203 p=" u+${count#0 }" ;;
198 *" 0") # behind upstream 204 *" 0") # behind upstream
199 p=" u-${count% 0}" ;; 205 p=" u-${count% 0}" ;;
200 *) # diverged from upstream 206 *) # diverged from upstream
201 p=" u+${count#* }-${count% *}" ;; 207 p=" u+${count#* }-${count% *}" ;;
202 esac 208 esac
209 if [[ -n "$count" && -n "$name" ]]; then
210 p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
211 fi
203 fi 212 fi
204 213
205 } 214 }
206 215
207 # Helper function that is meant to be called from __git_ps1. It 216 # Helper function that is meant to be called from __git_ps1. It
208 # injects color codes into the appropriate gitstring variables used 217 # injects color codes into the appropriate gitstring variables used
209 # to build a gitstring. 218 # to build a gitstring.
210 __git_ps1_colorize_gitstring () 219 __git_ps1_colorize_gitstring ()
211 { 220 {
212 if [[ -n ${ZSH_VERSION-} ]]; then 221 if [[ -n ${ZSH_VERSION-} ]]; then
213 local c_red='%F{red}' 222 local c_red='%F{red}'
214 local c_green='%F{green}' 223 local c_green='%F{green}'
215 local c_lblue='%F{blue}' 224 local c_lblue='%F{blue}'
216 local c_clear='%f' 225 local c_clear='%f'
217 else 226 else
218 # Using \[ and \] around colors is necessary to prevent 227 # Using \[ and \] around colors is necessary to prevent
219 # issues with command line editing/browsing/completion! 228 # issues with command line editing/browsing/completion!
220 local c_red='\[\e[31m\]' 229 local c_red='\[\e[31m\]'
221 local c_green='\[\e[32m\]' 230 local c_green='\[\e[32m\]'
222 local c_lblue='\[\e[1;34m\]' 231 local c_lblue='\[\e[1;34m\]'
223 local c_clear='\[\e[0m\]' 232 local c_clear='\[\e[0m\]'
224 fi 233 fi
225 local bad_color=$c_red 234 local bad_color=$c_red
226 local ok_color=$c_green 235 local ok_color=$c_green
227 local flags_color="$c_lblue" 236 local flags_color="$c_lblue"
228 237
229 local branch_color="" 238 local branch_color=""
230 if [ $detached = no ]; then 239 if [ $detached = no ]; then
231 branch_color="$ok_color" 240 branch_color="$ok_color"
232 else 241 else
233 branch_color="$bad_color" 242 branch_color="$bad_color"
234 fi 243 fi
235 c="$branch_color$c" 244 c="$branch_color$c"
236 245
237 z="$c_clear$z" 246 z="$c_clear$z"
238 if [ "$w" = "*" ]; then 247 if [ "$w" = "*" ]; then
239 w="$bad_color$w" 248 w="$bad_color$w"
240 fi 249 fi
241 if [ -n "$i" ]; then 250 if [ -n "$i" ]; then
242 i="$ok_color$i" 251 i="$ok_color$i"
243 fi 252 fi
244 if [ -n "$s" ]; then 253 if [ -n "$s" ]; then
245 s="$flags_color$s" 254 s="$flags_color$s"
246 fi 255 fi
247 if [ -n "$u" ]; then 256 if [ -n "$u" ]; then
248 u="$bad_color$u" 257 u="$bad_color$u"
249 fi 258 fi
250 r="$c_clear$r" 259 r="$c_clear$r"
251 } 260 }
252 261
262 eread ()
263 {
264 f="$1"
265 shift
266 test -r "$f" && read "$@" <"$f"
267 }
268
253 # __git_ps1 accepts 0 or 1 arguments (i.e., format string) 269 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
254 # when called from PS1 using command substitution 270 # when called from PS1 using command substitution
255 # in this mode it prints text to add to bash PS1 prompt (includes branch name) 271 # in this mode it prints text to add to bash PS1 prompt (includes branch name)
256 # 272 #
257 # __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc) 273 # __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc)
258 # in that case it _sets_ PS1. The arguments are parts of a PS1 string. 274 # in that case it _sets_ PS1. The arguments are parts of a PS1 string.
259 # when two arguments are given, the first is prepended and the second appended 275 # when two arguments are given, the first is prepended and the second appended
260 # to the state string when assigned to PS1. 276 # to the state string when assigned to PS1.
261 # The optional third parameter will be used as printf format string to further 277 # The optional third parameter will be used as printf format string to further
262 # customize the output of the git-status string. 278 # customize the output of the git-status string.
263 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true 279 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
264 __git_ps1 () 280 __git_ps1 ()
265 { 281 {
266 local pcmode=no 282 local pcmode=no
267 local detached=no 283 local detached=no
268 local ps1pc_start='\u@\h:\w ' 284 local ps1pc_start='\u@\h:\w '
269 local ps1pc_end='\$ ' 285 local ps1pc_end='\$ '
270 local printf_format=' (%s)' 286 local printf_format=' (%s)'
271 287
272 case "$#" in 288 case "$#" in
273 2|3) pcmode=yes 289 2|3) pcmode=yes
274 ps1pc_start="$1" 290 ps1pc_start="$1"
275 ps1pc_end="$2" 291 ps1pc_end="$2"
276 printf_format="${3:-$printf_format}" 292 printf_format="${3:-$printf_format}"
277 ;; 293 ;;
278 0|1) printf_format="${1:-$printf_format}" 294 0|1) printf_format="${1:-$printf_format}"
279 ;; 295 ;;
280 *) return 296 *) return
281 ;; 297 ;;
282 esac 298 esac
283 299
284 local repo_info rev_parse_exit_code 300 local repo_info rev_parse_exit_code
285 repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ 301 repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
286 --is-bare-repository --is-inside-work-tree \ 302 --is-bare-repository --is-inside-work-tree \
287 --short HEAD 2>/dev/null)" 303 --short HEAD 2>/dev/null)"
288 rev_parse_exit_code="$?" 304 rev_parse_exit_code="$?"
289 305
290 if [ -z "$repo_info" ]; then 306 if [ -z "$repo_info" ]; then
291 if [ $pcmode = yes ]; then 307 if [ $pcmode = yes ]; then
292 #In PC mode PS1 always needs to be set 308 #In PC mode PS1 always needs to be set
293 PS1="$ps1pc_start$ps1pc_end" 309 PS1="$ps1pc_start$ps1pc_end"
294 fi 310 fi
295 return 311 return
296 fi 312 fi
297 313
298 local short_sha 314 local short_sha
299 if [ "$rev_parse_exit_code" = "0" ]; then 315 if [ "$rev_parse_exit_code" = "0" ]; then
300 short_sha="${repo_info##*$'\n'}" 316 short_sha="${repo_info##*$'\n'}"
301 repo_info="${repo_info%$'\n'*}" 317 repo_info="${repo_info%$'\n'*}"
302 fi 318 fi
303 local inside_worktree="${repo_info##*$'\n'}" 319 local inside_worktree="${repo_info##*$'\n'}"
304 repo_info="${repo_info%$'\n'*}" 320 repo_info="${repo_info%$'\n'*}"
305 local bare_repo="${repo_info##*$'\n'}" 321 local bare_repo="${repo_info##*$'\n'}"
306 repo_info="${repo_info%$'\n'*}" 322 repo_info="${repo_info%$'\n'*}"
307 local inside_gitdir="${repo_info##*$'\n'}" 323 local inside_gitdir="${repo_info##*$'\n'}"
308 local g="${repo_info%$'\n'*}" 324 local g="${repo_info%$'\n'*}"
309 325
310 local r="" 326 local r=""
311 local b="" 327 local b=""
312 local step="" 328 local step=""
313 local total="" 329 local total=""
314 if [ -d "$g/rebase-merge" ]; then 330 if [ -d "$g/rebase-merge" ]; then
315 read b 2>/dev/null <"$g/rebase-merge/head-name" 331 eread "$g/rebase-merge/head-name" b
316 read step 2>/dev/null <"$g/rebase-merge/msgnum" 332 eread "$g/rebase-merge/msgnum" step
317 read total 2>/dev/null <"$g/rebase-merge/end" 333 eread "$g/rebase-merge/end" total
318 if [ -f "$g/rebase-merge/interactive" ]; then 334 if [ -f "$g/rebase-merge/interactive" ]; then
319 r="|REBASE-i" 335 r="|REBASE-i"
320 else 336 else
321 r="|REBASE-m" 337 r="|REBASE-m"
322 fi 338 fi
323 else 339 else
324 if [ -d "$g/rebase-apply" ]; then 340 if [ -d "$g/rebase-apply" ]; then
325 read step 2>/dev/null <"$g/rebase-apply/next" 341 eread "$g/rebase-apply/next" step
326 read total 2>/dev/null <"$g/rebase-apply/last" 342 eread "$g/rebase-apply/last" total
327 if [ -f "$g/rebase-apply/rebasing" ]; then 343 if [ -f "$g/rebase-apply/rebasing" ]; then
328 read b 2>/dev/null <"$g/rebase-apply/head-name" 344 eread "$g/rebase-apply/head-name" b
329 r="|REBASE" 345 r="|REBASE"
330 elif [ -f "$g/rebase-apply/applying" ]; then 346 elif [ -f "$g/rebase-apply/applying" ]; then
331 r="|AM" 347 r="|AM"
332 else 348 else
333 r="|AM/REBASE" 349 r="|AM/REBASE"
334 fi 350 fi
335 elif [ -f "$g/MERGE_HEAD" ]; then 351 elif [ -f "$g/MERGE_HEAD" ]; then
336 r="|MERGING" 352 r="|MERGING"
337 elif [ -f "$g/CHERRY_PICK_HEAD" ]; then 353 elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
338 r="|CHERRY-PICKING" 354 r="|CHERRY-PICKING"
339 elif [ -f "$g/REVERT_HEAD" ]; then 355 elif [ -f "$g/REVERT_HEAD" ]; then
340 r="|REVERTING" 356 r="|REVERTING"
341 elif [ -f "$g/BISECT_LOG" ]; then 357 elif [ -f "$g/BISECT_LOG" ]; then
342 r="|BISECTING" 358 r="|BISECTING"
343 fi 359 fi
344 360
345 if [ -n "$b" ]; then 361 if [ -n "$b" ]; then
346 : 362 :
347 elif [ -h "$g/HEAD" ]; then 363 elif [ -h "$g/HEAD" ]; then
348 # symlink symbolic ref 364 # symlink symbolic ref
349 b="$(git symbolic-ref HEAD 2>/dev/null)" 365 b="$(git symbolic-ref HEAD 2>/dev/null)"
350 else 366 else
351 local head="" 367 local head=""
352 if ! read head 2>/dev/null <"$g/HEAD"; then 368 if ! eread "$g/HEAD" head; then
353 if [ $pcmode = yes ]; then 369 if [ $pcmode = yes ]; then
354 PS1="$ps1pc_start$ps1pc_end" 370 PS1="$ps1pc_start$ps1pc_end"
355 fi 371 fi
356 return 372 return
357 fi 373 fi
358 # is it a symbolic ref? 374 # is it a symbolic ref?
359 b="${head#ref: }" 375 b="${head#ref: }"
360 if [ "$head" = "$b" ]; then 376 if [ "$head" = "$b" ]; then
361 detached=yes 377 detached=yes
362 b="$( 378 b="$(
363 case "${GIT_PS1_DESCRIBE_STYLE-}" in 379 case "${GIT_PS1_DESCRIBE_STYLE-}" in
364 (contains) 380 (contains)
365 git describe --contains HEAD ;; 381 git describe --contains HEAD ;;
366 (branch) 382 (branch)
367 git describe --contains --all HEAD ;; 383 git describe --contains --all HEAD ;;
368 (describe) 384 (describe)
369 git describe HEAD ;; 385 git describe HEAD ;;
370 (* | default) 386 (* | default)
371 git describe --tags --exact-match HEAD ;; 387 git describe --tags --exact-match HEAD ;;
372 esac 2>/dev/null)" || 388 esac 2>/dev/null)" ||
373 389
374 b="$short_sha..." 390 b="$short_sha..."
375 b="($b)" 391 b="($b)"
376 fi 392 fi
377 fi 393 fi
378 fi 394 fi
379 395
380 if [ -n "$step" ] && [ -n "$total" ]; then 396 if [ -n "$step" ] && [ -n "$total" ]; then
381 r="$r $step/$total" 397 r="$r $step/$total"
382 fi 398 fi
383 399
384 local w="" 400 local w=""
385 local i="" 401 local i=""
386 local s="" 402 local s=""
387 local u="" 403 local u=""
388 local c="" 404 local c=""
389 local p="" 405 local p=""
390 406
391 if [ "true" = "$inside_gitdir" ]; then 407 if [ "true" = "$inside_gitdir" ]; then
392 if [ "true" = "$bare_repo" ]; then 408 if [ "true" = "$bare_repo" ]; then
393 c="BARE:" 409 c="BARE:"
394 else 410 else
395 b="GIT_DIR!" 411 b="GIT_DIR!"
396 fi 412 fi
397 elif [ "true" = "$inside_worktree" ]; then 413 elif [ "true" = "$inside_worktree" ]; then
398 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && 414 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
399 [ "$(git config --bool bash.showDirtyState)" != "false" ] 415 [ "$(git config --bool bash.showDirtyState)" != "false" ]
400 then 416 then
401 git diff --no-ext-diff --quiet --exit-code || w="*" 417 git diff --no-ext-diff --quiet --exit-code || w="*"
402 if [ -n "$short_sha" ]; then 418 if [ -n "$short_sha" ]; then
403 git diff-index --cached --quiet HEAD -- || i="+" 419 git diff-index --cached --quiet HEAD -- || i="+"
404 else 420 else
405 i="#" 421 i="#"
406 fi 422 fi
407 fi 423 fi
408 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && 424 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
409 [ -r "$g/refs/stash" ]; then 425 [ -r "$g/refs/stash" ]; then
410 s="$" 426 s="$"
411 fi 427 fi
412 428
413 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && 429 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
414 [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && 430 [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
415 git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null 431 git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
416 then 432 then
417 u="%${ZSH_VERSION+%}" 433 u="%${ZSH_VERSION+%}"
418 fi 434 fi
419 435
420 if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then 436 if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
421 __git_ps1_show_upstream 437 __git_ps1_show_upstream
422 fi 438 fi
423 fi 439 fi
424 440
425 local z="${GIT_PS1_STATESEPARATOR-" "}" 441 local z="${GIT_PS1_STATESEPARATOR-" "}"
426 442
427 # NO color option unless in PROMPT_COMMAND mode 443 # NO color option unless in PROMPT_COMMAND mode
428 if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then 444 if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
429 __git_ps1_colorize_gitstring 445 __git_ps1_colorize_gitstring
430 fi 446 fi
431 447
432 local f="$w$i$s$u" 448 local f="$w$i$s$u"
433 local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p" 449 local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
434 450
435 if [ $pcmode = yes ]; then 451 if [ $pcmode = yes ]; then
436 if [[ -n ${ZSH_VERSION-} ]]; then 452 if [ "${__git_printf_supports_v-}" != yes ]; then
437 gitstring=$(printf -- "$printf_format" "$gitstring") 453 gitstring=$(printf -- "$printf_format" "$gitstring")
438 else 454 else
439 printf -v gitstring -- "$printf_format" "$gitstring" 455 printf -v gitstring -- "$printf_format" "$gitstring"
440 fi 456 fi
441 PS1="$ps1pc_start$gitstring$ps1pc_end" 457 PS1="$ps1pc_start$gitstring$ps1pc_end"
442 else 458 else
443 printf -- "$printf_format" "$gitstring" 459 printf -- "$printf_format" "$gitstring"
444 fi 460 fi
445 } 461 }
446 462
plugins/gradle/gradle.plugin.zsh
1 #!zsh 1 #!zsh
2 ############################################################################## 2 ##############################################################################
3 # A descriptive listing of core Gradle commands 3 # A descriptive listing of core Gradle commands
4 ############################################################################ 4 ############################################################################
5 function _gradle_core_commands() { 5 function _gradle_core_commands() {
6 local ret=1 state 6 local ret=1 state
7 _arguments ':subcommand:->subcommand' && ret=0 7 _arguments ':subcommand:->subcommand' && ret=0
8 8
9 case $state in 9 case $state in
10 subcommand) 10 subcommand)
11 subcommands=( 11 subcommands=(
12 "properties:Display all project properties" 12 "properties:Display all project properties"
13 "tasks:Calculate and display all tasks" 13 "tasks:Calculate and display all tasks"
14 "dependencies:Calculate and display all dependencies" 14 "dependencies:Calculate and display all dependencies"
15 "projects:Discover and display all sub-projects" 15 "projects:Discover and display all sub-projects"
16 "build:Build the project" 16 "build:Build the project"
17 "help:Display help" 17 "help:Display help"
18 ) 18 )
19 _describe -t subcommands 'gradle subcommands' subcommands && ret=0 19 _describe -t subcommands 'gradle subcommands' subcommands && ret=0
20 esac 20 esac
21 21
22 return ret 22 return ret
23 } 23 }
24 24
25 function _gradle_arguments() { 25 function _gradle_arguments() {
26 _arguments -C \ 26 _arguments -C \
27 '-a[Do not rebuild project dependencies]' \ 27 '-a[Do not rebuild project dependencies]' \
28 '-h[Help]' \ 28 '-h[Help]' \
29 '-D[System property]' \ 29 '-D[System property]' \
30 '-d[Log at the debug level]' \ 30 '-d[Log at the debug level]' \
31 '--gui[Launches the Gradle GUI app]' \ 31 '--gui[Launches the Gradle GUI app]' \
32 '--stop[Stop the Gradle daemon]' \ 32 '--stop[Stop the Gradle daemon]' \
33 '--daemon[Use the Gradle daemon]' \ 33 '--daemon[Use the Gradle daemon]' \
34 '--no-daemon[Do not use the Gradle daemon]' \ 34 '--no-daemon[Do not use the Gradle daemon]' \
35 '--no-opt[Do not perform any task optimization]' \ 35 '--no-opt[Do not perform any task optimization]' \
36 '-i[Log at the info level]' \ 36 '-i[Log at the info level]' \
37 '-m[Dry run]' \ 37 '-m[Dry run]' \
38 '-P[Set a project property]' \ 38 '-P[Set a project property]' \
39 '--profile[Profile the build time]' \ 39 '--profile[Profile the build time]' \
40 '-q[Log at the quiet level (only show errors)]' \ 40 '-q[Log at the quiet level (only show errors)]' \
41 '-v[Print the Gradle version info]' \ 41 '-v[Print the Gradle version info]' \
42 '-x[Specify a task to be excluded]' \ 42 '-x[Specify a task to be excluded]' \
43 '*::command:->command' \ 43 '*::command:->command' \
44 && return 0 44 && return 0
45 } 45 }
46 46
47 47
48 ############################################################################## 48 ##############################################################################
49 # Are we in a directory containing a build.gradle file? 49 # Are we in a directory containing a build.gradle file?
50 ############################################################################ 50 ############################################################################
51 function in_gradle() { 51 function in_gradle() {
52 if [[ -f build.gradle ]]; then 52 if [[ -f build.gradle ]]; then
53 echo 1 53 echo 1
54 fi 54 fi
55 } 55 }
56 56
57 ############################################################################## Examine the build.gradle file to see if its 57 ############################################################################## Examine the build.gradle file to see if its
58 # timestamp has changed, and if so, regen 58 # timestamp has changed, and if so, regen
59 # the .gradle_tasks cache file 59 # the .gradle_tasks cache file
60 ############################################################################ 60 ############################################################################
61 _gradle_does_task_list_need_generating () { 61 _gradle_does_task_list_need_generating () {
62 [ ! -f .gradletasknamecache ] && return 0; 62 [ ! -f .gradletasknamecache ] && return 0;
63 [ build.gradle -nt .gradletasknamecache ] && return 0; 63 [ build.gradle -nt .gradletasknamecache ] && return 0;
64 return 1; 64 return 1;
65 } 65 }
66 66
67 67
68 ############################################################################## 68 ##############################################################################
69 # Discover the gradle tasks by running "gradle tasks --all" 69 # Discover the gradle tasks by running "gradle tasks --all"
70 ############################################################################ 70 ############################################################################
71 _gradle_tasks () { 71 _gradle_tasks () {
72 if [ in_gradle ]; then 72 if [ in_gradle ]; then
73 _gradle_arguments 73 _gradle_arguments
74 if _gradle_does_task_list_need_generating; then 74 if _gradle_does_task_list_need_generating; then
75 gradle tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache 75 gradle tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
76 fi 76 fi
77 compadd -X "==== Gradle Tasks ====" `cat .gradletasknamecache` 77 compadd -X "==== Gradle Tasks ====" `cat .gradletasknamecache`
78 fi 78 fi
79 } 79 }
80 80
81 _gradlew_tasks () { 81 _gradlew_tasks () {
82 if [ in_gradle ]; then 82 if [ in_gradle ]; then
83 _gradle_arguments 83 _gradle_arguments
84 if _gradle_does_task_list_need_generating; then 84 if _gradle_does_task_list_need_generating; then
85 gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache 85 gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
86 fi 86 fi
87 compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache` 87 compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache`
88 fi 88 fi
89 } 89 }
90 90
91 91
92 ############################################################################## 92 ##############################################################################
93 # Register the completions against the gradle and gradlew commands 93 # Register the completions against the gradle and gradlew commands
94 ############################################################################ 94 ############################################################################
95 compdef _gradle_tasks gradle 95 compdef _gradle_tasks gradle
96 compdef _gradlew_tasks gradlew 96 compdef _gradlew_tasks gradlew
97 97
98 98
99 ############################################################################## 99 ##############################################################################
100 # Open questions for future improvements: 100 # Open questions for future improvements:
101 # 1) Should 'gradle tasks' use --all or just the regular set? 101 # 1) Should 'gradle tasks' use --all or just the regular set?
102 # 2) Should gradlew use the same approach as gradle? 102 # 2) Should gradlew use the same approach as gradle?
103 # 3) Should only the " - " be replaced with a colon so it can work 103 # 3) Should only the " - " be replaced with a colon so it can work
104 # with the richer descriptive method of _arguments? 104 # with the richer descriptive method of _arguments?
105 # gradle tasks | grep "^[a-zA-Z0-9]*\ -\ " | sed "s/ - /\:/" 105 # gradle tasks | grep "^[a-zA-Z0-9]*\ -\ " | sed "s/ - /\:/"
106 ############################################################################# 106 #############################################################################
107 107
plugins/history-substring-search/README.markdown
1 To activate this script, please include it the `plugins` variable within `~/.zshrc` 1 To activate this script, please include it the `plugins` variable within `~/.zshrc`
2 2
3 `plugins=(git history-substring-search.zsh)` 3 `plugins=(git history-substring-search)`
4 4
5 See the "history-substring-search.zsh" file for more information: 5 See the "history-substring-search.zsh" file for more information:
6 6
7 `sed -n '2,/^$/s/^#//p' history-substring-search.zsh | more` 7 `sed -n '2,/^$/s/^#//p' history-substring-search.zsh | more`
8 8
plugins/history-substring-search/history-substring-search.zsh
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 # 2 #
3 # This is a clean-room implementation of the Fish[1] shell's history search 3 # This is a clean-room implementation of the Fish[1] shell's history search
4 # feature, where you can type in any part of any previously entered command 4 # feature, where you can type in any part of any previously entered command
5 # and press the UP and DOWN arrow keys to cycle through the matching commands. 5 # and press the UP and DOWN arrow keys to cycle through the matching commands.
6 # 6 #
7 #----------------------------------------------------------------------------- 7 #-----------------------------------------------------------------------------
8 # Usage 8 # Usage
9 #----------------------------------------------------------------------------- 9 #-----------------------------------------------------------------------------
10 # 10 #
11 # 1. Load this script into your interactive ZSH session: 11 # 1. Load this script into your interactive ZSH session:
12 # 12 #
13 # % source history-substring-search.zsh 13 # % source history-substring-search.zsh
14 # 14 #
15 # If you want to use the zsh-syntax-highlighting[6] script along with this 15 # If you want to use the zsh-syntax-highlighting[6] script along with this
16 # script, then make sure that you load it *before* you load this script: 16 # script, then make sure that you load it *before* you load this script:
17 # 17 #
18 # % source zsh-syntax-highlighting.zsh 18 # % source zsh-syntax-highlighting.zsh
19 # % source history-substring-search.zsh 19 # % source history-substring-search.zsh
20 # 20 #
21 # 2. Type any part of any previous command and then: 21 # 2. Type any part of any previous command and then:
22 # 22 #
23 # * Press the UP arrow key to select the nearest command that (1) contains 23 # * Press the UP arrow key to select the nearest command that (1) contains
24 # your query and (2) is older than the current command in the command 24 # your query and (2) is older than the current command in the command
25 # history. 25 # history.
26 # 26 #
27 # * Press the DOWN arrow key to select the nearest command that (1) 27 # * Press the DOWN arrow key to select the nearest command that (1)
28 # contains your query and (2) is newer than the current command in the 28 # contains your query and (2) is newer than the current command in the
29 # command history. 29 # command history.
30 # 30 #
31 # * Press ^U (the Control and U keys simultaneously) to abort the search. 31 # * Press ^U (the Control and U keys simultaneously) to abort the search.
32 # 32 #
33 # 3. If a matching command spans more than one line of text, press the LEFT 33 # 3. If a matching command spans more than one line of text, press the LEFT
34 # arrow key to move the cursor away from the end of the command, and then: 34 # arrow key to move the cursor away from the end of the command, and then:
35 # 35 #
36 # * Press the UP arrow key to move the cursor to the line above. When the 36 # * Press the UP arrow key to move the cursor to the line above. When the
37 # cursor reaches the first line of the command, pressing the UP arrow 37 # cursor reaches the first line of the command, pressing the UP arrow
38 # key again will cause this script to perform another search. 38 # key again will cause this script to perform another search.
39 # 39 #
40 # * Press the DOWN arrow key to move the cursor to the line below. When 40 # * Press the DOWN arrow key to move the cursor to the line below. When
41 # the cursor reaches the last line of the command, pressing the DOWN 41 # the cursor reaches the last line of the command, pressing the DOWN
42 # arrow key again will cause this script to perform another search. 42 # arrow key again will cause this script to perform another search.
43 # 43 #
44 #----------------------------------------------------------------------------- 44 #-----------------------------------------------------------------------------
45 # Configuration 45 # Configuration
46 #----------------------------------------------------------------------------- 46 #-----------------------------------------------------------------------------
47 # 47 #
48 # This script defines the following global variables. You may override their 48 # This script defines the following global variables. You may override their
49 # default values only after having loaded this script into your ZSH session. 49 # default values only after having loaded this script into your ZSH session.
50 # 50 #
51 # * HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND is a global variable that defines 51 # * HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND is a global variable that defines
52 # how the query should be highlighted inside a matching command. Its default 52 # how the query should be highlighted inside a matching command. Its default
53 # value causes this script to highlight using bold, white text on a magenta 53 # value causes this script to highlight using bold, white text on a magenta
54 # background. See the "Character Highlighting" section in the zshzle(1) man 54 # background. See the "Character Highlighting" section in the zshzle(1) man
55 # page to learn about the kinds of values you may assign to this variable. 55 # page to learn about the kinds of values you may assign to this variable.
56 # 56 #
57 # * HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND is a global variable that 57 # * HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND is a global variable that
58 # defines how the query should be highlighted when no commands in the 58 # defines how the query should be highlighted when no commands in the
59 # history match it. Its default value causes this script to highlight using 59 # history match it. Its default value causes this script to highlight using
60 # bold, white text on a red background. See the "Character Highlighting" 60 # bold, white text on a red background. See the "Character Highlighting"
61 # section in the zshzle(1) man page to learn about the kinds of values you 61 # section in the zshzle(1) man page to learn about the kinds of values you
62 # may assign to this variable. 62 # may assign to this variable.
63 # 63 #
64 # * HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS is a global variable that defines 64 # * HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS is a global variable that defines
65 # how the command history will be searched for your query. Its default value 65 # how the command history will be searched for your query. Its default value
66 # causes this script to perform a case-insensitive search. See the "Globbing 66 # causes this script to perform a case-insensitive search. See the "Globbing
67 # Flags" section in the zshexpn(1) man page to learn about the kinds of 67 # Flags" section in the zshexpn(1) man page to learn about the kinds of
68 # values you may assign to this variable. 68 # values you may assign to this variable.
69 # 69 #
70 #----------------------------------------------------------------------------- 70 #-----------------------------------------------------------------------------
71 # History 71 # History
72 #----------------------------------------------------------------------------- 72 #-----------------------------------------------------------------------------
73 # 73 #
74 # This script was originally written by Peter Stephenson[2], who published it 74 # This script was originally written by Peter Stephenson[2], who published it
75 # to the ZSH users mailing list (thereby making it public domain) in September 75 # to the ZSH users mailing list (thereby making it public domain) in September
76 # 2009. It was later revised by Guido van Steen and released under the BSD 76 # 2009. It was later revised by Guido van Steen and released under the BSD
77 # license (see below) as part of the fizsh[3] project in January 2011. 77 # license (see below) as part of the fizsh[3] project in January 2011.
78 # 78 #
79 # It was later extracted from fizsh[3] release 1.0.1, refactored heavily, and 79 # It was later extracted from fizsh[3] release 1.0.1, refactored heavily, and
80 # repackaged as both an oh-my-zsh plugin[4] and as an independently loadable 80 # repackaged as both an oh-my-zsh plugin[4] and as an independently loadable
81 # ZSH script[5] by Suraj N. Kurapati in 2011. 81 # ZSH script[5] by Suraj N. Kurapati in 2011.
82 # 82 #
83 # It was further developed[4] by Guido van Steen, Suraj N. Kurapati, Sorin 83 # It was further developed[4] by Guido van Steen, Suraj N. Kurapati, Sorin
84 # Ionescu, and Vincent Guerci in 2011. 84 # Ionescu, and Vincent Guerci in 2011.
85 # 85 #
86 # [1]: http://fishshell.com 86 # [1]: http://fishshell.com
87 # [2]: http://www.zsh.org/mla/users/2009/msg00818.html 87 # [2]: http://www.zsh.org/mla/users/2009/msg00818.html
88 # [3]: http://sourceforge.net/projects/fizsh/ 88 # [3]: http://sourceforge.net/projects/fizsh/
89 # [4]: https://github.com/robbyrussell/oh-my-zsh/pull/215 89 # [4]: https://github.com/robbyrussell/oh-my-zsh/pull/215
90 # [5]: https://github.com/sunaku/zsh-history-substring-search 90 # [5]: https://github.com/sunaku/zsh-history-substring-search
91 # [6]: https://github.com/nicoulaj/zsh-syntax-highlighting 91 # [6]: https://github.com/nicoulaj/zsh-syntax-highlighting
92 # 92 #
93 ############################################################################## 93 ##############################################################################
94 # 94 #
95 # Copyright (c) 2009 Peter Stephenson 95 # Copyright (c) 2009 Peter Stephenson
96 # Copyright (c) 2011 Guido van Steen 96 # Copyright (c) 2011 Guido van Steen
97 # Copyright (c) 2011 Suraj N. Kurapati 97 # Copyright (c) 2011 Suraj N. Kurapati
98 # Copyright (c) 2011 Sorin Ionescu 98 # Copyright (c) 2011 Sorin Ionescu
99 # Copyright (c) 2011 Vincent Guerci 99 # Copyright (c) 2011 Vincent Guerci
100 # All rights reserved. 100 # All rights reserved.
101 # 101 #
102 # Redistribution and use in source and binary forms, with or without 102 # Redistribution and use in source and binary forms, with or without
103 # modification, are permitted provided that the following conditions are met: 103 # modification, are permitted provided that the following conditions are met:
104 # 104 #
105 # * Redistributions of source code must retain the above copyright 105 # * Redistributions of source code must retain the above copyright
106 # notice, this list of conditions and the following disclaimer. 106 # notice, this list of conditions and the following disclaimer.
107 # 107 #
108 # * Redistributions in binary form must reproduce the above 108 # * Redistributions in binary form must reproduce the above
109 # copyright notice, this list of conditions and the following 109 # copyright notice, this list of conditions and the following
110 # disclaimer in the documentation and/or other materials provided 110 # disclaimer in the documentation and/or other materials provided
111 # with the distribution. 111 # with the distribution.
112 # 112 #
113 # * Neither the name of the FIZSH nor the names of its contributors 113 # * Neither the name of the FIZSH nor the names of its contributors
114 # may be used to endorse or promote products derived from this 114 # may be used to endorse or promote products derived from this
115 # software without specific prior written permission. 115 # software without specific prior written permission.
116 # 116 #
117 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 117 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
118 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 118 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
119 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 119 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
120 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 120 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
121 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 121 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
122 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 122 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
123 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 123 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
124 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 124 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
125 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 125 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
126 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 126 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
127 # POSSIBILITY OF SUCH DAMAGE. 127 # POSSIBILITY OF SUCH DAMAGE.
128 # 128 #
129 ############################################################################## 129 ##############################################################################
130 130
131 #----------------------------------------------------------------------------- 131 #-----------------------------------------------------------------------------
132 # configuration variables 132 # configuration variables
133 #----------------------------------------------------------------------------- 133 #-----------------------------------------------------------------------------
134 134
135 HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' 135 HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
136 HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' 136 HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
137 HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' 137 HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
138 138
139 #----------------------------------------------------------------------------- 139 #-----------------------------------------------------------------------------
140 # the main ZLE widgets 140 # the main ZLE widgets
141 #----------------------------------------------------------------------------- 141 #-----------------------------------------------------------------------------
142 142
143 function history-substring-search-up() { 143 function history-substring-search-up() {
144 _history-substring-search-begin 144 _history-substring-search-begin
145 145
146 _history-substring-search-up-history || 146 _history-substring-search-up-history ||
147 _history-substring-search-up-buffer || 147 _history-substring-search-up-buffer ||
148 _history-substring-search-up-search 148 _history-substring-search-up-search
149 149
150 _history-substring-search-end 150 _history-substring-search-end
151 } 151 }
152 152
153 function history-substring-search-down() { 153 function history-substring-search-down() {
154 _history-substring-search-begin 154 _history-substring-search-begin
155 155
156 _history-substring-search-down-history || 156 _history-substring-search-down-history ||
157 _history-substring-search-down-buffer || 157 _history-substring-search-down-buffer ||
158 _history-substring-search-down-search 158 _history-substring-search-down-search
159 159
160 _history-substring-search-end 160 _history-substring-search-end
161 } 161 }
162 162
163 zle -N history-substring-search-up 163 zle -N history-substring-search-up
164 zle -N history-substring-search-down 164 zle -N history-substring-search-down
165 165
166 zmodload zsh/terminfo 166 zmodload zsh/terminfo
167 if [[ -n "$terminfo[kcuu1]" ]]; then 167 if [[ -n "$terminfo[kcuu1]" ]]; then
168 bindkey "$terminfo[kcuu1]" history-substring-search-up 168 bindkey "$terminfo[kcuu1]" history-substring-search-up
169 fi 169 fi
170 if [[ -n "$terminfo[kcud1]" ]]; then 170 if [[ -n "$terminfo[kcud1]" ]]; then
171 bindkey "$terminfo[kcud1]" history-substring-search-down 171 bindkey "$terminfo[kcud1]" history-substring-search-down
172 fi 172 fi
173 173
174 #----------------------------------------------------------------------------- 174 #-----------------------------------------------------------------------------
175 # implementation details 175 # implementation details
176 #----------------------------------------------------------------------------- 176 #-----------------------------------------------------------------------------
177 177
178 setopt extendedglob
179 zmodload -F zsh/parameter 178 zmodload -F zsh/parameter
180 179
181 # 180 #
182 # We have to "override" some keys and widgets if the 181 # We have to "override" some keys and widgets if the
183 # zsh-syntax-highlighting plugin has not been loaded: 182 # zsh-syntax-highlighting plugin has not been loaded:
184 # 183 #
185 # https://github.com/nicoulaj/zsh-syntax-highlighting 184 # https://github.com/nicoulaj/zsh-syntax-highlighting
186 # 185 #
187 if [[ $+functions[_zsh_highlight] -eq 0 ]]; then 186 if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
188 # 187 #
189 # Dummy implementation of _zsh_highlight() 188 # Dummy implementation of _zsh_highlight()
190 # that simply removes existing highlights 189 # that simply removes existing highlights
191 # 190 #
192 function _zsh_highlight() { 191 function _zsh_highlight() {
193 region_highlight=() 192 region_highlight=()
194 } 193 }
195 194
196 # 195 #
197 # Remove existing highlights when the user 196 # Remove existing highlights when the user
198 # inserts printable characters into $BUFFER 197 # inserts printable characters into $BUFFER
199 # 198 #
200 function ordinary-key-press() { 199 function ordinary-key-press() {
201 if [[ $KEYS == [[:print:]] ]]; then 200 if [[ $KEYS == [[:print:]] ]]; then
202 region_highlight=() 201 region_highlight=()
203 fi 202 fi
204 zle .self-insert 203 zle .self-insert
205 } 204 }
206 zle -N self-insert ordinary-key-press 205 zle -N self-insert ordinary-key-press
207 206
208 # 207 #
209 # Override ZLE widgets to invoke _zsh_highlight() 208 # Override ZLE widgets to invoke _zsh_highlight()
210 # 209 #
211 # https://github.com/nicoulaj/zsh-syntax-highlighting/blob/ 210 # https://github.com/nicoulaj/zsh-syntax-highlighting/blob/
212 # bb7fcb79fad797a40077bebaf6f4e4a93c9d8163/zsh-syntax-highlighting.zsh#L121 211 # bb7fcb79fad797a40077bebaf6f4e4a93c9d8163/zsh-syntax-highlighting.zsh#L121
213 # 212 #
214 #--------------8<-------------------8<-------------------8<----------------- 213 #--------------8<-------------------8<-------------------8<-----------------
215 # 214 #
216 # Copyright (c) 2010-2011 zsh-syntax-highlighting contributors 215 # Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
217 # All rights reserved. 216 # All rights reserved.
218 # 217 #
219 # Redistribution and use in source and binary forms, with or without 218 # Redistribution and use in source and binary forms, with or without
220 # modification, are permitted provided that the following conditions are 219 # modification, are permitted provided that the following conditions are
221 # met: 220 # met:
222 # 221 #
223 # * Redistributions of source code must retain the above copyright 222 # * Redistributions of source code must retain the above copyright
224 # notice, this list of conditions and the following disclaimer. 223 # notice, this list of conditions and the following disclaimer.
225 # 224 #
226 # * Redistributions in binary form must reproduce the above copyright 225 # * Redistributions in binary form must reproduce the above copyright
227 # notice, this list of conditions and the following disclaimer in the 226 # notice, this list of conditions and the following disclaimer in the
228 # documentation and/or other materials provided with the distribution. 227 # documentation and/or other materials provided with the distribution.
229 # 228 #
230 # * Neither the name of the zsh-syntax-highlighting contributors nor the 229 # * Neither the name of the zsh-syntax-highlighting contributors nor the
231 # names of its contributors may be used to endorse or promote products 230 # names of its contributors may be used to endorse or promote products
232 # derived from this software without specific prior written permission. 231 # derived from this software without specific prior written permission.
233 # 232 #
234 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 233 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
235 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 234 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
236 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 235 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
237 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 236 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
238 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 237 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
239 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 238 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
240 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 239 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
241 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 240 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
242 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 241 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
243 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 242 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
244 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 243 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
245 244
246 # Load ZSH module zsh/zleparameter, needed to override user defined widgets. 245 # Load ZSH module zsh/zleparameter, needed to override user defined widgets.
247 zmodload zsh/zleparameter 2>/dev/null || { 246 zmodload zsh/zleparameter 2>/dev/null || {
248 echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter, exiting.' >&2 247 echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter, exiting.' >&2
249 return -1 248 return -1
250 } 249 }
251 250
252 # Override ZLE widgets to make them invoke _zsh_highlight. 251 # Override ZLE widgets to make them invoke _zsh_highlight.
253 for event in ${${(f)"$(zle -la)"}:#(_*|orig-*|.run-help|.which-command)}; do 252 for event in ${${(f)"$(zle -la)"}:#(_*|orig-*|.run-help|.which-command)}; do
254 if [[ "$widgets[$event]" == completion:* ]]; then 253 if [[ "$widgets[$event]" == completion:* ]]; then
255 eval "zle -C orig-$event ${${${widgets[$event]}#*:}/:/ } ; $event() { builtin zle orig-$event && _zsh_highlight } ; zle -N $event" 254 eval "zle -C orig-$event ${${${widgets[$event]}#*:}/:/ } ; $event() { builtin zle orig-$event && _zsh_highlight } ; zle -N $event"
256 else 255 else
257 case $event in 256 case $event in
258 accept-and-menu-complete) 257 accept-and-menu-complete)
259 eval "$event() { builtin zle .$event && _zsh_highlight } ; zle -N $event" 258 eval "$event() { builtin zle .$event && _zsh_highlight } ; zle -N $event"
260 ;; 259 ;;
261 260
262 # The following widgets should NOT remove any previously 261 # The following widgets should NOT remove any previously
263 # applied highlighting. Therefore we do not remap them. 262 # applied highlighting. Therefore we do not remap them.
264 .forward-char|.backward-char|.up-line-or-history|.down-line-or-history) 263 .forward-char|.backward-char|.up-line-or-history|.down-line-or-history)
265 ;; 264 ;;
266 265
267 .*) 266 .*)
268 clean_event=$event[2,${#event}] # Remove the leading dot in the event name 267 clean_event=$event[2,${#event}] # Remove the leading dot in the event name
269 case ${widgets[$clean_event]-} in 268 case ${widgets[$clean_event]-} in
270 (completion|user):*) 269 (completion|user):*)
271 ;; 270 ;;
272 *) 271 *)
273 eval "$clean_event() { builtin zle $event && _zsh_highlight } ; zle -N $clean_event" 272 eval "$clean_event() { builtin zle $event && _zsh_highlight } ; zle -N $clean_event"
274 ;; 273 ;;
275 esac 274 esac
276 ;; 275 ;;
277 *) 276 *)
278 ;; 277 ;;
279 esac 278 esac
280 fi 279 fi
281 done 280 done
282 unset event clean_event 281 unset event clean_event
283 #-------------->8------------------->8------------------->8----------------- 282 #-------------->8------------------->8------------------->8-----------------
284 fi 283 fi
285 284
286 function _history-substring-search-begin() { 285 function _history-substring-search-begin() {
286 setopt localoptions extendedglob
287 _history_substring_search_move_cursor_eol=false 287 _history_substring_search_move_cursor_eol=false
288 _history_substring_search_query_highlight= 288 _history_substring_search_query_highlight=
289 289
290 # 290 #
291 # Continue using the previous $_history_substring_search_result by default, 291 # Continue using the previous $_history_substring_search_result by default,
292 # unless the current query was cleared or a new/different query was entered. 292 # unless the current query was cleared or a new/different query was entered.
293 # 293 #
294 if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then 294 if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then
295 # 295 #
296 # For the purpose of highlighting we will also keep 296 # For the purpose of highlighting we will also keep
297 # a version without doubly-escaped meta characters. 297 # a version without doubly-escaped meta characters.
298 # 298 #
299 _history_substring_search_query=$BUFFER 299 _history_substring_search_query=$BUFFER
300 300
301 # 301 #
302 # $BUFFER contains the text that is in the command-line currently. 302 # $BUFFER contains the text that is in the command-line currently.
303 # we put an extra "\\" before meta characters such as "\(" and "\)", 303 # we put an extra "\\" before meta characters such as "\(" and "\)",
304 # so that they become "\\\(" and "\\\)". 304 # so that they become "\\\(" and "\\\)".
305 # 305 #
306 _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH} 306 _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH}
307 307
308 # 308 #
309 # Find all occurrences of the search query in the history file. 309 # Find all occurrences of the search query in the history file.
310 # 310 #
311 # (k) turns it an array of line numbers. 311 # (k) turns it an array of line numbers.
312 # 312 #
313 # (on) seems to remove duplicates, which are default 313 # (on) seems to remove duplicates, which are default
314 # options. They can be turned off by (ON). 314 # options. They can be turned off by (ON).
315 # 315 #
316 _history_substring_search_matches=(${(kon)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]}) 316 _history_substring_search_matches=(${(kon)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})
317 317
318 # 318 #
319 # Define the range of values that $_history_substring_search_match_index 319 # Define the range of values that $_history_substring_search_match_index
320 # can take: [0, $_history_substring_search_matches_count_plus]. 320 # can take: [0, $_history_substring_search_matches_count_plus].
321 # 321 #
322 _history_substring_search_matches_count=$#_history_substring_search_matches 322 _history_substring_search_matches_count=$#_history_substring_search_matches
323 _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 )) 323 _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 ))
324 _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 )) 324 _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 ))
325 325
326 # 326 #
327 # If $_history_substring_search_match_index is equal to 327 # If $_history_substring_search_match_index is equal to
328 # $_history_substring_search_matches_count_plus, this indicates that we 328 # $_history_substring_search_matches_count_plus, this indicates that we
329 # are beyond the beginning of $_history_substring_search_matches. 329 # are beyond the beginning of $_history_substring_search_matches.
330 # 330 #
331 # If $_history_substring_search_match_index is equal to 0, this indicates 331 # If $_history_substring_search_match_index is equal to 0, this indicates
332 # that we are beyond the end of $_history_substring_search_matches. 332 # that we are beyond the end of $_history_substring_search_matches.
333 # 333 #
334 # If we have initially pressed "up" we have to initialize 334 # If we have initially pressed "up" we have to initialize
335 # $_history_substring_search_match_index to 335 # $_history_substring_search_match_index to
336 # $_history_substring_search_matches_count_plus so that it will be 336 # $_history_substring_search_matches_count_plus so that it will be
337 # decreased to $_history_substring_search_matches_count. 337 # decreased to $_history_substring_search_matches_count.
338 # 338 #
339 # If we have initially pressed "down" we have to initialize 339 # If we have initially pressed "down" we have to initialize
340 # $_history_substring_search_match_index to 340 # $_history_substring_search_match_index to
341 # $_history_substring_search_matches_count so that it will be increased to 341 # $_history_substring_search_matches_count so that it will be increased to
342 # $_history_substring_search_matches_count_plus. 342 # $_history_substring_search_matches_count_plus.
343 # 343 #
344 if [[ $WIDGET == history-substring-search-down ]]; then 344 if [[ $WIDGET == history-substring-search-down ]]; then
345 _history_substring_search_match_index=$_history_substring_search_matches_count 345 _history_substring_search_match_index=$_history_substring_search_matches_count
346 else 346 else
347 _history_substring_search_match_index=$_history_substring_search_matches_count_plus 347 _history_substring_search_match_index=$_history_substring_search_matches_count_plus
348 fi 348 fi
349 fi 349 fi
350 } 350 }
351 351
352 function _history-substring-search-end() { 352 function _history-substring-search-end() {
353 setopt localoptions extendedglob
353 _history_substring_search_result=$BUFFER 354 _history_substring_search_result=$BUFFER
354 355
355 # move the cursor to the end of the command line 356 # move the cursor to the end of the command line
356 if [[ $_history_substring_search_move_cursor_eol == true ]]; then 357 if [[ $_history_substring_search_move_cursor_eol == true ]]; then
357 CURSOR=${#BUFFER} 358 CURSOR=${#BUFFER}
358 fi 359 fi
359 360
360 # highlight command line using zsh-syntax-highlighting 361 # highlight command line using zsh-syntax-highlighting
361 _zsh_highlight 362 _zsh_highlight
362 363
363 # highlight the search query inside the command line 364 # highlight the search query inside the command line
364 if [[ -n $_history_substring_search_query_highlight && -n $_history_substring_search_query ]]; then 365 if [[ -n $_history_substring_search_query_highlight && -n $_history_substring_search_query ]]; then
365 # 366 #
366 # The following expression yields a variable $MBEGIN, which 367 # The following expression yields a variable $MBEGIN, which
367 # indicates the begin position + 1 of the first occurrence 368 # indicates the begin position + 1 of the first occurrence
368 # of _history_substring_search_query_escaped in $BUFFER. 369 # of _history_substring_search_query_escaped in $BUFFER.
369 # 370 #
370 : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)} 371 : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)}
371 local begin=$(( MBEGIN - 1 )) 372 local begin=$(( MBEGIN - 1 ))
372 local end=$(( begin + $#_history_substring_search_query )) 373 local end=$(( begin + $#_history_substring_search_query ))
373 region_highlight+=("$begin $end $_history_substring_search_query_highlight") 374 region_highlight+=("$begin $end $_history_substring_search_query_highlight")
374 fi 375 fi
375 376
376 # For debugging purposes: 377 # For debugging purposes:
377 # zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches} 378 # zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches}
378 # read -k -t 200 && zle -U $REPLY 379 # read -k -t 200 && zle -U $REPLY
379 380
380 # Exit successfully from the history-substring-search-* widgets. 381 # Exit successfully from the history-substring-search-* widgets.
381 true 382 true
382 } 383 }
383 384
384 function _history-substring-search-up-buffer() { 385 function _history-substring-search-up-buffer() {
385 # 386 #
386 # Check if the UP arrow was pressed to move the cursor within a multi-line 387 # Check if the UP arrow was pressed to move the cursor within a multi-line
387 # buffer. This amounts to three tests: 388 # buffer. This amounts to three tests:
388 # 389 #
389 # 1. $#buflines -gt 1. 390 # 1. $#buflines -gt 1.
390 # 391 #
391 # 2. $CURSOR -ne $#BUFFER. 392 # 2. $CURSOR -ne $#BUFFER.
392 # 393 #
393 # 3. Check if we are on the first line of the current multi-line buffer. 394 # 3. Check if we are on the first line of the current multi-line buffer.
394 # If so, pressing UP would amount to leaving the multi-line buffer. 395 # If so, pressing UP would amount to leaving the multi-line buffer.
395 # 396 #
396 # We check this by adding an extra "x" to $LBUFFER, which makes 397 # We check this by adding an extra "x" to $LBUFFER, which makes
397 # sure that xlbuflines is always equal to the number of lines 398 # sure that xlbuflines is always equal to the number of lines
398 # until $CURSOR (including the line with the cursor on it). 399 # until $CURSOR (including the line with the cursor on it).
399 # 400 #
400 local buflines XLBUFFER xlbuflines 401 local buflines XLBUFFER xlbuflines
401 buflines=(${(f)BUFFER}) 402 buflines=(${(f)BUFFER})
402 XLBUFFER=$LBUFFER"x" 403 XLBUFFER=$LBUFFER"x"
403 xlbuflines=(${(f)XLBUFFER}) 404 xlbuflines=(${(f)XLBUFFER})
404 405
405 if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xlbuflines -ne 1 ]]; then 406 if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xlbuflines -ne 1 ]]; then
406 zle up-line-or-history 407 zle up-line-or-history
407 return true 408 return true
408 fi 409 fi
409 410
410 false 411 false
411 } 412 }
412 413
413 function _history-substring-search-down-buffer() { 414 function _history-substring-search-down-buffer() {
414 # 415 #
415 # Check if the DOWN arrow was pressed to move the cursor within a multi-line 416 # Check if the DOWN arrow was pressed to move the cursor within a multi-line
416 # buffer. This amounts to three tests: 417 # buffer. This amounts to three tests:
417 # 418 #
418 # 1. $#buflines -gt 1. 419 # 1. $#buflines -gt 1.
419 # 420 #
420 # 2. $CURSOR -ne $#BUFFER. 421 # 2. $CURSOR -ne $#BUFFER.
421 # 422 #
422 # 3. Check if we are on the last line of the current multi-line buffer. 423 # 3. Check if we are on the last line of the current multi-line buffer.
423 # If so, pressing DOWN would amount to leaving the multi-line buffer. 424 # If so, pressing DOWN would amount to leaving the multi-line buffer.
424 # 425 #
425 # We check this by adding an extra "x" to $RBUFFER, which makes 426 # We check this by adding an extra "x" to $RBUFFER, which makes
426 # sure that xrbuflines is always equal to the number of lines 427 # sure that xrbuflines is always equal to the number of lines
427 # from $CURSOR (including the line with the cursor on it). 428 # from $CURSOR (including the line with the cursor on it).
428 # 429 #
429 local buflines XRBUFFER xrbuflines 430 local buflines XRBUFFER xrbuflines
430 buflines=(${(f)BUFFER}) 431 buflines=(${(f)BUFFER})
431 XRBUFFER="x"$RBUFFER 432 XRBUFFER="x"$RBUFFER
432 xrbuflines=(${(f)XRBUFFER}) 433 xrbuflines=(${(f)XRBUFFER})
433 434
434 if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xrbuflines -ne 1 ]]; then 435 if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xrbuflines -ne 1 ]]; then
435 zle down-line-or-history 436 zle down-line-or-history
436 return true 437 return true
437 fi 438 fi
438 439
439 false 440 false
440 } 441 }
441 442
442 function _history-substring-search-up-history() { 443 function _history-substring-search-up-history() {
443 # 444 #
444 # Behave like up in ZSH, except clear the $BUFFER 445 # Behave like up in ZSH, except clear the $BUFFER
445 # when beginning of history is reached like in Fish. 446 # when beginning of history is reached like in Fish.
446 # 447 #
447 if [[ -z $_history_substring_search_query ]]; then 448 if [[ -z $_history_substring_search_query ]]; then
448 449
449 # we have reached the absolute top of history 450 # we have reached the absolute top of history
450 if [[ $HISTNO -eq 1 ]]; then 451 if [[ $HISTNO -eq 1 ]]; then
451 BUFFER= 452 BUFFER=
452 453
453 # going up from somewhere below the top of history 454 # going up from somewhere below the top of history
454 else 455 else
455 zle up-history 456 zle up-history
456 fi 457 fi
457 458
458 return true 459 return true
459 fi 460 fi
460 461
461 false 462 false
462 } 463 }
463 464
464 function _history-substring-search-down-history() { 465 function _history-substring-search-down-history() {
465 # 466 #
466 # Behave like down-history in ZSH, except clear the 467 # Behave like down-history in ZSH, except clear the
467 # $BUFFER when end of history is reached like in Fish. 468 # $BUFFER when end of history is reached like in Fish.
468 # 469 #
469 if [[ -z $_history_substring_search_query ]]; then 470 if [[ -z $_history_substring_search_query ]]; then
470 471
471 # going down from the absolute top of history 472 # going down from the absolute top of history
472 if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then 473 if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then
473 BUFFER=${history[1]} 474 BUFFER=${history[1]}
474 _history_substring_search_move_cursor_eol=true 475 _history_substring_search_move_cursor_eol=true
475 476
476 # going down from somewhere above the bottom of history 477 # going down from somewhere above the bottom of history
477 else 478 else
478 zle down-history 479 zle down-history
479 fi 480 fi
480 481
481 return true 482 return true
482 fi 483 fi
483 484
484 false 485 false
485 } 486 }
486 487
487 function _history-substring-search-up-search() { 488 function _history-substring-search-up-search() {
488 _history_substring_search_move_cursor_eol=true 489 _history_substring_search_move_cursor_eol=true
489 490
490 # 491 #
491 # Highlight matches during history-substring-up-search: 492 # Highlight matches during history-substring-up-search:
492 # 493 #
493 # The following constants have been initialized in 494 # The following constants have been initialized in
494 # _history-substring-search-up/down-search(): 495 # _history-substring-search-up/down-search():
495 # 496 #
496 # $_history_substring_search_matches is the current list of matches 497 # $_history_substring_search_matches is the current list of matches
497 # $_history_substring_search_matches_count is the current number of matches 498 # $_history_substring_search_matches_count is the current number of matches
498 # $_history_substring_search_matches_count_plus is the current number of matches + 1 499 # $_history_substring_search_matches_count_plus is the current number of matches + 1
499 # $_history_substring_search_matches_count_sans is the current number of matches - 1 500 # $_history_substring_search_matches_count_sans is the current number of matches - 1
500 # $_history_substring_search_match_index is the index of the current match 501 # $_history_substring_search_match_index is the index of the current match
501 # 502 #
502 # The range of values that $_history_substring_search_match_index can take 503 # The range of values that $_history_substring_search_match_index can take
503 # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 504 # is: [0, $_history_substring_search_matches_count_plus]. A value of 0
504 # indicates that we are beyond the end of 505 # indicates that we are beyond the end of
505 # $_history_substring_search_matches. A value of 506 # $_history_substring_search_matches. A value of
506 # $_history_substring_search_matches_count_plus indicates that we are beyond 507 # $_history_substring_search_matches_count_plus indicates that we are beyond
507 # the beginning of $_history_substring_search_matches. 508 # the beginning of $_history_substring_search_matches.
508 # 509 #
509 # In _history-substring-search-up-search() the initial value of 510 # In _history-substring-search-up-search() the initial value of
510 # $_history_substring_search_match_index is 511 # $_history_substring_search_match_index is
511 # $_history_substring_search_matches_count_plus. This value is set in 512 # $_history_substring_search_matches_count_plus. This value is set in
512 # _history-substring-search-begin(). _history-substring-search-up-search() 513 # _history-substring-search-begin(). _history-substring-search-up-search()
513 # will initially decrease it to $_history_substring_search_matches_count. 514 # will initially decrease it to $_history_substring_search_matches_count.
514 # 515 #
515 if [[ $_history_substring_search_match_index -ge 2 ]]; then 516 if [[ $_history_substring_search_match_index -ge 2 ]]; then
516 # 517 #
517 # Highlight the next match: 518 # Highlight the next match:
518 # 519 #
519 # 1. Decrease the value of $_history_substring_search_match_index. 520 # 1. Decrease the value of $_history_substring_search_match_index.
520 # 521 #
521 # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 522 # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
522 # to highlight the current buffer. 523 # to highlight the current buffer.
523 # 524 #
524 (( _history_substring_search_match_index-- )) 525 (( _history_substring_search_match_index-- ))
525 BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] 526 BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
526 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 527 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
527 528
528 elif [[ $_history_substring_search_match_index -eq 1 ]]; then 529 elif [[ $_history_substring_search_match_index -eq 1 ]]; then
529 # 530 #
530 # We will move beyond the end of $_history_substring_search_matches: 531 # We will move beyond the end of $_history_substring_search_matches:
531 # 532 #
532 # 1. Decrease the value of $_history_substring_search_match_index. 533 # 1. Decrease the value of $_history_substring_search_match_index.
533 # 534 #
534 # 2. Save the current buffer in $_history_substring_search_old_buffer, 535 # 2. Save the current buffer in $_history_substring_search_old_buffer,
535 # so that it can be retrieved by 536 # so that it can be retrieved by
536 # _history-substring-search-down-search() later. 537 # _history-substring-search-down-search() later.
537 # 538 #
538 # 3. Make $BUFFER equal to $_history_substring_search_query. 539 # 3. Make $BUFFER equal to $_history_substring_search_query.
539 # 540 #
540 # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND 541 # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
541 # to highlight the current buffer. 542 # to highlight the current buffer.
542 # 543 #
543 (( _history_substring_search_match_index-- )) 544 (( _history_substring_search_match_index-- ))
544 _history_substring_search_old_buffer=$BUFFER 545 _history_substring_search_old_buffer=$BUFFER
545 BUFFER=$_history_substring_search_query 546 BUFFER=$_history_substring_search_query
546 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND 547 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
547 548
548 elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then 549 elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then
549 # 550 #
550 # We were beyond the beginning of $_history_substring_search_matches but 551 # We were beyond the beginning of $_history_substring_search_matches but
551 # UP makes us move back to $_history_substring_search_matches: 552 # UP makes us move back to $_history_substring_search_matches:
552 # 553 #
553 # 1. Decrease the value of $_history_substring_search_match_index. 554 # 1. Decrease the value of $_history_substring_search_match_index.
554 # 555 #
555 # 2. Restore $BUFFER from $_history_substring_search_old_buffer. 556 # 2. Restore $BUFFER from $_history_substring_search_old_buffer.
556 # 557 #
557 # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 558 # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
558 # to highlight the current buffer. 559 # to highlight the current buffer.
559 # 560 #
560 (( _history_substring_search_match_index-- )) 561 (( _history_substring_search_match_index-- ))
561 BUFFER=$_history_substring_search_old_buffer 562 BUFFER=$_history_substring_search_old_buffer
562 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 563 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
563 fi 564 fi
564 } 565 }
565 566
566 function _history-substring-search-down-search() { 567 function _history-substring-search-down-search() {
567 _history_substring_search_move_cursor_eol=true 568 _history_substring_search_move_cursor_eol=true
568 569
569 # 570 #
570 # Highlight matches during history-substring-up-search: 571 # Highlight matches during history-substring-up-search:
571 # 572 #
572 # The following constants have been initialized in 573 # The following constants have been initialized in
573 # _history-substring-search-up/down-search(): 574 # _history-substring-search-up/down-search():
574 # 575 #
575 # $_history_substring_search_matches is the current list of matches 576 # $_history_substring_search_matches is the current list of matches
576 # $_history_substring_search_matches_count is the current number of matches 577 # $_history_substring_search_matches_count is the current number of matches
577 # $_history_substring_search_matches_count_plus is the current number of matches + 1 578 # $_history_substring_search_matches_count_plus is the current number of matches + 1
578 # $_history_substring_search_matches_count_sans is the current number of matches - 1 579 # $_history_substring_search_matches_count_sans is the current number of matches - 1
579 # $_history_substring_search_match_index is the index of the current match 580 # $_history_substring_search_match_index is the index of the current match
580 # 581 #
581 # The range of values that $_history_substring_search_match_index can take 582 # The range of values that $_history_substring_search_match_index can take
582 # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 583 # is: [0, $_history_substring_search_matches_count_plus]. A value of 0
583 # indicates that we are beyond the end of 584 # indicates that we are beyond the end of
584 # $_history_substring_search_matches. A value of 585 # $_history_substring_search_matches. A value of
585 # $_history_substring_search_matches_count_plus indicates that we are beyond 586 # $_history_substring_search_matches_count_plus indicates that we are beyond
586 # the beginning of $_history_substring_search_matches. 587 # the beginning of $_history_substring_search_matches.
587 # 588 #
588 # In _history-substring-search-down-search() the initial value of 589 # In _history-substring-search-down-search() the initial value of
589 # $_history_substring_search_match_index is 590 # $_history_substring_search_match_index is
590 # $_history_substring_search_matches_count. This value is set in 591 # $_history_substring_search_matches_count. This value is set in
591 # _history-substring-search-begin(). 592 # _history-substring-search-begin().
592 # _history-substring-search-down-search() will initially increase it to 593 # _history-substring-search-down-search() will initially increase it to
593 # $_history_substring_search_matches_count_plus. 594 # $_history_substring_search_matches_count_plus.
594 # 595 #
595 if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then 596 if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then
596 # 597 #
597 # Highlight the next match: 598 # Highlight the next match:
598 # 599 #
599 # 1. Increase $_history_substring_search_match_index by 1. 600 # 1. Increase $_history_substring_search_match_index by 1.
600 # 601 #
601 # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 602 # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
602 # to highlight the current buffer. 603 # to highlight the current buffer.
603 # 604 #
604 (( _history_substring_search_match_index++ )) 605 (( _history_substring_search_match_index++ ))
605 BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] 606 BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
606 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 607 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
607 608
608 elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then 609 elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then
609 # 610 #
610 # We will move beyond the beginning of $_history_substring_search_matches: 611 # We will move beyond the beginning of $_history_substring_search_matches:
611 # 612 #
612 # 1. Increase $_history_substring_search_match_index by 1. 613 # 1. Increase $_history_substring_search_match_index by 1.
613 # 614 #
614 # 2. Save the current buffer in $_history_substring_search_old_buffer, so 615 # 2. Save the current buffer in $_history_substring_search_old_buffer, so
615 # that it can be retrieved by _history-substring-search-up-search() 616 # that it can be retrieved by _history-substring-search-up-search()
616 # later. 617 # later.
617 # 618 #
618 # 3. Make $BUFFER equal to $_history_substring_search_query. 619 # 3. Make $BUFFER equal to $_history_substring_search_query.
619 # 620 #
620 # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND 621 # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
621 # to highlight the current buffer. 622 # to highlight the current buffer.
622 # 623 #
623 (( _history_substring_search_match_index++ )) 624 (( _history_substring_search_match_index++ ))
624 _history_substring_search_old_buffer=$BUFFER 625 _history_substring_search_old_buffer=$BUFFER
625 BUFFER=$_history_substring_search_query 626 BUFFER=$_history_substring_search_query
626 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND 627 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
627 628
628 elif [[ $_history_substring_search_match_index -eq 0 ]]; then 629 elif [[ $_history_substring_search_match_index -eq 0 ]]; then
629 # 630 #
630 # We were beyond the end of $_history_substring_search_matches but DOWN 631 # We were beyond the end of $_history_substring_search_matches but DOWN
631 # makes us move back to the $_history_substring_search_matches: 632 # makes us move back to the $_history_substring_search_matches:
632 # 633 #
633 # 1. Increase $_history_substring_search_match_index by 1. 634 # 1. Increase $_history_substring_search_match_index by 1.
634 # 635 #
635 # 2. Restore $BUFFER from $_history_substring_search_old_buffer. 636 # 2. Restore $BUFFER from $_history_substring_search_old_buffer.
636 # 637 #
637 # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 638 # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
638 # to highlight the current buffer. 639 # to highlight the current buffer.
639 # 640 #
640 (( _history_substring_search_match_index++ )) 641 (( _history_substring_search_match_index++ ))
641 BUFFER=$_history_substring_search_old_buffer 642 BUFFER=$_history_substring_search_old_buffer
642 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 643 _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
643 fi 644 fi
644 } 645 }
645 646
646 # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- 647 # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
647 # vim: ft=zsh sw=2 ts=2 et 648 # vim: ft=zsh sw=2 ts=2 et
plugins/history/README.md
File was created 1 ## history
2
3 Provides a couple of convenient aliases for using the `history` command to examine your command line history.
4
5 ### Requirements
6
7 * None.
8
9 ### Usage
10
11 * If `h` is called, your command history is listed. Equivalent to using `history`
12
13 * If `hsi` is called with an argument, a **case insensitive** `grep` search is performed on your command history, looking for commands that match the argument provided
14
15 * If `hsi` is called without an argument you will help on `grep` arguments
plugins/httpie/README.md
File was created 1 ## HTTPie
2 **Maintainer:** [lululau](https://github.com/lululau)
3
4 This plugin adds completion for HTTPie, which is a command line HTTP client, a user-friendly cURL replacement.
5
6 [HTTPie Homepage](http://httpie.org)
7
plugins/jira/jira.plugin.zsh
1 # To use: add a .jira-url file in the base of your project 1 # To use: add a .jira-url file in the base of your project
2 # You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory 2 # You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
3 # .jira-url in the current directory takes precedence 3 # .jira-url in the current directory takes precedence
4 # 4 #
5 # If you use Rapid Board, set: 5 # If you use Rapid Board, set:
6 #JIRA_RAPID_BOARD="true" 6 #JIRA_RAPID_BOARD="true"
7 # in you .zshrc 7 # in you .zshrc
8 # 8 #
9 # Setup: cd to/my/project 9 # Setup: cd to/my/project
10 # echo "https://name.jira.com" >> .jira-url 10 # echo "https://name.jira.com" >> .jira-url
11 # Usage: jira # opens a new issue 11 # Usage: jira # opens a new issue
12 # jira ABC-123 # Opens an existing issue 12 # jira ABC-123 # Opens an existing issue
13 open_jira_issue () { 13 open_jira_issue () {
14 local open_cmd 14 local open_cmd
15 if [[ "$OSTYPE" = darwin* ]]; then 15 if [[ "$OSTYPE" = darwin* ]]; then
16 open_cmd='open' 16 open_cmd='open'
17 else 17 else
18 open_cmd='xdg-open' 18 open_cmd='xdg-open'
19 fi 19 fi
20 20
21 if [ -f .jira-url ]; then 21 if [ -f .jira-url ]; then
22 jira_url=$(cat .jira-url) 22 jira_url=$(cat .jira-url)
23 elif [ -f ~/.jira-url ]; then 23 elif [ -f ~/.jira-url ]; then
24 jira_url=$(cat ~/.jira-url) 24 jira_url=$(cat ~/.jira-url)
25 elif [[ "x$JIRA_URL" != "x" ]]; then 25 elif [[ "x$JIRA_URL" != "x" ]]; then
26 jira_url=$JIRA_URL 26 jira_url=$JIRA_URL
27 else 27 else
28 echo "JIRA url is not specified anywhere." 28 echo "JIRA url is not specified anywhere."
29 return 1 29 return 1
30 fi 30 fi
31 31
32 if [ -f .jira-prefix ]; then 32 if [ -f .jira-prefix ]; then
33 jira_prefix=$(cat .jira-prefix) 33 jira_prefix=$(cat .jira-prefix)
34 elif [ -f ~/.jira-prefix ]; then 34 elif [ -f ~/.jira-prefix ]; then
35 jira_prefix=$(cat ~/.jira-prefix) 35 jira_prefix=$(cat ~/.jira-prefix)
36 else 36 else
37 jira_prefix="" 37 jira_prefix=""
38 fi 38 fi
39 39
40 if [ -z "$1" ]; then 40 if [ -z "$1" ]; then
41 echo "Opening new issue" 41 echo "Opening new issue"
42 $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" 42 $open_cmd "${jira_url}/secure/CreateIssue!default.jspa"
43 elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then 43 elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then
44 jira_query $@ 44 jira_query $@
45 else 45 else
46 echo "Opening issue #$1" 46 echo "Opening issue #$1"
47 if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then 47 if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
48 $open_cmd "$jira_url/issues/$jira_prefix$1" 48 $open_cmd "$jira_url/issues/$jira_prefix$1"
49 else 49 else
50 $open_cmd "$jira_url/browse/$jira_prefix$1" 50 $open_cmd "$jira_url/browse/$jira_prefix$1"
51 fi 51 fi
52 else
53 local addcomment=''
54 if [[ "$2" == "m" ]]; then
55 addcomment="#add-comment"
56 echo "Add comment to issue #$1"
57 else
58 echo "Opening issue #$1"
59 fi
60
61 if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
62 $open_cmd "$jira_url/issues/$1$addcomment"
63 else
64 $open_cmd "$jira_url/browse/$1$addcomment"
65 fi
52 fi 66 fi
53 } 67 }
54 68
55 jira_name () { 69 jira_name () {
56 if [[ -z "$1" ]]; then 70 if [[ -z "$1" ]]; then
57 if [[ "x${JIRA_NAME}" != "x" ]]; then 71 if [[ "x${JIRA_NAME}" != "x" ]]; then
58 jira_name=${JIRA_NAME} 72 jira_name=${JIRA_NAME}
59 else 73 else
60 echo "JIRA_NAME not specified" 74 echo "JIRA_NAME not specified"
61 return 1 75 return 1
62 fi 76 fi
63 else 77 else
64 jira_name=$@ 78 jira_name=$@
65 fi 79 fi
66 } 80 }
67 81
68 jira_query () { 82 jira_query () {
69 verb="$1" 83 verb="$1"
70 if [[ "${verb}" = "reported" ]]; then 84 if [[ "${verb}" = "reported" ]]; then
71 lookup=reporter 85 lookup=reporter
72 preposition=by 86 preposition=by
73 elif [[ "${verb}" = "assigned" ]]; then 87 elif [[ "${verb}" = "assigned" ]]; then
74 lookup=assignee 88 lookup=assignee
75 preposition=to 89 preposition=to
76 else 90 else
77 echo "not a valid lookup $verb" 91 echo "not a valid lookup $verb"
78 return 1 92 return 1
79 fi 93 fi
80 shift 1 94 shift 1
81 jira_name $@ 95 jira_name $@
82 if [[ $? = 1 ]]; then 96 if [[ $? = 1 ]]; then
83 return 1 97 return 1
84 fi 98 fi
85 echo "Browsing issues ${verb} ${preposition} ${jira_name}" 99 echo "Browsing issues ${verb} ${preposition} ${jira_name}"
86 $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" 100 $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
87 } 101 }
88 102
89 alias jira='open_jira_issue' 103 alias jira='open_jira_issue'
90 104
91 105
plugins/jump/jump.plugin.zsh
1 # Easily jump around the file system by manually adding marks 1 # Easily jump around the file system by manually adding marks
2 # marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks) 2 # marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks)
3 # 3 #
4 # jump FOO: jump to a mark named FOO 4 # jump FOO: jump to a mark named FOO
5 # mark FOO: create a mark named FOO 5 # mark FOO: create a mark named FOO
6 # unmark FOO: delete a mark 6 # unmark FOO: delete a mark
7 # marks: lists all marks 7 # marks: lists all marks
8 # 8 #
9 export MARKPATH=$HOME/.marks 9 export MARKPATH=$HOME/.marks
10 10
11 jump() { 11 jump() {
12 cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" 12 cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
13 } 13 }
14 14
15 mark() { 15 mark() {
16 if (( $# == 0 )); then 16 if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then
17 MARK=$(basename "$PWD") 17 MARK=$(basename "$PWD")
18 else 18 else
19 MARK="$1" 19 MARK="$1"
20 fi 20 fi
21 if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then 21 if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
22 mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK" 22 mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK"
23 fi 23 fi
24 } 24 }
25 25
26 unmark() { 26 unmark() {
27 rm -i "$MARKPATH/$1" 27 rm -i "$MARKPATH/$1"
28 } 28 }
29 29
30 marks() { 30 marks() {
31 for link in $MARKPATH/*(@); do 31 for link in $MARKPATH/*(@); do
32 local markname="$fg[cyan]${link:t}$reset_color" 32 local markname="$fg[cyan]${link:t}$reset_color"
33 local markpath="$fg[blue]$(readlink $link)$reset_color" 33 local markpath="$fg[blue]$(readlink $link)$reset_color"
34 printf "%s\t" $markname 34 printf "%s\t" $markname
35 printf "-> %s \t\n" $markpath 35 printf "-> %s \t\n" $markpath
36 done 36 done
37 } 37 }
38 38
39 _completemarks() { 39 _completemarks() {
40 if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then 40 if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
41 reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g')) 41 reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g'))
42 else 42 else
43 if readlink -e "${MARKPATH}"/* &>/dev/null; then 43 if readlink -e "${MARKPATH}"/* &>/dev/null; then
44 reply=($(ls "${MARKPATH}")) 44 reply=($(ls "${MARKPATH}"))
45 fi 45 fi
46 fi 46 fi
47 } 47 }
48 compctl -K _completemarks jump 48 compctl -K _completemarks jump
49 compctl -K _completemarks unmark 49 compctl -K _completemarks unmark
50 50
51 _mark_expansion() { 51 _mark_expansion() {
52 setopt extendedglob 52 setopt extendedglob
53 autoload -U modify-current-argument 53 autoload -U modify-current-argument
54 modify-current-argument '$(readlink "$MARKPATH/$ARG")' 54 modify-current-argument '$(readlink "$MARKPATH/$ARG")'
55 } 55 }
56 zle -N _mark_expansion 56 zle -N _mark_expansion
57 bindkey "^g" _mark_expansion 57 bindkey "^g" _mark_expansion
58 58
plugins/kitchen/_kitchen
File was created 1 # author: Peter Eisentraut
2 # source: https://gist.github.com/petere/10307599
3 # compdef kitchen
4
5 _kitchen() {
6 local curcontext="$curcontext" state line
7 typeset -A opt_args
8
9 _arguments '1: :->cmds'\
10 '2: :->args'
11
12 case $state in
13 cmds)
14 _arguments "1:Commands:(console converge create destroy diagnose driver help init list login setup test verify version)"
15 ;;
16 args)
17 case $line[1] in
18 converge|create|destroy|diagnose|list|setup|test|verify)
19 compadd "$@" all
20 _kitchen_instances
21 ;;
22 login)
23 _kitchen_instances
24 ;;
25 esac
26 ;;
27 esac
28 }
29
30 _kitchen_instances() {
31 if [[ $_kitchen_instances_cache_dir != $PWD ]]; then
32 unset _kitchen_instances_cache
33 fi
34 if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then
35 _kitchen_instances_cache=(${(f)"$(bundle exec kitchen list -b 2>/dev/null || kitchen list -b 2>/dev/null)"})
36 _kitchen_instances_cache_dir=$PWD
37 fi
38 compadd -a _kitchen_instances_cache
39 }
40
41 _kitchen "$@"
42
plugins/laravel5/laravel5.plugin.zsh
1 # Laravel5 basic command completion 1 # Laravel5 basic command completion
2 _laravel5_get_command_list () { 2 _laravel5_get_command_list () {
3 php artisan --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }' 3 php artisan --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }'
4 } 4 }
5 5
6 _laravel5 () { 6 _laravel5 () {
7 if [ -f artisan ]; then 7 if [ -f artisan ]; then
8 compadd `_laravel5_get_command_list` 8 compadd `_laravel5_get_command_list`
9 fi 9 fi
10 } 10 }
11 11
12 compdef _laravel5 artisan 12 compdef _laravel5 artisan
13 compdef _laravel5 la5 13 compdef _laravel5 la5
14 14
15 #Alias 15 #Alias
16 alias la5='php artisan' 16 alias la5='php artisan'
17 17
18 alias la5dump='php artisan dump-autoload'
19 alias la5cache='php artisan cache:clear' 18 alias la5cache='php artisan cache:clear'
20 alias la5routes='php artisan routes' 19 alias la5routes='php artisan route:list'
20 alias la5vendor='php artisan vendor:publish'
plugins/last-working-dir/last-working-dir.plugin.zsh
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 # Keeps track of the last used working directory and automatically jumps 2 # Keeps track of the last used working directory and automatically jumps
3 # into it for new shells. 3 # into it for new shells.
4 4
5 # Flag indicating if we've previously jumped to last directory. 5 # Flag indicating if we've previously jumped to last directory.
6 typeset -g ZSH_LAST_WORKING_DIRECTORY 6 typeset -g ZSH_LAST_WORKING_DIRECTORY
7 mkdir -p $ZSH_CACHE_DIR 7 mkdir -p $ZSH_CACHE_DIR
8 cache_file="$ZSH_CACHE_DIR/last-working-dir" 8 cache_file="$ZSH_CACHE_DIR/last-working-dir"
9 9
10 # Updates the last directory once directory is changed. 10 # Updates the last directory once directory is changed.
11 function chpwd() { 11 function chpwd() {
12 # Use >| in case noclobber is set to avoid "file exists" error 12 # Use >| in case noclobber is set to avoid "file exists" error
13 pwd >| "$cache_file" 13 pwd >| "$cache_file"
14 } 14 }
15 15
16 # Changes directory to the last working directory. 16 # Changes directory to the last working directory.
17 function lwd() { 17 function lwd() {
18 [[ ! -r "$cache_file" ]] || cd `cat "$cache_file"` 18 [[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`"
19 } 19 }
20 20
21 # Automatically jump to last working directory unless this isn't the first time 21 # Automatically jump to last working directory unless this isn't the first time
22 # this plugin has been loaded. 22 # this plugin has been loaded.
23 if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then 23 if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then
24 lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true 24 lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
25 fi 25 fi
26 26
plugins/mercurial/README.md
File was created 1 # Mercurial plugin
2 ### Usage
3 Update .zshrc:
4
5 1. Add name to the list of plugins, e.g. `plugins = (..., mercurial, ...)`
6 (that is pretty obvious).
7 2. Change PROMPT variable of current theme to contain current folder mercurial repo info:
8
9 robbyrussel theme is used by default, so you need to modify PROMPT var
10 from [this file](https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/robbyrussell.zsh-theme)
11 by adding `$(hg_prompt_info)` after `$(git_prompt_info)`, so currently it
12 looks next:
13
14 ```diff
15 - PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
16 + PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
17 ```
18
19 and put modified var at the end of **.zshrc**.
20 3. Initialize additional vars used in plugin. So in short put next in **.zshrc**:
21
22 ```
23 ZSH_THEME_HG_PROMPT_PREFIX="%{$fg_bold[magenta]%}hg:(%{$fg[red]%}"
24 ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}"
25 ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[magenta]%}) %{$fg[yellow]%}✗%{$reset_color%}"
26 ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})"
27 ```
28
29 ### What's inside?
30 #### Adds handy aliases:
31 ###### general
32 * `hgc` - `hg commit`
33 * `hgb` - `hg branch`
34 * `hgba` - `hg branches`
35 * `hgbk` - `hg bookmarks`
36 * `hgco` - `hg checkout`
37 * `hgd` - `hg diff`
38 * `hged` - `hg diffmerge`
39
40 ###### pull and update
41 * `hgi` - `hg incoming`
42 * `hgl` - `hg pull -u`
43 * `hglr` - `hg pull --rebase`
44 * `hgo` - `hg outgoing`
45 * `hgp` - `hg push`
46 * `hgs` - `hg status`
47 * `hgsl` - `hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"`
48
49 ###### this is the 'git commit --amend' equivalent
50 * `hgca` - `hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip`
51
52 ###### list unresolved files (since hg does not list unmerged files in the status command)
53 * `hgun` - `hg resolve --list`
54
55 #### Displays repo branch and directory status in prompt
56 This is the same as git plugin does.
57
58 **Note**: additional changes to **.zshrc** are required in order for this to
59 work.
60
61 ### Mantainers
62 [ptrv](https://github.com/ptrv) - original creator
63
64 [oshybystyi](https://github.com/oshybystyi) - created this README and know how most of code works
65
plugins/mix-fast/README.md
File was created 1 # mix-fast
2
3 Fast mix autocompletion plugin.
4
5 This script caches the output for later usage and significantly speeds it up.
6 It generates a .mix_tasks cache file for current project. Currently if you want
7 to update cache you should remove .mix_tasks file
8
9 Inspired by and based on rake-fast zsh plugin.
10
11 This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-mix-task-completion-for-zsh/).
12
13
14 ## Installation
15
16 Just add the plugin to your `.zshrc`:
17
18 ```bash
19 plugins=(foo bar mix-fast)
20 ```
21
22 You might consider adding `.mix_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore)
23
24 ## Usage
25
26 `mix`, then press tab
27
28 Currently maintained by [styx](https://github.com/styx/)
plugins/mix-fast/mix-fast.plugin.zsh
File was created 1 _mix_refresh () {
2 if [ -f .mix_tasks ]; then
3 rm .mix_tasks
4 fi
5 echo "Generating .mix_tasks..." > /dev/stderr
6 _mix_generate
7 cat .mix_tasks
8 }
9
10 _mix_does_task_list_need_generating () {
11 [ ! -f .mix_tasks ];
12 }
13
14 _mix_generate () {
15 mix --help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks
16 }
17
18 _mix () {
19 if [ -f mix.exs ]; then
20 if _mix_does_task_list_need_generating; then
21 echo "\nGenerating .mix_tasks..." > /dev/stderr
22 _mix_generate
23 fi
24 compadd `cat .mix_tasks`
25 fi
26 }
27
28 compdef _mix mix
29 alias mix_refresh='_mix_refresh'
30
1 #compdef mix 1 #compdef mix
2 #autoload 2 #autoload
3 3
4 # Elixir mix zsh completion 4 # Elixir mix zsh completion
5 5
6 local -a _1st_arguments 6 local -a _1st_arguments
7 _1st_arguments=( 7 _1st_arguments=(
8 'archive:Archive this project into a .ez file' 8 'app.start:Start all registered apps'
9 'clean:Clean generated application files' 9 'archive:List all archives'
10 'archive.build:Archive this project into a .ez file'
11 'archive.install:Install an archive locally'
12 'archive.uninstall:Uninstall archives'
13 'clean:Delete generated application files'
14 'cmd:Executes the given command'
10 'compile:Compile source files' 15 'compile:Compile source files'
16 'compile.protocols:Consolidates all protocols in all paths'
11 'deps:List dependencies and their status' 17 'deps:List dependencies and their status'
12 "deps.clean:Remove dependencies' files" 18 "deps.clean:Remove the given dependencies' files"
13 'deps.compile:Compile dependencies' 19 'deps.compile:Compile dependencies'
14 'deps.get:Get all out of date dependencies' 20 'deps.get:Get all out of date dependencies'
15 'deps.unlock:Unlock the given dependencies' 21 'deps.unlock:Unlock the given dependencies'
16 'deps.update:Update dependencies' 22 'deps.update:Update the given dependencies'
17 'do:Executes the commands separated by comma' 23 'do:Executes the tasks separated by comma'
18 'escriptize:Generates an escript for the project' 24 'escript.build:Builds an escript for the project'
19 'help:Print help information for tasks' 25 'help:Print help information for tasks'
26 'hex:Print hex help information'
27 'hex.config:Read or update hex config'
28 'hex.docs:Publish docs for package'
29 'hex.info:Print hex information'
30 'hex.key:Hex API key tasks'
31 'hex.outdated:Shows outdated hex deps for the current project'
32 'hex.owner:Hex package ownership tasks'
33 'hex.publish:Publish a new package version'
34 'hex.search:Search for package names'
35 'hex.user:Hex user tasks'
36 'loadconfig:Loads and persists the given configuration'
20 'local:List local tasks' 37 'local:List local tasks'
21 'local.install:Install a task or an archive locally' 38 'local.hex:Install hex locally'
22 'local.rebar:Install rebar locally' 39 'local.rebar:Install rebar locally'
23 'local.uninstall:Uninstall local tasks or archives' 40 'new:Create a new Elixir project'
24 'local.hex:Install Hex locally'
25 'new:Creates a new Elixir project'
26 'run:Run the given file or expression' 41 'run:Run the given file or expression'
27 "test:Run a project's tests" 42 "test:Run a project's tests"
28 '--help:Describe available tasks' 43 '--help:Describe available tasks'
29 '--version:Prints the Elixir version information' 44 '--version:Prints the Elixir version information'
30 ) 45 )
31 46
32 __task_list () 47 __task_list ()
33 { 48 {
34 local expl 49 local expl
35 declare -a tasks 50 declare -a tasks
36 51
37 tasks=(archive clean compile deps deps.clean deps.compile deps.get deps.unlock deps.update do escriptize help local local.install local.rebar local.uninstall new run test) 52 tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new run test)
38 53
39 _wanted tasks expl 'help' compadd $tasks 54 _wanted tasks expl 'help' compadd $tasks
40 } 55 }
41 56
42 local expl 57 local expl
43 58
44 local curcontext="$curcontext" state line 59 local curcontext="$curcontext" state line
45 typeset -A opt_args 60 typeset -A opt_args
46 61
47 _arguments -C \ 62 _arguments -C \
48 ':command:->command' \ 63 ':command:->command' \
49 '*::options:->options' 64 '*::options:->options'
50 65
51 case $state in 66 case $state in
52 (command) 67 (command)
53 _describe -t commands "mix subcommand" _1st_arguments 68 _describe -t commands "mix subcommand" _1st_arguments
54 return 69 return
55 ;; 70 ;;
56 71
57 (options) 72 (options)
58 case $line[1] in 73 case $line[1] in
59 (help) 74 (help)
60 _arguments ':feature:__task_list' 75 _arguments ':feature:__task_list'
61 esac 76 esac
62 ;; 77 ;;
63 esac 78 esac
plugins/osx/osx.plugin.zsh
1 # ------------------------------------------------------------------------------ 1 # ------------------------------------------------------------------------------
2 # FILE: osx.plugin.zsh 2 # FILE: osx.plugin.zsh
3 # DESCRIPTION: oh-my-zsh plugin file. 3 # DESCRIPTION: oh-my-zsh plugin file.
4 # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) 4 # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
5 # VERSION: 1.1.0 5 # VERSION: 1.1.0
6 # ------------------------------------------------------------------------------ 6 # ------------------------------------------------------------------------------
7 7
8 function tab() { 8 function tab() {
9 local command="cd \\\"$PWD\\\"; clear; " 9 local command="cd \\\"$PWD\\\"; clear; "
10 (( $# > 0 )) && command="${command}; $*" 10 (( $# > 0 )) && command="${command}; $*"
11 11
12 the_app=$( 12 the_app=$(
13 osascript 2>/dev/null <<EOF 13 osascript 2>/dev/null <<EOF
14 tell application "System Events" 14 tell application "System Events"
15 name of first item of (every process whose frontmost is true) 15 name of first item of (every process whose frontmost is true)
16 end tell 16 end tell
17 EOF 17 EOF
18 ) 18 )
19 19
20 [[ "$the_app" == 'Terminal' ]] && { 20 [[ "$the_app" == 'Terminal' ]] && {
21 osascript 2>/dev/null <<EOF 21 osascript 2>/dev/null <<EOF
22 tell application "System Events" 22 tell application "System Events"
23 tell process "Terminal" to keystroke "t" using command down 23 tell process "Terminal" to keystroke "t" using command down
24 tell application "Terminal" to do script "${command}" in front window 24 tell application "Terminal" to do script "${command}" in front window
25 end tell 25 end tell
26 EOF 26 EOF
27 } 27 }
28 28
29 [[ "$the_app" == 'iTerm' ]] && { 29 [[ "$the_app" == 'iTerm' ]] && {
30 osascript 2>/dev/null <<EOF 30 osascript 2>/dev/null <<EOF
31 tell application "iTerm" 31 tell application "iTerm"
32 set current_terminal to current terminal 32 set current_terminal to current terminal
33 tell current_terminal 33 tell current_terminal
34 launch session "Default Session" 34 launch session "Default Session"
35 set current_session to current session 35 set current_session to current session
36 tell current_session 36 tell current_session
37 write text "${command}" 37 write text "${command}"
38 keystroke return 38 keystroke return
39 end tell 39 end tell
40 end tell 40 end tell
41 end tell 41 end tell
42 EOF 42 EOF
43 } 43 }
44 } 44 }
45 45
46 function vsplit_tab() { 46 function vsplit_tab() {
47 local command="cd \\\"$PWD\\\"" 47 local command="cd \\\"$PWD\\\""
48 (( $# > 0 )) && command="${command}; $*" 48 (( $# > 0 )) && command="${command}; $*"
49 49
50 the_app=$( 50 the_app=$(
51 osascript 2>/dev/null <<EOF 51 osascript 2>/dev/null <<EOF
52 tell application "System Events" 52 tell application "System Events"
53 name of first item of (every process whose frontmost is true) 53 name of first item of (every process whose frontmost is true)
54 end tell 54 end tell
55 EOF 55 EOF
56 ) 56 )
57 57
58 [[ "$the_app" == 'iTerm' ]] && { 58 [[ "$the_app" == 'iTerm' ]] && {
59 osascript 2>/dev/null <<EOF 59 osascript 2>/dev/null <<EOF
60 tell application "iTerm" to activate 60 tell application "iTerm" to activate
61 61
62 tell application "System Events" 62 tell application "System Events"
63 tell process "iTerm" 63 tell process "iTerm"
64 tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1 64 tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
65 click 65 click
66 end tell 66 end tell
67 end tell 67 end tell
68 keystroke "${command}; clear;" 68 keystroke "${command}; clear;"
69 keystroke return 69 keystroke return
70 end tell 70 end tell
71 EOF 71 EOF
72 } 72 }
73 } 73 }
74 74
75 function split_tab() { 75 function split_tab() {
76 local command="cd \\\"$PWD\\\"" 76 local command="cd \\\"$PWD\\\""
77 (( $# > 0 )) && command="${command}; $*" 77 (( $# > 0 )) && command="${command}; $*"
78 78
79 the_app=$( 79 the_app=$(
80 osascript 2>/dev/null <<EOF 80 osascript 2>/dev/null <<EOF
81 tell application "System Events" 81 tell application "System Events"
82 name of first item of (every process whose frontmost is true) 82 name of first item of (every process whose frontmost is true)
83 end tell 83 end tell
84 EOF 84 EOF
85 ) 85 )
86 86
87 [[ "$the_app" == 'iTerm' ]] && { 87 [[ "$the_app" == 'iTerm' ]] && {
88 osascript 2>/dev/null <<EOF 88 osascript 2>/dev/null <<EOF
89 tell application "iTerm" to activate 89 tell application "iTerm" to activate
90 90
91 tell application "System Events" 91 tell application "System Events"
92 tell process "iTerm" 92 tell process "iTerm"
93 tell menu item "Split Horizontally With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1 93 tell menu item "Split Horizontally With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
94 click 94 click
95 end tell 95 end tell
96 end tell 96 end tell
97 keystroke "${command}; clear;" 97 keystroke "${command}; clear;"
98 keystroke return 98 keystroke return
99 end tell 99 end tell
100 EOF 100 EOF
101 } 101 }
102 } 102 }
103 103
104 function pfd() { 104 function pfd() {
105 osascript 2>/dev/null <<EOF 105 osascript 2>/dev/null <<EOF
106 tell application "Finder" 106 tell application "Finder"
107 return POSIX path of (target of window 1 as alias) 107 return POSIX path of (target of window 1 as alias)
108 end tell 108 end tell
109 EOF 109 EOF
110 } 110 }
111 111
112 function pfs() { 112 function pfs() {
113 osascript 2>/dev/null <<EOF 113 osascript 2>/dev/null <<EOF
114 set output to "" 114 set output to ""
115 tell application "Finder" to set the_selection to selection 115 tell application "Finder" to set the_selection to selection
116 set item_count to count the_selection 116 set item_count to count the_selection
117 repeat with item_index from 1 to count the_selection 117 repeat with item_index from 1 to count the_selection
118 if item_index is less than item_count then set the_delimiter to "\n" 118 if item_index is less than item_count then set the_delimiter to "\n"
119 if item_index is item_count then set the_delimiter to "" 119 if item_index is item_count then set the_delimiter to ""
120 set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter 120 set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
121 end repeat 121 end repeat
122 EOF 122 EOF
123 } 123 }
124 124
125 function cdf() { 125 function cdf() {
126 cd "$(pfd)" 126 cd "$(pfd)"
127 } 127 }
128 128
129 function pushdf() { 129 function pushdf() {
130 pushd "$(pfd)" 130 pushd "$(pfd)"
131 } 131 }
132 132
133 function quick-look() { 133 function quick-look() {
134 (( $# > 0 )) && qlmanage -p $* &>/dev/null & 134 (( $# > 0 )) && qlmanage -p $* &>/dev/null &
135 } 135 }
136 136
137 function man-preview() { 137 function man-preview() {
138 man -t "$@" | open -f -a Preview 138 man -t "$@" | open -f -a Preview
139 } 139 }
140 140
141 function trash() {
142 local trash_dir="${HOME}/.Trash"
143 local temp_ifs="$IFS"
144 IFS=$'\n'
145 for item in "$@"; do
146 if [[ -e "$item" ]]; then
147 item_name="$(basename $item)"
148 if [[ -e "${trash_dir}/${item_name}" ]]; then
149 mv -f "$item" "${trash_dir}/${item_name} $(date "+%H-%M-%S")"
150 else
151 mv -f "$item" "${trash_dir}/"
152 fi
153 fi
154 done
155 IFS=$temp_ifs
156 }
157
158 function vncviewer() { 141 function vncviewer() {
159 open vnc://$@ 142 open vnc://$@
160 } 143 }
161 144
162 # iTunes control function 145 # iTunes control function
163 function itunes() { 146 function itunes() {
164 local opt=$1 147 local opt=$1
165 shift 148 shift
166 case "$opt" in 149 case "$opt" in
167 launch|play|pause|stop|rewind|resume|quit) 150 launch|play|pause|stop|rewind|resume|quit)
168 ;; 151 ;;
169 mute) 152 mute)
170 opt="set mute to true" 153 opt="set mute to true"
171 ;; 154 ;;
172 unmute) 155 unmute)
173 opt="set mute to false" 156 opt="set mute to false"
174 ;; 157 ;;
175 next|previous) 158 next|previous)
176 opt="$opt track" 159 opt="$opt track"
177 ;; 160 ;;
178 vol) 161 vol)
179 opt="set sound volume to $1" #$1 Due to the shift 162 opt="set sound volume to $1" #$1 Due to the shift
180 ;; 163 ;;
181 shuf|shuff|shuffle) 164 shuf|shuff|shuffle)
182 # The shuffle property of current playlist can't be changed in iTunes 12, 165 # The shuffle property of current playlist can't be changed in iTunes 12,
183 # so this workaround uses AppleScript to simulate user input instead. 166 # so this workaround uses AppleScript to simulate user input instead.
184 # Defaults to toggling when no options are given. 167 # Defaults to toggling when no options are given.
185 # The toggle option depends on the shuffle button being visible in the Now playing area. 168 # The toggle option depends on the shuffle button being visible in the Now playing area.
186 # On and off use the menu bar items. 169 # On and off use the menu bar items.
187 local state=$1 170 local state=$1
188 171
189 if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]] 172 if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
190 then 173 then
191 print "Usage: itunes shuffle [on|off|toggle]. Invalid option." 174 print "Usage: itunes shuffle [on|off|toggle]. Invalid option."
192 return 1 175 return 1
193 fi 176 fi
194 177
195 case "$state" in 178 case "$state" in
196 on|off) 179 on|off)
197 # Inspired by: http://stackoverflow.com/a/14675583 180 # Inspired by: http://stackoverflow.com/a/14675583
198 osascript 1>/dev/null 2>&1 <<-EOF 181 osascript 1>/dev/null 2>&1 <<-EOF
199 tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" ) 182 tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
200 EOF 183 EOF
201 return 0 184 return 0
202 ;; 185 ;;
203 toggle|*) 186 toggle|*)
204 osascript 1>/dev/null 2>&1 <<-EOF 187 osascript 1>/dev/null 2>&1 <<-EOF
205 tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1) 188 tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
206 EOF 189 EOF
207 return 0 190 return 0
208 ;; 191 ;;
209 esac 192 esac
210 ;; 193 ;;
211 ""|-h|--help) 194 ""|-h|--help)
212 echo "Usage: itunes <option>" 195 echo "Usage: itunes <option>"
213 echo "option:" 196 echo "option:"
214 echo "\tlaunch|play|pause|stop|rewind|resume|quit" 197 echo "\tlaunch|play|pause|stop|rewind|resume|quit"
215 echo "\tmute|unmute\tcontrol volume set" 198 echo "\tmute|unmute\tcontrol volume set"
216 echo "\tnext|previous\tplay next or previous track" 199 echo "\tnext|previous\tplay next or previous track"
217 echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." 200 echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
218 echo "\tvol\tSet the volume, takes an argument from 0 to 100" 201 echo "\tvol\tSet the volume, takes an argument from 0 to 100"
219 echo "\thelp\tshow this message and exit" 202 echo "\thelp\tshow this message and exit"
220 return 0 203 return 0
221 ;; 204 ;;
222 *) 205 *)
223 print "Unknown option: $opt" 206 print "Unknown option: $opt"
224 return 1 207 return 1
225 ;; 208 ;;
226 esac 209 esac
227 osascript -e "tell application \"iTunes\" to $opt" 210 osascript -e "tell application \"iTunes\" to $opt"
228 } 211 }
229 212
plugins/paver/paver.plugin.zsh
File was created 1 _paver_does_target_list_need_generating () {
2 [ ! -f .paver_targets ] && return 0;
3 [ pavement.py -nt .paver_targets ] && return 0;
4 return 1;
5 }
6
7 _paver () {
8 if [ -f pavement.py ]; then
9 if _paver_does_target_list_need_generating; then
10 paver --help 2>&1 |grep '-'|grep -v -e '--'|awk -F '-' '{print $1}'|tr -d ' ' > .paver_targets
11 fi
12 compadd `cat .paver_targets`
13 fi
14 }
15
16 compdef _paver paver
17
1 #compdef pod 1 #compdef pod
2 #autoload 2 #autoload
3 # setopt XTRACE VERBOSE
4 # vim: ft=zsh sw=2 ts=2 et
5
3 6
4 # ----------------------------------------------------------------------------- 7 # -----------------------------------------------------------------------------
5 # FILE: _pod 8 # FILE: _pod
6 # DESCRIPTION: Cocoapods (0.27.1) autocomplete plugin for Oh-My-Zsh 9 # DESCRIPTION: Cocoapods (0.33.1) autocomplete plugin for Oh-My-Zsh
7 # http://cocoapods.org 10 # http://cocoapods.org
11 # Generated with `pod --completion-script
8 # AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch) 12 # AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch)
9 # GITHUB: https://github.com/mekanics 13 # GITHUB: https://github.com/mekanics
10 # TWITTER: @jolyAlexandre 14 # TWITTER: @jolyAlexandre
11 # VERSION: 0.0.3 15 # VERSION: 0.0.5
12 # LICENSE: MIT
13 # ----------------------------------------------------------------------------- 16 # -----------------------------------------------------------------------------
14 17
15 local -a _1st_arguments 18 local -a _subcommands
16 _1st_arguments=( 19 local -a _options
17 'help:Show help for the given command' 20
18 'init:Generate a Podfile for the current directory' 21 case "$words[2]" in
19 'install:Install project dependencies' 22 help)
20 'ipc:Inter-process communication' 23 case "$words[3]" in
21 'list:List pods' 24 *) # pod help
22 'outdated:Show outdated project dependencies' 25 _options=(
23 'podfile-info:Shows information on installed Pods' 26 "--help:Show help banner of specified command"
24 'push:Push new specifications to a spec-repo' 27 "--no-ansi:Show output without ANSI codes"
25 'repo:Manage spec-repositories' 28 "--silent:Show nothing"
26 'search:Searches for pods' 29 "--verbose:Show more debugging information"
27 'setup:Setup the CocoaPods environment' 30 )
28 'spec:Manage pod specs' 31 _describe -t options "pod help options" _options
29 'update:Update outdated project dependencies' 32 ;;
30 )
31
32 local -a _repo_arguments
33 _repo_arguments=(
34 'add:Add a spec repo'
35 'lint:Validates all specs in a repo'
36 'remove:Remove a spec repo.'
37 'update:Update a spec repo'
38 )
39
40 local -a _spec_arguments
41 _spec_arguments=(
42 'cat:Prints a spec file'
43 'create:Create spec file stub'
44 'edit:Edit a spec file'
45 'lint:Validates a spec file'
46 'which:Prints the path of the given spec'
47 )
48
49 local -a _ipc_arguments
50 _ipc_arguments=(
51 'list:Lists the specifications know to CocoaPods'
52 'podfile:Converts a Podfile to YAML'
53 'repl:The repl listens to commands on standard input'
54 'spec:Converts a podspec to YAML'
55 'update-search-index:Updates the search index'
56 )
57
58 local -a _list_arguments
59 _list_arguments=(
60 'new:Lists pods introduced in the master spec-repo since the last check'
61 )
62
63 local -a _inherited_options
64 _inherited_options=(
65 '(--silent)--silent[Show nothing]' \
66 '(--version)--version[Show the version of CocoaPods]' \
67 '(--no-color)--no-color[Show output without color]' \
68 '(--verbose)--verbose[Show more debugging information]' \
69 '(--help)--help[Show help banner of specified command]'
70 )
71
72 local -a _install_options
73 _install_options=(
74 '(--no-clean)--no-clean[Leave SCM dirs like `.git` and `.svn` intact after downloading]' \
75 '(--no-integrate)--no-integrate[Skip integration of the Pods libraries in the Xcode project(s)]' \
76 '(--no-repo-update)--no-repo-update[Skip running `pod repo update` before install]'
77 )
78
79 local -a _update_options
80 _update_options=(
81 '(--no-clean)--no-clean[Leave SCM dirs like `.git` and `.svn intact after downloading]' \
82 '(--no-integrate)--no-integrate[Skip integration of the Pods libraries in the Xcode project(s)]' \
83 '(--no-repo-update)--no-repo-update[Skip running `pod repo update before install]'
84 )
85
86 local -a _outdated_options
87 _outdated_options=(
88 '(--no-repo-update)--no-repo-update[Skip running `pod repo update` before install]'
89 )
90
91 local -a _search_options
92 _search_options=(
93 '(--full)--full[Search by name, summary, and description]' \
94 '(--stats)--stats[Show additional stats (like GitHub watchers and forks)]' \
95 '(--ios)--ios[Restricts the search to Pods supported on iOS]' \
96 '(--osx)--osx[Restricts the search to Pods supported on OS X]'
97 )
98
99 local -a _list_options
100 _list_options=(
101 '(--update)--update[Run `pod repo update` before listing]'
102 )
103
104 local -a _podfile_info_options
105 _podfile_info_options=(
106 '(--all)--all[Show information about all Pods with dependencies that are used in a project]' \
107 '(--md)--md[Output information in Markdown format]' \
108 '*:script or directory:_files'
109 )
110
111 local -a _push_options
112 _push_options=(
113 '(--allow-warnings)--allow-warnings[Allows pushing even if there are warnings]' \
114 '(--local-only)--local-only[Does not perform the step of pushing REPO to its remote]' \
115 '*:script or directory:_files'
116 )
117
118 local -a _repo_lint_options
119 _repo_lint_options=(
120 '(--only-errors)--only-errors[Lint presents only the errors]'
121 )
122
123 local -a _setup_options
124 _setup_options=(
125 '(--push)--push[Use this option to enable push access once granted]'
126 )
127
128 local -a _spec_lint_options
129 _spec_lint_options=(
130 '(--quick)--quick[Lint skips checks that would require to download and build the spec]' \
131 '(--only-errors)--only-errors[Lint validates even if warnings are present]' \
132 '(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]' \
133 '*:script or directory:_files'
134 )
135
136 local -a _spec_cat_options
137 _spec_cat_options=(
138 '(--show-all)--show-all[Pick from all versions of the given podspec]'
139 )
140
141 local -a _spec_which_options
142 _spec_which_options=(
143 '(--show-all)--show-all[Print all versions of the given podspec]'
144 )
145
146 local -a _spec_edit_options
147 _spec_edit_options=(
148 '(--show-all)--show-all[Pick which spec to edit from all available versions of the given podspec]'
149 )
150
151
152 __first_command_list ()
153 {
154 local expl
155 declare -a tasks
156
157 tasks=(install ipc list outdated podfile-info push repo search setup spec update)
158
159 _wanted tasks expl 'help' compadd $tasks
160 }
161
162 __repo_list() {
163 _wanted application expl 'repo' compadd $(command ls -1 ~/.cocoapods/repos 2>/dev/null | sed -e 's/ /\\ /g')
164 }
165
166 __pod-repo() {
167 local curcontext="$curcontext" state line
168 typeset -A opt_args
169
170 _arguments -C \
171 ':command:->command' \
172 '*::options:->options'
173
174 case $state in
175 (command)
176 _describe -t commands "pod repo" _repo_arguments
177 return
178 ;;
179
180 (options)
181 case $line[1] in
182 (lint)
183 _arguments \
184 $_inherited_options \
185 $_repo_lint_options \
186 ':feature:__repo_list'
187 ;;
188
189 (update)
190 _arguments \
191 $_inherited_options \
192 ':feature:__repo_list'
193 ;;
194
195 (add)
196 _arguments \
197 $_inherited_options
198
199 (remove)
200 _arguments \
201 $_inherited_options \
202 ':feature:__repo_list'
203 ;;
204 esac
205 ;;
206 esac 33 esac
207 } 34 ;;
208 35 ipc)
209 __pod-spec() { 36 case "$words[3]" in
210 local curcontext="$curcontext" state line 37 list)
211 typeset -A opt_args 38 case "$words[4]" in
212 39 *) # pod ipc list
213 _arguments -C \ 40 _options=(
214 ':command:->command' \ 41 "--help:Show help banner of specified command"
215 '*::options:->options' 42 "--no-ansi:Show output without ANSI codes"
216 43 "--silent:Show nothing"
217 case $state in 44 "--verbose:Show more debugging information"
218 (command) 45 )
219 _describe -t commands "pod spec" _spec_arguments 46 _describe -t options "pod ipc list options" _options
220 return 47 ;;
221 ;; 48 esac
222 49 ;;
223 (options) 50 podfile)
224 case $line[1] in 51 case "$words[4]" in
225 (create) 52 *) # pod ipc podfile
226 _arguments \ 53 _options=(
227 $_inherited_options 54 "--help:Show help banner of specified command"
228 ;; 55 "--no-ansi:Show output without ANSI codes"
229 56 "--silent:Show nothing"
230 (lint) 57 "--verbose:Show more debugging information"
231 _arguments \ 58 )
232 $_inherited_options \ 59 _describe -t options "pod ipc podfile options" _options
233 $_spec_lint_options 60 ;;
234 ;; 61 esac
235 62 ;;
236 (cat) 63 repl)
237 _arguments \ 64 case "$words[4]" in
238 $_inherited_options \ 65 *) # pod ipc repl
239 $_spec_cat_options 66 _options=(
240 ;; 67 "--help:Show help banner of specified command"
241 68 "--no-ansi:Show output without ANSI codes"
242 (which) 69 "--silent:Show nothing"
243 _arguments \ 70 "--verbose:Show more debugging information"
244 $_inherited_options \ 71 )
245 $_spec_which_options 72 _describe -t options "pod ipc repl options" _options
246 ;; 73 ;;
247 74 esac
248 (edit) 75 ;;
249 _arguments \ 76 spec)
250 $_inherited_options \ 77 case "$words[4]" in
251 $_spec_edit_options 78 *) # pod ipc spec
252 ;; 79 _options=(
253 esac 80 "--help:Show help banner of specified command"
254 return 81 "--no-ansi:Show output without ANSI codes"
255 ;; 82 "--silent:Show nothing"
83 "--verbose:Show more debugging information"
84 )
85 _describe -t options "pod ipc spec options" _options
86 ;;
87 esac
88 ;;
89 update-search-index)
90 case "$words[4]" in
91 *) # pod ipc update-search-index
92 _options=(
93 "--help:Show help banner of specified command"
94 "--no-ansi:Show output without ANSI codes"
95 "--silent:Show nothing"
96 "--verbose:Show more debugging information"
97 )
98 _describe -t options "pod ipc update-search-index options" _options
99 ;;
100 esac
101 ;;
102 *) # pod ipc
103 _subcommands=(
104 "list:Lists the specifications known to CocoaPods."
105 "podfile:Converts a Podfile to YAML."
106 "repl:The repl listens to commands on standard input."
107 "spec:Converts a podspec to JSON."
108 "update-search-index:Updates the search index."
109 )
110 _describe -t commands "pod ipc subcommands" _subcommands
111 _options=(
112 "--help:Show help banner of specified command"
113 "--no-ansi:Show output without ANSI codes"
114 "--silent:Show nothing"
115 "--verbose:Show more debugging information"
116 )
117 _describe -t options "pod ipc options" _options
118 ;;
256 esac 119 esac
257 } 120 ;;
258 121 init)
259 __pod-ipc() { 122 case "$words[3]" in
260 local curcontext="$curcontext" state line 123 *) # pod init
261 typeset -A opt_args 124 _options=(
262 125 "--help:Show help banner of specified command"
263 _arguments -C \ 126 "--no-ansi:Show output without ANSI codes"
264 ':command:->command' \ 127 "--silent:Show nothing"
265 '*::options:->options' 128 "--verbose:Show more debugging information"
266 129 )
267 case $state in 130 _describe -t options "pod init options" _options
268 (command) 131 ;;
269 _describe -t commands "pod ipc" _ipc_arguments
270 return
271 ;;
272
273 (options)
274 _arguments -C \
275 $_inherited_options
276 return
277 ;;
278 esac 132 esac
279 } 133 ;;
280 134 install)
281 __pod-list() { 135 case "$words[3]" in
282 local curcontext="$curcontext" state line 136 *) # pod install
283 typeset -A opt_args 137 _options=(
284 138 "--help:Show help banner of specified command"
285 _arguments -C \ 139 "--no-ansi:Show output without ANSI codes"
286 $_inherited_options \ 140 "--no-clean:Leave SCM dirs like \`.git\` and \`.svn\` intact after downloading"
287 $_list_options \ 141 "--no-integrate:Skip integration of the Pods libraries in the Xcode project(s)"
288 ':command:->command' \ 142 "--no-repo-update:Skip running \`pod repo update\` before install"
289 '*::options:->options' 143 "--silent:Show nothing"
290 144 "--verbose:Show more debugging information"
291 case $state in 145 )
292 (command) 146 _describe -t options "pod install options" _options
293 _describe -t commands "pod list" _list_arguments 147 ;;
294 return
295 ;;
296
297 (options)
298 _arguments -C \
299 $_inherited_options \
300 $_list_options
301 return
302 ;;
303 esac 148 esac
304 }
305
306 local curcontext="$curcontext" state line
307 typeset -A opt_args
308
309 _arguments -C \
310 $_inherited_options \
311 ':command:->command' \
312 '*::options:->options'
313
314 case $state in
315 (command)
316 _describe -t commands "pod" _1st_arguments
317 return
318 ;; 149 ;;
319 150 lib)
320 (options) 151 case "$words[3]" in
321 case $line[1] in 152 create)
322 (help) 153 case "$words[4]" in
323 _arguments \ 154 *) # pod lib create
324 $_inherited_options \ 155 _options=(
325 ':help:__first_command_list' 156 "--help:Show help banner of specified command"
326 ;; 157 "--no-ansi:Show output without ANSI codes"
327 158 "--silent:Show nothing"
328 (push) 159 "--verbose:Show more debugging information"
329 _arguments \ 160 )
330 $_inherited_options \ 161 _describe -t options "pod lib create options" _options
331 $_push_options \ 162 ;;
332 ':repo:__repo_list' 163 esac
333 ;; 164 ;;
334 165 lint)
335 (repo) 166 case "$words[4]" in
336 __pod-repo 167 *) # pod lib lint
337 ;; 168 _options=(
338 169 "--help:Show help banner of specified command"
339 (spec) 170 "--no-ansi:Show output without ANSI codes"
340 __pod-spec 171 "--no-clean:Lint leaves the build directory intact for inspection"
341 ;; 172 "--no-subspecs:Lint skips validation of subspecs"
342 173 "--only-errors:Lint validates even if warnings are present"
343 (ipc) 174 "--quick:Lint skips checks that would require to download and build the spec"
344 __pod-ipc 175 "--silent:Show nothing"
345 ;; 176 "--subspec=NAME:Lint validates only the given subspec"
346 177 "--verbose:Show more debugging information"
347 (list) 178 )
348 __pod-list 179 _describe -t options "pod lib lint options" _options
349 ;; 180 ;;
350 181 esac
351 (install) 182 ;;
352 _arguments \ 183 *) # pod lib
353 $_inherited_options \ 184 _subcommands=(
354 $_install_options 185 "create:Creates a new Pod"
355 ;; 186 "lint:Validates a Pod"
356 187 )
357 (update) 188 _describe -t commands "pod lib subcommands" _subcommands
358 _arguments \ 189 _options=(
359 $_inherited_options \ 190 "--help:Show help banner of specified command"
360 $_update_options 191 "--no-ansi:Show output without ANSI codes"
361 ;; 192 "--silent:Show nothing"
362 193 "--verbose:Show more debugging information"
363 (outdated) 194 )
364 _arguments \ 195 _describe -t options "pod lib options" _options
365 $_inherited_options \ 196 ;;
366 $_outdated_options 197 esac
367 ;; 198 ;;
368 199 list)
369 (search) 200 case "$words[3]" in
370 _arguments \ 201 new)
371 $_inherited_options \ 202 case "$words[4]" in
372 $_search_options 203 *) # pod list new
373 ;; 204 _options=(
374 205 "--help:Show help banner of specified command"
375 (podfile-info) 206 "--no-ansi:Show output without ANSI codes"
376 _arguments \ 207 "--silent:Show nothing"
377 $_inherited_options \ 208 "--update:Run \`pod repo update\` before listing"
378 $_podfile_info_options 209 "--verbose:Show more debugging information"
379 ;; 210 )
380 211 _describe -t options "pod list new options" _options
381 (setup) 212 ;;
382 _arguments \ 213 esac
383 $_inherited_options \ 214 ;;
384 $_setup_options 215 *) # pod list
385 ;; 216 _subcommands=(
386 217 "new:Lists pods introduced in the master spec-repo since the last check"
218 )
219 _describe -t commands "pod list subcommands" _subcommands
220 _options=(
221 "--help:Show help banner of specified command"
222 "--no-ansi:Show output without ANSI codes"
223 "--silent:Show nothing"
224 "--update:Run \`pod repo update\` before listing"
225 "--verbose:Show more debugging information"
226 )
227 _describe -t options "pod list options" _options
228 ;;
229 esac
230 ;;
231 outdated)
232 case "$words[3]" in
233 *) # pod outdated
234 _options=(
235 "--help:Show help banner of specified command"
236 "--no-ansi:Show output without ANSI codes"
237 "--no-repo-update:Skip running \`pod repo update\` before install"
238 "--silent:Show nothing"
239 "--verbose:Show more debugging information"
240 )
241 _describe -t options "pod outdated options" _options
242 ;;
243 esac
244 ;;
245 plugins)
246 case "$words[3]" in
247 create)
248 case "$words[4]" in
249 *) # pod plugins create
250 _options=(
251 "--help:Show help banner of specified command"
252 "--no-ansi:Show output without ANSI codes"
253 "--silent:Show nothing"
254 "--verbose:Show more debugging information"
255 )
256 _describe -t options "pod plugins create options" _options
257 ;;
258 esac
259 ;;
260 list)
261 case "$words[4]" in
262 *) # pod plugins list
263 _options=(
264 "--help:Show help banner of specified command"
265 "--no-ansi:Show output without ANSI codes"
266 "--verbose:Show more debugging information"
267 )
268 _describe -t options "pod plugins list options" _options
269 ;;
270 esac
271 ;;
272 search)
273 case "$words[4]" in
274 *) # pod plugins search
275 _options=(
276 "--full:Search by name, author, and description"
277 "--help:Show help banner of specified command"
278 "--no-ansi:Show output without ANSI codes"
279 "--verbose:Show more debugging information"
280 )
281 _describe -t options "pod plugins search options" _options
282 ;;
283 esac
284 ;;
285 *) # pod plugins
286 _subcommands=(
287 "create:Creates a new plugin"
288 "list:List all known plugins"
289 "search:Search for known plugins"
290 )
291 _describe -t commands "pod plugins subcommands" _subcommands
292 _options=(
293 "--help:Show help banner of specified command"
294 "--no-ansi:Show output without ANSI codes"
295 "--silent:Show nothing"
296 "--verbose:Show more debugging information"
297 )
298 _describe -t options "pod plugins options" _options
299 ;;
300 esac
301 ;;
302 push)
303 case "$words[3]" in
304 *) # pod push
305 _options=(
306 "--help:Show help banner of specified command"
307 "--no-ansi:Show output without ANSI codes"
308 "--silent:Show nothing"
309 "--verbose:Show more debugging information"
310 )
311 _describe -t options "pod push options" _options
312 ;;
313 esac
314 ;;
315 repo)
316 case "$words[3]" in
317 add)
318 case "$words[4]" in
319 *) # pod repo add
320 _options=(
321 "--help:Show help banner of specified command"
322 "--no-ansi:Show output without ANSI codes"
323 "--shallow:Create a shallow clone (fast clone, but no push capabilities)"
324 "--silent:Show nothing"
325 "--verbose:Show more debugging information"
326 )
327 _describe -t options "pod repo add options" _options
328 ;;
329 esac
330 ;;
331 lint)
332 case "$words[4]" in
333 *) # pod repo lint
334 _options=(
335 "--help:Show help banner of specified command"
336 "--no-ansi:Show output without ANSI codes"
337 "--only-errors:Lint presents only the errors"
338 "--silent:Show nothing"
339 "--verbose:Show more debugging information"
340 )
341 _describe -t options "pod repo lint options" _options
342 ;;
343 esac
344 ;;
345 push)
346 case "$words[4]" in
347 *) # pod repo push
348 _options=(
349 "--allow-warnings:Allows pushing even if there are warnings"
350 "--help:Show help banner of specified command"
351 "--local-only:Does not perform the step of pushing REPO to its remote"
352 "--no-ansi:Show output without ANSI codes"
353 "--silent:Show nothing"
354 "--verbose:Show more debugging information"
355 )
356 _describe -t options "pod repo push options" _options
357 ;;
358 esac
359 ;;
360 remove)
361 case "$words[4]" in
362 *) # pod repo remove
363 _options=(
364 "--help:Show help banner of specified command"
365 "--no-ansi:Show output without ANSI codes"
366 "--silent:Show nothing"
367 "--verbose:Show more debugging information"
368 )
369 _describe -t options "pod repo remove options" _options
370 ;;
371 esac
372 ;;
373 update)
374 case "$words[4]" in
375 *) # pod repo update
376 _options=(
377 "--help:Show help banner of specified command"
378 "--no-ansi:Show output without ANSI codes"
379 "--silent:Show nothing"
380 "--verbose:Show more debugging information"
381 )
382 _describe -t options "pod repo update options" _options
383 ;;
384 esac
385 ;;
386 *) # pod repo
387 _subcommands=(
388 "add:Add a spec repo."
389 "lint:Validates all specs in a repo."
390 "push:Push new specifications to a spec-repo"
391 "remove:Remove a spec repo"
392 "update:Update a spec repo."
393 )
394 _describe -t commands "pod repo subcommands" _subcommands
395 _options=(
396 "--help:Show help banner of specified command"
397 "--no-ansi:Show output without ANSI codes"
398 "--silent:Show nothing"
399 "--verbose:Show more debugging information"
400 )
401 _describe -t options "pod repo options" _options
402 ;;
387 esac 403 esac
388 ;; 404 ;;
405 search)
406 case "$words[3]" in
407 *) # pod search
408 _options=(
409 "--full:Search by name, summary, and description"
410 "--help:Show help banner of specified command"
411 "--ios:Restricts the search to Pods supported on iOS"
412 "--no-ansi:Show output without ANSI codes"
413 "--osx:Restricts the search to Pods supported on OS X"
414 "--stats:Show additional stats (like GitHub watchers and forks)"
415 "--verbose:Show more debugging information"
416 "--web:Searches on cocoapods.org"
417 )
418 _describe -t options "pod search options" _options
419 ;;
420 esac
421 ;;
422 setup)
423 case "$words[3]" in
424 *) # pod setup
425 _options=(
426 "--help:Show help banner of specified command"
427 "--no-ansi:Show output without ANSI codes"
428 "--no-shallow:Clone full history so push will work"
429 "--push:Use this option to enable push access once granted"
430 "--silent:Show nothing"
431 "--verbose:Show more debugging information"
432 )
433 _describe -t options "pod setup options" _options
434 ;;
435 esac
436 ;;
437 spec)
438 case "$words[3]" in
439 cat)
440 case "$words[4]" in
441 *) # pod spec cat
442 _options=(
443 "--help:Show help banner of specified command"
444 "--no-ansi:Show output without ANSI codes"
445 "--show-all:Pick from all versions of the given podspec"
446 "--silent:Show nothing"
447 "--verbose:Show more debugging information"
448 )
449 _describe -t options "pod spec cat options" _options
450 ;;
451 esac
452 ;;
453 create)
454 case "$words[4]" in
455 *) # pod spec create
456 _options=(
457 "--help:Show help banner of specified command"
458 "--no-ansi:Show output without ANSI codes"
459 "--silent:Show nothing"
460 "--verbose:Show more debugging information"
461 )
462 _describe -t options "pod spec create options" _options
463 ;;
464 esac
465 ;;
466 edit)
467 case "$words[4]" in
468 *) # pod spec edit
469 _options=(
470 "--help:Show help banner of specified command"
471 "--no-ansi:Show output without ANSI codes"
472 "--show-all:Pick which spec to edit from all available versions of the given podspec"
473 "--silent:Show nothing"
474 "--verbose:Show more debugging information"
plugins/rails/rails.plugin.zsh
1 function _rails_command () { 1 function _rails_command () {
2 if [ -e "bin/rails" ]; then 2 if [ -e "bin/rails" ]; then
3 bin/rails $@ 3 bin/rails $@
4 elif [ -e "script/rails" ]; then 4 elif [ -e "script/rails" ]; then
5 ruby script/rails $@ 5 ruby script/rails $@
6 elif [ -e "script/server" ]; then 6 elif [ -e "script/server" ]; then
7 ruby script/$@ 7 ruby script/$@
8 else 8 else
9 command rails $@ 9 command rails $@
10 fi 10 fi
11 } 11 }
12 12
13 function _rake_command () { 13 function _rake_command () {
14 if [ -e "bin/rake" ]; then 14 if [ -e "bin/rake" ]; then
15 bin/rake $@ 15 bin/rake $@
16 else 16 else
17 command rake $@ 17 command rake $@
18 fi 18 fi
19 } 19 }
20 20
21 alias rails='_rails_command' 21 alias rails='_rails_command'
22 compdef _rails_command=rails 22 compdef _rails_command=rails
23 23
24 alias rake='_rake_command' 24 alias rake='_rake_command'
25 compdef _rake_command=rake 25 compdef _rake_command=rake
26 26
27 alias devlog='tail -f log/development.log' 27 alias devlog='tail -f log/development.log'
28 alias prodlog='tail -f log/production.log' 28 alias prodlog='tail -f log/production.log'
29 alias testlog='tail -f log/test.log' 29 alias testlog='tail -f log/test.log'
30 30
31 alias -g RED='RAILS_ENV=development' 31 alias -g RED='RAILS_ENV=development'
32 alias -g REP='RAILS_ENV=production' 32 alias -g REP='RAILS_ENV=production'
33 alias -g RET='RAILS_ENV=test' 33 alias -g RET='RAILS_ENV=test'
34 34
35 # Rails aliases 35 # Rails aliases
36 alias rc='rails console' 36 alias rc='rails console'
37 alias rd='rails destroy' 37 alias rd='rails destroy'
38 alias rdb='rails dbconsole' 38 alias rdb='rails dbconsole'
39 alias rg='rails generate' 39 alias rg='rails generate'
40 alias rgm='rails generate migration' 40 alias rgm='rails generate migration'
41 alias rp='rails plugin' 41 alias rp='rails plugin'
42 alias ru='rails runner' 42 alias ru='rails runner'
43 alias rs='rails server' 43 alias rs='rails server'
44 alias rsd='rails server --debugger' 44 alias rsd='rails server --debugger'
45 45
46 # Rake aliases 46 # Rake aliases
47 alias rdm='rake db:migrate' 47 alias rdm='rake db:migrate'
48 alias rdms='rake db:migrate:status' 48 alias rdms='rake db:migrate:status'
49 alias rdr='rake db:rollback' 49 alias rdr='rake db:rollback'
50 alias rdc='rake db:create' 50 alias rdc='rake db:create'
51 alias rds='rake db:seed' 51 alias rds='rake db:seed'
52 alias rdd='rake db:drop' 52 alias rdd='rake db:drop'
53 alias rdrs='rake db:reset'
53 alias rdtc='rake db:test:clone' 54 alias rdtc='rake db:test:clone'
54 alias rdtp='rake db:test:prepare' 55 alias rdtp='rake db:test:prepare'
55 alias rdmtc='rake db:migrate db:test:clone' 56 alias rdmtc='rake db:migrate db:test:clone'
56 57
57 alias rlc='rake log:clear' 58 alias rlc='rake log:clear'
58 alias rn='rake notes' 59 alias rn='rake notes'
59 alias rr='rake routes' 60 alias rr='rake routes'
60 61
61 # legacy stuff 62 # legacy stuff
62 alias ss='thin --stats "/thin/stats" start' 63 alias sstat='thin --stats "/thin/stats" start'
63 alias sg='ruby script/generate' 64 alias sg='ruby script/generate'
64 alias sd='ruby script/destroy' 65 alias sd='ruby script/destroy'
65 alias sp='ruby script/plugin' 66 alias sp='ruby script/plugin'
66 alias sr='ruby script/runner' 67 alias sr='ruby script/runner'
67 alias ssp='ruby script/spec' 68 alias ssp='ruby script/spec'
68 alias sc='ruby script/console' 69 alias sc='ruby script/console'
69 alias sd='ruby script/server --debugger' 70 alias sd='ruby script/server --debugger'
70 71
71 function remote_console() { 72 function remote_console() {
72 /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )" 73 /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
73 } 74 }
74 75
plugins/rails3/rails3.plugin.zsh
1 echo "It looks like you have been using the 'rails3' plugin," File was deleted
2 echo "which has been deprecated in favor of a newly consolidated 'rails' plugin."
3 echo "You will want to modify your ~/.zshrc configuration to begin using it."
4 echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240"
5 1 echo "It looks like you have been using the 'rails3' plugin,"
plugins/rails4/rails4.plugin.zsh
1 echo "It looks like you have been using the 'rails4' plugin," File was deleted
2 echo "which has been deprecated in favor of a newly consolidated 'rails' plugin."
3 echo "You will want to modify your ~/.zshrc configuration to begin using it."
4 echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240"
5 1 echo "It looks like you have been using the 'rails4' plugin,"
plugins/sublime/README.md
1 ## sublime 1 ## sublime
2 2
3 Plugin for Sublime Text, a cross platform text and code editor, available for Linux, Mac OS X, and Windows. 3 Plugin for Sublime Text, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
4 4
5 ### Requirements 5 ### Requirements
6 6
7 * [Sublime Text](http://www.sublimetext.com/) 7 * [Sublime Text](http://www.sublimetext.com/)
8 8
9 ### Usage 9 ### Usage
10 10
11 * If `st` command is called without an argument, launch Sublime Text 11 * If `st` command is called without an argument, launch Sublime Text
12 12
13 * If `st` is passed a directory, `cd` to it and open it in Sublime Text 13 * If `st` is passed a directory, `cd` to it and open it in Sublime Text
14 14
15 * If `st` is passed a file, open it in Sublime Text 15 * If `st` is passed a file, open it in Sublime Text
16 16
17 * if `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text
17 * If `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text
18
plugins/sublime/sublime.plugin.zsh
1 # Sublime Text 2 Aliases 1 # Sublime Text 2 Aliases
2 2
3 if [[ $('uname') == 'Linux' ]]; then 3 if [[ $('uname') == 'Linux' ]]; then
4 local _sublime_linux_paths > /dev/null 2>&1 4 local _sublime_linux_paths > /dev/null 2>&1
5 _sublime_linux_paths=( 5 _sublime_linux_paths=(
6 "$HOME/bin/sublime_text" 6 "$HOME/bin/sublime_text"
7 "/opt/sublime_text/sublime_text" 7 "/opt/sublime_text/sublime_text"
8 "/opt/sublime_text_3/sublime_text"
8 "/usr/bin/sublime_text" 9 "/usr/bin/sublime_text"
9 "/usr/local/bin/sublime_text" 10 "/usr/local/bin/sublime_text"
10 "/usr/bin/subl" 11 "/usr/bin/subl"
12 "/opt/sublime_text_3/sublime_text"
13 "/usr/bin/subl3"
11 ) 14 )
12 for _sublime_path in $_sublime_linux_paths; do 15 for _sublime_path in $_sublime_linux_paths; do
13 if [[ -a $_sublime_path ]]; then 16 if [[ -a $_sublime_path ]]; then
14 st_run() { $_sublime_path $@ >/dev/null 2>&1 &| } 17 st_run() { $_sublime_path $@ >/dev/null 2>&1 &| }
15 st_run_sudo() {sudo $_sublime_path $@ >/dev/null 2>&1} 18 st_run_sudo() {sudo $_sublime_path $@ >/dev/null 2>&1}
16 alias sst=st_run_sudo 19 alias sst=st_run_sudo
17 alias st=st_run 20 alias st=st_run
18 break 21 break
19 fi 22 fi
20 done 23 done
21 24
22 elif [[ "$OSTYPE" = darwin* ]]; then 25 elif [[ "$OSTYPE" = darwin* ]]; then
23 local _sublime_darwin_paths > /dev/null 2>&1 26 local _sublime_darwin_paths > /dev/null 2>&1
24 _sublime_darwin_paths=( 27 _sublime_darwin_paths=(
25 "/usr/local/bin/subl" 28 "/usr/local/bin/subl"
26 "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" 29 "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
27 "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" 30 "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
28 "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" 31 "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
29 "$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" 32 "$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
30 "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" 33 "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
31 "$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" 34 "$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
32 ) 35 )
33 36
34 for _sublime_path in $_sublime_darwin_paths; do 37 for _sublime_path in $_sublime_darwin_paths; do
35 if [[ -a $_sublime_path ]]; then 38 if [[ -a $_sublime_path ]]; then
36 alias subl="'$_sublime_path'" 39 subl () { "$_sublime_path" $* }
37 alias st=subl 40 alias st=subl
38 break 41 break
39 fi 42 fi
40 done 43 done
41 fi 44 fi
42 45
43 alias stt='st .' 46 alias stt='st .'
44 47
plugins/taskwarrior/taskwarrior.plugin.zsh
1 ################################################################################ 1 ################################################################################
2 # Author: Pete Clark 2 # Author: Pete Clark
3 # Email: pete[dot]clark[at]gmail[dot]com 3 # Email: pete[dot]clark[at]gmail[dot]com
4 # Version: 0.1 (05/24/2011) 4 # Version: 0.1 (05/24/2011)
5 # License: WTFPL<http://sam.zoy.org/wtfpl/> 5 # License: WTFPL<http://sam.zoy.org/wtfpl/>
6 # 6 #
7 # This oh-my-zsh plugin adds smart tab completion for 7 # This oh-my-zsh plugin adds smart tab completion for
8 # TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion 8 # TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
9 # script (_task) distributed with TaskWarrior for the completion definitions. 9 # script (_task) distributed with TaskWarrior for the completion definitions.
10 # 10 #
11 # Typing task[tabtab] will give you a list of current tasks, task 66[tabtab] 11 # Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
12 # gives a list of available modifications for that task, etc. 12 # gives a list of available modifications for that task, etc.
13 ################################################################################ 13 ################################################################################
14 14
15 zstyle ':completion:*:*:task:*' verbose yes 15 zstyle ':completion:*:*:task:*' verbose yes
16 zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u' 16 zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
17 17
18 zstyle ':completion:*:*:task:*' group-name '' 18 zstyle ':completion:*:*:task:*' group-name ''
19 19
20 alias t=task 20 alias t=task
21 compdef _task t=task 21 compdef _task t=task
22 22
plugins/tugboat/_tugboat
File was created 1 #compdef tugboat
2 #autoload
3
4 # Tugboat zsh autocompletion
5
6
7 local -a _commands
8 _commands=(
9 'add-key:[NAME] Upload an ssh public key.'
10 'authorize:Authorize a DigitalOcean account with tugboat.'
11 'create:[NAME] Create a droplet.'
12 'destroy:[FUZZY_NAME] Destroy a droplet.'
13 'destroy_image:[FUZZY_NAME] Destroy an image.'
14 'droplets:Retrieve a list of your droplets.'
15 'halt:[FUZZY_NAME] Shutdown a droplet.'
16 'help:[COMMAND] Describe commands or a specific command.'
17 'images:Retrieve a list of your images.'
18 'info:[FUZZY_NAME] [OPTIONS] Show a droplets information.'
19 'info_image:[FUZZY_NAME] [OPTIONS] Show an images information.'
20 'keys:Show available SSH keys.'
21 'password-reset:[FUZZY_NAME] Reset root password.'
22 'rebuild:[FUZZY_NAME] [IMAGE_NAME] Rebuild a droplet.'
23 'regions:Show regions.'
24 'resize:[FUZZY_NAME -s, --size=N] Resize a droplet.'
25 'restart:[FUZZY_NAME] Restart a droplet.'
26 'sizes:Show available droplet sizes.'
27 'snapshot:[SNAPSHOT_NAME] [FUZZY_NAME] [OPTIONS] Queue a snapshot of the droplet.'
28 'ssh:[FUZZY_NAME] SSH into a droplet.'
29 'start:[FUZZY_NAME] Start a droplet.'
30 'verify:Check your DigitalOcean credentials.'
31 'version:Show version.'
32 'wait:[FUZZY_NAME] Wait for a droplet to reach a state.'
33 )
34
35 local -a _create_arguments
36 _create_arguments=(
37 '-s:[--size=N] The size_id of the droplet'
38 '-i:[--image=N] The image_id of the droplet'
39 '-r:[--region=N] The region_id of the droplet'
40 '-k:[--keys=KEYS] A comma separated list of SSH key ids to add to the droplet'
41 '-p:[--private-networking] Enable private networking on the droplet'
42 '-b:[--backups-enabled] Enable backups on the droplet'
43 '-q:[--quiet]'
44 )
45
46 __task_list ()
47 {
48 local expl
49 declare -a tasks
50
51 arguments=(add-key authorize create destroy destroy_image droplets halt help images info info_image keys password-reset rebuild regions resize restart sizes snapshot ssh start verify version wait)
52
53 _wanted tasks expl 'help' compadd $arguments
54 }
55
56 __droplets_list ()
57 {
58 _wanted application expl 'command' compadd $(command tugboat droplets | cut -d " " -f1)
59 }
60
61 __tugboat-create ()
62 {
63 local curcontext="$curcontext" state line
64 typeset -A opt_args
65
66 _arguments -C \
67 ':command:->command' \
68 '*::options:->options'
69
70 case $state in
71 (command)
72 _describe -t commands "gem subcommand" _create_arguments
73 return
74 ;;
75 esac
76 }
77
78 local curcontext="$curcontext" state line
79 typeset -A opt_args
80
81 _arguments -C \
82 ':command:->command' \
83 '*::options:->options'
84
85 case $state in
86 (command)
87 _describe -t commands "gem subcommand" _commands
88 return
89 ;;
90
91 (options)
92 case $line[1] in
93 (help)
94 _arguments ':feature:__task_list'
95 ;;
96
97 (ssh)
98 _arguments ':feature:__droplets_list'
99 ;;
100
101 (create)
102 _arguments ':feature:__tugboat-create'
103 ;;
104 esac
105 ;;
106 esac
107
plugins/vi-mode/README.md
File was created 1 vi-mode
2 =======
3 This plugin increase `vi-like` zsh functionality.
4
5 Use `ESC` or `CTRL-[` to enter `Normal mode`.
6
7
8 History
9 -------
10
11 - `ctrl-p` : Previous command in history
12 - `ctrl-n` : Next command in history
13 - `/` : Search backward in history
14 - `n` : Repeat the last `/`
15
16
17 Mode indicators
18 ---------------
19
20 *Normal mode* is indicated with red `<<<` mark at the right prompt, when it
21 wasn't defined by theme.
22
23
24 Vim edition
25 -----------
26
27 - `v` : Edit current command line in Vim
28
29
30 Movement
31 --------
32
33 - `$` : To the end of the line
34 - `^` : To the first non-blank character of the line
35 - `0` : To the first character of the line
36 - `w` : [count] words forward
37 - `W` : [count] WORDS forward
38 - `e` : Forward to the end of word [count] inclusive
39 - `E` : Forward to the end of WORD [count] inclusive
40 - `b` : [count] words backward
41 - `B` : [count] WORDS backward
42 - `t{char}` : Till before [count]'th occurrence of {char} to the right
43 - `T{char}` : Till before [count]'th occurrence of {char} to the left
44 - `f{char}` : To [count]'th occurrence of {char} to the right
45 - `F{char}` : To [count]'th occurrence of {char} to the left
46 - `;` : Repeat latest f, t, F or T [count] times
47 - `,` : Repeat latest f, t, F or T in opposite direction
48
49
50 Insertion
51 ---------
52
53 - `i` : Insert text before the cursor
54 - `I` : Insert text before the first character in the line
55 - `a` : Append text after the cursor
56 - `A` : Append text at the end of the line
57 - `o` : Insert new command line below the current one
58 - `O` : Insert new command line above the current one
59
60
61 Delete and Insert
62 -----------------
63
64 - `ctrl-h` : While in *Insert mode*: delete character after the cursor
65 - `ctrl-w` : While in *Insert mode*: delete word after the cursor
66 - `d{motion}` : Delete text that {motion} moves over
67 - `dd` : Delete line
68 - `D` : Delete characters under the cursor until the end of the line
69 - `c{motion}` : Delete {motion} text and start insert
70 - `cc` : Delete line and start insert
71 - `C` : Delete to the end of the line and start insert
72 - `r{char}` : Replace the character under the cursor with {char}
73 - `R` : Enter replace mode: Each character replaces existing one
74 - `x` : Delete [count] characters under and after the cursor
75 - `X` : Delete [count] characters before the cursor
76
plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
1 virtualenvwrapper='virtualenvwrapper.sh' 1 virtualenvwrapper='virtualenvwrapper.sh'
2 2
3 if (( $+commands[$virtualenvwrapper] )); then 3 if (( $+commands[$virtualenvwrapper] )); then
4 source ${${virtualenvwrapper}:c} 4 function {
5 setopt local_options
6 unsetopt equals
7 source ${${virtualenvwrapper}:c}
8 }
5 elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then 9 elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
6 virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper" 10 function {
7 source "/etc/bash_completion.d/virtualenvwrapper" 11 setopt local_options
12 unsetopt equals
13 virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
14 source "/etc/bash_completion.d/virtualenvwrapper"
15 }
8 else 16 else
9 print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\ 17 print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
10 "Please install with \`pip install virtualenvwrapper\`" >&2 18 "Please install with \`pip install virtualenvwrapper\`" >&2
11 return 19 return
12 fi 20 fi
13 if ! type workon &>/dev/null; then 21 if ! type workon &>/dev/null; then
14 print "zsh virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ 22 print "zsh virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
15 "Please check ${virtualenvwrapper}" >&2 23 "Please check ${virtualenvwrapper}" >&2
16 return 24 return
17 fi 25 fi
18 26
19 if [[ "$WORKON_HOME" == "" ]]; then 27 if [[ "$WORKON_HOME" == "" ]]; then
20 print "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" >&2 28 print "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" >&2
21 return 29 return
22 fi 30 fi
23 31
24 if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then 32 if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
25 # Automatically activate Git projects's virtual environments based on the 33 # Automatically activate Git projects's virtual environments based on the
26 # directory name of the project. Virtual environment name can be overridden 34 # directory name of the project. Virtual environment name can be overridden
27 # by placing a .venv file in the project root with a virtualenv name in it 35 # by placing a .venv file in the project root with a virtualenv name in it
28 function workon_cwd { 36 function workon_cwd {
29 if [ ! $WORKON_CWD ]; then 37 if [ ! $WORKON_CWD ]; then
30 WORKON_CWD=1 38 WORKON_CWD=1
31 # Check if this is a Git repo 39 # Check if this is a Git repo
32 PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` 40 PROJECT_ROOT=`pwd`
33 if (( $? != 0 )); then 41 while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" ]]; do
42 PROJECT_ROOT=`realpath $PROJECT_ROOT/..`
43 done
44 if [[ "$PROJECT_ROOT" == "/" ]]; then
34 PROJECT_ROOT="." 45 PROJECT_ROOT="."
35 fi 46 fi
36 # Check for virtualenv name override 47 # Check for virtualenv name override
37 if [[ -f "$PROJECT_ROOT/.venv" ]]; then 48 if [[ -f "$PROJECT_ROOT/.venv" ]]; then
38 ENV_NAME=`cat "$PROJECT_ROOT/.venv"` 49 ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
39 elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then 50 elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
40 ENV_NAME="$PROJECT_ROOT/.venv" 51 ENV_NAME="$PROJECT_ROOT/.venv"
41 elif [[ "$PROJECT_ROOT" != "." ]]; then 52 elif [[ "$PROJECT_ROOT" != "." ]]; then
42 ENV_NAME=`basename "$PROJECT_ROOT"` 53 ENV_NAME=`basename "$PROJECT_ROOT"`
43 else 54 else
44 ENV_NAME="" 55 ENV_NAME=""
45 fi 56 fi
46 if [[ "$ENV_NAME" != "" ]]; then 57 if [[ "$ENV_NAME" != "" ]]; then
47 # Activate the environment only if it is not already active 58 # Activate the environment only if it is not already active
48 if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then 59 if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
49 if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then 60 if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
50 workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" 61 workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
51 elif [[ -e "$ENV_NAME/bin/activate" ]]; then 62 elif [[ -e "$ENV_NAME/bin/activate" ]]; then
52 source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" 63 source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
53 fi 64 fi
54 fi 65 fi
55 elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then 66 elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
56 # We've just left the repo, deactivate the environment 67 # We've just left the repo, deactivate the environment
57 # Note: this only happens if the virtualenv was activated automatically 68 # Note: this only happens if the virtualenv was activated automatically
58 deactivate && unset CD_VIRTUAL_ENV 69 deactivate && unset CD_VIRTUAL_ENV
59 fi 70 fi
60 unset PROJECT_ROOT 71 unset PROJECT_ROOT
61 unset WORKON_CWD 72 unset WORKON_CWD
62 fi 73 fi
63 } 74 }
64 75
65 # Append workon_cwd to the chpwd_functions array, so it will be called on cd 76 # Append workon_cwd to the chpwd_functions array, so it will be called on cd
66 # http://zsh.sourceforge.net/Doc/Release/Functions.html 77 # http://zsh.sourceforge.net/Doc/Release/Functions.html
67 if ! (( $chpwd_functions[(I)workon_cwd] )); then 78 if ! (( $chpwd_functions[(I)workon_cwd] )); then
68 chpwd_functions+=(workon_cwd) 79 chpwd_functions+=(workon_cwd)
69 fi 80 fi
70 fi 81 fi
71 82
plugins/vundle/vundle.plugin.zsh
1 function vundle-init () { 1 function vundle-init () {
2 if [ ! -d ~/.vim/bundle/vundle/ ] 2 if [ ! -d ~/.vim/bundle/vundle/ ]
3 then 3 then
4 mkdir -p ~/.vim/bundle/vundle/ 4 mkdir -p ~/.vim/bundle/vundle/
5 fi 5 fi
6 6
7 if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ] 7 if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ]
8 then 8 then
9 git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 9 git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
10 echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n" 10 echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n"
11 fi 11 fi
12 } 12 }
13 13
14 function vundle () { 14 function vundle () {
15 vundle-init 15 vundle-init
16 vim -c "execute \"BundleInstall\" | q | q" 16 vim -c "execute \"PluginInstall\" | q | q"
17 } 17 }
18 18
19 function vundle-update () { 19 function vundle-update () {
20 vundle-init 20 vundle-init
21 vim -c "execute \"BundleInstall!\" | q | q" 21 vim -c "execute \"PluginInstall!\" | q | q"
22 } 22 }
23 23
24 function vundle-clean () { 24 function vundle-clean () {
25 vundle-init 25 vundle-init
26 vim -c "execute \"BundleClean!\" | q | q" 26 vim -c "execute \"PluginClean!\" | q | q"
27 } 27 }
28 28
plugins/web-search/web-search.plugin.zsh
1 # web_search from terminal 1 # web_search from terminal
2 2
3 function web_search() { 3 function web_search() {
4 emulate -L zsh 4 emulate -L zsh
5 5
6 # define search engine URLS 6 # define search engine URLS
7 typeset -A urls 7 typeset -A urls
8 urls=( 8 urls=(
9 google "https://www.google.com/search?q=" 9 google "https://www.google.com/search?q="
10 bing "https://www.bing.com/search?q=" 10 bing "https://www.bing.com/search?q="
11 yahoo "https://search.yahoo.com/search?p=" 11 yahoo "https://search.yahoo.com/search?p="
12 duckduckgo "https://www.duckduckgo.com/?q=" 12 duckduckgo "https://www.duckduckgo.com/?q="
13 yandex "https://yandex.ru/yandsearch?text=" 13 yandex "https://yandex.ru/yandsearch?text="
14 github "https://github.com/search?q="
14 ) 15 )
15 16
16 # define the open command 17 # define the open command
17 case "$OSTYPE" in 18 case "$OSTYPE" in
18 darwin*) open_cmd="open" ;; 19 darwin*) open_cmd="open" ;;
19 cygwin*) open_cmd="cygstart" ;; 20 cygwin*) open_cmd="cygstart" ;;
20 linux*) open_cmd="xdg-open" ;; 21 linux*) open_cmd="xdg-open" ;;
21 *) echo "Platform $OSTYPE not supported" 22 *) echo "Platform $OSTYPE not supported"
22 return 1 23 return 1
23 ;; 24 ;;
24 esac 25 esac
25 26
26 # check whether the search engine is supported 27 # check whether the search engine is supported
27 if [[ -z "$urls[$1]" ]]; then 28 if [[ -z "$urls[$1]" ]]; then
28 echo "Search engine $1 not supported." 29 echo "Search engine $1 not supported."
29 return 1 30 return 1
30 fi 31 fi
31 32
32 # search or go to main page depending on number of arguments passed 33 # search or go to main page depending on number of arguments passed
33 if [[ $# -gt 1 ]]; then 34 if [[ $# -gt 1 ]]; then
34 # build search url: 35 # build search url:
35 # join arguments passed with '+', then append to search engine URL 36 # join arguments passed with '+', then append to search engine URL
36 url="${urls[$1]}${(j:+:)@[2,-1]}" 37 url="${urls[$1]}${(j:+:)@[2,-1]}"
37 else 38 else
38 # build main page url: 39 # build main page url:
39 # split by '/', then rejoin protocol (1) and domain (2) parts with '//' 40 # split by '/', then rejoin protocol (1) and domain (2) parts with '//'
40 url="${(j://:)${(s:/:)urls[$1]}[1,2]}" 41 url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
41 fi 42 fi
42 43
43 nohup $open_cmd "$url" &>/dev/null 44 nohup $open_cmd "$url" &>/dev/null
44 } 45 }
45 46
46 47
47 alias bing='web_search bing' 48 alias bing='web_search bing'
48 alias google='web_search google' 49 alias google='web_search google'
49 alias yahoo='web_search yahoo' 50 alias yahoo='web_search yahoo'
50 alias ddg='web_search duckduckgo' 51 alias ddg='web_search duckduckgo'
51 alias yandex='web_search yandex' 52 alias yandex='web_search yandex'
53 alias github='web_search github'
52 54
53 #add your own !bang searches here 55 #add your own !bang searches here
54 alias wiki='web_search duckduckgo \!w' 56 alias wiki='web_search duckduckgo \!w'
55 alias news='web_search duckduckgo \!n' 57 alias news='web_search duckduckgo \!n'
56 alias youtube='web_search duckduckgo \!yt' 58 alias youtube='web_search duckduckgo \!yt'
57 alias map='web_search duckduckgo \!m' 59 alias map='web_search duckduckgo \!m'
58 alias image='web_search duckduckgo \!i' 60 alias image='web_search duckduckgo \!i'
59 alias ducky='web_search duckduckgo \!' 61 alias ducky='web_search duckduckgo \!'
60 62
plugins/zeus/README.md
1 ## zeus 1 ## zeus
2 **Maintainer:** [b4mboo](https://github.com/b4mboo) 2 **Maintainer:** [b4mboo](https://github.com/b4mboo)
3 3
4 * `zi` aliases `zeus init` 4 * `zi` aliases `zeus init`
5 * `zinit` aliases `zeus init` 5 * `zinit` aliases `zeus init`
6 6
7 * `zs` aliases `zeus start` 7 * `zs` aliases `zeus start`
8 * `ztart` aliases `zeus start` 8 * `ztart` aliases `zeus start`
9 9
10 * `zc` aliases `zeus console` 10 * `zc` aliases `zeus console`
11 * `zonsole` aliases `zeus console` 11 * `zonsole` aliases `zeus console`
12 12
13 * `zsr` aliases `zeus server` 13 * `zsr` aliases `zeus server`
14 * `zerver` aliases `zeus server` 14 * `zerver` aliases `zeus server`
15 15
16 * `zr` aliases `zeus rake` 16 * `zr` aliases `zeus rake`
17 * `zake` aliases `zeus rake` 17 * `zake` aliases `zeus rake`
18 18
19 * `zg` aliases `zeus generate` 19 * `zg` aliases `zeus generate`
20 * `zenerate` aliases `zeus generate` 20 * `zenerate` aliases `zeus generate`
21 21
22 * `zrn` aliases `zeus runner` 22 * `zrn` aliases `zeus runner`
23 * `zunner` aliases `zeus runner` 23 * `zunner` aliases `zeus runner`
24 24
25 * `zcu` aliases `zeus cucumber` 25 * `zcu` aliases `zeus cucumber`
26 * `zucumber` aliases `zeus cucumber` 26 * `zucumber` aliases `zeus cucumber`
27 27
28 * `zspec` aliases `zeus rspec` 28 * `zspec` aliases `zeus rspec`
29 29
30 * `zt` aliases `zeus test` 30 * `zt` aliases `zeus test`
31 * `zest` aliases `zeus test` 31 * `zest` aliases `zeus test`
32 32
33 * `zu` aliases `zeus test test/unit/*` 33 * `zu` aliases `zeus test test/unit/*`
34 * `zunits` aliases `zeus test test/unit/*` 34 * `zunits` aliases `zeus test test/unit/*`
35 35
36 * `zf` aliases `zeus test test/functional/*` 36 * `zf` aliases `zeus test test/functional/*`
37 * `zunctional` aliases `zeus test test/functional/*` 37 * `zunctional` aliases `zeus test test/functional/*`
38 38
39 * `za` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber` 39 * `za` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber`
40 * `zall` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber` 40 * `zall` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber`
41 41
42 * `zsw` aliases `rm .zeus.sock` 42 * `zsw` aliases `rm .zeus.sock`
43 * `zweep` aliases `rm .zeus.sock` 43 * `zweep` aliases `rm .zeus.sock`
44 44
45 `zdbr` aliases `zeus rake db:reset db:test:prepare` 45 * `zdbr` aliases `zeus rake db:reset db:test:prepare`
46 `zdbreset` aliases `zeus rake db:reset db:test:prepare` 46 * `zdbreset` aliases `zeus rake db:reset db:test:prepare`
47 47
48 `zdbm` aliases `zeus rake db:migrate db:test:prepare` 48 * `zdbm` aliases `zeus rake db:migrate db:test:prepare`
49 `zdbmigrate` aliases `zeus rake db:migrate db:test:prepare` 49 * `zdbmigrate` aliases `zeus rake db:migrate db:test:prepare`
50 50
51 `zdbc` aliases `zeus rake db:create` 51 * `zdbc` aliases `zeus rake db:create`
52 52
53 `zdbcm` aliases `zeus rake db:create db:migrate db:test:prepare` 53 * `zdbcm` aliases `zeus rake db:create db:migrate db:test:prepare`
54
55 ## Installation
56 Add zeus to the plugins line of your `.zshconfig` file (e.g. `plugins=(rails git zeus)`)
54 57
plugins/zeus/zeus.plugin.zsh
1 # Some aliases for zeus. (See: https://github.com/burke/zeus) 1 # Some aliases for zeus. (See: https://github.com/burke/zeus)
2 # Zeus preloads your Rails environment and forks that process whenever 2 # Zeus preloads your Rails environment and forks that process whenever
3 # needed. This effectively speeds up Rails' boot process to under 1 sec. 3 # needed. This effectively speeds up Rails' boot process to under 1 sec.
4 4
5 # Init 5 # Init
6 alias zi='zeus init' 6 alias zi='zeus init'
7 alias zinit='zeus init' 7 alias zinit='zeus init'
8 8
9 # Start 9 # Start
10 alias zs='zeus start' 10 alias zs='zeus start'
11 alias ztart='zeus start' 11 alias ztart='zeus start'
12 12
13 # Console 13 # Console
14 alias zc='zeus console' 14 alias zc='zeus console'
15 alias zonsole='zeus console' 15 alias zonsole='zeus console'
16 16
17 # Server 17 # Server
18 alias zsr='zeus server' 18 alias zsr='zeus server'
19 alias zerver='zeus server' 19 alias zerver='zeus server'
20 20
21 # Rake 21 # Rake
22 alias zr='zeus rake' 22 alias zr='noglob zeus rake'
23 alias zake='zeus rake' 23 alias zake='noglob zeus rake'
24 24
25 # Generate 25 # Generate
26 alias zg='zeus generate' 26 alias zg='zeus generate'
27 alias zenerate='zeus generate' 27 alias zenerate='zeus generate'
28 28
29 # Runner 29 # Runner
30 alias zrn='zeus runner' 30 alias zrn='zeus runner'
31 alias zunner='zeus runner' 31 alias zunner='zeus runner'
32 32
33 # Cucumber 33 # Cucumber
34 alias zcu='zeus cucumber' 34 alias zcu='zeus cucumber'
35 alias zucumber='zeus cucumber' 35 alias zucumber='zeus cucumber'
36 36
37 # Rspec 37 # Rspec
38 alias zspec='zeus rspec' 38 alias zspec='zeus rspec'
39 39
40 # Test 40 # Test
41 alias zt='zeus test' 41 alias zt='zeus test'
42 alias zest='zeus test' 42 alias zest='zeus test'
43 43
44 alias zu='zeus test test/unit/*' 44 alias zu='zeus test test/unit/*'
45 alias zunits='zeus test test/unit/*' 45 alias zunits='zeus test test/unit/*'
46 46
47 alias zf='zeus test test/functional/*' 47 alias zf='zeus test test/functional/*'
48 alias zunctional='zeus test test/functional/*' 48 alias zunctional='zeus test test/functional/*'
49 49
50 alias za='zeus test test/unit/*; zeus test test/functional/; zeus cucumber' 50 alias za='zeus test test/unit/*; zeus test test/functional/; zeus cucumber'
51 alias zall='zeus test test/unit/*; zeus test test/functional/; zeus cucumber' 51 alias zall='zeus test test/unit/*; zeus test test/functional/; zeus cucumber'
52 52
53 # Clean up crashed zeus instances. 53 # Clean up crashed zeus instances.
54 alias zsw='rm .zeus.sock' 54 alias zsw='rm .zeus.sock'
55 alias zweep='rm .zeus.sock' 55 alias zweep='rm .zeus.sock'
56 56
57 # Reset database 57 # Reset database
58 alias zdbr='zeus rake db:reset db:test:prepare' 58 alias zdbr='zeus rake db:reset db:test:prepare'
59 alias zdbreset='zeus rake db:reset db:test:prepare' 59 alias zdbreset='zeus rake db:reset db:test:prepare'
60 60
61 # Migrate and prepare database 61 # Migrate and prepare database
62 alias zdbm='zeus rake db:migrate db:test:prepare' 62 alias zdbm='zeus rake db:migrate db:test:prepare'
63 alias zdbmigrate='zeus rake db:migrate db:test:prepare' 63 alias zdbmigrate='zeus rake db:migrate db:test:prepare'
64 64
65 # Create database 65 # Create database
66 alias zdbc='zeus rake db:create' 66 alias zdbc='zeus rake db:create'
67 67
68 # Create, migrate and prepare database 68 # Create, migrate and prepare database
69 alias zdbcm='zeus rake db:create db:migrate db:test:prepare' 69 alias zdbcm='zeus rake db:create db:migrate db:test:prepare'
templates/zshrc.zsh-template
1 # Path to your oh-my-zsh installation. 1 # Path to your oh-my-zsh installation.
2 export ZSH=$HOME/.oh-my-zsh 2 export ZSH=$HOME/.oh-my-zsh
3 3
4 # Set name of the theme to load. 4 # Set name of the theme to load.
5 # Look in ~/.oh-my-zsh/themes/ 5 # Look in ~/.oh-my-zsh/themes/
6 # Optionally, if you set this to "random", it'll load a random theme each 6 # Optionally, if you set this to "random", it'll load a random theme each
7 # time that oh-my-zsh is loaded. 7 # time that oh-my-zsh is loaded.
8 ZSH_THEME="robbyrussell" 8 ZSH_THEME="robbyrussell"
9 9
10 # Uncomment the following line to use case-sensitive completion. 10 # Uncomment the following line to use case-sensitive completion.
11 # CASE_SENSITIVE="true" 11 # CASE_SENSITIVE="true"
12 12
13 # Uncomment the following line to use hyphen-insensitive completion. Case
14 # sensitive completion must be off. _ and - will be interchangeable.
15 # HYPHEN_INSENSITIVE="true"
16
13 # Uncomment the following line to disable bi-weekly auto-update checks. 17 # Uncomment the following line to disable bi-weekly auto-update checks.
14 # DISABLE_AUTO_UPDATE="true" 18 # DISABLE_AUTO_UPDATE="true"
15 19
16 # Uncomment the following line to change how often to auto-update (in days). 20 # Uncomment the following line to change how often to auto-update (in days).
17 # export UPDATE_ZSH_DAYS=13 21 # export UPDATE_ZSH_DAYS=13
18 22
19 # Uncomment the following line to disable colors in ls. 23 # Uncomment the following line to disable colors in ls.
20 # DISABLE_LS_COLORS="true" 24 # DISABLE_LS_COLORS="true"
21 25
22 # Uncomment the following line to disable auto-setting terminal title. 26 # Uncomment the following line to disable auto-setting terminal title.
23 # DISABLE_AUTO_TITLE="true" 27 # DISABLE_AUTO_TITLE="true"
24 28
25 # Uncomment the following line to enable command auto-correction. 29 # Uncomment the following line to enable command auto-correction.
26 # ENABLE_CORRECTION="true" 30 # ENABLE_CORRECTION="true"
27 31
28 # Uncomment the following line to display red dots whilst waiting for completion. 32 # Uncomment the following line to display red dots whilst waiting for completion.
29 # COMPLETION_WAITING_DOTS="true" 33 # COMPLETION_WAITING_DOTS="true"
30 34
31 # Uncomment the following line if you want to disable marking untracked files 35 # Uncomment the following line if you want to disable marking untracked files
32 # under VCS as dirty. This makes repository status check for large repositories 36 # under VCS as dirty. This makes repository status check for large repositories
33 # much, much faster. 37 # much, much faster.
34 # DISABLE_UNTRACKED_FILES_DIRTY="true" 38 # DISABLE_UNTRACKED_FILES_DIRTY="true"
35 39
36 # Uncomment the following line if you want to change the command execution time 40 # Uncomment the following line if you want to change the command execution time
37 # stamp shown in the history command output. 41 # stamp shown in the history command output.
38 # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 42 # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
39 # HIST_STAMPS="mm/dd/yyyy" 43 # HIST_STAMPS="mm/dd/yyyy"
40 44
41 # Would you like to use another custom folder than $ZSH/custom? 45 # Would you like to use another custom folder than $ZSH/custom?
42 # ZSH_CUSTOM=/path/to/new-custom-folder 46 # ZSH_CUSTOM=/path/to/new-custom-folder
43 47
44 # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) 48 # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
45 # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ 49 # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
46 # Example format: plugins=(rails git textmate ruby lighthouse) 50 # Example format: plugins=(rails git textmate ruby lighthouse)
47 # Add wisely, as too many plugins slow down shell startup. 51 # Add wisely, as too many plugins slow down shell startup.
48 plugins=(git) 52 plugins=(git)
49 53
50 # User configuration 54 # User configuration
51 55
52 export PATH=$HOME/bin:/usr/local/bin:$PATH 56 export PATH=$HOME/bin:/usr/local/bin:$PATH
53 # export MANPATH="/usr/local/man:$MANPATH" 57 # export MANPATH="/usr/local/man:$MANPATH"
54 58
55 source $ZSH/oh-my-zsh.sh 59 source $ZSH/oh-my-zsh.sh
56 60
57 # You may need to manually set your language environment 61 # You may need to manually set your language environment
58 # export LANG=en_US.UTF-8 62 # export LANG=en_US.UTF-8
59 63
60 # Preferred editor for local and remote sessions 64 # Preferred editor for local and remote sessions
61 # if [[ -n $SSH_CONNECTION ]]; then 65 # if [[ -n $SSH_CONNECTION ]]; then
62 # export EDITOR='vim' 66 # export EDITOR='vim'
63 # else 67 # else
64 # export EDITOR='mvim' 68 # export EDITOR='mvim'
65 # fi 69 # fi
66 70
67 # Compilation flags 71 # Compilation flags
68 # export ARCHFLAGS="-arch x86_64" 72 # export ARCHFLAGS="-arch x86_64"
69 73
70 # ssh 74 # ssh
71 # export SSH_KEY_PATH="~/.ssh/dsa_id" 75 # export SSH_KEY_PATH="~/.ssh/dsa_id"
72 76
73 # Set personal aliases, overriding those provided by oh-my-zsh libs, 77 # Set personal aliases, overriding those provided by oh-my-zsh libs,
74 # plugins, and themes. Aliases can be placed here, though oh-my-zsh 78 # plugins, and themes. Aliases can be placed here, though oh-my-zsh
75 # users are encouraged to define aliases within the ZSH_CUSTOM folder. 79 # users are encouraged to define aliases within the ZSH_CUSTOM folder.
76 # For a full list of active aliases, run `alias`. 80 # For a full list of active aliases, run `alias`.
77 # 81 #
78 # Example aliases 82 # Example aliases
79 # alias zshconfig="mate ~/.zshrc" 83 # alias zshconfig="mate ~/.zshrc"
80 # alias ohmyzsh="mate ~/.oh-my-zsh" 84 # alias ohmyzsh="mate ~/.oh-my-zsh"
81 85
themes/adben.zsh-theme
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 # # 2 # #
3 # # #README 3 # # #README
4 # # 4 # #
5 # # This theme provides two customizable header functionalities: 5 # # This theme provides two customizable header functionalities:
6 # # a) displaying a pseudo-random message from a database of quotations 6 # # a) displaying a pseudo-random message from a database of quotations
7 # # (https://en.wikipedia.org/wiki/Fortune_%28Unix%29) 7 # # (https://en.wikipedia.org/wiki/Fortune_%28Unix%29)
8 # # b) displaying randomly command line tips from The command line fu 8 # # b) displaying randomly command line tips from The command line fu
9 # # (http://www.commandlinefu.com) community: in order to make use of this functionality 9 # # (http://www.commandlinefu.com) community: in order to make use of this functionality
10 # # you will need Internet connection. 10 # # you will need Internet connection.
11 # # This theme provides as well information for the current user's context, like; 11 # # This theme provides as well information for the current user's context, like;
12 # # branch and status for the current version control system (git and svn currently 12 # # branch and status for the current version control system (git and svn currently
13 # # supported) and time, presented to the user in a non invasive volatile way. 13 # # supported) and time, presented to the user in a non invasive volatile way.
14 # # 14 # #
15 # # #REQUIREMENTS 15 # # #REQUIREMENTS
16 # # This theme requires wget:: 16 # # This theme requires wget::
17 # # -Homebrew-osx- brew install wget 17 # # -Homebrew-osx- brew install wget
18 # # -Debian/Ubuntu- apt-get install wget 18 # # -Debian/Ubuntu- apt-get install wget
19 # # and fortune :: 19 # # and fortune ::
20 # # -Homebrew-osx- brew install fortune 20 # # -Homebrew-osx- brew install fortune
21 # # -Debian/Ubuntu- apt-get install fortune 21 # # -Debian/Ubuntu- apt-get install fortune
22 # # 22 # #
23 # # optionally: 23 # # optionally:
24 # # -Oh-myzsh vcs plug-ins git and svn. 24 # # -Oh-myzsh vcs plug-ins git and svn.
25 # # -Solarized theme (https://github.com/altercation/solarized/) 25 # # -Solarized theme (https://github.com/altercation/solarized/)
26 # # -OS X: iTerm 2 (http://www.iterm2.com/) 26 # # -OS X: iTerm 2 (http://www.iterm2.com/)
27 # # -font Source code pro (https://github.com/adobe/source-code-pro) 27 # # -font Source code pro (https://github.com/adobe/source-code-pro)
28 # # 28 # #
29 # # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info: 29 # # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
30 # # http://pthree.org/2008/11/23/727/ 30 # # http://pthree.org/2008/11/23/727/
31 # # enjoy! 31 # # enjoy!
32 ########## COLOR ########### 32 ########## COLOR ###########
33 for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do 33 for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
34 eval PR_$COLOR='%{$fg[${(L)COLOR}]%}' 34 eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
35 eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}' 35 eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
36 done 36 done
37 PR_RESET="%{$reset_color%}" 37 PR_RESET="%{$reset_color%}"
38 RED_START="${PR_RESET}${PR_GREY}<${PR_RESET}${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} " 38 RED_START="${PR_RESET}${PR_GREY}<${PR_RESET}${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
39 RED_END="${PR_RESET}${PR_BRIGHT_RED}>${PR_RESET}${PR_RED}>${PR_GREY}>${PR_RESET} " 39 RED_END="${PR_RESET}${PR_BRIGHT_RED}>${PR_RESET}${PR_RED}>${PR_GREY}>${PR_RESET} "
40 GREEN_END="${PR_RESET}${PR_BRIGHT_GREEN}>${PR_RESET}${PR_GREEN}>${PR_GREY}>${PR_RESET} " 40 GREEN_END="${PR_RESET}${PR_BRIGHT_GREEN}>${PR_RESET}${PR_GREEN}>${PR_GREY}>${PR_RESET} "
41 GREEN_BASE_START="${PR_RESET}${PR_GREY}>${PR_RESET}${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}" 41 GREEN_BASE_START="${PR_RESET}${PR_GREY}>${PR_RESET}${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}"
42 GREEN_START_P1="${PR_RESET}${GREEN_BASE_START}${PR_RESET} " 42 GREEN_START_P1="${PR_RESET}${GREEN_BASE_START}${PR_RESET} "
43 DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}" 43 DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
44 VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}" 44 VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}"
45 Vcs_CLEAN_COLOR="${PR_RESET}${PR_GREEN}" 45 VCS_CLEAN_COLOR="${PR_RESET}${PR_GREEN}"
46 VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}" 46 VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}"
47 # ########## COLOR ########### 47 # ########## COLOR ###########
48 # ########## SVN ########### 48 # ########## SVN ###########
49 ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹svn:" 49 ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹svn:"
50 ZSH_THEME_SVN_PROMPT_SUFFIX="" 50 ZSH_THEME_SVN_PROMPT_SUFFIX=""
51 ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}" 51 ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
52 ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}" 52 ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
53 # ########## SVN ########### 53 # ########## SVN ###########
54 # ########## GIT ########### 54 # ########## GIT ###########
55 ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:" 55 ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:"
56 ZSH_THEME_GIT_PROMPT_SUFFIX="" 56 ZSH_THEME_GIT_PROMPT_SUFFIX=""
57 ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}" 57 ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
58 ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}" 58 ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
59 ZSH_THEME_GIT_PROMPT_ADDED="${PR_RESET}${PR_YELLOW} ✚${PR_RESET}" 59 ZSH_THEME_GIT_PROMPT_ADDED="${PR_RESET}${PR_YELLOW} ✚${PR_RESET}"
60 ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_RESET}${PR_YELLOW} ✹${PR_RESET}" 60 ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_RESET}${PR_YELLOW} ✹${PR_RESET}"
61 ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}" 61 ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}"
62 ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜${PR_RESET}" 62 ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜${PR_RESET}"
63 ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═${PR_RESET}" 63 ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═${PR_RESET}"
64 ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭${PR_RESET}" 64 ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭${PR_RESET}"
65 # ########## GIT ########### 65 # ########## GIT ###########
66 function precmd { 66 function precmd {
67 #gets the fortune 67 #gets the fortune
68 ps1_fortune () { 68 ps1_fortune () {
69 #Choose from all databases, regardless of whether they are considered "offensive" 69 #Choose from all databases, regardless of whether they are considered "offensive"
70 fortune -a 70 fortune -a
71 } 71 }
72 #obtains the tip 72 #obtains the tip
73 ps1_command_tip () { 73 ps1_command_tip () {
74 wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d' 74 wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d'
75 } 75 }
76 prompt_header () { 76 prompt_header () {
77 if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then 77 if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then
78 ps1_command_tip 78 ps1_command_tip
79 else 79 else
80 ps1_fortune 80 ps1_fortune
81 fi 81 fi
82 } 82 }
83 PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}" 83 PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
84 # set a simple variable to show when in screen 84 # set a simple variable to show when in screen
85 if [[ -n "${WINDOW}" ]]; then 85 if [[ -n "${WINDOW}" ]]; then
86 SCREEN="" 86 SCREEN=""
87 fi 87 fi
88 } 88 }
89 89
90 # Context: user@directory or just directory 90 # Context: user@directory or just directory
91 prompt_context () { 91 prompt_context () {
92 if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then 92 if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
93 echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}" 93 echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
94 else 94 else
95 echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}" 95 echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
96 fi 96 fi
97 } 97 }
98 98
99 set_prompt () { 99 set_prompt () {
100 # required for the prompt 100 # required for the prompt
101 setopt prompt_subst 101 setopt prompt_subst
102 autoload zsh/terminfo 102 autoload zsh/terminfo
103 103
104 # ######### PROMPT ######### 104 # ######### PROMPT #########
105 PROMPT='${PROMPT_HEAD} 105 PROMPT='${PROMPT_HEAD}
106 ${RED_START}$(prompt_context) 106 ${RED_START}$(prompt_context)
107 ${GREEN_START_P1}' 107 ${GREEN_START_P1}'
108 RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}' 108 RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
109 # Matching continuation prompt 109 # Matching continuation prompt
110 PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} ' 110 PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
111 # ######### PROMPT ######### 111 # ######### PROMPT #########
112 } 112 }
113 113
114 set_prompt 114 set_prompt
115 115
themes/agnoster.zsh-theme
1 # vim:ft=zsh ts=2 sw=2 sts=2 1 # vim:ft=zsh ts=2 sw=2 sts=2
2 # 2 #
3 # agnoster's Theme - https://gist.github.com/3712874 3 # agnoster's Theme - https://gist.github.com/3712874
4 # A Powerline-inspired theme for ZSH 4 # A Powerline-inspired theme for ZSH
5 # 5 #
6 # # README 6 # # README
7 # 7 #
8 # In order for this theme to render correctly, you will need a 8 # In order for this theme to render correctly, you will need a
9 # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). 9 # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
10 # 10 #
11 # In addition, I recommend the 11 # In addition, I recommend the
12 # [Solarized theme](https://github.com/altercation/solarized/) and, if you're 12 # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
13 # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - 13 # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
14 # it has significantly better color fidelity. 14 # it has significantly better color fidelity.
15 # 15 #
16 # # Goals 16 # # Goals
17 # 17 #
18 # The aim of this theme is to only show you *relevant* information. Like most 18 # The aim of this theme is to only show you *relevant* information. Like most
19 # prompts, it will only show git information when in a git working directory. 19 # prompts, it will only show git information when in a git working directory.
20 # However, it goes a step further: everything from the current user and 20 # However, it goes a step further: everything from the current user and
21 # hostname to whether the last call exited with an error to whether background 21 # hostname to whether the last call exited with an error to whether background
22 # jobs are running in this shell will all be displayed automatically when 22 # jobs are running in this shell will all be displayed automatically when
23 # appropriate. 23 # appropriate.
24 24
25 ### Segment drawing 25 ### Segment drawing
26 # A few utility functions to make it easy and re-usable to draw segmented prompts 26 # A few utility functions to make it easy and re-usable to draw segmented prompts
27 27
28 CURRENT_BG='NONE' 28 CURRENT_BG='NONE'
29 SEGMENT_SEPARATOR='' 29
30 # Fix odd char on mac
31 if [[ `uname` == 'Darwin' ]]; then
32 SEGMENT_SEPARATOR='\ue0b0'
33 else
34 SEGMENT_SEPARATOR=''
35 fi
30 36
31 # Begin a segment 37 # Begin a segment
32 # Takes two arguments, background and foreground. Both can be omitted, 38 # Takes two arguments, background and foreground. Both can be omitted,
33 # rendering default background/foreground. 39 # rendering default background/foreground.
34 prompt_segment() { 40 prompt_segment() {
35 local bg fg 41 local bg fg
36 [[ -n $1 ]] && bg="%K{$1}" || bg="%k" 42 [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
37 [[ -n $2 ]] && fg="%F{$2}" || fg="%f" 43 [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
38 if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then 44 if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
39 echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " 45 echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
40 else 46 else
41 echo -n "%{$bg%}%{$fg%} " 47 echo -n "%{$bg%}%{$fg%} "
42 fi 48 fi
43 CURRENT_BG=$1 49 CURRENT_BG=$1
44 [[ -n $3 ]] && echo -n $3 50 [[ -n $3 ]] && echo -n $3
45 } 51 }
46 52
47 # End the prompt, closing any open segments 53 # End the prompt, closing any open segments
48 prompt_end() { 54 prompt_end() {
49 if [[ -n $CURRENT_BG ]]; then 55 if [[ -n $CURRENT_BG ]]; then
50 echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" 56 echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
51 else 57 else
52 echo -n "%{%k%}" 58 echo -n "%{%k%}"
53 fi 59 fi
54 echo -n "%{%f%}" 60 echo -n "%{%f%}"
55 CURRENT_BG='' 61 CURRENT_BG=''
56 } 62 }
57 63
58 ### Prompt components 64 ### Prompt components
59 # Each component will draw itself, and hide itself if no information needs to be shown 65 # Each component will draw itself, and hide itself if no information needs to be shown
60 66
61 # Context: user@hostname (who am I and where am I) 67 # Context: user@hostname (who am I and where am I)
62 prompt_context() { 68 prompt_context() {
63 if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then 69 if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
64 prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" 70 prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
65 fi 71 fi
66 } 72 }
67 73
68 # Git: branch/detached head, dirty status 74 # Git: branch/detached head, dirty status
69 prompt_git() { 75 prompt_git() {
70 local ref dirty mode repo_path 76 local ref dirty mode repo_path
71 repo_path=$(git rev-parse --git-dir 2>/dev/null) 77 repo_path=$(git rev-parse --git-dir 2>/dev/null)
72 78
73 if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then 79 if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
74 dirty=$(parse_git_dirty) 80 dirty=$(parse_git_dirty)
75 ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" 81 ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
76 if [[ -n $dirty ]]; then 82 if [[ -n $dirty ]]; then
77 prompt_segment yellow black 83 prompt_segment yellow black
78 else 84 else
79 prompt_segment green black 85 prompt_segment green black
80 fi 86 fi
81 87
82 if [[ -e "${repo_path}/BISECT_LOG" ]]; then 88 if [[ -e "${repo_path}/BISECT_LOG" ]]; then
83 mode=" <B>" 89 mode=" <B>"
84 elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then 90 elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
85 mode=" >M<" 91 mode=" >M<"
86 elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then 92 elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
87 mode=" >R>" 93 mode=" >R>"
88 fi 94 fi
89 95
90 setopt promptsubst 96 setopt promptsubst
91 autoload -Uz vcs_info 97 autoload -Uz vcs_info
92 98
93 zstyle ':vcs_info:*' enable git 99 zstyle ':vcs_info:*' enable git
94 zstyle ':vcs_info:*' get-revision true 100 zstyle ':vcs_info:*' get-revision true
95 zstyle ':vcs_info:*' check-for-changes true 101 zstyle ':vcs_info:*' check-for-changes true
96 zstyle ':vcs_info:*' stagedstr '✚' 102 zstyle ':vcs_info:*' stagedstr '✚'
97 zstyle ':vcs_info:git:*' unstagedstr '●' 103 zstyle ':vcs_info:git:*' unstagedstr '●'
98 zstyle ':vcs_info:*' formats ' %u%c' 104 zstyle ':vcs_info:*' formats ' %u%c'
99 zstyle ':vcs_info:*' actionformats ' %u%c' 105 zstyle ':vcs_info:*' actionformats ' %u%c'
100 vcs_info 106 vcs_info
101 echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}" 107 echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
102 fi 108 fi
103 } 109 }
104 110
105 prompt_hg() { 111 prompt_hg() {
106 local rev status 112 local rev status
107 if $(hg id >/dev/null 2>&1); then 113 if $(hg id >/dev/null 2>&1); then
108 if $(hg prompt >/dev/null 2>&1); then 114 if $(hg prompt >/dev/null 2>&1); then
109 if [[ $(hg prompt "{status|unknown}") = "?" ]]; then 115 if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
110 # if files are not added 116 # if files are not added
111 prompt_segment red white 117 prompt_segment red white
112 st='±' 118 st='±'
113 elif [[ -n $(hg prompt "{status|modified}") ]]; then 119 elif [[ -n $(hg prompt "{status|modified}") ]]; then
114 # if any modification 120 # if any modification
115 prompt_segment yellow black 121 prompt_segment yellow black
116 st='±' 122 st='±'
117 else 123 else
118 # if working copy is clean 124 # if working copy is clean
119 prompt_segment green black 125 prompt_segment green black
120 fi 126 fi
121 echo -n $(hg prompt "☿ {rev}@{branch}") $st 127 echo -n $(hg prompt "☿ {rev}@{branch}") $st
122 else 128 else
123 st="" 129 st=""
124 rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') 130 rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
125 branch=$(hg id -b 2>/dev/null) 131 branch=$(hg id -b 2>/dev/null)
126 if `hg st | grep -q "^\?"`; then 132 if `hg st | grep -q "^\?"`; then
127 prompt_segment red black 133 prompt_segment red black
128 st='±' 134 st='±'
129 elif `hg st | grep -q "^(M|A)"`; then 135 elif `hg st | grep -q "^[MA]"`; then
130 prompt_segment yellow black 136 prompt_segment yellow black
131 st='±' 137 st='±'
132 else 138 else
133 prompt_segment green black 139 prompt_segment green black
134 fi 140 fi
135 echo -n "☿ $rev@$branch" $st 141 echo -n "☿ $rev@$branch" $st
136 fi 142 fi
137 fi 143 fi
138 } 144 }
139 145
140 # Dir: current working directory 146 # Dir: current working directory
141 prompt_dir() { 147 prompt_dir() {
142 prompt_segment blue black '%~' 148 prompt_segment blue black '%~'
143 } 149 }
144 150
145 # Virtualenv: current working virtualenv 151 # Virtualenv: current working virtualenv
146 prompt_virtualenv() { 152 prompt_virtualenv() {
147 local virtualenv_path="$VIRTUAL_ENV" 153 local virtualenv_path="$VIRTUAL_ENV"
148 if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then 154 if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
149 prompt_segment blue black "(`basename $virtualenv_path`)" 155 prompt_segment blue black "(`basename $virtualenv_path`)"
150 fi 156 fi
151 } 157 }
152 158
153 # Status: 159 # Status:
154 # - was there an error 160 # - was there an error
155 # - am I root 161 # - am I root
156 # - are there background jobs? 162 # - are there background jobs?
157 prompt_status() { 163 prompt_status() {
158 local symbols 164 local symbols
159 symbols=() 165 symbols=()
160 [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" 166 [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
161 [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" 167 [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
162 [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" 168 [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
163 169
164 [[ -n "$symbols" ]] && prompt_segment black default "$symbols" 170 [[ -n "$symbols" ]] && prompt_segment black default "$symbols"
165 } 171 }
166 172
167 ## Main prompt 173 ## Main prompt
168 build_prompt() { 174 build_prompt() {
169 RETVAL=$? 175 RETVAL=$?
170 prompt_status 176 prompt_status
171 prompt_virtualenv 177 prompt_virtualenv
172 prompt_context 178 prompt_context
173 prompt_dir 179 prompt_dir
174 prompt_git 180 prompt_git
175 prompt_hg 181 prompt_hg
176 prompt_end 182 prompt_end
177 } 183 }
178 184
179 PROMPT='%{%f%b%k%}$(build_prompt) ' 185 PROMPT='%{%f%b%k%}$(build_prompt) '
180 186
themes/avit.zsh-theme
1 # AVIT ZSH Theme 1 # AVIT ZSH Theme
2 2
3 PROMPT=' 3 PROMPT='
4 $(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version) 4 $(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
5 ▶ ' 5 ▶ '
6 6
7 PROMPT2='%{$fg[grey]%}◀%{$reset_color%} ' 7 PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
8 8
9 RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' 9 RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
10 10
11 local _current_dir="%{$fg[blue]%}%3~%{$reset_color%} " 11 local _current_dir="%{$fg[blue]%}%3~%{$reset_color%} "
12 local _return_status="%{$fg[red]%}%(?..⍉)%{$reset_color%}" 12 local _return_status="%{$fg[red]%}%(?..⍉)%{$reset_color%}"
13 local _hist_no="%{$fg[grey]%}%h%{$reset_color%}" 13 local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
14 14
15 function _user_host() { 15 function _user_host() {
16 if [[ -n $SSH_CONNECTION ]]; then 16 if [[ -n $SSH_CONNECTION ]]; then
17 me="%n@%m" 17 me="%n@%m"
18 elif [[ $LOGNAME != $USER ]]; then 18 elif [[ $LOGNAME != $USER ]]; then
19 me="%n" 19 me="%n"
20 fi 20 fi
21 if [[ -n $me ]]; then 21 if [[ -n $me ]]; then
22 echo "%{$fg[cyan]%}$me%{$reset_color%}:" 22 echo "%{$fg[cyan]%}$me%{$reset_color%}:"
23 fi 23 fi
24 } 24 }
25 25
26 function _vi_status() { 26 function _vi_status() {
27 if {echo $fpath | grep -q "plugins/vi-mode"}; then 27 if {echo $fpath | grep -q "plugins/vi-mode"}; then
28 echo "$(vi_mode_prompt_info)" 28 echo "$(vi_mode_prompt_info)"
29 fi 29 fi
30 } 30 }
31 31
32 function _ruby_version() { 32 function _ruby_version() {
33 if {echo $fpath | grep -q "plugins/rvm"}; then 33 if {echo $fpath | grep -q "plugins/rvm"}; then
34 echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}" 34 echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
35 fi 35 fi
36 } 36 }
37 37
38 # Determine the time since last commit. If branch is clean, 38 # Determine the time since last commit. If branch is clean,
39 # use a neutral color, otherwise colors will vary according to time. 39 # use a neutral color, otherwise colors will vary according to time.
40 function _git_time_since_commit() { 40 function _git_time_since_commit() {
41 if git rev-parse --git-dir > /dev/null 2>&1; then 41 # Only proceed if there is actually a commit.
42 # Only proceed if there is actually a commit. 42 if git log -1 > /dev/null 2>&1; then
43 if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then 43 # Get the last commit.
44 # Get the last commit. 44 last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
45 last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null) 45 now=$(date +%s)
46 now=$(date +%s) 46 seconds_since_last_commit=$((now-last_commit))
47 seconds_since_last_commit=$((now-last_commit)) 47
48 48 # Totals
49 # Totals 49 minutes=$((seconds_since_last_commit / 60))
50 minutes=$((seconds_since_last_commit / 60)) 50 hours=$((seconds_since_last_commit/3600))
51 hours=$((seconds_since_last_commit/3600)) 51
52 52 # Sub-hours and sub-minutes
53 # Sub-hours and sub-minutes 53 days=$((seconds_since_last_commit / 86400))
54 days=$((seconds_since_last_commit / 86400)) 54 sub_hours=$((hours % 24))
55 sub_hours=$((hours % 24)) 55 sub_minutes=$((minutes % 60))
56 sub_minutes=$((minutes % 60)) 56
57 57 if [ $hours -gt 24 ]; then
58 if [ $hours -gt 24 ]; then 58 commit_age="${days}d"
59 commit_age="${days}d" 59 elif [ $minutes -gt 60 ]; then
60 elif [ $minutes -gt 60 ]; then 60 commit_age="${sub_hours}h${sub_minutes}m"
61 commit_age="${sub_hours}h${sub_minutes}m" 61 else
62 else 62 commit_age="${minutes}m"
63 commit_age="${minutes}m"
64 fi
65
66 color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
67 echo "$color$commit_age%{$reset_color%}"
68 fi 63 fi
64
65 color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
66 echo "$color$commit_age%{$reset_color%}"
69 fi 67 fi
70 } 68 }
71 69
72 if [[ $USER == "root" ]]; then 70 if [[ $USER == "root" ]]; then
73 CARETCOLOR="red" 71 CARETCOLOR="red"
74 else 72 else
75 CARETCOLOR="white" 73 CARETCOLOR="white"
76 fi 74 fi
77 75
78 MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}" 76 MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
79 77
80 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" 78 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
81 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" 79 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
82 80
83 ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}" 81 ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
84 ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}" 82 ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
85 ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ " 83 ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
86 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ " 84 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
87 ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ " 85 ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
88 ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ " 86 ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
89 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ " 87 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
90 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}◒ " 88 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}◒ "
91 89
92 # Colors vary depending on time lapsed. 90 # Colors vary depending on time lapsed.
93 ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" 91 ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
94 ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}" 92 ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
95 ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}" 93 ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
96 ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}" 94 ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}"
97 95
98 # LS colors, made with http://geoff.greer.fm/lscolors/ 96 # LS colors, made with http://geoff.greer.fm/lscolors/
99 export LSCOLORS="exfxcxdxbxegedabagacad" 97 export LSCOLORS="exfxcxdxbxegedabagacad"
100 export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' 98 export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
themes/candy-kingdom.zsh-theme
1 # neuralsanwich.zsh-theme 1 # neuralsanwich.zsh-theme
2 2
3 if [ "x$OH_MY_ZSH_HG" = "x" ]; then 3 if [ "x$OH_MY_ZSH_HG" = "x" ]; then
4 OH_MY_ZSH_HG="hg" 4 OH_MY_ZSH_HG="hg"
5 fi 5 fi
6 6
7 function hg_prompt_info { 7 function hg_prompt_info {
8 $OH_MY_ZSH_HG prompt --angle-brackets "\ 8 $OH_MY_ZSH_HG prompt --angle-brackets "\
9 < on %{$fg[magenta]%}<branch>%{$reset_color%}>\ 9 < on %{$fg[magenta]%}<branch>%{$reset_color%}>\
10 < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\ 10 < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
11 %{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}< 11 %{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
12 patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null 12 patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
13 } 13 }
14 14
15 function box_name { 15 function box_name {
16 [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST 16 [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-HOST}
17 } 17 }
18 18
19 PROMPT=' 19 PROMPT='
20 %{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}$(box_name)%{$reset_color%}:%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info) 20 %{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}$(box_name)%{$reset_color%}:%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)
21 %(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )$ ' 21 %(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )$ '
22 22
23 ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[magenta]%}branch: " 23 ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[magenta]%}branch: "
24 ZSH_THEME_GIT_PROMPT_CLEAN="" 24 ZSH_THEME_GIT_PROMPT_CLEAN=""
25 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?" 25 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
26 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!" 26 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
27 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" 27 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
28 28
29 local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}" 29 local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}"
30 RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}' 30 RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
31 31
themes/fino-time.zsh-theme
1 # fino-time.zsh-theme 1 # fino-time.zsh-theme
2 2
3 # Use with a dark background and 256-color terminal! 3 # Use with a dark background and 256-color terminal!
4 # Meant for people with RVM and git. Tested only on OS X 10.7. 4 # Meant for people with RVM and git. Tested only on OS X 10.7.
5 5
6 # You can set your computer name in the ~/.box-name file if you want. 6 # You can set your computer name in the ~/.box-name file if you want.
7 7
8 # Borrowing shamelessly from these oh-my-zsh themes: 8 # Borrowing shamelessly from these oh-my-zsh themes:
9 # bira 9 # bira
10 # robbyrussell 10 # robbyrussell
11 # 11 #
12 # Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ 12 # Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
13 13
14 function virtualenv_info { 14 function virtualenv_info {
15 [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' 15 [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
16 } 16 }
17 17
18 function prompt_char { 18 function prompt_char {
19 git branch >/dev/null 2>/dev/null && echo '⠠⠵' && return 19 git branch >/dev/null 2>/dev/null && echo '⠠⠵' && return
20 echo '○' 20 echo '○'
21 } 21 }
22 22
23 function box_name { 23 function box_name {
24 [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST 24 [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-HOST}
25 } 25 }
26 26
27 27
28 local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}' 28 local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}'
29 local current_dir='${PWD/#$HOME/~}' 29 local current_dir='${PWD/#$HOME/~}'
30 local git_info='$(git_prompt_info)' 30 local git_info='$(git_prompt_info)'
31 31
32 32
33 PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby} %D - %* 33 PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby} %D - %*
34 ╰─$(virtualenv_info)$(prompt_char) " 34 ╰─$(virtualenv_info)$(prompt_char) "
35 35
36 ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" 36 ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
37 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" 37 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
38 ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘" 38 ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘"
39 ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔" 39 ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔"
40 40
themes/fino.zsh-theme
1 # fino.zsh-theme 1 # fino.zsh-theme
2 2
3 # Use with a dark background and 256-color terminal! 3 # Use with a dark background and 256-color terminal!
4 # Meant for people with rbenv and git. Tested only on OS X 10.7. 4 # Meant for people with rbenv and git. Tested only on OS X 10.7.
5 5
6 # You can set your computer name in the ~/.box-name file if you want. 6 # You can set your computer name in the ~/.box-name file if you want.
7 7
8 # Borrowing shamelessly from these oh-my-zsh themes: 8 # Borrowing shamelessly from these oh-my-zsh themes:
9 # bira 9 # bira
10 # robbyrussell 10 # robbyrussell
11 # 11 #
12 # Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ 12 # Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
13 13
14 function prompt_char { 14 function prompt_char {
15 git branch >/dev/null 2>/dev/null && echo "±" && return 15 git branch >/dev/null 2>/dev/null && echo "±" && return
16 echo '○' 16 echo '○'
17 } 17 }
18 18
19 function box_name { 19 function box_name {
20 [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST 20 [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-HOST}
21 } 21 }
22 22
23 local ruby_env='' 23 local ruby_env=''
24 if which rvm-prompt &> /dev/null; then 24 if which rvm-prompt &> /dev/null; then
25 ruby_env=' ‹$(rvm-prompt i v g)›%{$reset_color%}' 25 ruby_env=' ‹$(rvm-prompt i v g)›%{$reset_color%}'
26 else 26 else
27 if which rbenv &> /dev/null; then 27 if which rbenv &> /dev/null; then
28 ruby_env=' ‹$(rbenv version-name)›%{$reset_color%}' 28 ruby_env=' ‹$(rbenv version-name)›%{$reset_color%}'
29 fi 29 fi
30 fi 30 fi
31 31
32 local current_dir='${PWD/#$HOME/~}' 32 local current_dir='${PWD/#$HOME/~}'
33 local git_info='$(git_prompt_info)' 33 local git_info='$(git_prompt_info)'
34 local prompt_char='$(prompt_char)' 34 local prompt_char='$(prompt_char)'
35 35
36 36
37 PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%}${ruby_env} 37 PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%}${ruby_env}
38 ╰─${prompt_char}%{$reset_color%} " 38 ╰─${prompt_char}%{$reset_color%} "
39 39
40 ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" 40 ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
41 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" 41 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
42 ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘" 42 ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘"
43 ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔" 43 ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔"
44 44
themes/michelebologna.zsh-theme
1 # reference colors 1 # Michele Bologna's theme
2 GREEN="%{$fg_bold[green]%}" 2 # http://michelebologna.net
3 RED="%{$fg_bold[red]%}" 3 #
4 CYAN="%{$fg_bold[cyan]%}" 4 # This a theme for oh-my-zsh. Features a colored prompt with:
5 YELLOW="%{$fg_bold[yellow]%}" 5 # * username@host: [jobs] [git] workdir %
6 BLUE="%{$fg_bold[blue]%}" 6 # * hostname color is based on hostname characters. When using as root, the
7 MAGENTA="%{$fg_bold[magenta]%}" 7 # prompt shows only the hostname in red color.
8 WHITE="%{$fg_bold[white]%}" 8 # * [jobs], if applicable, counts the number of suspended jobs tty
9 9 # * [git], if applicable, represents the status of your git repo (more on that
10 COLOR_ARRAY=($GREEN $RED $CYAN $YELLOW $BLUE $MAGENTA $WHITE) 10 # later)
11 11 # * '%' prompt will be green if last command return value is 0, yellow otherwise.
12 # color reset 12 #
13 RESET_COLOR="%{$reset_color%}" 13 # git prompt is inspired by official git contrib prompt:
14 14 # https://github.com/git/git/tree/master/contrib/completion/git-prompt.sh
15 # which color should be applied? 15 # and it adds:
16 USERNAME_NORMAL_COLOR=$WHITE 16 # * the current branch
17 USERNAME_ROOT_COLOR=$RED 17 # * '%' if there are untracked files
18 HOSTNAME_NORMAL_COLOR=$BLUE 18 # * '$' if there are stashed changes
19 # uncomment next line if you want auto-generated hostname color 19 # * '*' if there are modified files
20 #for i in $HOST; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]] 20 # * '+' if there are added files
21 HOSTNAME_ROOT_COLOR=$RED 21 # * '<' if local repo is behind remote repo
22 HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR) 22 # * '>' if local repo is ahead remote repo
23 CURRENT_DIR_COLOR=$CYAN 23 # * '=' if local repo is equal to remote repo (in sync)
24 24 # * '<>' if local repo is diverged
25 # zsh commands 25
26 USERNAME_COMMAND="%n" 26 local green="%{$fg_bold[green]%}"
27 HOSTNAME_COMMAND="%m" 27 local red="%{$fg_bold[red]%}"
28 CURRENT_DIR="%~" 28 local cyan="%{$fg_bold[cyan]%}"
29 29 local yellow="%{$fg_bold[yellow]%}"
30 # output: colors + commands 30 local blue="%{$fg_bold[blue]%}"
31 USERNAME_OUTPUT="%(!..$USERNAME_NORMAL_COLOR$USERNAME_COMMAND$RESET_COLOR@)" 31 local magenta="%{$fg_bold[magenta]%}"
32 HOSTNAME_OUTPUT="$HOSTNAME_COLOR$HOSTNAME_COMMAND$RESET_COLOR" 32 local white="%{$fg_bold[white]%}"
33 CURRENT_DIR_OUTPUT="$CURRENT_DIR_COLOR$CURRENT_DIR" 33 local reset="%{$reset_color%}"
34 LAST_COMMAND_OUTPUT="%(?.%(!.$RED.$GREEN).$YELLOW)" 34
35 35 local -a color_array
36 # git theming 36 color_array=($green $red $cyan $yellow $blue $magenta $white)
37 ZSH_THEME_GIT_PROMPT_PREFIX="(" 37
38 local username_normal_color=$white
39 local username_root_color=$red
40 local hostname_root_color=$red
41
42 # calculating hostname color with hostname characters
43 for i in `hostname`; local hostname_normal_color=$color_array[$[((#i))%7+1]]
44 local -a hostname_color
45 hostname_color=%(!.$hostname_root_color.$hostname_normal_color)
46
47 local current_dir_color=$blue
48 local username_command="%n"
49 local hostname_command="%m"
50 local current_dir="%~"
51
52 local username_output="%(!..$username_normal_color$username_command$reset@)"
53 local hostname_output="$hostname_color$hostname_command$reset"
54 local current_dir_output="$current_dir_color$current_dir$reset"
55 local jobs_bg="${red}fg: %j$reset"
56 local last_command_output="%(?.%(!.$red.$green).$yellow)"
57
58 ZSH_THEME_GIT_PROMPT_PREFIX=""
38 ZSH_THEME_GIT_PROMPT_SUFFIX="" 59 ZSH_THEME_GIT_PROMPT_SUFFIX=""
39 ZSH_THEME_GIT_PROMPT_DIRTY=")$RED*" 60 ZSH_THEME_GIT_PROMPT_DIRTY=""
40 ZSH_THEME_GIT_PROMPT_CLEAN=")" 61 ZSH_THEME_GIT_PROMPT_CLEAN=""
62 ZSH_THEME_GIT_PROMPT_UNTRACKED="%%"
63 ZSH_THEME_GIT_PROMPT_MODIFIED="*"
64 ZSH_THEME_GIT_PROMPT_ADDED="+"
65 ZSH_THEME_GIT_PROMPT_STASHED="$"
66 ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="="
67 ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
68 ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
69 ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="<>"
41 70
42 # wrap all together 71 PROMPT='$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)'
43 PROMPT='$USERNAME_OUTPUT$HOSTNAME_OUTPUT:$CURRENT_DIR_OUTPUT $LAST_COMMAND_OUTPUT%#$RESET_COLOR ' 72 PROMPT+='$(__git_ps1)'
44 RPROMPT='%1(j.fg: [%j].) $GREEN$(git_prompt_info)$RESET_COLOR [%@]' 73 PROMPT+=" $last_command_output%#$reset "
74 RPROMPT=''
45 75
themes/minimal.zsh-theme
1 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[white]%}[" 1 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[white]%}["
2 ZSH_THEME_GIT_PROMPT_SUFFIX="" 2 ZSH_THEME_GIT_PROMPT_SUFFIX=""
3 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$reset_color%}]%{$reset_color%} " 3 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[white]%}]%{$reset_color%} "
4 ZSH_THEME_GIT_PROMPT_CLEAN="]%{$reset_color%} " 4 ZSH_THEME_GIT_PROMPT_CLEAN="]%{$reset_color%} "
5 ZSH_THEME_SVN_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX 5 ZSH_THEME_SVN_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX
6 ZSH_THEME_SVN_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX 6 ZSH_THEME_SVN_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX
7 ZSH_THEME_SVN_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY 7 ZSH_THEME_SVN_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY
8 ZSH_THEME_SVN_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN 8 ZSH_THEME_SVN_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN
9 ZSH_THEME_HG_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX
10 ZSH_THEME_HG_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX
11 ZSH_THEME_HG_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY
12 ZSH_THEME_HG_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN
9 13
10 vcs_status() { 14 vcs_status() {
11 if [[ ( $(whence in_svn) != "" ) && ( $(in_svn) == 1 ) ]]; then 15 if [[ $(whence in_svn) != "" ]] && in_svn; then
12 svn_prompt_info 16 svn_prompt_info
17 elif [[ $(whence in_hg) != "" ]] && in_hg; then
18 hg_prompt_info
13 else 19 else
14 git_prompt_info 20 git_prompt_info
15 fi 21 fi
16 } 22 }
17 23
18 PROMPT='%2~ $(vcs_status)»%b '
24 PROMPT='%2~ $(vcs_status)»%b '
themes/strug.zsh-theme
File was created 1 # terminal coloring
2 export CLICOLOR=1
3 export LSCOLORS=dxFxCxDxBxegedabagacad
4
5 local git_branch='$(git_prompt_info)%{$reset_color%}$(git_remote_status)'
6
7 PROMPT="%{$fg[green]%}╭─%n@%m %{$reset_color%}%{$fg[yellow]%}in %~ %{$reset_color%}${git_branch}
8 %{$fg[green]%}╰\$ %{$reset_color%}"
9
10 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}on "
11 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
12
13 ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}%{$fg[red]%} ✘ %{$reset_color%}"
14 ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✔ %{$reset_color%}"
15
16 ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED=true
17 ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX="%{$fg[yellow]%}("
18 ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX="%{$fg[yellow]%})%{$reset_color%}"
19
20 ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=" +"
21 ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR=%{$fg[green]%}
22
23 ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE=" -"
24 ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR=%{$fg[red]%}
25
26
tools/check_for_upgrade.sh
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 2
3 zmodload zsh/datetime 3 zmodload zsh/datetime
4 4
5 function _current_epoch() { 5 function _current_epoch() {
6 echo $(( $EPOCHSECONDS / 60 / 60 / 24 )) 6 echo $(( $EPOCHSECONDS / 60 / 60 / 24 ))
7 } 7 }
8 8
9 function _update_zsh_update() { 9 function _update_zsh_update() {
10 echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update 10 echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update
11 } 11 }
12 12
13 function _upgrade_zsh() { 13 function _upgrade_zsh() {
14 env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh 14 env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
15 # update the zsh file 15 # update the zsh file
16 _update_zsh_update 16 _update_zsh_update
17 } 17 }
18 18
19 epoch_target=$UPDATE_ZSH_DAYS 19 epoch_target=$UPDATE_ZSH_DAYS
20 if [[ -z "$epoch_target" ]]; then 20 if [[ -z "$epoch_target" ]]; then
21 # Default to old behavior 21 # Default to old behavior
22 epoch_target=13 22 epoch_target=13
23 fi 23 fi
24 24
25 # Cancel upgrade if the current user doesn't have write permissions for the 25 # Cancel upgrade if the current user doesn't have write permissions for the
26 # oh-my-zsh directory. 26 # oh-my-zsh directory.
27 [[ -w "$ZSH" ]] || return 0 27 [[ -w "$ZSH" ]] || return 0
28 28
29 if [ -f ~/.zsh-update ] 29 if [ -f ~/.zsh-update ]
30 then 30 then
31 . ~/.zsh-update 31 . ~/.zsh-update
32 32
33 if [[ -z "$LAST_EPOCH" ]]; then 33 if [[ -z "$LAST_EPOCH" ]]; then
34 _update_zsh_update && return 0; 34 _update_zsh_update && return 0;
35 fi 35 fi
36 36
37 epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) 37 epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
38 if [ $epoch_diff -gt $epoch_target ] 38 if [ $epoch_diff -gt $epoch_target ]
39 then 39 then
40 if [ "$DISABLE_UPDATE_PROMPT" = "true" ] 40 if [ "$DISABLE_UPDATE_PROMPT" = "true" ]
41 then 41 then
42 _upgrade_zsh 42 _upgrade_zsh
43 else 43 else
44 echo "[Oh My Zsh] Would you like to check for updates?" 44 echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c"
45 echo "Type Y to update oh-my-zsh: \c"
46 read line 45 read line
47 if [ "$line" = Y ] || [ "$line" = y ]; then 46 if [ "$line" = Y ] || [ "$line" = y ] || [ -z "$line" ]; then
48 _upgrade_zsh 47 _upgrade_zsh
49 else 48 else
50 _update_zsh_update 49 _update_zsh_update
51 fi 50 fi
52 fi 51 fi
53 fi 52 fi
54 else 53 else
55 # create the zsh file 54 # create the zsh file
56 _update_zsh_update 55 _update_zsh_update
57 fi 56 fi
58 57
59 58
1 set -e 1 set -e
2 2
3 if [ ! -n "$ZSH" ]; then 3 if [ ! -n "$ZSH" ]; then
4 ZSH=~/.oh-my-zsh 4 ZSH=~/.oh-my-zsh
5 fi 5 fi
6 6
7 if [ -d "$ZSH" ]; then 7 if [ -d "$ZSH" ]; then
8 echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install" 8 echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install"
9 exit 9 exit
10 fi 10 fi
11 11
12 echo "\033[0;34mCloning Oh My Zsh...\033[0m" 12 echo "\033[0;34mCloning Oh My Zsh...\033[0m"
13 hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { 13 hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
14 echo "git not installed" 14 echo "git not installed"
15 exit 15 exit
16 } 16 }
17 17
18 echo "\033[0;34mLooking for an existing zsh config...\033[0m" 18 echo "\033[0;34mLooking for an existing zsh config...\033[0m"
19 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then 19 if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
20 echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m"; 20 echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m";
21 mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh; 21 mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
22 fi 22 fi
23 23
24 echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" 24 echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
25 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc 25 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
26 sed -i -e "/^export ZSH=/ c\\ 26 sed -i -e "/^export ZSH=/ c\\
27 export ZSH=$ZSH 27 export ZSH=$ZSH
28 " ~/.zshrc 28 " ~/.zshrc
29 29
30 echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" 30 echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
31 sed -i -e "/export PATH=/ c\\ 31 sed -i -e "/export PATH=/ c\\
32 export PATH=\"$PATH\" 32 export PATH=\"$PATH\"
33 " ~/.zshrc 33 " ~/.zshrc
34 34
35 if [ "$SHELL" != "$(which zsh)" ]; then 35 TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
36 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
36 echo "\033[0;34mTime to change your default shell to zsh!\033[0m" 37 echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
37 chsh -s `which zsh` 38 chsh -s $(grep /zsh$ /etc/shells | tail -1)
38 fi 39 fi
40 unset TEST_CURRENT_SHELL
39 41
40 echo "\033[0;32m"' __ __ '"\033[0m" 42 echo "\033[0;32m"' __ __ '"\033[0m"
41 echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" 43 echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
42 echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" 44 echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
43 echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" 45 echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
44 echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" 46 echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
45 echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" 47 echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m"
46 echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" 48 echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m"
47 echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" 49 echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m"
48 echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m" 50 echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m"
49 env zsh 51 env zsh
50 . ~/.zshrc 52 . ~/.zshrc
51 53