Compare View
-
3c8a333 Merge pull request #5343 from mcornella/rake-fast-plugin-refactor
abf73bb rake-fast: change variable name from `$path' to `$file'
59fdb2b Reword rake-fast README, add `lib/tasks` information
81ca318 Fix syntax and formatting of rake-fast plugin
2277967 Fix _tasks_changed algorithm in rake-fast plugin
2ab6738 Added perms plugin (#1752)
deadc36 Disable zsh file globbing when running pip (#5348)
f258083 Merge branch 'apjanke-cask-homebrew-paths'
cf4da1b Add README to cask plugin
a7e60e4 Style fixes and shorter command lookup
e1e3acc cask: check for Homebrew path for completion file
d8b03f3 init script: remove trailing slash from $ZSH_CACHE_DIR
051a2ee Merge branch 'add-tig-plugin'
04dd977 Add README to tig plugin
bf79e1c adding tig plugin for oh-my-zsh
6e33095 iTerm2 v3 tab commands fixes (#5336)
cbd9d04 Added documentation for undocumented OSX plugin commands (#5338)
3186b65 Merge pull request #5335 from mcornella/cleanup-archlinux-plugin
b90c894 archlinux: fix pacmanallkeys URL, make curl silent
98ea641 archlinux: reword and simplify README
65f16fb archlinux: remove comments, format functions better
4f15bd1 Properly fix npm completion source
9e81b79 Reorder zshrc template
136a834 npm: only load completion if npm exists
3b8d0ad archlinux: Update yasu alias
251bc2d dircycle: keep switch until a directory is found
7c1ca0e Create and cache npm completion on first run
4b9772f Add more go aliases (#5259)
b9c3e86 Add alias for checking out develop branch (#5307)
292a62e Fix git emptiness check in dogenpunk theme (#5329)
774c4ec Revert "Fix pj() function when no project has been specified"
24ac1aa Clobber ssh environment regardless of setopt (#5322)
76821f5 Rename `gh` alias (git help) to `ghh`
9981214 Add git alias to clear entire stash (#5306)
66179bd Fix git-flow README
0615dfe Add alias and README to git-flow plugin (#5129)
acd6a14 Merge pull request #5296 from mcornella/fix-pj-plugin
bec5313 Fix shwordsplit bug when a basedir contains spaces
7d298a3 Fix pj() function when no project has been specified
7f8851f Refactor pj function
c9c11d6 Fix _pj completion function
26bef09 Add Readme to pj plugin
525ee50 Clean up comments in pj plugin file and reorganise
75f2f4e Adding alias to rake db:schema:load command. (#5281)
073ea01 Create an alias to open up sublime project (#5258)
95371af Add gcpa and gcpc aliases to git plugin (#5271)
5d6c350 Enhancement: Show/Hide OSX hidden files 💯 (#5275)
341e83f Plugin : Sudo - Add support of sudoedit (#5035)
40a9d9c plugins/urltools: add suport for python 3 (#5039)
b44aa61 Merge branch 'adispring-master'
b96a587 #5130 resolving conflict in git plugin for gh
1e9084c muse theme: Remove extra spaces for none git/virtualenv prompt (#5278)
f19b6b2 add kubectl plugin (#5298)
51c1078 refresh .rake_tasks when lib/tasks changed (#5111)
906a773 Add tmux attach -d alias (#5285)
0181fe4 add npm aliases (#5290)
ae21102 (git): Add gpsup alias (#5287)
c093230 Add shrink-path plugin to shorten directory paths (e.g. ~/f/b/quux) (#5262)
a9428b1 added mix autocompletion support for phoenix (#4967)
4505a43 update alias of get a list of packages installed locally (#5276)
9772f8e Replace /bin/sh with sh for portability (#5291)
a7de0fa nvm plugin improvements (#5265)
7654b16 [git plugin] Fix indentation and organise aliases
f553724 Fix gbda alias to support `color.ui = always` + exclude dev branches (#4304)
508b80c support for startpage search engine in web-search plugin (#5245)
6198195 Updated git_commits_ahead function (#5247)
a7e30b2 Fix hg call when missing on archlinux with command-not-found (#5218)
cc8285b adding python virtualenv support to the prompt (#5031)
f401305 Updated _docker-compose to the latest version (from 0.1.0 to 1.5.0). (#5215)
eb244d9 Update emacs plugin. (#5201)
d061093 Merge pull request #5233 from donatj/donatj-patch-1
c51823c Remove warning lines from phing completion
bfbfef9 Cleans up phing plugin.
96a2092 lib/git.zsh: Added git_commits_behind function (#4450)
644bc64 Merge pull request #5207 from mcornella/gb-plugin
dc0a884 Rename getgb plugin to gb
cab6359 Rename gb completion file to more conventional _gb
a29f8f7 Fix formatting of gb plugin completion
d0ea3f2 Add more information to the README
57a689f Add README to gb plugin
af1ee2b Add plugin for Gb completion (http://getgb.io)
7fabc8b bundler plugin: Simplify retrieval of cpu count on OSX (#5180)
c62442f Fix gfg function completion definition
9a61336 Fix man-preview completion definition
909fcef Fix issue with `dash` as the default `/bin/sh` script executing program. (#5177)
d012402 znt: update to v2.2.1 (#5174)
d7c0613 emacs plugin tweak to open buffer from stdin (#5126)
b1561c6 Update taskwarrior completion to 2.5.1 (#5171)
551abfc Remove undesirable hardcoding of PATH into zshrc (#4925)
46c0d95 Add README for OSX plugin and refactor plugin file
137a554 Open finder to PWD - part 2 (#5165)
623ea23 Add ofd() to OSX plugin to open finder on current directory (#5164)
3f2dd80 add 'mvn clean install -DskipTests --offline' alias to speed up maven compile (#5153)
53acf21 Peepcode theme: Don't try to use RVM if it's not available (#5154)
514ef60 Replace _kitchen completion with the version from zsh-users (#5011)
3ce2228 Mod: use new debug namespace to avoid deprecation warning (#4799)
80cac85 Fix: Plugin knife: Add relative local path for commands which upload files (#4240)
2d7a451 Add list-timers to systemd user commands (#5099)
deb992b Adds ReactNative plugin :iphone: (#5018)
dc22270 Fix arcanist aliases (#5110)
e1e549c add plugin react-native (#4606)
5fa4d9d add alias gh=git help
483f120 installer: fix ordering of cygwin msys git check (#4557)
9e8f417 Merge pull request #4729 from sachin21/update_rake_command_in_rails_plugin
c195189 Use default branch on recently created Mercurial repository. (#4985)
73cca94 Add zsh completion plugin for rustc (#3159)
0aa3cb2 Merge pull request #5119 from baig/git-plugin-update
bdc8211 Changd `alias gsta='git stash'` to `alias gsta='git stash save'`.
1e90f36 added assembly alias (#5107)
222d843 Merge branch 'Draniu/patch-1'
87cbf3f Fix styling in cakephp3 completion
9a0f9d7 Better cake3 completion
9ad9ac6 Change vim command to $EDITOR for consistency (#5063)
670a470 fixed bower completion error from issue #2694 (#5056)
f2b1be0 vagrant snapshot (#5032)
c2168d7 Arcanist plugin (#5106)
970f11d Merge pull request #5104 from felipec/fc/gitfast
36e29fb completion: zsh: improve main function selection
079fef4 gitfast: fix the prompt colour
eec3dc6 gitfast: update to upstream v2.8
841d2b9 Merge pull request #5053 from psprint/master
5b9c6c1 Merge pull request #5044 from charpeni/jira-rapid-board
23ed432 Merge pull request #5077 from jgmdev/master
de427f3 Merge pull request #5094 from pzgull/add-rbenv-to-avit-theme
11b48e1 Merge pull request #5100 from emzar/yet-another-git-tree
d2712d3 Add alias for oneline git tree with --all option
169cd8b gitfast: update to upstream v2.4
0b5d18a gitfast: update to upstream v2.0
e2d157d znt: update to v2.1.15
b1ab13d Add rbenv support for ruby version display
621eb21 Fix deprecated usage (#5050)
615af65 Add 'gcn!' for the '--no-edit' option. (#4830)
5aa7e0f Add mvn options to ignore test failures (#5092)
4a1e89c Merge pull request #5076 from tomasnorre/VagrantSnapshot
d393436 Merge branch 'juanpastas/patch-2'
5272387 Add README to meteor plugin
edf89bf Add meteor plugin aliases
4d9ae02 Merge branch 'normalize-repository'
7a0d299 Reword and clarify example.zsh custom file
54ace41 Tidy up gitignore file
66e7e7d Use .gitkeep files to keep cache/ and log/ directories
2198ff0 Rename license to LICENSE.txt for consistency
26a07b0 Rename README.markdown to README.md for consistency
25dddd2 Merge branch 'email2vimalraj/readme-for-maven'
30870d8 Reword and fix formatting of mvn plugin README
863675f Add README file for mvn plugin
817889c Merge branch 'manu09-patch-1'
2ad13bd This plugin also includes tab completions
6dbeb7b Merge branch 'fix/weird-autocompletion'
cc36063 Cleanup theme-and-appearance.zsh
ed484df Delete cdablevars option by default
2bce3b1 Added fossil plugin.
244d6b1 [TASK] Vagrant plugin: Add missing vagrant snapshot command
0ebe359 Merge pull request #4907 from johankj/feature/osx-iterm2
3524fc8 JIRA Plugin will open rapidboard instead of dashboard if JIRA_RAPID_BOARD is true
1b1315a Merge pull request #5027 from tony612/add-files-completion-to-mix-test
63ad708 Merge pull request #5023 from psprint/master
c1ed141 add files completion to mix test
19769fd Don't leave positional parameters being set
656ddab Merge pull request #5009 from cosmosgenius/github-gitio-bug
f28c0a8 Moved git.io url to https
d310fac Merge pull request #4572 from aioutecism/master
b714292 Merge pull request #4976 from mcornella/bureau-theme-fixes
82a4587 Use `grep -q` for silent behavior
e1b04cf Fix logic of bureau_git_status function
d189236 Add iTerm2 v3 support
06659f7 Support bundler
e66afc0 Avoid using "PREFIX" that cause nvm to complain about.git-subtree-dir: repos/robbyrussell/oh-my-zsh
git-subtree-split: 3c8a33364f64975970839eeded921c3ed85ad507
Changes
Showing 124 changed files Side-by-side Diff
- repos/robbyrussell/oh-my-zsh/.gitignore
- repos/robbyrussell/oh-my-zsh/LICENSE.txt
- repos/robbyrussell/oh-my-zsh/MIT-LICENSE.txt
- repos/robbyrussell/oh-my-zsh/README.markdown
- repos/robbyrussell/oh-my-zsh/README.md
- repos/robbyrussell/oh-my-zsh/cache/.easter-egg
- repos/robbyrussell/oh-my-zsh/cache/.gitkeep
- repos/robbyrussell/oh-my-zsh/custom/example.zsh
- repos/robbyrussell/oh-my-zsh/lib/functions.zsh
- repos/robbyrussell/oh-my-zsh/lib/git.zsh
- repos/robbyrussell/oh-my-zsh/lib/nvm.zsh
- repos/robbyrussell/oh-my-zsh/lib/theme-and-appearance.zsh
- repos/robbyrussell/oh-my-zsh/log/.easter-egg
- repos/robbyrussell/oh-my-zsh/log/.gitkeep
- repos/robbyrussell/oh-my-zsh/oh-my-zsh.sh
- repos/robbyrussell/oh-my-zsh/plugins/arcanist/README.md
- repos/robbyrussell/oh-my-zsh/plugins/arcanist/arcanist.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/archlinux/README.md
- repos/robbyrussell/oh-my-zsh/plugins/archlinux/archlinux.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/bower/bower.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/branch/branch.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/bundler/bundler.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/cakephp3/cakephp3.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/cask/README.md
- repos/robbyrussell/oh-my-zsh/plugins/cask/cask.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/dircycle/dircycle.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/docker-compose/README.md
- repos/robbyrussell/oh-my-zsh/plugins/docker-compose/_docker-compose
- repos/robbyrussell/oh-my-zsh/plugins/emacs/emacs.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/emacs/emacsclient.sh
- repos/robbyrussell/oh-my-zsh/plugins/fasd/fasd.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/fossil/README.md
- repos/robbyrussell/oh-my-zsh/plugins/fossil/fossil.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/gb/README.md
- repos/robbyrussell/oh-my-zsh/plugins/gb/_gb
- repos/robbyrussell/oh-my-zsh/plugins/git-flow/README.md
- repos/robbyrussell/oh-my-zsh/plugins/git-flow/git-flow.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/git/git.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/gitfast/_git
- repos/robbyrussell/oh-my-zsh/plugins/gitfast/git-completion.bash
- repos/robbyrussell/oh-my-zsh/plugins/gitfast/git-prompt.sh
- repos/robbyrussell/oh-my-zsh/plugins/github/github.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/golang/golang.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/jira/jira.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/kitchen/_kitchen
- repos/robbyrussell/oh-my-zsh/plugins/knife/_knife
- repos/robbyrussell/oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/meteor/README.md
- repos/robbyrussell/oh-my-zsh/plugins/meteor/meteor.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/mix/_mix
- repos/robbyrussell/oh-my-zsh/plugins/mvn/README.md
- repos/robbyrussell/oh-my-zsh/plugins/mvn/mvn.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/npm/npm.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/nvm/_nvm
- repos/robbyrussell/oh-my-zsh/plugins/nvm/nvm.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/osx/README.md
- repos/robbyrussell/oh-my-zsh/plugins/osx/_man-preview
- repos/robbyrussell/oh-my-zsh/plugins/osx/osx.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/perms/README.md
- repos/robbyrussell/oh-my-zsh/plugins/perms/perms.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/phing/phing.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/pip/pip.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/pj/README.md
- repos/robbyrussell/oh-my-zsh/plugins/pj/pj.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/rails/rails.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/rake-fast/README.md
- repos/robbyrussell/oh-my-zsh/plugins/rake-fast/rake-fast.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/react-native/README.md
- repos/robbyrussell/oh-my-zsh/plugins/react-native/_react-native
- repos/robbyrussell/oh-my-zsh/plugins/react-native/react-native.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/rust/_rust
- repos/robbyrussell/oh-my-zsh/plugins/sbt/sbt.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/shrink-path/README.md
- repos/robbyrussell/oh-my-zsh/plugins/shrink-path/shrink-path.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/ssh-agent/ssh-agent.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/sublime/README.md
- repos/robbyrussell/oh-my-zsh/plugins/sublime/sublime.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/sudo/sudo.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/symfony2/symfony2.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/systemd/systemd.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/taskwarrior/_task
- repos/robbyrussell/oh-my-zsh/plugins/tig/README.md
- repos/robbyrussell/oh-my-zsh/plugins/tig/tig.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/tmux/tmux.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/ubuntu/ubuntu.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/urltools/urltools.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/vagrant/_vagrant
- repos/robbyrussell/oh-my-zsh/plugins/web-search/web-search.plugin.zsh
- repos/robbyrussell/oh-my-zsh/plugins/wp-cli/README.md
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-env.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-history.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-list.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-options.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/README.md
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/_n-kill
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-aliases
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-cd
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-env
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-functions
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-help
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-history
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-kill
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-list
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-list-draw
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-list-input
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-options
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/n-panelize
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/znt-history-widget
- repos/robbyrussell/oh-my-zsh/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
- repos/robbyrussell/oh-my-zsh/templates/zshrc.zsh-template
- repos/robbyrussell/oh-my-zsh/themes/agnoster.zsh-theme
- repos/robbyrussell/oh-my-zsh/themes/avit.zsh-theme
- repos/robbyrussell/oh-my-zsh/themes/bureau.zsh-theme
- repos/robbyrussell/oh-my-zsh/themes/dogenpunk.zsh-theme
- repos/robbyrussell/oh-my-zsh/themes/muse.zsh-theme
- repos/robbyrussell/oh-my-zsh/themes/peepcode.zsh-theme
- repos/robbyrussell/oh-my-zsh/themes/sunrise.zsh-theme
- repos/robbyrussell/oh-my-zsh/tools/check_for_upgrade.sh
- repos/robbyrussell/oh-my-zsh/tools/install.sh
... | ... | @@ -0,0 +1,22 @@ |
1 | +The MIT License (MIT) | |
2 | + | |
3 | +Copyright (c) 2009-2016 Robby Russell and contributors | |
4 | +See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors | |
5 | + | |
6 | +Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | +of this software and associated documentation files (the "Software"), to deal | |
8 | +in the Software without restriction, including without limitation the rights | |
9 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | +copies of the Software, and to permit persons to whom the Software is | |
11 | +furnished to do so, subject to the following conditions: | |
12 | + | |
13 | +The above copyright notice and this permission notice shall be included in all | |
14 | +copies or substantial portions of the Software. | |
15 | + | |
16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
19 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
22 | +SOFTWARE. |
... | ... | @@ -1,22 +0,0 @@ |
1 | -The MIT License (MIT) | |
2 | - | |
3 | -Copyright (c) 2009-2016 Robby Russell and contributors | |
4 | -See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors | |
5 | - | |
6 | -Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | -of this software and associated documentation files (the "Software"), to deal | |
8 | -in the Software without restriction, including without limitation the rights | |
9 | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | -copies of the Software, and to permit persons to whom the Software is | |
11 | -furnished to do so, subject to the following conditions: | |
12 | - | |
13 | -The above copyright notice and this permission notice shall be included in all | |
14 | -copies or substantial portions of the Software. | |
15 | - | |
16 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
19 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
22 | -SOFTWARE. |
... | ... | @@ -1,213 +0,0 @@ |
1 | -<p align="center"> | |
2 | - <img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"> | |
3 | -</p> | |
4 | - | |
5 | -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. | |
6 | - | |
7 | -__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. | |
8 | - | |
9 | -To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. | |
10 | - | |
11 | -## Getting Started | |
12 | - | |
13 | -### Prerequisites | |
14 | - | |
15 | -__Disclaimer:__ _Oh My Zsh works best on OS X and Linux._ | |
16 | - | |
17 | -* Unix-based operating system (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) | |
19 | -* `curl` or `wget` should be installed | |
20 | -* `git` should be installed | |
21 | - | |
22 | -### Basic Installation | |
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`. | |
25 | - | |
26 | -#### via curl | |
27 | - | |
28 | -```shell | |
29 | -sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
30 | -``` | |
31 | - | |
32 | -#### via wget | |
33 | - | |
34 | -```shell | |
35 | -sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" | |
36 | -``` | |
37 | - | |
38 | -## Using Oh My Zsh | |
39 | - | |
40 | -### Plugins | |
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. | |
43 | - | |
44 | -#### Enabling Plugins | |
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. | |
47 | - | |
48 | -For example, this line might begin to look like... | |
49 | - | |
50 | -```shell | |
51 | -plugins=(git bundler osx rake ruby) | |
52 | -``` | |
53 | - | |
54 | -#### Using Plugins | |
55 | - | |
56 | -Most plugins (should! we're working on this) include a __README__, which documents how to use them. | |
57 | - | |
58 | -### Themes | |
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! | |
61 | - | |
62 | -#### Selecting a Theme | |
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)._ | |
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: | |
67 | - | |
68 | -```shell | |
69 | -ZSH_THEME="robbyrussell" | |
70 | -``` | |
71 | - | |
72 | -To use a different theme, simply change the value to match the name of your desired theme. For example: | |
73 | - | |
74 | -```shell | |
75 | -ZSH_THEME="agnoster" # (this is one of the fancy ones) | |
76 | -``` | |
77 | - | |
78 | -Open up a new terminal window and your prompt should look something like... | |
79 | - | |
80 | - | |
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). | |
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. | |
85 | - | |
86 | - | |
87 | -```shell | |
88 | -ZSH_THEME="random" # (...please let it be pie... please be some pie..) | |
89 | -``` | |
90 | - | |
91 | - | |
92 | -## Advanced Topics | |
93 | - | |
94 | -If you're the type that likes to get their hands dirty, these sections might resonate. | |
95 | - | |
96 | -### Advanced Installation | |
97 | - | |
98 | -Some users may want to change the default path, or manually install Oh My Zsh. | |
99 | - | |
100 | -#### Custom Directory | |
101 | - | |
102 | -The default location is `~/.oh-my-zsh` (hidden in your home directory) | |
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: | |
105 | - | |
106 | -```shell | |
107 | -export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
108 | -``` | |
109 | - | |
110 | -#### Manual Installation | |
111 | - | |
112 | -##### 1. Clone the repository: | |
113 | - | |
114 | -```shell | |
115 | -git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
116 | -``` | |
117 | - | |
118 | -##### 2. *Optionally*, backup your existing `~/.zshrc` file: | |
119 | - | |
120 | -```shell | |
121 | -cp ~/.zshrc ~/.zshrc.orig | |
122 | -``` | |
123 | - | |
124 | -##### 3. Create a new zsh configuration file | |
125 | - | |
126 | -You can create a new zsh config file by copying the template that we included for you. | |
127 | - | |
128 | -```shell | |
129 | -cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc | |
130 | -``` | |
131 | - | |
132 | -##### 4. Change your default shell | |
133 | - | |
134 | -```shell | |
135 | -chsh -s /bin/zsh | |
136 | -``` | |
137 | - | |
138 | -##### 5. Initialize your new zsh configuration | |
139 | - | |
140 | -Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. | |
141 | - | |
142 | -### Installation Problems | |
143 | - | |
144 | -If you have any hiccups installing, here are a few common fixes. | |
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`. | |
147 | -* If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. | |
148 | - | |
149 | -### Custom Plugins and Themes | |
150 | - | |
151 | -If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory. | |
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. | |
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/`. | |
156 | - | |
157 | -## Getting Updates | |
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`: | |
160 | - | |
161 | -```shell | |
162 | -DISABLE_UPDATE_PROMPT=true | |
163 | -``` | |
164 | - | |
165 | -To disable automatic upgrades, set the following in your `~/.zshrc`: | |
166 | - | |
167 | -```shell | |
168 | -DISABLE_AUTO_UPDATE=true | |
169 | -``` | |
170 | - | |
171 | -### Manual Updates | |
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: | |
174 | - | |
175 | -```shell | |
176 | -upgrade_oh_my_zsh | |
177 | -``` | |
178 | - | |
179 | -Magic! | |
180 | - | |
181 | -## Uninstalling Oh My Zsh | |
182 | - | |
183 | -Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup. | |
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. | |
186 | - | |
187 | -## Contributing | |
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! | |
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. | |
192 | - | |
193 | -### Do NOT send us themes | |
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. | |
196 | - | |
197 | -## Contributors | |
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. | |
200 | - | |
201 | -Thank you so much! | |
202 | - | |
203 | -## Follow Us | |
204 | - | |
205 | -We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. | |
206 | - | |
207 | -## Merchandise | |
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! | |
210 | - | |
211 | -## License | |
212 | - | |
213 | -Oh My Zsh is released under the [MIT license](MIT-LICENSE.txt). |
... | ... | @@ -0,0 +1,213 @@ |
1 | +<p align="center"> | |
2 | + <img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"> | |
3 | +</p> | |
4 | + | |
5 | +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. | |
6 | + | |
7 | +__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. | |
8 | + | |
9 | +To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. | |
10 | + | |
11 | +## Getting Started | |
12 | + | |
13 | +### Prerequisites | |
14 | + | |
15 | +__Disclaimer:__ _Oh My Zsh works best on OS X and Linux._ | |
16 | + | |
17 | +* Unix-based operating system (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) | |
19 | +* `curl` or `wget` should be installed | |
20 | +* `git` should be installed | |
21 | + | |
22 | +### Basic Installation | |
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`. | |
25 | + | |
26 | +#### via curl | |
27 | + | |
28 | +```shell | |
29 | +sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
30 | +``` | |
31 | + | |
32 | +#### via wget | |
33 | + | |
34 | +```shell | |
35 | +sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" | |
36 | +``` | |
37 | + | |
38 | +## Using Oh My Zsh | |
39 | + | |
40 | +### Plugins | |
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. | |
43 | + | |
44 | +#### Enabling Plugins | |
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. | |
47 | + | |
48 | +For example, this line might begin to look like... | |
49 | + | |
50 | +```shell | |
51 | +plugins=(git bundler osx rake ruby) | |
52 | +``` | |
53 | + | |
54 | +#### Using Plugins | |
55 | + | |
56 | +Most plugins (should! we're working on this) include a __README__, which documents how to use them. | |
57 | + | |
58 | +### Themes | |
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! | |
61 | + | |
62 | +#### Selecting a Theme | |
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)._ | |
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: | |
67 | + | |
68 | +```shell | |
69 | +ZSH_THEME="robbyrussell" | |
70 | +``` | |
71 | + | |
72 | +To use a different theme, simply change the value to match the name of your desired theme. For example: | |
73 | + | |
74 | +```shell | |
75 | +ZSH_THEME="agnoster" # (this is one of the fancy ones) | |
76 | +``` | |
77 | + | |
78 | +Open up a new terminal window and your prompt should look something like... | |
79 | + | |
80 | + | |
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). | |
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. | |
85 | + | |
86 | + | |
87 | +```shell | |
88 | +ZSH_THEME="random" # (...please let it be pie... please be some pie..) | |
89 | +``` | |
90 | + | |
91 | + | |
92 | +## Advanced Topics | |
93 | + | |
94 | +If you're the type that likes to get their hands dirty, these sections might resonate. | |
95 | + | |
96 | +### Advanced Installation | |
97 | + | |
98 | +Some users may want to change the default path, or manually install Oh My Zsh. | |
99 | + | |
100 | +#### Custom Directory | |
101 | + | |
102 | +The default location is `~/.oh-my-zsh` (hidden in your home directory) | |
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: | |
105 | + | |
106 | +```shell | |
107 | +export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
108 | +``` | |
109 | + | |
110 | +#### Manual Installation | |
111 | + | |
112 | +##### 1. Clone the repository: | |
113 | + | |
114 | +```shell | |
115 | +git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
116 | +``` | |
117 | + | |
118 | +##### 2. *Optionally*, backup your existing `~/.zshrc` file: | |
119 | + | |
120 | +```shell | |
121 | +cp ~/.zshrc ~/.zshrc.orig | |
122 | +``` | |
123 | + | |
124 | +##### 3. Create a new zsh configuration file | |
125 | + | |
126 | +You can create a new zsh config file by copying the template that we included for you. | |
127 | + | |
128 | +```shell | |
129 | +cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc | |
130 | +``` | |
131 | + | |
132 | +##### 4. Change your default shell | |
133 | + | |
134 | +```shell | |
135 | +chsh -s /bin/zsh | |
136 | +``` | |
137 | + | |
138 | +##### 5. Initialize your new zsh configuration | |
139 | + | |
140 | +Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. | |
141 | + | |
142 | +### Installation Problems | |
143 | + | |
144 | +If you have any hiccups installing, here are a few common fixes. | |
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`. | |
147 | +* If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. | |
148 | + | |
149 | +### Custom Plugins and Themes | |
150 | + | |
151 | +If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory. | |
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. | |
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/`. | |
156 | + | |
157 | +## Getting Updates | |
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`: | |
160 | + | |
161 | +```shell | |
162 | +DISABLE_UPDATE_PROMPT=true | |
163 | +``` | |
164 | + | |
165 | +To disable automatic upgrades, set the following in your `~/.zshrc`: | |
166 | + | |
167 | +```shell | |
168 | +DISABLE_AUTO_UPDATE=true | |
169 | +``` | |
170 | + | |
171 | +### Manual Updates | |
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: | |
174 | + | |
175 | +```shell | |
176 | +upgrade_oh_my_zsh | |
177 | +``` | |
178 | + | |
179 | +Magic! | |
180 | + | |
181 | +## Uninstalling Oh My Zsh | |
182 | + | |
183 | +Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup. | |
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. | |
186 | + | |
187 | +## Contributing | |
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! | |
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. | |
192 | + | |
193 | +### Do NOT send us themes | |
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. | |
196 | + | |
197 | +## Contributors | |
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. | |
200 | + | |
201 | +Thank you so much! | |
202 | + | |
203 | +## Follow Us | |
204 | + | |
205 | +We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. | |
206 | + | |
207 | +## Merchandise | |
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! | |
210 | + | |
211 | +## License | |
212 | + | |
213 | +Oh My Zsh is released under the [MIT license](LICENSE.txt). |
1 | -# Add yourself some shortcuts to projects you often work on | |
2 | -# Example: | |
1 | +# You can put files here to add functionality separated per file, which | |
2 | +# will be ignored by git. | |
3 | +# Files on the custom/ directory will be automatically loaded by the init | |
4 | +# script, in alphabetical order. | |
5 | + | |
6 | +# For example: add yourself some shortcuts to projects you often work on. | |
7 | +# | |
8 | +# brainstormr=~/Projects/development/planetargon/brainstormr | |
9 | +# cd $brainstormr | |
3 | 10 | # |
4 | -# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr | |
5 | -# | |
6 | 11 | \ No newline at end of file |
... | ... | @@ -3,11 +3,11 @@ function zsh_stats() { |
3 | 3 | } |
4 | 4 | |
5 | 5 | function uninstall_oh_my_zsh() { |
6 | - env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh | |
6 | + env ZSH=$ZSH sh $ZSH/tools/uninstall.sh | |
7 | 7 | } |
8 | 8 | |
9 | 9 | function upgrade_oh_my_zsh() { |
10 | - env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh | |
10 | + env ZSH=$ZSH sh $ZSH/tools/upgrade.sh | |
11 | 11 | } |
12 | 12 | |
13 | 13 | function take() { |
... | ... | @@ -76,13 +76,19 @@ function git_current_branch() { |
76 | 76 | |
77 | 77 | # Gets the number of commits ahead from remote |
78 | 78 | function git_commits_ahead() { |
79 | - if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then | |
80 | - local COMMITS | |
81 | - COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') | |
79 | + if $(command git rev-parse --git-dir > /dev/null 2>&1); then | |
80 | + local COMMITS="$(git rev-list --count @{upstream}..HEAD)" | |
82 | 81 | echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" |
83 | 82 | fi |
84 | 83 | } |
85 | 84 | |
85 | +# Gets the number of commits behind remote | |
86 | +function git_commits_behind() { | |
87 | + if $(command git rev-parse --git-dir > /dev/null 2>&1); then | |
88 | + echo $(git rev-list --count HEAD..@{upstream}) | |
89 | + fi | |
90 | +} | |
91 | + | |
86 | 92 | # Outputs if current branch is ahead of remote |
87 | 93 | function git_prompt_ahead() { |
88 | 94 | if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then |
... | ... | @@ -11,9 +11,9 @@ then |
11 | 11 | # otherwise, leave ls as is, because NetBSD's ls doesn't support -G |
12 | 12 | gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' |
13 | 13 | elif [[ "$(uname -s)" == "OpenBSD" ]]; then |
14 | - # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, | |
15 | - # with color and multibyte support) are available from ports. "colorls" | |
16 | - # will be installed on purpose and can't be pulled in by installing | |
14 | + # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, | |
15 | + # with color and multibyte support) are available from ports. "colorls" | |
16 | + # will be installed on purpose and can't be pulled in by installing | |
17 | 17 | # coreutils, so prefer it to "gls". |
18 | 18 | gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' |
19 | 19 | colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' |
... | ... | @@ -22,10 +22,8 @@ then |
22 | 22 | fi |
23 | 23 | fi |
24 | 24 | |
25 | -#setopt no_beep | |
26 | 25 | setopt auto_cd |
27 | 26 | setopt multios |
28 | -setopt cdablevars | |
29 | 27 | |
30 | 28 | if [[ x$WINDOW != x ]] |
31 | 29 | then |
... | ... | @@ -0,0 +1,21 @@ |
1 | +# | |
2 | +# Aliases | |
3 | +# (sorted alphabetically) | |
4 | +# | |
5 | + | |
6 | +alias ara='arc amend' | |
7 | +alias arb='arc branch' | |
8 | +alias arco='arc cover' | |
9 | +alias arci='arc commit' | |
10 | + | |
11 | +alias ard='arc diff' | |
12 | +alias ardnu='arc diff --nounit' | |
13 | +alias ardnupc='arc diff --nounit --plan-changes' | |
14 | +alias ardpc='arc diff --plan-changes' | |
15 | + | |
16 | +alias are='arc export' | |
17 | +alias arh='arc help' | |
18 | +alias arl='arc land' | |
19 | +alias arli='arc lint' | |
20 | +alias arls='arc list' | |
21 | +alias arpa='arc patch' |
1 | -## ARCHLINUX PLUGIN | |
1 | +# Archlinux plugin | |
2 | 2 | |
3 | +## Features | |
3 | 4 | |
4 | ---- | |
5 | +#### YAOURT | |
6 | + | |
7 | +| Alias | Command | Description | | |
8 | +|---------|------------------------------------|---------------------------------------------------------------------| | |
9 | +| yaconf | yaourt -C | Fix all configuration files with vimdiff | | |
10 | +| yain | yaourt -S | Install packages from the repositories | | |
11 | +| yains | yaourt -U | Install a package from a local file | | |
12 | +| yainsd | yaourt -S --asdeps | Install packages as dependencies of another package | | |
13 | +| yaloc | yaourt -Qi | Display information about a package in the local database | | |
14 | +| yalocs | yaourt -Qs | Search for packages in the local database | | |
15 | +| yalst | yaourt -Qe | List installed packages including from AUR (tagged as "local") | | |
16 | +| yamir | yaourt -Syy | Force refresh of all package lists after updating mirrorlist | | |
17 | +| yaorph | yaourt -Qtd | Remove orphans using yaourt | | |
18 | +| yare | yaourt -R | Remove packages, keeping its settings and dependencies | | |
19 | +| yarem | yaourt -Rns | Remove packages, including its settings and unneeded dependencies | | |
20 | +| yarep | yaourt -Si | Display information about a package in the repositories | | |
21 | +| yareps | yaourt -Ss | Search for packages in the repositories | | |
22 | +| yaupd | yaourt -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases | | |
23 | +| yaupd | yaourt -Sy && sudo abs | Update and refresh the local package and ABS databases | | |
24 | +| yaupd | yaourt -Sy && sudo aur | Update and refresh the local package and AUR databases | | |
25 | +| yaupd | yaourt -Sy | Update and refresh the local package database | | |
26 | +| yaupg | yaourt -Syua | Sync with repositories before upgrading all packages (from AUR too) | | |
27 | +| yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation | | |
28 | +| upgrade | yaourt -Syu | Sync with repositories before upgrading packages | | |
5 | 29 | |
6 | -### FEATURES | |
30 | +#### PACMAN | |
7 | 31 | |
8 | -| Alias | Function | Description | | |
9 | -|:------------:|-----------------------------------------|:--------------------------------------------------------------------------------------------------------------------| | |
10 | -| pacin | sudo pacman -S | Install specific package(s) from the repositories | | |
11 | -| pacins | sudo pacman -U | Install specific package not from the repositories but from a file | | |
12 | -| pacinsd | sudo pacman -S --asdeps | Install given package(s) as dependencies of another package | | |
13 | -| pacloc | pacman -Qi | Display information about a given package in the local database | | |
14 | -| paclocs | pacman -Qs | Search for package(s) in the local database | | |
15 | -| paclsorphans | sudo pacman -Qdt' | List all orphaned packages | | |
16 | -| pacmir | sudo pacman -Syy | Force refresh of all package lists after updating /etc/pacman.d/mirrorlist | | |
17 | -| pacre | sudo pacman -R | Remove the specified package(s), retaining its configuration(s) and required dependencies | | |
18 | -| pacrem | sudo pacman -Rns | Remove the specified package(s), its configuration(s) and unneeded dependencies | | |
19 | -| pacrep | pacman -Si | Display information about a given package in the repositories | | |
20 | -| pacreps | pacman -Ss | Search for package(s) in the repositories | | |
21 | -| pacrmorphans | sudo pacman -Rs $(pacman -Qtdq)' | Delete all orphaned packages | | |
22 | -| pacupd | sudo pacman -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases against repositories | | |
23 | -| pacupd | sudo pacman -Sy && sudo abs | Update and refresh the local package and ABS databases against repositories | | |
24 | -| pacupd | sudo pacman -Sy && sudo aur | Update and refresh the local package and AUR databases against repositories | | |
25 | -| pacupd | sudo pacman -Sy | Update and refresh the local package database against repositories | | |
26 | -| pacupg | sudo pacman -Syu | Synchronize with repositories before upgrading packages that are out of date on the local system. | | |
27 | -| yaconf | yaourt -C | Fix all configuration files with vimdiff | | |
28 | -| yain | yaourt -S | Install specific package(s) from the repositories | | |
29 | -| yains | yaourt -U | Install specific package not from the repositories but from a file | | |
30 | -| yainsd | yaourt -S --asdeps | Install given package(s) as dependencies of another package | | |
31 | -| yaloc | yaourt -Qi | Display information about a given package in the local database | | |
32 | -| yalocs | yaourt -Qs | Search for package(s) in the local database | | |
33 | -| yalst | yaourt -Qe | List installed packages, even those installed from AUR (they're tagged as "local") | | |
34 | -| yamir | yaourt -Syy | Force refresh of all package lists after updating /etc/pacman.d/mirrorlist | | |
35 | -| yaorph | yaourt -Qtd | Remove orphans using yaourt | | |
36 | -| yare | yaourt -R | Remove the specified package(s), retaining its configuration(s) and required dependencies | | |
37 | -| yarem | yaourt -Rns | Remove the specified package(s), its configuration(s) and unneeded dependencies | | |
38 | -| yarep | yaourt -Si | Display information about a given package in the repositories | | |
39 | -| yareps | yaourt -Ss | Search for package(s) in the repositories | | |
40 | -| yasu | yaourt --sucre | Same as yaupg, but without confirmation | | |
41 | -| yaupd | yaourt -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases against repositories | | |
42 | -| yaupd | yaourt -Sy && sudo abs | Update and refresh the local package and ABS databases against repositories | | |
43 | -| yaupd | yaourt -Sy && sudo aur | Update and refresh the local package and AUR databases against repositories | | |
44 | -| yaupd | yaourt -Sy | Update and refresh the local package database against repositories | | |
45 | -| yaupg | yaourt -Syua | Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system | | |
32 | +| Alias | Command | Description | | |
33 | +|--------------|-----------------------------------------|--------------------------------------------------------------| | |
34 | +| pacin | sudo pacman -S | Install packages from the repositories | | |
35 | +| pacins | sudo pacman -U | Install a package from a local file | | |
36 | +| pacinsd | sudo pacman -S --asdeps | Install packages as dependencies of another package | | |
37 | +| pacloc | pacman -Qi | Display information about a package in the local database | | |
38 | +| paclocs | pacman -Qs | Search for packages in the local database | | |
39 | +| paclsorphans | sudo pacman -Qdt | List all orphaned packages | | |
40 | +| pacmir | sudo pacman -Syy | Force refresh of all package lists after updating mirrorlist | | |
41 | +| pacre | sudo pacman -R | Remove packages, keeping its settings and dependencies | | |
42 | +| pacrem | sudo pacman -Rns | Remove packages, including its settings and dependencies | | |
43 | +| pacrep | pacman -Si | Display information about a package in the repositories | | |
44 | +| pacreps | pacman -Ss | Search for packages in the repositories | | |
45 | +| pacrmorphans | sudo pacman -Rs $(pacman -Qtdq) | Delete all orphaned packages | | |
46 | +| pacupd | sudo pacman -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases | | |
47 | +| pacupd | sudo pacman -Sy && sudo abs | Update and refresh the local package and ABS databases | | |
48 | +| pacupd | sudo pacman -Sy && sudo aur | Update and refresh the local package and AUR databases | | |
49 | +| pacupd | sudo pacman -Sy | Update and refresh the local package database | | |
50 | +| pacupg | sudo pacman -Syu | Sync with repositories before upgrading packages | | |
51 | +| upgrade | sudo pacman -Syu | Sync with repositories before upgrading packages | | |
46 | 52 | |
47 | -| Function | Description | | |
48 | -|----------------|:------------------------------------------------------------------------------------------------------------------| | |
49 | -| pacdisowned | List all disowned files in your system | | |
50 | -| paclist | List all installed packages with a short description - [Source](https://bbs.archlinux.org/viewtopic.php?id=93683) | | |
51 | -| pacmanallkeys | Get all keys for developers and trusted users | | |
52 | -| pacmansignkeys | | | |
53 | +| Function | Description | | |
54 | +|----------------|------------------------------------------------------| | |
55 | +| pacdisowned | List all disowned files in your system | | |
56 | +| paclist | List all installed packages with a short description | | |
57 | +| pacmanallkeys | Get all keys for developers and trusted users | | |
58 | +| pacmansignkeys | Locally trust all keys passed as parameters | | |
53 | 59 | |
54 | 60 | --- |
55 | 61 | |
56 | -### CONTRIBUTORS | |
57 | - - Benjamin Boudreau - dreurmail@gmail.com | |
58 | - - Celso Miranda - contacto@celsomiranda.net | |
59 | - - KhasMek - Boushh@gmail.com | |
60 | - - Martin Putniorz - mputniorz@gmail.com | |
61 | - - MatthR3D - matthr3d@gmail.com | |
62 | - - ornicar - thibault.duplessis@gmail.com | |
62 | +## Contributors | |
63 | 63 | |
64 | ---- | |
64 | +- Benjamin Boudreau - dreurmail@gmail.com | |
65 | +- Celso Miranda - contacto@celsomiranda.net | |
66 | +- KhasMek - Boushh@gmail.com | |
67 | +- Martin Putniorz - mputniorz@gmail.com | |
68 | +- MatthR3D - matthr3d@gmail.com | |
69 | +- ornicar - thibault.duplessis@gmail.com |
1 | -# Archlinux zsh aliases and functions | |
2 | -# Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins | |
3 | - | |
4 | -# Look for yaourt, and add some useful functions if we have it. | |
5 | -if (( $+commands[yaourt] )); then | |
1 | +if ! (( $+commands[yaourt] )); then | |
2 | + upgrade() { | |
3 | + sudo pacman -Syu | |
4 | + } | |
5 | +else | |
6 | 6 | upgrade () { |
7 | 7 | yaourt -Syu |
8 | 8 | } |
9 | - alias yaconf='yaourt -C' # Fix all configuration files with vimdiff | |
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. | |
12 | - alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation | |
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 | |
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 | |
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 | |
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 | |
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 | |
23 | - # Additional yaourt alias examples | |
9 | + | |
10 | + alias yaconf='yaourt -C' | |
11 | + alias yaupg='yaourt -Syua' | |
12 | + alias yasu='yaourt --Syua --no-confirm' | |
13 | + alias yain='yaourt -S' | |
14 | + alias yains='yaourt -U' | |
15 | + alias yare='yaourt -R' | |
16 | + alias yarem='yaourt -Rns' | |
17 | + alias yarep='yaourt -Si' | |
18 | + alias yareps='yaourt -Ss' | |
19 | + alias yaloc='yaourt -Qi' | |
20 | + alias yalocs='yaourt -Qs' | |
21 | + alias yalst='yaourt -Qe' | |
22 | + alias yaorph='yaourt -Qtd' | |
23 | + alias yainsd='yaourt -S --asdeps' | |
24 | + alias yamir='yaourt -Syy' | |
25 | + | |
26 | + | |
24 | 27 | 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 | |
28 | + alias yaupd='yaourt -Sy && sudo abs && sudo aur' | |
26 | 29 | elif (( $+commands[abs] )); then |
27 | - alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories | |
30 | + alias yaupd='yaourt -Sy && sudo abs' | |
28 | 31 | elif (( $+commands[aur] )); then |
29 | - alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories | |
32 | + alias yaupd='yaourt -Sy && sudo aur' | |
30 | 33 | else |
31 | - alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories | |
34 | + alias yaupd='yaourt -Sy' | |
32 | 35 | fi |
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 | |
35 | -else | |
36 | - upgrade() { | |
37 | - sudo pacman -Syu | |
38 | - } | |
39 | 36 | fi |
40 | 37 | |
41 | 38 | # 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. | |
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 | |
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 | |
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 | |
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 | |
51 | -# Additional pacman alias examples | |
39 | +alias pacupg='sudo pacman -Syu' | |
40 | +alias pacin='sudo pacman -S' | |
41 | +alias pacins='sudo pacman -U' | |
42 | +alias pacre='sudo pacman -R' | |
43 | +alias pacrem='sudo pacman -Rns' | |
44 | +alias pacrep='pacman -Si' | |
45 | +alias pacreps='pacman -Ss' | |
46 | +alias pacloc='pacman -Qi' | |
47 | +alias paclocs='pacman -Qs' | |
48 | +alias pacinsd='sudo pacman -S --asdeps' | |
49 | +alias pacmir='sudo pacman -Syy' | |
50 | +alias paclsorphans='sudo pacman -Qdt' | |
51 | +alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)' | |
52 | + | |
53 | + | |
52 | 54 | 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 | |
55 | + alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' | |
54 | 56 | elif (( $+commands[abs] )); then |
55 | - alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories | |
57 | + alias pacupd='sudo pacman -Sy && sudo abs' | |
56 | 58 | elif (( $+commands[aur] )); then |
57 | - alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories | |
59 | + alias pacupd='sudo pacman -Sy && sudo aur' | |
58 | 60 | else |
59 | - alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories | |
61 | + alias pacupd='sudo pacman -Sy' | |
60 | 62 | fi |
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 | |
63 | 63 | |
64 | -# https://bbs.archlinux.org/viewtopic.php?id=93683 | |
65 | 64 | 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}' | |
65 | + # Source: https://bbs.archlinux.org/viewtopic.php?id=93683 | |
66 | + LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \ | |
67 | + awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}' | |
67 | 68 | } |
68 | 69 | |
69 | -alias paclsorphans='sudo pacman -Qdt' | |
70 | -alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)' | |
71 | - | |
72 | 70 | pacdisowned() { |
71 | + emulate -L zsh | |
72 | + | |
73 | 73 | tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ |
74 | 74 | db=$tmp/db |
75 | 75 | fs=$tmp/fs |
... | ... | @@ -79,21 +79,21 @@ pacdisowned() { |
79 | 79 | |
80 | 80 | pacman -Qlq | sort -u > "$db" |
81 | 81 | |
82 | - find /bin /etc /lib /sbin /usr \ | |
83 | - ! -name lost+found \ | |
84 | - \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" | |
82 | + find /bin /etc /lib /sbin /usr ! -name lost+found \ | |
83 | + \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" | |
85 | 84 | |
86 | 85 | comm -23 "$fs" "$db" |
87 | 86 | } |
88 | 87 | |
89 | 88 | pacmanallkeys() { |
90 | - # Get all keys for developers and trusted users | |
91 | - curl https://www.archlinux.org/{developers,trustedusers}/ | | |
92 | - awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' | | |
93 | - xargs sudo pacman-key --recv-keys | |
89 | + emulate -L zsh | |
90 | + curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \ | |
91 | + awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \ | |
92 | + xargs sudo pacman-key --recv-keys | |
94 | 93 | } |
95 | 94 | |
96 | 95 | pacmansignkeys() { |
96 | + emulate -L zsh | |
97 | 97 | for key in $*; do |
98 | 98 | sudo pacman-key --recv-keys $key |
99 | 99 | sudo pacman-key --lsign-key $key |
... | ... | @@ -17,7 +17,12 @@ function branch_prompt_info() { |
17 | 17 | # Mercurial repository |
18 | 18 | if [[ -d "${current_dir}/.hg" ]] |
19 | 19 | then |
20 | - echo '☿' $(<"$current_dir/.hg/branch") | |
20 | + if [[ -f "$current_dir/.hg/branch" ]] | |
21 | + then | |
22 | + echo '☿' $(<"$current_dir/.hg/branch") | |
23 | + else | |
24 | + echo '☿ default' | |
25 | + fi | |
21 | 26 | return; |
22 | 27 | fi |
23 | 28 | # Defines path as parent directory and keeps looking for :) |
... | ... | @@ -58,7 +58,7 @@ bundle_install() { |
58 | 58 | if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then |
59 | 59 | if [[ "$OSTYPE" = darwin* ]] |
60 | 60 | then |
61 | - local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" | |
61 | + local cores_num="$(sysctl -n hw.ncpu)" | |
62 | 62 | else |
63 | 63 | local cores_num="$(nproc)" |
64 | 64 | fi |
1 | 1 | # CakePHP 3 basic command completion |
2 | 2 | _cakephp3_get_command_list () { |
3 | - cakephp3commands=($(bin/cake completion commands));printf "%s\n" "${cakephp3commands[@]}" | |
3 | + bin/cake Completion commands | |
4 | +} | |
5 | + | |
6 | +_cakephp3_get_sub_command_list () { | |
7 | + bin/cake Completion subcommands ${words[2]} | |
8 | +} | |
9 | + | |
10 | +_cakephp3_get_3rd_argument () { | |
11 | + bin/cake ${words[2]} ${words[3]} | \grep '\-\ '| \awk '{print $2}' | |
4 | 12 | } |
5 | 13 | |
6 | 14 | _cakephp3 () { |
7 | - if [ -f bin/cake ]; then | |
8 | - compadd `_cakephp3_get_command_list` | |
15 | + local -a has3rdargument | |
16 | + has3rdargument=("all" "controller" "fixture" "model" "template") | |
17 | + if [ -f bin/cake ]; then | |
18 | + if (( CURRENT == 2 )); then | |
19 | + compadd $(_cakephp3_get_command_list) | |
20 | + fi | |
21 | + if (( CURRENT == 3 )); then | |
22 | + compadd $(_cakephp3_get_sub_command_list) | |
23 | + fi | |
24 | + if (( CURRENT == 4 )); then | |
25 | + if [[ ${has3rdargument[(i)${words[3]}]} -le ${#has3rdargument} ]]; then | |
26 | + compadd $(_cakephp3_get_3rd_argument) | |
27 | + fi | |
28 | + fi | |
9 | 29 | fi |
10 | 30 | } |
11 | 31 | |
... | ... | @@ -14,6 +34,5 @@ compdef _cakephp3 cake |
14 | 34 | |
15 | 35 | #Alias |
16 | 36 | alias c3='bin/cake' |
17 | - | |
18 | 37 | alias c3cache='bin/cake orm_cache clear' |
19 | 38 | alias c3migrate='bin/cake migrations migrate' |
... | ... | @@ -0,0 +1,11 @@ |
1 | +# cask plugin | |
2 | + | |
3 | +Loads `cask` completion from non-standard locations, such as if installed | |
4 | +via Homebrew or others. To enable it, add `cask` to your plugins array: | |
5 | + | |
6 | +```zsh | |
7 | +plugins=(... cask) | |
8 | +``` | |
9 | + | |
10 | +Make sure you have the `cask` directory in your `$PATH` before loading | |
11 | +Oh My Zsh, otherwise you'll get the "command not found" error. |
1 | -if which cask &> /dev/null; then | |
2 | - source $(dirname $(which cask))/../etc/cask_completion.zsh | |
3 | -else | |
4 | - print "zsh cask plugin: cask not found" | |
5 | -fi | |
1 | +() { | |
2 | + emulate -L zsh | |
3 | + | |
4 | + if ! (( $+commands[cask] )); then | |
5 | + print "zsh cask plugin: cask command not found" >&2 | |
6 | + return | |
7 | + fi | |
8 | + | |
9 | + cask_base=${commands[cask]:h:h} | |
10 | + | |
11 | + # Plain cask installation location (for Cask 0.7.2 and earlier) | |
12 | + comp_files=($cask_base/etc/cask_completion.zsh) | |
13 | + | |
14 | + # Mac Homebrew installs the completion in a different location | |
15 | + if (( $+commands[brew] )); then | |
16 | + comp_files+=($(brew --prefix)/share/zsh/site-functions/cask_completion.zsh) | |
17 | + fi | |
18 | + | |
19 | + # Load first found file | |
20 | + for f in $comp_files; do | |
21 | + if [[ -f "$f" ]]; then | |
22 | + source "$f" | |
23 | + break | |
24 | + fi | |
25 | + done | |
26 | +} |
... | ... | @@ -8,11 +8,21 @@ |
8 | 8 | # pushd +N: start counting from left of `dirs' output |
9 | 9 | # pushd -N: start counting from right of `dirs' output |
10 | 10 | |
11 | +switch-to-dir () { | |
12 | + while ! builtin pushd -q $1 &>/dev/null; do | |
13 | + # We found a missing directory: pop it out of the dir stack | |
14 | + builtin popd -q $1 | |
15 | + | |
16 | + # Stop trying if there are no more directories in the dir stack | |
17 | + [[ ${#dirstack} -eq 0 ]] && break | |
18 | + done | |
19 | +} | |
20 | + | |
11 | 21 | insert-cycledleft () { |
12 | 22 | emulate -L zsh |
13 | 23 | setopt nopushdminus |
14 | 24 | |
15 | - builtin pushd -q +1 &>/dev/null || true | |
25 | + switch-to-dir +1 | |
16 | 26 | zle reset-prompt |
17 | 27 | } |
18 | 28 | zle -N insert-cycledleft |
... | ... | @@ -21,7 +31,7 @@ insert-cycledright () { |
21 | 31 | emulate -L zsh |
22 | 32 | setopt nopushdminus |
23 | 33 | |
24 | - builtin pushd -q -0 &>/dev/null || true | |
34 | + switch-to-dir -0 | |
25 | 35 | zle reset-prompt |
26 | 36 | } |
27 | 37 | zle -N insert-cycledright |
1 | 1 | # Docker-compose plugin for oh my zsh |
2 | 2 | |
3 | -A copy of the completion script from the [docker-compose](1) git repo. | |
3 | +A copy of the completion script from the [docker-compose](https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose) git repo. | |
4 | 4 | |
5 | -[1]:[https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose] |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | # ------------------------------------------------------------------------- |
8 | 8 | # Version |
9 | 9 | # ------- |
10 | -# 0.1.0 | |
10 | +# 1.5.0 | |
11 | 11 | # ------------------------------------------------------------------------- |
12 | 12 | # Authors |
13 | 13 | # ------- |
... | ... | @@ -19,58 +19,69 @@ |
19 | 19 | # * @felixr docker zsh completion script : https://github.com/felixr/docker-zsh-completion |
20 | 20 | # ------------------------------------------------------------------------- |
21 | 21 | |
22 | -# For compatibility reasons, Compose and therefore its completion supports several | |
23 | -# stack compositon files as listed here, in descending priority. | |
24 | -# Support for these filenames might be dropped in some future version. | |
25 | -__docker-compose_compose_file() { | |
26 | - local file | |
27 | - for file in docker-compose.y{,a}ml fig.y{,a}ml ; do | |
28 | - [ -e $file ] && { | |
29 | - echo $file | |
30 | - return | |
31 | - } | |
32 | - done | |
33 | - echo docker-compose.yml | |
22 | +__docker-compose_q() { | |
23 | + docker-compose 2>/dev/null $compose_options "$@" | |
34 | 24 | } |
35 | 25 | |
36 | -# Extracts all service names from docker-compose.yml. | |
37 | -___docker-compose_all_services_in_compose_file() { | |
26 | +# All services defined in docker-compose.yml | |
27 | +__docker-compose_all_services_in_compose_file() { | |
38 | 28 | local already_selected |
39 | 29 | local -a services |
40 | - already_selected=$(echo ${words[@]} | tr " " "|") | |
41 | - awk -F: '/^[a-zA-Z0-9]/{print $1}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | grep -Ev "$already_selected" | |
30 | + already_selected=$(echo $words | tr " " "|") | |
31 | + __docker-compose_q config --services \ | |
32 | + | grep -Ev "^(${already_selected})$" | |
42 | 33 | } |
43 | 34 | |
44 | 35 | # All services, even those without an existing container |
45 | 36 | __docker-compose_services_all() { |
46 | - services=$(___docker-compose_all_services_in_compose_file) | |
47 | - _alternative "args:services:($services)" | |
37 | + [[ $PREFIX = -* ]] && return 1 | |
38 | + integer ret=1 | |
39 | + services=$(__docker-compose_all_services_in_compose_file) | |
40 | + _alternative "args:services:($services)" && ret=0 | |
41 | + | |
42 | + return ret | |
48 | 43 | } |
49 | 44 | |
50 | 45 | # All services that have an entry with the given key in their docker-compose.yml section |
51 | -___docker-compose_services_with_key() { | |
46 | +__docker-compose_services_with_key() { | |
52 | 47 | local already_selected |
53 | 48 | local -a buildable |
54 | - already_selected=$(echo ${words[@]} | tr " " "|") | |
49 | + already_selected=$(echo $words | tr " " "|") | |
55 | 50 | # flatten sections to one line, then filter lines containing the key and return section name. |
56 | - awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | awk -F: -v key=": +$1:" '$0 ~ key {print $1}' 2>/dev/null | grep -Ev "$already_selected" | |
51 | + __docker-compose_q config \ | |
52 | + | sed -n -e '/^services:/,/^[^ ]/p' \ | |
53 | + | sed -n 's/^ //p' \ | |
54 | + | awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \ | |
55 | + | grep " \+$1:" \ | |
56 | + | cut -d: -f1 \ | |
57 | + | grep -Ev "^(${already_selected})$" | |
57 | 58 | } |
58 | 59 | |
59 | 60 | # All services that are defined by a Dockerfile reference |
60 | 61 | __docker-compose_services_from_build() { |
61 | - buildable=$(___docker-compose_services_with_key build) | |
62 | - _alternative "args:buildable services:($buildable)" | |
62 | + [[ $PREFIX = -* ]] && return 1 | |
63 | + integer ret=1 | |
64 | + buildable=$(__docker-compose_services_with_key build) | |
65 | + _alternative "args:buildable services:($buildable)" && ret=0 | |
66 | + | |
67 | + return ret | |
63 | 68 | } |
64 | 69 | |
65 | 70 | # All services that are defined by an image |
66 | 71 | __docker-compose_services_from_image() { |
67 | - pullable=$(___docker-compose_services_with_key image) | |
68 | - _alternative "args:pullable services:($pullable)" | |
72 | + [[ $PREFIX = -* ]] && return 1 | |
73 | + integer ret=1 | |
74 | + pullable=$(__docker-compose_services_with_key image) | |
75 | + _alternative "args:pullable services:($pullable)" && ret=0 | |
76 | + | |
77 | + return ret | |
69 | 78 | } |
70 | 79 | |
71 | 80 | __docker-compose_get_services() { |
72 | - local kind expl | |
73 | - declare -a running stopped lines args services | |
81 | + [[ $PREFIX = -* ]] && return 1 | |
82 | + integer ret=1 | |
83 | + local kind | |
84 | + declare -a running paused stopped lines args services | |
74 | 85 | |
75 | 86 | docker_status=$(docker ps > /dev/null 2>&1) |
76 | 87 | if [ $? -ne 0 ]; then |
... | ... | @@ -80,64 +91,78 @@ __docker-compose_get_services() { |
80 | 91 | |
81 | 92 | kind=$1 |
82 | 93 | shift |
83 | - [[ $kind = (stopped|all) ]] && args=($args -a) | |
94 | + [[ $kind =~ (stopped|all) ]] && args=($args -a) | |
84 | 95 | |
85 | - lines=(${(f)"$(_call_program commands docker ps ${args})"}) | |
86 | - services=(${(f)"$(_call_program commands docker-compose 2>/dev/null ${compose_file:+-f $compose_file} ${compose_project:+-p $compose_project} ps -q)"}) | |
96 | + lines=(${(f)"$(_call_program commands docker $docker_options ps $args)"}) | |
97 | + services=(${(f)"$(_call_program commands docker-compose 2>/dev/null $compose_options ps -q)"}) | |
87 | 98 | |
88 | 99 | # Parse header line to find columns |
89 | 100 | local i=1 j=1 k header=${lines[1]} |
90 | 101 | declare -A begin end |
91 | - while (( $j < ${#header} - 1 )) { | |
92 | - i=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 1)) | |
93 | - j=$(( $i + ${${header[$i,-1]}[(i) ]} - 1)) | |
94 | - k=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 2)) | |
95 | - begin[${header[$i,$(($j-1))]}]=$i | |
96 | - end[${header[$i,$(($j-1))]}]=$k | |
97 | - } | |
102 | + while (( j < ${#header} - 1 )); do | |
103 | + i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) | |
104 | + j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) | |
105 | + k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) | |
106 | + begin[${header[$i,$((j-1))]}]=$i | |
107 | + end[${header[$i,$((j-1))]}]=$k | |
108 | + done | |
98 | 109 | lines=(${lines[2,-1]}) |
99 | 110 | |
100 | 111 | # Container ID |
101 | 112 | local line s name |
102 | 113 | local -a names |
103 | 114 | for line in $lines; do |
104 | - if [[ $services == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then | |
115 | + if [[ ${services[@]} == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then | |
105 | 116 | names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}}) |
106 | 117 | for name in $names; do |
107 | 118 | s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" |
108 | 119 | s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}" |
109 | - s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\:}%% ##}" | |
120 | + s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\:}%% ##}" | |
110 | 121 | if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then |
111 | 122 | stopped=($stopped $s) |
112 | 123 | else |
124 | + if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = *\(Paused\)* ]]; then | |
125 | + paused=($paused $s) | |
126 | + fi | |
113 | 127 | running=($running $s) |
114 | 128 | fi |
115 | 129 | done |
116 | 130 | fi |
117 | 131 | done |
118 | 132 | |
119 | - [[ $kind = (running|all) ]] && _describe -t services-running "running services" running | |
120 | - [[ $kind = (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped | |
133 | + [[ $kind =~ (running|all) ]] && _describe -t services-running "running services" running "$@" && ret=0 | |
134 | + [[ $kind =~ (paused|all) ]] && _describe -t services-paused "paused services" paused "$@" && ret=0 | |
135 | + [[ $kind =~ (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped "$@" && ret=0 | |
136 | + | |
137 | + return ret | |
138 | +} | |
139 | + | |
140 | +__docker-compose_pausedservices() { | |
141 | + [[ $PREFIX = -* ]] && return 1 | |
142 | + __docker-compose_get_services paused "$@" | |
121 | 143 | } |
122 | 144 | |
123 | 145 | __docker-compose_stoppedservices() { |
146 | + [[ $PREFIX = -* ]] && return 1 | |
124 | 147 | __docker-compose_get_services stopped "$@" |
125 | 148 | } |
126 | 149 | |
127 | 150 | __docker-compose_runningservices() { |
151 | + [[ $PREFIX = -* ]] && return 1 | |
128 | 152 | __docker-compose_get_services running "$@" |
129 | 153 | } |
130 | 154 | |
131 | -__docker-compose_services () { | |
155 | +__docker-compose_services() { | |
156 | + [[ $PREFIX = -* ]] && return 1 | |
132 | 157 | __docker-compose_get_services all "$@" |
133 | 158 | } |
134 | 159 | |
135 | 160 | __docker-compose_caching_policy() { |
136 | - oldp=( "$1"(Nmh+1) ) # 1 hour | |
161 | + oldp=( "$1"(Nmh+1) ) # 1 hour | |
137 | 162 | (( $#oldp )) |
138 | 163 | } |
139 | 164 | |
140 | -__docker-compose_commands () { | |
165 | +__docker-compose_commands() { | |
141 | 166 | local cache_policy |
142 | 167 | |
143 | 168 | zstyle -s ":completion:${curcontext}:" cache-policy cache_policy |
... | ... | @@ -151,110 +176,204 @@ __docker-compose_commands () { |
151 | 176 | local -a lines |
152 | 177 | lines=(${(f)"$(_call_program commands docker-compose 2>&1)"}) |
153 | 178 | _docker_compose_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) |
154 | - _store_cache docker_compose_subcommands _docker_compose_subcommands | |
179 | + (( $#_docker_compose_subcommands > 0 )) && _store_cache docker_compose_subcommands _docker_compose_subcommands | |
155 | 180 | fi |
156 | 181 | _describe -t docker-compose-commands "docker-compose command" _docker_compose_subcommands |
157 | 182 | } |
158 | 183 | |
159 | -__docker-compose_subcommand () { | |
160 | - local -a _command_args | |
184 | +__docker-compose_subcommand() { | |
185 | + local opts_help opts_force_recreate opts_no_recreate opts_no_build opts_remove_orphans opts_timeout opts_no_color opts_no_deps | |
186 | + | |
187 | + opts_help='(: -)--help[Print usage]' | |
188 | + opts_force_recreate="(--no-recreate)--force-recreate[Recreate containers even if their configuration and image haven't changed. Incompatible with --no-recreate.]" | |
189 | + opts_no_recreate="(--force-recreate)--no-recreate[If containers already exist, don't recreate them. Incompatible with --force-recreate.]" | |
190 | + opts_no_build="(--build)--no-build[Don't build an image, even if it's missing.]" | |
191 | + opts_remove_orphans="--remove-orphans[Remove containers for services not defined in the Compose file]" | |
192 | + opts_timeout=('(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: ") | |
193 | + opts_no_color='--no-color[Produce monochrome output.]' | |
194 | + opts_no_deps="--no-deps[Don't start linked services.]" | |
195 | + | |
161 | 196 | integer ret=1 |
197 | + | |
162 | 198 | case "$words[1]" in |
163 | 199 | (build) |
164 | 200 | _arguments \ |
165 | - '--no-cache[Do not use cache when building the image]' \ | |
201 | + $opts_help \ | |
202 | + '--force-rm[Always remove intermediate containers.]' \ | |
203 | + '--no-cache[Do not use cache when building the image.]' \ | |
204 | + '--pull[Always attempt to pull a newer version of the image.]' \ | |
166 | 205 | '*:services:__docker-compose_services_from_build' && ret=0 |
167 | 206 | ;; |
207 | + (bundle) | |
208 | + _arguments \ | |
209 | + $opts_help \ | |
210 | + '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0 | |
211 | + ;; | |
212 | + (config) | |
213 | + _arguments \ | |
214 | + $opts_help \ | |
215 | + '(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \ | |
216 | + '--services[Print the service names, one per line.]' && ret=0 | |
217 | + ;; | |
218 | + (create) | |
219 | + _arguments \ | |
220 | + $opts_help \ | |
221 | + $opts_force_recreate \ | |
222 | + $opts_no_recreate \ | |
223 | + $opts_no_build \ | |
224 | + "(--no-build)--build[Build images before creating containers.]" \ | |
225 | + '*:services:__docker-compose_services_all' && ret=0 | |
226 | + ;; | |
227 | + (down) | |
228 | + _arguments \ | |
229 | + $opts_help \ | |
230 | + "--rmi[Remove images. Type must be one of: 'all': Remove all images used by any service. 'local': Remove only images that don't have a custom tag set by the \`image\` field.]:type:(all local)" \ | |
231 | + '(-v --volumes)'{-v,--volumes}"[Remove named volumes declared in the \`volumes\` section of the Compose file and anonymous volumes attached to containers.]" \ | |
232 | + $opts_remove_orphans && ret=0 | |
233 | + ;; | |
234 | + (events) | |
235 | + _arguments \ | |
236 | + $opts_help \ | |
237 | + '--json[Output events as a stream of json objects]' \ | |
238 | + '*:services:__docker-compose_services_all' && ret=0 | |
239 | + ;; | |
240 | + (exec) | |
241 | + _arguments \ | |
242 | + $opts_help \ | |
243 | + '-d[Detached mode: Run command in the background.]' \ | |
244 | + '--privileged[Give extended privileges to the process.]' \ | |
245 | + '--user=[Run the command as this user.]:username:_users' \ | |
246 | + '-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \ | |
247 | + '--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \ | |
248 | + '(-):running services:__docker-compose_runningservices' \ | |
249 | + '(-):command: _command_names -e' \ | |
250 | + '*::arguments: _normal' && ret=0 | |
251 | + ;; | |
168 | 252 | (help) |
169 | 253 | _arguments ':subcommand:__docker-compose_commands' && ret=0 |
170 | 254 | ;; |
171 | 255 | (kill) |
172 | 256 | _arguments \ |
257 | + $opts_help \ | |
173 | 258 | '-s[SIGNAL to send to the container. Default signal is SIGKILL.]:signal:_signals' \ |
174 | 259 | '*:running services:__docker-compose_runningservices' && ret=0 |
175 | 260 | ;; |
176 | 261 | (logs) |
177 | 262 | _arguments \ |
178 | - '--no-color[Produce monochrome output.]' \ | |
263 | + $opts_help \ | |
264 | + '(-f --follow)'{-f,--follow}'[Follow log output]' \ | |
265 | + $opts_no_color \ | |
266 | + '--tail=[Number of lines to show from the end of the logs for each container.]:number of lines: ' \ | |
267 | + '(-t --timestamps)'{-t,--timestamps}'[Show timestamps]' \ | |
179 | 268 | '*:services:__docker-compose_services_all' && ret=0 |
180 | 269 | ;; |
181 | - (migrate-to-labels) | |
270 | + (pause) | |
182 | 271 | _arguments \ |
183 | - '(-):Recreate containers to add labels' && ret=0 | |
272 | + $opts_help \ | |
273 | + '*:running services:__docker-compose_runningservices' && ret=0 | |
184 | 274 | ;; |
185 | 275 | (port) |
186 | 276 | _arguments \ |
187 | - '--protocol=-[tcp or udap (defaults to tcp)]:protocol:(tcp udp)' \ | |
188 | - '--index=-[index of the container if there are mutiple instances of a service (defaults to 1)]:index: ' \ | |
277 | + $opts_help \ | |
278 | + '--protocol=[tcp or udp \[default: tcp\]]:protocol:(tcp udp)' \ | |
279 | + '--index=[index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \ | |
189 | 280 | '1:running services:__docker-compose_runningservices' \ |
190 | 281 | '2:port:_ports' && ret=0 |
191 | 282 | ;; |
192 | 283 | (ps) |
193 | 284 | _arguments \ |
285 | + $opts_help \ | |
194 | 286 | '-q[Only display IDs]' \ |
195 | 287 | '*:services:__docker-compose_services_all' && ret=0 |
196 | 288 | ;; |
197 | 289 | (pull) |
198 | 290 | _arguments \ |
199 | - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ | |
291 | + $opts_help \ | |
292 | + '--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \ | |
200 | 293 | '*:services:__docker-compose_services_from_image' && ret=0 |
201 | 294 | ;; |
295 | + (push) | |
296 | + _arguments \ | |
297 | + $opts_help \ | |
298 | + '--ignore-push-failures[Push what it can and ignores images with push failures.]' \ | |
299 | + '*:services:__docker-compose_services' && ret=0 | |
300 | + ;; | |
202 | 301 | (rm) |
203 | 302 | _arguments \ |
303 | + $opts_help \ | |
204 | 304 | '(-f --force)'{-f,--force}"[Don't ask to confirm removal]" \ |
205 | - '-v[Remove volumes associated with containers]' \ | |
305 | + '-v[Remove any anonymous volumes attached to containers]' \ | |
206 | 306 | '*:stopped services:__docker-compose_stoppedservices' && ret=0 |
207 | 307 | ;; |
208 | 308 | (run) |
209 | 309 | _arguments \ |
210 | - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ | |
310 | + $opts_help \ | |
211 | 311 | '-d[Detached mode: Run container in the background, print new container name.]' \ |
212 | - '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \ | |
213 | 312 | '*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \ |
214 | - '(-u --user)'{-u,--user=-}'[Run as specified username or uid]:username or uid:_users' \ | |
215 | - "--no-deps[Don't start linked services.]" \ | |
313 | + '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \ | |
314 | + '--name=[Assign a name to the container]:name: ' \ | |
315 | + $opts_no_deps \ | |
316 | + '(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \ | |
216 | 317 | '--rm[Remove container after run. Ignored in detached mode.]' \ |
217 | 318 | "--service-ports[Run command with the service's ports enabled and mapped to the host.]" \ |
218 | 319 | '-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \ |
320 | + '(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \ | |
321 | + '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \ | |
219 | 322 | '(-):services:__docker-compose_services' \ |
220 | 323 | '(-):command: _command_names -e' \ |
221 | 324 | '*::arguments: _normal' && ret=0 |
222 | 325 | ;; |
223 | 326 | (scale) |
224 | - _arguments '*:running services:__docker-compose_runningservices' && ret=0 | |
327 | + _arguments \ | |
328 | + $opts_help \ | |
329 | + $opts_timeout \ | |
330 | + '*:running services:__docker-compose_runningservices' && ret=0 | |
225 | 331 | ;; |
226 | 332 | (start) |
227 | - _arguments '*:stopped services:__docker-compose_stoppedservices' && ret=0 | |
333 | + _arguments \ | |
334 | + $opts_help \ | |
335 | + '*:stopped services:__docker-compose_stoppedservices' && ret=0 | |
228 | 336 | ;; |
229 | 337 | (stop|restart) |
230 | 338 | _arguments \ |
231 | - '(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \ | |
339 | + $opts_help \ | |
340 | + $opts_timeout \ | |
232 | 341 | '*:running services:__docker-compose_runningservices' && ret=0 |
233 | 342 | ;; |
343 | + (unpause) | |
344 | + _arguments \ | |
345 | + $opts_help \ | |
346 | + '*:paused services:__docker-compose_pausedservices' && ret=0 | |
347 | + ;; | |
234 | 348 | (up) |
235 | 349 | _arguments \ |
236 | - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ | |
237 | - '-d[Detached mode: Run containers in the background, print new container names.]' \ | |
238 | - '--no-color[Produce monochrome output.]' \ | |
239 | - "--no-deps[Don't start linked services.]" \ | |
240 | - "--no-recreate[If containers already exist, don't recreate them.]" \ | |
241 | - "--no-build[Don't build an image, even if it's missing]" \ | |
242 | - '(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \ | |
243 | - "--x-smart-recreate[Only recreate containers whose configuration or image needs to be updated. (EXPERIMENTAL)]" \ | |
350 | + $opts_help \ | |
351 | + '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \ | |
352 | + $opts_no_color \ | |
353 | + $opts_no_deps \ | |
354 | + $opts_force_recreate \ | |
355 | + $opts_no_recreate \ | |
356 | + $opts_no_build \ | |
357 | + "(--no-build)--build[Build images before starting containers.]" \ | |
358 | + "(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \ | |
359 | + '(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \ | |
360 | + $opts_remove_orphans \ | |
244 | 361 | '*:services:__docker-compose_services_all' && ret=0 |
245 | 362 | ;; |
246 | 363 | (version) |
247 | 364 | _arguments \ |
365 | + $opts_help \ | |
248 | 366 | "--short[Shows only Compose's version number.]" && ret=0 |
249 | 367 | ;; |
250 | 368 | (*) |
251 | - _message 'Unknown sub command' | |
369 | + _message 'Unknown sub command' && ret=1 | |
370 | + ;; | |
252 | 371 | esac |
253 | 372 | |
254 | 373 | return ret |
255 | 374 | } |
256 | 375 | |
257 | -_docker-compose () { | |
376 | +_docker-compose() { | |
258 | 377 | # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`. |
259 | 378 | # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. |
260 | 379 | if [[ $service != docker-compose ]]; then |
... | ... | @@ -262,34 +381,62 @@ _docker-compose () { |
262 | 381 | return |
263 | 382 | fi |
264 | 383 | |
265 | - local curcontext="$curcontext" state line ret=1 | |
384 | + local curcontext="$curcontext" state line | |
385 | + integer ret=1 | |
266 | 386 | typeset -A opt_args |
267 | 387 | |
268 | 388 | _arguments -C \ |
269 | 389 | '(- :)'{-h,--help}'[Get help]' \ |
270 | - '--verbose[Show more output]' \ | |
271 | - '(- :)'{-v,--version}'[Print version and exit]' \ | |
272 | 390 | '(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \ |
273 | 391 | '(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \ |
392 | + '--verbose[Show more output]' \ | |
393 | + '(- :)'{-v,--version}'[Print version and exit]' \ | |
394 | + '(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \ | |
395 | + '--tls[Use TLS; implied by --tlsverify]' \ | |
396 | + '--tlscacert=[Trust certs signed only by this CA]:ca path:' \ | |
397 | + '--tlscert=[Path to TLS certificate file]:client cert path:' \ | |
398 | + '--tlskey=[Path to TLS key file]:tls key path:' \ | |
399 | + '--tlsverify[Use TLS and verify the remote]' \ | |
400 | + "--skip-hostname-check[Don't check the daemon's hostname against the name specified in the client certificate (for example if your docker host is an IP address)]" \ | |
274 | 401 | '(-): :->command' \ |
275 | 402 | '(-)*:: :->option-or-argument' && ret=0 |
276 | 403 | |
277 | - local counter=1 | |
278 | - #local compose_file compose_project | |
279 | - while [ $counter -lt ${#words[@]} ]; do | |
280 | - case "${words[$counter]}" in | |
281 | - -f|--file) | |
282 | - (( counter++ )) | |
283 | - compose_file="${words[$counter]}" | |
284 | - ;; | |
285 | - -p|--project-name) | |
286 | - (( counter++ )) | |
287 | - compose_project="${words[$counter]}" | |
288 | - ;; | |
289 | - *) | |
290 | - ;; | |
291 | - esac | |
292 | - (( counter++ )) | |
404 | + local -a relevant_compose_flags relevant_docker_flags compose_options docker_options | |
405 | + | |
406 | + relevant_compose_flags=( | |
407 | + "--file" "-f" | |
408 | + "--host" "-H" | |
409 | + "--project-name" "-p" | |
410 | + "--tls" | |
411 | + "--tlscacert" | |
412 | + "--tlscert" | |
413 | + "--tlskey" | |
414 | + "--tlsverify" | |
415 | + "--skip-hostname-check" | |
416 | + ) | |
417 | + | |
418 | + relevant_docker_flags=( | |
419 | + "--host" "-H" | |
420 | + "--tls" | |
421 | + "--tlscacert" | |
422 | + "--tlscert" | |
423 | + "--tlskey" | |
424 | + "--tlsverify" | |
425 | + ) | |
426 | + | |
427 | + for k in "${(@k)opt_args}"; do | |
428 | + if [[ -n "${relevant_docker_flags[(r)$k]}" ]]; then | |
429 | + docker_options+=$k | |
430 | + if [[ -n "$opt_args[$k]" ]]; then | |
431 | + docker_options+=$opt_args[$k] | |
432 | + fi | |
433 | + fi | |
434 | + if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then | |
435 | + compose_options+=$k | |
436 | + if [[ -n "$opt_args[$k]" ]]; then | |
437 | + compose_options+=$opt_args[$k] | |
438 | + fi | |
439 | + fi | |
293 | 440 | done |
294 | 441 | |
295 | 442 | case $state in |
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | # - Configuration changes made at runtime are applied to all frames. |
11 | 11 | |
12 | 12 | |
13 | -if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then | |
13 | +if "$ZSH/tools/require_tool.sh" emacs 24 2>/dev/null ; then | |
14 | 14 | export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" |
15 | 15 | |
16 | 16 | # set EDITOR if not already defined. |
... | ... | @@ -18,15 +18,14 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then |
18 | 18 | |
19 | 19 | alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait" |
20 | 20 | alias e=emacs |
21 | + # open terminal emacsclient | |
22 | + alias te="$EMACS_PLUGIN_LAUNCHER -nw" | |
21 | 23 | |
22 | 24 | # same than M-x eval but from outside Emacs. |
23 | 25 | alias eeval="$EMACS_PLUGIN_LAUNCHER --eval" |
24 | 26 | # create a new X frame |
25 | 27 | alias eframe='emacsclient --alternate-editor "" --create-frame' |
26 | 28 | |
27 | - # to code all night long | |
28 | - alias emasc=emacs | |
29 | - alias emcas=emacs | |
30 | 29 | |
31 | 30 | # Write to standard output the path to the file |
32 | 31 | # opened in the current buffer. |
1 | 1 | #!/bin/sh |
2 | 2 | |
3 | -# get list of available X windows. | |
4 | -x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` | |
3 | +_emacsfun() | |
4 | +{ | |
5 | + # get list of emacs frames. | |
6 | + frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'` | |
5 | 7 | |
6 | -if [ -z "$x" ] || [ "$x" = "nil" ] ;then | |
7 | - # Create one if there is no X window yet. | |
8 | - emacsclient --alternate-editor "" --create-frame "$@" | |
8 | + if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then | |
9 | + # prevent creating another X frame if there is at least one present. | |
10 | + emacsclient --alternate-editor "" "$@" | |
11 | + else | |
12 | + # Create one if there is no X window yet. | |
13 | + emacsclient --alternate-editor "" --create-frame "$@" | |
14 | + fi | |
15 | +} | |
16 | + | |
17 | + | |
18 | +# adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh | |
19 | +# If the second argument is - then write stdin to a tempfile and open the | |
20 | +# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh) | |
21 | +if [ "$#" -ge "2" -a "$2" = "-" ] | |
22 | +then | |
23 | + tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)" | |
24 | + cat - > "$tempfile" | |
25 | + _emacsfun --no-wait $tempfile | |
9 | 26 | else |
10 | - # prevent creating another X frame if there is at least one present. | |
11 | - emacsclient --alternate-editor "" "$@" | |
27 | + _emacsfun "$@" | |
12 | 28 | fi |
... | ... | @@ -0,0 +1,89 @@ |
1 | +_FOSSIL_PROMPT="" | |
2 | + | |
3 | +# Prefix at the very beginning of the prompt, before the branch name | |
4 | +ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}" | |
5 | + | |
6 | +# At the very end of the prompt | |
7 | +ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})" | |
8 | + | |
9 | +# Text to display if the branch is dirty | |
10 | +ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖" | |
11 | + | |
12 | +# Text to display if the branch is clean | |
13 | +ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔" | |
14 | + | |
15 | +function fossil_prompt_info () { | |
16 | + local _OUTPUT=`fossil branch 2>&1` | |
17 | + local _STATUS=`echo $_OUTPUT | grep "use --repo"` | |
18 | + if [ "$_STATUS" = "" ]; then | |
19 | + local _EDITED=`fossil changes` | |
20 | + local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN" | |
21 | + local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'` | |
22 | + | |
23 | + if [ "$_EDITED" != "" ]; then | |
24 | + _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY" | |
25 | + fi | |
26 | + | |
27 | + echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \ | |
28 | + "$_BRANCH" \ | |
29 | + "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \ | |
30 | + "$_EDITED_SYM"\ | |
31 | + "%{$reset_color%}" | |
32 | + fi | |
33 | +} | |
34 | + | |
35 | +function _fossil_get_command_list () { | |
36 | + fossil help -a | grep -v "Usage|Common|This is" | |
37 | +} | |
38 | + | |
39 | +function _fossil () { | |
40 | + local context state state_descr line | |
41 | + typeset -A opt_args | |
42 | + | |
43 | + _arguments \ | |
44 | + '1: :->command'\ | |
45 | + '2: :->subcommand' | |
46 | + | |
47 | + case $state in | |
48 | + command) | |
49 | + local _OUTPUT=`fossil branch 2>&1 | grep "use --repo"` | |
50 | + if [ "$_OUTPUT" = "" ]; then | |
51 | + compadd `_fossil_get_command_list` | |
52 | + else | |
53 | + compadd clone init import help version | |
54 | + fi | |
55 | + ;; | |
56 | + subcommand) | |
57 | + if [ "$words[2]" = "help" ]; then | |
58 | + compadd `_fossil_get_command_list` | |
59 | + else | |
60 | + compcall -D | |
61 | + fi | |
62 | + ;; | |
63 | + esac | |
64 | +} | |
65 | + | |
66 | +function _fossil_prompt () { | |
67 | + local current=`echo $PROMPT $RPROMPT | grep fossil` | |
68 | + | |
69 | + if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then | |
70 | + local _prompt=${PROMPT} | |
71 | + local _rprompt=${RPROMPT} | |
72 | + | |
73 | + local is_prompt=`echo $PROMPT | grep git` | |
74 | + | |
75 | + if [ "$is_prompt" = "" ]; then | |
76 | + export RPROMPT="$_rprompt"'$(fossil_prompt_info)' | |
77 | + else | |
78 | + export PROMPT="$_prompt"'$(fossil_prompt_info) ' | |
79 | + fi | |
80 | + | |
81 | + _FOSSIL_PROMPT="1" | |
82 | + fi | |
83 | +} | |
84 | + | |
85 | +compdef _fossil fossil | |
86 | + | |
87 | +autoload -U add-zsh-hook | |
88 | + | |
89 | +add-zsh-hook precmd _fossil_prompt |
... | ... | @@ -0,0 +1,21 @@ |
1 | +# `gb` plugin | |
2 | + | |
3 | +> A project based build tool for the Go programming language. | |
4 | + | |
5 | +See https://getgb.io for the full `gb` documentation | |
6 | + | |
7 | +* * * * | |
8 | + | |
9 | +- Adds completion support for all `gb` commands. | |
10 | +- Also supports completion for the [`gb-vendor` plugin](https://godoc.org/github.com/constabulary/gb/cmd/gb-vendor). | |
11 | + | |
12 | +To use it, add `gb` to your plugins array: | |
13 | +```sh | |
14 | +plugins=(... gb) | |
15 | +``` | |
16 | + | |
17 | +## Caveats | |
18 | + | |
19 | +The `git` plugin defines an alias `gb` that usually conflicts with the `gb` program. | |
20 | +If you're having trouble with it, remove it by adding `unalias gb` at the end of your | |
21 | +zshrc file. |
... | ... | @@ -0,0 +1,111 @@ |
1 | +#compdef gb | |
2 | +#autoload | |
3 | + | |
4 | +_gb () { | |
5 | + local ret=1 state | |
6 | + _arguments -C ':command:->command' '*::options:->options' && ret=0 | |
7 | + | |
8 | + case $state in | |
9 | + (command) | |
10 | + local -a subcommands | |
11 | + subcommands=( | |
12 | + "build:build a package" | |
13 | + "doc:show documentation for a package or symbol" | |
14 | + "env:print project environment variables" | |
15 | + "generate:generate Go files by processing source" | |
16 | + "help:displays the help" | |
17 | + "info:info returns information about this project" | |
18 | + "list:list the packages named by the importpaths" | |
19 | + "test:test packages" | |
20 | + "vendor:manage your vendored dependencies" | |
21 | + ) | |
22 | + _describe -t subcommands 'gb subcommands' subcommands && ret=0 | |
23 | + ;; | |
24 | + (options) | |
25 | + case $line[1] in | |
26 | + (build) | |
27 | + _arguments \ | |
28 | + -f'[ignore cached packages]' \ | |
29 | + -F'[do not cache packages]' \ | |
30 | + -q'[decreases verbosity]' \ | |
31 | + -P'[the number of build jobs to run in parallel]' \ | |
32 | + -R'[sets the base of the project root search path]' \ | |
33 | + -dotfile'[output a dot formatted file of the build steps]' \ | |
34 | + -ldflags'["flag list" arguments to pass to the linker]' \ | |
35 | + -gcflags'["arg list" arguments to pass to the compiler]' \ | |
36 | + -race'[enable data race detection]' \ | |
37 | + -tags'["tag list" additional build tags]' | |
38 | + ;; | |
39 | + (list) | |
40 | + _arguments \ | |
41 | + -f'[alternate format for the list, using the syntax of package template]' \ | |
42 | + -s'[read format template from STDIN]' \ | |
43 | + -json'[prints output in structured JSON format]' | |
44 | + ;; | |
45 | + (test) | |
46 | + _arguments \ | |
47 | + -v'[print output from test subprocess]' \ | |
48 | + -ldflags'["flag list" arguments to pass to the linker]' \ | |
49 | + -gcflags'["arg list" arguments to pass to the compiler]' \ | |
50 | + -race'[enable data race detection]' \ | |
51 | + -tags'["tag list" additional build tags]' | |
52 | + ;; | |
53 | + (vendor) | |
54 | + _gb-vendor | |
55 | + esac | |
56 | + ;; | |
57 | + esac | |
58 | + | |
59 | + return ret | |
60 | +} | |
61 | + | |
62 | +_gb-vendor () { | |
63 | + local curcontext="$curcontext" state line | |
64 | + _arguments -C ':command:->command' '*::options:->options' | |
65 | + | |
66 | + case $state in | |
67 | + (command) | |
68 | + local -a subcommands | |
69 | + subcommands=( | |
70 | + 'delete:deletes a local dependency' | |
71 | + 'fetch:fetch a remote dependency' | |
72 | + 'list:lists dependencies, one per line' | |
73 | + 'purge:remove all unreferenced dependencies' | |
74 | + 'restore:restore dependencies from the manifest' | |
75 | + 'update:update a local dependency' | |
76 | + ) | |
77 | + _describe -t subcommands 'gb vendor subcommands' subcommands && ret=0 | |
78 | + ;; | |
79 | + (options) | |
80 | + case $line[1] in | |
81 | + (delete) | |
82 | + _arguments \ | |
83 | + -all'[remove all dependencies]' | |
84 | + ;; | |
85 | + (fetch) | |
86 | + _arguments \ | |
87 | + -branch'[fetch from a particular branch]' \ | |
88 | + -no-recurse'[do not fetch recursively]' \ | |
89 | + -tag'[fetch the specified tag]' \ | |
90 | + -revision'[fetch the specific revision from the branch (if supplied)]' \ | |
91 | + -precaire'[allow the use of insecure protocols]' \ | |
92 | + ;; | |
93 | + (list) | |
94 | + _arguments \ | |
95 | + -f'[controls the template used for printing each manifest entry]' | |
96 | + ;; | |
97 | + (restore) | |
98 | + _arguments \ | |
99 | + -precaire'[allow the use of insecure protocols]' | |
100 | + ;; | |
101 | + (update) | |
102 | + _arguments \ | |
103 | + -all'[update all dependencies in the manifest or supply a given dependency]' \ | |
104 | + -precaire'[allow the use of insecure protocols]' | |
105 | + ;; | |
106 | + esac | |
107 | + ;; | |
108 | + esac | |
109 | +} | |
110 | + | |
111 | +_gb |
... | ... | @@ -0,0 +1,31 @@ |
1 | +# Git-Flow plugin | |
2 | + | |
3 | +This plugin adds completion and aliases for the `git-flow` command. More information | |
4 | +at https://github.com/nvie/gitflow. | |
5 | + | |
6 | +Enable git-flow plugin in your zshrc file: | |
7 | +``` | |
8 | +plugins=(... git-flow) | |
9 | +``` | |
10 | + | |
11 | +## Aliases | |
12 | + | |
13 | +More information about `git-flow` commands: | |
14 | +https://github.com/nvie/gitflow/wiki/Command-Line-Arguments | |
15 | + | |
16 | +| Alias | Command | Description | | |
17 | +|---------|---------------------------|----------------------------------------| | |
18 | +| `gfl` | `git flow` | Git-Flow command | | |
19 | +| `gfli` | `git flow init` | Initialize git-flow repository | | |
20 | +| `gcd` | `git checkout develop` | Check out develop branch | | |
21 | +| `gch` | `git checkout hotfix` | Check out hotfix branch | | |
22 | +| `gcr` | `git checkout release` | Check out release branch | | |
23 | +| `gflf` | `git flow feature` | List existing feature branches | | |
24 | +| `gflh` | `git flow hotfix` | List existing hotfix branches | | |
25 | +| `gflr` | `git flow release` | List existing release branches | | |
26 | +| `gflfs` | `git flow feature start` | Start a new feature: `gflfs <name>` | | |
27 | +| `gflhs` | `git flow hotfix start` | Start a new hotfix: `gflhs <version>` | | |
28 | +| `gflrs` | `git flow release start` | Start a new release: `gflrs <version>` | | |
29 | +| `gflff` | `git flow feature finish` | Finish feature: `gflff <name>` | | |
30 | +| `gflhf` | `git flow hotfix finish` | Finish hotfix: `gflhf <version>` | | |
31 | +| `gflrf` | `git flow release finish` | Finish release: `gflrf <version>` | |
... | ... | @@ -22,9 +22,19 @@ |
22 | 22 | |
23 | 23 | #Alias |
24 | 24 | alias gfl='git flow' |
25 | +alias gfli='git flow init' | |
25 | 26 | alias gcd='git checkout develop' |
26 | 27 | alias gch='git checkout hotfix' |
27 | 28 | alias gcr='git checkout release' |
29 | +alias gflf='git flow feature' | |
30 | +alias gflh='git flow hotfix' | |
31 | +alias gflr='git flow release' | |
32 | +alias gflfs='git flow feature start' | |
33 | +alias gflhs='git flow hotfix start' | |
34 | +alias gflrs='git flow release start' | |
35 | +alias gflff='git flow feature finish' | |
36 | +alias gflhf='git flow hotfix finish' | |
37 | +alias gflrf='git flow release finish' | |
28 | 38 | |
29 | 39 | _git-flow () |
30 | 40 | { |
... | ... | @@ -46,7 +46,7 @@ alias gapa='git add --patch' |
46 | 46 | |
47 | 47 | alias gb='git branch' |
48 | 48 | alias gba='git branch -a' |
49 | -alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d' | |
49 | +alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' | |
50 | 50 | alias gbl='git blame -b -w' |
51 | 51 | alias gbnm='git branch --no-merged' |
52 | 52 | alias gbr='git branch --remote' |
... | ... | @@ -58,9 +58,11 @@ alias gbss='git bisect start' |
58 | 58 | |
59 | 59 | alias gc='git commit -v' |
60 | 60 | alias gc!='git commit -v --amend' |
61 | +alias gcn!='git commit -v --no-edit --amend' | |
61 | 62 | alias gca='git commit -v -a' |
62 | 63 | alias gca!='git commit -v -a --amend' |
63 | -alias gcan!='git commit -v -a -s --no-edit --amend' | |
64 | +alias gcan!='git commit -v -a --no-edit --amend' | |
65 | +alias gcans!='git commit -v -a -s --no-edit --amend' | |
64 | 66 | alias gcam='git commit -a -m' |
65 | 67 | alias gcb='git checkout -b' |
66 | 68 | alias gcf='git config --list' |
... | ... | @@ -68,73 +70,90 @@ alias gcl='git clone --recursive' |
68 | 70 | alias gclean='git clean -fd' |
69 | 71 | alias gpristine='git reset --hard && git clean -dfx' |
70 | 72 | alias gcm='git checkout master' |
73 | +alias gcd='git checkout develop' | |
71 | 74 | alias gcmsg='git commit -m' |
72 | 75 | alias gco='git checkout' |
73 | 76 | alias gcount='git shortlog -sn' |
74 | 77 | compdef gcount=git |
75 | 78 | alias gcp='git cherry-pick' |
79 | +alias gcpa='git cherry-pick --abort' | |
80 | +alias gcpc='git cherry-pick --continue' | |
76 | 81 | alias gcs='git commit -S' |
77 | 82 | |
78 | 83 | alias gd='git diff' |
79 | 84 | alias gdca='git diff --cached' |
80 | 85 | alias gdct='git describe --tags `git rev-list --tags --max-count=1`' |
81 | 86 | alias gdt='git diff-tree --no-commit-id --name-only -r' |
87 | +alias gdw='git diff --word-diff' | |
88 | + | |
82 | 89 | gdv() { git diff -w "$@" | view - } |
83 | 90 | compdef _git gdv=git-diff |
84 | -alias gdw='git diff --word-diff' | |
85 | 91 | |
86 | 92 | alias gf='git fetch' |
87 | 93 | alias gfa='git fetch --all --prune' |
88 | -function gfg() { git ls-files | grep $@ } | |
89 | -compdef gfg=grep | |
90 | 94 | alias gfo='git fetch origin' |
91 | 95 | |
96 | +function gfg() { git ls-files | grep $@ } | |
97 | +compdef _grep gfg | |
98 | + | |
92 | 99 | alias gg='git gui citool' |
93 | 100 | alias gga='git gui citool --amend' |
101 | + | |
94 | 102 | ggf() { |
95 | -[[ "$#" != 1 ]] && local b="$(git_current_branch)" | |
96 | -git push --force origin "${b:=$1}" | |
103 | + [[ "$#" != 1 ]] && local b="$(git_current_branch)" | |
104 | + git push --force origin "${b:=$1}" | |
97 | 105 | } |
98 | 106 | compdef _git ggf=git-checkout |
107 | + | |
99 | 108 | ggl() { |
100 | -if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then | |
101 | -git pull origin "${*}" | |
102 | -else | |
103 | -[[ "$#" == 0 ]] && local b="$(git_current_branch)" | |
104 | -git pull origin "${b:=$1}" | |
105 | -fi | |
109 | + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then | |
110 | + git pull origin "${*}" | |
111 | + else | |
112 | + [[ "$#" == 0 ]] && local b="$(git_current_branch)" | |
113 | + git pull origin "${b:=$1}" | |
114 | + fi | |
106 | 115 | } |
107 | 116 | compdef _git ggl=git-checkout |
108 | -alias ggpull='git pull origin $(git_current_branch)' | |
109 | -compdef _git ggpull=git-checkout | |
117 | + | |
110 | 118 | ggp() { |
111 | -if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then | |
112 | -git push origin "${*}" | |
113 | -else | |
114 | -[[ "$#" == 0 ]] && local b="$(git_current_branch)" | |
115 | -git push origin "${b:=$1}" | |
116 | -fi | |
119 | + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then | |
120 | + git push origin "${*}" | |
121 | + else | |
122 | + [[ "$#" == 0 ]] && local b="$(git_current_branch)" | |
123 | + git push origin "${b:=$1}" | |
124 | + fi | |
117 | 125 | } |
118 | 126 | compdef _git ggp=git-checkout |
119 | -alias ggpush='git push origin $(git_current_branch)' | |
120 | -compdef _git ggpush=git-checkout | |
127 | + | |
121 | 128 | ggpnp() { |
122 | -if [[ "$#" == 0 ]]; then | |
123 | -ggl && ggp | |
124 | -else | |
125 | -ggl "${*}" && ggp "${*}" | |
126 | -fi | |
129 | + if [[ "$#" == 0 ]]; then | |
130 | + ggl && ggp | |
131 | + else | |
132 | + ggl "${*}" && ggp "${*}" | |
133 | + fi | |
127 | 134 | } |
128 | 135 | compdef _git ggpnp=git-checkout |
129 | -alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' | |
136 | + | |
130 | 137 | ggu() { |
131 | -[[ "$#" != 1 ]] && local b="$(git_current_branch)" | |
132 | -git pull --rebase origin "${b:=$1}" | |
138 | + [[ "$#" != 1 ]] && local b="$(git_current_branch)" | |
139 | + git pull --rebase origin "${b:=$1}" | |
133 | 140 | } |
134 | 141 | compdef _git ggu=git-checkout |
142 | + | |
135 | 143 | alias ggpur='ggu' |
136 | 144 | compdef _git ggpur=git-checkout |
137 | 145 | |
146 | +alias ggpull='git pull origin $(git_current_branch)' | |
147 | +compdef _git ggpull=git-checkout | |
148 | + | |
149 | +alias ggpush='git push origin $(git_current_branch)' | |
150 | +compdef _git ggpush=git-checkout | |
151 | + | |
152 | +alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' | |
153 | +alias gpsup='git push --set-upstream origin $(git_current_branch)' | |
154 | + | |
155 | +alias ghh='git help' | |
156 | + | |
138 | 157 | alias gignore='git update-index --assume-unchanged' |
139 | 158 | alias gignored='git ls-files -v | grep "^[[:lower:]]"' |
140 | 159 | alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' |
... | ... | @@ -155,6 +174,7 @@ alias glo='git log --oneline --decorate' |
155 | 174 | alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
156 | 175 | 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" |
157 | 176 | alias glog='git log --oneline --decorate --graph' |
177 | +alias gloga='git log --oneline --decorate --graph --all' | |
158 | 178 | alias glp="_git_log_prettily" |
159 | 179 | compdef _git glp=git-log |
160 | 180 | |
... | ... | @@ -196,8 +216,9 @@ alias gsps='git show --pretty=short --show-signature' |
196 | 216 | alias gsr='git svn rebase' |
197 | 217 | alias gss='git status -s' |
198 | 218 | alias gst='git status' |
199 | -alias gsta='git stash' | |
219 | +alias gsta='git stash save' | |
200 | 220 | alias gstaa='git stash apply' |
221 | +alias gstc='git stash clear' | |
201 | 222 | alias gstd='git stash drop' |
202 | 223 | alias gstl='git stash list' |
203 | 224 | alias gstp='git stash pop' |
... | ... | @@ -104,6 +104,7 @@ __git_zsh_bash_func () |
104 | 104 | |
105 | 105 | local expansion=$(__git_aliased_command "$command") |
106 | 106 | if [ -n "$expansion" ]; then |
107 | + words[1]=$expansion | |
107 | 108 | completion_func="_git_${expansion//-/_}" |
108 | 109 | declare -f $completion_func >/dev/null && $completion_func |
109 | 110 | fi |
... | ... | @@ -213,8 +214,10 @@ _git () |
213 | 214 | |
214 | 215 | if (( $+functions[__${service}_zsh_main] )); then |
215 | 216 | __${service}_zsh_main |
216 | - else | |
217 | + elif (( $+functions[__${service}_main] )); then | |
217 | 218 | emulate ksh -c __${service}_main |
219 | + elif (( $+functions[_${service}] )); then | |
220 | + emulate ksh -c _${service} | |
218 | 221 | fi |
219 | 222 | |
220 | 223 | let _ret && _default && _ret=0 |
... | ... | @@ -10,17 +10,24 @@ |
10 | 10 | # *) local and remote tag names |
11 | 11 | # *) .git/remotes file names |
12 | 12 | # *) git 'subcommands' |
13 | +# *) git email aliases for git-send-email | |
13 | 14 | # *) tree paths within 'ref:path/to/file' expressions |
14 | 15 | # *) file paths within current working directory and index |
15 | 16 | # *) common --long-options |
16 | 17 | # |
17 | 18 | # To use these routines: |
18 | 19 | # |
19 | -# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). | |
20 | +# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). | |
20 | 21 | # 2) Add the following line to your .bashrc/.zshrc: |
21 | -# source ~/.git-completion.sh | |
22 | +# source ~/.git-completion.bash | |
22 | 23 | # 3) Consider changing your PS1 to also show the current branch, |
23 | 24 | # see git-prompt.sh for details. |
25 | +# | |
26 | +# If you use complex aliases of form '!f() { ... }; f', you can use the null | |
27 | +# command ':' as the first command in the function body to declare the desired | |
28 | +# completion style. For example '!f() { : git commit ; ... }; f' will | |
29 | +# tell the completion to use commit completion. This also works with aliases | |
30 | +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". | |
24 | 31 | |
25 | 32 | case "$COMP_WORDBREAKS" in |
26 | 33 | *:*) : great ;; |
... | ... | @@ -180,7 +187,7 @@ fi |
180 | 187 | |
181 | 188 | __gitcompappend () |
182 | 189 | { |
183 | - local i=${#COMPREPLY[@]} | |
190 | + local x i=${#COMPREPLY[@]} | |
184 | 191 | for x in $1; do |
185 | 192 | if [[ "$x" == "$3"* ]]; then |
186 | 193 | COMPREPLY[i++]="$2$x$4" |
... | ... | @@ -275,16 +282,12 @@ __gitcomp_file () |
275 | 282 | # argument, and using the options specified in the second argument. |
276 | 283 | __git_ls_files_helper () |
277 | 284 | { |
278 | - ( | |
279 | - test -n "${CDPATH+set}" && unset CDPATH | |
280 | - cd "$1" | |
281 | - if [ "$2" == "--committable" ]; then | |
282 | - git diff-index --name-only --relative HEAD | |
283 | - else | |
284 | - # NOTE: $2 is not quoted in order to support multiple options | |
285 | - git ls-files --exclude-standard $2 | |
286 | - fi | |
287 | - ) 2>/dev/null | |
285 | + if [ "$2" == "--committable" ]; then | |
286 | + git -C "$1" diff-index --name-only --relative HEAD | |
287 | + else | |
288 | + # NOTE: $2 is not quoted in order to support multiple options | |
289 | + git -C "$1" ls-files --exclude-standard $2 | |
290 | + fi 2>/dev/null | |
288 | 291 | } |
289 | 292 | |
290 | 293 | |
... | ... | @@ -382,7 +385,8 @@ __git_refs () |
382 | 385 | ;; |
383 | 386 | *) |
384 | 387 | echo "HEAD" |
385 | - git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" | |
388 | + git for-each-ref --format="%(refname:short)" -- \ | |
389 | + "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" | |
386 | 390 | ;; |
387 | 391 | esac |
388 | 392 | } |
... | ... | @@ -408,12 +412,9 @@ __git_refs_remotes () |
408 | 412 | |
409 | 413 | __git_remotes () |
410 | 414 | { |
411 | - local i IFS=$'\n' d="$(__gitdir)" | |
415 | + local d="$(__gitdir)" | |
412 | 416 | test -d "$d/remotes" && ls -1 "$d/remotes" |
413 | - for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do | |
414 | - i="${i#remote.}" | |
415 | - echo "${i/.url*/}" | |
416 | - done | |
417 | + git --git-dir="$d" remote | |
417 | 418 | } |
418 | 419 | |
419 | 420 | __git_list_merge_strategies () |
... | ... | @@ -516,7 +517,7 @@ __git_complete_index_file () |
516 | 517 | ;; |
517 | 518 | esac |
518 | 519 | |
519 | - __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" | |
520 | + __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" | |
520 | 521 | } |
521 | 522 | |
522 | 523 | __git_complete_file () |
... | ... | @@ -663,10 +664,11 @@ __git_list_porcelain_commands () |
663 | 664 | check-mailmap) : plumbing;; |
664 | 665 | check-ref-format) : plumbing;; |
665 | 666 | checkout-index) : plumbing;; |
667 | + column) : internal helper;; | |
666 | 668 | commit-tree) : plumbing;; |
667 | 669 | count-objects) : infrequent;; |
668 | - credential-cache) : credentials helper;; | |
669 | - credential-store) : credentials helper;; | |
670 | + credential) : credentials;; | |
671 | + credential-*) : credentials helper;; | |
670 | 672 | cvsexportcommit) : export;; |
671 | 673 | cvsimport) : import;; |
672 | 674 | cvsserver) : daemon;; |
... | ... | @@ -735,35 +737,28 @@ __git_list_porcelain_commands () |
735 | 737 | __git_porcelain_commands= |
736 | 738 | __git_compute_porcelain_commands () |
737 | 739 | { |
738 | - __git_compute_all_commands | |
739 | 740 | test -n "$__git_porcelain_commands" || |
740 | 741 | __git_porcelain_commands=$(__git_list_porcelain_commands) |
741 | 742 | } |
742 | 743 | |
743 | -__git_pretty_aliases () | |
744 | +# Lists all set config variables starting with the given section prefix, | |
745 | +# with the prefix removed. | |
746 | +__git_get_config_variables () | |
744 | 747 | { |
745 | - local i IFS=$'\n' | |
746 | - for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do | |
747 | - case "$i" in | |
748 | - pretty.*) | |
749 | - i="${i#pretty.}" | |
750 | - echo "${i/ */}" | |
751 | - ;; | |
752 | - esac | |
748 | + local section="$1" i IFS=$'\n' | |
749 | + for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do | |
750 | + echo "${i#$section.}" | |
753 | 751 | done |
754 | 752 | } |
755 | 753 | |
754 | +__git_pretty_aliases () | |
755 | +{ | |
756 | + __git_get_config_variables "pretty" | |
757 | +} | |
758 | + | |
756 | 759 | __git_aliases () |
757 | 760 | { |
758 | - local i IFS=$'\n' | |
759 | - for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do | |
760 | - case "$i" in | |
761 | - alias.*) | |
762 | - i="${i#alias.}" | |
763 | - echo "${i/ */}" | |
764 | - ;; | |
765 | - esac | |
766 | - done | |
761 | + __git_get_config_variables "alias" | |
767 | 762 | } |
768 | 763 | |
769 | 764 | # __git_aliased_command requires 1 argument |
... | ... | @@ -781,6 +776,10 @@ __git_aliased_command () |
781 | 776 | -*) : option ;; |
782 | 777 | *=*) : setting env ;; |
783 | 778 | git) : git itself ;; |
779 | + \(\)) : skip parens of shell function definition ;; | |
780 | + {) : skip start of shell helper function ;; | |
781 | + :) : skip null command ;; | |
782 | + \'*) : skip opening quote after sh -c ;; | |
784 | 783 | *) |
785 | 784 | echo "$word" |
786 | 785 | return |
... | ... | @@ -973,7 +972,7 @@ _git_branch () |
973 | 972 | |
974 | 973 | case "$cur" in |
975 | 974 | --set-upstream-to=*) |
976 | - __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" | |
975 | + __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}" | |
977 | 976 | ;; |
978 | 977 | --*) |
979 | 978 | __gitcomp " |
... | ... | @@ -1041,7 +1040,7 @@ _git_checkout () |
1041 | 1040 | |
1042 | 1041 | _git_cherry () |
1043 | 1042 | { |
1044 | - __gitcomp "$(__git_refs)" | |
1043 | + __gitcomp_nl "$(__git_refs)" | |
1045 | 1044 | } |
1046 | 1045 | |
1047 | 1046 | _git_cherry_pick () |
... | ... | @@ -1110,7 +1109,7 @@ _git_commit () |
1110 | 1109 | |
1111 | 1110 | case "$cur" in |
1112 | 1111 | --cleanup=*) |
1113 | - __gitcomp "default strip verbatim whitespace | |
1112 | + __gitcomp "default scissors strip verbatim whitespace | |
1114 | 1113 | " "" "${cur##--cleanup=}" |
1115 | 1114 | return |
1116 | 1115 | ;; |
... | ... | @@ -1165,12 +1164,12 @@ __git_diff_common_options="--stat --numstat --shortstat --summary |
1165 | 1164 | --full-index --binary --abbrev --diff-filter= |
1166 | 1165 | --find-copies-harder |
1167 | 1166 | --text --ignore-space-at-eol --ignore-space-change |
1168 | - --ignore-all-space --exit-code --quiet --ext-diff | |
1169 | - --no-ext-diff | |
1167 | + --ignore-all-space --ignore-blank-lines --exit-code | |
1168 | + --quiet --ext-diff --no-ext-diff | |
1170 | 1169 | --no-prefix --src-prefix= --dst-prefix= |
1171 | 1170 | --inter-hunk-context= |
1172 | 1171 | --patience --histogram --minimal |
1173 | - --raw --word-diff | |
1172 | + --raw --word-diff --word-diff-regex= | |
1174 | 1173 | --dirstat --dirstat= --dirstat-by-file |
1175 | 1174 | --dirstat-by-file= --cumulative |
1176 | 1175 | --diff-algorithm= |
... | ... | @@ -1197,7 +1196,7 @@ _git_diff () |
1197 | 1196 | } |
1198 | 1197 | |
1199 | 1198 | __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff |
1200 | - tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare | |
1199 | + tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare | |
1201 | 1200 | " |
1202 | 1201 | |
1203 | 1202 | _git_difftool () |
... | ... | @@ -1221,14 +1220,20 @@ _git_difftool () |
1221 | 1220 | __git_complete_revlist_file |
1222 | 1221 | } |
1223 | 1222 | |
1223 | +__git_fetch_recurse_submodules="yes on-demand no" | |
1224 | + | |
1224 | 1225 | __git_fetch_options=" |
1225 | 1226 | --quiet --verbose --append --upload-pack --force --keep --depth= |
1226 | - --tags --no-tags --all --prune --dry-run | |
1227 | + --tags --no-tags --all --prune --dry-run --recurse-submodules= | |
1227 | 1228 | " |
1228 | 1229 | |
1229 | 1230 | _git_fetch () |
1230 | 1231 | { |
1231 | 1232 | case "$cur" in |
1233 | + --recurse-submodules=*) | |
1234 | + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" | |
1235 | + return | |
1236 | + ;; | |
1232 | 1237 | --*) |
1233 | 1238 | __gitcomp "$__git_fetch_options" |
1234 | 1239 | return |
... | ... | @@ -1292,7 +1297,7 @@ _git_gitk () |
1292 | 1297 | } |
1293 | 1298 | |
1294 | 1299 | __git_match_ctag() { |
1295 | - awk "/^${1////\/}/ { print \$1 }" "$2" | |
1300 | + awk "/^${1//\//\/}/ { print \$1 }" "$2" | |
1296 | 1301 | } |
1297 | 1302 | |
1298 | 1303 | _git_grep () |
... | ... | @@ -1307,6 +1312,7 @@ _git_grep () |
1307 | 1312 | --full-name --line-number |
1308 | 1313 | --extended-regexp --basic-regexp --fixed-strings |
1309 | 1314 | --perl-regexp |
1315 | + --threads | |
1310 | 1316 | --files-with-matches --name-only |
1311 | 1317 | --files-without-match |
1312 | 1318 | --max-depth |
... | ... | @@ -1412,7 +1418,7 @@ __git_log_gitk_options=" |
1412 | 1418 | # Options that go well for log and shortlog (not gitk) |
1413 | 1419 | __git_log_shortlog_options=" |
1414 | 1420 | --author= --committer= --grep= |
1415 | - --all-match | |
1421 | + --all-match --invert-grep | |
1416 | 1422 | " |
1417 | 1423 | |
1418 | 1424 | __git_log_pretty_formats="oneline short medium full fuller email raw format:" |
... | ... | @@ -1438,7 +1444,7 @@ _git_log () |
1438 | 1444 | return |
1439 | 1445 | ;; |
1440 | 1446 | --decorate=*) |
1441 | - __gitcomp "long short" "" "${cur##--decorate=}" | |
1447 | + __gitcomp "full short no" "" "${cur##--decorate=}" | |
1442 | 1448 | return |
1443 | 1449 | ;; |
1444 | 1450 | --*) |
... | ... | @@ -1451,6 +1457,7 @@ _git_log () |
1451 | 1457 | --abbrev-commit --abbrev= |
1452 | 1458 | --relative-date --date= |
1453 | 1459 | --pretty= --format= --oneline |
1460 | + --show-signature | |
1454 | 1461 | --cherry-pick |
1455 | 1462 | --graph |
1456 | 1463 | --decorate --decorate= |
... | ... | @@ -1466,9 +1473,12 @@ _git_log () |
1466 | 1473 | __git_complete_revlist |
1467 | 1474 | } |
1468 | 1475 | |
1476 | +# Common merge options shared by git-merge(1) and git-pull(1). | |
1469 | 1477 | __git_merge_options=" |
1470 | 1478 | --no-commit --no-stat --log --no-log --squash --strategy |
1471 | 1479 | --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit |
1480 | + --verify-signatures --no-verify-signatures --gpg-sign | |
1481 | + --quiet --verbose --progress --no-progress | |
1472 | 1482 | " |
1473 | 1483 | |
1474 | 1484 | _git_merge () |
... | ... | @@ -1477,7 +1487,8 @@ _git_merge () |
1477 | 1487 | |
1478 | 1488 | case "$cur" in |
1479 | 1489 | --*) |
1480 | - __gitcomp "$__git_merge_options" | |
1490 | + __gitcomp "$__git_merge_options | |
1491 | + --rerere-autoupdate --no-rerere-autoupdate --abort" | |
1481 | 1492 | return |
1482 | 1493 | esac |
1483 | 1494 | __gitcomp_nl "$(__git_refs)" |
... | ... | @@ -1583,6 +1594,10 @@ _git_pull () |
1583 | 1594 | __git_complete_strategy && return |
1584 | 1595 | |
1585 | 1596 | case "$cur" in |
1597 | + --recurse-submodules=*) | |
1598 | + __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" | |
1599 | + return | |
1600 | + ;; | |
1586 | 1601 | --*) |
1587 | 1602 | __gitcomp " |
1588 | 1603 | --rebase --no-rebase |
... | ... | @@ -1595,22 +1610,55 @@ _git_pull () |
1595 | 1610 | __git_complete_remote_or_refspec |
1596 | 1611 | } |
1597 | 1612 | |
1613 | +__git_push_recurse_submodules="check on-demand" | |
1614 | + | |
1615 | +__git_complete_force_with_lease () | |
1616 | +{ | |
1617 | + local cur_=$1 | |
1618 | + | |
1619 | + case "$cur_" in | |
1620 | + --*=) | |
1621 | + ;; | |
1622 | + *:*) | |
1623 | + __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" | |
1624 | + ;; | |
1625 | + *) | |
1626 | + __gitcomp_nl "$(__git_refs)" "" "$cur_" | |
1627 | + ;; | |
1628 | + esac | |
1629 | +} | |
1630 | + | |
1598 | 1631 | _git_push () |
1599 | 1632 | { |
1600 | 1633 | case "$prev" in |
1601 | 1634 | --repo) |
1602 | 1635 | __gitcomp_nl "$(__git_remotes)" |
1603 | 1636 | return |
1637 | + ;; | |
1638 | + --recurse-submodules) | |
1639 | + __gitcomp "$__git_push_recurse_submodules" | |
1640 | + return | |
1641 | + ;; | |
1604 | 1642 | esac |
1605 | 1643 | case "$cur" in |
1606 | 1644 | --repo=*) |
1607 | 1645 | __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" |
1608 | 1646 | return |
1609 | 1647 | ;; |
1648 | + --recurse-submodules=*) | |
1649 | + __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}" | |
1650 | + return | |
1651 | + ;; | |
1652 | + --force-with-lease=*) | |
1653 | + __git_complete_force_with_lease "${cur##--force-with-lease=}" | |
1654 | + return | |
1655 | + ;; | |
1610 | 1656 | --*) |
1611 | 1657 | __gitcomp " |
1612 | 1658 | --all --mirror --tags --dry-run --force --verbose |
1659 | + --quiet --prune --delete --follow-tags | |
1613 | 1660 | --receive-pack= --repo= --set-upstream |
1661 | + --force-with-lease --force-with-lease= --recurse-submodules= | |
1614 | 1662 | " |
1615 | 1663 | return |
1616 | 1664 | ;; |
... | ... | @@ -1621,7 +1669,10 @@ _git_push () |
1621 | 1669 | _git_rebase () |
1622 | 1670 | { |
1623 | 1671 | local dir="$(__gitdir)" |
1624 | - if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then | |
1672 | + if [ -f "$dir"/rebase-merge/interactive ]; then | |
1673 | + __gitcomp "--continue --skip --abort --edit-todo" | |
1674 | + return | |
1675 | + elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then | |
1625 | 1676 | __gitcomp "--continue --skip --abort" |
1626 | 1677 | return |
1627 | 1678 | fi |
... | ... | @@ -1637,7 +1688,12 @@ _git_rebase () |
1637 | 1688 | --preserve-merges --stat --no-stat |
1638 | 1689 | --committer-date-is-author-date --ignore-date |
1639 | 1690 | --ignore-whitespace --whitespace= |
1640 | - --autosquash --fork-point --no-fork-point | |
1691 | + --autosquash --no-autosquash | |
1692 | + --fork-point --no-fork-point | |
1693 | + --autostash --no-autostash | |
1694 | + --verify --no-verify | |
1695 | + --keep-empty --root --force-rebase --no-ff | |
1696 | + --exec | |
1641 | 1697 | " |
1642 | 1698 | |
1643 | 1699 | return |
... | ... | @@ -1662,6 +1718,15 @@ __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" |
1662 | 1718 | |
1663 | 1719 | _git_send_email () |
1664 | 1720 | { |
1721 | + case "$prev" in | |
1722 | + --to|--cc|--bcc|--from) | |
1723 | + __gitcomp " | |
1724 | + $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null) | |
1725 | + " | |
1726 | + return | |
1727 | + ;; | |
1728 | + esac | |
1729 | + | |
1665 | 1730 | case "$cur" in |
1666 | 1731 | --confirm=*) |
1667 | 1732 | __gitcomp " |
... | ... | @@ -1686,6 +1751,12 @@ _git_send_email () |
1686 | 1751 | " "" "${cur##--thread=}" |
1687 | 1752 | return |
1688 | 1753 | ;; |
1754 | + --to=*|--cc=*|--bcc=*|--from=*) | |
1755 | + __gitcomp " | |
1756 | + $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null) | |
1757 | + " "" "${cur#--*=}" | |
1758 | + return | |
1759 | + ;; | |
1689 | 1760 | --*) |
1690 | 1761 | __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to |
1691 | 1762 | --compose --confirm= --dry-run --envelope-sender |
... | ... | @@ -1727,15 +1798,7 @@ __git_config_get_set_variables () |
1727 | 1798 | c=$((--c)) |
1728 | 1799 | done |
1729 | 1800 | |
1730 | - git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | | |
1731 | - while read -r line | |
1732 | - do | |
1733 | - case "$line" in | |
1734 | - *.*=*) | |
1735 | - echo "${line/=*/}" | |
1736 | - ;; | |
1737 | - esac | |
1738 | - done | |
1801 | + git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null | |
1739 | 1802 | } |
1740 | 1803 | |
1741 | 1804 | _git_config () |
... | ... | @@ -1750,7 +1813,7 @@ _git_config () |
1750 | 1813 | return |
1751 | 1814 | ;; |
1752 | 1815 | branch.*.rebase) |
1753 | - __gitcomp "false true" | |
1816 | + __gitcomp "false true preserve interactive" | |
1754 | 1817 | return |
1755 | 1818 | ;; |
1756 | 1819 | remote.pushdefault) |
... | ... | @@ -1820,6 +1883,10 @@ _git_config () |
1820 | 1883 | __gitcomp "$__git_send_email_suppresscc_options" |
1821 | 1884 | return |
1822 | 1885 | ;; |
1886 | + sendemail.transferencoding) | |
1887 | + __gitcomp "7bit 8bit quoted-printable base64" | |
1888 | + return | |
1889 | + ;; | |
1823 | 1890 | --get|--get-all|--unset|--unset-all) |
1824 | 1891 | __gitcomp_nl "$(__git_config_get_set_variables)" |
1825 | 1892 | return |
... | ... | @@ -1836,6 +1903,7 @@ _git_config () |
1836 | 1903 | --get --get-all --get-regexp |
1837 | 1904 | --add --unset --unset-all |
1838 | 1905 | --remove-section --rename-section |
1906 | + --name-only | |
1839 | 1907 | " |
1840 | 1908 | return |
1841 | 1909 | ;; |
... | ... | @@ -1954,6 +2022,7 @@ _git_config () |
1954 | 2022 | color.status.changed |
1955 | 2023 | color.status.header |
1956 | 2024 | color.status.nobranch |
2025 | + color.status.unmerged | |
1957 | 2026 | color.status.untracked |
1958 | 2027 | color.status.updated |
1959 | 2028 | color.ui |
... | ... | @@ -1991,6 +2060,7 @@ _git_config () |
1991 | 2060 | core.sparseCheckout |
1992 | 2061 | core.symlinks |
1993 | 2062 | core.trustctime |
2063 | + core.untrackedCache | |
1994 | 2064 | core.warnAmbiguousRefs |
1995 | 2065 | core.whitespace |
1996 | 2066 | core.worktree |
... | ... | @@ -2065,6 +2135,8 @@ _git_config () |
2065 | 2135 | http.noEPSV |
2066 | 2136 | http.postBuffer |
2067 | 2137 | http.proxy |
2138 | + http.sslCipherList | |
2139 | + http.sslVersion | |
2068 | 2140 | http.sslCAInfo |
2069 | 2141 | http.sslCAPath |
2070 | 2142 | http.sslCert |
... | ... | @@ -2128,6 +2200,7 @@ _git_config () |
2128 | 2200 | pull.octopus |
2129 | 2201 | pull.twohead |
2130 | 2202 | push.default |
2203 | + push.followTags | |
2131 | 2204 | rebase.autosquash |
2132 | 2205 | rebase.stat |
2133 | 2206 | receive.autogc |
... | ... | @@ -2201,12 +2274,7 @@ _git_remote () |
2201 | 2274 | __git_complete_remote_or_refspec |
2202 | 2275 | ;; |
2203 | 2276 | update) |
2204 | - local i c='' IFS=$'\n' | |
2205 | - for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do | |
2206 | - i="${i#remotes.}" | |
2207 | - c="$c ${i/ */}" | |
2208 | - done | |
2209 | - __gitcomp "$c" | |
2277 | + __gitcomp "$(__git_get_config_variables "remotes")" | |
2210 | 2278 | ;; |
2211 | 2279 | *) |
2212 | 2280 | ;; |
... | ... | @@ -2233,6 +2301,11 @@ _git_reset () |
2233 | 2301 | |
2234 | 2302 | _git_revert () |
2235 | 2303 | { |
2304 | + local dir="$(__gitdir)" | |
2305 | + if [ -f "$dir"/REVERT_HEAD ]; then | |
2306 | + __gitcomp "--continue --quit --abort" | |
2307 | + return | |
2308 | + fi | |
2236 | 2309 | case "$cur" in |
2237 | 2310 | --*) |
2238 | 2311 | __gitcomp "--edit --mainline --no-edit --no-commit --signoff" |
... | ... | @@ -2287,6 +2360,7 @@ _git_show () |
2287 | 2360 | ;; |
2288 | 2361 | --*) |
2289 | 2362 | __gitcomp "--pretty= --format= --abbrev-commit --oneline |
2363 | + --show-signature | |
2290 | 2364 | $__git_diff_common_options |
2291 | 2365 | " |
2292 | 2366 | return |
... | ... | @@ -2300,7 +2374,7 @@ _git_show_branch () |
2300 | 2374 | case "$cur" in |
2301 | 2375 | --*) |
2302 | 2376 | __gitcomp " |
2303 | - --all --remotes --topo-order --current --more= | |
2377 | + --all --remotes --topo-order --date-order --current --more= | |
2304 | 2378 | --list --independent --merge-base --no-name |
2305 | 2379 | --color --no-color |
2306 | 2380 | --sha1-name --sparse --topics --reflog |
... | ... | @@ -2313,7 +2387,7 @@ _git_show_branch () |
2313 | 2387 | |
2314 | 2388 | _git_stash () |
2315 | 2389 | { |
2316 | - local save_opts='--keep-index --no-keep-index --quiet --patch' | |
2390 | + local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' | |
2317 | 2391 | local subcommands='save list show apply clear drop pop create branch' |
2318 | 2392 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
2319 | 2393 | if [ -z "$subcommand" ]; then |
... | ... | @@ -2335,9 +2409,20 @@ _git_stash () |
2335 | 2409 | apply,--*|pop,--*) |
2336 | 2410 | __gitcomp "--index --quiet" |
2337 | 2411 | ;; |
2338 | - show,--*|drop,--*|branch,--*) | |
2412 | + drop,--*) | |
2413 | + __gitcomp "--quiet" | |
2339 | 2414 | ;; |
2340 | - show,*|apply,*|drop,*|pop,*|branch,*) | |
2415 | + show,--*|branch,--*) | |
2416 | + ;; | |
2417 | + branch,*) | |
2418 | + if [ $cword -eq 3 ]; then | |
2419 | + __gitcomp_nl "$(__git_refs)"; | |
2420 | + else | |
2421 | + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | |
2422 | + | sed -n -e 's/:.*//p')" | |
2423 | + fi | |
2424 | + ;; | |
2425 | + show,*|apply,*|drop,*|pop,*) | |
2341 | 2426 | __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ |
2342 | 2427 | | sed -n -e 's/:.*//p')" |
2343 | 2428 | ;; |
... | ... | @@ -2492,6 +2577,16 @@ _git_tag () |
2492 | 2577 | __gitcomp_nl "$(__git_refs)" |
2493 | 2578 | ;; |
2494 | 2579 | esac |
2580 | + | |
2581 | + case "$cur" in | |
2582 | + --*) | |
2583 | + __gitcomp " | |
2584 | + --list --delete --verify --annotate --message --file | |
2585 | + --sign --cleanup --local-user --force --column --sort | |
2586 | + --contains --points-at | |
2587 | + " | |
2588 | + ;; | |
2589 | + esac | |
2495 | 2590 | } |
2496 | 2591 | |
2497 | 2592 | _git_whatchanged () |
... | ... | @@ -2547,6 +2642,7 @@ __git_main () |
2547 | 2642 | |
2548 | 2643 | local expansion=$(__git_aliased_command "$command") |
2549 | 2644 | if [ -n "$expansion" ]; then |
2645 | + words[1]=$expansion | |
2550 | 2646 | completion_func="_git_${expansion//-/_}" |
2551 | 2647 | declare -f $completion_func >/dev/null && $completion_func |
2552 | 2648 | fi |
... | ... | @@ -66,6 +66,10 @@ |
66 | 66 | # git always compare HEAD to @{upstream} |
67 | 67 | # svn always compare HEAD to your SVN upstream |
68 | 68 | # |
69 | +# You can change the separator between the branch name and the above | |
70 | +# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator | |
71 | +# is SP. | |
72 | +# | |
69 | 73 | # By default, __git_ps1 will compare HEAD to your SVN upstream if it can |
70 | 74 | # find one, or @{upstream} otherwise. Once you have set |
71 | 75 | # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by |
... | ... | @@ -84,6 +88,11 @@ |
84 | 88 | # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on |
85 | 89 | # the colored output of "git status -sb" and are available only when |
86 | 90 | # using __git_ps1 for PROMPT_COMMAND or precmd. |
91 | +# | |
92 | +# If you would like __git_ps1 to do nothing in the case when the current | |
93 | +# directory is set up to be ignored by git, then set | |
94 | +# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the | |
95 | +# repository level by setting bash.hideIfPwdIgnored to "false". | |
87 | 96 | |
88 | 97 | # check whether printf supports -v |
89 | 98 | __git_printf_supports_v= |
... | ... | @@ -207,7 +216,16 @@ __git_ps1_show_upstream () |
207 | 216 | p=" u+${count#* }-${count% *}" ;; |
208 | 217 | esac |
209 | 218 | if [[ -n "$count" && -n "$name" ]]; then |
210 | - p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)" | |
219 | + __git_ps1_upstream_name=$(git rev-parse \ | |
220 | + --abbrev-ref "$upstream" 2>/dev/null) | |
221 | + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then | |
222 | + p="$p \${__git_ps1_upstream_name}" | |
223 | + else | |
224 | + p="$p ${__git_ps1_upstream_name}" | |
225 | + # not needed anymore; keep user's | |
226 | + # environment clean | |
227 | + unset __git_ps1_upstream_name | |
228 | + fi | |
211 | 229 | fi |
212 | 230 | fi |
213 | 231 | |
... | ... | @@ -259,9 +277,9 @@ __git_ps1_colorize_gitstring () |
259 | 277 | r="$c_clear$r" |
260 | 278 | } |
261 | 279 | |
262 | -eread () | |
280 | +__git_eread () | |
263 | 281 | { |
264 | - f="$1" | |
282 | + local f="$1" | |
265 | 283 | shift |
266 | 284 | test -r "$f" && read "$@" <"$f" |
267 | 285 | } |
... | ... | @@ -279,6 +297,8 @@ eread () |
279 | 297 | # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true |
280 | 298 | __git_ps1 () |
281 | 299 | { |
300 | + # preserve exit status | |
301 | + local exit=$? | |
282 | 302 | local pcmode=no |
283 | 303 | local detached=no |
284 | 304 | local ps1pc_start='\u@\h:\w ' |
... | ... | @@ -290,13 +310,54 @@ __git_ps1 () |
290 | 310 | ps1pc_start="$1" |
291 | 311 | ps1pc_end="$2" |
292 | 312 | printf_format="${3:-$printf_format}" |
313 | + # set PS1 to a plain prompt so that we can | |
314 | + # simply return early if the prompt should not | |
315 | + # be decorated | |
316 | + PS1="$ps1pc_start$ps1pc_end" | |
293 | 317 | ;; |
294 | 318 | 0|1) printf_format="${1:-$printf_format}" |
295 | 319 | ;; |
296 | - *) return | |
320 | + *) return $exit | |
297 | 321 | ;; |
298 | 322 | esac |
299 | 323 | |
324 | + # ps1_expanded: This variable is set to 'yes' if the shell | |
325 | + # subjects the value of PS1 to parameter expansion: | |
326 | + # | |
327 | + # * bash does unless the promptvars option is disabled | |
328 | + # * zsh does not unless the PROMPT_SUBST option is set | |
329 | + # * POSIX shells always do | |
330 | + # | |
331 | + # If the shell would expand the contents of PS1 when drawing | |
332 | + # the prompt, a raw ref name must not be included in PS1. | |
333 | + # This protects the user from arbitrary code execution via | |
334 | + # specially crafted ref names. For example, a ref named | |
335 | + # 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the | |
336 | + # shell to execute 'sudo rm -rf /' when the prompt is drawn. | |
337 | + # | |
338 | + # Instead, the ref name should be placed in a separate global | |
339 | + # variable (in the __git_ps1_* namespace to avoid colliding | |
340 | + # with the user's environment) and that variable should be | |
341 | + # referenced from PS1. For example: | |
342 | + # | |
343 | + # __git_ps1_foo=$(do_something_to_get_ref_name) | |
344 | + # PS1="...stuff...\${__git_ps1_foo}...stuff..." | |
345 | + # | |
346 | + # If the shell does not expand the contents of PS1, the raw | |
347 | + # ref name must be included in PS1. | |
348 | + # | |
349 | + # The value of this variable is only relevant when in pcmode. | |
350 | + # | |
351 | + # Assume that the shell follows the POSIX specification and | |
352 | + # expands PS1 unless determined otherwise. (This is more | |
353 | + # likely to be correct if the user has a non-bash, non-zsh | |
354 | + # shell and safer than the alternative if the assumption is | |
355 | + # incorrect.) | |
356 | + # | |
357 | + local ps1_expanded=yes | |
358 | + [ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no | |
359 | + [ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no | |
360 | + | |
300 | 361 | local repo_info rev_parse_exit_code |
301 | 362 | repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ |
302 | 363 | --is-bare-repository --is-inside-work-tree \ |
... | ... | @@ -304,11 +365,7 @@ __git_ps1 () |
304 | 365 | rev_parse_exit_code="$?" |
305 | 366 | |
306 | 367 | if [ -z "$repo_info" ]; then |
307 | - if [ $pcmode = yes ]; then | |
308 | - #In PC mode PS1 always needs to be set | |
309 | - PS1="$ps1pc_start$ps1pc_end" | |
310 | - fi | |
311 | - return | |
368 | + return $exit | |
312 | 369 | fi |
313 | 370 | |
314 | 371 | local short_sha |
... | ... | @@ -323,14 +380,22 @@ __git_ps1 () |
323 | 380 | local inside_gitdir="${repo_info##*$'\n'}" |
324 | 381 | local g="${repo_info%$'\n'*}" |
325 | 382 | |
383 | + if [ "true" = "$inside_worktree" ] && | |
384 | + [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] && | |
385 | + [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && | |
386 | + git check-ignore -q . | |
387 | + then | |
388 | + return $exit | |
389 | + fi | |
390 | + | |
326 | 391 | local r="" |
327 | 392 | local b="" |
328 | 393 | local step="" |
329 | 394 | local total="" |
330 | 395 | if [ -d "$g/rebase-merge" ]; then |
331 | - eread "$g/rebase-merge/head-name" b | |
332 | - eread "$g/rebase-merge/msgnum" step | |
333 | - eread "$g/rebase-merge/end" total | |
396 | + __git_eread "$g/rebase-merge/head-name" b | |
397 | + __git_eread "$g/rebase-merge/msgnum" step | |
398 | + __git_eread "$g/rebase-merge/end" total | |
334 | 399 | if [ -f "$g/rebase-merge/interactive" ]; then |
335 | 400 | r="|REBASE-i" |
336 | 401 | else |
... | ... | @@ -338,10 +403,10 @@ __git_ps1 () |
338 | 403 | fi |
339 | 404 | else |
340 | 405 | if [ -d "$g/rebase-apply" ]; then |
341 | - eread "$g/rebase-apply/next" step | |
342 | - eread "$g/rebase-apply/last" total | |
406 | + __git_eread "$g/rebase-apply/next" step | |
407 | + __git_eread "$g/rebase-apply/last" total | |
343 | 408 | if [ -f "$g/rebase-apply/rebasing" ]; then |
344 | - eread "$g/rebase-apply/head-name" b | |
409 | + __git_eread "$g/rebase-apply/head-name" b | |
345 | 410 | r="|REBASE" |
346 | 411 | elif [ -f "$g/rebase-apply/applying" ]; then |
347 | 412 | r="|AM" |
... | ... | @@ -365,11 +430,8 @@ __git_ps1 () |
365 | 430 | b="$(git symbolic-ref HEAD 2>/dev/null)" |
366 | 431 | else |
367 | 432 | local head="" |
368 | - if ! eread "$g/HEAD" head; then | |
369 | - if [ $pcmode = yes ]; then | |
370 | - PS1="$ps1pc_start$ps1pc_end" | |
371 | - fi | |
372 | - return | |
433 | + if ! __git_eread "$g/HEAD" head; then | |
434 | + return $exit | |
373 | 435 | fi |
374 | 436 | # is it a symbolic ref? |
375 | 437 | b="${head#ref: }" |
... | ... | @@ -414,21 +476,21 @@ __git_ps1 () |
414 | 476 | if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && |
415 | 477 | [ "$(git config --bool bash.showDirtyState)" != "false" ] |
416 | 478 | then |
417 | - git diff --no-ext-diff --quiet --exit-code || w="*" | |
418 | - if [ -n "$short_sha" ]; then | |
419 | - git diff-index --cached --quiet HEAD -- || i="+" | |
420 | - else | |
479 | + git diff --no-ext-diff --quiet || w="*" | |
480 | + git diff --no-ext-diff --cached --quiet || i="+" | |
481 | + if [ -z "$short_sha" ] && [ -z "$i" ]; then | |
421 | 482 | i="#" |
422 | 483 | fi |
423 | 484 | fi |
424 | 485 | if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && |
425 | - [ -r "$g/refs/stash" ]; then | |
486 | + git rev-parse --verify --quiet refs/stash >/dev/null | |
487 | + then | |
426 | 488 | s="$" |
427 | 489 | fi |
428 | 490 | |
429 | 491 | if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && |
430 | 492 | [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && |
431 | - git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null | |
493 | + git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null | |
432 | 494 | then |
433 | 495 | u="%${ZSH_VERSION+%}" |
434 | 496 | fi |
... | ... | @@ -440,13 +502,21 @@ __git_ps1 () |
440 | 502 | |
441 | 503 | local z="${GIT_PS1_STATESEPARATOR-" "}" |
442 | 504 | |
443 | - # NO color option unless in PROMPT_COMMAND mode | |
444 | - if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then | |
445 | - __git_ps1_colorize_gitstring | |
505 | + # NO color option unless in PROMPT_COMMAND mode or it's Zsh | |
506 | + if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then | |
507 | + if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then | |
508 | + __git_ps1_colorize_gitstring | |
509 | + fi | |
510 | + fi | |
511 | + | |
512 | + b=${b##refs/heads/} | |
513 | + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then | |
514 | + __git_ps1_branch_name=$b | |
515 | + b="\${__git_ps1_branch_name}" | |
446 | 516 | fi |
447 | 517 | |
448 | 518 | local f="$w$i$s$u" |
449 | - local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p" | |
519 | + local gitstring="$c$b${f:+$z$f}$r$p" | |
450 | 520 | |
451 | 521 | if [ $pcmode = yes ]; then |
452 | 522 | if [ "${__git_printf_supports_v-}" != yes ]; then |
... | ... | @@ -458,4 +528,6 @@ __git_ps1 () |
458 | 528 | else |
459 | 529 | printf -- "$printf_format" "$gitstring" |
460 | 530 | fi |
531 | + | |
532 | + return $exit | |
461 | 533 | } |
... | ... | @@ -71,7 +71,7 @@ exist_gh() { # [DIRECTORY] |
71 | 71 | # |
72 | 72 | git.io() { |
73 | 73 | emulate -L zsh |
74 | - curl -i -s http://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " " | |
74 | + curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " " | |
75 | 75 | } |
76 | 76 | |
77 | 77 | # End Functions ############################################################# |
... | ... | @@ -179,5 +179,15 @@ __go_tool_complete() { |
179 | 179 | |
180 | 180 | compdef __go_tool_complete go |
181 | 181 | |
182 | -# aliases | |
183 | -alias gfa='go fmt . ./...' | |
182 | +# aliases: go<~> | |
183 | +alias gob='go build' | |
184 | +alias goc='go clean' | |
185 | +alias god='go doc' | |
186 | +alias gof='go fmt' | |
187 | +alias gofa='go fmt . ./...' | |
188 | +alias gog='go get' | |
189 | +alias goi='go install' | |
190 | +alias gol='go list' | |
191 | +alias gor='go run' | |
192 | +alias got='go test' | |
193 | +alias gov='go vet' |
... | ... | @@ -38,7 +38,11 @@ function jira() { |
38 | 38 | _jira_query $@ |
39 | 39 | elif [[ "$action" == "dashboard" ]]; then |
40 | 40 | echo "Opening dashboard" |
41 | - open_command "${jira_url}/secure/Dashboard.jspa" | |
41 | + if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then | |
42 | + open_command "${jira_url}/secure/RapidBoard.jspa" | |
43 | + else | |
44 | + open_command "${jira_url}/secure/Dashboard.jspa" | |
45 | + fi | |
42 | 46 | elif [[ "$action" == "dumpconfig" ]]; then |
43 | 47 | echo "JIRA_URL=$jira_url" |
44 | 48 | echo "JIRA_PREFIX=$jira_prefix" |
... | ... | @@ -99,4 +103,3 @@ function _jira_query() { |
99 | 103 | query="${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" |
100 | 104 | open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${query}" |
101 | 105 | } |
102 | - |
1 | -# author: Peter Eisentraut | |
2 | -# source: https://gist.github.com/petere/10307599 | |
3 | -# compdef kitchen | |
1 | +#compdef kitchen | |
2 | +# ------------------------------------------------------------------------------ | |
3 | +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users | |
4 | +# All rights reserved. | |
5 | +# | |
6 | +# Redistribution and use in source and binary forms, with or without | |
7 | +# modification, are permitted provided that the following conditions are met: | |
8 | +# * Redistributions of source code must retain the above copyright | |
9 | +# notice, this list of conditions and the following disclaimer. | |
10 | +# * Redistributions in binary form must reproduce the above copyright | |
11 | +# notice, this list of conditions and the following disclaimer in the | |
12 | +# documentation and/or other materials provided with the distribution. | |
13 | +# * Neither the name of the zsh-users nor the | |
14 | +# names of its contributors may be used to endorse or promote products | |
15 | +# derived from this software without specific prior written permission. | |
16 | +# | |
17 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
18 | +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
19 | +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
20 | +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY | |
21 | +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
22 | +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
23 | +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
24 | +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
26 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | +# ------------------------------------------------------------------------------ | |
28 | +# Description | |
29 | +# ----------- | |
30 | +# | |
31 | +# Completion script for Test Kitchen (http://kitchen.ci/). | |
32 | +# | |
33 | +# ------------------------------------------------------------------------------ | |
34 | +# Authors | |
35 | +# ------- | |
36 | +# | |
37 | +# * Peter Eisentraut (https://github.com/petere) | |
38 | +# | |
39 | +# ------------------------------------------------------------------------------ | |
40 | + | |
4 | 41 | |
5 | 42 | _kitchen() { |
6 | - local curcontext="$curcontext" state line | |
7 | - typeset -A opt_args | |
8 | - | |
9 | - _arguments '1: :->cmds'\ | |
10 | - '2: :->args' | |
11 | - | |
12 | - case $state in | |
13 | - cmds) | |
14 | - _arguments "1:Commands:(console converge create destroy diagnose driver help init list login setup test verify version)" | |
15 | - ;; | |
16 | - args) | |
17 | - case $line[1] in | |
18 | - converge|create|destroy|diagnose|list|setup|test|verify) | |
19 | - compadd "$@" all | |
20 | - _kitchen_instances | |
21 | - ;; | |
22 | - login) | |
23 | - _kitchen_instances | |
24 | - ;; | |
25 | - esac | |
26 | - ;; | |
27 | - esac | |
43 | + local curcontext="$curcontext" state line | |
44 | + typeset -A opt_args | |
45 | + | |
46 | + _arguments '1: :->cmds'\ | |
47 | + '2: :->args' | |
48 | + | |
49 | + case $state in | |
50 | + cmds) | |
51 | + _kitchen_commands | |
52 | + ;; | |
53 | + args) | |
54 | + case $line[1] in | |
55 | + converge|create|destroy|diagnose|list|setup|test|verify) | |
56 | + compadd 'all' | |
57 | + _kitchen_instances | |
58 | + ;; | |
59 | + login) | |
60 | + _kitchen_instances | |
61 | + ;; | |
62 | + esac | |
63 | + ;; | |
64 | + esac | |
65 | +} | |
66 | + | |
67 | +_kitchen_commands() { | |
68 | + local commands | |
69 | + | |
70 | + commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ [].*# \(.*\)$/\1:\2/p')}") | |
71 | + _describe -t commands 'kitchen commands' commands | |
28 | 72 | } |
29 | 73 | |
30 | 74 | _kitchen_instances() { |
31 | - if [[ $_kitchen_instances_cache_dir != $PWD ]]; then | |
32 | - unset _kitchen_instances_cache | |
33 | - fi | |
34 | - if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then | |
35 | - _kitchen_instances_cache=(${(f)"$(bundle exec kitchen list -b 2>/dev/null || kitchen list -b 2>/dev/null)"}) | |
36 | - _kitchen_instances_cache_dir=$PWD | |
37 | - fi | |
38 | - compadd -a _kitchen_instances_cache | |
75 | + if [[ $_kitchen_instances_cache_dir != $PWD ]]; then | |
76 | + unset _kitchen_instances_cache | |
77 | + fi | |
78 | + if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then | |
79 | + _kitchen_instances_cache=(${(f)"$(_call_program instances $service list -b 2>/dev/null)"}) | |
80 | + _kitchen_instances_cache_dir=$PWD | |
81 | + fi | |
82 | + _wanted instances expl 'instance' compadd -a _kitchen_instances_cache | |
39 | 83 | } |
40 | 84 | |
41 | 85 | _kitchen "$@" |
... | ... | @@ -3,6 +3,9 @@ |
3 | 3 | # You can override the path to knife.rb and your cookbooks by setting |
4 | 4 | # KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb |
5 | 5 | # KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks |
6 | +# If you want your local cookbooks path to be calculated relative to where you are then | |
7 | +# set the below option | |
8 | +# KNIFE_RELATIVE_PATH=true | |
6 | 9 | # Read around where these are used for more detail. |
7 | 10 | |
8 | 11 | # These flags should be available everywhere according to man knife |
... | ... | @@ -119,7 +122,19 @@ _knife() { |
119 | 122 | _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))' |
120 | 123 | ;; |
121 | 124 | file) |
122 | - _arguments '*:file or directory:_files -g "*.(rb|json)"' | |
125 | + case $words[2] in | |
126 | + environment) | |
127 | + _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/environments"' | |
128 | + ;; | |
129 | + node) | |
130 | + _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/nodes"' | |
131 | + ;; | |
132 | + role) | |
133 | + _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/roles"' | |
134 | + ;; | |
135 | + *) | |
136 | + _arguments '*:Subsubcommands:($(_knife_options3))' | |
137 | + esac | |
123 | 138 | ;; |
124 | 139 | list) |
125 | 140 | compadd -a "$@" knife_general_flags |
... | ... | @@ -132,11 +147,22 @@ _knife() { |
132 | 147 | if (( versioncomp > 0 )); then |
133 | 148 | compadd "$@" attributes definitions files libraries providers recipes resources templates |
134 | 149 | else |
135 | - _arguments '*:Subsubcommands:($(_knife_options2))' | |
150 | + case $words[5] in | |
151 | + file) | |
152 | + _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ ' | |
153 | + ;; | |
154 | + *) _arguments '*:Subsubcommands:($(_knife_options2))' | |
155 | + esac | |
136 | 156 | fi |
137 | 157 | ;; |
138 | 158 | knifesubcmd5) |
139 | - _arguments '*:Subsubcommands:($(_knife_options3))' | |
159 | + case $words[5] in | |
160 | + file) | |
161 | + _arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"' | |
162 | + ;; | |
163 | + *) | |
164 | + _arguments '*:Subsubcommands:($(_knife_options3))' | |
165 | + esac | |
140 | 166 | esac |
141 | 167 | } |
142 | 168 | |
... | ... | @@ -184,12 +210,15 @@ _chef_environments_remote() { |
184 | 210 | |
185 | 211 | # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server |
186 | 212 | _chef_cookbooks_local() { |
187 | - | |
188 | - local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb} | |
189 | - if [ -f ./.chef/knife.rb ]; then | |
190 | - knife_rb="./.chef/knife.rb" | |
213 | + if [ $KNIFE_RELATIVE_PATH ]; then | |
214 | + local cookbook_path="$(_chef_root)/cookbooks" | |
215 | + else | |
216 | + local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb} | |
217 | + if [ -f ./.chef/knife.rb ]; then | |
218 | + knife_rb="./.chef/knife.rb" | |
219 | + fi | |
220 | + local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )} | |
191 | 221 | fi |
192 | - local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )} | |
193 | 222 | (for i in $cookbook_path; do ls $i; done) |
194 | 223 | } |
195 | 224 | |
... | ... | @@ -198,4 +227,15 @@ _cookbook_versions() { |
198 | 227 | (knife cookbook show $words[4] | grep -v $words[4] | grep -v -E '\]|\[|\{|\}' | sed 's/ //g' | sed 's/"//g') |
199 | 228 | } |
200 | 229 | |
230 | +# Searches up from current directory to find the closest folder that has a .chef folder | |
231 | +# Useful for the knife upload/from file commands | |
232 | +_chef_root () { | |
233 | + directory="$PWD" | |
234 | + while [ $directory != '/' ] | |
235 | + do | |
236 | + test -e "$directory/.chef" && echo "$directory" && return | |
237 | + directory="${directory:h}" | |
238 | + done | |
239 | +} | |
240 | + | |
201 | 241 | _knife "$@" |
... | ... | @@ -0,0 +1,45 @@ |
1 | +## Introduction | |
2 | + | |
3 | +The [meteor plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/meteor) provides many | |
4 | +[useful aliases](#aliases) as well as completion for the `meteor` command. | |
5 | + | |
6 | +Enable it by adding `meteor` to the plugins array in your zshrc file: | |
7 | +```zsh | |
8 | +plugins=(... meteor) | |
9 | +``` | |
10 | + | |
11 | +## Aliases | |
12 | + | |
13 | +| Alias | Command | Description | | |
14 | +|---------|----------------------------|------------------------------------------------------------------| | |
15 | +| `ma` | `meteor add` | Add a package to this project | | |
16 | +| `map` | `meteor add-platform` | Add a platform to this project | | |
17 | +| `mad` | `meteor admin` | Administrative commands | | |
18 | +| `mau` | `meteor authorized` | View or change authorized users and organizations for a site | | |
19 | +| `mb` | `meteor build` | Build this project for all platforms | | |
20 | +| `mcl` | `meteor claim` | Claim a site deployed with an old Meteor version | | |
21 | +| `mca` | `meteor configure-android` | Run the Android configuration tool from Meteor's ADK environment | | |
22 | +| `mc` | `meteor create` | Create a new project | | |
23 | +| `mdb` | `meteor debug` | Run the project, but suspend the server process for debugging | | |
24 | +| `mde` | `meteor deploy` | Deploy this project to Meteor | | |
25 | +| `mis` | `meteor install-sdk` | Installs SDKs for a platform | | |
26 | +| `ml` | `meteor list` | List the packages explicitly used by your project | | |
27 | +| `mlp` | `meteor list-platforms` | List the platforms added to your project | | |
28 | +| `mls` | `meteor list-sites` | List sites for which you are authorized | | |
29 | +| `mli` | `meteor login` | Log in to your Meteor developer account | | |
30 | +| `mlo` | `meteor logout` | Log out of your Meteor developer account | | |
31 | +| `mlog` | `meteor logs` | Show logs for specified site | | |
32 | +| `mm` | `meteor mongo` | Connect to the Mongo database for the specified site | | |
33 | +| `mp` | `meteor publish` | Publish a new version of a package to the package server | | |
34 | +| `mpa` | `meteor publish-for-arch` | Builds an already-published package for a new platform | | |
35 | +| `mpr` | `meteor publish-release` | Publish a new meteor release to the package server | | |
36 | +| `mr` | `meteor remove` | Remove a package from this project | | |
37 | +| `mrp` | `meteor remove-platform` | Remove a platform from this project | | |
38 | +| `mre` | `meteor reset` | Reset the project state. Erases the local database | | |
39 | +| `m` | `meteor run` | **[default]** Run this project in local development mode | | |
40 | +| `ms` | `meteor search` | Search through the package server database | | |
41 | +| `msh` | `meteor shell` | Launch a Node REPL for interactively evaluating server-side code | | |
42 | +| `msw` | `meteor show` | Show detailed information about a release or package | | |
43 | +| `mt` | `meteor test-packages` | Test one or more packages | | |
44 | +| `mu` | `meteor update` | Upgrade this project's dependencies to their latest versions | | |
45 | +| `mw` | `meteor whoami` | Prints the username of your Meteor developer account | |
... | ... | @@ -0,0 +1,33 @@ |
1 | +# Aliases in alphabetical order | |
2 | + | |
3 | +alias ma='meteor add' # Add a package to this project. | |
4 | +alias map='meteor add-platform' # Add a platform to this project. | |
5 | +alias mad='meteor admin' # Administrative commands. | |
6 | +alias mau='meteor authorized' # View or change authorized users and organizations for a site. | |
7 | +alias mb='meteor build' # Build this project for all platforms. | |
8 | +alias mcl='meteor claim' # Claim a site deployed with an old Meteor version. | |
9 | +alias mca='meteor configure-android' # Run the Android configuration tool from Meteor's ADK environment. | |
10 | +alias mc='meteor create' # Create a new project. | |
11 | +alias mdb='meteor debug' # Run the project, but suspend the server process for debugging. | |
12 | +alias mde='meteor deploy' # Deploy this project to Meteor. | |
13 | +alias mis='meteor install-sdk' # Installs SDKs for a platform. | |
14 | +alias ml='meteor list' # List the packages explicitly used by your project. | |
15 | +alias mlp='meteor list-platforms' # List the platforms added to your project. | |
16 | +alias mls='meteor list-sites' # List sites for which you are authorized. | |
17 | +alias mli='meteor login' # Log in to your Meteor developer account. | |
18 | +alias mlo='meteor logout' # Log out of your Meteor developer account. | |
19 | +alias mlog='meteor logs' # Show logs for specified site. | |
20 | +alias mm='meteor mongo' # Connect to the Mongo database for the specified site. | |
21 | +alias mp='meteor publish' # Publish a new version of a package to the package server. | |
22 | +alias mpa='meteor publish-for-arch' # Builds an already-published package for a new platform. | |
23 | +alias mpr='meteor publish-release' # Publish a new meteor release to the package server. | |
24 | +alias mr='meteor remove' # Remove a package from this project. | |
25 | +alias mrp='meteor remove-platform' # Remove a platform from this project. | |
26 | +alias mre='meteor reset' # Reset the project state. Erases the local database. | |
27 | +alias m='meteor run' # [default] Run this project in local development mode. | |
28 | +alias ms='meteor search' # Search through the package server database. | |
29 | +alias msh='meteor shell' # Launch a Node REPL for interactively evaluating server-side code. | |
30 | +alias msw='meteor show' # Show detailed information about a release or package. | |
31 | +alias mt='meteor test-packages' # Test one or more packages. | |
32 | +alias mu='meteor update' # Upgrade this project's dependencies to their latest versions. | |
33 | +alias mw='meteor whoami' # Prints the username of your Meteor developer account. |
... | ... | @@ -38,6 +38,15 @@ _1st_arguments=( |
38 | 38 | 'local.hex:Install hex locally' |
39 | 39 | 'local.rebar:Install rebar locally' |
40 | 40 | 'new:Create a new Elixir project' |
41 | + 'phoenix.digest:Digests and compress static files' | |
42 | + 'phoenix.gen.channel:Generates a Phoenix channel' | |
43 | + 'phoenix.gen.html:Generates controller, model and views for an HTML based resource' | |
44 | + 'phoenix.gen.json:Generates a controller and model for a JSON based resource' | |
45 | + 'phoenix.gen.model:Generates an Ecto model' | |
46 | + 'phoenix.gen.secret:Generates a secret' | |
47 | + 'phoenix.new:Create a new Phoenix application' | |
48 | + 'phoenix.routes:Prints all routes' | |
49 | + 'phoenix.server:Starts applications and their servers' | |
41 | 50 | 'run:Run the given file or expression' |
42 | 51 | "test:Run a project's tests" |
43 | 52 | '--help:Describe available tasks' |
... | ... | @@ -49,7 +58,7 @@ __task_list () |
49 | 58 | local expl |
50 | 59 | declare -a tasks |
51 | 60 | |
52 | - tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new run test) | |
61 | + tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server run test) | |
53 | 62 | |
54 | 63 | _wanted tasks expl 'help' compadd $tasks |
55 | 64 | } |
... | ... | @@ -73,7 +82,10 @@ case $state in |
73 | 82 | case $line[1] in |
74 | 83 | (help) |
75 | 84 | _arguments ':feature:__task_list' |
85 | + ;; | |
86 | + (test) | |
87 | + _files | |
88 | + ;; | |
76 | 89 | esac |
77 | 90 | ;; |
78 | 91 | esac |
79 | - |
... | ... | @@ -0,0 +1,33 @@ |
1 | +## Introduction | |
2 | + | |
3 | +The [mvn plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/mvn) provides many | |
4 | +[useful aliases](#aliases) as well as completion for the `mvn` command. | |
5 | + | |
6 | +Enable it by adding `mvn` to the plugins array in your zshrc file: | |
7 | +```zsh | |
8 | +plugins=(... mvn) | |
9 | +``` | |
10 | + | |
11 | +## Aliases | |
12 | + | |
13 | +| Alias | Command | | |
14 | +|:---------------------|:------------------------------------------------| | |
15 | +| `mvncie` | `mvn clean install eclipse:eclipse` | | |
16 | +| `mvnci` | `mvn clean install` | | |
17 | +| `mvncist` | `mvn clean install -DskipTests` | | |
18 | +| `mvncisto` | `mvn clean install -DskipTests --offline` | | |
19 | +| `mvne` | `mvn eclipse:eclipse` | | |
20 | +| `mvnd` | `mvn deploy` | | |
21 | +| `mvnp` | `mvn package` | | |
22 | +| `mvnc` | `mvn clean` | | |
23 | +| `mvncom` | `mvn compile` | | |
24 | +| `mvnct` | `mvn clean test` | | |
25 | +| `mvnt` | `mvn test` | | |
26 | +| `mvnag` | `mvn archetype:generate` | | |
27 | +| `mvn-updates` | `mvn versions:display-dependency-updates` | | |
28 | +| `mvntc7` | `mvn tomcat7:run` | | |
29 | +| `mvnjetty` | `mvn jetty:run` | | |
30 | +| `mvndt` | `mvn dependency:tree` | | |
31 | +| `mvns` | `mvn site` | | |
32 | +| `mvnsrc` | `mvn dependency:sources` | | |
33 | +| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` | |
... | ... | @@ -45,6 +45,7 @@ mvn-color() |
45 | 45 | alias mvncie='mvn clean install eclipse:eclipse' |
46 | 46 | alias mvnci='mvn clean install' |
47 | 47 | alias mvncist='mvn clean install -DskipTests' |
48 | +alias mvncisto='mvn clean install -DskipTests --offline' | |
48 | 49 | alias mvne='mvn eclipse:eclipse' |
49 | 50 | alias mvnce='mvn clean eclipse:clean eclipse:eclipse' |
50 | 51 | alias mvnd='mvn deploy' |
... | ... | @@ -171,7 +172,7 @@ function listMavenCompletions { |
171 | 172 | gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test |
172 | 173 | |
173 | 174 | # options |
174 | - -Dmaven.test.skip=true -DskipTests -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven | |
175 | + -Dmaven.test.skip=true -DskipTests -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true | |
175 | 176 | |
176 | 177 | # arguments |
177 | 178 | -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X |
1 | -eval "$(npm completion 2>/dev/null)" | |
1 | +(( $+commands[npm] )) && { | |
2 | + __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" | |
3 | + | |
4 | + if [[ ! -f $__NPM_COMPLETION_FILE ]]; then | |
5 | + npm completion >! $__NPM_COMPLETION_FILE || rm -f $__NPM_COMPLETION_FILE | |
6 | + fi | |
7 | + | |
8 | + source $__NPM_COMPLETION_FILE | |
9 | +} | |
2 | 10 | |
3 | 11 | # Install dependencies globally |
4 | 12 | alias npmg="npm i -g " |
... | ... | @@ -20,3 +28,10 @@ alias npmE='PATH="$(npm bin)":"$PATH"' |
20 | 28 | |
21 | 29 | # Check which npm modules are outdated |
22 | 30 | alias npmO="npm outdated" |
31 | + | |
32 | +# Run npm start | |
33 | +alias npmst="npm start" | |
34 | + | |
35 | +# Run npm test | |
36 | +alias npmt="npm test" | |
37 | + |
... | ... | @@ -0,0 +1,32 @@ |
1 | +# OSX plugin | |
2 | + | |
3 | +## Description | |
4 | + | |
5 | +This plugin provides a few utilities to make it more enjoyable on OSX. | |
6 | + | |
7 | +To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`: | |
8 | + | |
9 | +```zsh | |
10 | +plugins=(... osx) | |
11 | +``` | |
12 | + | |
13 | +Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) | |
14 | + | |
15 | + | |
16 | +## Commands | |
17 | + | |
18 | +| Command | Description | | |
19 | +| :-------------- | :----------------------------------------------- | | |
20 | +| `tab` | Open the current directory in a new tab | | |
21 | +| `split_tab` | Split the current terminal tab horizontally | | |
22 | +| `vsplit_tab` | Split the current terminal tab vertically | | |
23 | +| `ofd` | Open the current directory in a Finder window | | |
24 | +| `pfd` | Return the path of the frontmost Finder window | | |
25 | +| `pfs` | Return the current Finder selection | | |
26 | +| `cdf` | `cd` to the current Finder directory | | |
27 | +| `pushdf` | `pushd` to the current Finder directory | | |
28 | +| `quick-look` | Quick-Look a specified file | | |
29 | +| `man-preview` | Open a specified man page in Preview app | | |
30 | +| `showfiles` | Show hidden files | | |
31 | +| `hidefiles` | Hide the hidden files | | |
32 | +| `itunes` | Control iTunes. User `itunes -h` for usage details | |
1 | -# ------------------------------------------------------------------------------ | |
2 | -# FILE: osx.plugin.zsh | |
3 | -# DESCRIPTION: oh-my-zsh plugin file. | |
4 | -# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) | |
5 | -# VERSION: 1.1.0 | |
6 | -# ------------------------------------------------------------------------------ | |
1 | +# Open the current directory in a Finder window | |
2 | +alias ofd='open_command $PWD' | |
7 | 3 | |
8 | 4 | function _omz_osx_get_frontmost_app() { |
9 | 5 | local the_app=$( |
... | ... | @@ -46,6 +42,16 @@ EOF |
46 | 42 | end tell |
47 | 43 | EOF |
48 | 44 | |
45 | + elif [[ "$the_app" == 'iTerm2' ]]; then | |
46 | + osascript <<EOF | |
47 | + tell application "iTerm2" | |
48 | + tell current window | |
49 | + create tab with default profile | |
50 | + tell current session to write text "${command}" | |
51 | + end tell | |
52 | + end tell | |
53 | +EOF | |
54 | + | |
49 | 55 | else |
50 | 56 | echo "tab: unsupported terminal app: $the_app" |
51 | 57 | false |
... | ... | @@ -73,6 +79,19 @@ function vsplit_tab() { |
73 | 79 | end tell |
74 | 80 | EOF |
75 | 81 | |
82 | + elif [[ "$the_app" == 'iTerm2' ]]; then | |
83 | + osascript <<EOF | |
84 | + tell application "iTerm2" | |
85 | + tell current session of first window | |
86 | + set newSession to (split vertically with same profile) | |
87 | + tell newSession | |
88 | + write text "${command}" | |
89 | + select | |
90 | + end tell | |
91 | + end tell | |
92 | + end tell | |
93 | +EOF | |
94 | + | |
76 | 95 | else |
77 | 96 | echo "$0: unsupported terminal app: $the_app" >&2 |
78 | 97 | false |
... | ... | @@ -100,6 +119,19 @@ function split_tab() { |
100 | 119 | end tell |
101 | 120 | EOF |
102 | 121 | |
122 | + elif [[ "$the_app" == 'iTerm2' ]]; then | |
123 | + osascript <<EOF | |
124 | + tell application "iTerm2" | |
125 | + tell current session of first window | |
126 | + set newSession to (split horizontally with same profile) | |
127 | + tell newSession | |
128 | + write text "${command}" | |
129 | + select | |
130 | + end tell | |
131 | + end tell | |
132 | + end tell | |
133 | +EOF | |
134 | + | |
103 | 135 | else |
104 | 136 | echo "$0: unsupported terminal app: $the_app" >&2 |
105 | 137 | false |
... | ... | @@ -143,6 +175,7 @@ function quick-look() { |
143 | 175 | function man-preview() { |
144 | 176 | man -t "$@" | open -f -a Preview |
145 | 177 | } |
178 | +compdef _man man-preview | |
146 | 179 | |
147 | 180 | function vncviewer() { |
148 | 181 | open vnc://$@ |
... | ... | @@ -227,3 +260,7 @@ EOF |
227 | 260 | esac |
228 | 261 | osascript -e "tell application \"iTunes\" to $opt" |
229 | 262 | } |
263 | + | |
264 | +# Show/hide hidden files in the Finder | |
265 | +alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" | |
266 | +alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" |
... | ... | @@ -0,0 +1,9 @@ |
1 | +## Perms | |
2 | + | |
3 | +Plugin to handle some unix filesystem permissions quickly | |
4 | + | |
5 | +### Usage | |
6 | + | |
7 | +* `set755` recursively sets all directories located within the current working directory and sub directories to octal 755. | |
8 | +* `set644` recursively sets all files located within the current working directory and sub directories to octal 644. | |
9 | +* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases. | |
0 | 10 | \ No newline at end of file |
... | ... | @@ -0,0 +1,78 @@ |
1 | +# Some useful commands for setting permissions. | |
2 | +# | |
3 | +# Rory Hardy [GneatGeek] | |
4 | +# Andrew Janke [apjanke] | |
5 | + | |
6 | +### Aliases | |
7 | + | |
8 | +# Set all files' permissions to 644 recursively in a directory | |
9 | +alias set644='find . -type f -print0 | xargs -0 chmod 644' | |
10 | + | |
11 | +# Set all directories' permissions to 755 recursively in a directory | |
12 | +alias set755='find . -type d -print0 | xargs -0 chmod 755' | |
13 | + | |
14 | +### Functions | |
15 | + | |
16 | +# fixperms - fix permissions on files and directories, with confirmation | |
17 | +# Returns 0 on success, nonzero if any errors occurred | |
18 | +fixperms () { | |
19 | + local opts confirm target exit_status chmod_opts use_slow_mode | |
20 | + zparseopts -E -D -a opts -help -slow v+=chmod_opts | |
21 | + if [[ $# > 1 || -n "${opts[(r)--help]}" ]]; then | |
22 | + cat <<EOF | |
23 | +Usage: fixperms [-v] [--help] [--slow] [target] | |
24 | + | |
25 | + target is the file or directory to change permissions on. If omitted, | |
26 | + the current directory is taken to be the target. | |
27 | + | |
28 | + -v enables verbose output (may be supplied multiple times) | |
29 | + | |
30 | + --slow will use a slower but more robust mode, which is effective if | |
31 | + directories themselves have permissions that forbid you from | |
32 | + traversing them. | |
33 | + | |
34 | +EOF | |
35 | + exit_status=$(( $# > 1 )) | |
36 | + return $exit_status | |
37 | + fi | |
38 | + | |
39 | + if [[ $# == 0 ]]; then | |
40 | + target="." | |
41 | + else | |
42 | + target="$1" | |
43 | + fi | |
44 | + if [[ -n ${opts[(r)--slow]} ]]; then use_slow=true; else use_slow=false; fi | |
45 | + | |
46 | + # Because this requires confirmation, bail in noninteractive shells | |
47 | + if [[ ! -o interactive ]]; then | |
48 | + echo "fixperms: cannot run in noninteractive shell" | |
49 | + return 1 | |
50 | + fi | |
51 | + | |
52 | + echo "Fixing perms on $target?" | |
53 | + printf '%s' "Proceed? (y|n) " | |
54 | + read confirm | |
55 | + if [[ "$confirm" != y ]]; then | |
56 | + # User aborted | |
57 | + return 1 | |
58 | + fi | |
59 | + | |
60 | + # This xargs form is faster than -exec chmod <N> {} \; but will encounter | |
61 | + # issues if the directories themselves have permissions such that you can't | |
62 | + # recurse in to them. If that happens, just rerun this a few times. | |
63 | + exit_status=0; | |
64 | + if [[ $use_slow == true ]]; then | |
65 | + # Process directories first so non-traversable ones are fixed as we go | |
66 | + find "$target" -type d -exec chmod $chmod_opts 755 {} \; | |
67 | + if [[ $? != 0 ]]; then exit_status=$?; fi | |
68 | + find "$target" -type f -exec chmod $chmod_opts 644 {} \; | |
69 | + if [[ $? != 0 ]]; then exit_status=$?; fi | |
70 | + else | |
71 | + find "$target" -type d -print0 | xargs -0 chmod $chmod_opts 755 | |
72 | + if [[ $? != 0 ]]; then exit_status=$?; fi | |
73 | + find "$target" -type f -print0 | xargs -0 chmod $chmod_opts 644 | |
74 | + if [[ $? != 0 ]]; then exit_status=$?; fi | |
75 | + fi | |
76 | + echo "Complete" | |
77 | + return $exit_status | |
78 | +} |
1 | -_phing_does_target_list_need_generating () { | |
2 | - [ ! -f .phing_targets ] && return 0; | |
3 | - [ build.xml -nt .phing_targets ] && return 0; | |
4 | - return 1; | |
5 | -} | |
6 | - | |
7 | 1 | _phing () { |
8 | 2 | if [ -f build.xml ]; then |
9 | - if _phing_does_target_list_need_generating; then | |
10 | - phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets | |
11 | - fi | |
12 | - compadd `cat .phing_targets` | |
3 | + compadd $(phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|grep -v "Warning:"|awk '{print $1}') | |
13 | 4 | fi |
14 | 5 | } |
15 | 6 |
... | ... | @@ -0,0 +1,45 @@ |
1 | +# pj | |
2 | + | |
3 | +The `pj` plugin (short for `Project Jump`) allows you to define several | |
4 | +folders where you store your projects, so that you can jump there directly | |
5 | +by just using the name of the project directory. | |
6 | + | |
7 | +Original idea and code by Jan De Poorter ([@DefV](https://github.com/DefV)) | |
8 | +Source: https://gist.github.com/pjaspers/368394#gistcomment-1016 | |
9 | + | |
10 | +## Usage | |
11 | + | |
12 | +1. Enable the `pj` plugin: | |
13 | + | |
14 | + ```zsh | |
15 | + plugins=(... pj) | |
16 | + ``` | |
17 | + | |
18 | +2. Set `$PROJECT_PATHS` in your ~/.zshrc: | |
19 | + | |
20 | + ```zsh | |
21 | + PROJECT_PATHS=(~/src ~/work ~/"dir with spaces") | |
22 | + ``` | |
23 | + | |
24 | +You can now use one of the following commands: | |
25 | + | |
26 | +##### `pj my-project`: | |
27 | + | |
28 | +`cd` to the directory named "my-project" found in one of the `$PROJECT_PATHS` | |
29 | +directories. If there are several directories named the same, the first one | |
30 | +to appear in `$PROJECT_PATHS` has preference. | |
31 | + | |
32 | +For example: | |
33 | +```zsh | |
34 | +PROJECT_PATHS=(~/code ~/work) | |
35 | +$ ls ~/code # ~/code/blog ~/code/react | |
36 | +$ ls ~/work # ~/work/blog ~/work/project | |
37 | +$ pj blog # <-- will cd to ~/code/blog | |
38 | +``` | |
39 | + | |
40 | +##### `pjo my-project` | |
41 | + | |
42 | +Open the project directory with your defined `$EDITOR`. This follows the same | |
43 | +directory rules as the `pj` command above. | |
44 | + | |
45 | +Note: `pjo` is an alias of `pj open`. |
1 | -#!/bin/zsh | |
2 | - | |
3 | -# | |
4 | -# Original idea by DefV (Jan De Poorter) | |
5 | -# Source: https://gist.github.com/pjaspers/368394#comment-1016 | |
6 | -# | |
7 | -# Usage: | |
8 | -# - Set `$PROJECT_PATHS` in your ~/.zshrc | |
9 | -# e.g.: PROJECT_PATHS=(~/src ~/work) | |
10 | -# - In ZSH you now can open a project directory with the command: `pj my-project` | |
11 | -# the plugin will locate the `my-project` directory in one of the $PROJECT_PATHS | |
12 | -# Also tab completion is supported. | |
13 | -# - `pjo my-project` will open the directory in $EDITOR | |
14 | -# | |
15 | - | |
16 | -function pj() { | |
1 | +alias pjo="pj open" | |
2 | + | |
3 | +pj () { | |
4 | + emulate -L zsh | |
5 | + | |
17 | 6 | cmd="cd" |
18 | - file=$1 | |
7 | + project=$1 | |
19 | 8 | |
20 | - if [[ "open" == "$file" ]] then | |
9 | + if [[ "open" == "$project" ]]; then | |
21 | 10 | shift |
22 | - file=$* | |
23 | - cmd=(${(s: :)EDITOR}) | |
11 | + project=$* | |
12 | + cmd=${=EDITOR} | |
24 | 13 | else |
25 | - file=$* | |
14 | + project=$* | |
26 | 15 | fi |
27 | 16 | |
28 | - for project in $PROJECT_PATHS; do | |
29 | - if [[ -d $project/$file ]] then | |
30 | - $cmd "$project/$file" | |
31 | - unset project # Unset project var | |
17 | + for basedir ($PROJECT_PATHS); do | |
18 | + if [[ -d "$basedir/$project" ]]; then | |
19 | + $cmd "$basedir/$project" | |
32 | 20 | return |
33 | 21 | fi |
34 | 22 | done |
35 | 23 | |
36 | - echo "No such project $1" | |
24 | + echo "No such project '${project}'." | |
37 | 25 | } |
38 | 26 | |
39 | -alias pjo="pj open" | |
27 | +_pj () { | |
28 | + emulate -L zsh | |
40 | 29 | |
41 | -function _pj () { | |
42 | - # might be possible to improve this using glob, without the basename trick | |
43 | 30 | typeset -a projects |
44 | - projects=($PROJECT_PATHS/*) | |
45 | - projects=$projects:t | |
46 | - _arguments "*:file:($projects)" | |
47 | -} | |
31 | + for basedir ($PROJECT_PATHS); do | |
32 | + projects+=(${basedir}/*(/N)) | |
33 | + done | |
48 | 34 | |
35 | + compadd ${projects:t} | |
36 | +} | |
49 | 37 | compdef _pj pj |
... | ... | @@ -13,6 +13,8 @@ function _rails_command () { |
13 | 13 | function _rake_command () { |
14 | 14 | if [ -e "bin/rake" ]; then |
15 | 15 | bin/rake $@ |
16 | + elif type bundle &> /dev/null && [ -e "Gemfile" ]; then | |
17 | + bundle exec rake $@ | |
16 | 18 | else |
17 | 19 | command rake $@ |
18 | 20 | fi |
... | ... | @@ -55,6 +57,7 @@ alias rdrs='rake db:reset' |
55 | 57 | alias rdtc='rake db:test:clone' |
56 | 58 | alias rdtp='rake db:test:prepare' |
57 | 59 | alias rdmtc='rake db:migrate db:test:clone' |
60 | +alias rdsl='rake db:schema:load' | |
58 | 61 | alias rlc='rake log:clear' |
59 | 62 | alias rn='rake notes' |
60 | 63 | alias rr='rake routes' |
... | ... | @@ -2,22 +2,34 @@ |
2 | 2 | |
3 | 3 | Fast rake autocompletion plugin. |
4 | 4 | |
5 | -This script caches the output for later usage and significantly speeds it up. It generates a .rake_tasks cache file in parallel to the Rakefile. It also checks the file modification dates to see if it needs to regenerate the cache file. | |
5 | +This plugin caches the output for later usage and significantly speeds it up. | |
6 | +It generates a `.rake_tasks` cache file in parallel to the Rakefile. It also | |
7 | +checks the file modification time to see if it needs to regenerate the cache | |
8 | +file. | |
6 | 9 | |
7 | -This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/). | |
10 | +This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), | |
11 | +which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/). | |
8 | 12 | |
9 | 13 | Think about that. 2006. |
10 | 14 | |
15 | +---------- | |
16 | + | |
17 | +Since August of 2016, it also checks if it's in a Rails project and looks at | |
18 | +rake files inside `lib/tasks` and their modification time to know if the | |
19 | +cache file needs to be regenerated. | |
20 | + | |
11 | 21 | ## Installation |
12 | 22 | |
13 | 23 | Just add the plugin to your `.zshrc`: |
14 | 24 | |
15 | -```bash | |
16 | -plugins=(foo bar rake-fast) | |
25 | +```zsh | |
26 | +plugins=(... rake-fast) | |
17 | 27 | ``` |
18 | 28 | |
19 | 29 | You might consider adding `.rake_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore) |
20 | 30 | |
21 | 31 | ## Usage |
22 | 32 | |
23 | -`rake`, then press tab | |
33 | +Type `rake`, then press tab. | |
34 | + | |
35 | +If you want to force the regeneration of the `.rake_tasks` file, run `rake_refresh`. |
1 | -_rake_refresh () { | |
2 | - if [ -f .rake_tasks ]; then | |
3 | - rm .rake_tasks | |
4 | - fi | |
5 | - echo "Generating .rake_tasks..." > /dev/stderr | |
6 | - _rake_generate | |
7 | - cat .rake_tasks | |
1 | +_rake_does_task_list_need_generating () { | |
2 | + [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] || { _is_rails_app && _tasks_changed } | |
8 | 3 | } |
9 | 4 | |
10 | -_rake_does_task_list_need_generating () { | |
11 | - [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] | |
5 | +_is_rails_app () { | |
6 | + [[ -e "bin/rails" ]] || [[ -e "script/rails" ]] | |
7 | +} | |
8 | + | |
9 | +_tasks_changed () { | |
10 | + local -a files | |
11 | + files=(lib/tasks lib/tasks/**/*(N)) | |
12 | + | |
13 | + for file in $files; do | |
14 | + if [[ "$file" -nt .rake_tasks ]]; then | |
15 | + return 0 | |
16 | + fi | |
17 | + done | |
18 | + | |
19 | + return 1 | |
12 | 20 | } |
13 | 21 | |
14 | 22 | _rake_generate () { |
... | ... | @@ -16,14 +24,20 @@ _rake_generate () { |
16 | 24 | } |
17 | 25 | |
18 | 26 | _rake () { |
19 | - if [ -f Rakefile ]; then | |
27 | + if [[ -f Rakefile ]]; then | |
20 | 28 | if _rake_does_task_list_need_generating; then |
21 | - echo "\nGenerating .rake_tasks..." > /dev/stderr | |
29 | + echo "\nGenerating .rake_tasks..." >&2 | |
22 | 30 | _rake_generate |
23 | 31 | fi |
24 | - compadd `cat .rake_tasks` | |
32 | + compadd $(cat .rake_tasks) | |
25 | 33 | fi |
26 | 34 | } |
27 | - | |
28 | 35 | compdef _rake rake |
29 | -alias rake_refresh='_rake_refresh' | |
36 | + | |
37 | +rake_refresh () { | |
38 | + [[ -f .rake_tasks ]] && rm -f .rake_tasks | |
39 | + | |
40 | + echo "Generating .rake_tasks..." >&2 | |
41 | + _rake_generate | |
42 | + cat .rake_tasks | |
43 | +} |
... | ... | @@ -0,0 +1,14 @@ |
1 | +# React Native | |
2 | + | |
3 | +**Maintainer:** [BilalBudhani](https://github.com/BilalBudhani) | |
4 | + | |
5 | +### List of Aliases | |
6 | + | |
7 | +Alias | React Native command | |
8 | +------|--------------------- | |
9 | +**rnand** | *react-native run-android* | |
10 | +**rnios** | *react-native run-ios* | |
11 | +**rnios4s** | *react-native run-ios --simulator "iPhone 4s"* | |
12 | +**rnios5** | *react-native run-ios --simulator "iPhone 5"* | |
13 | +**rnios5s** | *react-native run-ios --simulator "iPhone 5s"* | |
14 | + |
... | ... | @@ -0,0 +1,23 @@ |
1 | +#compdef react-native | |
2 | +#autoload | |
3 | + | |
4 | +local -a _1st_arguments | |
5 | +_1st_arguments=( | |
6 | + 'start:starts the webserver' | |
7 | + 'bundle:builds the javascript bundle for offline use' | |
8 | + 'new-library:generates a native library bridge' | |
9 | + 'android:generates an Android project for your app' | |
10 | + 'run-android:builds your app and starts it on a connected Android emulator or device' | |
11 | + 'upgrade:upgrade your apps template files to the latest version; run this after updating the react-native version in your package.json and running npm install' | |
12 | +) | |
13 | + | |
14 | + | |
15 | +_arguments \ | |
16 | + '(--version)--version[show version]' \ | |
17 | + '(--help)--help[show help]' \ | |
18 | + '*:: :->subcmds' && return 0 | |
19 | + | |
20 | +if (( CURRENT == 1 )); then | |
21 | + _describe -t commands "react-native subcommand" _1st_arguments | |
22 | + return | |
23 | +fi |
... | ... | @@ -0,0 +1,191 @@ |
1 | +#compdef rustc | |
2 | + | |
3 | +local -a _rustc_opts_switches _rustc_opts_lint _rustc_opts_debug | |
4 | + | |
5 | +typeset -A opt_args | |
6 | + | |
7 | +_rustc_debuginfo_levels=( | |
8 | + "0[no debug info]" | |
9 | + "1[line-tables only (for stacktraces and breakpoints)]" | |
10 | + "2[full debug info with variable and type information (same as -g)]" | |
11 | +) | |
12 | + | |
13 | +_rustc_crate_types=( | |
14 | + 'bin' | |
15 | + 'lib' | |
16 | + 'rlib' | |
17 | + 'dylib' | |
18 | + 'staticlib' | |
19 | +) | |
20 | + | |
21 | +_rustc_emit_types=( | |
22 | + 'asm' | |
23 | + 'bc' | |
24 | + 'ir' | |
25 | + 'obj' | |
26 | + 'link' | |
27 | +) | |
28 | +_rustc_pretty_types=( | |
29 | + 'normal[un-annotated source]' | |
30 | + 'expanded[crates expanded]' | |
31 | + 'typed[crates expanded, with type annotations]' | |
32 | + 'identified[fully parenthesized, AST nodes and blocks with IDs]' | |
33 | + 'flowgraph=[graphviz formatted flowgraph for node]:NODEID:' | |
34 | +) | |
35 | +_rustc_color_types=( | |
36 | + 'auto[colorize, if output goes to a tty (default)]' | |
37 | + 'always[always colorize output]' | |
38 | + 'never[never colorize output]' | |
39 | +) | |
40 | + | |
41 | +_rustc_opts_vals=( | |
42 | + --crate-name='[Specify the name of the crate being built]' | |
43 | + --crate-type='[Comma separated list of types of crates for the compiler to emit]:TYPES:_values -s "," "Crate types" "$_rustc_crate_types[@]"' | |
44 | + --emit='[Comma separated list of types of output for the compiler to emit]:TYPES:_values -s "," "Emit Targets" "$_rustc_emit_types[@]"' | |
45 | + --debuginfo='[Emit DWARF debug info to the objects created]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"' | |
46 | + --dep-info='[Output dependency info to <filename> after compiling]::FILE:_files -/' | |
47 | + --sysroot='[Override the system root]:PATH:_files -/' | |
48 | + --cfg='[Configure the compilation environment]:SPEC:' | |
49 | + --out-dir='[Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. (default the current directory)]:DIR:_files -/' | |
50 | + -o'[Write output to <filename>. Ignored if more than one --emit is specified.]:FILENAME:_files' | |
51 | + --opt-level='[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)' | |
52 | + --pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"' | |
53 | + -L'[Add a directory to the library search path]:DIR:_files -/' | |
54 | + --target='[Target triple cpu-manufacturer-kernel\[-os\] to compile]:TRIPLE:' | |
55 | + --color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"' | |
56 | + {-v,--version}'[Print version info and exit]::VERBOSE:(verbose)' | |
57 | + --explain='[Provide a detailed explanation of an error message]:OPT:' | |
58 | + --extern'[Specify where an external rust library is located]:ARG:' | |
59 | +) | |
60 | + | |
61 | +_rustc_opts_switches=( | |
62 | + -g'[Equivalent to --debuginfo=2]' | |
63 | + {-h,--help}'[Display this message]' | |
64 | + --no-analysis'[Parse and expand the output, but run no analysis or produce output]' | |
65 | + --no-trans'[Run all passes except translation; no output]' | |
66 | + -O'[Equivalent to --opt-level=2]' | |
67 | + --parse-only'[Parse only; do not compile, assemble, or link]' | |
68 | + --print-crate-name'[Output the crate name and exit]' | |
69 | + --print-file-name'[Output the file(s) that would be written if compilation continued and exit]' | |
70 | + --test'[Build a test harness]' | |
71 | +) | |
72 | +_rustc_opts_codegen=( | |
73 | + 'ar=[Path to the archive utility to use when assembling archives.]:BIN:_path_files' | |
74 | + 'linker=[Path to the linker utility to use when linking libraries, executables, and objects.]:BIN:_path_files' | |
75 | + 'link-args=[A space-separated list of extra arguments to pass to the linker when the linker is invoked.]:ARGS:' | |
76 | + 'target-cpu=[Selects a target processor. If the value is "help", then a list of available CPUs is printed.]:CPU:' | |
77 | + 'target-feature=[A space-separated list of features to enable or disable for the target. A preceding "+" enables a feature while a preceding "-" disables it. Available features can be discovered through target-cpu=help.]:FEATURE:' | |
78 | + 'passes=[A space-separated list of extra LLVM passes to run. A value of "list" will cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager.]:LIST:' | |
79 | + 'llvm-args=[A space-separated list of arguments to pass through to LLVM.]:ARGS:' | |
80 | + 'save-temps[If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated throughout compilation in the output directory.]' | |
81 | + 'rpath[If specified, then the rpath value for dynamic libraries will be set in either dynamic library or executable outputs.]' | |
82 | + 'no-prepopulate-passes[Suppresses pre-population of the LLVM pass manager that is run over the module.]' | |
83 | + 'no-vectorize-loops[Suppresses running the loop vectorization LLVM pass, regardless of optimization level.]' | |
84 | + 'no-vectorize-slp[Suppresses running the LLVM SLP vectorization pass, regardless of optimization level.]' | |
85 | + 'soft-float[Generates software floating point library calls instead of hardware instructions.]' | |
86 | + 'prefer-dynamic[Prefers dynamic linking to static linking.]' | |
87 | + "no-integrated-as[Force usage of an external assembler rather than LLVM's integrated one.]" | |
88 | + 'no-redzone[disable the use of the redzone]' | |
89 | + 'relocation-model=[The relocation model to use. (default: pic)]:MODEL:(pic static dynamic-no-pic)' | |
90 | + 'code-model=[choose the code model to use (llc -code-model for details)]:MODEL:' | |
91 | + 'metadata=[metadata to mangle symbol names with]:VAL:' | |
92 | + 'extra-filenames=[extra data to put in each output filename]:VAL:' | |
93 | + 'codegen-units=[divide crate into N units to optimize in parallel]:N:' | |
94 | + 'help[Show all codegen options]' | |
95 | +) | |
96 | + | |
97 | +_rustc_opts_lint=( | |
98 | + 'help[Show a list of all lints]' | |
99 | + 'experimental[detects use of #\[experimental\] items]' | |
100 | + 'heap-memory[use of any (Box type or @ type) heap memory]' | |
101 | + 'managed-heap-memory[use of managed (@ type) heap memory]' | |
102 | + 'missing-doc[detects missing documentation for public members]' | |
103 | + 'non-uppercase-statics[static constants should have uppercase identifiers]' | |
104 | + 'owned-heap-memory[use of owned (~ type) heap memory]' | |
105 | + 'unnecessary-qualification[detects unnecessarily qualified names]' | |
106 | + 'unsafe-block[usage of an `unsafe` block]' | |
107 | + 'unstable[detects use of #\[unstable\] items (incl. items with no stability attribute)]' | |
108 | + 'unused-result[unused result of an expression in a statement]' | |
109 | + 'variant-size-difference[detects enums with widely varying variant sizes]' | |
110 | + 'ctypes[proper use of libc types in foreign modules]' | |
111 | + 'dead-assignment[detect assignments that will never be read]' | |
112 | + 'dead-code[detect piece of code that will never be used]' | |
113 | + 'deprecated[detects use of #\[deprecated\] items]' | |
114 | + 'non-camel-case-types[types, variants and traits should have camel case names]' | |
115 | + 'non-snake-case[methods, functions, lifetime parameters and modules should have snake case names]' | |
116 | + 'path-statement[path statements with no effect]' | |
117 | + 'raw-pointer-deriving[uses of #\[deriving\] with raw pointers are rarely correct]' | |
118 | + 'type-limits[comparisons made useless by limits of the types involved]' | |
119 | + 'type-overflow[literal out of range for its type]' | |
120 | + 'unnecessary-allocation[detects unnecessary allocations that can be eliminated]' | |
121 | + 'unnecessary-parens[`if`, `match`, `while` and `return` do not need parentheses]' | |
122 | + 'unreachable-code[detects unreachable code]' | |
123 | + 'unrecognized-lint[unrecognized lint attribute]' | |
124 | + 'unsigned-negate[using an unary minus operator on unsigned type]' | |
125 | + 'unused-attribute[detects attributes that were not used by the compiler]' | |
126 | + 'unused-imports[imports that are never used]' | |
127 | + 'unused-must-use[unused result of a type flagged as #\[must_use\]]' | |
128 | + "unused-mut[detect mut variables which don't need to be mutable]" | |
129 | + 'unused-unsafe[unnecessary use of an `unsafe` block]' | |
130 | + 'unused-variable[detect variables which are not used in any way]' | |
131 | + 'visible-private-types[detect use of private types in exported type signatures]' | |
132 | + 'warnings[mass-change the level for lints which produce warnings]' | |
133 | + 'while-true[suggest using `loop { }` instead of `while true { }`]' | |
134 | + 'unknown-crate-type[unknown crate type found in #\[crate_type\] directive]' | |
135 | + 'unknown-features[unknown features found in crate-level #\[feature\] directives]' | |
136 | + 'bad-style[group of non_camel_case_types, non_snake_case, non_uppercase_statics]' | |
137 | + 'unused[group of unused_imports, unused_variable, dead_assignment, dead_code, unused_mut, unreachable_code]' | |
138 | +) | |
139 | + | |
140 | +_rustc_opts_debug=( | |
141 | + 'verbose[in general, enable more debug printouts]' | |
142 | + 'time-passes[measure time of each rustc pass]' | |
143 | + 'count-llvm-insns[count where LLVM instrs originate]' | |
144 | + 'time-llvm-passes[measure time of each LLVM pass]' | |
145 | + 'trans-stats[gather trans statistics]' | |
146 | + 'asm-comments[generate comments into the assembly (may change behavior)]' | |
147 | + 'no-verify[skip LLVM verification]' | |
148 | + 'borrowck-stats[gather borrowck statistics]' | |
149 | + 'no-landing-pads[omit landing pads for unwinding]' | |
150 | + 'debug-llvm[enable debug output from LLVM]' | |
151 | + 'show-span[show spans for compiler debugging]' | |
152 | + 'count-type-sizes[count the sizes of aggregate types]' | |
153 | + 'meta-stats[gather metadata statistics]' | |
154 | + 'no-opt[do not optimize, even if -O is passed]' | |
155 | + 'print-link-args[Print the arguments passed to the linker]' | |
156 | + 'gc[Garbage collect shared data (experimental)]' | |
157 | + 'print-llvm-passes[Prints the llvm optimization passes being run]' | |
158 | + 'lto[Perform LLVM link-time optimizations]' | |
159 | + 'ast-json[Print the AST as JSON and halt]' | |
160 | + 'ast-json-noexpand[Print the pre-expansion AST as JSON and halt]' | |
161 | + 'ls[List the symbols defined by a library crate]' | |
162 | + 'save-analysis[Write syntax and type analysis information in addition to normal output]' | |
163 | + 'flowgraph-print-loans[Include loan analysis data in --pretty flowgraph output]' | |
164 | + 'flowgraph-print-moves[Include move analysis data in --pretty flowgraph output]' | |
165 | + 'flowgraph-print-assigns[Include assignment analysis data in --pretty flowgraph output]' | |
166 | + 'flowgraph-print-all[Include all dataflow analysis data in --pretty flowgraph output]' | |
167 | +) | |
168 | + | |
169 | +_rustc_opts_fun_lint(){ | |
170 | + _values -s , 'options' \ | |
171 | + "$_rustc_opts_lint[@]" | |
172 | +} | |
173 | + | |
174 | +_rustc_opts_fun_debug(){ | |
175 | + _values 'options' "$_rustc_opts_debug[@]" | |
176 | +} | |
177 | + | |
178 | +_rustc_opts_fun_codegen(){ | |
179 | + _values 'options' "$_rustc_opts_codegen[@]" | |
180 | +} | |
181 | + | |
182 | +_arguments -s : \ | |
183 | + '(-W --warn)'{-W,--warn=}'[Set lint warnings]:lint options:_rustc_opts_fun_lint' \ | |
184 | + '(-A --allow)'{-A,--allow=}'[Set lint allowed]:lint options:_rustc_opts_fun_lint' \ | |
185 | + '(-D --deny)'{-D,--deny=}'[Set lint denied]:lint options:_rustc_opts_fun_lint' \ | |
186 | + '(-F --forbid)'{-F,--forbid=}'[Set lint forbidden]:lint options:_rustc_opts_fun_lint' \ | |
187 | + '*-Z[Set internal debugging options]:debug options:_rustc_opts_fun_debug' \ | |
188 | + '*-C[Set internal Codegen options]:codegen options:_rustc_opts_fun_codegen' \ | |
189 | + "$_rustc_opts_switches[@]" \ | |
190 | + "$_rustc_opts_vals[@]" \ | |
191 | + '::files:_files -g "*.rs"' |
... | ... | @@ -0,0 +1,68 @@ |
1 | +# A plugin to shrink directory paths for brevity and pretty-printing | |
2 | + | |
3 | + | |
4 | +## Examples | |
5 | + | |
6 | +For this directory tree: | |
7 | +``` | |
8 | + /home/ | |
9 | + me/ | |
10 | + foo/ | |
11 | + bar/ | |
12 | + quux/ | |
13 | + biz/ # The prefix b is ambiguous between bar and biz. | |
14 | +``` | |
15 | +here are the results of calling `shrink_path <option> /home/me/foo/bar/quux`: | |
16 | +``` | |
17 | + Option Result | |
18 | + <none> /h/m/f/ba/q | |
19 | + -l|--last /h/m/f/ba/quux | |
20 | + -s|--short /h/m/f/b/q | |
21 | + -t|--tilde ~/f/ba/q | |
22 | + -f|--fish ~/f/b/quux | |
23 | +``` | |
24 | + | |
25 | + | |
26 | +## Usage | |
27 | + | |
28 | +For a fish-style working directory in your command prompt, add the following to | |
29 | +your theme or zshrc: | |
30 | + | |
31 | +``` | |
32 | + setopt prompt_subst | |
33 | + PS1='%n@%m $(shrink_path -f)>' | |
34 | +``` | |
35 | + | |
36 | +The following options are available: | |
37 | + | |
38 | +``` | |
39 | + -f, --fish fish simulation, equivalent to -l -s -t. | |
40 | + -l, --last Print the last directory's full name. | |
41 | + -s, --short Truncate directory names to the first character. Without | |
42 | + -s, names are truncated without making them ambiguous. | |
43 | + -t, --tilde Substitute ~ for the home directory. | |
44 | + -T, --nameddirs Substitute named directories as well. | |
45 | +``` | |
46 | + | |
47 | +The long options can also be set via zstyle, like | |
48 | +``` | |
49 | + zstyle :prompt:shrink_path fish yes | |
50 | +``` | |
51 | + | |
52 | +Note: Directory names containing two or more consecutive spaces are not yet | |
53 | +supported. | |
54 | + | |
55 | + | |
56 | +## License | |
57 | + | |
58 | +Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx> | |
59 | + | |
60 | +License: WTFPL <http://sam.zoy.org/wtfpl> | |
61 | + | |
62 | +Ref: http://www.zsh.org/mla/workers/2009/msg00415.html | |
63 | + http://www.zsh.org/mla/workers/2009/msg00419.html | |
64 | + | |
65 | + | |
66 | +## Misc | |
67 | + | |
68 | +Keywords: prompt directory truncate shrink collapse fish |
... | ... | @@ -0,0 +1,127 @@ |
1 | +# Shrink directory paths, e.g. /home/me/foo/bar/quux -> ~/f/b/quux. | |
2 | +# | |
3 | +# For a fish-style working directory in your command prompt, add the following | |
4 | +# to your theme or zshrc: | |
5 | +# | |
6 | +# setopt prompt_subst | |
7 | +# PS1='%n@%m $(shrink_path -f)>' | |
8 | +# | |
9 | +# The following options are available: | |
10 | +# | |
11 | +# -f, --fish fish simulation, equivalent to -l -s -t. | |
12 | +# -l, --last Print the last directory's full name. | |
13 | +# -s, --short Truncate directory names to the first character. Without | |
14 | +# -s, names are truncated without making them ambiguous. | |
15 | +# -t, --tilde Substitute ~ for the home directory. | |
16 | +# -T, --nameddirs Substitute named directories as well. | |
17 | +# | |
18 | +# The long options can also be set via zstyle, like | |
19 | +# zstyle :prompt:shrink_path fish yes | |
20 | +# | |
21 | +# Note: Directory names containing two or more consecutive spaces are not yet | |
22 | +# supported. | |
23 | +# | |
24 | +# Keywords: prompt directory truncate shrink collapse fish | |
25 | +# | |
26 | +# Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx> | |
27 | +# License: WTFPL <http://sam.zoy.org/wtfpl> | |
28 | +# | |
29 | +# Ref: http://www.zsh.org/mla/workers/2009/msg00415.html | |
30 | +# http://www.zsh.org/mla/workers/2009/msg00419.html | |
31 | + | |
32 | +shrink_path () { | |
33 | + setopt localoptions | |
34 | + setopt rc_quotes null_glob | |
35 | + | |
36 | + typeset -i lastfull=0 | |
37 | + typeset -i short=0 | |
38 | + typeset -i tilde=0 | |
39 | + typeset -i named=0 | |
40 | + | |
41 | + if zstyle -t ':prompt:shrink_path' fish; then | |
42 | + lastfull=1 | |
43 | + short=1 | |
44 | + tilde=1 | |
45 | + fi | |
46 | + if zstyle -t ':prompt:shrink_path' nameddirs; then | |
47 | + tilde=1 | |
48 | + named=1 | |
49 | + fi | |
50 | + zstyle -t ':prompt:shrink_path' last && lastfull=1 | |
51 | + zstyle -t ':prompt:shrink_path' short && short=1 | |
52 | + zstyle -t ':prompt:shrink_path' tilde && tilde=1 | |
53 | + | |
54 | + while [[ $1 == -* ]]; do | |
55 | + case $1 in | |
56 | + -f|--fish) | |
57 | + lastfull=1 | |
58 | + short=1 | |
59 | + tilde=1 | |
60 | + ;; | |
61 | + -h|--help) | |
62 | + print 'Usage: shrink_path [-f -l -s -t] [directory]' | |
63 | + print ' -f, --fish fish-simulation, like -l -s -t' | |
64 | + print ' -l, --last Print the last directory''s full name' | |
65 | + print ' -s, --short Truncate directory names to the first character' | |
66 | + print ' -t, --tilde Substitute ~ for the home directory' | |
67 | + print ' -T, --nameddirs Substitute named directories as well' | |
68 | + print 'The long options can also be set via zstyle, like' | |
69 | + print ' zstyle :prompt:shrink_path fish yes' | |
70 | + return 0 | |
71 | + ;; | |
72 | + -l|--last) lastfull=1 ;; | |
73 | + -s|--short) short=1 ;; | |
74 | + -t|--tilde) tilde=1 ;; | |
75 | + -T|--nameddirs) | |
76 | + tilde=1 | |
77 | + named=1 | |
78 | + ;; | |
79 | + esac | |
80 | + shift | |
81 | + done | |
82 | + | |
83 | + typeset -a tree expn | |
84 | + typeset result part dir=${1-$PWD} | |
85 | + typeset -i i | |
86 | + | |
87 | + [[ -d $dir ]] || return 0 | |
88 | + | |
89 | + if (( named )) { | |
90 | + for part in ${(k)nameddirs}; { | |
91 | + [[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/${nameddirs[$part]}/\~$part} | |
92 | + } | |
93 | + } | |
94 | + (( tilde )) && dir=${dir/$HOME/\~} | |
95 | + tree=(${(s:/:)dir}) | |
96 | + ( | |
97 | + unfunction chpwd 2> /dev/null | |
98 | + if [[ $tree[1] == \~* ]] { | |
99 | + cd ${~tree[1]} | |
100 | + result=$tree[1] | |
101 | + shift tree | |
102 | + } else { | |
103 | + cd / | |
104 | + } | |
105 | + for dir in $tree; { | |
106 | + if (( lastfull && $#tree == 1 )) { | |
107 | + result+="/$tree" | |
108 | + break | |
109 | + } | |
110 | + expn=(a b) | |
111 | + part='' | |
112 | + i=0 | |
113 | + until [[ (( ${#expn} == 1 )) || $dir = $expn || $i -gt 99 ]] do | |
114 | + (( i++ )) | |
115 | + part+=$dir[$i] | |
116 | + expn=($(echo ${part}*(-/))) | |
117 | + (( short )) && break | |
118 | + done | |
119 | + result+="/$part" | |
120 | + cd $dir | |
121 | + shift tree | |
122 | + } | |
123 | + echo ${result:-/} | |
124 | + ) | |
125 | +} | |
126 | + | |
127 | +## vim:ft=zsh |
... | ... | @@ -37,7 +37,7 @@ function _plugin__start_agent() |
37 | 37 | zstyle -s :omz:plugins:ssh-agent lifetime lifetime |
38 | 38 | |
39 | 39 | # start ssh-agent and setup environment |
40 | - /usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' > ${_plugin__ssh_env} | |
40 | + /usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! ${_plugin__ssh_env} | |
41 | 41 | chmod 600 ${_plugin__ssh_env} |
42 | 42 | . ${_plugin__ssh_env} > /dev/null |
43 | 43 |
... | ... | @@ -15,5 +15,7 @@ Plugin for Sublime Text, a cross platform text and code editor, available for Li |
15 | 15 | * If `st` is passed a file, open it in Sublime Text |
16 | 16 | |
17 | 17 | * If `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text |
18 | - | |
19 | - * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files. | |
20 | 18 | \ No newline at end of file |
19 | + | |
20 | + * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files. | |
21 | + | |
22 | + * If `stp` command is called, it find a `.sublime-project` file by traversing up the directory structure. If there is no `.sublime-project` file, but if the current folder is a Git repo, opens up the root directory of the repo. If the current folder is not a Git repo, then opens up the current directory. |
... | ... | @@ -56,3 +56,32 @@ elif [[ "$OSTYPE" = 'cygwin' ]]; then |
56 | 56 | fi |
57 | 57 | |
58 | 58 | alias stt='st .' |
59 | + | |
60 | +find_project() | |
61 | +{ | |
62 | + local PROJECT_ROOT="${PWD}" | |
63 | + local FINAL_DEST="." | |
64 | + | |
65 | + while [[ $PROJECT_ROOT != "/" && ! -d "$PROJECT_ROOT/.git" ]]; do | |
66 | + PROJECT_ROOT=$(dirname $PROJECT_ROOT) | |
67 | + done | |
68 | + | |
69 | + if [[ $PROJECT_ROOT != "/" ]]; then | |
70 | + local PROJECT_NAME="${PROJECT_ROOT##*/}" | |
71 | + | |
72 | + local SUBL_DIR=$PROJECT_ROOT | |
73 | + while [[ $SUBL_DIR != "/" && ! -f "$SUBL_DIR/$PROJECT_NAME.sublime-project" ]]; do | |
74 | + SUBL_DIR=$(dirname $SUBL_DIR) | |
75 | + done | |
76 | + | |
77 | + if [[ $SUBL_DIR != "/" ]]; then | |
78 | + FINAL_DEST="$SUBL_DIR/$PROJECT_NAME.sublime-project" | |
79 | + else | |
80 | + FINAL_DEST=$PROJECT_ROOT | |
81 | + fi | |
82 | + fi | |
83 | + | |
84 | + st $FINAL_DEST | |
85 | +} | |
86 | + | |
87 | +alias stp=find_project |
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | # Description |
3 | 3 | # ----------- |
4 | 4 | # |
5 | -# sudo will be inserted before the command | |
5 | +# sudo or sudoedit will be inserted before the command | |
6 | 6 | # |
7 | 7 | # ------------------------------------------------------------------------------ |
8 | 8 | # Authors |
... | ... | @@ -16,6 +16,12 @@ sudo-command-line() { |
16 | 16 | [[ -z $BUFFER ]] && zle up-history |
17 | 17 | if [[ $BUFFER == sudo\ * ]]; then |
18 | 18 | LBUFFER="${LBUFFER#sudo }" |
19 | + elif [[ $BUFFER == $EDITOR\ * ]]; then | |
20 | + LBUFFER="${LBUFFER#$EDITOR }" | |
21 | + LBUFFER="sudoedit $LBUFFER" | |
22 | + elif [[ $BUFFER == sudoedit\ * ]]; then | |
23 | + LBUFFER="${LBUFFER#sudoedit }" | |
24 | + LBUFFER="$EDITOR $LBUFFER" | |
19 | 25 | else |
20 | 26 | LBUFFER="sudo $LBUFFER" |
21 | 27 | fi |
... | ... | @@ -22,8 +22,8 @@ alias sf='`_symfony_console`' |
22 | 22 | alias sfcl='sf cache:clear' |
23 | 23 | alias sfsr='sf server:run -vvv' |
24 | 24 | alias sfcw='sf cache:warmup' |
25 | -alias sfroute='sf router:debug' | |
26 | -alias sfcontainer='sf container:debug' | |
25 | +alias sfroute='sf debug:router' | |
26 | +alias sfcontainer='sf debug:container' | |
27 | 27 | alias sfgb='sf generate:bundle' |
28 | 28 | alias sfdev='sf --env=dev' |
29 | 29 | alias sfprod='sf --env=prod' |
1 | 1 | #compdef task |
2 | 2 | # |
3 | -# Copyright 2010 - 2015 Johannes Schlatow | |
3 | +# Copyright 2010 - 2016 Johannes Schlatow | |
4 | 4 | # Copyright 2009 P.C. Shyamshankar |
5 | 5 | # |
6 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
... | ... | @@ -26,7 +26,6 @@ |
26 | 26 | typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers |
27 | 27 | _task_projects=($(task _projects)) |
28 | 28 | _task_tags=($(task _tags)) |
29 | -_task_ids=($(task _ids)) | |
30 | 29 | _task_zshids=( ${(f)"$(task _zshids)"} ) |
31 | 30 | _task_config=($(task _config)) |
32 | 31 | _task_columns=($(task _columns)) |
... | ... | @@ -139,8 +138,10 @@ task_dates=( |
139 | 138 | ) |
140 | 139 | |
141 | 140 | local -a task_zshids |
142 | -_regex_words values 'task IDs' $_task_zshids | |
143 | -task_zshids=("$reply[@]") | |
141 | +if (( $#_task_zshids )); then | |
142 | + _regex_words values 'task IDs' $_task_zshids | |
143 | + task_zshids=("$reply[@]") | |
144 | +fi | |
144 | 145 | |
145 | 146 | _regex_words values 'task frequencies' \ |
146 | 147 | 'daily:Every day' \ |
... | ... | @@ -0,0 +1,16 @@ |
1 | +# `tig` plugin | |
2 | + | |
3 | +This plugin adds some aliases for people who work with `tig` in | |
4 | +a regular basis. To use it, add `tig` to your plugins array: | |
5 | + | |
6 | +```zsh | |
7 | +plugins=(... tig) | |
8 | +``` | |
9 | + | |
10 | +## Features | |
11 | + | |
12 | +| Alias | Command | Description | | |
13 | +|-------|----------------|-------------------------------------------------| | |
14 | +| `tis` | `tig status` | Show git status | | |
15 | +| `til` | `tig log` | Show git log | | |
16 | +| `tib` | `tig blame -C` | `git-blame` a file detecting copies and renames | |
... | ... | @@ -63,7 +63,7 @@ alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ |
63 | 63 | |
64 | 64 | # Misc. ##################################################################### |
65 | 65 | # print all installed packages |
66 | -alias allpkgs='aptitude search -F "%p" --disable-columns ~i' | |
66 | +alias allpkgs='dpkg --get-selections | grep -v deinstall' | |
67 | 67 | |
68 | 68 | # Create a basic .deb package |
69 | 69 | alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' |
... | ... | @@ -11,9 +11,12 @@ fi |
11 | 11 | if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xnode" ) ]]; then |
12 | 12 | alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"' |
13 | 13 | alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"' |
14 | -elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then | |
15 | - alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' | |
16 | - alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' | |
14 | +elif [[ $(whence python3) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then | |
15 | + alias urlencode='python3 -c "import sys, urllib.parse as up; print(up.quote_plus(sys.argv[1]))"' | |
16 | + alias urldecode='python3 -c "import sys, urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"' | |
17 | +elif [[ $(whence python2) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then | |
18 | + alias urlencode='python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' | |
19 | + alias urldecode='python2 -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' | |
17 | 20 | elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then |
18 | 21 | function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"} |
19 | 22 | function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"} |
... | ... | @@ -26,10 +26,12 @@ _1st_arguments=( |
26 | 26 | 'rsync:Syncs rsync synced folders to remote machine' |
27 | 27 | 'rsync-auto:Syncs rsync synced folders automatically when files change' |
28 | 28 | 'share:Shares your Vagrant environment with anyone in the world' |
29 | + 'snapshot:Manage snapshots with the guest machine' | |
29 | 30 | 'ssh:SSH into the currently running environment' |
30 | 31 | 'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh' |
31 | 32 | 'status:Shows the status of the current Vagrant environment' |
32 | 33 | 'suspend:Suspends the currently running vagrant environment' |
34 | + 'snapshot:Used to manage snapshots with the guest machine' | |
33 | 35 | 'up:Creates the vagrant environment' |
34 | 36 | 'version:Prints current and latest Vagrant version' |
35 | 37 | '--help:[TASK] Describe available tasks or one specific task' |
... | ... | @@ -10,6 +10,7 @@ function web_search() { |
10 | 10 | bing "https://www.bing.com/search?q=" |
11 | 11 | yahoo "https://search.yahoo.com/search?p=" |
12 | 12 | duckduckgo "https://www.duckduckgo.com/?q=" |
13 | + startpage "https://www.startpage.com/do/search?q=" | |
13 | 14 | yandex "https://yandex.ru/yandsearch?text=" |
14 | 15 | github "https://github.com/search?q=" |
15 | 16 | baidu "https://www.baidu.com/s?wd=" |
... | ... | @@ -41,6 +42,7 @@ alias bing='web_search bing' |
41 | 42 | alias google='web_search google' |
42 | 43 | alias yahoo='web_search yahoo' |
43 | 44 | alias ddg='web_search duckduckgo' |
45 | +alias sp='web_search startpage' | |
44 | 46 | alias yandex='web_search yandex' |
45 | 47 | alias github='web_search github' |
46 | 48 | alias baidu='web_search baidu' |
... | ... | @@ -4,7 +4,9 @@ |
4 | 4 | |
5 | 5 | WordPress Command Line Interface (http://wp-cli.org/) |
6 | 6 | |
7 | -WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. | |
7 | +WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. | |
8 | + | |
9 | +This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as well as several aliases. | |
8 | 10 | |
9 | 11 | ## List of Aliases |
10 | 12 |
1 | 1 | # How should be current element of the list drawn. Possible values: reverse, |
2 | -# underline. Default (without option set) is reverse | |
2 | +# underline. | |
3 | 3 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
4 | -# underline support on that terminal) | |
5 | -# local active_text=underline | |
4 | +# underline support on that terminal). The same for screen/tmux. | |
5 | +local active_text=reverse | |
6 | + | |
7 | + | |
8 | + | |
9 | + | |
10 | + | |
11 | + | |
12 | +# | |
13 | +# Zshrc integration. All below variables can | |
14 | +# be set in zshrc and will have precedence | |
15 | +# over config files | |
16 | +# | |
17 | + | |
18 | +# 1. znt_aliases_active_text | |
19 | +active_text=${znt_aliases_active_text:-$active_text} | |
20 | + | |
21 | +# 2. znt_aliases_nlist_coloring_pattern | |
22 | +NLIST_COLORING_PATTERN=${znt_aliases_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
23 | + | |
24 | +# 3. znt_aliases_nlist_coloring_color | |
25 | +NLIST_COLORING_COLOR=${znt_aliases_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
26 | + | |
27 | +# 4. znt_aliases_nlist_coloring_match_multiple | |
28 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_aliases_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
29 | + | |
30 | +# 5. znt_aliases_keywords (array) | |
31 | +if (( ${+znt_aliases_keywords} )); then | |
32 | + keywords=( "${znt_aliases_keywords[@]}" ) | |
33 | +fi |
1 | 1 | # Hotlist |
2 | -# Try to use $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions | |
3 | -local hotlist | |
2 | +# Can use e.g. $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions | |
3 | +local -a hotlist | |
4 | 4 | hotlist=( |
5 | 5 | ~/.config/znt |
6 | 6 | /usr/share/zsh/site-functions |
... | ... | @@ -8,6 +8,7 @@ hotlist=( |
8 | 8 | /usr/local/share/zsh/site-functions |
9 | 9 | /usr/local/share/zsh |
10 | 10 | /usr/local/bin |
11 | + /usr/lib | |
11 | 12 | ) |
12 | 13 | |
13 | 14 | # Suppress adding (to directory stack) directories visited by n-cd |
... | ... | @@ -15,12 +16,53 @@ hotlist=( |
15 | 16 | local NCD_DONT_PUSHD=0 |
16 | 17 | |
17 | 18 | # How should be current element of the list drawn. Possible values: reverse, |
18 | -# underline. Default (without option set) is reverse | |
19 | +# underline. | |
19 | 20 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
20 | -# underline support on that terminal) | |
21 | -# local active_text=underline | |
21 | +# underline support on that terminal). The same for screen/tmux. | |
22 | +local active_text=reverse | |
22 | 23 | |
23 | 24 | # Colorize last segments of the paths |
24 | 25 | # (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex) |
25 | 26 | local NLIST_COLORING_PATTERN="[a-zA-Z0-9 ._-]##/#(#e)" |
26 | 27 | local NLIST_COLORING_COLOR=$'\x1b[00;33m' |
28 | + | |
29 | +# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/ | |
30 | +local -a keywords | |
31 | +keywords=( "zsh" "local" "git" ) | |
32 | + | |
33 | + | |
34 | + | |
35 | + | |
36 | + | |
37 | + | |
38 | + | |
39 | +# | |
40 | +# Zshrc integration. All below variables can | |
41 | +# be set in zshrc and will have precedence | |
42 | +# over config files | |
43 | +# | |
44 | + | |
45 | +# 1. znt_cd_hotlist (array) | |
46 | +if (( ${+znt_cd_hotlist} )); then | |
47 | + hotlist=( "${znt_cd_hotlist[@]}" ) | |
48 | +fi | |
49 | + | |
50 | +# 2. znt_cd_dont_pushd | |
51 | +NCD_DONT_PUSHD=${znt_cd_dont_pushd:-$NCD_DONT_PUSHD} | |
52 | + | |
53 | +# 3. znt_cd_active_text | |
54 | +active_text=${znt_cd_active_text:-$active_text} | |
55 | + | |
56 | +# 4. znt_cd_nlist_coloring_pattern | |
57 | +NLIST_COLORING_PATTERN=${znt_cd_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
58 | + | |
59 | +# 5. znt_cd_nlist_coloring_color | |
60 | +NLIST_COLORING_COLOR=${znt_cd_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
61 | + | |
62 | +# 6. znt_cd_nlist_coloring_match_multiple | |
63 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_cd_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
64 | + | |
65 | +# 7. znt_cd_keywords (array) | |
66 | +if (( ${+znt_cd_keywords} )); then | |
67 | + keywords=( "${znt_cd_keywords[@]}" ) | |
68 | +fi |
1 | 1 | # How should be current element of the list drawn. Possible values: reverse, |
2 | -# underline. Default (without option set) is reverse | |
2 | +# underline. | |
3 | 3 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
4 | -# underline support on that terminal) | |
5 | -# local active_text=underline | |
4 | +# underline support on that terminal). The same for screen/tmux. | |
5 | +local active_text=reverse | |
6 | 6 | |
7 | 7 | # (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex) |
8 | 8 | local NLIST_COLORING_PATTERN="[a-zA-Z0-9_]##" |
9 | 9 | local NLIST_COLORING_MATCH_MULTIPLE=0 |
10 | + | |
11 | + | |
12 | + | |
13 | + | |
14 | + | |
15 | + | |
16 | + | |
17 | +# | |
18 | +# Zshrc integration. All below variables can | |
19 | +# be set in zshrc and will have precedence | |
20 | +# over config files | |
21 | +# | |
22 | + | |
23 | +# 1. znt_env_active_text | |
24 | +active_text=${znt_env_active_text:-$active_text} | |
25 | + | |
26 | +# 2. znt_env_nlist_coloring_pattern | |
27 | +NLIST_COLORING_PATTERN=${znt_env_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
28 | + | |
29 | +# 3. znt_env_nlist_coloring_color | |
30 | +NLIST_COLORING_COLOR=${znt_env_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
31 | + | |
32 | +# 4. znt_env_nlist_coloring_match_multiple | |
33 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_env_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
34 | + | |
35 | +# 5. znt_env_keywords (array) | |
36 | +if (( ${+znt_env_keywords} )); then | |
37 | + keywords=( "${znt_env_keywords[@]}" ) | |
38 | +fi |
... | ... | @@ -4,7 +4,38 @@ local feditor="zed" |
4 | 4 | # local feditor="vared" |
5 | 5 | |
6 | 6 | # How should be current element of the list drawn. Possible values: reverse, |
7 | -# underline. Default (without option set) is reverse | |
7 | +# underline. | |
8 | 8 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
9 | -# underline support on that terminal) | |
10 | -# local active_text=underline | |
9 | +# underline support on that terminal). The same for screen/tmux. | |
10 | +local active_text=reverse | |
11 | + | |
12 | + | |
13 | + | |
14 | + | |
15 | + | |
16 | + | |
17 | +# | |
18 | +# Zshrc integration. All below variables can | |
19 | +# be set in zshrc and will have precedence | |
20 | +# over config files | |
21 | +# | |
22 | + | |
23 | +# 1. znt_functions_feditor | |
24 | +feditor=${znt_functions_feditor:-$feditor} | |
25 | + | |
26 | +# 2. znt_functions_active_text | |
27 | +active_text=${znt_functions_active_text:-$active_text} | |
28 | + | |
29 | +# 3. znt_functions_nlist_coloring_pattern | |
30 | +NLIST_COLORING_PATTERN=${znt_functions_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
31 | + | |
32 | +# 4. znt_functions_nlist_coloring_color | |
33 | +NLIST_COLORING_COLOR=${znt_functions_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
34 | + | |
35 | +# 5. znt_functions_nlist_coloring_match_multiple | |
36 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_functions_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
37 | + | |
38 | +# 6. znt_functions_keywords (array) | |
39 | +if (( ${+znt_functions_keywords} )); then | |
40 | + keywords=( "${znt_functions_keywords[@]}" ) | |
41 | +fi |
1 | 1 | # How should be current element of the list drawn. Possible values: reverse, |
2 | -# underline. Default (without option set) is reverse | |
2 | +# underline. | |
3 | 3 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
4 | -# underline support on that terminal) | |
4 | +# underline support on that terminal). The same for screen/tmux. | |
5 | 5 | local active_text=underline |
6 | 6 | |
7 | 7 | # Highlight a few keywords |
8 | 8 | local NLIST_COLORING_PATTERN="(while|for |sudo|make|(#s)git|vim(#e)|vim |emacs(#e)|emacs )" |
9 | 9 | local NLIST_COLORING_COLOR=$'\x1b[00;33m' |
10 | 10 | local NLIST_COLORING_MATCH_MULTIPLE=1 |
11 | + | |
12 | +# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/ | |
13 | +local -a keywords | |
14 | +keywords=( "git" "vim" "mplayer" ) | |
15 | + | |
16 | + | |
17 | + | |
18 | + | |
19 | + | |
20 | + | |
21 | + | |
22 | +# | |
23 | +# Zshrc integration. All below variables can | |
24 | +# be set in zshrc and will have precedence | |
25 | +# over config files | |
26 | +# | |
27 | + | |
28 | +# 1. znt_history_active_text | |
29 | +active_text=${znt_history_active_text:-$active_text} | |
30 | + | |
31 | +# 2. znt_history_nlist_coloring_pattern | |
32 | +NLIST_COLORING_PATTERN=${znt_history_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
33 | + | |
34 | +# 3. znt_history_nlist_coloring_color | |
35 | +NLIST_COLORING_COLOR=${znt_history_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
36 | + | |
37 | +# 4. znt_history_nlist_coloring_match_multiple | |
38 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_history_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
39 | + | |
40 | +# 5. znt_history_keywords (array) | |
41 | +if (( ${+znt_history_keywords} )); then | |
42 | + keywords=( "${znt_history_keywords[@]}" ) | |
43 | +fi |
1 | 1 | # How should be current element of the list drawn. Possible values: reverse, |
2 | -# underline. Default (without option set) is reverse | |
2 | +# underline. | |
3 | 3 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
4 | -# underline support on that terminal) | |
5 | -# local active_text=underline | |
4 | +# underline support on that terminal). The same for screen/tmux. | |
5 | +local active_text=reverse | |
6 | 6 | |
7 | 7 | # Colorize first number column and last path segment |
8 | 8 | # This doesn't cover scripts named "[0-9]## *", which should be very rare |
9 | 9 | # (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex) |
10 | 10 | # | is alternative, but only in () |
11 | -local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e)|[^ /\\\\]##[^0-9/\\\\ ]##[^/\\\\]#(#e))" | |
11 | +local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e))" | |
12 | 12 | local NLIST_COLORING_COLOR=$'\x1b[00;33m' |
13 | 13 | local NLIST_COLORING_MATCH_MULTIPLE=1 |
14 | + | |
15 | +# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/ | |
16 | +local -a keywords | |
17 | +keywords=( "vim" "git" "git commit" "firefox" "mplayer" ) | |
18 | + | |
19 | + | |
20 | + | |
21 | + | |
22 | + | |
23 | + | |
24 | + | |
25 | +# | |
26 | +# Zshrc integration. All below variables can | |
27 | +# be set in zshrc and will have precedence | |
28 | +# over config files | |
29 | +# | |
30 | + | |
31 | +# 1. znt_kill_active_text | |
32 | +active_text=${znt_kill_active_text:-$active_text} | |
33 | + | |
34 | +# 2. znt_kill_nlist_coloring_pattern | |
35 | +NLIST_COLORING_PATTERN=${znt_kill_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
36 | + | |
37 | +# 3. znt_kill_nlist_coloring_color | |
38 | +NLIST_COLORING_COLOR=${znt_kill_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
39 | + | |
40 | +# 4. znt_kill_nlist_coloring_match_multiple | |
41 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_kill_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
42 | + | |
43 | +# 5. znt_kill_keywords (array) | |
44 | +if (( ${+znt_kill_keywords} )); then | |
45 | + keywords=( "${znt_kill_keywords[@]}" ) | |
46 | +fi |
1 | 1 | # Should the list (text, borders) be drawn in bold |
2 | 2 | # Value 1 is the default |
3 | -local bold=1 | |
3 | +local bold=0 | |
4 | + | |
5 | +# Main color pair (foreground/background) | |
6 | +local colorpair="white/black" | |
7 | + | |
8 | +# Should draw the border? | |
9 | +local border=0 | |
10 | + | |
11 | +# Combinations of colors to try out with Ctrl-T and Ctrl-G | |
12 | +# The last number is the bold option, 0 or 1 | |
13 | +local -a themes | |
14 | +themes=( "white/black/1" "green/black/0" "green/black/1" "white/blue/0" "white/blue/1" | |
15 | + "magenta/black/0" "magenta/black/1" ) | |
16 | + | |
17 | +# Uncomment when using new (>5.2) Zsh version that supports 256 colors in zcurses | |
18 | +#themes=( "white/17/0" "10/17/1" "white/24/1" "white/22/0" "white/22/1" "white/25/0" "white/25/1" | |
19 | +# "white/59/0" "white/59/1" "white/60/0" "white/60/1" "white/61/0" "white/61/1" "black/65/0" | |
20 | +# "black/244/0" ) | |
21 | + | |
22 | +# When 1, pressing enter when in search mode will not | |
23 | +# only leave the mode, but also do selection and leave | |
24 | +# n-history | |
25 | +local NLIST_INSTANT_SELECT=0 | |
26 | + | |
27 | + | |
28 | + | |
29 | + | |
30 | + | |
31 | + | |
32 | + | |
33 | +# | |
34 | +# Zshrc integration. All below variables can | |
35 | +# be set in zshrc and will have precedence | |
36 | +# over config files | |
37 | +# | |
38 | + | |
39 | +# 1. znt_list_bold | |
40 | +bold=${znt_list_bold:-$bold} | |
41 | + | |
42 | +# 2. znt_list_colorpair | |
43 | +colorpair=${znt_list_colorpair:-$colorpair} | |
44 | + | |
45 | +# 3. znt_list_border | |
46 | +border=${znt_list_border:-$border} | |
47 | + | |
48 | +# 4. znt_list_themes (array) | |
49 | +if (( ${+znt_list_themes} )); then | |
50 | + themes=( "${znt_list_themes[@]}" ) | |
51 | +fi | |
52 | + | |
53 | +# 5. znt_list_instant_select | |
54 | +NLIST_INSTANT_SELECT=${znt_list_instant_select:-$NLIST_INSTANT_SELECT} | |
55 | + |
1 | 1 | # How should be current element of the list drawn. Possible values: reverse, |
2 | -# underline. Default (without option set) is reverse | |
2 | +# underline. | |
3 | 3 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
4 | -# underline support on that terminal) | |
5 | -# local active_text=underline | |
4 | +# underline support on that terminal). The same for screen/tmux. | |
5 | +local active_text=reverse | |
6 | + | |
7 | + | |
8 | + | |
9 | + | |
10 | + | |
11 | + | |
12 | + | |
13 | +# | |
14 | +# Zshrc integration. All below variables can | |
15 | +# be set in zshrc and will have precedence | |
16 | +# over config files | |
17 | +# | |
18 | + | |
19 | +# 1. znt_options_active_text | |
20 | +active_text=${znt_options_active_text:-$active_text} | |
21 | + | |
22 | +# 2. znt_options_nlist_coloring_pattern | |
23 | +NLIST_COLORING_PATTERN=${znt_options_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
24 | + | |
25 | +# 3. znt_options_nlist_coloring_color | |
26 | +NLIST_COLORING_COLOR=${znt_options_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
27 | + | |
28 | +# 4. znt_options_nlist_coloring_match_multiple | |
29 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_options_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
30 | + | |
31 | +# 5. znt_options_keywords (array) | |
32 | +if (( ${+znt_options_keywords} )); then | |
33 | + keywords=( "${znt_options_keywords[@]}" ) | |
34 | +fi |
1 | 1 | # How should be current element of the list drawn. Possible values: reverse, |
2 | -# underline. Default (without option set) is reverse | |
2 | +# underline. | |
3 | 3 | # On Linux virtual terminal this will be enforced to reverse (because of poor |
4 | -# underline support on that terminal) | |
5 | -# local active_text=underline | |
4 | +# underline support on that terminal). The same for screen/tmux. | |
5 | +local active_text=reverse | |
6 | + | |
7 | + | |
8 | + | |
9 | + | |
10 | + | |
11 | + | |
12 | + | |
13 | +# | |
14 | +# Zshrc integration. All below variables can | |
15 | +# be set in zshrc and will have precedence | |
16 | +# over config files | |
17 | +# | |
18 | + | |
19 | +# 1. znt_panelize_active_text | |
20 | +active_text=${znt_panelize_active_text:-$active_text} | |
21 | + | |
22 | +# 2. znt_panelize_nlist_coloring_pattern | |
23 | +NLIST_COLORING_PATTERN=${znt_panelize_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN} | |
24 | + | |
25 | +# 3. znt_panelize_nlist_coloring_color | |
26 | +NLIST_COLORING_COLOR=${znt_panelize_nlist_coloring_color:-$NLIST_COLORING_COLOR} | |
27 | + | |
28 | +# 4. znt_panelize_nlist_coloring_match_multiple | |
29 | +NLIST_COLORING_MATCH_MULTIPLE=${znt_panelize_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE} | |
30 | + | |
31 | +# 5. znt_panelize_keywords (array) | |
32 | +if (( ${+znt_panelize_keywords} )); then | |
33 | + keywords=( "${znt_panelize_keywords[@]}" ) | |
34 | +fi |
1 | 1 | # Zsh Navigation Tools |
2 | 2 | |
3 | -http://imageshack.com/a/img633/7967/ps6rKR.png | |
3 | +https://raw.githubusercontent.com/psprint/zsh-navigation-tools/master/doc/img/n-history2.png | |
4 | 4 | |
5 | 5 | Set of tools like n-history – multi-word history searcher, n-cd – directory |
6 | 6 | bookmark manager, n-kill – htop like kill utility, and more. Based on |
... | ... | @@ -32,6 +32,26 @@ to key combinations (no need for autoload when using Oh My Zsh): |
32 | 32 | Oh My Zsh stores history into ~/.zsh_history. When you switch to OMZ you could |
33 | 33 | want to copy your previous data (from e.g. ~/.zhistory) into the new location. |
34 | 34 | |
35 | +## News | |
36 | + | |
37 | +* 30-04-2016 | |
38 | + - New feature: color themes. Use Ctrl-T and Ctrl-G to browse predefined | |
39 | + themes. They are listed in ~/.config/znt/n-list.conf. Use the file to | |
40 | + permanently set a color scheme. Also, I sent a patch to Zsh developers | |
41 | + and starting from Zsh > 5.2 (not yet released) supported will be 256 colors. | |
42 | + The file ~/.config/znt/n-list.conf already has set of 256-color themes prepared :) | |
43 | + | |
44 | +* 29-04-2016 | |
45 | + - New feature: private history – n-history tracks selected history entries, | |
46 | + exposes them via new view (activated with F1) | |
47 | + | |
48 | +* 28-04-2016 | |
49 | + - New features: | |
50 | + 1. New n-history view (activated with F1): Most Frequent History Words | |
51 | + 2. Predefined search keywords – use F2 to quickly search for chosen | |
52 | + keywords (video: [https://youtu.be/DN9QqssAYB8](https://youtu.be/DN9QqssAYB8)) | |
53 | + 3. Configuration option for doing instant selection in search mode | |
54 | + | |
35 | 55 | ## Introduction |
36 | 56 | |
37 | 57 | The tools are: |
... | ... | @@ -60,6 +80,65 @@ cursors. Other keys are: |
60 | 80 | - Ctrl-w (in incremental search) - delete whole word |
61 | 81 | - Ctrl-k (in incremental search) - delete whole line |
62 | 82 | |
83 | +## Configuration | |
84 | + | |
85 | +`ZNT` has configuration files located in `~/.config/znt`. The files are: | |
86 | + | |
87 | +``` | |
88 | +n-aliases.conf | |
89 | +n-cd.conf | |
90 | +n-env.conf | |
91 | +n-functions.conf | |
92 | +n-history.conf | |
93 | +n-kill.conf | |
94 | +n-list.conf | |
95 | +n-options.conf | |
96 | +n-panelize.conf | |
97 | +``` | |
98 | + | |
99 | +`n-list.conf` contains main configuration variables: | |
100 | + | |
101 | +```zsh | |
102 | +# Should the list (text, borders) be drawn in bold | |
103 | +local bold=0 | |
104 | + | |
105 | +# Main color pair (foreground/background) | |
106 | +local colorpair="white/black" | |
107 | + | |
108 | +# Should draw the border? | |
109 | +local border=1 | |
110 | + | |
111 | +# Combinations of colors to try out with Ctrl-T and Ctrl-G | |
112 | +# The last number is the bold option, 0 or 1 | |
113 | +local -a themes | |
114 | +themes=( "white/black/1" "green/black/0" "green/black/1" "white/blue/0" "white/blue/1" | |
115 | + "magenta/black/0" "magenta/black/1" ) | |
116 | +``` | |
117 | + | |
118 | +Read remaining configuration files to see what's in them. Nevertheless, configuration | |
119 | +can be also set from `zshrc`. There are `5` standard `zshrc` configuration variables: | |
120 | + | |
121 | +``` | |
122 | +znt_history_active_text - underline or reverse - how should be active element highlighted | |
123 | +znt_history_nlist_coloring_pattern - pattern that can be used to colorize elements | |
124 | +znt_history_nlist_coloring_color - color with which to colorize | |
125 | +znt_history_nlist_coloring_match_multiple - should multiple matches be colorized (0 or 1) | |
126 | +znt_history_keywords (array) - search keywords activated with `Ctrl-X` | |
127 | +``` | |
128 | + | |
129 | +Above variables will work for `n-history` tool. For other tools, change `_history_` to | |
130 | +e.g. `_cd_`, for the `n-cd` tool. The same works for all `8` tools. | |
131 | + | |
132 | +Common configuration of the tools uses variables with `_list_` in them: | |
133 | + | |
134 | +``` | |
135 | +znt_list_bold - should draw text in bold (0 or 1) | |
136 | +znt_list_colorpair - main pair of colors to be used, e.g "green/black" | |
137 | +znt_list_border - should draw borders around windows (0 or 1) | |
138 | +znt_list_themes (array) - list of themes to try out with Ctrl-T, e.g. ( "white/black/1" "green/black/0" ) | |
139 | +znt_list_instant_select - should pressing enter in search mode leave tool (0 or 1) | |
140 | +``` | |
141 | + | |
63 | 142 | ## Programming |
64 | 143 | |
65 | 144 | The function n-list is used as follows: |
... | ... | @@ -0,0 +1,41 @@ |
1 | +#compdef n-kill | |
2 | + | |
3 | +local context ret=1 | |
4 | + | |
5 | +typeset -a list linewords | |
6 | +typeset -aU words wordbits | |
7 | +local line word | |
8 | +integer cygwin=0 | |
9 | + | |
10 | +local IFS=" | |
11 | +" | |
12 | + | |
13 | +case "$(uname)" in | |
14 | + CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;; | |
15 | + *) list=( `command ps -o pid,uid,command -A` ) ;; | |
16 | +esac | |
17 | + | |
18 | +shift list | |
19 | + | |
20 | +IFS=" " | |
21 | +for line in "${list[@]}"; do | |
22 | + linewords=( $=line ) | |
23 | + if [ "$cygwin" = "1" ]; then | |
24 | + linewords=( "${(@)linewords[8,-1]}" ) | |
25 | + else | |
26 | + linewords=( "${(@)linewords[3,-1]}" ) | |
27 | + fi | |
28 | + for word in "${linewords[@]}"; do | |
29 | + if [ "$cygwin" = "1" ]; then | |
30 | + wordbits=( "${(@s:\:)word}" ) | |
31 | + else | |
32 | + wordbits=( "${(@s:/:)word}" ) | |
33 | + fi | |
34 | + words+=( "${wordbits[@]}" ) | |
35 | + done | |
36 | +done | |
37 | + | |
38 | +_wanted bits expl "Processes' name bits" \ | |
39 | + compadd "$@" -a - words && ret=0 | |
40 | + | |
41 | +return "$ret" |
... | ... | @@ -16,8 +16,8 @@ local IFS=" |
16 | 16 | |
17 | 17 | unset NLIST_COLORING_PATTERN |
18 | 18 | |
19 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
20 | -[ -f ~/.config/znt/n-aliases.conf ] && . ~/.config/znt/n-aliases.conf | |
19 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
20 | +[ -f ~/.config/znt/n-aliases.conf ] && builtin source ~/.config/znt/n-aliases.conf | |
21 | 21 | |
22 | 22 | local list |
23 | 23 | local selected |
... | ... | @@ -16,8 +16,8 @@ local IFS=" |
16 | 16 | # Unset before configuration is read |
17 | 17 | unset NLIST_COLORING_PATTERN |
18 | 18 | |
19 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
20 | -[ -f ~/.config/znt/n-cd.conf ] && . ~/.config/znt/n-cd.conf | |
19 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
20 | +[ -f ~/.config/znt/n-cd.conf ] && builtin source ~/.config/znt/n-cd.conf | |
21 | 21 | |
22 | 22 | local list |
23 | 23 | local selected |
... | ... | @@ -53,13 +53,16 @@ if [ "$REPLY" -gt 0 ]; then |
53 | 53 | |
54 | 54 | (( NCD_DONT_PUSHD )) && setopt NO_AUTO_PUSHD |
55 | 55 | cd "$selected" |
56 | + local code=$? | |
56 | 57 | (( NCD_DONT_PUSHD )) && setopt AUTO_PUSHD |
57 | 58 | |
58 | - # ZLE? | |
59 | - if [ "${(t)CURSOR}" = "integer-local-special" ]; then | |
60 | - zle -M "You have selected $selected" | |
61 | - else | |
62 | - echo "You have selected $selected" | |
59 | + if [ "$code" -eq "0" ]; then | |
60 | + # ZLE? | |
61 | + if [ "${(t)CURSOR}" = "integer-local-special" ]; then | |
62 | + zle -M "You have selected $selected" | |
63 | + else | |
64 | + echo "You have selected $selected" | |
65 | + fi | |
63 | 66 | fi |
64 | 67 | else |
65 | 68 | [ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay |
... | ... | @@ -15,8 +15,8 @@ zmodload zsh/curses |
15 | 15 | local IFS=" |
16 | 16 | " |
17 | 17 | |
18 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
19 | -[ -f ~/.config/znt/n-env.conf ] && . ~/.config/znt/n-env.conf | |
18 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
19 | +[ -f ~/.config/znt/n-env.conf ] && builtin source ~/.config/znt/n-env.conf | |
20 | 20 | |
21 | 21 | local list |
22 | 22 | local selected |
... | ... | @@ -16,8 +16,8 @@ local IFS=" |
16 | 16 | |
17 | 17 | unset NLIST_COLORING_PATTERN |
18 | 18 | |
19 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
20 | -[ -f ~/.config/znt/n-functions.conf ] && . ~/.config/znt/n-functions.conf | |
19 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
20 | +[ -f ~/.config/znt/n-functions.conf ] && builtin source ~/.config/znt/n-functions.conf | |
21 | 21 | |
22 | 22 | local list |
23 | 23 | local selected |
... | ... | @@ -0,0 +1,135 @@ |
1 | +autoload colors | |
2 | +colors | |
3 | + | |
4 | +local h1="$fg_bold[magenta]" | |
5 | +local h2="$fg_bold[green]" | |
6 | +local h3="$fg_bold[blue]" | |
7 | +local h4="$fg_bold[yellow]" | |
8 | +local h5="$fg_bold[cyan]" | |
9 | +local rst="$reset_color" | |
10 | + | |
11 | +LESS="-iRc" less <<<" | |
12 | +${h1}Key Bindings${rst} | |
13 | + | |
14 | +${h2}H${rst}, ${h2}?${rst} (from n-history) - run n-help | |
15 | +${h2}Ctrl-A${rst} - rotate entered words (1+2+3 -> 3+1+2) | |
16 | +${h2}Ctrl-F${rst} - fix mode (approximate matching) | |
17 | +${h2}Ctrl-L${rst} - redraw of whole display | |
18 | +${h2}Ctrl-T${rst} - browse themes (next theme) | |
19 | +${h2}Ctrl-G${rst} - browse themes (previous theme) | |
20 | +${h2}Ctrl-U${rst} - half page up | |
21 | +${h2}Ctrl-D${rst} - half page down | |
22 | +${h2}Ctrl-P${rst} - previous element (also done with vim's k) | |
23 | +${h2}Ctrl-N${rst} - next element (also done with vim's j) | |
24 | +${h2}[${rst}, ${h2}]${rst} - jump directory bookmarks in n-cd and typical signals in n-kill | |
25 | +${h2}g, ${h2}G${rst} - beginning and end of the list | |
26 | +${h2}/${rst} - show incremental search | |
27 | +${h2}F3${rst} - show/hide incremental search | |
28 | +${h2}Esc${rst} - exit incremental search, clearing filter | |
29 | +${h2}Ctrl-W${rst} (in incremental search) - delete whole word | |
30 | +${h2}Ctrl-K${rst} (in incremental search) - delete whole line | |
31 | +${h2}Ctrl-O, ${h2}o${rst} - enter uniq mode (no duplicate lines) | |
32 | +${h2}Ctrl-E, ${h2}e${rst} - edit private history (when in private history view) | |
33 | +${h2}F1${rst} - (in n-history) - switch view | |
34 | +${h2}F2${rst}, ${h2}Ctrl-X${rst}, ${h2}Ctrl-/${rst} - search predefined keywords (defined in config files) | |
35 | + | |
36 | +${h1}Configuration files${rst} | |
37 | + | |
38 | +Location of the files is ${h3}~/.config/znt${rst}. Skeletons are copied there | |
39 | +when using ${h3}zsh-navigation-tools.plugin.zsh${rst} file (sourcing it or using | |
40 | +a plugin manager). There's a main config file ${h3}n-list.conf${rst} and files | |
41 | +for each tool. | |
42 | + | |
43 | +To have a skeleton copied again into ${h3}~/.config/znt${rst}, delete it from | |
44 | +there and restart Zsh a few times (3-7 or so; there's a random check | |
45 | +that optimizes startup time). | |
46 | + | |
47 | +${h1}Predefined search keywords${rst} | |
48 | + | |
49 | +Following block of code in e.g. ${h3}~/.config/znt/n-history.conf${rst} defines | |
50 | +set of keywords that can be invoked (i.e. searched for) via ${h2}F2${rst}, ${h2}Ctrl-X${rst} | |
51 | +or ${h2}Ctrl-/${rst}: | |
52 | + | |
53 | + ${h4}# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/${rst} | |
54 | + ${h2}local${rst} -a keywords | |
55 | + keywords=( ${h2}\"git\" \"vim\" \"mplayer\"${rst} ) | |
56 | + | |
57 | +${h1}Search query rotation${rst} | |
58 | + | |
59 | +When searching, after pressing ${h2}Ctrl-A${rst}, words 1 2 3 will become 3 1 2, etc. | |
60 | +This can be used to edit some not-last word. | |
61 | + | |
62 | +${h1}Fix mode${rst} | |
63 | + | |
64 | +Approximate matching - pressing ${h2}f${rst} or ${h2}Ctrl-F${rst} will enter "FIX" mode, in which | |
65 | +1 or 2 errors are allowed in what's searched. This utilizes original Zsh | |
66 | +approximate matching features and is intended to be used after entering | |
67 | +search query, when a typo is discovered. | |
68 | + | |
69 | +${h1}Color themes${rst} | |
70 | + | |
71 | +Following block of code in ${h3}~/.config/znt/n-list.conf${rst} defines set of | |
72 | +themes that can be browsed with ${h2}Ctrl-T${rst} and ${h2}Ctrl-G${rst}: | |
73 | + | |
74 | + ${h4}# Combinations of colors to try out with Ctrl-T and Ctrl-G | |
75 | + # The last number is the bold option, 0 or 1${rst} | |
76 | + ${h2}local${rst} -a themes | |
77 | + themes=( ${h2}\"white/black/1\" \"green/black/0\" \"green/black/1\"${rst} | |
78 | + ${h2}\"white/blue/0\" \"white/blue/1\" \"magenta/black/0\"${rst} | |
79 | + ${h2}\"magenta/black/1\"${rst} ) | |
80 | + | |
81 | +It's \"foreground/background/bold\". There's support for 256-color themes | |
82 | +for Zsh > 5.2, defined like e.g.: | |
83 | + | |
84 | + themes=( ${h2}\"white/17/0\" \"10/17/1\" \"white/24/1\"${rst} ) | |
85 | + | |
86 | +i.e. with use of numbers, from 0 to 254. | |
87 | + | |
88 | +${h1}Private history${rst} | |
89 | + | |
90 | +N-history stores what's selected in its own history file. It can be | |
91 | +edited. Use ${h2}e${rst} or ${h2}Ctrl-E${rst} for that when in n-history. Your \$EDITOR will | |
92 | +start. This is a way to have handy set of bookmarks prepared in private | |
93 | +history's file. | |
94 | + | |
95 | +Private history is instantly shared among sessions. | |
96 | + | |
97 | +${h1}Zshrc integration${rst} | |
98 | + | |
99 | +There are 5 standard configuration variables that can be set in zshrc: | |
100 | + | |
101 | +${h4}znt_history_active_text${rst} | |
102 | +\"underline\" or \"reverse\" - how should be active element highlighted | |
103 | +${h4}znt_history_nlist_coloring_pattern${rst} | |
104 | +Pattern that can be used to colorize elements | |
105 | +${h4}znt_history_nlist_coloring_color${rst} | |
106 | +Color with which to colorize via the pattern | |
107 | +${h4}znt_history_nlist_coloring_match_multiple${rst} | |
108 | +Should multiple matches be colorized (${h2}\"0\"${rst} or ${h2}\"1\"${rst}) | |
109 | +${h4}znt_history_keywords ${h2}(array)${rst} | |
110 | +Search keywords activated with Ctrl-X, F2, Ctrl-/, e.g. ( ${h2}\"git\"${rst} ${h2}\"vim\"${rst} ) | |
111 | + | |
112 | +Above variables will work for n-history tool. For other tools, change | |
113 | +\"_history_\" to e.g. \"_cd_\", for the n-cd tool. The same works for | |
114 | +all 8 tools. | |
115 | + | |
116 | +Common configuration of the tools uses variables with \"_list_\" in them: | |
117 | + | |
118 | +${h4}znt_list_bold${rst} | |
119 | +Should draw text in bold (${h2}\"0\"${rst} or ${h2}\"1\"${rst}) | |
120 | +${h4}znt_list_colorpair${rst} | |
121 | +Main pair of colors to be used, e.g ${h2}\"green/black\"${rst} | |
122 | +${h4}znt_list_border${rst} | |
123 | +Should draw borders around windows (${h2}\"0\"${rst} or ${h2}\"1\"${rst}) | |
124 | +${h4}znt_list_themes ${h2}(array)${rst} | |
125 | +List of themes to try out with Ctrl-T, e.g. ( ${h2}\"white/black/1\"${rst} | |
126 | +${h2}\"green/black/0\"${rst} ) | |
127 | +${h4}znt_list_instant_select${rst} | |
128 | +Should pressing enter in search mode leave tool (${h2}\"0\"${rst} or ${h2}\"1\"${rst}) | |
129 | + | |
130 | +If you used ZNT before v2.1.12 then remove old configuration files | |
131 | +${h3}~/.config/znt/*.conf${rst} so that ZNT can update them to the latest versions | |
132 | +that support integration with Zshrc. If you used installer then run it | |
133 | +again (after the remove of configuration files), that is not needed when | |
134 | +using as plugin. | |
135 | +" |
... | ... | @@ -15,37 +15,338 @@ zmodload zsh/parameter |
15 | 15 | local IFS=" |
16 | 16 | " |
17 | 17 | |
18 | -unset NLIST_COLORING_PATTERN | |
18 | +# Variables to save list's state when switching views | |
19 | +# The views are: history and "most frequent history words" | |
20 | +local one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
21 | +local one_NLIST_CURRENT_IDX | |
22 | +local one_NLIST_IS_SEARCH_MODE | |
23 | +local one_NLIST_SEARCH_BUFFER | |
24 | +local one_NLIST_TEXT_OFFSET | |
25 | +local one_NLIST_IS_UNIQ_MODE | |
26 | +local one_NLIST_IS_F_MODE | |
27 | +local one_NLIST_GREP_STRING | |
28 | +local one_NLIST_NONSELECTABLE_ELEMENTS | |
29 | +local one_NLIST_REMEMBER_STATE | |
30 | +local one_NLIST_ENABLED_EVENTS | |
19 | 31 | |
20 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
21 | -[ -f ~/.config/znt/n-history.conf ] && . ~/.config/znt/n-history.conf | |
32 | +local two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
33 | +local two_NLIST_CURRENT_IDX | |
34 | +local two_NLIST_IS_SEARCH_MODE | |
35 | +local two_NLIST_SEARCH_BUFFER | |
36 | +local two_NLIST_TEXT_OFFSET | |
37 | +local two_NLIST_IS_UNIQ_MODE | |
38 | +local two_NLIST_IS_F_MODE | |
39 | +local two_NLIST_GREP_STRING | |
40 | +local two_NLIST_NONSELECTABLE_ELEMENTS | |
41 | +local two_NLIST_REMEMBER_STATE | |
42 | +local two_NLIST_ENABLED_EVENTS | |
22 | 43 | |
23 | -local list | |
24 | -local selected | |
44 | +local three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
45 | +local three_NLIST_CURRENT_IDX | |
46 | +local three_NLIST_IS_SEARCH_MODE | |
47 | +local three_NLIST_SEARCH_BUFFER | |
48 | +local three_NLIST_TEXT_OFFSET | |
49 | +local three_NLIST_IS_UNIQ_MODE | |
50 | +local three_NLIST_IS_F_MODE | |
51 | +local three_NLIST_GREP_STRING | |
52 | +local three_NLIST_NONSELECTABLE_ELEMENTS | |
53 | +local three_NLIST_REMEMBER_STATE | |
54 | +local three_NLIST_ENABLED_EVENTS | |
25 | 55 | |
26 | -NLIST_REMEMBER_STATE=0 | |
56 | +# history view | |
57 | +integer active_view=0 | |
27 | 58 | |
28 | -list=( "$history[@]" ) | |
29 | -list=( "${(@M)list:#(#i)*$1*}" ) | |
59 | +# Lists are "0", "1", "2" - 1st, 2nd, 3rd | |
60 | +# Switching is done in cyclic manner | |
61 | +# i.e. 0 -> 1, 1 -> 2, 2 -> 0 | |
62 | +_nhistory_switch_lists_states() { | |
63 | + # First argument is current, newly selected list, i.e. $active_view | |
64 | + # This implies that we are switching from previous view | |
65 | + | |
66 | + if [ "$1" = "0" ]; then | |
67 | + # Switched to 1st list, save 3rd list's state | |
68 | + three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
69 | + three_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX | |
70 | + three_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE | |
71 | + three_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER | |
72 | + three_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET | |
73 | + three_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE | |
74 | + three_NLIST_IS_F_MODE=$NLIST_IS_F_MODE | |
75 | + three_NLIST_GREP_STRING=$NLIST_GREP_STRING | |
76 | + three_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} ) | |
77 | + three_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE | |
78 | + three_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} ) | |
30 | 79 | |
31 | -if [ "$#list" -eq 0 ]; then | |
32 | - echo "No matching history entries" | |
33 | - return 1 | |
34 | -fi | |
80 | + # ..and restore 1st list's state | |
81 | + NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
82 | + NLIST_CURRENT_IDX=$one_NLIST_CURRENT_IDX | |
83 | + NLIST_IS_SEARCH_MODE=$one_NLIST_IS_SEARCH_MODE | |
84 | + NLIST_SEARCH_BUFFER=$one_NLIST_SEARCH_BUFFER | |
85 | + NLIST_TEXT_OFFSET=$one_NLIST_TEXT_OFFSET | |
86 | + NLIST_IS_UNIQ_MODE=$one_NLIST_IS_UNIQ_MODE | |
87 | + NLIST_IS_F_MODE=$one_NLIST_IS_F_MODE | |
88 | + NLIST_GREP_STRING=$one_NLIST_GREP_STRING | |
89 | + NLIST_NONSELECTABLE_ELEMENTS=( ${one_NLIST_NONSELECTABLE_ELEMENTS[@]} ) | |
90 | + NLIST_REMEMBER_STATE=$one_NLIST_REMEMBER_STATE | |
91 | + NLIST_ENABLED_EVENTS=( ${one_NLIST_ENABLED_EVENTS[@]} ) | |
92 | + elif [ "$1" = "1" ]; then | |
93 | + # Switched to 2nd list, save 1st list's state | |
94 | + one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
95 | + one_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX | |
96 | + one_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE | |
97 | + one_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER | |
98 | + one_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET | |
99 | + one_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE | |
100 | + one_NLIST_IS_F_MODE=$NLIST_IS_F_MODE | |
101 | + one_NLIST_GREP_STRING=$NLIST_GREP_STRING | |
102 | + one_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} ) | |
103 | + one_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE | |
104 | + one_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} ) | |
105 | + | |
106 | + # ..and restore 2nd list's state | |
107 | + NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
108 | + NLIST_CURRENT_IDX=$two_NLIST_CURRENT_IDX | |
109 | + NLIST_IS_SEARCH_MODE=$two_NLIST_IS_SEARCH_MODE | |
110 | + NLIST_SEARCH_BUFFER=$two_NLIST_SEARCH_BUFFER | |
111 | + NLIST_TEXT_OFFSET=$two_NLIST_TEXT_OFFSET | |
112 | + NLIST_IS_UNIQ_MODE=$two_NLIST_IS_UNIQ_MODE | |
113 | + NLIST_IS_F_MODE=$two_NLIST_IS_F_MODE | |
114 | + NLIST_GREP_STRING=$two_NLIST_GREP_STRING | |
115 | + NLIST_NONSELECTABLE_ELEMENTS=( ${two_NLIST_NONSELECTABLE_ELEMENTS[@]} ) | |
116 | + NLIST_REMEMBER_STATE=$two_NLIST_REMEMBER_STATE | |
117 | + NLIST_ENABLED_EVENTS=( ${two_NLIST_ENABLED_EVENTS[@]} ) | |
118 | + elif [ "$1" = "2" ]; then | |
119 | + # Switched to 3rd list, save 2nd list's state | |
120 | + two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
121 | + two_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX | |
122 | + two_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE | |
123 | + two_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER | |
124 | + two_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET | |
125 | + two_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE | |
126 | + two_NLIST_IS_F_MODE=$NLIST_IS_F_MODE | |
127 | + two_NLIST_GREP_STRING=$NLIST_GREP_STRING | |
128 | + two_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} ) | |
129 | + two_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE | |
130 | + two_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} ) | |
131 | + | |
132 | + # ..and restore 3rd list's state | |
133 | + NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN | |
134 | + NLIST_CURRENT_IDX=$three_NLIST_CURRENT_IDX | |
135 | + NLIST_IS_SEARCH_MODE=$three_NLIST_IS_SEARCH_MODE | |
136 | + NLIST_SEARCH_BUFFER=$three_NLIST_SEARCH_BUFFER | |
137 | + NLIST_TEXT_OFFSET=$three_NLIST_TEXT_OFFSET | |
138 | + NLIST_IS_UNIQ_MODE=$three_NLIST_IS_UNIQ_MODE | |
139 | + NLIST_IS_F_MODE=$three_NLIST_IS_F_MODE | |
140 | + NLIST_GREP_STRING=$three_NLIST_GREP_STRING | |
141 | + NLIST_NONSELECTABLE_ELEMENTS=( ${three_NLIST_NONSELECTABLE_ELEMENTS[@]} ) | |
142 | + NLIST_REMEMBER_STATE=$three_NLIST_REMEMBER_STATE | |
143 | + NLIST_ENABLED_EVENTS=( ${three_NLIST_ENABLED_EVENTS[@]} ) | |
144 | + fi | |
145 | +} | |
146 | + | |
147 | +local most_frequent_db="$HOME/.config/znt/mostfrequent.db" | |
148 | +_nhistory_generate_most_frequent() { | |
149 | + local title=$'\x1b[00;31m'"Most frequent history words:"$'\x1b[00;00m\0' | |
150 | + | |
151 | + typeset -A uniq | |
152 | + for k in "${historywords[@]}"; do | |
153 | + uniq[$k]=$(( ${uniq[$k]:-0} + 1 )) | |
154 | + done | |
155 | + vk=() | |
156 | + for k v in ${(kv)uniq}; do | |
157 | + vk+="$v"$'\t'"$k" | |
158 | + done | |
159 | + | |
160 | + print -rl -- "$title" "${(On)vk[@]}" > "$most_frequent_db" | |
161 | +} | |
162 | + | |
163 | +# Load configuration | |
164 | +unset NLIST_COLORING_PATTERN | |
165 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
166 | +[ -f ~/.config/znt/n-history.conf ] && builtin source ~/.config/znt/n-history.conf | |
167 | + | |
168 | +local list | |
169 | +local selected | |
170 | +local private_history_db="$HOME/.config/znt/privhist.db" | |
35 | 171 | |
36 | 172 | local NLIST_GREP_STRING="$1" |
173 | +# 2 is: init once, then remember | |
174 | +local NLIST_REMEMBER_STATE=2 | |
175 | +two_NLIST_REMEMBER_STATE=2 | |
176 | +three_NLIST_REMEMBER_STATE=2 | |
177 | + | |
178 | +# Only Private history has EDIT | |
179 | +local -a NLIST_ENABLED_EVENTS | |
180 | +NLIST_ENABLED_EVENTS=( "F1" "HELP" ) | |
181 | +two_NLIST_ENABLED_EVENTS=( "F1" "EDIT" "HELP" ) | |
182 | +three_NLIST_ENABLED_EVENTS=( "F1" "HELP" ) | |
183 | + | |
184 | +# All view should attempt to replace new lines with \n | |
37 | 185 | local NLIST_REPLACE_NEWLINES="1" |
38 | -n-list "${list[@]}" | |
186 | +two_NLIST_REPLACE_NEWLINES="1" | |
187 | +three_NLIST_REPLACE_NEWLINES="1" | |
188 | + | |
189 | +# Only second and third view has non-selectable first entry | |
190 | +local -a NLIST_NONSELECTABLE_ELEMENTS | |
191 | +NLIST_NONSELECTABLE_ELEMENTS=( ) | |
192 | +two_NLIST_NONSELECTABLE_ELEMENTS=( 1 ) | |
193 | +three_NLIST_NONSELECTABLE_ELEMENTS=( 1 ) | |
194 | + | |
195 | +while (( 1 )); do | |
196 | + | |
197 | + # | |
198 | + # View 1 - history | |
199 | + # | |
200 | + if [ "$active_view" = "0" ]; then | |
201 | + list=( "$history[@]" ) | |
202 | + list=( "${(@M)list:#(#i)*$NLIST_GREP_STRING*}" ) | |
203 | + | |
204 | + if [ "$#list" -eq 0 ]; then | |
205 | + echo "No matching history entries" | |
206 | + return 1 | |
207 | + fi | |
208 | + | |
209 | + n-list "${list[@]}" | |
210 | + | |
211 | + # Selection or quit? | |
212 | + if [[ "$REPLY" = -(#c0,1)[0-9]## && ("$REPLY" -lt 0 || "$REPLY" -gt 0) ]]; then | |
213 | + break | |
214 | + fi | |
215 | + | |
216 | + # View change? | |
217 | + if [ "$REPLY" = "F1" ]; then | |
218 | + # Target view: 2 | |
219 | + active_view=1 | |
220 | + _nhistory_switch_lists_states "1" | |
221 | + elif [ "$REPLY" = "HELP" ]; then | |
222 | + n-help | |
223 | + fi | |
224 | + | |
225 | + # | |
226 | + # View 3 - most frequent words in history | |
227 | + # | |
228 | + elif [ "$active_view" = "2" ]; then | |
229 | + local -a dbfile | |
230 | + dbfile=( $most_frequent_db(Nm+1) ) | |
231 | + | |
232 | + # Compute most frequent history words | |
233 | + if [[ "${#NHISTORY_WORDS}" -eq "0" || "${#dbfile}" -ne "0" ]]; then | |
234 | + # Read the list if it's there | |
235 | + local -a list | |
236 | + list=() | |
237 | + [ -s "$most_frequent_db" ] && list=( ${(f)"$(<$most_frequent_db)"} ) | |
238 | + | |
239 | + # Will wait for the data? | |
240 | + local message=0 | |
241 | + if [[ "${#list}" -eq 0 ]]; then | |
242 | + message=1 | |
243 | + _nlist_alternate_screen 1 | |
244 | + zcurses init | |
245 | + zcurses delwin info 2>/dev/null | |
246 | + zcurses addwin info "$term_height" "$term_width" 0 0 | |
247 | + zcurses bg info white/black | |
248 | + zcurses string info "Computing most frequent history words..."$'\n' | |
249 | + zcurses string info "(This is done once per day, from now on transparently)"$'\n' | |
250 | + zcurses refresh info | |
251 | + sleep 3 | |
252 | + fi | |
253 | + | |
254 | + # Start periodic list regeneration? | |
255 | + if [[ "${#list}" -eq 0 || "${#dbfile}" -ne "0" ]]; then | |
256 | + # Mark the file with current time, to prevent double | |
257 | + # regeneration (on quick double change of view) | |
258 | + print >> "$most_frequent_db" | |
259 | + (_nhistory_generate_most_frequent &) &> /dev/null | |
260 | + fi | |
261 | + | |
262 | + # Ensure we got the list, wait for it if needed | |
263 | + while [[ "${#list}" -eq 0 ]]; do | |
264 | + zcurses string info "." | |
265 | + zcurses refresh info | |
266 | + LANG=C sleep 0.5 | |
267 | + [ -s "$most_frequent_db" ] && list=( ${(f)"$(<$most_frequent_db)"} ) | |
268 | + done | |
269 | + | |
270 | + NHISTORY_WORDS=( "${list[@]}" ) | |
271 | + | |
272 | + if [ "$message" -eq "1" ]; then | |
273 | + zcurses delwin info 2>/dev/null | |
274 | + zcurses refresh | |
275 | + zcurses end | |
276 | + _nlist_alternate_screen 0 | |
277 | + fi | |
278 | + else | |
279 | + # Reuse most frequent history words | |
280 | + local -a list | |
281 | + list=( "${NHISTORY_WORDS[@]}" ) | |
282 | + fi | |
283 | + | |
284 | + n-list "${list[@]}" | |
285 | + | |
286 | + if [ "$REPLY" = "F1" ]; then | |
287 | + # Target view: 1 | |
288 | + active_view=0 | |
289 | + _nhistory_switch_lists_states "0" | |
290 | + elif [[ "$REPLY" = -(#c0,1)[0-9]## && "$REPLY" -lt 0 ]]; then | |
291 | + break | |
292 | + elif [[ "$REPLY" = -(#c0,1)[0-9]## && "$REPLY" -gt 0 ]]; then | |
293 | + local word="${reply[REPLY]#(#s) #[0-9]##$'\t'}" | |
294 | + one_NLIST_SEARCH_BUFFER="$word" | |
295 | + one_NLIST_SEARCH_BUFFER="${one_NLIST_SEARCH_BUFFER## ##}" | |
296 | + | |
297 | + # Target view: 1 | |
298 | + active_view=0 | |
299 | + _nhistory_switch_lists_states "0" | |
300 | + elif [ "$REPLY" = "HELP" ]; then | |
301 | + n-help | |
302 | + fi | |
303 | + | |
304 | + # | |
305 | + # View 2 - private history | |
306 | + # | |
307 | + elif [ "$active_view" = "1" ]; then | |
308 | + if [ -s "$private_history_db" ]; then | |
309 | + local title=$'\x1b[00;32m'"Private history:"$'\x1b[00;00m\0' | |
310 | + () { fc -ap -R "$private_history_db"; list=( "$title" ${history[@]} ) } | |
311 | + else | |
312 | + list=( "Private history - history entries selected via this tool will be put here" ) | |
313 | + fi | |
314 | + | |
315 | + n-list "${list[@]}" | |
316 | + | |
317 | + # Selection or quit? | |
318 | + if [[ "$REPLY" = -(#c0,1)[0-9]## && ("$REPLY" -lt 0 || "$REPLY" -gt 0) ]]; then | |
319 | + break | |
320 | + fi | |
321 | + | |
322 | + # View change? | |
323 | + if [ "$REPLY" = "F1" ]; then | |
324 | + # Target view: 3 | |
325 | + active_view=2 | |
326 | + _nhistory_switch_lists_states "2" | |
327 | + # Edit of the history? | |
328 | + elif [ "$REPLY" = "EDIT" ]; then | |
329 | + "${EDITOR:-vim}" "$private_history_db" | |
330 | + elif [ "$REPLY" = "HELP" ]; then | |
331 | + n-help | |
332 | + fi | |
333 | + fi | |
334 | +done | |
39 | 335 | |
40 | 336 | if [ "$REPLY" -gt 0 ]; then |
41 | 337 | selected="$reply[REPLY]" |
42 | 338 | # ZLE? |
43 | 339 | if [ "${(t)CURSOR}" = "integer-local-special" ]; then |
44 | - zle redisplay | |
45 | - zle kill-buffer | |
46 | - zle -U "$selected" | |
340 | + zle .redisplay | |
341 | + zle .kill-buffer | |
342 | + LBUFFER+="$selected" | |
343 | + | |
344 | + # Append to private history | |
345 | + local newline=$'\n' | |
346 | + selected="${selected//$newline/\\$newline}" | |
347 | + [ "$active_view" = "0" ] && print -r -- "$selected" >> "$private_history_db" | |
47 | 348 | else |
48 | - print -zr "$selected" | |
349 | + print -zr -- "$selected" | |
49 | 350 | fi |
50 | 351 | else |
51 | 352 | [ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay |
... | ... | @@ -13,8 +13,8 @@ zmodload zsh/curses |
13 | 13 | local IFS=" |
14 | 14 | " |
15 | 15 | |
16 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
17 | -[ -f ~/.config/znt/n-kill.conf ] && . ~/.config/znt/n-kill.conf | |
16 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
17 | +[ -f ~/.config/znt/n-kill.conf ] && builtin source ~/.config/znt/n-kill.conf | |
18 | 18 | |
19 | 19 | typeset -A signals |
20 | 20 | signals=( |
... | ... | @@ -29,7 +29,7 @@ _nlist_exit() { |
29 | 29 | setopt localoptions |
30 | 30 | setopt extendedglob |
31 | 31 | |
32 | - [[ "$REPLY" = -(#c0,1)[0-9]## ]] || REPLY="-1" | |
32 | + [[ "$REPLY" = -(#c0,1)[0-9]## || "$REPLY" = F<-> || "$REPLY" = "EDIT" || "$REPLY" = "HELP" ]] || REPLY="-1" | |
33 | 33 | zcurses 2>/dev/null delwin inner |
34 | 34 | zcurses 2>/dev/null delwin main |
35 | 35 | zcurses 2>/dev/null refresh |
... | ... | @@ -167,6 +167,26 @@ integer prev_uniq_mode=0 |
167 | 167 | integer prev_start_idx=-1 |
168 | 168 | local MBEGIN MEND MATCH mbegin mend match |
169 | 169 | |
170 | +# Iteration over predefined keywords | |
171 | +integer curkeyword nkeywords | |
172 | +local keywordisfresh="0" | |
173 | +if [[ "${(t)keywords}" != *array* ]]; then | |
174 | + local -a keywords | |
175 | + keywords=() | |
176 | +fi | |
177 | +curkeyword=0 | |
178 | +nkeywords=${#keywords} | |
179 | + | |
180 | +# Iteration over themes | |
181 | +integer curtheme nthemes | |
182 | +local themeisfresh="0" | |
183 | +if [[ "${(t)themes}" != *array* ]]; then | |
184 | + local -a themes | |
185 | + themes=() | |
186 | +fi | |
187 | +curtheme=0 | |
188 | +nthemes=${#themes} | |
189 | + | |
170 | 190 | # Ability to remember the list between calls |
171 | 191 | if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then |
172 | 192 | NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=1 |
... | ... | @@ -175,6 +195,7 @@ if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REM |
175 | 195 | NLIST_SEARCH_BUFFER="" |
176 | 196 | NLIST_TEXT_OFFSET=0 |
177 | 197 | NLIST_IS_UNIQ_MODE=0 |
198 | + NLIST_IS_F_MODE=0 | |
178 | 199 | |
179 | 200 | # Zero - because it isn't known, unless we |
180 | 201 | # confirm that first element is selectable |
... | ... | @@ -207,12 +228,19 @@ zcurses delwin main 2>/dev/null |
207 | 228 | zcurses delwin inner 2>/dev/null |
208 | 229 | zcurses addwin main "$term_height" "$term_width" 0 0 |
209 | 230 | zcurses addwin inner "$inner_height" "$inner_width" 1 2 |
210 | -zcurses bg main white/black | |
211 | -zcurses bg inner white/black | |
231 | +# From n-list.conf | |
232 | +[ "$colorpair" = "" ] && colorpair="white/black" | |
233 | +[ "$border" = "0" ] || border="1" | |
234 | +local background="${colorpair#*/}" | |
235 | +local backuptheme="$colorpair/$bold" | |
236 | +zcurses bg main "$colorpair" | |
237 | +zcurses bg inner "$colorpair" | |
212 | 238 | if [ "$NLIST_IS_SEARCH_MODE" -ne 1 ]; then |
213 | 239 | _nlist_cursor_visibility 0 |
214 | 240 | fi |
215 | 241 | |
242 | +zcurses refresh | |
243 | + | |
216 | 244 | # |
217 | 245 | # Listening for input |
218 | 246 | # |
... | ... | @@ -237,9 +265,12 @@ while (( 1 )); do |
237 | 265 | # Do searching (filtering with string) |
238 | 266 | if [ -n "$NLIST_SEARCH_BUFFER" ]; then |
239 | 267 | # Compute new list? |
240 | - if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then | |
268 | + if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" | |
269 | + || "$NLIST_IS_F_MODE" -ne "$prev_f_mode" ]] | |
270 | + then | |
241 | 271 | prev_search_buffer="$NLIST_SEARCH_BUFFER" |
242 | 272 | prev_uniq_mode="$NLIST_IS_UNIQ_MODE" |
273 | + prev_f_mode="$NLIST_IS_F_MODE" | |
243 | 274 | # regenerating list -> regenerating disp_list |
244 | 275 | prev_start_idx=-1 |
245 | 276 | |
... | ... | @@ -251,7 +282,9 @@ while (( 1 )); do |
251 | 282 | |
252 | 283 | # Remove non-selectable elements |
253 | 284 | [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do |
254 | - list[$i]=() | |
285 | + if [[ "$i" = <-> ]]; then | |
286 | + list[$i]=() | |
287 | + fi | |
255 | 288 | done |
256 | 289 | |
257 | 290 | # Remove duplicates |
... | ... | @@ -266,13 +299,22 @@ while (( 1 )); do |
266 | 299 | local search_pattern="" |
267 | 300 | local colsearch_pattern="" |
268 | 301 | if [ -n "$search_buffer" ]; then |
269 | - # Patterns will be *foo*~^*bar* and (foo|bar) | |
270 | - search_pattern="${search_buffer// ##/*~^*}" | |
271 | - colsearch_pattern="${search_buffer// ##/|}" | |
272 | - | |
273 | 302 | # The repeat will make the matching work on a fresh heap |
274 | 303 | repeat 1; do |
275 | - list=( "${(@M)list:#(#i)*$~search_pattern*}" ) | |
304 | + if [ "$NLIST_IS_F_MODE" -eq "1" ]; then | |
305 | + search_pattern="${search_buffer// ##/*~^(#a1)*}" | |
306 | + colsearch_pattern="${search_buffer// ##/|(#a1)}" | |
307 | + list=( "${(@M)list:#(#ia1)*$~search_pattern*}" ) | |
308 | + elif [ "$NLIST_IS_F_MODE" -eq "2" ]; then | |
309 | + search_pattern="${search_buffer// ##/*~^(#a2)*}" | |
310 | + colsearch_pattern="${search_buffer// ##/|(#a2)}" | |
311 | + list=( "${(@M)list:#(#ia2)*$~search_pattern*}" ) | |
312 | + else | |
313 | + # Patterns will be *foo*~^*bar* and (foo|bar) | |
314 | + search_pattern="${search_buffer// ##/*~^*}" | |
315 | + colsearch_pattern="${search_buffer// ##/|}" | |
316 | + list=( "${(@M)list:#(#i)*$~search_pattern*}" ) | |
317 | + fi | |
276 | 318 | done |
277 | 319 | |
278 | 320 | last_element="$#list" |
... | ... | @@ -295,7 +337,13 @@ while (( 1 )); do |
295 | 337 | local red=$'\x1b[00;31m' reset=$'\x1b[00;00m' |
296 | 338 | # The repeat will make the matching work on a fresh heap |
297 | 339 | repeat 1; do |
298 | - disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) | |
340 | + if [ "$NLIST_IS_F_MODE" -eq "1" ]; then | |
341 | + disp_list=( "${(@)disp_list//(#mia1)($~colsearch_pattern)/$red${MATCH}$reset}" ) | |
342 | + elif [ "$NLIST_IS_F_MODE" -eq "2" ]; then | |
343 | + disp_list=( "${(@)disp_list//(#mia2)($~colsearch_pattern)/$red${MATCH}$reset}" ) | |
344 | + else | |
345 | + disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) | |
346 | + fi | |
299 | 347 | done |
300 | 348 | fi |
301 | 349 | |
... | ... | @@ -304,6 +352,7 @@ while (( 1 )); do |
304 | 352 | fi |
305 | 353 | |
306 | 354 | # Output colored list |
355 | + zcurses clear inner | |
307 | 356 | n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \ |
308 | 357 | "$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \ |
309 | 358 | "$disp_list[@]" |
... | ... | @@ -327,7 +376,9 @@ while (( 1 )); do |
327 | 376 | # Remove non-selectable elements only when in uniq mode |
328 | 377 | [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && |
329 | 378 | for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do |
330 | - list[$i]=() | |
379 | + if [[ "$i" = <-> ]]; then | |
380 | + list[$i]=() | |
381 | + fi | |
331 | 382 | done |
332 | 383 | |
333 | 384 | # Remove duplicates when in uniq mode |
... | ... | @@ -355,29 +406,49 @@ while (( 1 )); do |
355 | 406 | fi |
356 | 407 | |
357 | 408 | # Output the list |
409 | + zcurses clear inner | |
358 | 410 | n-list-draw "$(( (NLIST_CURRENT_IDX-1) % page_height + 1 ))" \ |
359 | 411 | "$page_height" "$page_width" 0 0 "$NLIST_TEXT_OFFSET" inner \ |
360 | 412 | "$disp_list[@]" |
361 | 413 | fi |
362 | 414 | |
363 | 415 | local status_msg_strlen |
416 | + local keywordmsg="" | |
417 | + if [ "$keywordisfresh" = "1" ]; then | |
418 | + keywordmsg="($curkeyword/$nkeywords) " | |
419 | + keywordisfresh="0" | |
420 | + fi | |
421 | + | |
422 | + local thememsg="" | |
423 | + if [ "$themeisfresh" = "1" ]; then | |
424 | + local theme="$backuptheme" | |
425 | + [ "$curtheme" -gt 0 ] && theme="${themes[curtheme]}" | |
426 | + thememsg="($curtheme/$nthemes $theme) " | |
427 | + themeisfresh="0" | |
428 | + fi | |
429 | + | |
430 | + local _txt2="" _txt3="" | |
431 | + [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] " | |
432 | + [ "$NLIST_IS_F_MODE" -eq 1 ] && _txt3="[-FIX-] " | |
433 | + [ "$NLIST_IS_F_MODE" -eq 2 ] && _txt3="[-FIX2-] " | |
434 | + | |
364 | 435 | if [ "$NLIST_IS_SEARCH_MODE" = "1" ]; then |
365 | - local _txt2="" | |
366 | - [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] " | |
367 | - _nlist_status_msg "${_txt2}Filtering with: ${NLIST_SEARCH_BUFFER// /+}" | |
436 | + _nlist_status_msg "${_txt2}${_txt3}${keywordmsg}${thememsg}Filtering with: ${NLIST_SEARCH_BUFFER// /+}" | |
368 | 437 | elif [[ ${NLIST_NONSELECTABLE_ELEMENTS[(r)$NLIST_CURRENT_IDX]} != $NLIST_CURRENT_IDX || |
369 | 438 | -n "$NLIST_SEARCH_BUFFER" || "$NLIST_IS_UNIQ_MODE" -eq 1 ]]; then |
370 | - local _txt="" _txt2="" | |
439 | + local _txt="" | |
371 | 440 | [ -n "$NLIST_GREP_STRING" ] && _txt=" [$NLIST_GREP_STRING]" |
372 | - [ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && _txt2="[-UNIQ-] " | |
373 | - _nlist_status_msg "${_txt2}Current #$NLIST_USER_CURRENT_IDX (of #$NLIST_USER_LAST_ELEMENT entries)$_txt" | |
441 | + _nlist_status_msg "${_txt2}${_txt3}${keywordmsg}${thememsg}Current #$NLIST_USER_CURRENT_IDX (of #$NLIST_USER_LAST_ELEMENT entries)$_txt" | |
374 | 442 | else |
375 | - _nlist_status_msg "" | |
443 | + _nlist_status_msg "${keywordmsg}${thememsg}" | |
376 | 444 | fi |
377 | 445 | |
378 | - zcurses border main | |
446 | + [ "$border" = "1" ] && zcurses border main | |
379 | 447 | |
380 | - local top_msg="${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL, $USER" | |
448 | + local top_msg=" ${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL " | |
449 | + if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then | |
450 | + top_msg=" F1-change view,$top_msg" | |
451 | + fi | |
381 | 452 | zcurses move main 0 $(( term_width / 2 - $#top_msg / 2 )) |
382 | 453 | zcurses string main $top_msg |
383 | 454 | |
... | ... | @@ -400,7 +471,7 @@ while (( 1 )); do |
400 | 471 | n-list-input "$NLIST_CURRENT_IDX" "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" \ |
401 | 472 | "$page_height" "$page_width" "$last_element" "$NLIST_TEXT_OFFSET" \ |
402 | 473 | "$final_key" "$NLIST_IS_SEARCH_MODE" "$NLIST_SEARCH_BUFFER" \ |
403 | - "$NLIST_IS_UNIQ_MODE" | |
474 | + "$NLIST_IS_UNIQ_MODE" "$NLIST_IS_F_MODE" | |
404 | 475 | |
405 | 476 | selection="$reply[1]" |
406 | 477 | action="$reply[2]" |
... | ... | @@ -410,8 +481,11 @@ while (( 1 )); do |
410 | 481 | NLIST_IS_SEARCH_MODE="$reply[6]" |
411 | 482 | NLIST_SEARCH_BUFFER="$reply[7]" |
412 | 483 | NLIST_IS_UNIQ_MODE="$reply[8]" |
484 | + NLIST_IS_F_MODE="$reply[9]" | |
413 | 485 | |
414 | - if [ "$action" = "SELECT" ]; then | |
486 | + if [ -z "$action" ]; then | |
487 | + continue | |
488 | + elif [ "$action" = "SELECT" ]; then | |
415 | 489 | REPLY="$selection" |
416 | 490 | reply=( "$list[@]" ) |
417 | 491 | break |
... | ... | @@ -422,6 +496,18 @@ while (( 1 )); do |
422 | 496 | elif [ "$action" = "REDRAW" ]; then |
423 | 497 | zcurses clear main redraw |
424 | 498 | zcurses clear inner redraw |
499 | + elif [[ "$action" = F<-> ]]; then | |
500 | + REPLY="$action" | |
501 | + reply=( "$list[@]" ) | |
502 | + break | |
503 | + elif [[ "$action" = "EDIT" ]]; then | |
504 | + REPLY="EDIT" | |
505 | + reply=( "$list[@]" ) | |
506 | + break | |
507 | + elif [[ "$action" = "HELP" ]]; then | |
508 | + REPLY="HELP" | |
509 | + reply=( "$list[@]" ) | |
510 | + break | |
425 | 511 | fi |
426 | 512 | done |
427 | 513 |
... | ... | @@ -79,9 +79,9 @@ _nlist_print_with_ansi() { |
79 | 79 | |
80 | 80 | if (( no_match == 0 )); then |
81 | 81 | if (( col >= 30 && col <= 37 )); then |
82 | - zcurses attr "$win" $c[col-29]/black | |
82 | + zcurses attr "$win" $c[col-29]/"$background" | |
83 | 83 | elif [[ "$col" -eq 0 ]]; then |
84 | - zcurses attr "$win" white/black | |
84 | + zcurses attr "$win" "$colorpair" | |
85 | 85 | fi |
86 | 86 | fi |
87 | 87 | done |
... | ... | @@ -97,17 +97,19 @@ local win="$7" |
97 | 97 | shift 7 |
98 | 98 | integer max_text_len=page_width-x_offset |
99 | 99 | |
100 | -[ "$bold" = "0" ] && bold="" || bold="+bold" | |
100 | +[[ "$bold" = "0" || "$bold" = "-bold" ]] && bold="-bold" || bold="+bold" | |
101 | 101 | [[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || local active_text="reverse" |
102 | -# With Linux terminal underline won't work properly | |
103 | -[ "$TERM" = "linux" ] && active_text="reverse" | |
102 | +# Linux has ncv 18, screen* has ncv 3 - underline won't work properly | |
103 | +(( ${terminfo[ncv]:-0} & 2 )) && active_text="reverse" | |
104 | +# FreeBSD uses TERM=xterm for newcons but doesn't actually support underline | |
105 | +[[ "$TERM" = "xterm" && -z "$DISPLAY" ]] && active_text="reverse" | |
104 | 106 | |
105 | 107 | integer max_idx=page_height |
106 | 108 | integer end_idx=max_idx |
107 | 109 | [ "$end_idx" -gt "$#" ] && end_idx="$#" |
108 | 110 | integer y=y_offset |
109 | 111 | |
110 | -zcurses attr "$win" $bold white/black | |
112 | +zcurses attr "$win" "$bold" "$colorpair" | |
111 | 113 | |
112 | 114 | integer i text_len |
113 | 115 | local text |
... | ... | @@ -14,6 +14,52 @@ _nlist_compute_first_to_show_idx() { |
14 | 14 | from_what_idx_list_is_shown=0+((current_idx-1)/page_height)*page_height+1 |
15 | 15 | } |
16 | 16 | |
17 | +_nlist_update_from_keywords() { | |
18 | + keywordisfresh="1" | |
19 | + if [ "$nkeywords" -gt 0 ]; then | |
20 | + curkeyword=$(( (curkeyword+1) % (nkeywords+1) )) | |
21 | + if [ "$curkeyword" -eq "0" ]; then | |
22 | + buffer="" | |
23 | + else | |
24 | + buffer="${keywords[curkeyword]}" | |
25 | + fi | |
26 | + fi | |
27 | +} | |
28 | + | |
29 | +_nlist_iterate_theme() { | |
30 | + themeisfresh="1" | |
31 | + if [ "$1" = "1" ]; then | |
32 | + curtheme=$(( (curtheme+1) % (nthemes+1) )) | |
33 | + else | |
34 | + curtheme=curtheme-1 | |
35 | + [ "$curtheme" -lt 0 ] && curtheme=nthemes | |
36 | + fi | |
37 | + | |
38 | + if [ "$nthemes" -gt 0 ]; then | |
39 | + local theme=${themes[curtheme]} | |
40 | + [ "$curtheme" -eq "0" ] && theme="$backuptheme" | |
41 | + | |
42 | + colorpair="${theme%/*}" | |
43 | + bold="${theme##*/}" | |
44 | + background="${colorpair#*/}" | |
45 | + zcurses bg main "$colorpair" | |
46 | + zcurses bg inner "$colorpair" | |
47 | + fi | |
48 | +} | |
49 | + | |
50 | +_nlist_rotate_buffer() { | |
51 | + setopt localoptions noglob | |
52 | + | |
53 | + local -a words | |
54 | + words=( ${(s: :)buffer} ) | |
55 | + words=( ${words[-1]} ${words[1,-2]} ) | |
56 | + | |
57 | + local space="" | |
58 | + [ "${buffer[-1]}" = " " ] && space=" " | |
59 | + | |
60 | + buffer="${(j: :)words}$space" | |
61 | +} | |
62 | + | |
17 | 63 | typeset -ga reply |
18 | 64 | reply=( -1 '' ) |
19 | 65 | integer current_idx="$1" |
... | ... | @@ -26,6 +72,7 @@ local key="$7" |
26 | 72 | integer search="$8" |
27 | 73 | local buffer="$9" |
28 | 74 | integer uniq_mode="$10" |
75 | +integer f_mode="$11" | |
29 | 76 | |
30 | 77 | # |
31 | 78 | # Listening for input |
... | ... | @@ -79,21 +126,36 @@ case "$key" in |
79 | 126 | ${NLIST_NONSELECTABLE_ELEMENTS[(r)$current_idx]} != $current_idx ]] |
80 | 127 | then |
81 | 128 | # Save current element in the result variable |
82 | - reply=( $current_idx SELECT ) | |
129 | + reply=( $current_idx "SELECT" ) | |
130 | + fi | |
131 | + ;; | |
132 | + (H|'?') | |
133 | + # This event needs to be enabled | |
134 | + if [[ "${NLIST_ENABLED_EVENTS[(r)HELP]}" = "HELP" ]]; then | |
135 | + reply=( -1 "HELP" ) | |
83 | 136 | fi |
84 | 137 | ;; |
138 | + (F1) | |
139 | + # This event needs to be enabled | |
140 | + if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then | |
141 | + reply=( -1 "$key" ) | |
142 | + fi | |
143 | + ;; | |
144 | + (F4|F5|F6|F7|F8|F9|F10|DC) | |
145 | + # ignore; F2, F3 are used below | |
146 | + ;; | |
85 | 147 | (q) |
86 | - reply=( -1 QUIT ) | |
148 | + reply=( -1 "QUIT" ) | |
87 | 149 | ;; |
88 | 150 | (/) |
89 | 151 | search=1 |
90 | 152 | _nlist_cursor_visibility 1 |
91 | 153 | ;; |
92 | 154 | ($'\t') |
93 | - reply=( $current_idx LEAVE ) | |
155 | + reply=( $current_idx "LEAVE" ) | |
94 | 156 | ;; |
95 | 157 | ($'\C-L') |
96 | - reply=( -1 REDRAW ) | |
158 | + reply=( -1 "REDRAW" ) | |
97 | 159 | ;; |
98 | 160 | (\]) |
99 | 161 | [[ "${(t)NLIST_HOP_INDEXES}" = "array" || "${(t)NLIST_HOP_INDEXES}" = "array-local" ]] && |
... | ... | @@ -127,9 +189,41 @@ case "$key" in |
127 | 189 | ($'\E') |
128 | 190 | buffer="" |
129 | 191 | ;; |
192 | + (F3) | |
193 | + if [ "$search" = "1" ]; then | |
194 | + search=0 | |
195 | + _nlist_cursor_visibility 0 | |
196 | + else | |
197 | + search=1 | |
198 | + _nlist_cursor_visibility 1 | |
199 | + fi | |
200 | + ;; | |
130 | 201 | (o|$'\C-O') |
131 | 202 | uniq_mode=1-uniq_mode |
132 | 203 | ;; |
204 | + (f|$'\C-F') | |
205 | + (( f_mode=(f_mode+1) % 3 )) | |
206 | + ;; | |
207 | + ($'\x1F'|F2|$'\C-X') | |
208 | + search=1 | |
209 | + _nlist_cursor_visibility 1 | |
210 | + _nlist_update_from_keywords | |
211 | + ;; | |
212 | + ($'\C-T') | |
213 | + _nlist_iterate_theme 1 | |
214 | + ;; | |
215 | + ($'\C-G') | |
216 | + _nlist_iterate_theme 0 | |
217 | + ;; | |
218 | + ($'\C-E'|e) | |
219 | + # This event needs to be enabled | |
220 | + if [[ "${NLIST_ENABLED_EVENTS[(r)EDIT]}" = "EDIT" ]]; then | |
221 | + reply=( -1 "EDIT" ) | |
222 | + fi | |
223 | + ;; | |
224 | + ($'\C-A') | |
225 | + _nlist_rotate_buffer | |
226 | + ;; | |
133 | 227 | (*) |
134 | 228 | ;; |
135 | 229 | esac |
... | ... | @@ -138,11 +232,19 @@ else |
138 | 232 | |
139 | 233 | case "$key" in |
140 | 234 | ($'\n'|ENTER) |
141 | - search=0 | |
142 | - _nlist_cursor_visibility 0 | |
235 | + if [ "$NLIST_INSTANT_SELECT" = "1" ]; then | |
236 | + if [[ "$NLIST_SEARCH_BUFFER" != "" || "$NLIST_IS_UNIQ_MODE" -eq 1 || | |
237 | + ${NLIST_NONSELECTABLE_ELEMENTS[(r)$current_idx]} != $current_idx ]] | |
238 | + then | |
239 | + reply=( $current_idx "SELECT" ) | |
240 | + fi | |
241 | + else | |
242 | + search=0 | |
243 | + _nlist_cursor_visibility 0 | |
244 | + fi | |
143 | 245 | ;; |
144 | 246 | ($'\C-L') |
145 | - reply=( -1 REDRAW ) | |
247 | + reply=( -1 "REDRAW" ) | |
146 | 248 | ;; |
147 | 249 | |
148 | 250 | # |
... | ... | @@ -192,8 +294,14 @@ case "$key" in |
192 | 294 | (RIGHT) |
193 | 295 | hscroll+=7 |
194 | 296 | ;; |
195 | - (F1|F2|F3|F4|F5|F6|F7|F8|F9|F10) | |
196 | - # ignore | |
297 | + (F1) | |
298 | + # This event needs to be enabled | |
299 | + if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then | |
300 | + reply=( -1 "$key" ) | |
301 | + fi | |
302 | + ;; | |
303 | + (F4|F5|F6|F7|F8|F9|F10|DC) | |
304 | + # ignore; F2, F3 are used below | |
197 | 305 | ;; |
198 | 306 | |
199 | 307 | # |
... | ... | @@ -214,9 +322,39 @@ case "$key" in |
214 | 322 | search=0 |
215 | 323 | _nlist_cursor_visibility 0 |
216 | 324 | ;; |
325 | + (F3) | |
326 | + if [ "$search" = "1" ]; then | |
327 | + search=0 | |
328 | + _nlist_cursor_visibility 0 | |
329 | + else | |
330 | + search=1 | |
331 | + _nlist_cursor_visibility 1 | |
332 | + fi | |
333 | + ;; | |
217 | 334 | ($'\C-O') |
218 | 335 | uniq_mode=1-uniq_mode |
219 | 336 | ;; |
337 | + ($'\C-F') | |
338 | + (( f_mode=(f_mode+1) % 3 )) | |
339 | + ;; | |
340 | + ($'\x1F'|F2|$'\C-X') | |
341 | + _nlist_update_from_keywords | |
342 | + ;; | |
343 | + ($'\C-T') | |
344 | + _nlist_iterate_theme 1 | |
345 | + ;; | |
346 | + ($'\C-G') | |
347 | + _nlist_iterate_theme 0 | |
348 | + ;; | |
349 | + ($'\C-E') | |
350 | + # This event needs to be enabled | |
351 | + if [[ "${NLIST_ENABLED_EVENTS[(r)EDIT]}" = "EDIT" ]]; then | |
352 | + reply=( -1 "EDIT" ) | |
353 | + fi | |
354 | + ;; | |
355 | + ($'\C-A') | |
356 | + _nlist_rotate_buffer | |
357 | + ;; | |
220 | 358 | (*) |
221 | 359 | if [[ $#key == 1 && $((#key)) -lt 31 ]]; then |
222 | 360 | # ignore all other control keys |
... | ... | @@ -234,5 +372,6 @@ reply[5]="$hscroll" |
234 | 372 | reply[6]="$search" |
235 | 373 | reply[7]="$buffer" |
236 | 374 | reply[8]="$uniq_mode" |
375 | +reply[9]="$f_mode" | |
237 | 376 | |
238 | 377 | # vim: set filetype=zsh: |
... | ... | @@ -14,8 +14,8 @@ local IFS=" |
14 | 14 | |
15 | 15 | unset NLIST_COLORING_PATTERN |
16 | 16 | |
17 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
18 | -[ -f ~/.config/znt/n-options.conf ] && . ~/.config/znt/n-options.conf | |
17 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
18 | +[ -f ~/.config/znt/n-options.conf ] && builtin source ~/.config/znt/n-options.conf | |
19 | 19 | |
20 | 20 | # TODO restore options |
21 | 21 | unsetopt localoptions |
... | ... | @@ -17,8 +17,8 @@ local IFS=" |
17 | 17 | |
18 | 18 | unset NLIST_COLORING_PATTERN |
19 | 19 | |
20 | -[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf | |
21 | -[ -f ~/.config/znt/n-panelize.conf ] && . ~/.config/znt/n-panelize.conf | |
20 | +[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf | |
21 | +[ -f ~/.config/znt/n-panelize.conf ] && builtin source ~/.config/znt/n-panelize.conf | |
22 | 22 | |
23 | 23 | local list |
24 | 24 | local selected |
... | ... | @@ -4,6 +4,14 @@ local NLIST_START_IN_UNIQ_MODE=1 |
4 | 4 | |
5 | 5 | # Only if current $BUFFER doesn't come from history |
6 | 6 | if [ "$HISTCMD" = "$HISTNO" ]; then |
7 | + () { | |
8 | + setopt localoptions extendedglob | |
9 | + local -a match mbegin mend | |
10 | + local MATCH; integer MBEGIN MEND | |
11 | + | |
12 | + [ -n "$BUFFER" ] && BUFFER="${BUFFER%% ##} " | |
13 | + } | |
14 | + | |
7 | 15 | local NLIST_SET_SEARCH_TO="$BUFFER" |
8 | 16 | fi |
9 | 17 |
... | ... | @@ -15,24 +15,36 @@ if ! test -d "$CONFIG_DIR"; then |
15 | 15 | mkdir "$CONFIG_DIR" |
16 | 16 | fi |
17 | 17 | |
18 | +# 9 files | |
18 | 19 | set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf |
19 | 20 | |
20 | -for i; do | |
21 | - if ! test -f "$CONFIG_DIR/$i"; then | |
22 | - cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR" | |
23 | - fi | |
24 | -done | |
21 | +# Check for random 2 files if they exist | |
22 | +# This will shift 0 - 7 elements | |
23 | +shift $(( RANDOM % 8 )) | |
24 | +if ! test -f "$CONFIG_DIR/$1" || ! test -f "$CONFIG_DIR/$2"; then | |
25 | + # Something changed - examine every file | |
26 | + set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf | |
27 | + for i; do | |
28 | + if ! test -f "$CONFIG_DIR/$i"; then | |
29 | + cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR" | |
30 | + fi | |
31 | + done | |
32 | +fi | |
33 | + | |
34 | +# Don't leave positional parameters being set | |
35 | +set -- | |
25 | 36 | |
26 | 37 | # |
27 | 38 | # Load functions |
28 | 39 | # |
29 | 40 | |
30 | -autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize | |
41 | +autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize n-help | |
31 | 42 | autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget |
32 | 43 | alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history |
33 | -alias nkill=n-kill noptions=n-options npanelize=n-panelize | |
44 | +alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help | |
34 | 45 | |
35 | 46 | zle -N znt-history-widget |
36 | 47 | bindkey '^R' znt-history-widget |
37 | 48 | setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS |
49 | +zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*' | |
38 | 50 |
1 | +# If you come from bash you might have to change your $PATH. | |
2 | +# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
3 | + | |
1 | 4 | # Path to your oh-my-zsh installation. |
2 | 5 | export ZSH=$HOME/.oh-my-zsh |
3 | 6 | |
4 | -# Set name of the theme to load. | |
5 | -# Look in ~/.oh-my-zsh/themes/ | |
6 | -# Optionally, if you set this to "random", it'll load a random theme each | |
7 | -# time that oh-my-zsh is loaded. | |
7 | +# Set name of the theme to load. Optionally, if you set this to "random" | |
8 | +# it'll load a random theme each time that oh-my-zsh is loaded. | |
9 | +# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
8 | 10 | ZSH_THEME="robbyrussell" |
9 | 11 | |
10 | 12 | # Uncomment the following line to use case-sensitive completion. |
... | ... | @@ -51,13 +53,12 @@ ZSH_THEME="robbyrussell" |
51 | 53 | # Add wisely, as too many plugins slow down shell startup. |
52 | 54 | plugins=(git) |
53 | 55 | |
56 | +source $ZSH/oh-my-zsh.sh | |
57 | + | |
54 | 58 | # User configuration |
55 | 59 | |
56 | -export PATH=$HOME/bin:/usr/local/bin:$PATH | |
57 | 60 | # export MANPATH="/usr/local/man:$MANPATH" |
58 | 61 | |
59 | -source $ZSH/oh-my-zsh.sh | |
60 | - | |
61 | 62 | # You may need to manually set your language environment |
62 | 63 | # export LANG=en_US.UTF-8 |
63 | 64 |
... | ... | @@ -41,6 +41,8 @@ function _vi_status() { |
41 | 41 | function _ruby_version() { |
42 | 42 | if {echo $fpath | grep -q "plugins/rvm"}; then |
43 | 43 | echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}" |
44 | + elif {echo $fpath | grep -q "plugins/rbenv"}; then | |
45 | + echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}" | |
44 | 46 | fi |
45 | 47 | } |
46 | 48 |
... | ... | @@ -22,38 +22,44 @@ bureau_git_branch () { |
22 | 22 | echo "${ref#refs/heads/}" |
23 | 23 | } |
24 | 24 | |
25 | -bureau_git_status () { | |
25 | +bureau_git_status() { | |
26 | 26 | _STATUS="" |
27 | - if [[ $(command git status --short 2> /dev/null) != "" ]]; then | |
28 | - _INDEX=$(command git status --porcelain -b 2> /dev/null) | |
29 | - if $(echo "$_INDEX" | command grep '^[AMRD]. ' &> /dev/null); then | |
27 | + | |
28 | + # check status of files | |
29 | + _INDEX=$(command git status --porcelain 2> /dev/null) | |
30 | + if [[ -n "$_INDEX" ]]; then | |
31 | + if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then | |
30 | 32 | _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED" |
31 | 33 | fi |
32 | - if $(echo "$_INDEX" | command grep '^.[MTD] ' &> /dev/null); then | |
34 | + if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then | |
33 | 35 | _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" |
34 | 36 | fi |
35 | - if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then | |
37 | + if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then | |
36 | 38 | _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" |
37 | 39 | fi |
38 | - if $(echo "$_INDEX" | command grep '^UU ' &> /dev/null); then | |
40 | + if $(echo "$_INDEX" | command grep -q '^UU '); then | |
39 | 41 | _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" |
40 | 42 | fi |
41 | - if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then | |
42 | - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED" | |
43 | - fi | |
44 | - if $(echo "$_INDEX" | command grep '^## .*ahead' &> /dev/null); then | |
45 | - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" | |
46 | - fi | |
47 | - if $(echo "$_INDEX" | command grep '^## .*behind' &> /dev/null); then | |
48 | - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND" | |
49 | - fi | |
50 | - if $(echo "$_INDEX" | command grep '^## .*diverged' &> /dev/null); then | |
51 | - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED" | |
52 | - fi | |
53 | 43 | else |
54 | 44 | _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" |
55 | 45 | fi |
56 | 46 | |
47 | + # check status of local repository | |
48 | + _INDEX=$(command git status --porcelain -b 2> /dev/null) | |
49 | + if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then | |
50 | + _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" | |
51 | + fi | |
52 | + if $(echo "$_INDEX" | command grep -q '^## .*behind'); then | |
53 | + _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND" | |
54 | + fi | |
55 | + if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then | |
56 | + _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED" | |
57 | + fi | |
58 | + | |
59 | + if $(command git rev-parse --verify refs/stash &> /dev/null); then | |
60 | + _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED" | |
61 | + fi | |
62 | + | |
57 | 63 | echo $_STATUS |
58 | 64 | } |
59 | 65 |
... | ... | @@ -37,7 +37,7 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" |
37 | 37 | function git_time_since_commit() { |
38 | 38 | if git rev-parse --git-dir > /dev/null 2>&1; then |
39 | 39 | # Only proceed if there is actually a commit. |
40 | - if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then | |
40 | + if git log -n 1 > /dev/null 2>&1; then | |
41 | 41 | # Get the last commit. |
42 | 42 | last_commit=`git log --pretty=format:'%at' -1 2> /dev/null` |
43 | 43 | now=`date +%s` |
... | ... | @@ -13,11 +13,11 @@ GIT_DIRTY_COLOR=$FG[133] |
13 | 13 | GIT_CLEAN_COLOR=$FG[118] |
14 | 14 | GIT_PROMPT_INFO=$FG[012] |
15 | 15 | |
16 | -PROMPT='%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%} %{$GIT_PROMPT_INFO%}$(git_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} ' | |
16 | +PROMPT='%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%}%{$GIT_PROMPT_INFO%}$(git_prompt_info)$(virtualenv_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} ' | |
17 | 17 | |
18 | 18 | #RPS1="${return_code}" |
19 | 19 | |
20 | -ZSH_THEME_GIT_PROMPT_PREFIX="(" | |
20 | +ZSH_THEME_GIT_PROMPT_PREFIX=" (" | |
21 | 21 | ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%})" |
22 | 22 | ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘" |
23 | 23 | ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔" |
... | ... | @@ -28,3 +28,6 @@ ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[160]%}✖%{$reset_color%}" |
28 | 28 | ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[220]%}➜%{$reset_color%}" |
29 | 29 | ZSH_THEME_GIT_PROMPT_UNMERGED="%{$FG[082]%}═%{$reset_color%}" |
30 | 30 | ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$FG[190]%}✭%{$reset_color%}" |
31 | + | |
32 | +ZSH_THEME_VIRTUALENV_PREFIX=" [" | |
33 | +ZSH_THEME_VIRTUALENV_SUFFIX="]" |
... | ... | @@ -41,4 +41,10 @@ PROMPT=' |
41 | 41 | %~ |
42 | 42 | ${smiley} %{$reset_color%}' |
43 | 43 | |
44 | -RPROMPT='%{$fg[white]%} $(~/.rvm/bin/rvm-prompt)$(git_prompt)%{$reset_color%}' | |
44 | +if [[ -d ~/.rvm ]] && [[ -e ~/.rvm/bin/rvm-prompt ]]; then | |
45 | + rvm_prompt='$(~/.rvm/bin/rvm-prompt)' | |
46 | +else | |
47 | + rvm_prompt='' | |
48 | +fi | |
49 | + | |
50 | +RPROMPT='%{$fg[white]%} $rvm_prompt$(git_prompt)%{$reset_color%}' |
... | ... | @@ -10,9 +10,9 @@ B=$fg_no_bold[blue] |
10 | 10 | RESET=$reset_color |
11 | 11 | |
12 | 12 | if [ "$USER" = "root" ]; then |
13 | - PROMPTCOLOR="%{$R%}" PREFIX="-!-"; | |
13 | + PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-"; | |
14 | 14 | else |
15 | - PROMPTCOLOR="" PREFIX="---"; | |
15 | + PROMPTCOLOR="" PROMPTPREFIX="---"; | |
16 | 16 | fi |
17 | 17 | |
18 | 18 | local return_code="%(?..%{$R%}%? ↵%{$RESET%})" |
... | ... | @@ -66,7 +66,7 @@ function custom_git_prompt() { |
66 | 66 | } |
67 | 67 | |
68 | 68 | # %B sets bold text |
69 | -PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' | |
69 | +PROMPT='%B$PROMPTPREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' | |
70 | 70 | RPS1="${return_code}" |
71 | 71 | |
72 | 72 | ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹" |
... | ... | @@ -53,11 +53,6 @@ main() { |
53 | 53 | echo "Error: git is not installed" |
54 | 54 | exit 1 |
55 | 55 | } |
56 | - env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { | |
57 | - printf "Error: git clone of oh-my-zsh repo failed\n" | |
58 | - exit 1 | |
59 | - } | |
60 | - | |
61 | 56 | # The Windows (MSYS) Git is not compatible with normal use on cygwin |
62 | 57 | if [ "$OSTYPE" = cygwin ]; then |
63 | 58 | if git --version | grep msysgit > /dev/null; then |
... | ... | @@ -66,6 +61,11 @@ main() { |
66 | 61 | exit 1 |
67 | 62 | fi |
68 | 63 | fi |
64 | + env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { | |
65 | + printf "Error: git clone of oh-my-zsh repo failed\n" | |
66 | + exit 1 | |
67 | + } | |
68 | + | |
69 | 69 | |
70 | 70 | printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n" |
71 | 71 | if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then |
... | ... | @@ -80,12 +80,6 @@ main() { |
80 | 80 | " ~/.zshrc > ~/.zshrc-omztemp |
81 | 81 | mv -f ~/.zshrc-omztemp ~/.zshrc |
82 | 82 | |
83 | - printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n" | |
84 | - sed "/export PATH=/ c\\ | |
85 | - export PATH=\"$PATH\" | |
86 | - " ~/.zshrc > ~/.zshrc-omztemp | |
87 | - mv -f ~/.zshrc-omztemp ~/.zshrc | |
88 | - | |
89 | 83 | # If this user's login shell is not already "zsh", attempt to switch. |
90 | 84 | TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') |
91 | 85 | if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then |