Commit 61aaa7b58bf9508cb738a8b0c30610e994d443ac

Authored by mj
1 parent f5c7faa5a9
Exists in master and in 1 other branch 02-merge

Squashed 'repos/robbyrussell/oh-my-zsh/' changes from ee34381..686e460

686e460 Merge branch 'sachin21-a_happy_new_year'
03cc1f7 Cleanup LICENSE file and fix README link
fdde897 Update year to 2016
f558a46 Merge pull request #4709 from mcornella/fix-local-vars-in-git-prompt
0842384 Put `local var` declaration in its own line in lib/git.zsh
30ddf25 Merge pull request #4695 from mcornella/add-hub-completion
69c73a4 Merge pull request #4704 from paulcalabro/patch-1
247a582 Fixed a typo.
5adb06d Merge pull request #4702 from prikhi/master
3ebbb40 colored-man-pages: Use Portable `less` Path
6ad6d11 Merge pull request #4700 from giordanovi/master
015437c Update gulp.plugin.zsh
3162de5 Add hub's completion file
4b95c16 Merge branch 'fix-colored-man-pages-syntax'
5e310c5 Fix syntax error in colored-man-pages
fe9ff63 Merge pull request #4463 from giordanovi/master
4f314e2 Update gulp.plugin.zsh
8042394 Update gulp.plugin.zsh
cb11d13 Merge pull request #4697 from psprint/master
d30a501 znt: more optimizing workarounds for 5.0.6 <= zsh < 5.2
5de1704 Merge branch 'cknoblauch-patch-1'
09d2a59 Fix style of colored-man-pages plugin
a815729 colored-man plugin: Quoted PATH variable
dd29954 Merge branch 'hallabro-consistent-wording-update'
18ca953 Use consistent wording when updating
ef31d06 Merge pull request #4139 from ultimatemonty/patch-1
8a3b78e Merge pull request #4536 from alexws54tk/patch-1
e344f4c Merge pull request #4420 from apjanke/git-move-current_branch-to-core
9f55213 Move current_branch() from git plugin to core lib/git.zsh
bfd2d8d Merge pull request #4498 from gfvcastro/alias-rake-stats
8d6fcce Merge pull request #4589 from apjanke/agnoster-powerline-char-stronger-warning
93c00cc Merge pull request #4451 from victor-torres/branch-plugin
d988ee0 Merge pull request #4568 from blueyed/archlinux-improve-commands-lookup
fe63ed0 Updating speed test info and using zsh command line.
cf5db83 Implementing mcornella's suggestions in pull request 4451.
531789e Merge pull request #4628 from moyamo/master
bd384a0 Merge pull request #4667 from dbohdan/patch-1
b15918d "fishy" theme: Fix "~" use in prompt
71deb74 Fix indentation
d779750 Default to using terminfo to set the terminal title
6a8692d Merge pull request #4676 from bamarni/composer-stderr
4108c48 Merge pull request #4690 from kaelig/patch-1
6190d3e Point to the GitHub repository
f564159 Merge branch 'GNUletik-master'
95aa9bd Better research history with arrow keys
273063a Merge pull request #4663 from psprint/master
d54d896 Merge pull request #3966 from apjanke/fix-spectrum-ls
4d154ab Merge branch 'apjanke-histsubstr-double-bind'
45822e8 history-substring-search: bind arrows in both emacs and viins modes
11de60f Merge pull request #3965 from apjanke/spectrum-hide-codes
4fbfb14 Add back the `-` alias to go to the previous directory
b6997f6 Update link to git completion
5e950d4 Merge pull request #4689 from apjanke/fix-non-numeric-versions
45e42ef Merge pull request #4657 from hghwng/master
07fcbbe Merge pull request #4641 from WeeBull/patch-1
c52f677 common-aliases: handle "dev" versions in version check
0cca3c0 Merge pull request #4687 from gmccue/web-search-ecosia
fb5effd Add Ecosia to web-search plugin.
357d57c znt: include some status information on top of the window
0d45e77 [Composer] redirect stderr to /dev/null for completion commands
c793bae znt: optimize heap usage for older Zsh's (e.g. 5.0.8)
2e3731c "fishy" theme: Shorten path .foo to .f, not .
89205f9 znt: faster startup of tools using colorifying (e.g. n-history)
a42a3ee Recognize Firefox addon and Android packages.
b57ddd6 Use actual `commit --amend` command for Mercurial
cc116f6 agnoster: stronger warning about changing SEGMENT_SEPARATOR character
9e4aba4 archlinux: use $+commands instead of 'command -v' in a subshell
67abf0f Update frontcube.zsh-theme
e5164d7 Add 'rake stats' alias.
ee8f377 Added support to subtask through gulp --tasks-simple command
d49cacf Add branch plugin
e6ccd37 Merge master (rebase being super annoying). Fix conflicts
30ef856 Fix maintainer line
3594e27 Nicer formatting
0bda651 Fix the spectrum_ls implementation in spectrum.zsh
8142261 Hide spectrum.zsh var values to avoid junky "set" output to terminal

git-subtree-dir: repos/robbyrussell/oh-my-zsh
git-subtree-split: 686e46025890cba38d2cb7ad7cc229bf6beeba57

Showing 39 changed files with 429 additions and 178 deletions Inline Diff

1 The MIT License 1 The MIT License (MIT)
2 2
3 Copyright (c) 2009-2015 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors) 3 Copyright (c) 2009-2016 Robby Russell and contributors
4 See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
4 5
5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal 7 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights 8 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is 10 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions: 11 furnished to do so, subject to the following conditions:
11 12
12 The above copyright notice and this permission notice shall be included in 13 The above copyright notice and this permission notice shall be included in all
13 all copies or substantial portions of the Software. 14 copies or substantial portions of the Software.
14 15
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 THE SOFTWARE. 22 SOFTWARE.
22 23
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 interact with your command prompt, you'll be able to take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. 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 interact with your command prompt, you'll be able to take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often.
7 7
8 To learn more, visit [ohmyz.sh](http://ohmyz.sh) and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. 8 To learn more, visit [ohmyz.sh](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). 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) 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 * `curl` or `wget` should be installed 19 * `curl` or `wget` should be installed
20 * `git` 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 ```shell 28 ```shell
29 sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" 29 sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
30 ``` 30 ```
31 31
32 #### via wget 32 #### via wget
33 33
34 ```shell 34 ```shell
35 sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" 35 sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
36 ``` 36 ```
37 37
38 ## Using Oh My Zsh 38 ## Using Oh My Zsh
39 39
40 ### Plugins 40 ### Plugins
41 41
42 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. 42 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.
43 43
44 #### Enabling Plugins 44 #### Enabling Plugins
45 45
46 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. 46 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.
47 47
48 For example, this line might begin to look like... 48 For example, this line might begin to look like...
49 49
50 ```shell 50 ```shell
51 plugins=(git bundler osx rake ruby) 51 plugins=(git bundler osx rake ruby)
52 ``` 52 ```
53 53
54 #### Using Plugins 54 #### Using Plugins
55 55
56 Most plugins (should! we're working on this) include a __README__, which documents how to use them. 56 Most plugins (should! we're working on this) include a __README__, which documents how to use them.
57 57
58 ### Themes 58 ### Themes
59 59
60 We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out! 60 We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out!
61 61
62 #### Selecting a Theme 62 #### Selecting a Theme
63 63
64 _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)._ 64 _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)._
65 65
66 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: 66 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:
67 67
68 ```shell 68 ```shell
69 ZSH_THEME="robbyrussell" 69 ZSH_THEME="robbyrussell"
70 ``` 70 ```
71 71
72 To use a different theme, simply change the value to match the name of your desired theme. For example: 72 To use a different theme, simply change the value to match the name of your desired theme. For example:
73 73
74 ```shell 74 ```shell
75 ZSH_THEME="agnoster" # (this is one of the fancy ones) 75 ZSH_THEME="agnoster" # (this is one of the fancy ones)
76 ``` 76 ```
77 77
78 Open up a new terminal window and your prompt should look something like... 78 Open up a new terminal window and your prompt should look something like...
79 79
80 ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) 80 ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
81 81
82 In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). 82 In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes).
83 83
84 If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. 84 If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
85 85
86 86
87 ```shell 87 ```shell
88 ZSH_THEME="random" # (...please let it be pie... please be some pie..) 88 ZSH_THEME="random" # (...please let it be pie... please be some pie..)
89 ``` 89 ```
90 90
91 91
92 ## Advanced Topics 92 ## Advanced Topics
93 93
94 If you're the type that likes to get their hands dirty, these sections might resonate. 94 If you're the type that likes to get their hands dirty, these sections might resonate.
95 95
96 ### Advanced Installation 96 ### Advanced Installation
97 97
98 Some users may want to change the default path, or manually install Oh My Zsh. 98 Some users may want to change the default path, or manually install Oh My Zsh.
99 99
100 #### Custom Directory 100 #### Custom Directory
101 101
102 The default location is `~/.oh-my-zsh` (hidden in your home directory) 102 The default location is `~/.oh-my-zsh` (hidden in your home directory)
103 103
104 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: 104 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:
105 105
106 ```shell 106 ```shell
107 export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" 107 export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
108 ``` 108 ```
109 109
110 #### Manual Installation 110 #### Manual Installation
111 111
112 ##### 1. Clone the repository: 112 ##### 1. Clone the repository:
113 113
114 ```shell 114 ```shell
115 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh 115 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
116 ``` 116 ```
117 117
118 ##### 2. *Optionally*, backup your existing `~/.zshrc` file: 118 ##### 2. *Optionally*, backup your existing `~/.zshrc` file:
119 119
120 ```shell 120 ```shell
121 cp ~/.zshrc ~/.zshrc.orig 121 cp ~/.zshrc ~/.zshrc.orig
122 ``` 122 ```
123 123
124 ##### 3. Create a new zsh configuration file 124 ##### 3. Create a new zsh configuration file
125 125
126 You can create a new zsh config file by copying the template that we included for you. 126 You can create a new zsh config file by copying the template that we included for you.
127 127
128 ```shell 128 ```shell
129 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc 129 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
130 ``` 130 ```
131 131
132 ##### 4. Change your default shell 132 ##### 4. Change your default shell
133 133
134 ```shell 134 ```shell
135 chsh -s /bin/zsh 135 chsh -s /bin/zsh
136 ``` 136 ```
137 137
138 ##### 5. Initialize your new zsh configuration 138 ##### 5. Initialize your new zsh configuration
139 139
140 Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. 140 Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
141 141
142 ### Installation Problems 142 ### Installation Problems
143 143
144 If you have any hiccups installing, here are a few common fixes. 144 If you have any hiccups installing, here are a few common fixes.
145 145
146 * You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`. 146 * You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
147 * If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. 147 * If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
148 148
149 ### Custom Plugins and Themes 149 ### Custom Plugins and Themes
150 150
151 If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory. 151 If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
152 152
153 If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin. 153 If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin.
154 154
155 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/`. 155 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/`.
156 156
157 ## Getting Updates 157 ## Getting Updates
158 158
159 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`: 159 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`:
160 160
161 ```shell 161 ```shell
162 DISABLE_UPDATE_PROMPT=true 162 DISABLE_UPDATE_PROMPT=true
163 ``` 163 ```
164 164
165 To disable automatic upgrades, set the following in your `~/.zshrc`: 165 To disable automatic upgrades, set the following in your `~/.zshrc`:
166 166
167 ```shell 167 ```shell
168 DISABLE_AUTO_UPDATE=true 168 DISABLE_AUTO_UPDATE=true
169 ``` 169 ```
170 170
171 ### Manual Updates 171 ### Manual Updates
172 172
173 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: 173 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:
174 174
175 ```shell 175 ```shell
176 upgrade_oh_my_zsh 176 upgrade_oh_my_zsh
177 ``` 177 ```
178 178
179 Magic! 179 Magic!
180 180
181 ## Uninstalling Oh My Zsh 181 ## Uninstalling Oh My Zsh
182 182
183 Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup. 183 Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
184 184
185 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. 185 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.
186 186
187 ## Contributing 187 ## Contributing
188 188
189 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! 189 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!
190 190
191 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. 191 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.
192 192
193 ### Do NOT send us themes 193 ### Do NOT send us themes
194 194
195 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. 195 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.
196 196
197 ## Contributors 197 ## Contributors
198 198
199 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. 199 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.
200 200
201 Thank you so much! 201 Thank you so much!
202 202
203 ## Follow Us 203 ## Follow Us
204 204
205 We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. 205 We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it.
206 206
207 ## Merchandise 207 ## Merchandise
208 208
209 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! 209 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!
210 210
211 ## License 211 ## License
212 212
213 Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt). 213 Oh My Zsh is released under the [MIT license](MIT-LICENSE.txt).
214 214
1 # Changing/making/removing directory 1 # Changing/making/removing directory
2 setopt auto_pushd 2 setopt auto_pushd
3 setopt pushd_ignore_dups 3 setopt pushd_ignore_dups
4 setopt pushdminus 4 setopt pushdminus
5 5
6 alias -g ...='../..' 6 alias -g ...='../..'
7 alias -g ....='../../..' 7 alias -g ....='../../..'
8 alias -g .....='../../../..' 8 alias -g .....='../../../..'
9 alias -g ......='../../../../..' 9 alias -g ......='../../../../..'
10 10
11 alias -- -='cd -'
11 alias 1='cd -' 12 alias 1='cd -'
12 alias 2='cd -2' 13 alias 2='cd -2'
13 alias 3='cd -3' 14 alias 3='cd -3'
14 alias 4='cd -4' 15 alias 4='cd -4'
15 alias 5='cd -5' 16 alias 5='cd -5'
16 alias 6='cd -6' 17 alias 6='cd -6'
17 alias 7='cd -7' 18 alias 7='cd -7'
18 alias 8='cd -8' 19 alias 8='cd -8'
19 alias 9='cd -9' 20 alias 9='cd -9'
20 21
21 alias md='mkdir -p' 22 alias md='mkdir -p'
22 alias rd=rmdir 23 alias rd=rmdir
23 alias d='dirs -v | head -10' 24 alias d='dirs -v | head -10'
24 25
25 # List directory contents 26 # List directory contents
26 alias lsa='ls -lah' 27 alias lsa='ls -lah'
27 alias l='ls -lah' 28 alias l='ls -lah'
28 alias ll='ls -lh' 29 alias ll='ls -lh'
29 alias la='ls -lAh' 30 alias la='ls -lAh'
30 31
31 # Push and pop directories on directory stack 32 # Push and pop directories on directory stack
32 alias pu='pushd' 33 alias pu='pushd'
33 alias po='popd' 34 alias po='popd'
34 35
1 # get the name of the branch we are on 1 # Outputs current branch info in prompt format
2 function git_prompt_info() { 2 function git_prompt_info() {
3 local ref
3 if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then 4 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) || \ 5 ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
5 ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 6 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" 7 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
7 fi 8 fi
8 } 9 }
9 10
10
11 # Checks if working tree is dirty 11 # Checks if working tree is dirty
12 parse_git_dirty() { 12 function 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 # Gets the difference between the local and remote branches
33 git_remote_status() { 33 function git_remote_status() {
34 local remote ahead behind git_remote_status git_remote_status_detailed
34 remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} 35 remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
35 if [[ -n ${remote} ]] ; then 36 if [[ -n ${remote} ]]; then
36 ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) 37 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) 38 behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
38 39
39 if [ $ahead -eq 0 ] && [ $behind -eq 0 ] 40 if [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
40 then
41 git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
42 elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
43 then
44 git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE" 41 git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
45 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}" 42 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
46 elif [ $behind -gt 0 ] && [ $ahead -eq 0 ] 43 elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
47 then
48 git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE" 44 git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
49 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}" 45 git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
50 elif [ $ahead -gt 0 ] && [ $behind -gt 0 ] 46 elif [[ $ahead -gt 0 ]] && [[ $behind -gt 0 ]]; then
51 then
52 git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE" 47 git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
53 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 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%}"
54 fi 49 fi
55 50
56 if [ $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ] 51 if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
57 then
58 git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX" 52 git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
59 fi 53 fi
60 54
61 echo $git_remote_status 55 echo $git_remote_status
62 fi 56 fi
63 } 57 }
64 58
59 # Outputs the name of the current branch
60 # Usage example: git pull origin $(git_current_branch)
61 # Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
62 # it's not a symbolic ref, but in a Git repo.
63 function git_current_branch() {
64 local ref
65 ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
66 local ret=$?
67 if [[ $ret != 0 ]]; then
68 [[ $ret == 128 ]] && return # no git repo.
69 ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
70 fi
71 echo ${ref#refs/heads/}
72 }
73
74
65 # Gets the number of commits ahead from remote 75 # Gets the number of commits ahead from remote
66 function git_commits_ahead() { 76 function git_commits_ahead() {
67 if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then 77 if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
78 local COMMITS
68 COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') 79 COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
69 echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" 80 echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
70 fi 81 fi
71 } 82 }
72 83
73 # Outputs if current branch is ahead of remote 84 # Outputs if current branch is ahead of remote
74 function git_prompt_ahead() { 85 function git_prompt_ahead() {
75 if [[ -n "$(command git rev-list origin/$(current_branch)..HEAD 2> /dev/null)" ]]; then 86 if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
76 echo "$ZSH_THEME_GIT_PROMPT_AHEAD" 87 echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
77 fi 88 fi
78 } 89 }
79 90
80 # Outputs if current branch is behind remote 91 # Outputs if current branch is behind remote
81 function git_prompt_behind() { 92 function git_prompt_behind() {
82 if [[ -n "$(command git rev-list HEAD..origin/$(current_branch) 2> /dev/null)" ]]; then 93 if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
83 echo "$ZSH_THEME_GIT_PROMPT_BEHIND" 94 echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
84 fi 95 fi
85 } 96 }
86 97
87 # Outputs if current branch exists on remote or not 98 # Outputs if current branch exists on remote or not
88 function git_prompt_remote() { 99 function git_prompt_remote() {
89 if [[ -n "$(command git show-ref origin/$(current_branch) 2> /dev/null)" ]]; then 100 if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
90 echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS" 101 echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
91 else 102 else
92 echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING" 103 echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
93 fi 104 fi
94 } 105 }
95 106
96 # Formats prompt string for current git commit short SHA 107 # Formats prompt string for current git commit short SHA
97 function git_prompt_short_sha() { 108 function git_prompt_short_sha() {
109 local SHA
98 SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" 110 SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
99 } 111 }
100 112
101 # Formats prompt string for current git commit long SHA 113 # Formats prompt string for current git commit long SHA
102 function git_prompt_long_sha() { 114 function git_prompt_long_sha() {
115 local SHA
103 SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" 116 SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
104 } 117 }
105 118
106 # Get the status of the working tree 119 # Get the status of the working tree
107 git_prompt_status() { 120 function git_prompt_status() {
121 local INDEX STATUS
108 INDEX=$(command git status --porcelain -b 2> /dev/null) 122 INDEX=$(command git status --porcelain -b 2> /dev/null)
109 STATUS="" 123 STATUS=""
110 if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then 124 if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
111 STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" 125 STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
112 fi 126 fi
113 if $(echo "$INDEX" | grep '^A ' &> /dev/null); then 127 if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
114 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" 128 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
115 elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then 129 elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
116 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" 130 STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
117 fi 131 fi
118 if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then 132 if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
119 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 133 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
120 elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then 134 elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
121 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 135 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
122 elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then 136 elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
123 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 137 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
124 fi 138 fi
125 if $(echo "$INDEX" | grep '^R ' &> /dev/null); then 139 if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
126 STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" 140 STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
127 fi 141 fi
128 if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then 142 if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
129 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 143 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
130 elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then 144 elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
131 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 145 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
132 elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then 146 elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
133 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 147 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
134 fi 148 fi
135 if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then 149 if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
136 STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" 150 STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
137 fi 151 fi
138 if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then 152 if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
139 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" 153 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
140 fi 154 fi
141 if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then 155 if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then
142 STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" 156 STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
143 fi 157 fi
144 if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then 158 if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then
145 STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" 159 STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
146 fi 160 fi
147 if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then 161 if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then
148 STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" 162 STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
149 fi 163 fi
150 echo $STATUS 164 echo $STATUS
151 } 165 }
152 166
153 #compare the provided version of git to the version installed and on path 167 # Compares the provided version of git to the version installed and on path
154 #prints 1 if input version <= installed version 168 # Outputs -1, 0, or 1 if the installed version is less than, equal to, or
155 #prints -1 otherwise 169 # greater than the input version, respectively.
156 function git_compare_version() { 170 function git_compare_version() {
157 local INPUT_GIT_VERSION=$1; 171 local INPUT_GIT_VERSION INSTALLED_GIT_VERSION
158 local INSTALLED_GIT_VERSION 172 INPUT_GIT_VERSION=(${(s/./)1})
159 INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION}); 173 INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null))
160 INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)); 174 INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]})
161 INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
162 175
163 for i in {1..3}; do 176 for i in {1..3}; do
164 if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then 177 if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then
165 echo 1 178 echo 1
166 return 0 179 return 0
167 fi 180 fi
168 if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then 181 if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
169 echo -1 182 echo -1
170 return 0 183 return 0
171 fi 184 fi
lib/key-bindings.zsh
1 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html 1 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
2 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins 2 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
3 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets 3 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
4 4
5 # Make sure that the terminal is in application mode when zle is active, since 5 # Make sure that the terminal is in application mode when zle is active, since
6 # only then values from $terminfo are valid 6 # only then values from $terminfo are valid
7 if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then 7 if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
8 function zle-line-init() { 8 function zle-line-init() {
9 echoti smkx 9 echoti smkx
10 } 10 }
11 function zle-line-finish() { 11 function zle-line-finish() {
12 echoti rmkx 12 echoti rmkx
13 } 13 }
14 zle -N zle-line-init 14 zle -N zle-line-init
15 zle -N zle-line-finish 15 zle -N zle-line-finish
16 fi 16 fi
17 17
18 bindkey -e # Use emacs key bindings 18 bindkey -e # Use emacs key bindings
19 19
20 bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark 20 bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
21 bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls 21 bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
22 bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. 22 bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
23 if [[ "${terminfo[kpp]}" != "" ]]; then 23 if [[ "${terminfo[kpp]}" != "" ]]; then
24 bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history 24 bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
25 fi 25 fi
26 if [[ "${terminfo[knp]}" != "" ]]; then 26 if [[ "${terminfo[knp]}" != "" ]]; then
27 bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history 27 bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
28 fi 28 fi
29 29
30 # start typing + [Up-Arrow] - fuzzy find history forward
30 if [[ "${terminfo[kcuu1]}" != "" ]]; then 31 if [[ "${terminfo[kcuu1]}" != "" ]]; then
31 bindkey "${terminfo[kcuu1]}" up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward 32 autoload -U up-line-or-beginning-search
33 zle -N up-line-or-beginning-search
34 bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
32 fi 35 fi
36 # start typing + [Down-Arrow] - fuzzy find history backward
33 if [[ "${terminfo[kcud1]}" != "" ]]; then 37 if [[ "${terminfo[kcud1]}" != "" ]]; then
34 bindkey "${terminfo[kcud1]}" down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward 38 autoload -U down-line-or-beginning-search
39 zle -N down-line-or-beginning-search
40 bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
35 fi 41 fi
36 42
37 if [[ "${terminfo[khome]}" != "" ]]; then 43 if [[ "${terminfo[khome]}" != "" ]]; then
38 bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line 44 bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
39 fi 45 fi
40 if [[ "${terminfo[kend]}" != "" ]]; then 46 if [[ "${terminfo[kend]}" != "" ]]; then
41 bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line 47 bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
42 fi 48 fi
43 49
44 bindkey ' ' magic-space # [Space] - do history expansion 50 bindkey ' ' magic-space # [Space] - do history expansion
45 51
46 bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word 52 bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
47 bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word 53 bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
48 54
49 if [[ "${terminfo[kcbt]}" != "" ]]; then 55 if [[ "${terminfo[kcbt]}" != "" ]]; then
50 bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards 56 bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
51 fi 57 fi
52 58
53 bindkey '^?' backward-delete-char # [Backspace] - delete backward 59 bindkey '^?' backward-delete-char # [Backspace] - delete backward
54 if [[ "${terminfo[kdch1]}" != "" ]]; then 60 if [[ "${terminfo[kdch1]}" != "" ]]; then
55 bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward 61 bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
56 else 62 else
57 bindkey "^[[3~" delete-char 63 bindkey "^[[3~" delete-char
58 bindkey "^[3;5~" delete-char 64 bindkey "^[3;5~" delete-char
59 bindkey "\e[3~" delete-char 65 bindkey "\e[3~" delete-char
60 fi 66 fi
61 67
62 # Edit the current command line in $EDITOR 68 # Edit the current command line in $EDITOR
63 autoload -U edit-command-line 69 autoload -U edit-command-line
64 zle -N edit-command-line 70 zle -N edit-command-line
65 bindkey '\C-x\C-e' edit-command-line 71 bindkey '\C-x\C-e' edit-command-line
66 72
67 # file rename magick 73 # file rename magick
68 bindkey "^[m" copy-prev-shell-word 74 bindkey "^[m" copy-prev-shell-word
69 75
70 # consider emacs keybindings: 76 # consider emacs keybindings:
71 77
72 #bindkey -e ## emacs key bindings 78 #bindkey -e ## emacs key bindings
73 # 79 #
74 #bindkey '^[[A' up-line-or-search 80 #bindkey '^[[A' up-line-or-search
75 #bindkey '^[[B' down-line-or-search 81 #bindkey '^[[B' down-line-or-search
76 #bindkey '^[^[[C' emacs-forward-word 82 #bindkey '^[^[[C' emacs-forward-word
77 #bindkey '^[^[[D' emacs-backward-word 83 #bindkey '^[^[[D' emacs-backward-word
78 # 84 #
79 #bindkey -s '^X^Z' '%-^M' 85 #bindkey -s '^X^Z' '%-^M'
80 #bindkey '^[e' expand-cmd-path 86 #bindkey '^[e' expand-cmd-path
81 #bindkey '^[^I' reverse-menu-complete 87 #bindkey '^[^I' reverse-menu-complete
82 #bindkey '^X^N' accept-and-infer-next-history 88 #bindkey '^X^N' accept-and-infer-next-history
83 #bindkey '^W' kill-region 89 #bindkey '^W' kill-region
84 #bindkey '^I' complete-word 90 #bindkey '^I' complete-word
85 ## Fix weird sequence that rxvt produces 91 ## Fix weird sequence that rxvt produces
86 #bindkey -s '^[[Z' '\t' 92 #bindkey -s '^[[Z' '\t'
87 # 93 #
88 94
1 #! /bin/zsh 1 #! /bin/zsh
2 # A script to make using 256 colors in zsh less painful. 2 # A script to make using 256 colors in zsh less painful.
3 # P.C. Shyamshankar <sykora@lucentbeing.com> 3 # P.C. Shyamshankar <sykora@lucentbeing.com>
4 # Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ 4 # Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
5 5
6 typeset -Ag FX FG BG 6 typeset -AHg FX FG BG
7 7
8 FX=( 8 FX=(
9 reset "%{%}" 9 reset "%{%}"
10 bold "%{%}" no-bold "%{%}" 10 bold "%{%}" no-bold "%{%}"
11 italic "%{%}" no-italic "%{%}" 11 italic "%{%}" no-italic "%{%}"
12 underline "%{%}" no-underline "%{%}" 12 underline "%{%}" no-underline "%{%}"
13 blink "%{%}" no-blink "%{%}" 13 blink "%{%}" no-blink "%{%}"
14 reverse "%{%}" no-reverse "%{%}" 14 reverse "%{%}" no-reverse "%{%}"
15 ) 15 )
16 16
17 for color in {000..255}; do 17 for color in {000..255}; do
18 FG[$color]="%{[38;5;${color}m%}" 18 FG[$color]="%{[38;5;${color}m%}"
19 BG[$color]="%{[48;5;${color}m%}" 19 BG[$color]="%{[48;5;${color}m%}"
20 done 20 done
21 21
22 22
23 ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} 23 ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
24 24
25 # Show all 256 colors with color number 25 # Show all 256 colors with color number
26 function spectrum_ls() { 26 function spectrum_ls() {
27 for code in {000..255}; do 27 for code in {000..255}; do
28 print -P -- "$code: %F{$code}$ZSH_SPECTRUM_TEXT%f" 28 print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
29 done 29 done
30 } 30 }
31 31
32 # Show all 256 colors where the background is set to specific color 32 # Show all 256 colors where the background is set to specific color
33 function spectrum_bls() { 33 function spectrum_bls() {
34 for code in {000..255}; do 34 for code in {000..255}; do
35 print -P -- "$BG[$code]$code: $ZSH_SPECTRUM_TEXT %{$reset_color%}" 35 print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
36 done 36 done
37 } 37 }
38 38
1 # Set terminal window and tab/icon title 1 # Set terminal window and tab/icon title
2 # 2 #
3 # usage: title short_tab_title [long_window_title] 3 # usage: title short_tab_title [long_window_title]
4 # 4 #
5 # See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 5 # See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
6 # Fully supports screen, iterm, and probably most modern xterm and rxvt 6 # Fully supports screen, iterm, and probably most modern xterm and rxvt
7 # (In screen, only short_tab_title is used) 7 # (In screen, only short_tab_title is used)
8 # Limited support for Apple Terminal (Terminal can't set window and tab separately) 8 # Limited support for Apple Terminal (Terminal can't set window and tab separately)
9 function title { 9 function title {
10 emulate -L zsh 10 emulate -L zsh
11 setopt prompt_subst 11 setopt prompt_subst
12 12
13 [[ "$EMACS" == *term* ]] && return 13 [[ "$EMACS" == *term* ]] && return
14 14
15 # if $2 is unset use $1 as default 15 # if $2 is unset use $1 as default
16 # if it is set and empty, leave it as is 16 # if it is set and empty, leave it as is
17 : ${2=$1} 17 : ${2=$1}
18 18
19 case "$TERM" in 19 case "$TERM" in
20 cygwin|xterm*|putty*|rxvt*|ansi) 20 cygwin|xterm*|putty*|rxvt*|ansi)
21 print -Pn "\e]2;$2:q\a" # set window name 21 print -Pn "\e]2;$2:q\a" # set window name
22 print -Pn "\e]1;$1:q\a" # set tab name 22 print -Pn "\e]1;$1:q\a" # set tab name
23 ;; 23 ;;
24 screen*) 24 screen*)
25 print -Pn "\ek$1:q\e\\" # set screen hardstatus 25 print -Pn "\ek$1:q\e\\" # set screen hardstatus
26 ;; 26 ;;
27 *) 27 *)
28 if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then 28 if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
29 print -Pn "\e]2;$2:q\a" # set window name 29 print -Pn "\e]2;$2:q\a" # set window name
30 print -Pn "\e]1;$1:q\a" # set tab name 30 print -Pn "\e]1;$1:q\a" # set tab name
31 else
32 # Try to use terminfo to set the title
33 # If the feature is available set title
34 if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
35 echoti tsl
36 print -Pn "$1"
37 echoti fsl
38 fi
31 fi 39 fi
32 ;; 40 ;;
33 esac 41 esac
34 } 42 }
35 43
36 ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD 44 ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
37 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" 45 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
38 # Avoid duplication of directory in terminals with independent dir display 46 # Avoid duplication of directory in terminals with independent dir display
39 if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then 47 if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
40 ZSH_THEME_TERM_TITLE_IDLE="%n@%m" 48 ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
41 fi 49 fi
42 50
43 # Runs before showing the prompt 51 # Runs before showing the prompt
44 function omz_termsupport_precmd { 52 function omz_termsupport_precmd {
45 emulate -L zsh 53 emulate -L zsh
46 54
47 if [[ "$DISABLE_AUTO_TITLE" == true ]]; then 55 if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
48 return 56 return
49 fi 57 fi
50 58
51 title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE 59 title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
52 } 60 }
53 61
54 # Runs before executing the command 62 # Runs before executing the command
55 function omz_termsupport_preexec { 63 function omz_termsupport_preexec {
56 emulate -L zsh 64 emulate -L zsh
57 setopt extended_glob 65 setopt extended_glob
58 66
59 if [[ "$DISABLE_AUTO_TITLE" == true ]]; then 67 if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
60 return 68 return
61 fi 69 fi
62 70
63 # cmd name only, or if this is sudo or ssh, the next cmd 71 # cmd name only, or if this is sudo or ssh, the next cmd
64 local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} 72 local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
65 local LINE="${2:gs/%/%%}" 73 local LINE="${2:gs/%/%%}"
66 74
67 title '$CMD' '%100>...>$LINE%<<' 75 title '$CMD' '%100>...>$LINE%<<'
68 } 76 }
69 77
70 precmd_functions+=(omz_termsupport_precmd) 78 precmd_functions+=(omz_termsupport_precmd)
71 preexec_functions+=(omz_termsupport_preexec) 79 preexec_functions+=(omz_termsupport_preexec)
72 80
73 81
74 # Keep Apple Terminal.app's current working directory updated 82 # Keep Apple Terminal.app's current working directory updated
75 # Based on this answer: http://superuser.com/a/315029 83 # Based on this answer: http://superuser.com/a/315029
76 # With extra fixes to handle multibyte chars and non-UTF-8 locales 84 # With extra fixes to handle multibyte chars and non-UTF-8 locales
77 85
78 if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then 86 if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
79 # Emits the control sequence to notify Terminal.app of the cwd 87 # Emits the control sequence to notify Terminal.app of the cwd
80 # Identifies the directory using a file: URI scheme, including 88 # Identifies the directory using a file: URI scheme, including
81 # the host name to disambiguate local vs. remote paths. 89 # the host name to disambiguate local vs. remote paths.
82 function update_terminalapp_cwd() { 90 function update_terminalapp_cwd() {
83 emulate -L zsh 91 emulate -L zsh
84 92
85 # Percent-encode the pathname. 93 # Percent-encode the pathname.
86 local URL_PATH="$(omz_urlencode -P $PWD)" 94 local URL_PATH="$(omz_urlencode -P $PWD)"
87 [[ $? != 0 ]] && return 1 95 [[ $? != 0 ]] && return 1
88 96
89 # Undocumented Terminal.app-specific control sequence 97 # Undocumented Terminal.app-specific control sequence
90 printf '\e]7;%s\a' "file://$HOST$URL_PATH" 98 printf '\e]7;%s\a' "file://$HOST$URL_PATH"
91 } 99 }
92 100
93 # Use a precmd hook instead of a chpwd hook to avoid contaminating output 101 # Use a precmd hook instead of a chpwd hook to avoid contaminating output
94 precmd_functions+=(update_terminalapp_cwd) 102 precmd_functions+=(update_terminalapp_cwd)
95 # Run once to get initial cwd set 103 # Run once to get initial cwd set
96 update_terminalapp_cwd 104 update_terminalapp_cwd
97 fi 105 fi
98 106
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 `command -v yaourt` ]]; then 5 if (( $+commands[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 `command -v abs` && -x `command -v aur` ]]; then 24 if (( $+commands[abs] && $+commands[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 `command -v abs` ]]; then 26 elif (( $+commands[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 `command -v aur` ]]; then 28 elif (( $+commands[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 `command -v abs` && -x `command -v aur` ]]; then 52 if (( $+commands[abs] && $+commands[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 `command -v abs` ]]; then 54 elif (( $+commands[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 `command -v aur` ]]; then 56 elif (( $+commands[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 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}' 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/branch/README.md
File was created 1 # Branch
2
3 Displays the current Git or Mercurial branch fast.
4
5 ## Speed test
6
7 ### Mercurial
8
9 ```shell
10 $ time hg branch
11 0.11s user 0.14s system 70% cpu 0.355 total
12 ```
13
14 ### Branch plugin
15
16 ```shell
17 $ time zsh /tmp/branch_prompt_info_test.zsh
18 0.00s user 0.01s system 78% cpu 0.014 total
19 ```
20
21 ## Usage
22
23 Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
24 adding `$(branch_prompt_info)` in your prompt like this:
25
26 ```diff
27 - PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
28 + PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
29 ```
30
31 ## Maintainer
32
33 Victor Torres (<vpaivatorres@gmail.com>)
34
plugins/branch/branch.plugin.zsh
File was created 1 # Branch: displays the current Git or Mercurial branch fast.
2 # Victor Torres <vpaivatorres@gmail.com>
3 # Oct 2, 2015
4
5 function branch_prompt_info() {
6 # Defines path as current directory
7 local current_dir=$PWD
8 # While current path is not root path
9 while [[ $current_dir != '/' ]]
10 do
11 # Git repository
12 if [[ -d "${current_dir}/.git" ]]
13 then
14 echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
15 return;
16 fi
17 # Mercurial repository
18 if [[ -d "${current_dir}/.hg" ]]
19 then
20 echo '☿' $(<"$current_dir/.hg/branch")
21 return;
22 fi
23 # Defines path as parent directory and keeps looking for :)
24 current_dir="${current_dir:h}"
25 done
26 }
27
plugins/colored-man-pages/colored-man-pages.plugin.zsh
1 if [ "$OSTYPE[0,7]" = "solaris" ] 1 if [[ "$OSTYPE" = solaris* ]]
2 then 2 then
3 if [ ! -x ${HOME}/bin/nroff ] 3 if [[ ! -x "$HOME/bin/nroff" ]]
4 then 4 then
5 mkdir -p ${HOME}/bin 5 mkdir -p "$HOME/bin"
6 cat > ${HOME}/bin/nroff <<EOF 6 cat > "$HOME/bin/nroff" <<EOF
7 #!/bin/sh 7 #!/bin/sh
8 if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then 8 if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
9 shift 9 shift
10 exec /usr/bin/nroff -u\${_NROFF_U} "\$@" 10 exec /usr/bin/nroff -u\$_NROFF_U "\$@"
11 fi 11 fi
12 #-- Some other invocation of nroff 12 #-- Some other invocation of nroff
13 exec /usr/bin/nroff "\$@" 13 exec /usr/bin/nroff "\$@"
14 EOF 14 EOF
15 chmod +x ${HOME}/bin/nroff 15 chmod +x "$HOME/bin/nroff"
16 fi 16 fi
17 fi 17 fi
18 18
19 man() { 19 man() {
20 env \ 20 env \
21 LESS_TERMCAP_mb=$(printf "\e[1;31m") \ 21 LESS_TERMCAP_mb=$(printf "\e[1;31m") \
22 LESS_TERMCAP_md=$(printf "\e[1;31m") \ 22 LESS_TERMCAP_md=$(printf "\e[1;31m") \
23 LESS_TERMCAP_me=$(printf "\e[0m") \ 23 LESS_TERMCAP_me=$(printf "\e[0m") \
24 LESS_TERMCAP_se=$(printf "\e[0m") \ 24 LESS_TERMCAP_se=$(printf "\e[0m") \
25 LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ 25 LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
26 LESS_TERMCAP_ue=$(printf "\e[0m") \ 26 LESS_TERMCAP_ue=$(printf "\e[0m") \
27 LESS_TERMCAP_us=$(printf "\e[1;32m") \ 27 LESS_TERMCAP_us=$(printf "\e[1;32m") \
28 PAGER=/usr/bin/less \ 28 PAGER="${commands[less]:-$PAGER}" \
29 _NROFF_U=1 \ 29 _NROFF_U=1 \
30 PATH=${HOME}/bin:${PATH} \ 30 PATH="$HOME/bin:$PATH" \
31 man "$@" 31 man "$@"
32 } 32 }
33 33
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='$EDITOR ~/.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 is-at-least 4.2.0; 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/composer/composer.plugin.zsh
1 # ------------------------------------------------------------------------------ 1 # ------------------------------------------------------------------------------
2 # FILE: composer.plugin.zsh 2 # FILE: composer.plugin.zsh
3 # DESCRIPTION: oh-my-zsh composer plugin file. 3 # DESCRIPTION: oh-my-zsh composer plugin file.
4 # AUTHOR: Daniel Gomes (me@danielcsgomes.com) 4 # AUTHOR: Daniel Gomes (me@danielcsgomes.com)
5 # VERSION: 1.0.0 5 # VERSION: 1.0.0
6 # ------------------------------------------------------------------------------ 6 # ------------------------------------------------------------------------------
7 7
8 # Composer basic command completion 8 # Composer basic command completion
9 _composer_get_command_list () { 9 _composer_get_command_list () {
10 $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }' 10 $_comp_command1 --no-ansi 2>/dev/null | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
11 } 11 }
12 12
13 _composer_get_required_list () { 13 _composer_get_required_list () {
14 $_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' 14 $_comp_command1 show -s --no-ansi 2>/dev/null | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
15 } 15 }
16 16
17 _composer () { 17 _composer () {
18 local curcontext="$curcontext" state line 18 local curcontext="$curcontext" state line
19 typeset -A opt_args 19 typeset -A opt_args
20 _arguments \ 20 _arguments \
21 '1: :->command'\ 21 '1: :->command'\
22 '*: :->args' 22 '*: :->args'
23 23
24 case $state in 24 case $state in
25 command) 25 command)
26 compadd $(_composer_get_command_list) 26 compadd $(_composer_get_command_list)
27 ;; 27 ;;
28 *) 28 *)
29 compadd $(_composer_get_required_list) 29 compadd $(_composer_get_required_list)
30 ;; 30 ;;
31 esac 31 esac
32 } 32 }
33 33
34 compdef _composer composer 34 compdef _composer composer
35 compdef _composer composer.phar 35 compdef _composer composer.phar
36 36
37 # Aliases 37 # Aliases
38 alias c='composer' 38 alias c='composer'
39 alias csu='composer self-update' 39 alias csu='composer self-update'
40 alias cu='composer update' 40 alias cu='composer update'
41 alias cr='composer require' 41 alias cr='composer require'
42 alias ci='composer install' 42 alias ci='composer install'
43 alias ccp='composer create-project' 43 alias ccp='composer create-project'
44 alias cdu='composer dump-autoload' 44 alias cdu='composer dump-autoload'
45 alias cgu='composer global update' 45 alias cgu='composer global update'
46 alias cgr='composer global require' 46 alias cgr='composer global require'
47 47
48 # install composer in the current directory 48 # install composer in the current directory
49 alias cget='curl -s https://getcomposer.org/installer | php' 49 alias cget='curl -s https://getcomposer.org/installer | php'
50 50
51 # Add Composer's global binaries to PATH 51 # Add Composer's global binaries to PATH
52 export PATH=$PATH:~/.composer/vendor/bin 52 export PATH=$PATH:~/.composer/vendor/bin
53 53
plugins/ember-cli/README.md
1 # Ember CLI 1 # Ember CLI
2 2
3 **Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa) 3 **Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa)
4 4
5 Ember CLI (http://www.ember-cli.com/) 5 Ember CLI (http://www.ember-cli.com/)
6 6
7 ### List of Aliases 7 ### List of Aliases
8 8
9 alias es='ember serve' 9 Alias | Ember-CLI command
10 alias ea='ember addon' 10 ----- | -----------------
11 alias eb='ember build' 11 **es** | *ember serve*
12 alias ed='ember destroy' 12 **ea** | *ember addon*
13 alias eg='ember generate' 13 **eb** | *ember build*
14 alias eh='ember help' 14 **ed** | *ember destroy*
15 alias ein='ember init' 15 **eg** | *ember generate*
16 alias ei='ember install' 16 **eh** | *ember help*
17 alias et='ember test' 17 **ein** | *ember init*
18 alias eu='ember update' 18 **ei** | *ember install*
19 alias ev='ember version' 19 **et** | *ember test*
20 **eu** | *ember update*
21 **ev** | *ember version*
20 22
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|*.ipsw) unzip "$1" -d $extract_dir ;; 55 (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) 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/git-extras/git-extras.plugin.zsh
1 # ------------------------------------------------------------------------------ 1 # ------------------------------------------------------------------------------
2 # Description 2 # Description
3 # ----------- 3 # -----------
4 # 4 #
5 # Completion script for git-extras (http://github.com/tj/git-extras). 5 # Completion script for git-extras (http://github.com/tj/git-extras).
6 # 6 #
7 # This depends on and reueses some of the internals of the _git completion 7 # This depends on and reuses some of the internals of the _git completion
8 # function that ships with zsh itself. It will not work with the _git that ships 8 # function that ships with zsh itself. It will not work with the _git that ships
9 # with git. 9 # with git.
10 # 10 #
11 # ------------------------------------------------------------------------------ 11 # ------------------------------------------------------------------------------
12 # Authors 12 # Authors
13 # ------- 13 # -------
14 # 14 #
15 # * Alexis GRIMALDI (https://github.com/agrimaldi) 15 # * Alexis GRIMALDI (https://github.com/agrimaldi)
16 # * spacewander (https://github.com/spacewander) 16 # * spacewander (https://github.com/spacewander)
17 # 17 #
18 # ------------------------------------------------------------------------------ 18 # ------------------------------------------------------------------------------
19 # Inspirations 19 # Inspirations
20 # ----------- 20 # -----------
21 # 21 #
22 # * git-extras (http://github.com/tj/git-extras) 22 # * git-extras (http://github.com/tj/git-extras)
23 # * git-flow-completion (http://github.com/bobthecow/git-flow-completion) 23 # * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
24 # 24 #
25 # ------------------------------------------------------------------------------ 25 # ------------------------------------------------------------------------------
26 26
27 27
28 # Internal functions 28 # Internal functions
29 # These are a lot like their __git_* equivalents inside _git 29 # These are a lot like their __git_* equivalents inside _git
30 30
31 __gitex_command_successful () { 31 __gitex_command_successful () {
32 if (( ${#*:#0} > 0 )); then 32 if (( ${#*:#0} > 0 )); then
33 _message 'not a git repository' 33 _message 'not a git repository'
34 return 1 34 return 1
35 fi 35 fi
36 return 0 36 return 0
37 } 37 }
38 38
39 __gitex_commits() { 39 __gitex_commits() {
40 declare -A commits 40 declare -A commits
41 git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit 41 git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit
42 do 42 do
43 hash=$(echo $commit | cut -d':' -f1) 43 hash=$(echo $commit | cut -d':' -f1)
44 commits[$hash]="$commit" 44 commits[$hash]="$commit"
45 done 45 done
46 local ret=1 46 local ret=1
47 _describe -t commits commit commits && ret=0 47 _describe -t commits commit commits && ret=0
48 } 48 }
49 49
50 __gitex_tag_names() { 50 __gitex_tag_names() {
51 local expl 51 local expl
52 declare -a tag_names 52 declare -a tag_names
53 tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) 53 tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
54 __git_command_successful || return 54 __git_command_successful || return
55 _wanted tag-names expl tag-name compadd $* - $tag_names 55 _wanted tag-names expl tag-name compadd $* - $tag_names
56 } 56 }
57 57
58 58
59 __gitex_branch_names() { 59 __gitex_branch_names() {
60 local expl 60 local expl
61 declare -a branch_names 61 declare -a branch_names
62 branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) 62 branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
63 __git_command_successful || return 63 __git_command_successful || return
64 _wanted branch-names expl branch-name compadd $* - $branch_names 64 _wanted branch-names expl branch-name compadd $* - $branch_names
65 } 65 }
66 66
67 __gitex_specific_branch_names() { 67 __gitex_specific_branch_names() {
68 local expl 68 local expl
69 declare -a branch_names 69 declare -a branch_names
70 branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/}) 70 branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/})
71 __git_command_successful || return 71 __git_command_successful || return
72 _wanted branch-names expl branch-name compadd $* - $branch_names 72 _wanted branch-names expl branch-name compadd $* - $branch_names
73 } 73 }
74 74
75 __gitex_feature_branch_names() { 75 __gitex_feature_branch_names() {
76 __gitex_specific_branch_names 'feature' 76 __gitex_specific_branch_names 'feature'
77 } 77 }
78 78
79 __gitex_refactor_branch_names() { 79 __gitex_refactor_branch_names() {
80 __gitex_specific_branch_names 'refactor' 80 __gitex_specific_branch_names 'refactor'
81 } 81 }
82 82
83 __gitex_bug_branch_names() { 83 __gitex_bug_branch_names() {
84 __gitex_specific_branch_names 'bug' 84 __gitex_specific_branch_names 'bug'
85 } 85 }
86 86
87 __gitex_submodule_names() { 87 __gitex_submodule_names() {
88 local expl 88 local expl
89 declare -a submodule_names 89 declare -a submodule_names
90 submodule_names=(${(f)"$(_call_program branchrefs git submodule status | awk '{print $2}')"}) # ' 90 submodule_names=(${(f)"$(_call_program branchrefs git submodule status | awk '{print $2}')"}) # '
91 __git_command_successful || return 91 __git_command_successful || return
92 _wanted submodule-names expl submodule-name compadd $* - $submodule_names 92 _wanted submodule-names expl submodule-name compadd $* - $submodule_names
93 } 93 }
94 94
95 95
96 __gitex_author_names() { 96 __gitex_author_names() {
97 local expl 97 local expl
98 declare -a author_names 98 declare -a author_names
99 author_names=(${(f)"$(_call_program branchrefs git log --format='%aN' | sort -u)"}) 99 author_names=(${(f)"$(_call_program branchrefs git log --format='%aN' | sort -u)"})
100 __git_command_successful || return 100 __git_command_successful || return
101 _wanted author-names expl author-name compadd $* - $author_names 101 _wanted author-names expl author-name compadd $* - $author_names
102 } 102 }
103 103
104 # subcommands 104 # subcommands
105 105
106 _git-bug() { 106 _git-bug() {
107 local curcontext=$curcontext state line ret=1 107 local curcontext=$curcontext state line ret=1
108 declare -A opt_args 108 declare -A opt_args
109 109
110 _arguments -C \ 110 _arguments -C \
111 ': :->command' \ 111 ': :->command' \
112 '*:: :->option-or-argument' && ret=0 112 '*:: :->option-or-argument' && ret=0
113 113
114 case $state in 114 case $state in
115 (command) 115 (command)
116 declare -a commands 116 declare -a commands
117 commands=( 117 commands=(
118 'finish:merge bug into the current branch' 118 'finish:merge bug into the current branch'
119 ) 119 )
120 _describe -t commands command commands && ret=0 120 _describe -t commands command commands && ret=0
121 ;; 121 ;;
122 (option-or-argument) 122 (option-or-argument)
123 curcontext=${curcontext%:*}-$line[1]: 123 curcontext=${curcontext%:*}-$line[1]:
124 case $line[1] in 124 case $line[1] in
125 (finish) 125 (finish)
126 _arguments -C \ 126 _arguments -C \
127 ':branch-name:__gitex_bug_branch_names' 127 ':branch-name:__gitex_bug_branch_names'
128 ;; 128 ;;
129 esac 129 esac
130 esac 130 esac
131 } 131 }
132 132
133 133
134 _git-changelog() { 134 _git-changelog() {
135 _arguments \ 135 _arguments \
136 '(-l --list)'{-l,--list}'[list commits]' \ 136 '(-l --list)'{-l,--list}'[list commits]' \
137 } 137 }
138 138
139 139
140 140
141 _git-contrib() { 141 _git-contrib() {
142 _arguments \ 142 _arguments \
143 ':author:__gitex_author_names' 143 ':author:__gitex_author_names'
144 } 144 }
145 145
146 146
147 _git-count() { 147 _git-count() {
148 _arguments \ 148 _arguments \
149 '--all[detailed commit count]' 149 '--all[detailed commit count]'
150 } 150 }
151 151
152 152
153 _git-delete-branch() { 153 _git-delete-branch() {
154 _arguments \ 154 _arguments \
155 ':branch-name:__gitex_branch_names' 155 ':branch-name:__gitex_branch_names'
156 } 156 }
157 157
158 158
159 _git-delete-submodule() { 159 _git-delete-submodule() {
160 _arguments \ 160 _arguments \
161 ':submodule-name:__gitex_submodule_names' 161 ':submodule-name:__gitex_submodule_names'
162 } 162 }
163 163
164 164
165 _git-delete-tag() { 165 _git-delete-tag() {
166 _arguments \ 166 _arguments \
167 ':tag-name:__gitex_tag_names' 167 ':tag-name:__gitex_tag_names'
168 } 168 }
169 169
170 170
171 _git-effort() { 171 _git-effort() {
172 _arguments \ 172 _arguments \
173 '--above[ignore file with less than x commits]' 173 '--above[ignore file with less than x commits]'
174 } 174 }
175 175
176 176
177 _git-extras() { 177 _git-extras() {
178 local curcontext=$curcontext state line ret=1 178 local curcontext=$curcontext state line ret=1
179 declare -A opt_args 179 declare -A opt_args
180 180
181 _arguments -C \ 181 _arguments -C \
182 ': :->command' \ 182 ': :->command' \
183 '*:: :->option-or-argument' && ret=0 183 '*:: :->option-or-argument' && ret=0
184 184
185 case $state in 185 case $state in
186 (command) 186 (command)
187 declare -a commands 187 declare -a commands
188 commands=( 188 commands=(
189 'update:update git-extras' 189 'update:update git-extras'
190 ) 190 )
191 _describe -t commands command commands && ret=0 191 _describe -t commands command commands && ret=0
192 ;; 192 ;;
193 esac 193 esac
194 194
195 _arguments \ 195 _arguments \
196 '(-v --version)'{-v,--version}'[show current version]' 196 '(-v --version)'{-v,--version}'[show current version]'
197 } 197 }
198 198
199 199
200 _git-feature() { 200 _git-feature() {
201 local curcontext=$curcontext state line ret=1 201 local curcontext=$curcontext state line ret=1
202 declare -A opt_args 202 declare -A opt_args
203 203
204 _arguments -C \ 204 _arguments -C \
205 ': :->command' \ 205 ': :->command' \
206 '*:: :->option-or-argument' && ret=0 206 '*:: :->option-or-argument' && ret=0
207 207
208 case $state in 208 case $state in
209 (command) 209 (command)
210 declare -a commands 210 declare -a commands
211 commands=( 211 commands=(
212 'finish:merge feature into the current branch' 212 'finish:merge feature into the current branch'
213 ) 213 )
214 _describe -t commands command commands && ret=0 214 _describe -t commands command commands && ret=0
215 ;; 215 ;;
216 (option-or-argument) 216 (option-or-argument)
217 curcontext=${curcontext%:*}-$line[1]: 217 curcontext=${curcontext%:*}-$line[1]:
218 case $line[1] in 218 case $line[1] in
219 (finish) 219 (finish)
220 _arguments -C \ 220 _arguments -C \
221 ':branch-name:__gitex_feature_branch_names' 221 ':branch-name:__gitex_feature_branch_names'
222 ;; 222 ;;
223 esac 223 esac
224 esac 224 esac
225 } 225 }
226 226
227 227
228 _git-graft() { 228 _git-graft() {
229 _arguments \ 229 _arguments \
230 ':src-branch-name:__gitex_branch_names' \ 230 ':src-branch-name:__gitex_branch_names' \
231 ':dest-branch-name:__gitex_branch_names' 231 ':dest-branch-name:__gitex_branch_names'
232 } 232 }
233 233
234 234
235 _git-ignore() { 235 _git-ignore() {
236 _arguments -C \ 236 _arguments -C \
237 '(--local -l)'{--local,-l}'[show local gitignore]' \ 237 '(--local -l)'{--local,-l}'[show local gitignore]' \
238 '(--global -g)'{--global,-g}'[show global gitignore]' 238 '(--global -g)'{--global,-g}'[show global gitignore]'
239 } 239 }
240 240
241 241
242 _git-missing() { 242 _git-missing() {
243 _arguments \ 243 _arguments \
244 ':first-branch-name:__gitex_branch_names' \ 244 ':first-branch-name:__gitex_branch_names' \
245 ':second-branch-name:__gitex_branch_names' 245 ':second-branch-name:__gitex_branch_names'
246 } 246 }
247 247
248 248
249 _git-refactor() { 249 _git-refactor() {
250 local curcontext=$curcontext state line ret=1 250 local curcontext=$curcontext state line ret=1
251 declare -A opt_args 251 declare -A opt_args
252 252
253 _arguments -C \ 253 _arguments -C \
254 ': :->command' \ 254 ': :->command' \
255 '*:: :->option-or-argument' && ret=0 255 '*:: :->option-or-argument' && ret=0
256 256
257 case $state in 257 case $state in
258 (command) 258 (command)
259 declare -a commands 259 declare -a commands
260 commands=( 260 commands=(
261 'finish:merge refactor into the current branch' 261 'finish:merge refactor into the current branch'
262 ) 262 )
263 _describe -t commands command commands && ret=0 263 _describe -t commands command commands && ret=0
264 ;; 264 ;;
265 (option-or-argument) 265 (option-or-argument)
266 curcontext=${curcontext%:*}-$line[1]: 266 curcontext=${curcontext%:*}-$line[1]:
267 case $line[1] in 267 case $line[1] in
268 (finish) 268 (finish)
269 _arguments -C \ 269 _arguments -C \
270 ':branch-name:__gitex_refactor_branch_names' 270 ':branch-name:__gitex_refactor_branch_names'
271 ;; 271 ;;
272 esac 272 esac
273 esac 273 esac
274 } 274 }
275 275
276 276
277 _git-squash() { 277 _git-squash() {
278 _arguments \ 278 _arguments \
279 ':branch-name:__gitex_branch_names' 279 ':branch-name:__gitex_branch_names'
280 } 280 }
281 281
282 _git-summary() { 282 _git-summary() {
283 _arguments '--line[summarize with lines rather than commits]' 283 _arguments '--line[summarize with lines rather than commits]'
284 __gitex_commits 284 __gitex_commits
285 } 285 }
286 286
287 287
288 _git-undo(){ 288 _git-undo(){
289 _arguments -C \ 289 _arguments -C \
290 '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \ 290 '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
291 '(--hard -h)'{--hard,-h}'[wipes your commit(s)]' 291 '(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
292 } 292 }
293 293
294 zstyle ':completion:*:*:git:*' user-commands \ 294 zstyle ':completion:*:*:git:*' user-commands \
295 alias:'define, search and show aliases' \ 295 alias:'define, search and show aliases' \
296 archive-file:'export the current HEAD of the git repository to a archive' \ 296 archive-file:'export the current HEAD of the git repository to a archive' \
297 back:'undo and stage latest commits' \ 297 back:'undo and stage latest commits' \
298 bug:'create a bug branch' \ 298 bug:'create a bug branch' \
299 changelog:'populate changelog file with commits since the previous tag' \ 299 changelog:'populate changelog file with commits since the previous tag' \
300 commits-since:'list commits since a given date' \ 300 commits-since:'list commits since a given date' \
301 contrib:'display author contributions' \ 301 contrib:'display author contributions' \
302 count:'count commits' \ 302 count:'count commits' \
303 create-branch:'create local and remote branch' \ 303 create-branch:'create local and remote branch' \
304 delete-branch:'delete local and remote branch' \ 304 delete-branch:'delete local and remote branch' \
305 delete-merged-branches:'delete merged branches'\ 305 delete-merged-branches:'delete merged branches'\
306 delete-submodule:'delete submodule' \ 306 delete-submodule:'delete submodule' \
307 delete-tag:'delete local and remote tag' \ 307 delete-tag:'delete local and remote tag' \
308 effort:'display effort statistics' \ 308 effort:'display effort statistics' \
309 extras:'git-extras' \ 309 extras:'git-extras' \
310 feature:'create a feature branch' \ 310 feature:'create a feature branch' \
311 fork:'fork a repo on github' \ 311 fork:'fork a repo on github' \
312 fresh-branch:'create empty local branch' \ 312 fresh-branch:'create empty local branch' \
313 gh-pages:'create the GitHub Pages branch' \ 313 gh-pages:'create the GitHub Pages branch' \
314 graft:'merge commits from source branch to destination branch' \ 314 graft:'merge commits from source branch to destination branch' \
315 ignore:'add patterns to .gitignore' \ 315 ignore:'add patterns to .gitignore' \
316 info:'show info about the repository' \ 316 info:'show info about the repository' \
317 local-commits:'list unpushed commits on the local branch' \ 317 local-commits:'list unpushed commits on the local branch' \
318 lock:'lock a file excluded from version control' \ 318 lock:'lock a file excluded from version control' \
319 locked:'ls files that have been locked' \ 319 locked:'ls files that have been locked' \
320 missing:'show commits missing from another branch' \ 320 missing:'show commits missing from another branch' \
321 pr:'checks out a pull request locally' \ 321 pr:'checks out a pull request locally' \
322 rebase-patch:'rebases a patch' \ 322 rebase-patch:'rebases a patch' \
323 refactor:'create a refactor branch' \ 323 refactor:'create a refactor branch' \
324 release:'commit, tag and push changes to the repository' \ 324 release:'commit, tag and push changes to the repository' \
325 rename-tag:'rename a tag' \ 325 rename-tag:'rename a tag' \
326 repl:'read-eval-print-loop' \ 326 repl:'read-eval-print-loop' \
327 reset-file:'reset one file' \ 327 reset-file:'reset one file' \
328 root:'show path of root' \ 328 root:'show path of root' \
329 setup:'setup a git repository' \ 329 setup:'setup a git repository' \
330 show-tree:'show branch tree of commit history' \ 330 show-tree:'show branch tree of commit history' \
331 squash:'merge commits from source branch into the current one as a single commit' \ 331 squash:'merge commits from source branch into the current one as a single commit' \
332 summary:'repository summary' \ 332 summary:'repository summary' \
333 touch:'one step creation of new files' \ 333 touch:'one step creation of new files' \
334 undo:'remove the latest commit' \ 334 undo:'remove the latest commit' \
335 unlock:'unlock a file excluded from version control' 335 unlock:'unlock a file excluded from version control'
336 336
plugins/git-flow/git-flow.plugin.zsh
1 #!zsh 1 #!zsh
2 # 2 #
3 # Installation 3 # Installation
4 # ------------ 4 # ------------
5 # 5 #
6 # To achieve git-flow completion nirvana: 6 # To achieve git-flow completion nirvana:
7 # 7 #
8 # 0. Update your zsh's git-completion module to the newest version. 8 # 0. Update your zsh's git-completion module to the newest version.
9 # From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD 9 # From here. https://raw.githubusercontent.com/zsh-users/zsh/master/Completion/Unix/Command/_git
10 # 10 #
11 # 1. Install this file. Either: 11 # 1. Install this file. Either:
12 # 12 #
13 # a. Place it in your .zshrc: 13 # a. Place it in your .zshrc:
14 # 14 #
15 # b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in 15 # b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in
16 # your .zshrc: 16 # your .zshrc:
17 # 17 #
18 # source ~/.git-flow-completion.zsh 18 # source ~/.git-flow-completion.zsh
19 # 19 #
20 # c. Or, use this file as an oh-my-zsh plugin. 20 # c. Or, use this file as an oh-my-zsh plugin.
21 # 21 #
22 22
23 #Alias 23 #Alias
24 alias gfl='git flow' 24 alias gfl='git flow'
25 alias gcd='git checkout develop' 25 alias gcd='git checkout develop'
26 alias gch='git checkout hotfix' 26 alias gch='git checkout hotfix'
27 alias gcr='git checkout release' 27 alias gcr='git checkout release'
28 28
29 _git-flow () 29 _git-flow ()
30 { 30 {
31 local curcontext="$curcontext" state line 31 local curcontext="$curcontext" state line
32 typeset -A opt_args 32 typeset -A opt_args
33 33
34 _arguments -C \ 34 _arguments -C \
35 ':command:->command' \ 35 ':command:->command' \
36 '*::options:->options' 36 '*::options:->options'
37 37
38 case $state in 38 case $state in
39 (command) 39 (command)
40 40
41 local -a subcommands 41 local -a subcommands
42 subcommands=( 42 subcommands=(
43 'init:Initialize a new git repo with support for the branching model.' 43 'init:Initialize a new git repo with support for the branching model.'
44 'feature:Manage your feature branches.' 44 'feature:Manage your feature branches.'
45 'release:Manage your release branches.' 45 'release:Manage your release branches.'
46 'hotfix:Manage your hotfix branches.' 46 'hotfix:Manage your hotfix branches.'
47 'support:Manage your support branches.' 47 'support:Manage your support branches.'
48 'version:Shows version information.' 48 'version:Shows version information.'
49 ) 49 )
50 _describe -t commands 'git flow' subcommands 50 _describe -t commands 'git flow' subcommands
51 ;; 51 ;;
52 52
53 (options) 53 (options)
54 case $line[1] in 54 case $line[1] in
55 55
56 (init) 56 (init)
57 _arguments \ 57 _arguments \
58 -f'[Force setting of gitflow branches, even if already configured]' 58 -f'[Force setting of gitflow branches, even if already configured]'
59 ;; 59 ;;
60 60
61 (version) 61 (version)
62 ;; 62 ;;
63 63
64 (hotfix) 64 (hotfix)
65 __git-flow-hotfix 65 __git-flow-hotfix
66 ;; 66 ;;
67 67
68 (release) 68 (release)
69 __git-flow-release 69 __git-flow-release
70 ;; 70 ;;
71 71
72 (feature) 72 (feature)
73 __git-flow-feature 73 __git-flow-feature
74 ;; 74 ;;
75 esac 75 esac
76 ;; 76 ;;
77 esac 77 esac
78 } 78 }
79 79
80 __git-flow-release () 80 __git-flow-release ()
81 { 81 {
82 local curcontext="$curcontext" state line 82 local curcontext="$curcontext" state line
83 typeset -A opt_args 83 typeset -A opt_args
84 84
85 _arguments -C \ 85 _arguments -C \
86 ':command:->command' \ 86 ':command:->command' \
87 '*::options:->options' 87 '*::options:->options'
88 88
89 case $state in 89 case $state in
90 (command) 90 (command)
91 91
92 local -a subcommands 92 local -a subcommands
93 subcommands=( 93 subcommands=(
94 'start:Start a new release branch.' 94 'start:Start a new release branch.'
95 'finish:Finish a release branch.' 95 'finish:Finish a release branch.'
96 'list:List all your release branches. (Alias to `git flow release`)' 96 'list:List all your release branches. (Alias to `git flow release`)'
97 'publish: public' 97 'publish: public'
98 'track: track' 98 'track: track'
99 ) 99 )
100 _describe -t commands 'git flow release' subcommands 100 _describe -t commands 'git flow release' subcommands
101 _arguments \ 101 _arguments \
102 -v'[Verbose (more) output]' 102 -v'[Verbose (more) output]'
103 ;; 103 ;;
104 104
105 (options) 105 (options)
106 case $line[1] in 106 case $line[1] in
107 107
108 (start) 108 (start)
109 _arguments \ 109 _arguments \
110 -F'[Fetch from origin before performing finish]'\ 110 -F'[Fetch from origin before performing finish]'\
111 ':version:__git_flow_version_list' 111 ':version:__git_flow_version_list'
112 ;; 112 ;;
113 113
114 (finish) 114 (finish)
115 _arguments \ 115 _arguments \
116 -F'[Fetch from origin before performing finish]' \ 116 -F'[Fetch from origin before performing finish]' \
117 -s'[Sign the release tag cryptographically]'\ 117 -s'[Sign the release tag cryptographically]'\
118 -u'[Use the given GPG-key for the digital signature (implies -s)]'\ 118 -u'[Use the given GPG-key for the digital signature (implies -s)]'\
119 -m'[Use the given tag message]'\ 119 -m'[Use the given tag message]'\
120 -p'[Push to $ORIGIN after performing finish]'\ 120 -p'[Push to $ORIGIN after performing finish]'\
121 -k'[Keep branch after performing finish]'\ 121 -k'[Keep branch after performing finish]'\
122 -n"[Don't tag this release]"\ 122 -n"[Don't tag this release]"\
123 ':version:__git_flow_version_list' 123 ':version:__git_flow_version_list'
124 ;; 124 ;;
125 125
126 (publish) 126 (publish)
127 _arguments \ 127 _arguments \
128 ':version:__git_flow_version_list'\ 128 ':version:__git_flow_version_list'\
129 ;; 129 ;;
130 130
131 (track) 131 (track)
132 _arguments \ 132 _arguments \
133 ':version:__git_flow_version_list'\ 133 ':version:__git_flow_version_list'\
134 ;; 134 ;;
135 135
136 *) 136 *)
137 _arguments \ 137 _arguments \
138 -v'[Verbose (more) output]' 138 -v'[Verbose (more) output]'
139 ;; 139 ;;
140 esac 140 esac
141 ;; 141 ;;
142 esac 142 esac
143 } 143 }
144 144
145 __git-flow-hotfix () 145 __git-flow-hotfix ()
146 { 146 {
147 local curcontext="$curcontext" state line 147 local curcontext="$curcontext" state line
148 typeset -A opt_args 148 typeset -A opt_args
149 149
150 _arguments -C \ 150 _arguments -C \
151 ':command:->command' \ 151 ':command:->command' \
152 '*::options:->options' 152 '*::options:->options'
153 153
154 case $state in 154 case $state in
155 (command) 155 (command)
156 156
157 local -a subcommands 157 local -a subcommands
158 subcommands=( 158 subcommands=(
159 'start:Start a new hotfix branch.' 159 'start:Start a new hotfix branch.'
160 'finish:Finish a hotfix branch.' 160 'finish:Finish a hotfix branch.'
161 'list:List all your hotfix branches. (Alias to `git flow hotfix`)' 161 'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
162 ) 162 )
163 _describe -t commands 'git flow hotfix' subcommands 163 _describe -t commands 'git flow hotfix' subcommands
164 _arguments \ 164 _arguments \
165 -v'[Verbose (more) output]' 165 -v'[Verbose (more) output]'
166 ;; 166 ;;
167 167
168 (options) 168 (options)
169 case $line[1] in 169 case $line[1] in
170 170
171 (start) 171 (start)
172 _arguments \ 172 _arguments \
173 -F'[Fetch from origin before performing finish]'\ 173 -F'[Fetch from origin before performing finish]'\
174 ':hotfix:__git_flow_version_list'\ 174 ':hotfix:__git_flow_version_list'\
175 ':branch-name:__git_branch_names' 175 ':branch-name:__git_branch_names'
176 ;; 176 ;;
177 177
178 (finish) 178 (finish)
179 _arguments \ 179 _arguments \
180 -F'[Fetch from origin before performing finish]' \ 180 -F'[Fetch from origin before performing finish]' \
181 -s'[Sign the release tag cryptographically]'\ 181 -s'[Sign the release tag cryptographically]'\
182 -u'[Use the given GPG-key for the digital signature (implies -s)]'\ 182 -u'[Use the given GPG-key for the digital signature (implies -s)]'\
183 -m'[Use the given tag message]'\ 183 -m'[Use the given tag message]'\
184 -p'[Push to $ORIGIN after performing finish]'\ 184 -p'[Push to $ORIGIN after performing finish]'\
185 -k'[Keep branch after performing finish]'\ 185 -k'[Keep branch after performing finish]'\
186 -n"[Don't tag this release]"\ 186 -n"[Don't tag this release]"\
187 ':hotfix:__git_flow_hotfix_list' 187 ':hotfix:__git_flow_hotfix_list'
188 ;; 188 ;;
189 189
190 *) 190 *)
191 _arguments \ 191 _arguments \
192 -v'[Verbose (more) output]' 192 -v'[Verbose (more) output]'
193 ;; 193 ;;
194 esac 194 esac
195 ;; 195 ;;
196 esac 196 esac
197 } 197 }
198 198
199 __git-flow-feature () 199 __git-flow-feature ()
200 { 200 {
201 local curcontext="$curcontext" state line 201 local curcontext="$curcontext" state line
202 typeset -A opt_args 202 typeset -A opt_args
203 203
204 _arguments -C \ 204 _arguments -C \
205 ':command:->command' \ 205 ':command:->command' \
206 '*::options:->options' 206 '*::options:->options'
207 207
208 case $state in 208 case $state in
209 (command) 209 (command)
210 210
211 local -a subcommands 211 local -a subcommands
212 subcommands=( 212 subcommands=(
213 'start:Start a new feature branch.' 213 'start:Start a new feature branch.'
214 'finish:Finish a feature branch.' 214 'finish:Finish a feature branch.'
215 'list:List all your feature branches. (Alias to `git flow feature`)' 215 'list:List all your feature branches. (Alias to `git flow feature`)'
216 'publish: publish' 216 'publish: publish'
217 'track: track' 217 'track: track'
218 'diff: diff' 218 'diff: diff'
219 'rebase: rebase' 219 'rebase: rebase'
220 'checkout: checkout' 220 'checkout: checkout'
221 'pull: pull' 221 'pull: pull'
222 ) 222 )
223 _describe -t commands 'git flow feature' subcommands 223 _describe -t commands 'git flow feature' subcommands
224 _arguments \ 224 _arguments \
225 -v'[Verbose (more) output]' 225 -v'[Verbose (more) output]'
226 ;; 226 ;;
227 227
228 (options) 228 (options)
229 case $line[1] in 229 case $line[1] in
230 230
231 (start) 231 (start)
232 _arguments \ 232 _arguments \
233 -F'[Fetch from origin before performing finish]'\ 233 -F'[Fetch from origin before performing finish]'\
234 ':feature:__git_flow_feature_list'\ 234 ':feature:__git_flow_feature_list'\
235 ':branch-name:__git_branch_names' 235 ':branch-name:__git_branch_names'
236 ;; 236 ;;
237 237
238 (finish) 238 (finish)
239 _arguments \ 239 _arguments \
240 -F'[Fetch from origin before performing finish]' \ 240 -F'[Fetch from origin before performing finish]' \
241 -r'[Rebase instead of merge]'\ 241 -r'[Rebase instead of merge]'\
242 -k'[Keep branch after performing finish]'\ 242 -k'[Keep branch after performing finish]'\
243 ':feature:__git_flow_feature_list' 243 ':feature:__git_flow_feature_list'
244 ;; 244 ;;
245 245
246 (publish) 246 (publish)
247 _arguments \ 247 _arguments \
248 ':feature:__git_flow_feature_list'\ 248 ':feature:__git_flow_feature_list'\
249 ;; 249 ;;
250 250
251 (track) 251 (track)
252 _arguments \ 252 _arguments \
253 ':feature:__git_flow_feature_list'\ 253 ':feature:__git_flow_feature_list'\
254 ;; 254 ;;
255 255
256 (diff) 256 (diff)
257 _arguments \ 257 _arguments \
258 ':branch:__git_flow_feature_list'\ 258 ':branch:__git_flow_feature_list'\
259 ;; 259 ;;
260 260
261 (rebase) 261 (rebase)
262 _arguments \ 262 _arguments \
263 -i'[Do an interactive rebase]' \ 263 -i'[Do an interactive rebase]' \
264 ':branch:__git_flow_feature_list' 264 ':branch:__git_flow_feature_list'
265 ;; 265 ;;
266 266
267 (checkout) 267 (checkout)
268 _arguments \ 268 _arguments \
269 ':branch:__git_flow_feature_list'\ 269 ':branch:__git_flow_feature_list'\
270 ;; 270 ;;
271 271
272 (pull) 272 (pull)
273 _arguments \ 273 _arguments \
274 ':remote:__git_remotes'\ 274 ':remote:__git_remotes'\
275 ':branch:__git_flow_feature_list' 275 ':branch:__git_flow_feature_list'
276 ;; 276 ;;
277 277
278 *) 278 *)
279 _arguments \ 279 _arguments \
280 -v'[Verbose (more) output]' 280 -v'[Verbose (more) output]'
281 ;; 281 ;;
282 esac 282 esac
283 ;; 283 ;;
284 esac 284 esac
285 } 285 }
286 286
287 __git_flow_version_list () 287 __git_flow_version_list ()
288 { 288 {
289 local expl 289 local expl
290 declare -a versions 290 declare -a versions
291 291
292 versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}}) 292 versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
293 __git_command_successful || return 293 __git_command_successful || return
294 294
295 _wanted versions expl 'version' compadd $versions 295 _wanted versions expl 'version' compadd $versions
296 } 296 }
297 297
298 __git_flow_feature_list () 298 __git_flow_feature_list ()
299 { 299 {
300 local expl 300 local expl
301 declare -a features 301 declare -a features
302 302
303 features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}}) 303 features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
304 __git_command_successful || return 304 __git_command_successful || return
305 305
306 _wanted features expl 'feature' compadd $features 306 _wanted features expl 'feature' compadd $features
307 } 307 }
308 308
309 __git_remotes () { 309 __git_remotes () {
310 local expl gitdir remotes 310 local expl gitdir remotes
311 311
312 gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) 312 gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
313 __git_command_successful || return 313 __git_command_successful || return
314 314
315 remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) 315 remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
316 __git_command_successful || return 316 __git_command_successful || return
317 317
318 # TODO: Should combine the two instead of either or. 318 # TODO: Should combine the two instead of either or.
319 if (( $#remotes > 0 )); then 319 if (( $#remotes > 0 )); then
320 _wanted remotes expl remote compadd $* - $remotes 320 _wanted remotes expl remote compadd $* - $remotes
321 else 321 else
322 _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" 322 _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
323 fi 323 fi
324 } 324 }
325 325
326 __git_flow_hotfix_list () 326 __git_flow_hotfix_list ()
327 { 327 {
328 local expl 328 local expl
329 declare -a hotfixes 329 declare -a hotfixes
330 330
331 hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}}) 331 hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
332 __git_command_successful || return 332 __git_command_successful || return
333 333
334 _wanted hotfixes expl 'hotfix' compadd $hotfixes 334 _wanted hotfixes expl 'hotfix' compadd $hotfixes
335 } 335 }
336 336
337 __git_branch_names () { 337 __git_branch_names () {
338 local expl 338 local expl
339 declare -a branch_names 339 declare -a branch_names
340 340
341 branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) 341 branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
342 __git_command_successful || return 342 __git_command_successful || return
343 343
344 _wanted branch-names expl branch-name compadd $* - $branch_names 344 _wanted branch-names expl branch-name compadd $* - $branch_names
345 } 345 }
346 346
347 __git_command_successful () { 347 __git_command_successful () {
348 if (( ${#pipestatus:#0} > 0 )); then 348 if (( ${#pipestatus:#0} > 0 )); then
349 _message 'not a git repository' 349 _message 'not a git repository'
350 return 1 350 return 1
351 fi 351 fi
352 return 0 352 return 0
353 } 353 }
354 354
355 zstyle ':completion:*:*:git:*' user-commands flow:'description for foo' 355 zstyle ':completion:*:*:git:*' user-commands flow:'description for foo'
356 356
plugins/git/git.plugin.zsh
1 # Query/use custom command for `git`. 1 # Query/use custom command for `git`.
2 zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd 2 zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
3 : ${_omz_git_git_cmd:=git} 3 : ${_omz_git_git_cmd:=git}
4 4
5 # 5 #
6 # Functions 6 # Functions
7 # 7 #
8 8
9 # The current branch name 9 # The name of the current branch
10 # Usage example: git pull origin $(current_branch) 10 # Back-compatibility wrapper for when this function was defined here in
11 # Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if 11 # the plugin, before being pulled in to core lib/git.zsh as git_current_branch()
12 # it's not a symbolic ref, but in a Git repo. 12 # to fix the core -> git plugin dependency.
13 function current_branch() { 13 function current_branch() {
14 local ref 14 git_current_branch
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 } 15 }
23 # The list of remotes 16 # The list of remotes
24 function current_repository() { 17 function current_repository() {
25 if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then 18 if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
26 return 19 return
27 fi 20 fi
28 echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2) 21 echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
29 } 22 }
30 # Pretty log messages 23 # Pretty log messages
31 function _git_log_prettily(){ 24 function _git_log_prettily(){
32 if ! [ -z $1 ]; then 25 if ! [ -z $1 ]; then
33 git log --pretty=$1 26 git log --pretty=$1
34 fi 27 fi
35 } 28 }
36 # Warn if the current branch is a WIP 29 # Warn if the current branch is a WIP
37 function work_in_progress() { 30 function work_in_progress() {
38 if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then 31 if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
39 echo "WIP!!" 32 echo "WIP!!"
40 fi 33 fi
41 } 34 }
42 35
43 # 36 #
44 # Aliases 37 # Aliases
45 # (sorted alphabetically) 38 # (sorted alphabetically)
46 # 39 #
47 40
48 alias g='git' 41 alias g='git'
49 42
50 alias ga='git add' 43 alias ga='git add'
51 alias gaa='git add --all' 44 alias gaa='git add --all'
52 alias gapa='git add --patch' 45 alias gapa='git add --patch'
53 46
54 alias gb='git branch' 47 alias gb='git branch'
55 alias gba='git branch -a' 48 alias gba='git branch -a'
56 alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d' 49 alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d'
57 alias gbl='git blame -b -w' 50 alias gbl='git blame -b -w'
58 alias gbnm='git branch --no-merged' 51 alias gbnm='git branch --no-merged'
59 alias gbr='git branch --remote' 52 alias gbr='git branch --remote'
60 alias gbs='git bisect' 53 alias gbs='git bisect'
61 alias gbsb='git bisect bad' 54 alias gbsb='git bisect bad'
62 alias gbsg='git bisect good' 55 alias gbsg='git bisect good'
63 alias gbsr='git bisect reset' 56 alias gbsr='git bisect reset'
64 alias gbss='git bisect start' 57 alias gbss='git bisect start'
65 58
66 alias gc='git commit -v' 59 alias gc='git commit -v'
67 alias gc!='git commit -v --amend' 60 alias gc!='git commit -v --amend'
68 alias gca='git commit -v -a' 61 alias gca='git commit -v -a'
69 alias gca!='git commit -v -a --amend' 62 alias gca!='git commit -v -a --amend'
70 alias gcan!='git commit -v -a -s --no-edit --amend' 63 alias gcan!='git commit -v -a -s --no-edit --amend'
71 alias gcam='git commit -a -m' 64 alias gcam='git commit -a -m'
72 alias gcb='git checkout -b' 65 alias gcb='git checkout -b'
73 alias gcf='git config --list' 66 alias gcf='git config --list'
74 alias gcl='git clone --recursive' 67 alias gcl='git clone --recursive'
75 alias gclean='git clean -fd' 68 alias gclean='git clean -fd'
76 alias gpristine='git reset --hard && git clean -dfx' 69 alias gpristine='git reset --hard && git clean -dfx'
77 alias gcm='git checkout master' 70 alias gcm='git checkout master'
78 alias gcmsg='git commit -m' 71 alias gcmsg='git commit -m'
79 alias gco='git checkout' 72 alias gco='git checkout'
80 alias gcount='git shortlog -sn' 73 alias gcount='git shortlog -sn'
81 compdef gcount=git 74 compdef gcount=git
82 alias gcp='git cherry-pick' 75 alias gcp='git cherry-pick'
83 alias gcs='git commit -S' 76 alias gcs='git commit -S'
84 77
85 alias gd='git diff' 78 alias gd='git diff'
86 alias gdca='git diff --cached' 79 alias gdca='git diff --cached'
87 alias gdct='git describe --tags `git rev-list --tags --max-count=1`' 80 alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
88 alias gdt='git diff-tree --no-commit-id --name-only -r' 81 alias gdt='git diff-tree --no-commit-id --name-only -r'
89 gdv() { git diff -w "$@" | view - } 82 gdv() { git diff -w "$@" | view - }
90 compdef _git gdv=git-diff 83 compdef _git gdv=git-diff
91 alias gdw='git diff --word-diff' 84 alias gdw='git diff --word-diff'
92 85
93 alias gf='git fetch' 86 alias gf='git fetch'
94 alias gfa='git fetch --all --prune' 87 alias gfa='git fetch --all --prune'
95 function gfg() { git ls-files | grep $@ } 88 function gfg() { git ls-files | grep $@ }
96 compdef gfg=grep 89 compdef gfg=grep
97 alias gfo='git fetch origin' 90 alias gfo='git fetch origin'
98 91
99 alias gg='git gui citool' 92 alias gg='git gui citool'
100 alias gga='git gui citool --amend' 93 alias gga='git gui citool --amend'
101 ggf() { 94 ggf() {
102 [[ "$#" != 1 ]] && local b="$(current_branch)" 95 [[ "$#" != 1 ]] && local b="$(git_current_branch)"
103 git push --force origin "${b:=$1}" 96 git push --force origin "${b:=$1}"
104 } 97 }
105 compdef _git ggf=git-checkout 98 compdef _git ggf=git-checkout
106 ggl() { 99 ggl() {
107 if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then 100 if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
108 git pull origin "${*}" 101 git pull origin "${*}"
109 else 102 else
110 [[ "$#" == 0 ]] && local b="$(current_branch)" 103 [[ "$#" == 0 ]] && local b="$(git_current_branch)"
111 git pull origin "${b:=$1}" 104 git pull origin "${b:=$1}"
112 fi 105 fi
113 } 106 }
114 compdef _git ggl=git-checkout 107 compdef _git ggl=git-checkout
115 alias ggpull='git pull origin $(current_branch)' 108 alias ggpull='git pull origin $(git_current_branch)'
116 compdef _git ggpull=git-checkout 109 compdef _git ggpull=git-checkout
117 ggp() { 110 ggp() {
118 if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then 111 if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
119 git push origin "${*}" 112 git push origin "${*}"
120 else 113 else
121 [[ "$#" == 0 ]] && local b="$(current_branch)" 114 [[ "$#" == 0 ]] && local b="$(git_current_branch)"
122 git push origin "${b:=$1}" 115 git push origin "${b:=$1}"
123 fi 116 fi
124 } 117 }
125 compdef _git ggp=git-checkout 118 compdef _git ggp=git-checkout
126 alias ggpush='git push origin $(current_branch)' 119 alias ggpush='git push origin $(git_current_branch)'
127 compdef _git ggpush=git-checkout 120 compdef _git ggpush=git-checkout
128 ggpnp() { 121 ggpnp() {
129 if [[ "$#" == 0 ]]; then 122 if [[ "$#" == 0 ]]; then
130 ggl && ggp 123 ggl && ggp
131 else 124 else
132 ggl "${*}" && ggp "${*}" 125 ggl "${*}" && ggp "${*}"
133 fi 126 fi
134 } 127 }
135 compdef _git ggpnp=git-checkout 128 compdef _git ggpnp=git-checkout
136 alias ggsup='git branch --set-upstream-to=origin/$(current_branch)' 129 alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
137 ggu() { 130 ggu() {
138 [[ "$#" != 1 ]] && local b="$(current_branch)" 131 [[ "$#" != 1 ]] && local b="$(git_current_branch)"
139 git pull --rebase origin "${b:=$1}" 132 git pull --rebase origin "${b:=$1}"
140 } 133 }
141 compdef _git ggu=git-checkout 134 compdef _git ggu=git-checkout
142 alias ggpur='ggu' 135 alias ggpur='ggu'
143 compdef _git ggpur=git-checkout 136 compdef _git ggpur=git-checkout
144 137
145 alias gignore='git update-index --assume-unchanged' 138 alias gignore='git update-index --assume-unchanged'
146 alias gignored='git ls-files -v | grep "^[[:lower:]]"' 139 alias gignored='git ls-files -v | grep "^[[:lower:]]"'
147 alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' 140 alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
148 compdef git-svn-dcommit-push=git 141 compdef git-svn-dcommit-push=git
149 142
150 alias gk='\gitk --all --branches' 143 alias gk='\gitk --all --branches'
151 compdef _git gk='gitk' 144 compdef _git gk='gitk'
152 alias gke='\gitk --all $(git log -g --pretty=format:%h)' 145 alias gke='\gitk --all $(git log -g --pretty=format:%h)'
153 compdef _git gke='gitk' 146 compdef _git gke='gitk'
154 147
155 alias gl='git pull' 148 alias gl='git pull'
156 alias glg='git log --stat --color' 149 alias glg='git log --stat --color'
157 alias glgp='git log --stat --color -p' 150 alias glgp='git log --stat --color -p'
158 alias glgg='git log --graph --color' 151 alias glgg='git log --graph --color'
159 alias glgga='git log --graph --decorate --all' 152 alias glgga='git log --graph --decorate --all'
160 alias glgm='git log --graph --max-count=10' 153 alias glgm='git log --graph --max-count=10'
161 alias glo='git log --oneline --decorate --color' 154 alias glo='git log --oneline --decorate --color'
162 alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" 155 alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
163 alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" 156 alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
164 alias glog='git log --oneline --decorate --color --graph' 157 alias glog='git log --oneline --decorate --color --graph'
165 alias glp="_git_log_prettily" 158 alias glp="_git_log_prettily"
166 compdef _git glp=git-log 159 compdef _git glp=git-log
167 160
168 alias gm='git merge' 161 alias gm='git merge'
169 alias gmom='git merge origin/master' 162 alias gmom='git merge origin/master'
170 alias gmt='git mergetool --no-prompt' 163 alias gmt='git mergetool --no-prompt'
171 alias gmtvim='git mergetool --no-prompt --tool=vimdiff' 164 alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
172 alias gmum='git merge upstream/master' 165 alias gmum='git merge upstream/master'
173 166
174 alias gp='git push' 167 alias gp='git push'
175 alias gpd='git push --dry-run' 168 alias gpd='git push --dry-run'
176 alias gpoat='git push origin --all && git push origin --tags' 169 alias gpoat='git push origin --all && git push origin --tags'
177 compdef _git gpoat=git-push 170 compdef _git gpoat=git-push
178 alias gpu='git push upstream' 171 alias gpu='git push upstream'
179 alias gpv='git push -v' 172 alias gpv='git push -v'
180 173
181 alias gr='git remote' 174 alias gr='git remote'
182 alias gra='git remote add' 175 alias gra='git remote add'
183 alias grb='git rebase' 176 alias grb='git rebase'
184 alias grba='git rebase --abort' 177 alias grba='git rebase --abort'
185 alias grbc='git rebase --continue' 178 alias grbc='git rebase --continue'
186 alias grbi='git rebase -i' 179 alias grbi='git rebase -i'
187 alias grbm='git rebase master' 180 alias grbm='git rebase master'
188 alias grbs='git rebase --skip' 181 alias grbs='git rebase --skip'
189 alias grh='git reset HEAD' 182 alias grh='git reset HEAD'
190 alias grhh='git reset HEAD --hard' 183 alias grhh='git reset HEAD --hard'
191 alias grmv='git remote rename' 184 alias grmv='git remote rename'
192 alias grrm='git remote remove' 185 alias grrm='git remote remove'
193 alias grset='git remote set-url' 186 alias grset='git remote set-url'
194 alias grt='cd $(git rev-parse --show-toplevel || echo ".")' 187 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
195 alias gru='git reset --' 188 alias gru='git reset --'
196 alias grup='git remote update' 189 alias grup='git remote update'
197 alias grv='git remote -v' 190 alias grv='git remote -v'
198 191
199 alias gsb='git status -sb' 192 alias gsb='git status -sb'
200 alias gsd='git svn dcommit' 193 alias gsd='git svn dcommit'
201 alias gsi='git submodule init' 194 alias gsi='git submodule init'
202 alias gsps='git show --pretty=short --show-signature' 195 alias gsps='git show --pretty=short --show-signature'
203 alias gsr='git svn rebase' 196 alias gsr='git svn rebase'
204 alias gss='git status -s' 197 alias gss='git status -s'
205 alias gst='git status' 198 alias gst='git status'
206 alias gsta='git stash' 199 alias gsta='git stash'
207 alias gstaa='git stash apply' 200 alias gstaa='git stash apply'
208 alias gstd='git stash drop' 201 alias gstd='git stash drop'
209 alias gstl='git stash list' 202 alias gstl='git stash list'
210 alias gstp='git stash pop' 203 alias gstp='git stash pop'
211 alias gsts='git stash show --text' 204 alias gsts='git stash show --text'
212 alias gsu='git submodule update' 205 alias gsu='git submodule update'
213 206
214 alias gts='git tag -s' 207 alias gts='git tag -s'
215 alias gtv='git tag | sort -V' 208 alias gtv='git tag | sort -V'
216 209
217 alias gunignore='git update-index --no-assume-unchanged' 210 alias gunignore='git update-index --no-assume-unchanged'
218 alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' 211 alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
219 alias gup='git pull --rebase' 212 alias gup='git pull --rebase'
220 alias gupv='git pull --rebase -v' 213 alias gupv='git pull --rebase -v'
221 alias glum='git pull upstream master' 214 alias glum='git pull upstream master'
222 215
223 alias gvt='git verify-tag' 216 alias gvt='git verify-tag'
224 217
225 alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' 218 alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
226 alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"' 219 alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"'
227 220
File was created 1 #compdef hub
2
3 # Zsh will source this file when attempting to autoload the "_hub" function,
4 # typically on the first attempt to complete the hub command. We define two new
5 # setup helper routines (one for the zsh-distributed version, one for the
6 # git-distributed, bash-based version). Then we redefine the "_hub" function to
7 # call "_git" after some other interception.
8 #
9 # This is pretty fragile, if you think about it. Any number of implementation
10 # changes in the "_git" scripts could cause problems down the road. It would be
11 # better if the stock git completions were just a bit more permissive about how
12 # it allowed third-party commands to be added.
13
14 (( $+functions[__hub_setup_zsh_fns] )) ||
15 __hub_setup_zsh_fns () {
16 (( $+functions[_git-alias] )) ||
17 _git-alias () {
18 _arguments \
19 '-s[output shell script suitable for eval]' \
20 '1::shell:(zsh bash csh)'
21 }
22
23 (( $+functions[_git-browse] )) ||
24 _git-browse () {
25 _arguments \
26 '-u[output the URL]' \
27 '2::subpage:(wiki commits issues)'
28 }
29
30 (( $+functions[_git-compare] )) ||
31 _git-compare () {
32 _arguments \
33 '-u[output the URL]' \
34 ':[start...]end range:'
35 }
36
37 (( $+functions[_git-create] )) ||
38 _git-create () {
39 _arguments \
40 '::name (REPOSITORY or ORGANIZATION/REPOSITORY):' \
41 '-p[make repository private]' \
42 '-d[description]:description' \
43 '-h[home page]:repository home page URL:_urls'
44 }
45
46 (( $+functions[_git-fork] )) ||
47 _git-fork () {
48 _arguments \
49 '--no-remote[do not add a remote for the new fork]'
50 }
51
52 (( $+functions[_git-pull-request] )) ||
53 _git-pull-request () {
54 _arguments \
55 '-f[force (skip check for local commits)]' \
56 '-b[base]:base ("branch", "owner\:branch", "owner/repo\:branch"):' \
57 '-h[head]:head ("branch", "owner\:branch", "owner/repo\:branch"):' \
58 - set1 \
59 '-m[message]' \
60 '-F[file]' \
61 '-a[user]' \
62 '-M[milestone]' \
63 '-l[labels]' \
64 - set2 \
65 '-i[issue]:issue number:' \
66 - set3 \
67 '::issue-url:_urls'
68 }
69
70 # stash the "real" command for later
71 functions[_hub_orig_git_commands]=$functions[_git_commands]
72
73 # Replace it with our own wrapper.
74 declare -f _git_commands >& /dev/null && unfunction _git_commands
75 _git_commands () {
76 local ret=1
77 # call the original routine
78 _call_function ret _hub_orig_git_commands
79
80 # Effectively "append" our hub commands to the behavior of the original
81 # _git_commands function. Using this wrapper function approach ensures
82 # that we only offer the user the hub subcommands when the user is
83 # actually trying to complete subcommands.
84 hub_commands=(
85 alias:'show shell instructions for wrapping git'
86 pull-request:'open a pull request on GitHub'
87 fork:'fork origin repo on GitHub'
88 create:'create new repo on GitHub for the current project'
89 browse:'browse the project on GitHub'
90 compare:'open GitHub compare view'
91 ci-status:'lookup commit in GitHub Status API'
92 )
93 _describe -t hub-commands 'hub command' hub_commands && ret=0
94
95 return ret
96 }
97 }
98
99 (( $+functions[__hub_setup_bash_fns] )) ||
100 __hub_setup_bash_fns () {
101 # TODO more bash-style fns needed here to complete subcommand args. They take
102 # the form "_git_CMD" where "CMD" is something like "pull-request".
103
104 # Duplicate and rename the 'list_all_commands' function
105 eval "$(declare -f __git_list_all_commands | \
106 sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
107
108 # Wrap the 'list_all_commands' function with extra hub commands
109 __git_list_all_commands() {
110 cat <<-EOF
111 alias
112 pull-request
113 fork
114 create
115 browse
116 compare
117 ci-status
118 EOF
119 __git_list_all_commands_without_hub
120 }
121
122 # Ensure cached commands are cleared
123 __git_all_commands=""
124 }
125
126 # redefine _hub to a much smaller function in the steady state
127 _hub () {
128 # only attempt to intercept the normal "_git" helper functions once
129 (( $+__hub_func_replacement_done )) ||
130 () {
131 # At this stage in the shell's execution the "_git" function has not yet
132 # been autoloaded, so the "_git_commands" or "__git_list_all_commands"
133 # functions will not be defined. Call it now (with a bogus no-op service
134 # to prevent premature completion) so that we can wrap them.
135 if declare -f _git >& /dev/null ; then
136 _hub_noop () { __hub_zsh_provided=1 } # zsh-provided will call this one
137 __hub_noop_main () { __hub_git_provided=1 } # git-provided will call this one
138 local service=hub_noop
139 _git
140 unfunction _hub_noop
141 unfunction __hub_noop_main
142 service=git
143 fi
144
145 if (( $__hub_zsh_provided )) ; then
146 __hub_setup_zsh_fns
147 elif (( $__hub_git_provided )) ; then
148 __hub_setup_bash_fns
149 fi
150
151 __hub_func_replacement_done=1
152 }
153
154 # Now perform the actual completion, allowing the "_git" function to call our
155 # replacement "_git_commands" function as needed. Both versions expect
156 # service=git or they will call nonexistent routines or end up in an infinite
157 # loop.
158 service=git
159 declare -f _git >& /dev/null && _git
160 }
161
162 # make sure we actually attempt to complete on the first "tab" from the user
163 _hub
164
plugins/gulp/gulp.plugin.zsh
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 2
3 # 3 #
4 # gulp-autocompletion-zsh 4 # gulp-autocompletion-zsh
5 # 5 #
6 # Autocompletion for your gulp.js tasks 6 # Autocompletion for your gulp.js tasks
7 # 7 #
8 # Copyright(c) 2014 André König <andre.koenig@posteo.de> 8 # Copyright(c) 2014 André König <andre.koenig@posteo.de>
9 # MIT Licensed 9 # MIT Licensed
10 # 10 #
11 11
12 # 12 #
13 # André König 13 # André König
14 # Github: https://github.com/akoenig 14 # Github: https://github.com/akoenig
15 # Twitter: https://twitter.com/caiifr 15 # Twitter: https://twitter.com/caiifr
16 # 16 #
17 17
18 # 18 #
19 # Grabs all available tasks from the `gulpfile.js` 19 # Grabs all available tasks from the `gulpfile.js`
20 # in the current directory. 20 # in the current directory.
21 # 21 #
22 function $$gulp_completion { 22 function $$gulp_completion {
23 compls="$(grep -Eo "gulp.task\((['\"](([a-zA-Z0-9]|-)*)['\"],)" gulpfile.js 2>/dev/null | grep -Eo "['\"](([a-zA-Z0-9]|-)*)['\"]" | sed s/"['\"]"//g | sort)" 23 compls=$(gulp --tasks-simple 2>/dev/null)
24 24
25 completions=(${=compls}) 25 completions=(${=compls})
26 compadd -- $completions 26 compadd -- $completions
27 } 27 }
28 28
29 compdef $$gulp_completion gulp 29 compdef $$gulp_completion gulp
30 30
plugins/history-substring-search/history-substring-search.plugin.zsh
1 # This file integrates the zsh-history-substring-search script into oh-my-zsh. 1 # This file integrates the zsh-history-substring-search script into oh-my-zsh.
2 2
3 source "${0:r:r}.zsh" 3 source "${0:r:r}.zsh"
4 4
5 if test "$CASE_SENSITIVE" = true; then 5 if test "$CASE_SENSITIVE" = true; then
6 unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS 6 unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS
7 fi 7 fi
8 8
9 if test "$DISABLE_COLOR" = true; then 9 if test "$DISABLE_COLOR" = true; then
10 unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND 10 unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
11 unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND 11 unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
12 fi 12 fi
13 13
14 14
15 # Bind terminal-specific up and down keys 15 # Bind terminal-specific up and down keys
16 16 # Bind in both emacs and vi modes so it works in both, and is not
17 # sensitive to whether this is loaded before or after the vi-mode plugin
17 if [[ -n "$terminfo[kcuu1]" ]]; then 18 if [[ -n "$terminfo[kcuu1]" ]]; then
18 bindkey "$terminfo[kcuu1]" history-substring-search-up 19 bindkey -M emacs "$terminfo[kcuu1]" history-substring-search-up
20 bindkey -M viins "$terminfo[kcuu1]" history-substring-search-up
19 fi 21 fi
20 if [[ -n "$terminfo[kcud1]" ]]; then 22 if [[ -n "$terminfo[kcud1]" ]]; then
21 bindkey "$terminfo[kcud1]" history-substring-search-down 23 bindkey -M emacs "$terminfo[kcud1]" history-substring-search-down
24 bindkey -M viins "$terminfo[kcud1]" history-substring-search-down
22 fi 25 fi
23 26
24 27
plugins/history-substring-search/update-from-upstream.zsh
1 #!/usr/bin/env zsh 1 #!/usr/bin/env zsh
2 # 2 #
3 # update-from-upstream.zsh 3 # update-from-upstream.zsh
4 # 4 #
5 # This script updates the Oh My Zsh version of the zsh-history-substring-search 5 # This script updates the Oh My Zsh version of the zsh-history-substring-search
6 # plugin from the independent upstream repo. This is to be run by OMZ developers 6 # plugin from the independent upstream repo. This is to be run by OMZ developers
7 # when they want to pull in new changes from upstream to OMZ. It is not run 7 # when they want to pull in new changes from upstream to OMZ. It is not run
8 # during normal use of the plugin. 8 # during normal use of the plugin.
9 # 9 #
10 # The official upstream repo is zsh-users/zsh-history-substring-search 10 # The official upstream repo is zsh-users/zsh-history-substring-search
11 # https://github.com/zsh-users/zsh-history-substring-search 11 # https://github.com/zsh-users/zsh-history-substring-search
12 # 12 #
13 # This is a zsh script, not a function. Call it with `zsh update-from-upstream.zsh` 13 # This is a zsh script, not a function. Call it with `zsh update-from-upstream.zsh`
14 # from the command line, running it from within the plugin directory. 14 # from the command line, running it from within the plugin directory.
15 # 15 #
16 # You can set the environment variable REPO_PATH to point it at an upstream 16 # You can set the environment variable REPO_PATH to point it at an upstream
17 # repo you have already prepared. Otherwise, it will do a clean checkout of 17 # repo you have already prepared. Otherwise, it will do a clean checkout of
18 # upstream's HEAD to a temporary local repo and use that. 18 # upstream's HEAD to a temporary local repo and use that.
19 19
20 20
21 # Just bail on any error so we don't have to do extra checking. 21 # Just bail on any error so we don't have to do extra checking.
22 # This is a developer-use script, so terse output like that should 22 # This is a developer-use script, so terse output like that should
23 # be fine. 23 # be fine.
24 set -e 24 set -e
25 25
26 26
27 upstream_basename=zsh-history-substring-search 27 upstream_basename=zsh-history-substring-search
28 plugin_basename=history-substring-search 28 plugin_basename=history-substring-search
29 UPSTREAM_REPO=zsh-users/$upstream_basename 29 UPSTREAM_REPO=zsh-users/$upstream_basename
30 need_repo_cleanup=false 30 need_repo_cleanup=false
31 upstream_github_url="https://github.com/$UPSTREAM_REPO" 31 upstream_github_url="https://github.com/$UPSTREAM_REPO"
32 32
33 if [[ -z "$UPSTREAM_REPO_PATH" ]]; then 33 if [[ -z "$UPSTREAM_REPO_PATH" ]]; then
34 # Do a clean checkout 34 # Do a clean checkout
35 my_tempdir=$(mktemp -d -t omz-update-histsubstrsrch) 35 my_tempdir=$(mktemp -d -t omz-update-histsubstrsrch)
36 UPSTREAM_REPO_PATH="$my_tempdir/$upstream_basename" 36 UPSTREAM_REPO_PATH="$my_tempdir/$upstream_basename"
37 git clone "$upstream_github_url" "$UPSTREAM_REPO_PATH" 37 git clone "$upstream_github_url" "$UPSTREAM_REPO_PATH"
38 need_repo_cleanup=true 38 need_repo_cleanup=true
39 print "Checked out upstream repo to $UPSTREAM_REPO_PATH" 39 print "Checked out upstream repo to $UPSTREAM_REPO_PATH"
40 else 40 else
41 print "Using existing $upstream_basename repo at $UPSTREAM_REPO_PATH" 41 print "Using existing $upstream_basename repo at $UPSTREAM_REPO_PATH"
42 fi 42 fi
43 43
44 upstream="$UPSTREAM_REPO_PATH" 44 upstream="$UPSTREAM_REPO_PATH"
45 45
46 # Figure out what we're pulling in 46 # Figure out what we're pulling in
47 upstream_sha=$(cd $upstream && git rev-parse HEAD) 47 upstream_sha=$(cd $upstream && git rev-parse HEAD)
48 upstream_commit_date=$(cd $upstream && git log -1 --pretty=format:%ci) 48 upstream_commit_date=$(cd $upstream && git log -1 --pretty=format:%ci)
49 upstream_just_date=${${=upstream_commit_date}[1]} 49 upstream_just_date=${${=upstream_commit_date}[1]}
50 print "upstream SHA: $upstream_sha" 50 print "upstream SHA: $upstream_sha"
51 print "upstream commit time: $upstream_commit_date" 51 print "upstream commit time: $upstream_commit_date"
52 print "upstream commit date: $upstream_just_date" 52 print "upstream commit date: $upstream_just_date"
53 print 53 print
54 54
55 # Copy the files over, using the OMZ plugin's names where needed 55 # Copy the files over, using the OMZ plugin's names where needed
56 cp -v "$upstream"/* . 56 cp -v "$upstream"/* .
57 mv -v zsh-history-substring-search.zsh $plugin_basename.zsh 57 mv -v zsh-history-substring-search.zsh $plugin_basename.zsh
58 mv -v zsh-history-substring-search.plugin.zsh $plugin_basename.plugin.zsh 58 mv -v zsh-history-substring-search.plugin.zsh $plugin_basename.plugin.zsh
59 59
60 if [[ $need_repo_cleanup == true ]]; then 60 if [[ $need_repo_cleanup == true ]]; then
61 print "Removing temporary repo at $my_tempdir" 61 print "Removing temporary repo at $my_tempdir"
62 rm -rf "$my_tempdir" 62 rm -rf "$my_tempdir"
63 fi 63 fi
64 64
65 # Do OMZ-specific edits 65 # Do OMZ-specific edits
66 66
67 print 67 print
68 print "Updating files with OMZ-specific stuff" 68 print "Updating files with OMZ-specific stuff"
69 print 69 print
70 70
71 # OMZ binds the keys as part of the plugin loading 71 # OMZ binds the keys as part of the plugin loading
72 72
73 cat >> $plugin_basename.plugin.zsh <<EOF 73 cat >> $plugin_basename.plugin.zsh <<EOF
74 74
75 75
76 # Bind terminal-specific up and down keys 76 # Bind terminal-specific up and down keys
77 77
78 if [[ -n "\$terminfo[kcuu1]" ]]; then 78 if [[ -n "\$terminfo[kcuu1]" ]]; then
79 bindkey "\$terminfo[kcuu1]" history-substring-search-up 79 bindkey -M emacs "\$terminfo[kcuu1]" history-substring-search-up
80 bindkey -M viins "\$terminfo[kcuu1]" history-substring-search-up
80 fi 81 fi
81 if [[ -n "\$terminfo[kcud1]" ]]; then 82 if [[ -n "\$terminfo[kcud1]" ]]; then
82 bindkey "\$terminfo[kcud1]" history-substring-search-down 83 bindkey -M emacs "\$terminfo[kcud1]" history-substring-search-down
84 bindkey -M viins "\$terminfo[kcud1]" history-substring-search-down
83 fi 85 fi
84 86
85 EOF 87 EOF
86 88
87 # Tack OMZ-specific notes on to readme 89 # Tack OMZ-specific notes on to readme
88 90
89 thin_line="------------------------------------------------------------------------------" 91 thin_line="------------------------------------------------------------------------------"
90 cat >> README.md <<EOF 92 cat >> README.md <<EOF
91 93
92 $thin_line 94 $thin_line
93 Oh My Zsh Distribution Notes 95 Oh My Zsh Distribution Notes
94 $thin_line 96 $thin_line
95 97
96 What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search 98 What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search
97 as an OMZ module inside the Oh My Zsh distribution. 99 as an OMZ module inside the Oh My Zsh distribution.
98 100
99 The upstream repo, $UPSTREAM_REPO, can be found on GitHub at 101 The upstream repo, $UPSTREAM_REPO, can be found on GitHub at
100 $upstream_github_url. 102 $upstream_github_url.
101 103
102 This downstream copy was last updated from the following upstream commit: 104 This downstream copy was last updated from the following upstream commit:
103 105
104 SHA: $upstream_sha 106 SHA: $upstream_sha
105 Commit date: $upstream_commit_date 107 Commit date: $upstream_commit_date
106 108
107 Everything above this section is a copy of the original upstream's README, so things 109 Everything above this section is a copy of the original upstream's README, so things
108 may differ slightly when you're using this inside OMZ. In particular, you do not 110 may differ slightly when you're using this inside OMZ. In particular, you do not
109 need to set up key bindings for the up and down arrows yourself in \`~/.zshrc\`; the OMZ 111 need to set up key bindings for the up and down arrows yourself in \`~/.zshrc\`; the OMZ
110 plugin does that for you. You may still want to set up additional emacs- or vi-specific 112 plugin does that for you. You may still want to set up additional emacs- or vi-specific
111 bindings as mentioned above. 113 bindings as mentioned above.
112 114
113 EOF 115 EOF
114 116
115 # Announce success and generate git commit messages 117 # Announce success and generate git commit messages
116 118
117 cat <<EOF 119 cat <<EOF
118 Done OK 120 Done OK
119 121
120 Now you can check the results and commit like this: 122 Now you can check the results and commit like this:
121 123
122 git add * 124 git add *
123 git commit -m "history-substring-search: update to upstream version $upstream_just_date" \\ 125 git commit -m "history-substring-search: update to upstream version $upstream_just_date" \\
124 -m "Updates OMZ's copy to commit $upstream_sha from $UPSTREAM_REPO" 126 -m "Updates OMZ's copy to commit $upstream_sha from $UPSTREAM_REPO"
125 127
126 EOF 128 EOF
127 129
128 130
plugins/mercurial/mercurial.plugin.zsh
1 # Mercurial 1 # Mercurial
2 alias hgc='hg commit' 2 alias hgc='hg commit'
3 alias hgb='hg branch' 3 alias hgb='hg branch'
4 alias hgba='hg branches' 4 alias hgba='hg branches'
5 alias hgbk='hg bookmarks' 5 alias hgbk='hg bookmarks'
6 alias hgco='hg checkout' 6 alias hgco='hg checkout'
7 alias hgd='hg diff' 7 alias hgd='hg diff'
8 alias hged='hg diffmerge' 8 alias hged='hg diffmerge'
9 # pull and update 9 # pull and update
10 alias hgi='hg incoming' 10 alias hgi='hg incoming'
11 alias hgl='hg pull -u' 11 alias hgl='hg pull -u'
12 alias hglr='hg pull --rebase' 12 alias hglr='hg pull --rebase'
13 alias hgo='hg outgoing' 13 alias hgo='hg outgoing'
14 alias hgp='hg push' 14 alias hgp='hg push'
15 alias hgs='hg status' 15 alias hgs='hg status'
16 alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" ' 16 alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" '
17 # this is the 'git commit --amend' equivalent 17 alias hgca='hg commit --amend'
18 alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'
19 # list unresolved files (since hg does not list unmerged files in the status command) 18 # list unresolved files (since hg does not list unmerged files in the status command)
20 alias hgun='hg resolve --list' 19 alias hgun='hg resolve --list'
21 20
22 function in_hg() { 21 function in_hg() {
23 if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then 22 if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then
24 echo 1 23 echo 1
25 fi 24 fi
26 } 25 }
27 26
28 function hg_get_branch_name() { 27 function hg_get_branch_name() {
29 if [ $(in_hg) ]; then 28 if [ $(in_hg) ]; then
30 echo $(hg branch) 29 echo $(hg branch)
31 fi 30 fi
32 } 31 }
33 32
34 function hg_prompt_info { 33 function hg_prompt_info {
35 if [ $(in_hg) ]; then 34 if [ $(in_hg) ]; then
36 _DISPLAY=$(hg_get_branch_name) 35 _DISPLAY=$(hg_get_branch_name)
37 echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\ 36 echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
38 $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR" 37 $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR"
39 unset _DISPLAY 38 unset _DISPLAY
40 fi 39 fi
41 } 40 }
42 41
43 function hg_dirty_choose { 42 function hg_dirty_choose {
44 if [ $(in_hg) ]; then 43 if [ $(in_hg) ]; then
45 hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]' 44 hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
46 if [ $pipestatus[-1] -eq 0 ]; then 45 if [ $pipestatus[-1] -eq 0 ]; then
47 # Grep exits with 0 when "One or more lines were selected", return "dirty". 46 # Grep exits with 0 when "One or more lines were selected", return "dirty".
48 echo $1 47 echo $1
49 else 48 else
50 # Otherwise, no lines were found, or an error occurred. Return clean. 49 # Otherwise, no lines were found, or an error occurred. Return clean.
51 echo $2 50 echo $2
52 fi 51 fi
53 fi 52 fi
54 } 53 }
55 54
56 function hg_dirty { 55 function hg_dirty {
57 hg_dirty_choose $ZSH_THEME_HG_PROMPT_DIRTY $ZSH_THEME_HG_PROMPT_CLEAN 56 hg_dirty_choose $ZSH_THEME_HG_PROMPT_DIRTY $ZSH_THEME_HG_PROMPT_CLEAN
58 } 57 }
59 58
60 function hgic() { 59 function hgic() {
61 hg incoming "$@" | grep "changeset" | wc -l 60 hg incoming "$@" | grep "changeset" | wc -l
62 } 61 }
63 62
64 function hgoc() { 63 function hgoc() {
65 hg outgoing "$@" | grep "changeset" | wc -l 64 hg outgoing "$@" | grep "changeset" | wc -l
66 } 65 }
67 66
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 alias rsp='rails server --port' 45 alias rsp='rails server --port'
46 46
47 # Rake aliases 47 # Rake aliases
48 alias rdm='rake db:migrate' 48 alias rdm='rake db:migrate'
49 alias rdms='rake db:migrate:status' 49 alias rdms='rake db:migrate:status'
50 alias rdr='rake db:rollback' 50 alias rdr='rake db:rollback'
51 alias rdc='rake db:create' 51 alias rdc='rake db:create'
52 alias rds='rake db:seed' 52 alias rds='rake db:seed'
53 alias rdd='rake db:drop' 53 alias rdd='rake db:drop'
54 alias rdrs='rake db:reset' 54 alias rdrs='rake db:reset'
55 alias rdtc='rake db:test:clone' 55 alias rdtc='rake db:test:clone'
56 alias rdtp='rake db:test:prepare' 56 alias rdtp='rake db:test:prepare'
57 alias rdmtc='rake db:migrate db:test:clone' 57 alias rdmtc='rake db:migrate db:test:clone'
58 alias rlc='rake log:clear' 58 alias rlc='rake log:clear'
59 alias rn='rake notes' 59 alias rn='rake notes'
60 alias rr='rake routes' 60 alias rr='rake routes'
61 alias rrg='rake routes | grep' 61 alias rrg='rake routes | grep'
62 alias rt='rake test' 62 alias rt='rake test'
63 alias rmd='rake middleware' 63 alias rmd='rake middleware'
64 alias rsts='rake stats'
64 65
65 # legacy stuff 66 # legacy stuff
66 alias sstat='thin --stats "/thin/stats" start' 67 alias sstat='thin --stats "/thin/stats" start'
67 alias sg='ruby script/generate' 68 alias sg='ruby script/generate'
68 alias sd='ruby script/destroy' 69 alias sd='ruby script/destroy'
69 alias sp='ruby script/plugin' 70 alias sp='ruby script/plugin'
70 alias sr='ruby script/runner' 71 alias sr='ruby script/runner'
71 alias ssp='ruby script/spec' 72 alias ssp='ruby script/spec'
72 alias sc='ruby script/console' 73 alias sc='ruby script/console'
73 alias sd='ruby script/server --debugger' 74 alias sd='ruby script/server --debugger'
74 75
75 function remote_console() { 76 function remote_console() {
76 /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )" 77 /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
77 } 78 }
78 79
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 github "https://github.com/search?q="
15 baidu "https://www.baidu.com/s?wd=" 15 baidu "https://www.baidu.com/s?wd="
16 ecosia "https://www.ecosia.org/search?q="
16 ) 17 )
17 18
18 # check whether the search engine is supported 19 # check whether the search engine is supported
19 if [[ -z "$urls[$1]" ]]; then 20 if [[ -z "$urls[$1]" ]]; then
20 echo "Search engine $1 not supported." 21 echo "Search engine $1 not supported."
21 return 1 22 return 1
22 fi 23 fi
23 24
24 # search or go to main page depending on number of arguments passed 25 # search or go to main page depending on number of arguments passed
25 if [[ $# -gt 1 ]]; then 26 if [[ $# -gt 1 ]]; then
26 # build search url: 27 # build search url:
27 # join arguments passed with '+', then append to search engine URL 28 # join arguments passed with '+', then append to search engine URL
28 url="${urls[$1]}${(j:+:)@[2,-1]}" 29 url="${urls[$1]}${(j:+:)@[2,-1]}"
29 else 30 else
30 # build main page url: 31 # build main page url:
31 # split by '/', then rejoin protocol (1) and domain (2) parts with '//' 32 # split by '/', then rejoin protocol (1) and domain (2) parts with '//'
32 url="${(j://:)${(s:/:)urls[$1]}[1,2]}" 33 url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
33 fi 34 fi
34 35
35 open_command "$url" 36 open_command "$url"
36 } 37 }
37 38
38 39
39 alias bing='web_search bing' 40 alias bing='web_search bing'
40 alias google='web_search google' 41 alias google='web_search google'
41 alias yahoo='web_search yahoo' 42 alias yahoo='web_search yahoo'
42 alias ddg='web_search duckduckgo' 43 alias ddg='web_search duckduckgo'
43 alias yandex='web_search yandex' 44 alias yandex='web_search yandex'
44 alias github='web_search github' 45 alias github='web_search github'
45 alias baidu='web_search baidu' 46 alias baidu='web_search baidu'
47 alias ecosia='web_search ecosia'
46 48
47 #add your own !bang searches here 49 #add your own !bang searches here
48 alias wiki='web_search duckduckgo \!w' 50 alias wiki='web_search duckduckgo \!w'
49 alias news='web_search duckduckgo \!n' 51 alias news='web_search duckduckgo \!n'
50 alias youtube='web_search duckduckgo \!yt' 52 alias youtube='web_search duckduckgo \!yt'
51 alias map='web_search duckduckgo \!m' 53 alias map='web_search duckduckgo \!m'
52 alias image='web_search duckduckgo \!i' 54 alias image='web_search duckduckgo \!i'
53 alias ducky='web_search duckduckgo \!' 55 alias ducky='web_search duckduckgo \!'
54 56
plugins/zsh-navigation-tools/README.md
1 # Zsh Navigation Tools 1 # Zsh Navigation Tools
2 2
3 http://imageshack.com/a/img633/7967/ps6rKR.png 3 http://imageshack.com/a/img633/7967/ps6rKR.png
4 4
5 Set of tools like n-history – multi-word history searcher, n-cd – directory 5 Set of tools like n-history – multi-word history searcher, n-cd – directory
6 bookmark manager, n-kill – htop like kill utility, and more. Based on 6 bookmark manager, n-kill – htop like kill utility, and more. Based on
7 n-list, a tool generating selectable curses-based list of elements that has 7 n-list, a tool generating selectable curses-based list of elements that has
8 access to current Zsh session, i.e. has broad capabilities to work together 8 access to current Zsh session, i.e. has broad capabilities to work together
9 with it. Feature highlights include incremental multi-word searching, ANSI 9 with it. Feature highlights include incremental multi-word searching, ANSI
10 coloring, unique mode, horizontal scroll, non-selectable elements, grepping and 10 coloring, unique mode, horizontal scroll, non-selectable elements, grepping and
11 various integrations with Zsh. 11 various integrations with Zsh.
12 12
13 ## History Widget 13 ## History Widget
14 14
15 To have n-history as multi-word incremental searcher bound to Ctrl-R copy znt-* 15 To have n-history as multi-word incremental searcher bound to Ctrl-R copy znt-*
16 files into the */site-functions dir (unless you use Oh My Zsh) and 16 files into the */site-functions dir (unless you use Oh My Zsh) and
17 add: 17 add:
18 18
19 autoload znt-history-widget 19 autoload znt-history-widget
20 zle -N znt-history-widget 20 zle -N znt-history-widget
21 bindkey "^R" znt-history-widget 21 bindkey "^R" znt-history-widget
22 22
23 to .zshrc. This is done automatically when using Oh My Zsh. Two other 23 to .zshrc. This is done automatically when using Oh My Zsh. Two other
24 widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned 24 widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned
25 to key combinations (no need for autoload when using Oh My Zsh): 25 to key combinations (no need for autoload when using Oh My Zsh):
26 26
27 zle -N znt-cd-widget 27 zle -N znt-cd-widget
28 bindkey "^T" znt-cd-widget 28 bindkey "^T" znt-cd-widget
29 zle -N znt-kill-widget 29 zle -N znt-kill-widget
30 bindkey "^Y" znt-kill-widget 30 bindkey "^Y" znt-kill-widget
31 31
32 Oh My Zsh stores history into ~/.zsh_history. When you switch to OMZ you could 32 Oh My Zsh stores history into ~/.zsh_history. When you switch to OMZ you could
33 want to copy your previous data (from e.g. ~/.zhistory) into the new location. 33 want to copy your previous data (from e.g. ~/.zhistory) into the new location.
34 34
35 ## Introduction 35 ## Introduction
36 36
37 The tools are: 37 The tools are:
38 38
39 - n-aliases - browses aliases, relegates editing to vared 39 - n-aliases - browses aliases, relegates editing to vared
40 - n-cd - browses dirstack and bookmarked directories, allows to enter selected directory 40 - n-cd - browses dirstack and bookmarked directories, allows to enter selected directory
41 - n-functions - browses functions, relegates editing to zed or vared 41 - n-functions - browses functions, relegates editing to zed or vared
42 - n-history - browses history, allows to edit and run commands from it 42 - n-history - browses history, allows to edit and run commands from it
43 - n-kill - browses processes list, allows to send signal to selected process 43 - n-kill - browses processes list, allows to send signal to selected process
44 - n-env - browses environment, relegates editing to vared 44 - n-env - browses environment, relegates editing to vared
45 - n-options - browses options, allows to toggle their state 45 - n-options - browses options, allows to toggle their state
46 - n-panelize - loads output of given command into the list for browsing 46 - n-panelize - loads output of given command into the list for browsing
47 47
48 All tools support horizontal scroll with <,>, {,}, h,l or left and right 48 All tools support horizontal scroll with <,>, {,}, h,l or left and right
49 cursors. Other keys are: 49 cursors. Other keys are:
50 50
51 - [,] - jump directory bookmarks in n-cd and typical signals in n-kill 51 - [,] - jump directory bookmarks in n-cd and typical signals in n-kill
52 - Ctrl-d, Ctrl-u - half page up or down 52 - Ctrl-d, Ctrl-u - half page up or down
53 - Ctrl-p, Ctrl-n - previous and next (also done with vim's j,k) 53 - Ctrl-p, Ctrl-n - previous and next (also done with vim's j,k)
54 - Ctrl-l - redraw of whole display 54 - Ctrl-l - redraw of whole display
55 - g, G - beginning and end of the list 55 - g, G - beginning and end of the list
56 - Ctrl-o, o - enter uniq mode (no duplicate lines) 56 - Ctrl-o, o - enter uniq mode (no duplicate lines)
57 - / - start incremental search 57 - / - start incremental search
58 - Enter - finish incremental search, retaining filter 58 - Enter - finish incremental search, retaining filter
59 - Esc - exit incremental search, clearing filter 59 - Esc - exit incremental search, clearing filter
60 - Ctrl-w (in incremental search) - delete whole word 60 - Ctrl-w (in incremental search) - delete whole word
61 - Ctrl-k (in incremental search) - delete whole line 61 - Ctrl-k (in incremental search) - delete whole line
62 62
63 ## Programming 63 ## Programming
64 64
65 The function n-list is used as follows: 65 The function n-list is used as follows:
66 66
67 n-list {element1} [element2] ... [elementN] 67 n-list {element1} [element2] ... [elementN]
68 68
69 This is all that is needed to be done to have the features like ANSI coloring, 69 This is all that is needed to be done to have the features like ANSI coloring,
70 incremental multi-word search, unique mode, horizontal scroll, non-selectable 70 incremental multi-word search, unique mode, horizontal scroll, non-selectable
71 elements (grepping is done outside n-list, see the tools for how it can be 71 elements (grepping is done outside n-list, see the tools for how it can be
72 done). To set up non-selectable entries add their indices into array 72 done). To set up non-selectable entries add their indices into array
73 NLIST_NONSELECTABLE_ELEMENTS: 73 NLIST_NONSELECTABLE_ELEMENTS:
74 74
75 typeset -a NLIST_NONSELECTABLE_ELEMENTS 75 typeset -a NLIST_NONSELECTABLE_ELEMENTS
76 NLIST_NONSELECTABLE_ELEMENTS=( 1 ) 76 NLIST_NONSELECTABLE_ELEMENTS=( 1 )
77 77
78 Result is stored as $reply[REPLY] ($ isn't needed before REPLY because 78 Result is stored as $reply[REPLY] ($ isn't needed before REPLY because
79 of arithmetic context inside []). The returned array might be different from 79 of arithmetic context inside []). The returned array might be different from
80 input arguments as n-list can process them via incremental search or uniq 80 input arguments as n-list can process them via incremental search or uniq
81 mode. $REPLY is the index in that possibly processed array. If $REPLY 81 mode. $REPLY is the index in that possibly processed array. If $REPLY
82 equals -1 it means that no selection have been made (user quitted via q 82 equals -1 it means that no selection have been made (user quitted via q
83 key). 83 key).
84 84
85 To set up entries that can be jumped to with [,] keys add their indices to 85 To set up entries that can be jumped to with [,] keys add their indices to
86 NLIST_HOP_INDEXES array: 86 NLIST_HOP_INDEXES array:
87 87
88 typeset -a NLIST_HOP_INDEXES 88 typeset -a NLIST_HOP_INDEXES
89 NLIST_HOP_INDEXES=( 1 10 ) 89 NLIST_HOP_INDEXES=( 1 10 )
90 90
91 n-list can automatically colorize entries according to a Zsh pattern. 91 n-list can automatically colorize entries according to a Zsh pattern.
92 Following example will colorize all numbers with blue: 92 Following example will colorize all numbers with blue:
93 93
94 local NLIST_COLORING_PATTERN="[0-9]##" 94 local NLIST_COLORING_PATTERN="[0-9]##"
95 local NLIST_COLORING_COLOR=$'\x1b[00;34m' 95 local NLIST_COLORING_COLOR=$'\x1b[00;34m'
96 local NLIST_COLORING_END_COLOR=$'\x1b[0m' 96 local NLIST_COLORING_END_COLOR=$'\x1b[0m'
97 local NLIST_COLORING_MATCH_MULTIPLE=1 97 local NLIST_COLORING_MATCH_MULTIPLE=1
98 n-list "This is a number 123" "This line too has a number: 456" 98 n-list "This is a number 123" "This line too has a number: 456"
99 99
100 Blue is the default color, it doesn't have to be set. See zshexpn man page 100 Blue is the default color, it doesn't have to be set. See zshexpn man page
101 for more information on Zsh patterns. Briefly, comparing to regular 101 for more information on Zsh patterns. Briefly, comparing to regular
102 expressions, (#s) is ^, (#e) is $, # is *, ## is +. Alternative 102 expressions, (#s) is ^, (#e) is $, # is *, ## is +. Alternative
103 will work when in parenthesis, i.e. (a|b). BTW by using this method you can 103 will work when in parenthesis, i.e. (a|b). BTW by using this method you can
104 colorize output of the tools, via their config files (check out e.g. n-cd.conf, 104 colorize output of the tools, via their config files (check out e.g. n-cd.conf,
105 it uses this). 105 it uses this).
106 106
107 ## Performance 107 ## Performance
108 ZNT are fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to 108 ZNT are fastest with Zsh before 5.0.6 and starting from 5.2
109 be released).
110 109
111 110
112 vim:filetype=conf 111 vim:filetype=conf
113 112
plugins/zsh-navigation-tools/n-list
1 # $1, $2, ... - elements of the list 1 # $1, $2, ... - elements of the list
2 # $NLIST_NONSELECTABLE_ELEMENTS - array of indexes (1-based) that cannot be selected 2 # $NLIST_NONSELECTABLE_ELEMENTS - array of indexes (1-based) that cannot be selected
3 # $REPLY is the output variable - contains index (1-based) or -1 when no selection 3 # $REPLY is the output variable - contains index (1-based) or -1 when no selection
4 # 4 #
5 # Copy this file into /usr/share/zsh/site-functions/ 5 # Copy this file into /usr/share/zsh/site-functions/
6 # and add 'autoload n-list` to .zshrc 6 # and add 'autoload n-list` to .zshrc
7 # 7 #
8 # This function outputs a list of elements that can be 8 # This function outputs a list of elements that can be
9 # navigated with keyboard. Uses curses library 9 # navigated with keyboard. Uses curses library
10 10
11 emulate -LR zsh 11 emulate -LR zsh
12 12
13 setopt typesetsilent extendedglob noshortloops 13 setopt typesetsilent extendedglob noshortloops
14 14
15 _nlist_has_terminfo=0 15 _nlist_has_terminfo=0
16 16
17 zmodload zsh/curses 17 zmodload zsh/curses
18 zmodload zsh/terminfo 2>/dev/null && _nlist_has_terminfo=1 18 zmodload zsh/terminfo 2>/dev/null && _nlist_has_terminfo=1
19 19
20 trap "REPLY=-2; reply=(); return" TERM INT QUIT 20 trap "REPLY=-2; reply=(); return" TERM INT QUIT
21 trap "_nlist_exit" EXIT 21 trap "_nlist_exit" EXIT
22 22
23 # Drawing and input 23 # Drawing and input
24 autoload n-list-draw n-list-input 24 autoload n-list-draw n-list-input
25 25
26 # Cleanup before any exit 26 # Cleanup before any exit
27 _nlist_exit() { 27 _nlist_exit() {
28 setopt localoptions 28 setopt localoptions
29 setopt extendedglob 29 setopt extendedglob
30 30
31 [[ "$REPLY" = -(#c0,1)[0-9]## ]] || REPLY="-1" 31 [[ "$REPLY" = -(#c0,1)[0-9]## ]] || REPLY="-1"
32 zcurses 2>/dev/null delwin inner 32 zcurses 2>/dev/null delwin inner
33 zcurses 2>/dev/null delwin main 33 zcurses 2>/dev/null delwin main
34 zcurses 2>/dev/null refresh 34 zcurses 2>/dev/null refresh
35 zcurses end 35 zcurses end
36 _nlist_alternate_screen 0 36 _nlist_alternate_screen 0
37 _nlist_cursor_visibility 1 37 _nlist_cursor_visibility 1
38 unset _nlist_has_terminfo 38 unset _nlist_has_terminfo
39 } 39 }
40 40
41 # Outputs a message in the bottom of the screen 41 # Outputs a message in the bottom of the screen
42 _nlist_status_msg() { 42 _nlist_status_msg() {
43 # -1 for border, -1 for 0-based indexing 43 # -1 for border, -1 for 0-based indexing
44 zcurses move main $(( term_height - 1 - 1 )) 2 44 zcurses move main $(( term_height - 1 - 1 )) 2
45 zcurses clear main eol 45 zcurses clear main eol
46 zcurses string main "$1" 46 zcurses string main "$1"
47 #status_msg_strlen is localized in caller 47 #status_msg_strlen is localized in caller
48 status_msg_strlen=$#1 48 status_msg_strlen=$#1
49 } 49 }
50 50
51 # Prefer tput, then module terminfo 51 # Prefer tput, then module terminfo
52 _nlist_cursor_visibility() { 52 _nlist_cursor_visibility() {
53 if type tput 2>/dev/null 1>&2; then 53 if type tput 2>/dev/null 1>&2; then
54 [ "$1" = "1" ] && { tput cvvis; tput cnorm } 54 [ "$1" = "1" ] && { tput cvvis; tput cnorm }
55 [ "$1" = "0" ] && tput civis 55 [ "$1" = "0" ] && tput civis
56 elif [ "$_nlist_has_terminfo" = "1" ]; then 56 elif [ "$_nlist_has_terminfo" = "1" ]; then
57 [ "$1" = "1" ] && { [ -n $terminfo[cvvis] ] && echo -n $terminfo[cvvis]; 57 [ "$1" = "1" ] && { [ -n $terminfo[cvvis] ] && echo -n $terminfo[cvvis];
58 [ -n $terminfo[cnorm] ] && echo -n $terminfo[cnorm] } 58 [ -n $terminfo[cnorm] ] && echo -n $terminfo[cnorm] }
59 [ "$1" = "0" ] && [ -n $terminfo[civis] ] && echo -n $terminfo[civis] 59 [ "$1" = "0" ] && [ -n $terminfo[civis] ] && echo -n $terminfo[civis]
60 fi 60 fi
61 } 61 }
62 62
63 # Reason for this function is that on some systems 63 # Reason for this function is that on some systems
64 # smcup and rmcup are not knowing why left empty 64 # smcup and rmcup are not knowing why left empty
65 _nlist_alternate_screen() { 65 _nlist_alternate_screen() {
66 [ "$_nlist_has_terminfo" -ne "1" ] && return 66 [ "$_nlist_has_terminfo" -ne "1" ] && return
67 [[ "$1" = "1" && -n "$terminfo[smcup]" ]] && return 67 [[ "$1" = "1" && -n "$terminfo[smcup]" ]] && return
68 [[ "$1" = "0" && -n "$terminfo[rmcup]" ]] && return 68 [[ "$1" = "0" && -n "$terminfo[rmcup]" ]] && return
69 69
70 case "$TERM" in 70 case "$TERM" in
71 *rxvt*) 71 *rxvt*)
72 [ "$1" = "1" ] && echo -n $'\x1b7\x1b[?47h' 72 [ "$1" = "1" ] && echo -n $'\x1b7\x1b[?47h'
73 [ "$1" = "0" ] && echo -n $'\x1b[2J\x1b[?47l\x1b8' 73 [ "$1" = "0" ] && echo -n $'\x1b[2J\x1b[?47l\x1b8'
74 ;; 74 ;;
75 *) 75 *)
76 [ "$1" = "1" ] && echo -n $'\x1b[?1049h' 76 [ "$1" = "1" ] && echo -n $'\x1b[?1049h'
77 [ "$1" = "0" ] && echo -n $'\x1b[?1049l' 77 [ "$1" = "0" ] && echo -n $'\x1b[?1049l'
78 # just to remember two other that work: $'\x1b7\x1b[r\x1b[?47h', $'\x1b[?47l\x1b8' 78 # just to remember two other that work: $'\x1b7\x1b[r\x1b[?47h', $'\x1b[?47l\x1b8'
79 ;; 79 ;;
80 esac 80 esac
81 } 81 }
82 82
83 _nlist_compute_user_vars_difference() { 83 _nlist_compute_user_vars_difference() {
84 if [[ "${(t)NLIST_NONSELECTABLE_ELEMENTS}" != "array" && 84 if [[ "${(t)NLIST_NONSELECTABLE_ELEMENTS}" != "array" &&
85 "${(t)NLIST_NONSELECTABLE_ELEMENTS}" != "array-local" ]] 85 "${(t)NLIST_NONSELECTABLE_ELEMENTS}" != "array-local" ]]
86 then 86 then
87 last_element_difference=0 87 last_element_difference=0
88 current_difference=0 88 current_difference=0
89 else 89 else
90 last_element_difference=$#NLIST_NONSELECTABLE_ELEMENTS 90 last_element_difference=$#NLIST_NONSELECTABLE_ELEMENTS
91 current_difference=0 91 current_difference=0
92 local idx 92 local idx
93 for idx in "${(n)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do 93 for idx in "${(n)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
94 [ "$idx" -le "$NLIST_CURRENT_IDX" ] && current_difference+=1 || break 94 [ "$idx" -le "$NLIST_CURRENT_IDX" ] && current_difference+=1 || break
95 done 95 done
96 fi 96 fi
97 } 97 }
98 98
99 # List was processed, check if variables aren't off range 99 # List was processed, check if variables aren't off range
100 _nlist_verify_vars() { 100 _nlist_verify_vars() {
101 [ "$NLIST_CURRENT_IDX" -gt "$last_element" ] && NLIST_CURRENT_IDX="$last_element" 101 [ "$NLIST_CURRENT_IDX" -gt "$last_element" ] && NLIST_CURRENT_IDX="$last_element"
102 [[ "$NLIST_CURRENT_IDX" -eq 0 && "$last_element" -ne 0 ]] && NLIST_CURRENT_IDX=1 102 [[ "$NLIST_CURRENT_IDX" -eq 0 && "$last_element" -ne 0 ]] && NLIST_CURRENT_IDX=1
103 (( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=0+((NLIST_CURRENT_IDX-1)/page_height)*page_height+1 )) 103 (( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=0+((NLIST_CURRENT_IDX-1)/page_height)*page_height+1 ))
104 } 104 }
105 105
106 # Compute the variables which are shown to the user 106 # Compute the variables which are shown to the user
107 _nlist_setup_user_vars() { 107 _nlist_setup_user_vars() {
108 if [ "$1" = "1" ]; then 108 if [ "$1" = "1" ]; then
109 # Basic values when there are no non-selectables 109 # Basic values when there are no non-selectables
110 NLIST_USER_CURRENT_IDX="$NLIST_CURRENT_IDX" 110 NLIST_USER_CURRENT_IDX="$NLIST_CURRENT_IDX"
111 NLIST_USER_LAST_ELEMENT="$last_element" 111 NLIST_USER_LAST_ELEMENT="$last_element"
112 else 112 else
113 _nlist_compute_user_vars_difference 113 _nlist_compute_user_vars_difference
114 NLIST_USER_CURRENT_IDX=$(( NLIST_CURRENT_IDX - current_difference )) 114 NLIST_USER_CURRENT_IDX=$(( NLIST_CURRENT_IDX - current_difference ))
115 NLIST_USER_LAST_ELEMENT=$(( last_element - last_element_difference )) 115 NLIST_USER_LAST_ELEMENT=$(( last_element - last_element_difference ))
116 fi 116 fi
117 } 117 }
118 118
119 _nlist_coloring_list_into_col_list() { 119 _nlist_colorify_disp_list() {
120 local col=$'\x1b[00;34m' reset=$'\x1b[0m' 120 local col=$'\x1b[00;34m' reset=$'\x1b[0m'
121 [ -n "$NLIST_COLORING_COLOR" ] && col="$NLIST_COLORING_COLOR" 121 [ -n "$NLIST_COLORING_COLOR" ] && col="$NLIST_COLORING_COLOR"
122 [ -n "$NLIST_COLORING_END_COLOR" ] && reset="$NLIST_COLORING_END_COLOR" 122 [ -n "$NLIST_COLORING_END_COLOR" ] && reset="$NLIST_COLORING_END_COLOR"
123 123
124 if [ "$NLIST_COLORING_MATCH_MULTIPLE" -eq 1 ]; then 124 if [ "$NLIST_COLORING_MATCH_MULTIPLE" -eq 1 ]; then
125 col_list=( "${(@)list//(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" ) 125 disp_list=( "${(@)disp_list//(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" )
126 else 126 else
127 col_list=( "${(@)list/(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" ) 127 disp_list=( "${(@)disp_list/(#mi)$~NLIST_COLORING_PATTERN/$col${MATCH}$reset}" )
128 fi 128 fi
129 } 129 }
130 130
131 # 131 #
132 # Main code 132 # Main code
133 # 133 #
134 134
135 # Check if there is proper input 135 # Check if there is proper input
136 if [ "$#" -lt 1 ]; then 136 if [ "$#" -lt 1 ]; then
137 echo "Usage: n-list element_1 ..." 137 echo "Usage: n-list element_1 ..."
138 return 1 138 return 1
139 fi 139 fi
140 140
141 REPLY="-1" 141 REPLY="-1"
142 typeset -ga reply 142 typeset -ga reply
143 reply=() 143 reply=()
144 144
145 integer term_height="$LINES" 145 integer term_height="$LINES"
146 integer term_width="$COLUMNS" 146 integer term_width="$COLUMNS"
147 if [[ "$term_height" -lt 1 || "$term_width" -lt 1 ]]; then 147 if [[ "$term_height" -lt 1 || "$term_width" -lt 1 ]]; then
148 local stty_out=$( stty size ) 148 local stty_out=$( stty size )
149 term_height="${stty_out% *}" 149 term_height="${stty_out% *}"
150 term_width="${stty_out#* }" 150 term_width="${stty_out#* }"
151 fi 151 fi
152 integer inner_height=term_height-3 152 integer inner_height=term_height-3
153 integer inner_width=term_width-3 153 integer inner_width=term_width-3
154 integer page_height=inner_height 154 integer page_height=inner_height
155 integer page_width=inner_width 155 integer page_width=inner_width
156 156
157 typeset -a list col_list disp_list 157 typeset -a list disp_list
158 integer last_element=$# 158 integer last_element=$#
159 local action 159 local action
160 local final_key 160 local final_key
161 integer selection 161 integer selection
162 integer last_element_difference=0 162 integer last_element_difference=0
163 integer current_difference=0 163 integer current_difference=0
164 local prev_search_buffer="" 164 local prev_search_buffer=""
165 integer prev_uniq_mode=0 165 integer prev_uniq_mode=0
166 integer prev_start_idx=-1 166 integer prev_start_idx=-1
167 167
168 # Ability to remember the list between calls 168 # Ability to remember the list between calls
169 if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then 169 if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then
170 NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=1 170 NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=1
171 NLIST_CURRENT_IDX=1 171 NLIST_CURRENT_IDX=1
172 NLIST_IS_SEARCH_MODE=0 172 NLIST_IS_SEARCH_MODE=0
173 NLIST_SEARCH_BUFFER="" 173 NLIST_SEARCH_BUFFER=""
174 NLIST_TEXT_OFFSET=0 174 NLIST_TEXT_OFFSET=0
175 NLIST_IS_UNIQ_MODE=0 175 NLIST_IS_UNIQ_MODE=0
176 176
177 # Zero - because it isn't known, unless we 177 # Zero - because it isn't known, unless we
178 # confirm that first element is selectable 178 # confirm that first element is selectable
179 NLIST_USER_CURRENT_IDX=0 179 NLIST_USER_CURRENT_IDX=0
180 [[ ${NLIST_NONSELECTABLE_ELEMENTS[(r)1]} != 1 ]] && NLIST_USER_CURRENT_IDX=1 180 [[ ${NLIST_NONSELECTABLE_ELEMENTS[(r)1]} != 1 ]] && NLIST_USER_CURRENT_IDX=1
181 NLIST_USER_LAST_ELEMENT=$(( last_element - $#NLIST_NONSELECTABLE_ELEMENTS )) 181 NLIST_USER_LAST_ELEMENT=$(( last_element - $#NLIST_NONSELECTABLE_ELEMENTS ))
182 182
183 # 2 is init once, then remember 183 # 2 is init once, then remember
184 [ "$NLIST_REMEMBER_STATE" -eq 2 ] && NLIST_REMEMBER_STATE=1 184 [ "$NLIST_REMEMBER_STATE" -eq 2 ] && NLIST_REMEMBER_STATE=1
185 fi 185 fi
186 186
187 if [ "$NLIST_START_IN_SEARCH_MODE" -eq 1 ]; then 187 if [ "$NLIST_START_IN_SEARCH_MODE" -eq 1 ]; then
188 NLIST_START_IN_SEARCH_MODE=0 188 NLIST_START_IN_SEARCH_MODE=0
189 NLIST_IS_SEARCH_MODE=1 189 NLIST_IS_SEARCH_MODE=1
190 fi 190 fi
191 191
192 if [ -n "$NLIST_SET_SEARCH_TO" ]; then 192 if [ -n "$NLIST_SET_SEARCH_TO" ]; then
193 NLIST_SEARCH_BUFFER="$NLIST_SET_SEARCH_TO" 193 NLIST_SEARCH_BUFFER="$NLIST_SET_SEARCH_TO"
194 NLIST_SET_SEARCH_TO="" 194 NLIST_SET_SEARCH_TO=""
195 fi 195 fi
196 196
197 if [ "$NLIST_START_IN_UNIQ_MODE" -eq 1 ]; then 197 if [ "$NLIST_START_IN_UNIQ_MODE" -eq 1 ]; then
198 NLIST_START_IN_UNIQ_MODE=0 198 NLIST_START_IN_UNIQ_MODE=0
199 NLIST_IS_UNIQ_MODE=1 199 NLIST_IS_UNIQ_MODE=1
200 fi 200 fi
201 201
202 _nlist_alternate_screen 1 202 _nlist_alternate_screen 1
203 zcurses init 203 zcurses init
204 zcurses delwin main 2>/dev/null 204 zcurses delwin main 2>/dev/null
205 zcurses delwin inner 2>/dev/null 205 zcurses delwin inner 2>/dev/null
206 zcurses addwin main "$term_height" "$term_width" 0 0 206 zcurses addwin main "$term_height" "$term_width" 0 0
207 zcurses addwin inner "$inner_height" "$inner_width" 1 2 207 zcurses addwin inner "$inner_height" "$inner_width" 1 2
208 zcurses bg main white/black 208 zcurses bg main white/black
209 zcurses bg inner white/black 209 zcurses bg inner white/black
210 if [ "$NLIST_IS_SEARCH_MODE" -ne 1 ]; then 210 if [ "$NLIST_IS_SEARCH_MODE" -ne 1 ]; then
211 _nlist_cursor_visibility 0 211 _nlist_cursor_visibility 0
212 fi 212 fi
213 213
214 # 214 #
215 # Listening for input 215 # Listening for input
216 # 216 #
217 217
218 local key keypad 218 local key keypad
219 219
220 # Clear input buffer 220 # Clear input buffer
221 zcurses timeout main 0 221 zcurses timeout main 0
222 zcurses input main key keypad 222 zcurses input main key keypad
223 zcurses timeout main -1 223 zcurses timeout main -1
224 key="" 224 key=""
225 keypad="" 225 keypad=""
226 226
227 list=( "$@" ) 227 # This loop makes script faster on some Zsh's (e.g. 5.0.8)
228 last_element="$#list" 228 repeat 1; do
229 list=( "$@" )
230 done
229 231
230 integer is_colored=0 232 last_element="$#list"
231 if [[ -z "$NLIST_SEARCH_BUFFER" && -n "$NLIST_COLORING_PATTERN" ]]; then
232 is_colored=1
233 _nlist_coloring_list_into_col_list
234 fi
235 233
236 while (( 1 )); do 234 while (( 1 )); do
237 # Do searching (filtering with string) 235 # Do searching (filtering with string)
238 if [ -n "$NLIST_SEARCH_BUFFER" ]; then 236 if [ -n "$NLIST_SEARCH_BUFFER" ]; then
239 # Compute new list, col_list ? 237 # Compute new list?
240 if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then 238 if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then
241 prev_search_buffer="$NLIST_SEARCH_BUFFER" 239 prev_search_buffer="$NLIST_SEARCH_BUFFER"
242 prev_uniq_mode="$NLIST_IS_UNIQ_MODE" 240 prev_uniq_mode="$NLIST_IS_UNIQ_MODE"
243 # regenerating list -> regenerating disp_list 241 # regenerating list -> regenerating disp_list
244 prev_start_idx=-1 242 prev_start_idx=-1
245 243
246 # Take all elements, including duplicates and non-selectables 244 # Take all elements, including duplicates and non-selectables
247 typeset +U list 245 typeset +U list
248 list=( "$@" ) 246 repeat 1; do
247 list=( "$@" )
248 done
249 249
250 # Remove non-selectable elements 250 # Remove non-selectable elements
251 [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do 251 [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
252 list[$i]=() 252 list[$i]=()
253 done 253 done
254 254
255 # Remove duplicates 255 # Remove duplicates
256 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && typeset -U list 256 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && typeset -U list
257 257
258 last_element="$#list" 258 last_element="$#list"
259 259
260 # Next do the filtering 260 # Next do the filtering
261 local search_buffer="${NLIST_SEARCH_BUFFER%% ##}" 261 local search_buffer="${NLIST_SEARCH_BUFFER%% ##}"
262 search_buffer="${search_buffer## ##}" 262 search_buffer="${search_buffer## ##}"
263 search_buffer="${search_buffer//(#m)[][*?|#~^()><\\]/\\$MATCH}" 263 search_buffer="${search_buffer//(#m)[][*?|#~^()><\\]/\\$MATCH}"
264 local search_pattern="" 264 local search_pattern=""
265 local colsearch_pattern="" 265 local colsearch_pattern=""
266 if [ -n "$search_buffer" ]; then 266 if [ -n "$search_buffer" ]; then
267 # Patterns will be *foo*~^*bar* and foo|bar) 267 # Patterns will be *foo*~^*bar* and foo|bar)
268 search_pattern="${search_buffer// ##/*~^*}" 268 search_pattern="${search_buffer// ##/*~^*}"
269 colsearch_pattern="${search_buffer// ##/|}" 269 colsearch_pattern="${search_buffer// ##/|}"
270 270
271 list=( "${(@M)list:#(#i)*$~search_pattern*}" ) 271 list=( "${(@M)list:#(#i)*$~search_pattern*}" )
272 last_element="$#list" 272 last_element="$#list"
273 fi 273 fi
274 274
275 # Called after processing list 275 # Called after processing list
276 _nlist_verify_vars 276 _nlist_verify_vars
277 fi 277 fi
278 278
279 _nlist_setup_user_vars 1 279 _nlist_setup_user_vars 1
280 280
281 integer end_idx=$(( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN + page_height - 1 )) 281 integer end_idx=$(( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN + page_height - 1 ))
282 [ "$end_idx" -gt "$last_element" ] && end_idx=last_element 282 [ "$end_idx" -gt "$last_element" ] && end_idx=last_element
283 283
284 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then 284 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
285 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" 285 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
286 disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" ) 286 disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
287 287
288 if [ -n "$colsearch_pattern" ]; then 288 if [ -n "$colsearch_pattern" ]; then
289 local red=$'\x1b[00;31m' reset=$'\x1b[00;00m' 289 local red=$'\x1b[00;31m' reset=$'\x1b[00;00m'
290 disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) 290 disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
291 fi 291 fi
292 292
293 # We have display list, lets replace newlines with "\n" when needed (1/3) 293 # We have display list, lets replace newlines with "\n" when needed (1/2)
294 [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" ) 294 [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
295 fi 295 fi
296 296
297 # Output colored list 297 # Output colored list
298 n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \ 298 n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \
299 "$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \ 299 "$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \
300 "$disp_list[@]" 300 "$disp_list[@]"
301 else 301 else
302 # There is no search, but there was in previous loop 302 # There is no search, but there was in previous loop
303 # OR 303 # OR
304 # Uniq mode was entered or left out 304 # Uniq mode was entered or left out
305 # -> compute new list (maybe also col_list) 305 # -> compute new list
306 if [[ -n "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then 306 if [[ -n "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then
307 prev_search_buffer="" 307 prev_search_buffer=""
308 prev_uniq_mode="$NLIST_IS_UNIQ_MODE" 308 prev_uniq_mode="$NLIST_IS_UNIQ_MODE"
309 # regenerating list -> regenerating disp_list 309 # regenerating list -> regenerating disp_list
310 prev_start_idx=-1 310 prev_start_idx=-1
311 311
312 # Take all elements, including duplicates and non-selectables 312 # Take all elements, including duplicates and non-selectables
313 typeset +U list 313 typeset +U list
314 list=( "$@" ) 314 repeat 1; do
315 list=( "$@" )
316 done
315 317
316 # Remove non-selectable elements only when in uniq mode 318 # Remove non-selectable elements only when in uniq mode
317 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && 319 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] &&
318 for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do 320 for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
319 list[$i]=() 321 list[$i]=()
320 done 322 done
321 323
322 # Remove duplicates when in uniq mode 324 # Remove duplicates when in uniq mode
323 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && typeset -U list 325 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && typeset -U list
324 326
325 # Apply coloring pattern (when not with search query)
326 is_colored=0
327 if [ -n "$NLIST_COLORING_PATTERN" ]; then
328 is_colored=1
329 _nlist_coloring_list_into_col_list
330 fi
331
332 last_element="$#list" 327 last_element="$#list"
333 # Called after processing list 328 # Called after processing list
334 _nlist_verify_vars 329 _nlist_verify_vars
335 fi 330 fi
336 331
337 # "1" - shouldn't bother with non-selectables 332 # "1" - shouldn't bother with non-selectables
338 _nlist_setup_user_vars "$NLIST_IS_UNIQ_MODE" 333 _nlist_setup_user_vars "$NLIST_IS_UNIQ_MODE"
339 334
340 integer end_idx=$(( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN + page_height - 1 )) 335 integer end_idx=$(( NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN + page_height - 1 ))
341 [ "$end_idx" -gt "$last_element" ] && end_idx=last_element 336 [ "$end_idx" -gt "$last_element" ] && end_idx=last_element
342 337
343 if [ "$is_colored" -eq 0 ]; then 338 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
344 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then 339 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
345 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" 340 disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
346 disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
347 341
348 # We have display list, lets replace newlines with "\n" when needed (2/3) 342 [ -n "$NLIST_COLORING_PATTERN" ] && _nlist_colorify_disp_list
349 [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
350 fi
351 else
352 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
353 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
354 disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
355 343
356 # We have display list, lets replace newlines with "\n" when needed (3/3) 344 # We have display list, lets replace newlines with "\n" when needed (2/2)
357 [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" ) 345 [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
358 fi
359 fi 346 fi
360 347
361 # Output the list 348 # Output the list
362 n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \ 349 n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \
363 "$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \ 350 "$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \
364 "$disp_list[@]" 351 "$disp_list[@]"
365 fi 352 fi
366 353
367 local status_msg_strlen 354 local status_msg_strlen
368 if [ "$NLIST_IS_SEARCH_MODE" = "1" ]; then 355 if [ "$NLIST_IS_SEARCH_MODE" = "1" ]; then
369 local _txt2="" 356 local _txt2=""
370 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] " 357 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] "
371 _nlist_status_msg "${_txt2}Filtering with: ${NLIST_SEARCH_BUFFER// /+}" 358 _nlist_status_msg "${_txt2}Filtering with: ${NLIST_SEARCH_BUFFER// /+}"
372 elif [[ ${NLIST_NONSELECTABLE_ELEMENTS[(r)$NLIST_CURRENT_IDX]} != $NLIST_CURRENT_IDX || 359 elif [[ ${NLIST_NONSELECTABLE_ELEMENTS[(r)$NLIST_CURRENT_IDX]} != $NLIST_CURRENT_IDX ||
373 -n "$NLIST_SEARCH_BUFFER" || "$NLIST_IS_UNIQ_MODE" -eq 1 ]]; then 360 -n "$NLIST_SEARCH_BUFFER" || "$NLIST_IS_UNIQ_MODE" -eq 1 ]]; then
374 local _txt="" _txt2="" 361 local _txt="" _txt2=""
375 [ -n "$NLIST_GREP_STRING" ] && _txt=" [$NLIST_GREP_STRING]" 362 [ -n "$NLIST_GREP_STRING" ] && _txt=" [$NLIST_GREP_STRING]"
376 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] " 363 [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] "
377 _nlist_status_msg "${_txt2}Current #$NLIST_USER_CURRENT_IDX (of #$NLIST_USER_LAST_ELEMENT entries)$_txt" 364 _nlist_status_msg "${_txt2}Current #$NLIST_USER_CURRENT_IDX (of #$NLIST_USER_LAST_ELEMENT entries)$_txt"
378 else 365 else
379 _nlist_status_msg "" 366 _nlist_status_msg ""
380 fi 367 fi
381 368
382 zcurses border main 369 zcurses border main
370
371 local top_msg="${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL, $USER"
372 zcurses move main 0 $(( term_width / 2 - $#top_msg / 2 ))
373 zcurses string main $top_msg
374
383 zcurses refresh main inner 375 zcurses refresh main inner
384 zcurses move main $(( term_height - 1 - 1 )) $(( status_msg_strlen + 2 )) 376 zcurses move main $(( term_height - 1 - 1 )) $(( status_msg_strlen + 2 ))
385 377
386 # Wait for input 378 # Wait for input
387 zcurses input main key keypad 379 zcurses input main key keypad
388 380
389 # Get the special (i.e. "keypad") key or regular key 381 # Get the special (i.e. "keypad") key or regular key
390 if [ -n "$key" ]; then 382 if [ -n "$key" ]; then
391 final_key="$key" 383 final_key="$key"
392 elif [ -n "$keypad" ]; then 384 elif [ -n "$keypad" ]; then
393 final_key="$keypad" 385 final_key="$keypad"
394 else 386 else
395 _nlist_status_msg "Inproper input detected" 387 _nlist_status_msg "Inproper input detected"
396 zcurses refresh main inner 388 zcurses refresh main inner
397 fi 389 fi
398 390
399 n-list-input "$NLIST_CURRENT_IDX" "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" \ 391 n-list-input "$NLIST_CURRENT_IDX" "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" \
400 "$page_height" "$page_width" "$last_element" "$NLIST_TEXT_OFFSET" \ 392 "$page_height" "$page_width" "$last_element" "$NLIST_TEXT_OFFSET" \
401 "$final_key" "$NLIST_IS_SEARCH_MODE" "$NLIST_SEARCH_BUFFER" \ 393 "$final_key" "$NLIST_IS_SEARCH_MODE" "$NLIST_SEARCH_BUFFER" \
402 "$NLIST_IS_UNIQ_MODE" 394 "$NLIST_IS_UNIQ_MODE"
403 395
404 selection="$reply[1]" 396 selection="$reply[1]"
405 action="$reply[2]" 397 action="$reply[2]"
406 NLIST_CURRENT_IDX="$reply[3]" 398 NLIST_CURRENT_IDX="$reply[3]"
407 NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN="$reply[4]" 399 NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN="$reply[4]"
408 NLIST_TEXT_OFFSET="$reply[5]" 400 NLIST_TEXT_OFFSET="$reply[5]"
409 NLIST_IS_SEARCH_MODE="$reply[6]" 401 NLIST_IS_SEARCH_MODE="$reply[6]"
410 NLIST_SEARCH_BUFFER="$reply[7]" 402 NLIST_SEARCH_BUFFER="$reply[7]"
411 NLIST_IS_UNIQ_MODE="$reply[8]" 403 NLIST_IS_UNIQ_MODE="$reply[8]"
412 404
413 if [ "$action" = "SELECT" ]; then 405 if [ "$action" = "SELECT" ]; then
414 REPLY="$selection" 406 REPLY="$selection"
415 reply=( "$list[@]" ) 407 reply=( "$list[@]" )
416 break 408 break
417 elif [ "$action" = "QUIT" ]; then 409 elif [ "$action" = "QUIT" ]; then
plugins/zsh-navigation-tools/n-panelize
1 # Copy this file into /usr/share/zsh/site-functions/ 1 # Copy this file into /usr/share/zsh/site-functions/
2 # and add 'autoload n-panelize` to .zshrc 2 # and add 'autoload n-panelize` to .zshrc
3 # 3 #
4 # This function somewhat reminds the panelize feature from Midnight Commander 4 # This function somewhat reminds the panelize feature from Midnight Commander
5 # It allows browsing output of arbitrary command. Example usage: 5 # It allows browsing output of arbitrary command. Example usage:
6 # v-panelize ls /usr/local/bin 6 # v-panelize ls /usr/local/bin
7 # 7 #
8 # Uses n-list 8 # Uses n-list
9 9
10 emulate -L zsh 10 emulate -L zsh
11 11
12 setopt extendedglob 12 setopt extendedglob
13 zmodload zsh/curses 13 zmodload zsh/curses
14 14
15 local IFS=" 15 local IFS="
16 " 16 "
17 17
18 unset NLIST_COLORING_PATTERN 18 unset NLIST_COLORING_PATTERN
19 19
20 [ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf 20 [ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
21 [ -f ~/.config/znt/n-panelize.conf ] && . ~/.config/znt/n-panelize.conf 21 [ -f ~/.config/znt/n-panelize.conf ] && . ~/.config/znt/n-panelize.conf
22 22
23 local list 23 local list
24 local selected 24 local selected
25 25
26 NLIST_REMEMBER_STATE=0 26 NLIST_REMEMBER_STATE=0
27 27
28 if [ -t 0 ]; then 28 if [ -t 0 ]; then
29 # Check if there is proper input 29 # Check if there is proper input
30 if [ "$#" -lt 1 ]; then 30 if [ "$#" -lt 1 ]; then
31 echo "Usage: n-panelize {command} [option|argument] ... or command | n-panelize" 31 echo "Usage: n-panelize {command} [option|argument] ... or command | n-panelize"
32 return 1 32 return 1
33 fi 33 fi
34 34
35 list=( `"$@"` ) 35 # This loop makes script faster on some Zsh's (e.g. 5.0.8)
36 repeat 1; do
37 list=( `"$@"` )
38 done
39
36 # TODO: $? doesn't reach user 40 # TODO: $? doesn't reach user
37 [ "$?" -eq 127 ] && return $? 41 [ "$?" -eq 127 ] && return $?
38 else 42 else
39 # Check if can reattach to terminal 43 # Check if can reattach to terminal
40 if [[ ! -c /dev/tty && ! -t 2 ]]; then 44 if [[ ! -c /dev/tty && ! -t 2 ]]; then
41 echo "No terminal available (no /dev/tty)" 45 echo "No terminal available (no /dev/tty)"
42 return 1 46 return 1
43 fi 47 fi
44 48
45 list=( "${(@f)"$(<&0)"}" ) 49 # This loop makes script faster on some Zsh's (e.g. 5.0.8)
50 repeat 1; do
51 list=( "${(@f)"$(<&0)"}" )
52 done
46 53
47 if [[ ! -c /dev/tty ]]; then 54 if [[ ! -c /dev/tty ]]; then
48 exec <&2 55 exec <&2
49 else 56 else
50 exec </dev/tty 57 exec </dev/tty
51 fi 58 fi
52 fi 59 fi
53 60
54 n-list "${list[@]}" 61 n-list "${list[@]}"
55 62
56 if [ "$REPLY" -gt 0 ]; then 63 if [ "$REPLY" -gt 0 ]; then
57 selected="$reply[REPLY]" 64 selected="$reply[REPLY]"
58 print -zr "# $selected" 65 print -zr "# $selected"
59 fi 66 fi
60 67
61 # vim: set filetype=zsh: 68 # vim: set filetype=zsh:
62 69
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 # Make sure you have a recent version: the code points that Powerline 10 # Make sure you have a recent version: the code points that Powerline
11 # uses changed in 2012, and older versions will display incorrectly, 11 # uses changed in 2012, and older versions will display incorrectly,
12 # in confusing ways. 12 # in confusing ways.
13 # 13 #
14 # In addition, I recommend the 14 # In addition, I recommend the
15 # [Solarized theme](https://github.com/altercation/solarized/) and, if you're 15 # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
16 # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - 16 # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
17 # it has significantly better color fidelity. 17 # it has significantly better color fidelity.
18 # 18 #
19 # # Goals 19 # # Goals
20 # 20 #
21 # The aim of this theme is to only show you *relevant* information. Like most 21 # The aim of this theme is to only show you *relevant* information. Like most
22 # prompts, it will only show git information when in a git working directory. 22 # prompts, it will only show git information when in a git working directory.
23 # However, it goes a step further: everything from the current user and 23 # However, it goes a step further: everything from the current user and
24 # hostname to whether the last call exited with an error to whether background 24 # hostname to whether the last call exited with an error to whether background
25 # jobs are running in this shell will all be displayed automatically when 25 # jobs are running in this shell will all be displayed automatically when
26 # appropriate. 26 # appropriate.
27 27
28 ### Segment drawing 28 ### Segment drawing
29 # A few utility functions to make it easy and re-usable to draw segmented prompts 29 # A few utility functions to make it easy and re-usable to draw segmented prompts
30 30
31 CURRENT_BG='NONE' 31 CURRENT_BG='NONE'
32 32
33 # Special Powerline characters 33 # Special Powerline characters
34 34
35 () { 35 () {
36 local LC_ALL="" LC_CTYPE="en_US.UTF-8" 36 local LC_ALL="" LC_CTYPE="en_US.UTF-8"
37 # NOTE: This segment separator character is correct. In 2012, Powerline changed 37 # NOTE: This segment separator character is correct. In 2012, Powerline changed
38 # the code points they use for their special characters. This is the new code point. 38 # the code points they use for their special characters. This is the new code point.
39 # If this is not working for you, you probably have an old version of the 39 # If this is not working for you, you probably have an old version of the
40 # Powerline-patched fonts installed. Download and install the new version. 40 # Powerline-patched fonts installed. Download and install the new version.
41 # Do not submit PRs to change this unless you have reviewed the Powerline code point 41 # Do not submit PRs to change this unless you have reviewed the Powerline code point
42 # history and have new information. 42 # history and have new information.
43 # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of 43 # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of
44 # what font the user is viewing this source code in. Do not replace the 44 # what font the user is viewing this source code in. Do not replace the
45 # escape sequence with a single literal character. 45 # escape sequence with a single literal character.
46 SEGMENT_SEPARATOR=$'\ue0b0' #  46 # Do not change this! Do not make it '\u2b80'; that is the old, wrong code point.
47 SEGMENT_SEPARATOR=$'\ue0b0'
47 } 48 }
48 49
49 # Begin a segment 50 # Begin a segment
50 # Takes two arguments, background and foreground. Both can be omitted, 51 # Takes two arguments, background and foreground. Both can be omitted,
51 # rendering default background/foreground. 52 # rendering default background/foreground.
52 prompt_segment() { 53 prompt_segment() {
53 local bg fg 54 local bg fg
54 [[ -n $1 ]] && bg="%K{$1}" || bg="%k" 55 [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
55 [[ -n $2 ]] && fg="%F{$2}" || fg="%f" 56 [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
56 if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then 57 if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
57 echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " 58 echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
58 else 59 else
59 echo -n "%{$bg%}%{$fg%} " 60 echo -n "%{$bg%}%{$fg%} "
60 fi 61 fi
61 CURRENT_BG=$1 62 CURRENT_BG=$1
62 [[ -n $3 ]] && echo -n $3 63 [[ -n $3 ]] && echo -n $3
63 } 64 }
64 65
65 # End the prompt, closing any open segments 66 # End the prompt, closing any open segments
66 prompt_end() { 67 prompt_end() {
67 if [[ -n $CURRENT_BG ]]; then 68 if [[ -n $CURRENT_BG ]]; then
68 echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" 69 echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
69 else 70 else
70 echo -n "%{%k%}" 71 echo -n "%{%k%}"
71 fi 72 fi
72 echo -n "%{%f%}" 73 echo -n "%{%f%}"
73 CURRENT_BG='' 74 CURRENT_BG=''
74 } 75 }
75 76
76 ### Prompt components 77 ### Prompt components
77 # Each component will draw itself, and hide itself if no information needs to be shown 78 # Each component will draw itself, and hide itself if no information needs to be shown
78 79
79 # Context: user@hostname (who am I and where am I) 80 # Context: user@hostname (who am I and where am I)
80 prompt_context() { 81 prompt_context() {
81 if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then 82 if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
82 prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" 83 prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
83 fi 84 fi
84 } 85 }
85 86
86 # Git: branch/detached head, dirty status 87 # Git: branch/detached head, dirty status
87 prompt_git() { 88 prompt_git() {
88 89
89 local PL_BRANCH_CHAR 90 local PL_BRANCH_CHAR
90 () { 91 () {
91 local LC_ALL="" LC_CTYPE="en_US.UTF-8" 92 local LC_ALL="" LC_CTYPE="en_US.UTF-8"
92 PL_BRANCH_CHAR=$'\ue0a0' #  93 PL_BRANCH_CHAR=$'\ue0a0' # 
93 } 94 }
94 local ref dirty mode repo_path 95 local ref dirty mode repo_path
95 repo_path=$(git rev-parse --git-dir 2>/dev/null) 96 repo_path=$(git rev-parse --git-dir 2>/dev/null)
96 97
97 if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then 98 if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
98 dirty=$(parse_git_dirty) 99 dirty=$(parse_git_dirty)
99 ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" 100 ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
100 if [[ -n $dirty ]]; then 101 if [[ -n $dirty ]]; then
101 prompt_segment yellow black 102 prompt_segment yellow black
102 else 103 else
103 prompt_segment green black 104 prompt_segment green black
104 fi 105 fi
105 106
106 if [[ -e "${repo_path}/BISECT_LOG" ]]; then 107 if [[ -e "${repo_path}/BISECT_LOG" ]]; then
107 mode=" <B>" 108 mode=" <B>"
108 elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then 109 elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
109 mode=" >M<" 110 mode=" >M<"
110 elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then 111 elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
111 mode=" >R>" 112 mode=" >R>"
112 fi 113 fi
113 114
114 setopt promptsubst 115 setopt promptsubst
115 autoload -Uz vcs_info 116 autoload -Uz vcs_info
116 117
117 zstyle ':vcs_info:*' enable git 118 zstyle ':vcs_info:*' enable git
118 zstyle ':vcs_info:*' get-revision true 119 zstyle ':vcs_info:*' get-revision true
119 zstyle ':vcs_info:*' check-for-changes true 120 zstyle ':vcs_info:*' check-for-changes true
120 zstyle ':vcs_info:*' stagedstr '✚' 121 zstyle ':vcs_info:*' stagedstr '✚'
121 zstyle ':vcs_info:*' unstagedstr '●' 122 zstyle ':vcs_info:*' unstagedstr '●'
122 zstyle ':vcs_info:*' formats ' %u%c' 123 zstyle ':vcs_info:*' formats ' %u%c'
123 zstyle ':vcs_info:*' actionformats ' %u%c' 124 zstyle ':vcs_info:*' actionformats ' %u%c'
124 vcs_info 125 vcs_info
125 echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" 126 echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
126 fi 127 fi
127 } 128 }
128 129
129 prompt_hg() { 130 prompt_hg() {
130 local rev status 131 local rev status
131 if $(hg id >/dev/null 2>&1); then 132 if $(hg id >/dev/null 2>&1); then
132 if $(hg prompt >/dev/null 2>&1); then 133 if $(hg prompt >/dev/null 2>&1); then
133 if [[ $(hg prompt "{status|unknown}") = "?" ]]; then 134 if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
134 # if files are not added 135 # if files are not added
135 prompt_segment red white 136 prompt_segment red white
136 st='±' 137 st='±'
137 elif [[ -n $(hg prompt "{status|modified}") ]]; then 138 elif [[ -n $(hg prompt "{status|modified}") ]]; then
138 # if any modification 139 # if any modification
139 prompt_segment yellow black 140 prompt_segment yellow black
140 st='±' 141 st='±'
141 else 142 else
142 # if working copy is clean 143 # if working copy is clean
143 prompt_segment green black 144 prompt_segment green black
144 fi 145 fi
145 echo -n $(hg prompt "☿ {rev}@{branch}") $st 146 echo -n $(hg prompt "☿ {rev}@{branch}") $st
146 else 147 else
147 st="" 148 st=""
148 rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') 149 rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
149 branch=$(hg id -b 2>/dev/null) 150 branch=$(hg id -b 2>/dev/null)
150 if `hg st | grep -q "^\?"`; then 151 if `hg st | grep -q "^\?"`; then
151 prompt_segment red black 152 prompt_segment red black
152 st='±' 153 st='±'
153 elif `hg st | grep -q "^[MA]"`; then 154 elif `hg st | grep -q "^[MA]"`; then
154 prompt_segment yellow black 155 prompt_segment yellow black
155 st='±' 156 st='±'
156 else 157 else
157 prompt_segment green black 158 prompt_segment green black
158 fi 159 fi
159 echo -n "☿ $rev@$branch" $st 160 echo -n "☿ $rev@$branch" $st
160 fi 161 fi
161 fi 162 fi
162 } 163 }
163 164
164 # Dir: current working directory 165 # Dir: current working directory
165 prompt_dir() { 166 prompt_dir() {
166 prompt_segment blue black '%~' 167 prompt_segment blue black '%~'
167 } 168 }
168 169
169 # Virtualenv: current working virtualenv 170 # Virtualenv: current working virtualenv
170 prompt_virtualenv() { 171 prompt_virtualenv() {
171 local virtualenv_path="$VIRTUAL_ENV" 172 local virtualenv_path="$VIRTUAL_ENV"
172 if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then 173 if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
173 prompt_segment blue black "(`basename $virtualenv_path`)" 174 prompt_segment blue black "(`basename $virtualenv_path`)"
174 fi 175 fi
175 } 176 }
176 177
177 # Status: 178 # Status:
178 # - was there an error 179 # - was there an error
179 # - am I root 180 # - am I root
180 # - are there background jobs? 181 # - are there background jobs?
181 prompt_status() { 182 prompt_status() {
182 local symbols 183 local symbols
183 symbols=() 184 symbols=()
184 [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" 185 [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
185 [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" 186 [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
186 [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" 187 [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
187 188
188 [[ -n "$symbols" ]] && prompt_segment black default "$symbols" 189 [[ -n "$symbols" ]] && prompt_segment black default "$symbols"
189 } 190 }
190 191
191 ## Main prompt 192 ## Main prompt
192 build_prompt() { 193 build_prompt() {
193 RETVAL=$? 194 RETVAL=$?
194 prompt_status 195 prompt_status
195 prompt_virtualenv 196 prompt_virtualenv
196 prompt_context 197 prompt_context
197 prompt_dir 198 prompt_dir
198 prompt_git 199 prompt_git
199 prompt_hg 200 prompt_hg
200 prompt_end 201 prompt_end
201 } 202 }
202 203
203 PROMPT='%{%f%b%k%}$(build_prompt) ' 204 PROMPT='%{%f%b%k%}$(build_prompt) '
204 205
themes/eastwood.zsh-theme
1 # RVM settings 1 # RVM settings
2 if [[ -s ~/.rvm/scripts/rvm ]] ; then 2 if [[ -s ~/.rvm/scripts/rvm ]] ; then
3 RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1" 3 RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1"
4 else 4 else
5 if which rbenv &> /dev/null; then 5 if which rbenv &> /dev/null; then
6 RPS1="%{$fg[yellow]%}rbenv:%{$reset_color%}%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$reset_color%} $EPS1" 6 RPS1="%{$fg[yellow]%}rbenv:%{$reset_color%}%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$reset_color%} $EPS1"
7 fi 7 fi
8 fi 8 fi
9 9
10 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" 10 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
11 ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" 11 ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
12 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" 12 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
13 ZSH_THEME_GIT_PROMPT_CLEAN="" 13 ZSH_THEME_GIT_PROMPT_CLEAN=""
14 14
15 # Customized git status, oh-my-zsh currently does not allow render dirty status before branch 15 # Customized git status, oh-my-zsh currently does not allow render dirty status before branch
16 git_custom_status() { 16 git_custom_status() {
17 local cb=$(current_branch) 17 local cb=$(git_current_branch)
18 if [ -n "$cb" ]; then 18 if [ -n "$cb" ]; then
19 echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" 19 echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
20 fi 20 fi
21 } 21 }
22 22
23 PROMPT='$(git_custom_status)%{$fg[cyan]%}[%~% ]%{$reset_color%}%B$%b ' 23 PROMPT='$(git_custom_status)%{$fg[cyan]%}[%~% ]%{$reset_color%}%B$%b '
24 24
themes/fishy.zsh-theme
1 # ZSH Theme emulating the Fish shell's default prompt. 1 # ZSH Theme emulating the Fish shell's default prompt.
2 2
3 _fishy_collapsed_wd() { 3 _fishy_collapsed_wd() {
4 echo $(pwd | perl -pe " 4 echo $(pwd | perl -pe '
5 BEGIN { 5 BEGIN {
6 binmode STDIN, ':encoding(UTF-8)'; 6 binmode STDIN, ":encoding(UTF-8)";
7 binmode STDOUT, ':encoding(UTF-8)'; 7 binmode STDOUT, ":encoding(UTF-8)";
8 }; s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g 8 }; s|^$ENV{HOME}|~|g; s|/([^/.])[^/]*(?=/)|/$1|g; s|/\.([^/])[^/]*(?=/)|/.$1|g
9 ") 9 ')
10 } 10 }
11 11
12 local user_color='green'; [ $UID -eq 0 ] && user_color='red' 12 local user_color='green'; [ $UID -eq 0 ] && user_color='red'
13 PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) ' 13 PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) '
14 PROMPT2='%{$fg[red]%}\ %{$reset_color%}' 14 PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
15 15
16 local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}" 16 local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}"
17 RPROMPT='${return_status}$(git_prompt_info)$(git_prompt_status)%{$reset_color%}' 17 RPROMPT='${return_status}$(git_prompt_info)$(git_prompt_status)%{$reset_color%}'
18 18
19 ZSH_THEME_GIT_PROMPT_PREFIX=" " 19 ZSH_THEME_GIT_PROMPT_PREFIX=" "
20 ZSH_THEME_GIT_PROMPT_SUFFIX="" 20 ZSH_THEME_GIT_PROMPT_SUFFIX=""
21 ZSH_THEME_GIT_PROMPT_DIRTY="" 21 ZSH_THEME_GIT_PROMPT_DIRTY=""
22 ZSH_THEME_GIT_PROMPT_CLEAN="" 22 ZSH_THEME_GIT_PROMPT_CLEAN=""
23 23
24 ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[green]%}+" 24 ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[green]%}+"
25 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[blue]%}!" 25 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[blue]%}!"
26 ZSH_THEME_GIT_PROMPT_DELETED="%{$fg_bold[red]%}-" 26 ZSH_THEME_GIT_PROMPT_DELETED="%{$fg_bold[red]%}-"
27 ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[magenta]%}>" 27 ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[magenta]%}>"
28 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[yellow]%}#" 28 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[yellow]%}#"
29 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[cyan]%}?" 29 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[cyan]%}?"
30 30
themes/frontcube.zsh-theme
1 local rvm="%{$fg[green]%}[$(rvm-prompt i v g)]%{$reset_color%}" 1 local rvm="%{$fg[green]%}[$(rvm-prompt i v g)]%{$reset_color%}"
2 2
3 PROMPT=' 3 PROMPT='
4 %{$fg_bold[gray]%}%~%{$fg_bold[blue]%}%{$fg_bold[blue]%} % %{$reset_color%} 4 %{$fg_bold[gray]%}%~%{$fg_bold[blue]%}%{$fg_bold[blue]%} % %{$reset_color%}
5 %{$fg[green]%}➞ %{$reset_color%' 5 %{$fg[green]%}➞ %{$reset_color%'
6 6
7 RPROMPT='$(git_prompt_info) $(rvm)' 7 RPROMPT='$(git_prompt_info) ${rvm}'
8 8
9 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}[git:" 9 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}[git:"
10 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" 10 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
11 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}] %{$fg[red]%}✖ %{$reset_color%}" 11 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}] %{$fg[red]%}✖ %{$reset_color%}"
12 ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}] %{$fg[green]%}✔%{$reset_color%}" 12 ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}] %{$fg[green]%}✔%{$reset_color%}"
13 13
themes/gallois.zsh-theme
1 # Depends on the git plugin for work_in_progress()
2
1 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" 3 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
2 ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" 4 ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
3 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" 5 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
4 ZSH_THEME_GIT_PROMPT_CLEAN="" 6 ZSH_THEME_GIT_PROMPT_CLEAN=""
5 7
6 #Customized git status, oh-my-zsh currently does not allow render dirty status before branch 8 #Customized git status, oh-my-zsh currently does not allow render dirty status before branch
7 git_custom_status() { 9 git_custom_status() {
8 local cb=$(current_branch) 10 local cb=$(git_current_branch)
9 if [ -n "$cb" ]; then 11 if [ -n "$cb" ]; then
10 echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" 12 echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
11 fi 13 fi
12 } 14 }
13 15
14 # RVM component of prompt 16 # RVM component of prompt
15 ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}[" 17 ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}["
16 ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}" 18 ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}"
17 19
18 # Combine it all into a final right-side prompt 20 # Combine it all into a final right-side prompt
19 RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1' 21 RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1'
20 22
21 PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' 23 PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
22 24
themes/josh.zsh-theme
1 grey='\e[0;90m' 1 grey='\e[0;90m'
2 2
3 ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}(" 3 ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}("
4 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" 4 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
5 ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}" 5 ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}"
6 ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})" 6 ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})"
7 7
8 function josh_prompt { 8 function josh_prompt {
9 (( spare_width = ${COLUMNS} )) 9 (( spare_width = ${COLUMNS} ))
10 prompt=" " 10 prompt=" "
11 11
12 branch=$(current_branch) 12 branch=$(git_current_branch)
13 ruby_version=$(rvm_prompt_info || rbenv_prompt_info) 13 ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
14 path_size=${#PWD} 14 path_size=${#PWD}
15 branch_size=${#branch} 15 branch_size=${#branch}
16 ruby_size=${#ruby_version} 16 ruby_size=${#ruby_version}
17 user_machine_size=${#${(%):-%n@%m-}} 17 user_machine_size=${#${(%):-%n@%m-}}
18 18
19 if [[ ${#branch} -eq 0 ]] 19 if [[ ${#branch} -eq 0 ]]
20 then (( ruby_size = ruby_size + 1 )) 20 then (( ruby_size = ruby_size + 1 ))
21 else 21 else
22 (( branch_size = branch_size + 4 )) 22 (( branch_size = branch_size + 4 ))
23 if [[ -n $(git status -s 2> /dev/null) ]]; then 23 if [[ -n $(git status -s 2> /dev/null) ]]; then
24 (( branch_size = branch_size + 2 )) 24 (( branch_size = branch_size + 2 ))
25 fi 25 fi
26 fi 26 fi
27 27
28 (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) )) 28 (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) ))
29 29
30 while [ ${#prompt} -lt $spare_width ]; do 30 while [ ${#prompt} -lt $spare_width ]; do
31 prompt=" $prompt" 31 prompt=" $prompt"
32 done 32 done
33 33
34 prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(current_branch)" 34 prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_current_branch)"
35 35
36 echo $prompt 36 echo $prompt
37 } 37 }
38 38
39 setopt prompt_subst 39 setopt prompt_subst
40 40
41 PROMPT=' 41 PROMPT='
42 %n@%m $(josh_prompt) 42 %n@%m $(josh_prompt)
43 %(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%} ' 43 %(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%} '
44 44
themes/juanghurtado.zsh-theme
1 # Needs Git plugin for current_branch method
2
3 # Color shortcuts 1 # Color shortcuts
4 RED=$fg[red] 2 RED=$fg[red]
5 YELLOW=$fg[yellow] 3 YELLOW=$fg[yellow]
6 GREEN=$fg[green] 4 GREEN=$fg[green]
7 WHITE=$fg[white] 5 WHITE=$fg[white]
8 BLUE=$fg[blue] 6 BLUE=$fg[blue]
9 RED_BOLD=$fg_bold[red] 7 RED_BOLD=$fg_bold[red]
10 YELLOW_BOLD=$fg_bold[yellow] 8 YELLOW_BOLD=$fg_bold[yellow]
11 GREEN_BOLD=$fg_bold[green] 9 GREEN_BOLD=$fg_bold[green]
12 WHITE_BOLD=$fg_bold[white] 10 WHITE_BOLD=$fg_bold[white]
13 BLUE_BOLD=$fg_bold[blue] 11 BLUE_BOLD=$fg_bold[blue]
14 RESET_COLOR=$reset_color 12 RESET_COLOR=$reset_color
15 13
16 # Format for git_prompt_info() 14 # Format for git_prompt_info()
17 ZSH_THEME_GIT_PROMPT_PREFIX="" 15 ZSH_THEME_GIT_PROMPT_PREFIX=""
18 ZSH_THEME_GIT_PROMPT_SUFFIX="" 16 ZSH_THEME_GIT_PROMPT_SUFFIX=""
19 17
20 # Format for parse_git_dirty() 18 # Format for parse_git_dirty()
21 ZSH_THEME_GIT_PROMPT_DIRTY=" %{$RED%}(*)" 19 ZSH_THEME_GIT_PROMPT_DIRTY=" %{$RED%}(*)"
22 ZSH_THEME_GIT_PROMPT_CLEAN="" 20 ZSH_THEME_GIT_PROMPT_CLEAN=""
23 21
24 # Format for git_prompt_status() 22 # Format for git_prompt_status()
25 ZSH_THEME_GIT_PROMPT_UNMERGED=" %{$RED%}unmerged" 23 ZSH_THEME_GIT_PROMPT_UNMERGED=" %{$RED%}unmerged"
26 ZSH_THEME_GIT_PROMPT_DELETED=" %{$RED%}deleted" 24 ZSH_THEME_GIT_PROMPT_DELETED=" %{$RED%}deleted"
27 ZSH_THEME_GIT_PROMPT_RENAMED=" %{$YELLOW%}renamed" 25 ZSH_THEME_GIT_PROMPT_RENAMED=" %{$YELLOW%}renamed"
28 ZSH_THEME_GIT_PROMPT_MODIFIED=" %{$YELLOW%}modified" 26 ZSH_THEME_GIT_PROMPT_MODIFIED=" %{$YELLOW%}modified"
29 ZSH_THEME_GIT_PROMPT_ADDED=" %{$GREEN%}added" 27 ZSH_THEME_GIT_PROMPT_ADDED=" %{$GREEN%}added"
30 ZSH_THEME_GIT_PROMPT_UNTRACKED=" %{$WHITE%}untracked" 28 ZSH_THEME_GIT_PROMPT_UNTRACKED=" %{$WHITE%}untracked"
31 29
32 # Format for git_prompt_ahead() 30 # Format for git_prompt_ahead()
33 ZSH_THEME_GIT_PROMPT_AHEAD=" %{$RED%}(!)" 31 ZSH_THEME_GIT_PROMPT_AHEAD=" %{$RED%}(!)"
34 32
35 # Format for git_prompt_long_sha() and git_prompt_short_sha() 33 # Format for git_prompt_long_sha() and git_prompt_short_sha()
36 ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$WHITE%}[%{$YELLOW%}" 34 ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$WHITE%}[%{$YELLOW%}"
37 ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$WHITE%}]" 35 ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$WHITE%}]"
38 36
39 # Prompt format 37 # Prompt format
40 PROMPT=' 38 PROMPT='
41 %{$GREEN_BOLD%}%n@%m%{$WHITE%}:%{$YELLOW%}%~%u$(parse_git_dirty)$(git_prompt_ahead)%{$RESET_COLOR%} 39 %{$GREEN_BOLD%}%n@%m%{$WHITE%}:%{$YELLOW%}%~%u$(parse_git_dirty)$(git_prompt_ahead)%{$RESET_COLOR%}
42 %{$BLUE%}>%{$RESET_COLOR%} ' 40 %{$BLUE%}>%{$RESET_COLOR%} '
43 RPROMPT='%{$GREEN_BOLD%}$(current_branch)$(git_prompt_short_sha)$(git_prompt_status)%{$RESET_COLOR%}' 41 RPROMPT='%{$GREEN_BOLD%}$(git_current_branch)$(git_prompt_short_sha)$(git_prompt_status)%{$RESET_COLOR%}'
44 42
themes/mortalscumbag.zsh-theme
1 function my_git_prompt() { 1 function my_git_prompt() {
2 tester=$(git rev-parse --git-dir 2> /dev/null) || return 2 tester=$(git rev-parse --git-dir 2> /dev/null) || return
3 3
4 INDEX=$(git status --porcelain 2> /dev/null) 4 INDEX=$(git status --porcelain 2> /dev/null)
5 STATUS="" 5 STATUS=""
6 6
7 # is branch ahead? 7 # is branch ahead?
8 if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then 8 if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
9 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" 9 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
10 fi 10 fi
11 11
12 # is anything staged? 12 # is anything staged?
13 if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then 13 if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
14 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED" 14 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
15 fi 15 fi
16 16
17 # is anything unstaged? 17 # is anything unstaged?
18 if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then 18 if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then
19 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" 19 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
20 fi 20 fi
21 21
22 # is anything untracked? 22 # is anything untracked?
23 if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then 23 if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
24 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" 24 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
25 fi 25 fi
26 26
27 # is anything unmerged? 27 # is anything unmerged?
28 if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then 28 if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
29 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" 29 STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
30 fi 30 fi
31 31
32 if [[ -n $STATUS ]]; then 32 if [[ -n $STATUS ]]; then
33 STATUS=" $STATUS" 33 STATUS=" $STATUS"
34 fi 34 fi
35 35
36 echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX" 36 echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
37 } 37 }
38 38
39 function my_current_branch() { 39 function my_current_branch() {
40 echo $(current_branch || echo "(no branch)") 40 echo $(git_current_branch || echo "(no branch)")
41 } 41 }
42 42
43 function ssh_connection() { 43 function ssh_connection() {
44 if [[ -n $SSH_CONNECTION ]]; then 44 if [[ -n $SSH_CONNECTION ]]; then
45 echo "%{$fg_bold[red]%}(ssh) " 45 echo "%{$fg_bold[red]%}(ssh) "
46 fi 46 fi
47 } 47 }
48 48
49 local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}" 49 local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
50 PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# ' 50 PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
51 51
52 ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}" 52 ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
53 ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}" 53 ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}"
54 ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑" 54 ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑"
55 ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●" 55 ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●"
56 ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●" 56 ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●"
57 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●" 57 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●"
58 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕" 58 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕"
59 ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]›%{$reset_color%}" 59 ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]›%{$reset_color%}"
60 60
themes/peepcode.zsh-theme
1 # 1 #
2 # Based on Geoffrey Grosenbach's peepcode zsh theme from 2 # Based on Geoffrey Grosenbach's peepcode zsh theme from
3 # https://github.com/topfunky/zsh-simple 3 # https://github.com/topfunky/zsh-simple
4 # 4 #
5 5
6 git_repo_path() { 6 git_repo_path() {
7 git rev-parse --git-dir 2>/dev/null 7 git rev-parse --git-dir 2>/dev/null
8 } 8 }
9 9
10 git_commit_id() { 10 git_commit_id() {
11 git rev-parse --short HEAD 2>/dev/null 11 git rev-parse --short HEAD 2>/dev/null
12 } 12 }
13 13
14 git_mode() { 14 git_mode() {
15 if [[ -e "$repo_path/BISECT_LOG" ]]; then 15 if [[ -e "$repo_path/BISECT_LOG" ]]; then
16 echo "+bisect" 16 echo "+bisect"
17 elif [[ -e "$repo_path/MERGE_HEAD" ]]; then 17 elif [[ -e "$repo_path/MERGE_HEAD" ]]; then
18 echo "+merge" 18 echo "+merge"
19 elif [[ -e "$repo_path/rebase" || -e "$repo_path/rebase-apply" || -e "$repo_path/rebase-merge" || -e "$repo_path/../.dotest" ]]; then 19 elif [[ -e "$repo_path/rebase" || -e "$repo_path/rebase-apply" || -e "$repo_path/rebase-merge" || -e "$repo_path/../.dotest" ]]; then
20 echo "+rebase" 20 echo "+rebase"
21 fi 21 fi
22 } 22 }
23 23
24 git_dirty() { 24 git_dirty() {
25 if [[ "$repo_path" != '.' && `git ls-files -m` != "" ]]; then 25 if [[ "$repo_path" != '.' && `git ls-files -m` != "" ]]; then
26 echo " %{$fg_bold[grey]%}✗%{$reset_color%}" 26 echo " %{$fg_bold[grey]%}✗%{$reset_color%}"
27 fi 27 fi
28 } 28 }
29 29
30 git_prompt() { 30 git_prompt() {
31 local cb=$(current_branch) 31 local cb=$(git_current_branch)
32 if [ -n "$cb" ]; then 32 if [ -n "$cb" ]; then
33 local repo_path=$(git_repo_path) 33 local repo_path=$(git_repo_path)
34 echo " %{$fg_bold[grey]%}$cb %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)" 34 echo " %{$fg_bold[grey]%}$cb %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)"
35 fi 35 fi
36 } 36 }
37 37
38 local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})" 38 local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})"
39 39
40 PROMPT=' 40 PROMPT='
41 %~ 41 %~
42 ${smiley} %{$reset_color%}' 42 ${smiley} %{$reset_color%}'
43 43
44 RPROMPT='%{$fg[white]%} $(~/.rvm/bin/rvm-prompt)$(git_prompt)%{$reset_color%}' 44 RPROMPT='%{$fg[white]%} $(~/.rvm/bin/rvm-prompt)$(git_prompt)%{$reset_color%}'
45 45
themes/sunrise.zsh-theme
1 # Sunrise theme for oh-my-zsh 1 # Sunrise theme for oh-my-zsh
2 # Intended to be used with Solarized: http://ethanschoonover.com/solarized 2 # Intended to be used with Solarized: http://ethanschoonover.com/solarized
3 # (Needs Git plugin for current_branch method)
4 3
5 # Color shortcuts 4 # Color shortcuts
6 R=$fg_no_bold[red] 5 R=$fg_no_bold[red]
7 G=$fg_no_bold[green] 6 G=$fg_no_bold[green]
8 M=$fg_no_bold[magenta] 7 M=$fg_no_bold[magenta]
9 Y=$fg_no_bold[yellow] 8 Y=$fg_no_bold[yellow]
10 B=$fg_no_bold[blue] 9 B=$fg_no_bold[blue]
11 RESET=$reset_color 10 RESET=$reset_color
12 11
13 if [ "$USER" = "root" ]; then 12 if [ "$USER" = "root" ]; then
14 PROMPTCOLOR="%{$R%}" PREFIX="-!-"; 13 PROMPTCOLOR="%{$R%}" PREFIX="-!-";
15 else 14 else
16 PROMPTCOLOR="" PREFIX="---"; 15 PROMPTCOLOR="" PREFIX="---";
17 fi 16 fi
18 17
19 local return_code="%(?..%{$R%}%? ↵%{$RESET%})" 18 local return_code="%(?..%{$R%}%? ↵%{$RESET%})"
20 19
21 # Get the status of the working tree (copied and modified from git.zsh) 20 # Get the status of the working tree (copied and modified from git.zsh)
22 custom_git_prompt_status() { 21 custom_git_prompt_status() {
23 INDEX=$(git status --porcelain 2> /dev/null) 22 INDEX=$(git status --porcelain 2> /dev/null)
24 STATUS="" 23 STATUS=""
25 # Non-staged 24 # Non-staged
26 if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then 25 if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
27 STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" 26 STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
28 fi 27 fi
29 if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then 28 if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
30 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" 29 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
31 fi 30 fi
32 if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then 31 if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
33 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" 32 STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
34 fi 33 fi
35 if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then 34 if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then
36 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 35 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
37 elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then 36 elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
38 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 37 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
39 elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then 38 elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
40 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" 39 STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
41 fi 40 fi
42 # Staged 41 # Staged
43 if $(echo "$INDEX" | grep '^D ' &> /dev/null); then 42 if $(echo "$INDEX" | grep '^D ' &> /dev/null); then
44 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS" 43 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS"
45 fi 44 fi
46 if $(echo "$INDEX" | grep '^R' &> /dev/null); then 45 if $(echo "$INDEX" | grep '^R' &> /dev/null); then
47 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS" 46 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS"
48 fi 47 fi
49 if $(echo "$INDEX" | grep '^M' &> /dev/null); then 48 if $(echo "$INDEX" | grep '^M' &> /dev/null); then
50 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS" 49 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS"
51 fi 50 fi
52 if $(echo "$INDEX" | grep '^A' &> /dev/null); then 51 if $(echo "$INDEX" | grep '^A' &> /dev/null); then
53 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS" 52 STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS"
54 fi 53 fi
55 54
56 if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then 55 if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then
57 STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS" 56 STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS"
58 fi 57 fi
59 58
60 echo $STATUS 59 echo $STATUS
61 } 60 }
62 61
63 # get the name of the branch we are on (copied and modified from git.zsh) 62 # get the name of the branch we are on (copied and modified from git.zsh)
64 function custom_git_prompt() { 63 function custom_git_prompt() {
65 ref=$(git symbolic-ref HEAD 2> /dev/null) || return 64 ref=$(git symbolic-ref HEAD 2> /dev/null) || return
66 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX" 65 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX"
67 } 66 }
68 67
69 # %B sets bold text 68 # %B sets bold text
70 PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' 69 PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
71 RPS1="${return_code}" 70 RPS1="${return_code}"
72 71
73 ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹" 72 ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹"
74 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$Y%}›%{$RESET%} " 73 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$Y%}›%{$RESET%} "
75 74
76 ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*" 75 ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*"
77 ZSH_THEME_GIT_PROMPT_CLEAN="" 76 ZSH_THEME_GIT_PROMPT_CLEAN=""
78 77
79 ZSH_THEME_GIT_PROMPT_AHEAD="%{$B%}➔" 78 ZSH_THEME_GIT_PROMPT_AHEAD="%{$B%}➔"
80 79
81 80
82 ZSH_THEME_GIT_STATUS_PREFIX=" " 81 ZSH_THEME_GIT_STATUS_PREFIX=" "
83 82
84 # Staged 83 # Staged
85 ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A" 84 ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A"
86 ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M" 85 ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M"
87 ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R" 86 ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R"
88 ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D" 87 ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D"
89 88
90 # Not-staged 89 # Not-staged
91 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}?" 90 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}?"
92 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M" 91 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M"
93 ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D" 92 ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D"
94 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU" 93 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU"
95 94
1 1
2 # Use colors, but only if connected to a terminal, and that terminal 2 # Use colors, but only if connected to a terminal, and that terminal
3 # supports them. 3 # supports them.
4 if which tput >/dev/null 2>&1; then 4 if which tput >/dev/null 2>&1; then
5 ncolors=$(tput colors) 5 ncolors=$(tput colors)
6 fi 6 fi
7 if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then 7 if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
8 RED="$(tput setaf 1)" 8 RED="$(tput setaf 1)"
9 GREEN="$(tput setaf 2)" 9 GREEN="$(tput setaf 2)"
10 YELLOW="$(tput setaf 3)" 10 YELLOW="$(tput setaf 3)"
11 BLUE="$(tput setaf 4)" 11 BLUE="$(tput setaf 4)"
12 BOLD="$(tput bold)" 12 BOLD="$(tput bold)"
13 NORMAL="$(tput sgr0)" 13 NORMAL="$(tput sgr0)"
14 else 14 else
15 RED="" 15 RED=""
16 GREEN="" 16 GREEN=""
17 YELLOW="" 17 YELLOW=""
18 BLUE="" 18 BLUE=""
19 BOLD="" 19 BOLD=""
20 NORMAL="" 20 NORMAL=""
21 fi 21 fi
22 22
23 printf "${BLUE}%s${NORMAL}\n" "Upgrading Oh My Zsh" 23 printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
24 cd "$ZSH" 24 cd "$ZSH"
25 if git pull --rebase --stat origin master 25 if git pull --rebase --stat origin master
26 then 26 then
27 printf '%s' "$GREEN" 27 printf '%s' "$GREEN"
28 printf '%s\n' ' __ __ ' 28 printf '%s\n' ' __ __ '
29 printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' 29 printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
30 printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' 30 printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
31 printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' 31 printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
32 printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' 32 printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
33 printf '%s\n' ' /____/ ' 33 printf '%s\n' ' /____/ '
34 printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version." 34 printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
35 printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh" 35 printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
36 printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/" 36 printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/"
37 else 37 else
38 printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?' 38 printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
39 fi 39 fi
40 40