summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/autojump/autojump.plugin.zsh4
-rw-r--r--plugins/capistrano/_capistrano53
-rw-r--r--plugins/capistrano/capistrano.plugin.zsh11
-rw-r--r--plugins/coffee/coffee.plugin.zsh4
-rw-r--r--plugins/docker/_docker2
-rw-r--r--plugins/ember-cli/README.md31
-rw-r--r--plugins/ember-cli/ember-cli.plugin.zsh7
-rw-r--r--plugins/emoji/emoji-char-definitions.zsh9
-rw-r--r--plugins/emoji/emoji.plugin.zsh7
-rw-r--r--plugins/emoji/update_emoji.pl2
-rw-r--r--plugins/frontend-search/README.md112
-rw-r--r--plugins/frontend-search/_frontend-search.sh4
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh215
-rw-r--r--plugins/git-extras/git-extras.plugin.zsh194
-rw-r--r--plugins/git-flow/git-flow.plugin.zsh2
-rw-r--r--plugins/git-prompt/git-prompt.plugin.zsh89
-rw-r--r--plugins/git-prompt/gitstatus.py146
-rw-r--r--plugins/git/git.plugin.zsh4
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh5
-rw-r--r--plugins/gradle/gradle.plugin.zsh2
-rw-r--r--plugins/gulp/gulp.plugin.zsh29
-rw-r--r--plugins/heroku/_heroku1
-rw-r--r--plugins/jira/_jira21
-rw-r--r--plugins/jira/jira.plugin.zsh150
-rw-r--r--plugins/man/man.zsh27
-rw-r--r--plugins/npm/npm.plugin.zsh3
-rw-r--r--plugins/osx/osx.plugin.zsh84
-rw-r--r--plugins/rails/rails.plugin.zsh4
-rw-r--r--plugins/rand-quote/rand-quote.plugin.zsh2
-rw-r--r--plugins/rbenv/rbenv.plugin.zsh9
-rw-r--r--plugins/rvm/rvm.plugin.zsh10
-rw-r--r--plugins/scw/README.md7
-rw-r--r--plugins/scw/_scw333
-rw-r--r--plugins/spring/README.md25
-rw-r--r--plugins/spring/_spring29
-rw-r--r--plugins/sudo/sudo.plugin.zsh6
-rw-r--r--plugins/svn/svn.plugin.zsh10
-rw-r--r--plugins/symfony2/symfony2.plugin.zsh2
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh8
-rw-r--r--plugins/taskwarrior/README.md13
-rw-r--r--plugins/taskwarrior/_task312
-rw-r--r--plugins/taskwarrior/taskwarrior.plugin.zsh14
-rw-r--r--plugins/terminalapp/terminalapp.plugin.zsh45
-rw-r--r--plugins/thefuck/README.md9
-rw-r--r--plugins/thefuck/thefuck.plugin.zsh17
-rw-r--r--plugins/ubuntu/ubuntu.plugin.zsh7
-rw-r--r--plugins/vundle/vundle.plugin.zsh10
-rw-r--r--plugins/xcode/README.md84
-rw-r--r--plugins/xcode/_xcselv19
-rw-r--r--plugins/xcode/xcode.plugin.zsh192
50 files changed, 1631 insertions, 754 deletions
diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh
index 4cf036401..c05c699e1 100644
--- a/plugins/autojump/autojump.plugin.zsh
+++ b/plugins/autojump/autojump.plugin.zsh
@@ -15,7 +15,7 @@ if [ $commands[autojump] ]; then # check if autojump is installed
. /usr/local/share/autojump/autojump.zsh
elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports
. /opt/local/etc/profile.d/autojump.zsh
- elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.zsh ]; then # mac os x with brew
- . `brew --prefix`/etc/autojump.zsh
+ elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew
+ . `brew --prefix`/etc/autojump.sh
fi
fi
diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano
index 3cadf3d54..e6e71ffcc 100644
--- a/plugins/capistrano/_capistrano
+++ b/plugins/capistrano/_capistrano
@@ -1,10 +1,49 @@
-#compdef cap
+#compdef shipit
#autoload
-if [[ -f config/deploy.rb || -f Capfile ]]; then
- if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then
- echo "\nGenerating .cap_tasks~..." > /dev/stderr
- cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
+# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work.
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
+
+local curcontext="$curcontext" state line ret=1
+local -a _configs
+
+_arguments -C \
+ '1: :->cmds' \
+ '2:: :->args' && ret=0
+
+_cap_tasks() {
+ if [[ -f config/deploy.rb || -f Capfile ]]; then
+ if [[ ! -f .cap_tasks~ ]]; then
+ shipit -v --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~
+ fi
+
+ OLD_IFS=$IFS
+ IFS=$'\n'
+ _values 'cap commands' $(< .cap_tasks~)
+ IFS=$OLD_IFS
+ # zmodload zsh/mapfile
+ # _values ${(f)mapfile[.cap_tasks~]}
fi
- compadd `cat .cap_tasks~`
-fi
+}
+
+_cap_stages() {
+ compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
+}
+
+case $state in
+ cmds)
+ # check if it uses multistage
+ if [[ -d config/deploy ]]; then
+ _cap_stages
+ else
+ _cap_tasks
+ fi
+ ret=0
+ ;;
+ args)
+ _cap_tasks
+ ret=0
+ ;;
+esac
+
+return ret
diff --git a/plugins/capistrano/capistrano.plugin.zsh b/plugins/capistrano/capistrano.plugin.zsh
new file mode 100644
index 000000000..c85eb474c
--- /dev/null
+++ b/plugins/capistrano/capistrano.plugin.zsh
@@ -0,0 +1,11 @@
+# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work.
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
+
+func shipit() {
+ if [ -f Gemfile ]
+ then
+ bundle exec cap $*
+ else
+ cap $*
+ fi
+}
diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh
index 1a7bedd87..4e98e0228 100644
--- a/plugins/coffee/coffee.plugin.zsh
+++ b/plugins/coffee/coffee.plugin.zsh
@@ -2,11 +2,11 @@
# compile a string of coffeescript and print to output
cf () {
- coffee -peb $1
+ coffee -peb "$1"
}
# compile & copy to clipboard
cfc () {
- cf $1 | pbcopy
+ cf "$1" | pbcopy
}
# compile from pasteboard & print
diff --git a/plugins/docker/_docker b/plugins/docker/_docker
index 25f55beca..a82a31ad3 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -27,7 +27,7 @@ __docker_all_containers() {
# output a selectable list of all docker images
__docker_images() {
declare -a img_cmd
- img_cmd=($(docker images | awk 'NR>1{print $1}'))
+ img_cmd=($(docker images | awk 'NR>1{print $1}'| sed 's/:/\\:/g'))
_describe 'images' img_cmd
}
diff --git a/plugins/ember-cli/README.md b/plugins/ember-cli/README.md
index d1dedf884..482c347d2 100644
--- a/plugins/ember-cli/README.md
+++ b/plugins/ember-cli/README.md
@@ -1,22 +1,19 @@
-# Ember-cli
+# Ember CLI
-**Maintainer:** [BilalBudhani](http://www.github.com/BilalBudhani)
+**Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa)
-Ember-cli (http://www.ember-cli.com/)
+Ember CLI (http://www.ember-cli.com/)
### List of Aliases
-alias es='ember serve'
-alias ea='ember addon'
-alias eb='ember build'
-alias ed='ember destroy'
-alias eg='ember generate'
-alias eh='ember help'
-alias ein='ember init'
-alias eia='ember install:addon'
-alias eib='ember install:bower'
-alias ein='ember install:npm'
-alias ei='ember install'
-alias et='ember test'
-alias eu='ember update'
-alias ev='ember version'
+ alias es='ember serve'
+ alias ea='ember addon'
+ alias eb='ember build'
+ alias ed='ember destroy'
+ alias eg='ember generate'
+ alias eh='ember help'
+ alias ein='ember init'
+ alias ei='ember install'
+ alias et='ember test'
+ alias eu='ember update'
+ alias ev='ember version'
diff --git a/plugins/ember-cli/ember-cli.plugin.zsh b/plugins/ember-cli/ember-cli.plugin.zsh
index 044a2c043..a0f346829 100644
--- a/plugins/ember-cli/ember-cli.plugin.zsh
+++ b/plugins/ember-cli/ember-cli.plugin.zsh
@@ -1,5 +1,5 @@
-# Ember ClI
-# visit http://www.ember-cli.com/ to view user guid
+# Ember CLI
+# Visit http://www.ember-cli.com/ to view user guide
alias es='ember serve'
alias ea='ember addon'
@@ -8,9 +8,6 @@ alias ed='ember destroy'
alias eg='ember generate'
alias eh='ember help'
alias ein='ember init'
-alias eia='ember install:addon'
-alias eib='ember install:bower'
-alias ein='ember install:npm'
alias ei='ember install'
alias et='ember test'
alias eu='ember update'
diff --git a/plugins/emoji/emoji-char-definitions.zsh b/plugins/emoji/emoji-char-definitions.zsh
index 7d110603c..04693da05 100644
--- a/plugins/emoji/emoji-char-definitions.zsh
+++ b/plugins/emoji/emoji-char-definitions.zsh
@@ -7,8 +7,12 @@
# $emoji - which maps character names to Unicode characters
# $emoji_flags - maps country names to Unicode flag characters using region indicators
+# Main emoji
typeset -gAH emoji
+# National flags
typeset -gAH emoji_flags
+# Combining modifiers
+typeset -gAH emoji_mod
emoji[copyright_sign]=$'\U00A9'
emoji[registered_sign]=$'\U00AE'
@@ -448,10 +452,15 @@ emoji[badminton_racquet_and_shuttlecock]=$'\U1F3F8'
emoji[bow_and_arrow]=$'\U1F3F9'
emoji[amphora]=$'\U1F3FA'
emoji[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB'
+emoji_mod[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB'
emoji[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC'
+emoji_mod[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC'
emoji[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD'
+emoji_mod[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD'
emoji[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE'
+emoji_mod[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE'
emoji[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF'
+emoji_mod[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF'
emoji[rat]=$'\U1F400'
emoji[mouse]=$'\U1F401'
emoji[ox]=$'\U1F402'
diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh
index a98d0b714..7876f1c89 100644
--- a/plugins/emoji/emoji.plugin.zsh
+++ b/plugins/emoji/emoji.plugin.zsh
@@ -76,8 +76,6 @@ emoji_skintone[6]=$'\U1F3FF'
# These are stored in a single associative array, $emoji_groups, to avoid cluttering up the global
# namespace, and to allow adding additional group definitions at run time.
# The keys are the group names, and the values are whitespace-separated lists of emoji character names.
-#
-# These extra local arrays are used to allow more convenient formatting of the source code.
emoji_groups[fruits]="
tomato
@@ -255,9 +253,10 @@ function random_emoji() {
if [[ -z "$group" || "$group" == "all" ]]; then
names=(${(k)emoji})
else
- names=(${=emoji_groups[$group_name]})
+ names=(${=emoji_groups[$group]})
fi
- local list_size=$#names
+ local list_size=${#names}
+ [[ $list_size -eq 0 ]] && return 1
local random_index=$(( ( RANDOM % $list_size ) + 1 ))
local name=${names[$random_index]}
echo ${emoji[$name]}
diff --git a/plugins/emoji/update_emoji.pl b/plugins/emoji/update_emoji.pl
index d90c6e316..04f3ce8e7 100644
--- a/plugins/emoji/update_emoji.pl
+++ b/plugins/emoji/update_emoji.pl
@@ -88,7 +88,7 @@ typeset -gAH emoji_mod
}
# Modifiers are included in both the main set and their separate map,
# because they have a standalone representation as a color swatch.
- if ( $modifier_status == "modifier" ) {
+ if ( $modifier_status eq "modifier" ) {
$outfh->print("emoji_mod[$omz_name]=\$'$zsh_code'\n");
}
} else {
diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
index 801d450f3..d0bc5589f 100644
--- a/plugins/frontend-search/README.md
+++ b/plugins/frontend-search/README.md
@@ -1,74 +1,60 @@
-## Rationale ##
+## Introduction ##
-> Searches for your Frontend contents more easier
+> Searches for your frontend web development made easier
-## Instalation ##
+## Installation ##
+Open your `~/.zshrc` file and enable the `frontend-search` plugin:
-Open your `.zshrc` file and load `frontend-search` plugin
+```zsh
+
+plugins=( ... frontend-search)
-```bash
-...
-plugins=( <your-plugins-list>... frontend-search)
-...
```
-## Commands ##
-
-All command searches are accept only in format
-
-* `frontend <search-content> <search-term>`
-
-The search content are
-
-* `jquery <api.jquery.com>`
-* `mdn <developer.mozilla.org>`
-* `compass <compass-style.org>`
-* `html5please <html5please.com>`
-* `caniuse <caniuse.com>`
-* `aurajs <aurajs.com>`
-* `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>`
-* `lodash <search>`
-* `qunit <api.qunitjs.com>`
-* `fontello <fontello.com>`
-* `bootsnipp <bootsnipp.com>`
-* `cssflow <cssflow.com>`
-* `codepen <codepen.io>`
-* `unheap <www.unheap.com>`
-* `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>`
-* `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>`
-* `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>`
-* `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>`
-* `emberjs <emberjs.com>`
-* `stackoverflow <stackoverflow.com>`
-
-
-## Aliases ##
-
-There are a few aliases presented as well:
-
-* `jquery` A shorthand for `frontend jquery`
-* `mdn` A shorthand for `frontend mdn`
-* `compass` A shorthand for `frontend compass`
-* `html5please` A shorthand for `frontend html5please`
-* `caniuse` A shorthand for `frontend caniuse`
-* `aurajs` A shorthand for `frontend aurajs`
-* `dartlang` A shorthand for `frontend dartlang`
-* `lodash` A shorthand for `frontend lodash`
-* `qunit` A shorthand for `frontend qunit`
-* `fontello` A shorthand for `frontend fontello`
-* `bootsnipp` A shorthand for `frontend bootsnipp`
-* `cssflow` A shorthand for `frontend cssflow`
-* `codepen` A shorthand for `frontend codepen`
-* `unheap` A shorthand for `frontend unheap`
-* `bem` A shorthand for `frontend bem`
-* `smacss` A shorthand for `frontend smacss`
-* `angularjs` A shorthand for `frontend angularjs`
-* `reactjs` A shorthand for `frontend reactjs`
-* `emberjs` A shorthand for `frontend emberjs`
-* `stackoverflow` A shorthand for `frontend stackoverflow`
+## Usage ##
+
+You can use the frontend-search plugin in these two forms:
+
+* `frontend <context> <term> [more terms if you want]`
+* `<context> <term> [more terms if you want]`
+
+For example, these two are equivalent:
+
+```zsh
+$ frontend angularjs dependency injection
+$ angularjs dependency injection
+```
+
+Available search contexts are:
+
+| context | URL |
+|---------------|--------------------------------------------------------------------------|
+| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
+| aurajs | `http://aurajs.com/api/#stq=` |
+| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` |
+| bootsnipp | `http://bootsnipp.com/search?q=` |
+| caniuse | `http://caniuse.com/#search=` |
+| codepen | `http://codepen.io/search?q=` |
+| compass | `http://compass-style.org/search?q=` |
+| cssflow | `http://www.cssflow.com/search?q=` |
+| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` |
+| emberjs | `http://emberjs.com/api/#stp=1&stq=` |
+| fontello | `http://fontello.com/#search=` |
+| html5please | `http://html5please.com/#` |
+| jquery | `https://api.jquery.com/?s=` |
+| lodash | `https://devdocs.io/lodash/index#` |
+| mdn | `https://developer.mozilla.org/search?q=` |
+| npmjs | `https://www.npmjs.com/search?q=` |
+| qunit | `https://api.qunitjs.com/?s=` |
+| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
+| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
+| stackoverflow | `http://stackoverflow.com/search?q=` |
+| unheap | `http://www.unheap.com/?s=` |
+
+If you want to have another context, open an Issue and tell us!
## Author
@@ -77,5 +63,3 @@ There are a few aliases presented as well:
+ <https://plus.google.com/+WilsonMendes>
+ <https://twitter.com/willmendesneto>
+ <http://github.com/willmendesneto>
-
-New features comming soon.
diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh
index 252f21570..b12f829a1 100644
--- a/plugins/frontend-search/_frontend-search.sh
+++ b/plugins/frontend-search/_frontend-search.sh
@@ -37,6 +37,7 @@ function _frontend() {
'reactjs: Search in React website'
'emberjs: Search in Ember website'
'stackoverflow: Search in StackOverflow website'
+ 'npmjs: Search in NPMJS website'
)
_arguments -C \
@@ -110,6 +111,9 @@ function _frontend() {
stackoverflow)
_describe -t points "Warp points" frontend_points && ret=0
;;
+ npmjs)
+ _describe -t points "Warp points" frontend_points && ret=0
+ ;;
esac
;;
esac
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index f7485621b..2fd5416b3 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -1,150 +1,91 @@
-# frontend from terminal
+alias angularjs='frontend angularjs'
+alias aurajs='frontend aurajs'
+alias bem='frontend bem'
+alias bootsnipp='frontend bootsnipp'
+alias caniuse='frontend caniuse'
+alias codepen='frontend codepen'
+alias compass='frontend compass'
+alias cssflow='frontend cssflow'
+alias dartlang='frontend dartlang'
+alias emberjs='frontend emberjs'
+alias fontello='frontend fontello'
+alias html5please='frontend html5please'
+alias jquery='frontend jquery'
+alias lodash='frontend lodash'
+alias mdn='frontend mdn'
+alias npmjs='frontend npmjs'
+alias qunit='frontend qunit'
+alias reactjs='frontend reactjs'
+alias smacss='frontend smacss'
+alias stackoverflow='frontend stackoverflow'
+alias unheap='frontend unheap'
function frontend() {
-
- # no keyword provided, simply show how call methods
- if [[ $# -le 1 ]]; then
- echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
- return 1
+ emulate -L zsh
+
+ # define search context URLS
+ typeset -A urls
+ urls=(
+ angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
+ aurajs 'http://aurajs.com/api/#stq='
+ bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
+ bootsnipp 'http://bootsnipp.com/search?q='
+ caniuse 'http://caniuse.com/#search='
+ codepen 'http://codepen.io/search?q='
+ compass 'http://compass-style.org/search?q='
+ cssflow 'http://www.cssflow.com/search?q='
+ dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
+ emberjs 'http://emberjs.com/api/#stp=1&stq='
+ fontello 'http://fontello.com/#search='
+ html5please 'http://html5please.com/#'
+ jquery 'https://api.jquery.com/?s='
+ lodash 'https://devdocs.io/lodash/index#'
+ mdn 'https://developer.mozilla.org/search?q='
+ npmjs 'https://www.npmjs.com/search?q='
+ qunit 'https://api.qunitjs.com/?s='
+ reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
+ smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
+ stackoverflow 'http://stackoverflow.com/search?q='
+ unheap 'http://www.unheap.com/?s='
+ )
+
+ # show help for command list
+ if [[ $# -lt 2 ]]
+ then
+ print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
+ print -P ""
+ print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
+ print -P "and %Ucontext%u is one of the following:"
+ print -P ""
+ print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow,"
+ print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
+ print -P " qunit, reactjs, smacss, stackoverflow, unheap"
+ print -P ""
+ print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
+ print -P ""
+ return 1
fi
- # check whether the search engine is supported
- if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]];
+ # check whether the search context is supported
+ if [[ -z "$urls[$1]" ]]
then
- echo "Search valid search content $1 not supported."
- echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
- echo "* jquery"
- echo "* mdn"
- echo "* compass"
- echo "* html5please"
- echo "* caniuse"
- echo "* aurajs"
- echo "* dartlang"
- echo "* lodash"
- echo "* qunit"
- echo "* fontello"
- echo "* bootsnipp"
- echo "* cssflow"
- echo "* codepen"
- echo "* unheap"
- echo "* bem"
- echo "* smacss"
- echo "* angularjs"
- echo "* reactjs"
- echo "* emberjs"
- echo "* stackoverflow"
+ echo "Search context \"$1\" currently not supported."
+ echo ""
+ echo "Valid contexts are:"
+ echo ""
+ echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, "
+ echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
+ echo " qunit, reactjs, smacss, stackoverflow, unheap"
echo ""
-
return 1
fi
- local url="http://"
- local query=""
+ # build search url:
+ # join arguments passed with '+', then append to search context URL
+ # TODO substitute for proper urlencode method
+ url="${urls[$1]}${(j:+:)@[2,-1]}"
- case "$1" in
- "jquery")
- url="${url}api.jquery.com"
- url="${url}/?s=$2" ;;
- "mdn")
- url="${url}developer.mozilla.org"
- url="${url}/search?q=$2" ;;
- "compass")
- url="${url}compass-style.org"
- url="${url}/search?q=$2" ;;
- "html5please")
- url="${url}html5please.com"
- url="${url}/#$2" ;;
- "caniuse")
- url="${url}caniuse.com"
- url="${url}/#search=$2" ;;
- "aurajs")
- url="${url}aurajs.com"
- url="${url}/api/#stq=$2" ;;
- "dartlang")
- url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer"
- url="${url}/dart-$2" ;;
- "qunit")
- url="${url}api.qunitjs.com"
- url="${url}/?s=$2" ;;
- "fontello")
- url="${url}fontello.com"
- url="${url}/#search=$2" ;;
- "bootsnipp")
- url="${url}bootsnipp.com"
- url="${url}/search?q=$2" ;;
- "cssflow")
- url="${url}cssflow.com"
- url="${url}/search?q=$2" ;;
- "codepen")
- url="${url}codepen.io"
- url="${url}/search?q=$2" ;;
- "unheap")
- url="${url}www.unheap.com"
- url="${url}/?s=$2" ;;
- "bem")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;;
- "smacss")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;;
- "angularjs")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;;
- "reactjs")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;;
- "emberjs")
- url="${url}emberjs.com"
- url="${url}/api/#stq=$2&stp=1" ;;
- "stackoverflow")
- url="${url}stackoverflow.com"
- url="${url}/search?q=$2" ;;
- *) echo "INVALID PARAM!"
- return ;;
- esac
-
- echo "$url"
+ echo "Opening $url ..."
open_command "$url"
-
}
-
-# javascript
-alias jquery='frontend jquery'
-alias mdn='frontend mdn'
-
-# pre processors frameworks
-alias compassdoc='frontend compass'
-
-# important links
-alias html5please='frontend html5please'
-alias caniuse='frontend caniuse'
-
-# components and libraries
-alias aurajs='frontend aurajs'
-alias dartlang='frontend dartlang'
-alias lodash='frontend lodash'
-
-#tests
-alias qunit='frontend qunit'
-
-#fonts
-alias fontello='frontend fontello'
-
-# snippets
-alias bootsnipp='frontend bootsnipp'
-alias cssflow='frontend cssflow'
-alias codepen='frontend codepen'
-alias unheap='frontend unheap'
-
-# css architecture
-alias bem='frontend bem'
-alias smacss='frontend smacss'
-
-# frameworks
-alias angularjs='frontend angularjs'
-alias reactjs='frontend reactjs'
-alias emberjs='frontend emberjs'
-
-# search websites
-alias stackoverflow='frontend stackoverflow'
diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh
index 8419166ab..d91c1af81 100644
--- a/plugins/git-extras/git-extras.plugin.zsh
+++ b/plugins/git-extras/git-extras.plugin.zsh
@@ -3,19 +3,20 @@
# Description
# -----------
#
-# Completion script for git-extras (http://github.com/visionmedia/git-extras).
+# Completion script for git-extras (http://github.com/tj/git-extras).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Alexis GRIMALDI (https://github.com/agrimaldi)
+# * spacewander (https://github.com/spacewander)
#
# ------------------------------------------------------------------------------
# Inspirations
# -----------
#
-# * git-extras (http://github.com/visionmedia/git-extras)
+# * git-extras (http://github.com/tj/git-extras)
# * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
#
# ------------------------------------------------------------------------------
@@ -30,10 +31,21 @@ __git_command_successful () {
}
+__git_commits() {
+ declare -A commits
+ git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit
+ do
+ hash=$(echo $commit | cut -d':' -f1)
+ commits[$hash]="$commit"
+ done
+ local ret=1
+ _describe -t commits commit commits && ret=0
+}
+
__git_tag_names() {
local expl
declare -a tag_names
- tag_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
+ tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
__git_command_successful || return
_wanted tag-names expl tag-name compadd $* - $tag_names
}
@@ -47,31 +59,27 @@ __git_branch_names() {
_wanted branch-names expl branch-name compadd $* - $branch_names
}
-
-__git_feature_branch_names() {
+__git_specific_branch_names() {
local expl
declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/})
+ branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
+__git_feature_branch_names() {
+ __git_specific_branch_names 'feature'
+}
+
+
__git_refactor_branch_names() {
- local expl
- declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/})
- __git_command_successful || return
- _wanted branch-names expl branch-name compadd $* - $branch_names
+ __git_specific_branch_names 'refactor'
}
__git_bug_branch_names() {
- local expl
- declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/})
- __git_command_successful || return
- _wanted branch-names expl branch-name compadd $* - $branch_names
+ __git_specific_branch_names 'bug'
}
@@ -92,19 +100,43 @@ __git_author_names() {
_wanted author-names expl author-name compadd $* - $author_names
}
+# subcommands
-_git-changelog() {
- _arguments \
- '(-l --list)'{-l,--list}'[list commits]' \
+_git-bug() {
+ local curcontext=$curcontext state line ret=1
+ declare -A opt_args
+
+ _arguments -C \
+ ': :->command' \
+ '*:: :->option-or-argument' && ret=0
+
+ case $state in
+ (command)
+ declare -a commands
+ commands=(
+ 'finish:merge bug into the current branch'
+ )
+ _describe -t commands command commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*}-$line[1]:
+ case $line[1] in
+ (finish)
+ _arguments -C \
+ ':branch-name:__git_bug_branch_names'
+ ;;
+ esac
+ esac
}
-_git-effort() {
+_git-changelog() {
_arguments \
- '--above[ignore file with less than x commits]' \
+ '(-l --list)'{-l,--list}'[list commits]' \
}
+
_git-contrib() {
_arguments \
':author:__git_author_names'
@@ -135,6 +167,11 @@ _git-delete-tag() {
}
+_git-effort() {
+ _arguments \
+ '--above[ignore file with less than x commits]'
+}
+
_git-extras() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
@@ -154,20 +191,7 @@ _git-extras() {
esac
_arguments \
- '(-v --version)'{-v,--version}'[show current version]' \
-}
-
-
-_git-graft() {
- _arguments \
- ':src-branch-name:__git_branch_names' \
- ':dest-branch-name:__git_branch_names'
-}
-
-
-_git-squash() {
- _arguments \
- ':branch-name:__git_branch_names'
+ '(-v --version)'{-v,--version}'[show current version]'
}
@@ -199,6 +223,25 @@ _git-feature() {
}
+_git-graft() {
+ _arguments \
+ ':src-branch-name:__git_branch_names' \
+ ':dest-branch-name:__git_branch_names'
+}
+
+
+_git-ignore() {
+ _arguments -C \
+ '(--local -l)'{--local,-l}'[show local gitignore]' \
+ '(--global -g)'{--global,-g}'[show global gitignore]'
+}
+
+_git-missing() {
+ _arguments \
+ ':first-branch-name:__git_branch_names' \
+ ':second-branch-name:__git_branch_names'
+}
+
_git-refactor() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
@@ -227,59 +270,62 @@ _git-refactor() {
}
-_git-bug() {
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
-
- _arguments -C \
- ': :->command' \
- '*:: :->option-or-argument' && ret=0
+_git-squash() {
+ _arguments \
+ ':branch-name:__git_branch_names'
+}
- case $state in
- (command)
- declare -a commands
- commands=(
- 'finish:merge bug into the current branch'
- )
- _describe -t commands command commands && ret=0
- ;;
- (option-or-argument)
- curcontext=${curcontext%:*}-$line[1]:
- case $line[1] in
- (finish)
- _arguments -C \
- ':branch-name:__git_bug_branch_names'
- ;;
- esac
- esac
+_git-summary() {
+ _arguments '--line[summarize with lines other than commits]'
+ __git_commits
}
+_git-undo(){
+ _arguments -C \
+ '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
+ '(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
+}
+
zstyle ':completion:*:*:git:*' user-commands \
+ alias:'define, search and show aliases' \
+ archive-file:'export the current HEAD of the git repository to a archive' \
+ back:'undo and stage latest commits' \
+ bug:'create a bug branch' \
changelog:'populate changelog file with commits since the previous tag' \
+ commits-since:'list commits since a given date' \
contrib:'display author contributions' \
count:'count commits' \
+ create-branch:'create local and remote branch' \
delete-branch:'delete local and remote branch' \
+ delete-merged-brancees:'delete merged branches'\
delete-submodule:'delete submodule' \
delete-tag:'delete local and remote tag' \
+ effort:'display effort statistics' \
extras:'git-extras' \
- graft:'merge commits from source branch to destination branch' \
- squash:'merge commits from source branch into the current one as a single commit' \
feature:'create a feature branch' \
- refactor:'create a refactor branch' \
- bug:'create a bug branch' \
- summary:'repository summary' \
- effort:'display effort statistics' \
- repl:'read-eval-print-loop' \
- commits-since:'list commits since a given date' \
- release:'release commit with the given tag' \
- alias:'define, search and show aliases' \
+ fork:'fork a repo on github' \
+ fresh-branch:'create empty local branch' \
+ gh-pages:'create the GitHub Pages branch' \
+ graft:'merge commits from source branch to destination branch' \
ignore:'add patterns to .gitignore' \
info:'show info about the repository' \
- create-branch:'create local and remote branch' \
- fresh-branch:'create empty local branch' \
- undo:'remove the latest commit' \
+ local-commits:'list unpushed commits on the local branch' \
+ lock:'lock a file excluded from version control' \
+ locked:'ls files that have been locked' \
+ missing:'show commits missing from another branch' \
+ pr:'checks out a pull request locally' \
+ rebase-patch:'rebases a patch' \
+ refactor:'create a refactor branch' \
+ release:'commit, tag and push changes to the repository' \
+ rename-tag:'rename a tag' \
+ repl:'read-eval-print-loop' \
+ reset-file:'reset one file' \
+ root:'show path of root' \
setup:'setup a git repository' \
+ show-tree:'show branch tree of commit history' \
+ squash:'merge commits from source branch into the current one as a single commit' \
+ summary:'repository summary' \
touch:'one step creation of new files' \
- obliterate:'Completely remove a file from the repository, including past commits and tags' \
- local-commits:'list unpushed commits on the local branch' \
+ undo:'remove the latest commit' \
+ unlock:'unlock a file excluded from version control'
diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh
index 4357c0895..444440bcb 100644
--- a/plugins/git-flow/git-flow.plugin.zsh
+++ b/plugins/git-flow/git-flow.plugin.zsh
@@ -21,7 +21,7 @@
#
#Alias
-alias gf='git flow'
+alias gfl='git flow'
alias gcd='git checkout develop'
alias gch='git checkout hotfix'
alias gcr='git checkout release'
diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh
index d868a5fe1..5175bf70f 100644
--- a/plugins/git-prompt/git-prompt.plugin.zsh
+++ b/plugins/git-prompt/git-prompt.plugin.zsh
@@ -1,57 +1,92 @@
# ZSH Git Prompt Plugin from:
# http://github.com/olivierverdier/zsh-git-prompt
-#
-export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt
-# Allow for functions in the prompt.
-setopt PROMPT_SUBST
+__GIT_PROMPT_DIR="${0:A:h}"
-## Enable auto-execution of functions.
-typeset -ga preexec_functions
-typeset -ga precmd_functions
-typeset -ga chpwd_functions
-
-# Append git functions needed for prompt.
-preexec_functions+='preexec_update_git_vars'
-precmd_functions+='precmd_update_git_vars'
-chpwd_functions+='chpwd_update_git_vars'
+## Hook function definitions
+function chpwd_update_git_vars() {
+ update_current_git_vars
+}
-## Function definitions
function preexec_update_git_vars() {
case "$2" in
- git*)
+ git*|hub*|gh*|stg*)
__EXECUTED_GIT_COMMAND=1
;;
esac
}
function precmd_update_git_vars() {
- if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
+ if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ]; then
update_current_git_vars
unset __EXECUTED_GIT_COMMAND
fi
}
-function chpwd_update_git_vars() {
- update_current_git_vars
-}
+chpwd_functions+=(chpwd_update_git_vars)
+precmd_functions+=(precmd_update_git_vars)
+preexec_functions+=(preexec_update_git_vars)
+
+## Function definitions
function update_current_git_vars() {
unset __CURRENT_GIT_STATUS
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
- _GIT_STATUS=`python ${gitstatus}`
- __CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}")
+ _GIT_STATUS=$(python ${gitstatus} 2>/dev/null)
+ __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}")
+ GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
+ GIT_AHEAD=$__CURRENT_GIT_STATUS[2]
+ GIT_BEHIND=$__CURRENT_GIT_STATUS[3]
+ GIT_STAGED=$__CURRENT_GIT_STATUS[4]
+ GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5]
+ GIT_CHANGED=$__CURRENT_GIT_STATUS[6]
+ GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7]
}
-function prompt_git_info() {
+git_super_status() {
+ precmd_update_git_vars
if [ -n "$__CURRENT_GIT_STATUS" ]; then
- echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})"
+ STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}"
+ if [ "$GIT_BEHIND" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}"
+ fi
+ if [ "$GIT_AHEAD" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}"
+ fi
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR"
+ if [ "$GIT_STAGED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}"
+ fi
+ if [ "$GIT_CONFLICTS" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}"
+ fi
+ if [ "$GIT_CHANGED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}"
+ fi
+ if [ "$GIT_UNTRACKED" -ne "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}"
+ fi
+ if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then
+ STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
+ fi
+ STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
+ echo "$STATUS"
fi
}
+# Default values for the appearance of the prompt.
+ZSH_THEME_GIT_PROMPT_PREFIX="("
+ZSH_THEME_GIT_PROMPT_SUFFIX=")"
+ZSH_THEME_GIT_PROMPT_SEPARATOR="|"
+ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
+ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}"
+ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}"
+ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}"
+ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}"
+ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}"
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}"
+
# Set the prompt.
-#PROMPT='%B%m%~%b$(prompt_git_info) %# '
-# for a right prompt:
-#RPROMPT='%b$(prompt_git_info)'
-RPROMPT='$(prompt_git_info)'
+RPROMPT='$(git_super_status)'
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index 256841432..a8eb8284b 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -1,82 +1,84 @@
#!/usr/bin/env python
-# -*- coding: UTF-8 -*-
-from subprocess import Popen, PIPE
-import re
+from __future__ import print_function
-# change those symbols to whatever you prefer
-symbols = {
- 'ahead of': '↑',
- 'behind': '↓',
- 'staged': '♦',
- 'changed': '‣',
- 'untracked': '…',
- 'clean': '⚡',
- 'unmerged': '≠',
- 'sha1': ':'
-}
+import sys
+import re
+import shlex
+from subprocess import Popen, PIPE, check_output
-output, error = Popen(
- ['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate()
-if error:
- import sys
- sys.exit(0)
-lines = output.splitlines()
+def get_tagname_or_hash():
+ """return tagname if exists else hash"""
+ cmd = 'git log -1 --format="%h%d"'
+ output = check_output(shlex.split(cmd)).decode('utf-8').strip()
+ hash_, tagname = None, None
+ # get hash
+ m = re.search('\(.*\)$', output)
+ if m:
+ hash_ = output[:m.start()-1]
+ # get tagname
+ m = re.search('tag: .*[,\)]', output)
+ if m:
+ tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
-behead_re = re.compile(
- r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
-diverge_re = re.compile(r"^# and have (\d+) and (\d+) different")
+ if tagname:
+ return tagname
+ elif hash_:
+ return hash_
+ return None
-status = ''
-staged = re.compile(r'^# Changes to be committed:$', re.MULTILINE)
-changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE)
-untracked = re.compile(r'^# Untracked files:$', re.MULTILINE)
-unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE)
+# `git status --porcelain --branch` can collect all information
+# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
+po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE)
+stdout, sterr = po.communicate()
+if po.returncode != 0:
+ sys.exit(0) # Not a git repository
-def execute(*command):
- out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate()
- if not err:
- nb = len(out.splitlines())
+# collect git status information
+untracked, staged, changed, conflicts = [], [], [], []
+ahead, behind = 0, 0
+status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()]
+for st in status:
+ if st[0] == '#' and st[1] == '#':
+ if re.search('Initial commit on', st[2]):
+ branch = st[2].split(' ')[-1]
+ elif re.search('no branch', st[2]): # detached status
+ branch = get_tagname_or_hash()
+ elif len(st[2].strip().split('...')) == 1:
+ branch = st[2].strip()
+ else:
+ # current and remote branch info
+ branch, rest = st[2].strip().split('...')
+ if len(rest.split(' ')) == 1:
+ # remote_branch = rest.split(' ')[0]
+ pass
+ else:
+ # ahead or behind
+ divergence = ' '.join(rest.split(' ')[1:])
+ divergence = divergence.lstrip('[').rstrip(']')
+ for div in divergence.split(', '):
+ if 'ahead' in div:
+ ahead = int(div[len('ahead '):].strip())
+ elif 'behind' in div:
+ behind = int(div[len('behind '):].strip())
+ elif st[0] == '?' and st[1] == '?':
+ untracked.append(st)
else:
- nb = '?'
- return nb
-
-if staged.search(output):
- nb = execute(
- ['git', 'diff', '--staged', '--name-only', '--diff-filter=ACDMRT'])
- status += '%s%s' % (symbols['staged'], nb)
-if unmerged.search(output):
- nb = execute(['git', 'diff', '--staged', '--name-only', '--diff-filter=U'])
- status += '%s%s' % (symbols['unmerged'], nb)
-if changed.search(output):
- nb = execute(['git', 'diff', '--name-only', '--diff-filter=ACDMRT'])
- status += '%s%s' % (symbols['changed'], nb)
-if untracked.search(output):
- status += symbols['untracked']
-if status == '':
- status = symbols['clean']
-
-remote = ''
-
-bline = lines[0]
-if bline.find('Not currently on any branch') != -1:
- branch = symbols['sha1'] + Popen([
- 'git',
- 'rev-parse',
- '--short',
- 'HEAD'], stdout=PIPE).communicate()[0][:-1]
-else:
- branch = bline.split(' ')[-1]
- bstatusline = lines[1]
- match = behead_re.match(bstatusline)
- if match:
- remote = symbols[match.groups()[0]]
- remote += match.groups()[2]
- elif lines[2:]:
- div_match = diverge_re.match(lines[2])
- if div_match:
- remote = "{behind}{1}{ahead of}{0}".format(
- *div_match.groups(), **symbols)
+ if st[1] == 'M':
+ changed.append(st)
+ if st[0] == 'U':
+ conflicts.append(st)
+ elif st[0] != ' ':
+ staged.append(st)
-print('\n'.join([branch, remote, status]))
+out = ' '.join([
+ branch,
+ str(ahead),
+ str(behind),
+ str(len(staged)),
+ str(len(conflicts)),
+ str(len(changed)),
+ str(len(untracked)),
+])
+print(out, end='')
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index cc6eb1031..bbee13ab8 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -68,10 +68,12 @@ alias gc!='git commit -v --amend'
alias gca='git commit -v -a'
alias gca!='git commit -v -a --amend'
alias gcan!='git commit -v -a -s --no-edit --amend'
+alias gcam='git commit -a -m'
alias gcb='git checkout -b'
alias gcf='git config --list'
alias gcl='git clone --recursive'
-alias gclean='git reset --hard && git clean -dfx'
+alias gclean='git clean -fd'
+alias gpristine='git reset --hard && git clean -dfx'
alias gcm='git checkout master'
alias gcmsg='git commit -m'
alias gco='git checkout'
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index e59265d66..de95f7e6c 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -29,7 +29,10 @@ if [[ -x "${commands[gwhoami]}" ]]; then
'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
'gwhoami' 'gyes')
- # Not part of coreutils, installed separately.
+ # findutils
+ gcmds+=('gfind' 'gxargs' 'glocate')
+
+ # Not part of either coreutils or findutils, installed separately.
gcmds+=('gsed' 'gtar' 'gtime')
for gcmd in "${gcmds[@]}"; do
diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
index 6f634d1ba..97941756d 100644
--- a/plugins/gradle/gradle.plugin.zsh
+++ b/plugins/gradle/gradle.plugin.zsh
@@ -82,7 +82,7 @@ _gradlew_tasks () {
if [ in_gradle ]; then
_gradle_arguments
if _gradle_does_task_list_need_generating; then
- gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
+ ./gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
fi
compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache`
fi
diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh
new file mode 100644
index 000000000..6017c7b60
--- /dev/null
+++ b/plugins/gulp/gulp.plugin.zsh
@@ -0,0 +1,29 @@
+#!/usr/bin/env zsh
+
+#
+# gulp-autocompletion-zsh
+#
+# Autocompletion for your gulp.js tasks
+#
+# Copyright(c) 2014 André König <andre.koenig@posteo.de>
+# MIT Licensed
+#
+
+#
+# André König
+# Github: https://github.com/akoenig
+# Twitter: https://twitter.com/caiifr
+#
+
+#
+# Grabs all available tasks from the `gulpfile.js`
+# in the current directory.
+#
+function $$gulp_completion() {
+ compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort)
+
+ completions=(${=compls})
+ compadd -- $completions
+}
+
+compdef $$gulp_completion gulp \ No newline at end of file
diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku
index bb2f7403f..fd72e530e 100644
--- a/plugins/heroku/_heroku
+++ b/plugins/heroku/_heroku
@@ -143,5 +143,6 @@ _arguments \
$_command_args \
'(--app)--app[the app name]' \
'(--remote)--remote[the remote name]' \
+ '(--help)--help[help about the current command]' \
&& return 0
diff --git a/plugins/jira/_jira b/plugins/jira/_jira
new file mode 100644
index 000000000..b0ea658e2
--- /dev/null
+++ b/plugins/jira/_jira
@@ -0,0 +1,21 @@
+#compdef jira
+#autoload
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'new:create a new issue'
+ 'dashboard:open the dashboard'
+ 'reported:search for issues reported by a user'
+ 'assigned:search for issues assigned to a user'
+)
+
+_arguments -C \
+ ':command:->command' \
+ '*::options:->options'
+
+case $state in
+ (command)
+ _describe -t commands "jira subcommand" _1st_arguments
+ return
+ ;;
+esac
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index 9a8932702..89559767f 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -1,90 +1,118 @@
-# To use: add a .jira-url file in the base of your project
-# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
-# .jira-url in the current directory takes precedence
+# CLI support for JIRA interaction
#
-# If you use Rapid Board, set:
-#JIRA_RAPID_BOARD="true"
-# in you .zshrc
+# Setup:
+# Add a .jira-url file in the base of your project
+# You can also set $JIRA_URL in your .zshrc or put .jira-url in your home directory
+# A .jira-url in the current directory takes precedence.
+# The same goes with .jira-prefix and $JIRA_PREFIX.
#
-# Setup: cd to/my/project
-# echo "https://name.jira.com" >> .jira-url
-# Usage: jira # opens a new issue
-# jira ABC-123 # Opens an existing issue
-open_jira_issue () {
- if [ -f .jira-url ]; then
+# For example:
+# cd to/my/project
+# echo "https://name.jira.com" >> .jira-url
+#
+# Variables:
+# $JIRA_RAPID_BOARD - set to "true" if you use Rapid Board
+# $JIRA_DEFAULT_ACTION - action to do when `jira` is called witn no args
+# defaults to "new"
+# $JIRA_NAME - Your JIRA username. Used as default for assigned/reported
+# $JIRA_PREFIX - Prefix added to issue ID arguments
+#
+#
+# Usage:
+# jira # Performs the default action
+# jira new # opens a new issue
+# jira reported [username]
+# jira assigned [username]
+# jira dashboard
+# jira ABC-123 # Opens an existing issue
+# jira ABC-123 m # Opens an existing issue for adding a comment
+
+: ${JIRA_DEFAULT_ACTION:=new}
+
+function jira() {
+ local action=${1:=$JIRA_DEFAULT_ACTION}
+
+ local jira_url jira_prefix
+ if [[ -f .jira-url ]]; then
jira_url=$(cat .jira-url)
- elif [ -f ~/.jira-url ]; then
+ elif [[ -f ~/.jira-url ]]; then
jira_url=$(cat ~/.jira-url)
- elif [[ "x$JIRA_URL" != "x" ]]; then
- jira_url=$JIRA_URL
+ elif [[ -n "${JIRA_URL}" ]]; then
+ jira_url=${JIRA_URL}
else
- echo "JIRA url is not specified anywhere."
+ _jira_url_help
return 1
fi
- if [ -f .jira-prefix ]; then
+ if [[ -f .jira-prefix ]]; then
jira_prefix=$(cat .jira-prefix)
- elif [ -f ~/.jira-prefix ]; then
+ elif [[ -f ~/.jira-prefix ]]; then
jira_prefix=$(cat ~/.jira-prefix)
+ elif [[ -n "${JIRA_PREFIX}" ]]; then
+ jira_prefix=${JIRA_PREFIX}
else
jira_prefix=""
fi
- if [ -z "$1" ]; then
+
+ if [[ $action == "new" ]]; then
echo "Opening new issue"
open_command "${jira_url}/secure/CreateIssue!default.jspa"
- elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then
- jira_query $@
- else
- local addcomment=''
+ elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
+ _jira_query $@
+ elif [[ "$action" == "dashboard" ]]; then
+ echo "Opening dashboard"
+ open_command "${jira_url}/secure/Dashboard.jspa"
+ else
+ # Anything that doesn't match a special action is considered an issue name
+ local issue_arg=$action
+ local issue="${jira_prefix}${issue_arg}"
+ local url_fragment=''
if [[ "$2" == "m" ]]; then
- addcomment="#add-comment"
- echo "Add comment to issue #$1"
+ url_fragment="#add-comment"
+ echo "Add comment to issue #$issue"
else
- echo "Opening issue #$1"
+ echo "Opening issue #$issue"
fi
-
- if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
- open_command "$jira_url/issues/$jira_prefix$1$addcomment"
+ if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
+ open_command "${jira_url}/issues/${issue}${url_fragment}"
else
- open_command "$jira_url/browse/$jira_prefix$1$addcomment"
+ open_command "${jira_url}/browse/${issue}${url_fragment}"
fi
fi
}
-jira_name () {
- if [[ -z "$1" ]]; then
- if [[ "x${JIRA_NAME}" != "x" ]]; then
- jira_name=${JIRA_NAME}
- else
- echo "JIRA_NAME not specified"
- return 1
- fi
+function _jira_url_help() {
+ cat << EOF
+JIRA url is not specified anywhere.
+Valid options, in order of precedence:
+ .jira-url file
+ \$HOME/.jira-url file
+ JIRA_URL environment variable
+EOF
+}
+
+function _jira_query() {
+ local verb="$1"
+ local jira_name lookup preposition query
+ if [[ "${verb}" == "reported" ]]; then
+ lookup=reporter
+ preposition=by
+ elif [[ "${verb}" == "assigned" ]]; then
+ lookup=assignee
+ preposition=to
else
- jira_name=$@
+ echo "not a valid lookup: $verb" >&2
+ return 1
+ fi
+ jira_name=${2:=$JIRA_NAME}
+ if [[ -z $jira_name ]]; then
+ echo "JIRA_NAME not specified" >&2
+ return 1
fi
-}
-jira_query () {
- verb="$1"
- if [[ "${verb}" = "reported" ]]; then
- lookup=reporter
- preposition=by
- elif [[ "${verb}" = "assigned" ]]; then
- lookup=assignee
- preposition=to
- else
- echo "not a valid lookup $verb"
- return 1
- fi
- shift 1
- jira_name $@
- if [[ $? = 1 ]]; then
- return 1
- fi
- echo "Browsing issues ${verb} ${preposition} ${jira_name}"
- open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
+ echo "Browsing issues ${verb} ${preposition} ${jira_name}"
+ query="${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
+ open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${query}"
}
-alias jira='open_jira_issue'
-
diff --git a/plugins/man/man.zsh b/plugins/man/man.zsh
new file mode 100644
index 000000000..3490b0b61
--- /dev/null
+++ b/plugins/man/man.zsh
@@ -0,0 +1,27 @@
+# ------------------------------------------------------------------------------
+# Author
+# ------
+#
+# * Jerry Ling<jerryling315@gmail.com>
+#
+# ------------------------------------------------------------------------------
+# Usgae
+# -----
+#
+# man will be inserted before the command
+#
+# ------------------------------------------------------------------------------
+
+man-command-line() {
+ [[ -z $BUFFER ]] && zle up-history
+ [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER"
+}
+zle -N man-command-line
+# Defined shortcut keys: [Esc]man
+bindkey "\e"man man-command-line
+
+
+# ------------------------------------------------------------------------------
+# Also, you might want to use man-preview included in 'osx' plugin
+# just substitute "man" in the function with "man-preview" after you included OS X in
+# the .zshrc \ No newline at end of file
diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
index 68ec5fabd..595105d3c 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -12,3 +12,6 @@ alias npmS="npm i -S "
# Install and save to dev-dependencies in your package.json
# npmd is used by https://github.com/dominictarr/npmd
alias npmD="npm i -D "
+# Execute command from node_modules folder based on current directory
+# i.e npmE gulp
+alias npmE='PATH="$(npm bin)":"$PATH"'
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index a6e3a83e6..2cbb95977 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -5,29 +5,35 @@
# VERSION: 1.1.0
# ------------------------------------------------------------------------------
-function tab() {
- local command="cd \\\"$PWD\\\"; clear; "
- (( $# > 0 )) && command="${command}; $*"
-
- the_app=$(
+function _omz_osx_get_frontmost_app() {
+ local the_app=$(
osascript 2>/dev/null <<EOF
tell application "System Events"
name of first item of (every process whose frontmost is true)
end tell
EOF
)
+ echo "$the_app"
+}
- [[ "$the_app" == 'Terminal' ]] && {
- osascript 2>/dev/null <<EOF
+function tab() {
+ # Must not have trailing semicolon, for iTerm compatibility
+ local command="cd \\\"$PWD\\\"; clear"
+ (( $# > 0 )) && command="${command}; $*"
+
+ local the_app=$(_omz_osx_get_frontmost_app)
+
+ if [[ "$the_app" == 'Terminal' ]]; then
+ # Discarding stdout to quash "tab N of window id XXX" output
+ osascript >/dev/null <<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
- tell application "Terminal" to do script "${command}" in front window
end tell
+ tell application "Terminal" to do script "${command}" in front window
EOF
- }
- [[ "$the_app" == 'iTerm' ]] && {
- osascript 2>/dev/null <<EOF
+ elif [[ "$the_app" == 'iTerm' ]]; then
+ osascript <<EOF
tell application "iTerm"
set current_terminal to current terminal
tell current_terminal
@@ -35,29 +41,27 @@ EOF
set current_session to current session
tell current_session
write text "${command}"
- keystroke return
end tell
end tell
end tell
EOF
- }
+
+ else
+ echo "tab: unsupported terminal app: $the_app"
+ false
+
+ fi
}
function vsplit_tab() {
- local command="cd \\\"$PWD\\\""
+ local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"
- the_app=$(
- osascript 2>/dev/null <<EOF
- tell application "System Events"
- name of first item of (every process whose frontmost is true)
- end tell
-EOF
- )
+ local the_app=$(_omz_osx_get_frontmost_app)
- [[ "$the_app" == 'iTerm' ]] && {
- osascript 2>/dev/null <<EOF
- tell application "iTerm" to activate
+ if [[ "$the_app" == 'iTerm' ]]; then
+ osascript <<EOF
+ -- tell application "iTerm" to activate
tell application "System Events"
tell process "iTerm"
@@ -65,26 +69,24 @@ EOF
click
end tell
end tell
- keystroke "${command}; clear;"
- keystroke return
+ keystroke "${command} \n"
end tell
EOF
- }
+
+ else
+ echo "$0: unsupported terminal app: $the_app" >&2
+ false
+
+ fi
}
function split_tab() {
- local command="cd \\\"$PWD\\\""
+ local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"
- the_app=$(
- osascript 2>/dev/null <<EOF
- tell application "System Events"
- name of first item of (every process whose frontmost is true)
- end tell
-EOF
- )
+ local the_app=$(_omz_osx_get_frontmost_app)
- [[ "$the_app" == 'iTerm' ]] && {
+ if [[ "$the_app" == 'iTerm' ]]; then
osascript 2>/dev/null <<EOF
tell application "iTerm" to activate
@@ -94,11 +96,15 @@ EOF
click
end tell
end tell
- keystroke "${command}; clear;"
- keystroke return
+ keystroke "${command} \n"
end tell
EOF
- }
+
+ else
+ echo "$0: unsupported terminal app: $the_app" >&2
+ false
+
+ fi
}
function pfd() {
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index 6824836fc..39e388494 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -54,10 +54,12 @@ alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone'
-
alias rlc='rake log:clear'
alias rn='rake notes'
alias rr='rake routes'
+alias rrg='rake routes | grep'
+alias rt='rake test'
+
# legacy stuff
alias sstat='thin --stats "/thin/stats" start'
diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh
index c3bf6234e..8f345d9aa 100644
--- a/plugins/rand-quote/rand-quote.plugin.zsh
+++ b/plugins/rand-quote/rand-quote.plugin.zsh
@@ -18,8 +18,6 @@ if [[ -x `which curl` ]]; then
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
if [ "$W" -a "$TXT" ]; then
echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}"
- else
- quote
fi
}
#quote
diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh
index 213e1beb0..ef5106f2d 100644
--- a/plugins/rbenv/rbenv.plugin.zsh
+++ b/plugins/rbenv/rbenv.plugin.zsh
@@ -2,14 +2,11 @@ _homebrew-installed() {
type brew &> /dev/null
}
-_rbenv-from-homebrew-installed() {
- brew --prefix rbenv &> /dev/null
-}
-
FOUND_RBENV=0
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
-if _homebrew-installed && _rbenv-from-homebrew-installed ; then
- rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}")
+if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then
+ rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}")
+ unset rbenv_homebrew_path
fi
for rbenvdir in "${rbenvdirs[@]}" ; do
diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh
index 234ac1642..53e809aaf 100644
--- a/plugins/rvm/rvm.plugin.zsh
+++ b/plugins/rvm/rvm.plugin.zsh
@@ -61,11 +61,11 @@ function gems {
local current_ruby=`rvm-prompt i v p`
local current_gemset=`rvm-prompt g`
- gem list $@ | sed \
- -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
- -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
- -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
- -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
+ gem list $@ | sed -E \
+ -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
+ -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
+ -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
+ -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
}
function _rvm_completion {
diff --git a/plugins/scw/README.md b/plugins/scw/README.md
new file mode 100644
index 000000000..d2312c2e5
--- /dev/null
+++ b/plugins/scw/README.md
@@ -0,0 +1,7 @@
+## Scaleway CLI autocomplete plugin
+
+[scw](https://github.com/scaleway/scaleway-cli): Manage Bare Metal servers from Command Line (as easily as with Docker)
+
+- Adds autocomplete options for all `scw` commands.
+
+Maintainer : Manfred Touron ([@moul](https://github.com/moul))
diff --git a/plugins/scw/_scw b/plugins/scw/_scw
new file mode 100644
index 000000000..f9fdf916e
--- /dev/null
+++ b/plugins/scw/_scw
@@ -0,0 +1,333 @@
+#compdef scw
+#
+# zsh completion for scw (http://scaleway.com)
+#
+# Inspired by https://github.com/felixr/docker-zsh-completion
+
+__scw_get_servers() {
+ local expl
+ declare -a servers
+ servers=(${(f)"$(_call_program commands scw _completion servers-names)"})
+ _describe -t servers "servers" servers
+}
+
+__scw_stoppedservers() {
+ __scw_get_servers
+}
+
+__scw_runningservers() {
+ __scw_get_servers
+}
+
+__scw_servers () {
+ __scw_get_servers
+}
+
+__scw_images () {
+ local expl
+ declare -a images
+ images=(${(f)"$(_call_program commands scw _completion images-names)"})
+ _describe -t images "images" images
+}
+
+__scw_images_and_snapshots () {
+ __scw_images
+ __scw_snapshots
+}
+
+__scw_snapshots () {
+ local expl
+ declare -a snapshots
+ snapshots=(${(f)"$(_call_program commands scw _completion --prefix snapshots-names)"})
+ _describe -t snapshots "snapshots" snapshots
+}
+
+__scw_bootscripts () {
+ local expl
+ declare -a bootscripts
+ bootscripts=(${(f)"$(_call_program commands scw _completion bootscripts-names)"})
+ _describe -t bootscripts "bootscripts" bootscripts
+}
+
+__scw_tags() {
+ __scw_images
+}
+
+__scw_repositories_with_tags() {
+ __scw_images
+}
+
+__scw_search() {
+ # declare -a scwsearch
+ local cache_policy
+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+ if [[ -z "$cache_policy" ]]; then
+ zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
+ fi
+
+ local searchterm cachename
+ searchterm="${words[$CURRENT]%/}"
+ cachename=_scw-search-$searchterm
+
+ local expl
+ local -a result
+ if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
+ && ! _retrieve_cache ${cachename#_}; then
+ _message "Searching for ${searchterm}..."
+ result=(${${${(f)"$(_call_program commands scw search ${searchterm})"}%% *}[2,-1]})
+ _store_cache ${cachename#_} result
+ fi
+ _wanted scwsearch expl 'available images' compadd -a result
+}
+
+__scw_caching_policy()
+{
+ oldp=( "$1"(Nmh+1) ) # 1 hour
+ (( $#oldp ))
+}
+
+
+__scw_repositories () {
+ __scw_images
+}
+
+__scw_commands () {
+ # local -a _scw_subcommands
+ local cache_policy
+
+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+ if [[ -z "$cache_policy" ]]; then
+ zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
+ fi
+
+ if ( [[ ${+_scw_subcommands} -eq 0 ]] || _cache_invalid scw_subcommands) \
+ && ! _retrieve_cache scw_subcommands;
+ then
+ local -a lines
+ lines=(${(f)"$(_call_program commands scw 2>&1)"})
+ _scw_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
+ _scw_subcommands=($_scw_subcommands 'help:Show help for a command')
+ _store_cache scw_subcommands _scw_subcommands
+ fi
+ _describe -t scw-commands "scw command" _scw_subcommands
+}
+
+__scw_subcommand () {
+ local -a _command_args
+ case "$words[1]" in
+ (attach)
+ _arguments \
+ '--no-stdin[Do not attach stdin]' \
+ ':servers:__scw_runningservers'
+ ;;
+ (commit)
+ _arguments \
+ {-v,--volume=0}'[Volume slot]:volume: ' \
+ ':server:__scw_servers' \
+ ':repository:__scw_repositories_with_tags'
+ ;;
+ (cp)
+ _arguments \
+ ':server:->server' \
+ ':hostpath:_files'
+ case $state in
+ (server)
+ if compset -P '*:'; then
+ _files
+ else
+ __scw_servers -qS ":"
+ fi
+ ;;
+ esac
+ ;;
+ (exec)
+ local state ret
+ _arguments \
+ {-T,--timeout=0}'[Set timeout values to seconds]' \
+ {-w,--wait}'[Wait for SSH to be ready]' \
+ ':servers:__scw_runningservers' \
+ '*::command:->anycommand' && ret=0
+
+ case $state in
+ (anycommand)
+ shift 1 words
+ (( CURRENT-- ))
+ _normal
+ ;;
+ esac
+
+ return ret
+ ;;
+ (history)
+ _arguments \
+ '--no-trunc[Do not truncate output]' \
+ {-q,--quiet}'[Only show numeric IDs]' \
+ '*:images:__scw_images'
+ ;;
+ (images)
+ _arguments \
+ {-a,--all}'[Show all images]' \
+ '--no-trunc[Do not truncate output]' \
+ {-q,--quiet}'[Only show numeric IDs]' \
+ ':repository:__scw_repositories'
+ ;;
+ (info)
+ ;;
+ (inspect)
+ _arguments \
+ {-f,--format=-}'[Format the output using the given go template]:template: ' \
+ '*:servers:__scw_servers'
+ ;;
+ (kill)
+ _arguments \
+ '*:servers:__scw_runningservers'
+ ;;
+ (login)
+ _arguments \
+ {-o,--organization=-}'[Organization]:organization: ' \
+ {-t,--token=-}'[Token]:token: ' \
+ ':server: '
+ ;;
+ (logout)
+ _arguments \
+ ':server: '
+ ;;
+ (logs)
+ _arguments \
+ '*:servers:__scw_servers'
+ ;;
+ (port)
+ _arguments \
+ '1:servers:__scw_runningservers' \
+ '2:port:_ports'
+ ;;
+ (start)
+ _arguments \
+ {-T,--timeout=0}'[Set timeout values to seconds]' \
+ {-w,--wait}'[Wait for SSH to be ready]' \
+ '*:servers:__scw_stoppedservers'
+ ;;
+ (rm)
+ _arguments \
+ '*:servers:__scw_stoppedservers'
+ ;;
+ (rmi)
+ _arguments \
+ '*:images:__scw_images'
+ ;;
+ (restart)
+ _arguments \
+ '*:servers:__scw_runningservers'
+ ;;
+ (stop)
+ _arguments \
+ {-t,--terminate}'[Stop and trash a server with its volumes]' \
+ {-w,--wait}'[Synchronous stop. Wait for server to be stopped]' \
+ '*:servers:__scw_runningservers'
+ ;;
+ (top)
+ _arguments \
+ '1:servers:__scw_runningservers' \
+ '(-)*:: :->ps-arguments'
+ case $state in
+ (ps-arguments)
+ _ps
+ ;;
+ esac
+ ;;
+ (ps)
+ _arguments \
+ {-a,--all}'[Show all servers. Only running servers are shown by default]' \
+ {-l,--latest}'[Show only the latest created server]' \
+ '-n[Show n last created servers, include non-running one]:n:(1 5 10 25 50)' \
+ '--no-trunc[Do not truncate output]' \
+ {-q,--quiet}'[Only show numeric IDs]'
+ ;;
+ (tag)
+ _arguments \
+ {-f,--force}'[force]'\
+ ':image:__scw_images'\
+ ':repository:__scw_repositories_with_tags'
+ ;;
+ (create|run)
+ _arguments \
+ {-a,--attach}'[Attach to stdin, stdout or stderr]' \
+ '*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \
+ '--name=-[Server name]:name: ' \
+ '--bootscript=-[Assign a bootscript]:bootscript:__scw_bootscripts ' \
+ '*-v[Bind mount a volume]:volume: '\
+ '(-):images:__scw_images_and_snapshots' \
+ '(-):command: _command_names -e' \
+ '*::arguments: _normal'
+
+ case $state in
+ (link)
+ if compset -P '*:'; then
+ _wanted alias expl 'Alias' compadd -E ""
+ else
+ __scw_runningservers -qS ":"
+ fi
+ ;;
+ esac
+ ;;
+ (rename)
+ _arguments \
+ ':old name:__scw_servers' \
+ ':new name: '
+ ;;
+ (search)
+ _arguments \
+ '--no-trunc[Do not truncate output]' \
+ ':term: '
+ ;;
+ (wait)
+ _arguments '*:servers:__scw_runningservers'
+ ;;
+ (help)
+ _arguments ':subcommand:__scw_commands'
+ ;;
+ (*)
+ _message 'Unknown sub command'
+ esac
+
+}
+
+_scw () {
+ # Support for subservices, which allows for `compdef _scw scw-shell=_scw_servers`.
+ # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
+ if [[ $service != scw ]]; then
+ _call_function - _$service
+ return
+ fi
+
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ _arguments -C \
+ '-H[tcp://host:port to bind/connect to]:socket: ' \
+ '(-): :->command' \
+ '(-)*:: :->option-or-argument'
+
+ if (( CURRENT == 1 )); then
+
+ fi
+ case $state in
+ (command)
+ __scw_commands
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:scw-$words[1]:
+ __scw_subcommand
+ ;;
+ esac
+}
+
+_scw "$@"
+
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 4
+# indent-tabs-mode: nil
+# sh-basic-offset: 4
+# End:
+# vim: ft=zsh sw=4 ts=4 et
diff --git a/plugins/spring/README.md b/plugins/spring/README.md
new file mode 100644
index 000000000..62bfd8013
--- /dev/null
+++ b/plugins/spring/README.md
@@ -0,0 +1,25 @@
+# Spring Boot oh-my-zsh plugin
+oh-my-zsh Spring Boot plugin
+
+## Spring Boot autocomplete plugin
+
+- Adds autocomplete options for all spring boot commands.
+
+## Manual Install
+
+ $ cd ~/.oh-my-zsh/plugins
+ $ git clone git@github.com:linux-china/oh-my-zsh-spring-boot-plugin.git spring
+
+Adjust your .zshrc file and add spring to plugins=(...)
+
+## Tips
+
+* Install Spring Cloud plugin: spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE
+
+## Reference
+
+* Spring Boot: http://projects.spring.io/spring-boot/
+* Spring Boot CLI: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#cli
+
+Maintainer : linux_china ([@linux_china](https://twitter.com/linux_china))
+
diff --git a/plugins/spring/_spring b/plugins/spring/_spring
new file mode 100644
index 000000000..93f19517d
--- /dev/null
+++ b/plugins/spring/_spring
@@ -0,0 +1,29 @@
+#compdef spring 'spring'
+#autoload
+
+_spring() {
+
+ local cword
+ let cword=CURRENT-1
+
+ local hints
+ hints=()
+
+ local reply
+ while read -r line; do
+ reply=`echo "$line" | awk '{printf $1 ":"; for (i=2; i<NF; i++) printf $i " "; print $NF}'`
+ hints+=("$reply")
+ done < <(spring hint ${cword} ${words[*]})
+
+ if ((cword == 1)) {
+ _describe -t commands 'commands' hints
+ return 0
+ }
+
+ _describe -t options 'options' hints
+ _files
+
+ return 0
+}
+
+_spring "$@" \ No newline at end of file
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index e3ba39918..0ba8bed5b 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -14,7 +14,11 @@
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
- [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
+ if [[ $BUFFER == sudo\ * ]]; then
+ LBUFFER="${LBUFFER#sudo }"
+ else
+ LBUFFER="sudo $LBUFFER"
+ fi
}
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
index 9f7a4c6eb..816055afe 100644
--- a/plugins/svn/svn.plugin.zsh
+++ b/plugins/svn/svn.plugin.zsh
@@ -1,16 +1,17 @@
# vim:ft=zsh ts=2 sw=2 sts=2
#
function svn_prompt_info() {
+ local _DISPLAY
if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name)
else
_DISPLAY=$(svn_get_repo_name)
+ _DISPLAY=$(omz_urldecode "${_DISPLAY}")
fi
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
- unset _DISPLAY
fi
}
@@ -30,7 +31,7 @@ function svn_get_repo_name() {
}
function svn_get_branch_name() {
- _DISPLAY=$(
+ local _DISPLAY=$(
svn info 2> /dev/null | \
awk -F/ \
'/^URL:/ { \
@@ -49,7 +50,6 @@ function svn_get_branch_name() {
else
echo $_DISPLAY
fi
- unset _DISPLAY
}
function svn_get_rev_nr() {
@@ -60,7 +60,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() {
if in_svn; then
- root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
+ local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
@@ -77,7 +77,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () {
if in_svn; then
- root=$PWD
+ local root=$PWD
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh
index e94280ed0..98a2321db 100644
--- a/plugins/symfony2/symfony2.plugin.zsh
+++ b/plugins/symfony2/symfony2.plugin.zsh
@@ -5,7 +5,7 @@ _symfony_console () {
}
_symfony2_get_command_list () {
- `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }'
+ `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[^ ]+ / { print $1 }'
}
_symfony2 () {
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index 4ae70dfa7..8c2633355 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -140,12 +140,16 @@ d0() {
# gather external ip address
geteip() {
- curl http://ifconfig.me
+ curl -s -S https://icanhazip.com
}
# determine local IP address
getip() {
- ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
+ if (( ${+commands[ip]} )); then
+ ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}'
+ else
+ ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
+ fi
}
# Clear zombie processes
diff --git a/plugins/taskwarrior/README.md b/plugins/taskwarrior/README.md
new file mode 100644
index 000000000..053151e78
--- /dev/null
+++ b/plugins/taskwarrior/README.md
@@ -0,0 +1,13 @@
+# taskwarrior
+
+This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/).
+It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
+completion definitions.
+
+The latest version pulled in from the official project is of January 1st, 2015.
+
+
+## Examples
+
+Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a
+list of available modifications for that task, etcetera.
diff --git a/plugins/taskwarrior/_task b/plugins/taskwarrior/_task
index 5cc253152..afa30d45a 100644
--- a/plugins/taskwarrior/_task
+++ b/plugins/taskwarrior/_task
@@ -1,9 +1,6 @@
#compdef task
-# zsh completion for taskwarrior
#
-# taskwarrior - a command line task list manager.
-#
-# Copyright 2010 - 2011 Johannes Schlatow
+# Copyright 2010 - 2015 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -30,31 +27,40 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects))
_task_tags=($(task _tags))
_task_ids=($(task _ids))
+_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_columns=($(task _columns))
_task_modifiers=(
- 'before' \
- 'after' \
- 'none' \
- 'any' \
- 'is' \
- 'isnt' \
- 'has' \
- 'hasnt' \
- 'startswith' \
- 'endswith' \
- 'word' \
- 'noword'
+ 'before' \
+ 'after' \
+ 'none' \
+ 'any' \
+ 'is' \
+ 'isnt' \
+ 'has' \
+ 'hasnt' \
+ 'startswith' \
+ 'endswith' \
+ 'word' \
+ 'noword'
)
_task_conjunctions=(
- 'and' \
- 'or' \
- 'xor' \
- '\)'
- '\('
+ 'and' \
+ 'or' \
+ 'xor' \
+ '\)' \
+ '\(' \
+ '<' \
+ '<=' \
+ '=' \
+ '!=' \
+ '>=' \
+ '>'
)
-_task_cmds=($(task _commands))
-_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
+_task_cmds=($(task _commands; task _aliases))
+_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel )
+
+_task_aliases=($(task _aliases))
_task() {
_arguments -s -S \
@@ -68,110 +74,130 @@ word=$'[^\0]#\0'
# priorities
local -a task_priorities
_regex_words values 'task priorities' \
- 'H:High' \
- 'M:Middle' \
- 'L:Low'
+ 'H:High' \
+ 'M:Middle' \
+ 'L:Low'
task_priorities=("$reply[@]")
# projects
local -a task_projects
task_projects=(
- /"$word"/
- ":values:task projects:compadd -a _task_projects"
+ /"$word"/
+ ":values:task projects:compadd -a _task_projects"
)
local -a _task_dates
_regex_words values 'task dates' \
- 'tod*ay:Today' \
- 'yes*terday:Yesterday' \
- 'tom*orrow:Tomorrow' \
- 'sow:Start of week' \
- 'soww:Start of work week' \
- 'socw:Start of calendar week' \
- 'som:Start of month' \
- 'soy:Start of year' \
- 'eow:End of week' \
- 'eoww:End of work week' \
- 'eocw:End of calendar week' \
- 'eom:End of month' \
- 'eoy:End of year' \
- 'mon:Monday' \
- 'tue:Tuesday'\
- 'wed:Wednesday' \
- 'thu:Thursday' \
- 'fri:Friday' \
- 'sat:Saturday' \
- 'sun:Sunday'
+ 'tod*ay:Today' \
+ 'yes*terday:Yesterday' \
+ 'tom*orrow:Tomorrow' \
+ 'sow:Start of week' \
+ 'soww:Start of work week' \
+ 'socw:Start of calendar week' \
+ 'som:Start of month' \
+ 'soq:Start of quarter' \
+ 'soy:Start of year' \
+ 'eow:End of week' \
+ 'eoww:End of work week' \
+ 'eocw:End of calendar week' \
+ 'eom:End of month' \
+ 'eoq:End of quarter' \
+ 'eoy:End of year' \
+ 'mon:Monday' \
+ 'tue:Tuesday'\
+ 'wed:Wednesday' \
+ 'thu:Thursday' \
+ 'fri:Friday' \
+ 'sat:Saturday' \
+ 'sun:Sunday' \
+ 'good*friday:Good Friday' \
+ 'easter:Easter' \
+ 'eastermonday:Easter Monday' \
+ 'ascension:Ascension' \
+ 'pentecost:Pentecost' \
+ 'midsommar:Midsommar' \
+ 'midsommarafton:Midsommarafton' \
+ 'later:Later' \
+ 'someday:Some Day'
_task_dates=("$reply[@]")
local -a _task_reldates
_regex_words values 'task reldates' \
- 'hrs:n hours' \
- 'day:n days' \
- '1st:first' \
- '2nd:second' \
- '3rd:third' \
- 'th:4th, 5th, etc.' \
- 'wks:weeks'
+ 'hrs:n hours' \
+ 'day:n days' \
+ '1st:first' \
+ '2nd:second' \
+ '3rd:third' \
+ 'th:4th, 5th, etc.' \
+ 'wks:weeks'
_task_reldates=("$reply[@]")
task_dates=(
- \( "$_task_dates[@]" \|
+ \( "$_task_dates[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \)
- \)
+ \)
)
+local -a task_zshids
+_regex_words values 'task IDs' $_task_zshids
+task_zshids=("$reply[@]")
+
_regex_words values 'task frequencies' \
- 'daily:Every day' \
- 'day:Every day' \
- 'weekdays:Every day skipping weekend days' \
- 'weekly:Every week' \
- 'biweekly:Every two weeks' \
- 'fortnight:Every two weeks' \
-+ 'monthly:Every month' \
- 'quarterly:Every three months' \
- 'semiannual:Every six months' \
- 'annual:Every year' \
- 'yearly:Every year' \
- 'biannual:Every two years' \
- 'biyearly:Every two years'
+ 'daily:Every day' \
+ 'day:Every day' \
+ 'weekdays:Every day skipping weekend days' \
+ 'weekly:Every week' \
+ 'biweekly:Every two weeks' \
+ 'fortnight:Every two weeks' \
+ 'monthly:Every month' \
+ 'quarterly:Every three months' \
+ 'semiannual:Every six months' \
+ 'annual:Every year' \
+ 'yearly:Every year' \
+ 'biannual:Every two years' \
+ 'biyearly:Every two years'
_task_freqs=("$reply[@]")
local -a _task_frequencies
_regex_words values 'task frequencies' \
- 'd:days' \
- 'w:weeks' \
- 'q:quarters' \
- 'y:years'
+ 'd:days' \
+ 'w:weeks' \
+ 'q:quarters' \
+ 'y:years'
_task_frequencies=("$reply[@]")
task_freqs=(
- \( "$_task_freqs[@]" \|
+ \( "$_task_freqs[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \)
- \)
+ \)
)
# attributes
local -a task_attributes
_regex_words -t ':' default 'task attributes' \
- 'pro*ject:Project name:$task_projects' \
- 'du*e:Due date:$task_dates' \
- 'wa*it:Date until task becomes pending:$task_dates' \
- 're*cur:Recurrence frequency:$task_freqs' \
- 'pri*ority:priority:$task_priorities' \
- 'un*til:Recurrence end date:$task_dates' \
- 'fg:Foreground color' \
- 'bg:Background color' \
- 'li*mit:Desired number of rows in report'
+ 'des*cription:Task description text' \
+ 'status:Status of task - pending, completed, deleted, waiting' \
+ 'pro*ject:Project name:$task_projects' \
+ 'pri*ority:priority:$task_priorities' \
+ 'du*e:Due date:$task_dates' \
+ 're*cur:Recurrence frequency:$task_freqs' \
+ 'un*til:Expiration date:$task_dates' \
+ 'li*mit:Desired number of rows in report' \
+ 'wa*it:Date until task becomes pending:$task_dates' \
+ 'ent*ry:Date task was created:$task_dates' \
+ 'end:Date task was completed/deleted:$task_dates' \
+ 'st*art:Date task was started:$task_dates' \
+ 'sc*heduled:Date task is scheduled to start:$task_dates' \
+ 'dep*ends:Other tasks that this task depends upon:$task_zshids'
task_attributes=("$reply[@]")
args=(
- \( "$task_attributes[@]" \|
- \( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
- \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
- \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
- \( /"$word"/ \)
- \) \#
+ \( "$task_attributes[@]" \|
+ \( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
+ \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
+ \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
+ \( /"$word"/ \)
+ \) \#
)
_regex_arguments _task_attributes "${args[@]}"
@@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}"
# filter completion
(( $+functions[_task_filter] )) ||
_task_filter() {
- _task_attributes "$@"
-
- # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
- _describe -t default 'task conjunctions' _task_conjunctions
-}
-
-# merge completion
-(( $+functions[_task_merge] )) ||
-_task_merge() {
- # TODO match URIs in .taskrc
- _files
-}
-
-# push completion
-(( $+functions[_task_push] )) ||
-_task_push() {
- # TODO match URIs in .taskrc
- _files
-}
+ _task_attributes "$@"
-# pull completion
-(( $+functions[_task_pull] )) ||
-_task_pull() {
- # TODO match URIs in .taskrc
- _files
+ # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
+ _describe -t default 'task conjunctions' _task_conjunctions
}
# execute completion
(( $+functions[_task_execute] )) ||
_task_execute() {
- _files
+ _files
}
# id-only completion
(( $+functions[_task_id] )) ||
_task_id() {
- _describe -t values 'task IDs' _task_zshids
+ _describe -t values 'task IDs' _task_zshids
+}
+
+# subcommand-only function
+(( $+functions[_task_subcommands] )) ||
+_task_subcommands() {
+ local -a subcommands
+ local _zshcmd
+ local cmd category desc
+ local lastcategory=''
+ # The list is sorted by category, in the right order.
+ for _zshcmd in "$_task_zshcmds[@]"; do
+ # Parse out the three fields
+ cmd=${_zshcmd%%:*}
+ category=${${_zshcmd#*:}%%:*}
+ desc=${_zshcmd#*:*:}
+
+ # Present each category as soon as the first entry in the *next* category
+ # is seen.
+ if [[ $category != $lastcategory && -n $lastcategory ]]; then
+ _describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands
+ subcommands=()
+ fi
+
+ # Log the subcommand; we will process it in some future iteration.
+ subcommands+=( "$cmd:$desc" )
+
+ lastcategory=$category
+ done
}
## first level completion => task sub-command completion
@@ -224,27 +257,28 @@ _task_id() {
_task_default() {
local cmd ret=1
- integer i=1
- while (( i < $#words ))
- do
- cmd="${_task_cmds[(r)$words[$i]]}"
- if (( $#cmd )); then
- _call_function ret _task_${cmd} ||
- _call_function ret _task_filter ||
- _message "No command remaining."
- return ret
- fi
- (( i++ ))
- done
-
- # update IDs
- _task_zshids=( ${(f)"$(task _zshids)"} )
-
- _describe -t commands 'task command' _task_zshcmds
- _describe -t values 'task IDs' _task_zshids
- _call_function ret _task_filter
-
- return ret
+ integer i=1
+ while (( i < $#words ))
+ do
+ cmd="${_task_cmds[(r)$words[$i]]}"
+ if (( $#cmd )); then
+ _call_function ret _task_${cmd} ||
+ _call_function ret _task_filter ||
+ _message "No command remaining."
+ return ret
+ fi
+ (( i++ ))
+ done
+
+ # update IDs
+ _task_zshids=( ${(f)"$(task _zshids)"} )
+
+ _task_subcommands
+ _describe -t tasks 'task IDs' _task_zshids
+ _describe -t aliases 'task aliases' _task_aliases
+ _call_function ret _task_filter
+
+ return ret
}
-_task
+_task "$@"
diff --git a/plugins/taskwarrior/taskwarrior.plugin.zsh b/plugins/taskwarrior/taskwarrior.plugin.zsh
index 5d1e6ffea..ab885943f 100644
--- a/plugins/taskwarrior/taskwarrior.plugin.zsh
+++ b/plugins/taskwarrior/taskwarrior.plugin.zsh
@@ -1,17 +1,3 @@
-################################################################################
-# Author: Pete Clark
-# Email: pete[dot]clark[at]gmail[dot]com
-# Version: 0.1 (05/24/2011)
-# License: WTFPL<http://sam.zoy.org/wtfpl/>
-#
-# This oh-my-zsh plugin adds smart tab completion for
-# TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
-# script (_task) distributed with TaskWarrior for the completion definitions.
-#
-# Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
-# gives a list of available modifications for that task, etc.
-################################################################################
-
zstyle ':completion:*:*:task:*' verbose yes
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh
index 6e47ee188..7c0c278b9 100644
--- a/plugins/terminalapp/terminalapp.plugin.zsh
+++ b/plugins/terminalapp/terminalapp.plugin.zsh
@@ -1,39 +1,6 @@
-# Set Apple Terminal.app resume directory
-# based on this answer: http://superuser.com/a/315029
-# 2012-10-26: (javageek) Changed code using the updated answer
-
-# Tell the terminal about the working directory whenever it changes.
-if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
- update_terminal_cwd() {
- # Identify the directory using a "file:" scheme URL, including
- # the host name to disambiguate local vs. remote paths.
-
- # Percent-encode the pathname.
- local URL_PATH=''
- {
- # Use LANG=C to process text byte-by-byte.
- local i ch hexch LANG=C
- for ((i = 1; i <= ${#PWD}; ++i)); do
- ch="$PWD[i]"
- if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
- URL_PATH+="$ch"
- else
- hexch=$(printf "%02X" "'$ch")
- URL_PATH+="%$hexch"
- fi
- done
- }
-
- local PWD_URL="file://$HOST$URL_PATH"
- #echo "$PWD_URL" # testing
- printf '\e]7;%s\a' "$PWD_URL"
- }
-
- # Register the function so it is called whenever the working
- # directory changes.
- autoload add-zsh-hook
- add-zsh-hook precmd update_terminal_cwd
-
- # Tell the terminal about the initial directory.
- update_terminal_cwd
-fi
+# This file is intentionally empty.
+#
+# The terminalapp plugin is deprecated and may be removed in a future release.
+# Its functionality has been folded in to the core lib/termsupport.zsh, which
+# is loaded for all users. You can remove terminalapp from your $plugins list
+# once all your systems are updated to the current version of Oh My Zsh.
diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
new file mode 100644
index 000000000..a9b7550d7
--- /dev/null
+++ b/plugins/thefuck/README.md
@@ -0,0 +1,9 @@
+# The Fuck
+
+[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
+
+## Usage
+Press `ESC` twice to correct previous console command.
+
+## Notes
+`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin.
diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
new file mode 100644
index 000000000..765e2b9a5
--- /dev/null
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -0,0 +1,17 @@
+if [[ -z $commands[thefuck] ]]; then
+ echo 'thefuck is not installed, you should "pip install thefuck" first'
+ return -1
+fi
+
+# Register alias
+eval "$(thefuck --alias)"
+
+fuck-command-line() {
+ local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
+ [[ -z $FUCK ]] && echo -n -e "\a" && return
+ BUFFER=$FUCK
+ zle end-of-line
+}
+zle -N fuck-command-line
+# Defined shortcut keys: [Esc] [Esc]
+bindkey "\e\e" fuck-command-line
diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
index 0211d3374..f08853643 100644
--- a/plugins/ubuntu/ubuntu.plugin.zsh
+++ b/plugins/ubuntu/ubuntu.plugin.zsh
@@ -3,6 +3,7 @@
# https://github.com/dbb
# https://github.com/Mappleconfusers
# Nicolas Jonas nextgenthemes.com
+# https://github.com/loctauxphilippe
#
# Debian, Ubuntu and friends related zsh aliases and functions for zsh
@@ -28,6 +29,7 @@ compdef _ppap ppap='sudo ppa-purge'
alias ag='sudo apt-get' # age - but without sudo
alias aga='sudo apt-get autoclean' # aac
+alias agar='sudo apt-get autoremove'
alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc
alias agd='sudo apt-get dselect-upgrade' # ads
@@ -38,9 +40,11 @@ alias agu='sudo apt-get update' # ad
alias agud='sudo apt-get update && sudo apt-get dist-upgrade' #adu
alias agug='sudo apt-get upgrade' # ag
alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg
+alias agar='sudo apt-get autoremove'
compdef _ag ag='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean'
+compdef _agar agar='sudo apt-get autoremove'
compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean'
compdef _agd agd='sudo apt-get dselect-upgrade'
@@ -51,6 +55,7 @@ compdef _agu agu='sudo apt-get update'
compdef _agud agud='sudo apt-get update && sudo apt-get dist-upgrade'
compdef _agug agug='sudo apt-get upgrade'
compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade'
+compdef _agar agar='sudo apt-get autoremove'
# Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
@@ -65,7 +70,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# apt-add-repository with automatic install/upgrade of the desired package
# Usage: aar ppa:xxxxxx/xxxxxx [packagename]
-# If packagename is not given as 2nd arument the function will ask for it and guess the defaupt by taking
+# If packagename is not given as 2nd argument the function will ask for it and guess the default by taking
# the part after the / from the ppa name wich is sometimes the right name for the package you want to install
aar() {
if [ -n "$2" ]; then
diff --git a/plugins/vundle/vundle.plugin.zsh b/plugins/vundle/vundle.plugin.zsh
index fa1911477..0f071597a 100644
--- a/plugins/vundle/vundle.plugin.zsh
+++ b/plugins/vundle/vundle.plugin.zsh
@@ -1,13 +1,13 @@
function vundle-init () {
- if [ ! -d ~/.vim/bundle/vundle/ ]
+ if [ ! -d ~/.vim/bundle/Vundle.vim/ ]
then
- mkdir -p ~/.vim/bundle/vundle/
+ mkdir -p ~/.vim/bundle/Vundle.vim/
fi
- if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ]
+ if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ]
then
- git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
- echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n"
+ git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
+ echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n"
fi
}
diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md
new file mode 100644
index 000000000..15e657859
--- /dev/null
+++ b/plugins/xcode/README.md
@@ -0,0 +1,84 @@
+# Xcode
+
+## Description
+
+This plugin provides a few utilities that can help you on your daily use of Xcode and iOS development.
+
+To start using it, add the `xcode` plugin to your `plugins` array in `~/.zshrc`:
+
+```zsh
+plugins=(... xcode)
+```
+
+
+## Aliases
+
+| Alias | Description | Command |
+|-------|------------------------------------------|------------------------------------------------|
+| xcb | Build Xcode projects and workspaces | xcodebuild |
+| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
+| xcp | Show currently selected Xcode directory | xcode-select --print-path |
+| xcsel | Select different Xcode directory by path | sudo xcode-select --switch |
+
+
+
+## Functions
+
+### `xc`
+
+Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory.
+Returns 1 if it didn't find any relevant files.
+
+### `simulator`
+
+Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.)
+
+### `xcselv`
+
+Selects different Xcode installations by version name. This is like `xcsel`, except it takes just a version name as an argument instead of the full path to the Xcode installation. Uses the naming conventions described below.
+
+* `xcselv <version>` selects a version
+ * Example: `xcselv 6.2`
+* `xcselv default` selects the default unversioned `Applications/Xcode.app`
+* `xcselv` with no argument lists the available Xcode versions in a human-readable format
+* `xcselv -l` lists the installed Xcode versions
+* `xcselv -L` lists the installed Xcode versions in a short version-name-only format
+* `xcselv -p` prints info about the active Xcode version
+* `xcselv -h` prints a help message
+
+The option parsing for `xcselv` is naive. Options may not be combined, and only the first option is recognized.
+
+## Multiple Xcode Versions
+
+The `xcselv` command provides support for switching between different Xcode installations using just a version number. Different Xcode versions are identified by file naming conventions.
+
+### Versioned Xcode Naming Conventions
+
+Apple does not seem to explicitly define or provide tooling support for a naming convention or other organizational mechanism for managing versioned Xcode installations. Apple seems to have released beta versions with both `Xcode<version>.app` and `Xcode-<version>.app` style names in the past, and both styles show up in forum and blog discussions.
+
+We've adopted the following naming convention:
+
+* Versioned Xcode installations are identified by the name `Xcode-<version>` or `Xcode<version>`.
+* The `-` separating `"Xcode"` and the version name is optional, and may be replaced by a space.
+* The versioned name may be applied to the `Xcode.app` itself, or a subdirectory underneath `Applications/` containing it.
+* You cannot version both the `Xcode.app` filename itself and the containing subfolder.
+* Thus, all of the following are equivalent.
+ * `Applications/Xcode-<version>.app`
+ * `Applications/Xcode-<version>/Xcode.app`
+ * `Applications/Xcode<version>.app`
+ * `Applications/Xcode <version>.app`
+ * `Applications/Xcode <version>/Xcode.app`
+* Both the system `/Applications/` and user `$HOME/Applications/` directories are searched.
+ * The user's `$HOME/Applications/` takes precedence over `/Applications` for a given version.
+ * If multiple naming variants within the same `Applications/` folder indicate the same version (for example, `Xcode-3.2.1.app`, `Xcode3.2.1.app`, and `Xcode-3.2.1/Xcode.app`), the precedence order is unspecified and implementation-dependent.
+* The `<version>` may be any string that is valid in a filename.
+* The special version name `"default"` refers to the "default" unversioned Xcode at `Applications/Xcode.app` (in either `/Applications/` or `$HOME/Applications/`).
+* Version names may not start with ``"-"`` or whitespace.
+
+The restrictions on the naming convention may need to be tightened in the future. In particular, if there are other well-known applications whose names begin with the string `"Xcode"`, the strings allowed for `<version>` may need to be restricted to avoid colliding with other applications. If there's evidence that one of these naming techniques is strongly favored either in practice or by Apple, we may tighten the naming convention to favor it.
+
+## Caveats
+
+Using `xcsel` or `xcselv` to select an Xcode that is installed under your `$HOME` may break things for other users, depending on your system setup. We let you do this anyway because some people run OS X as effectively single-user, or have open permissions so this will work. You could also use `$DEVELOPER_DIR` as an alternative to `xcsel` that is scoped to the current user or session, instead of a global setting.
+
+This does not verify that the version name in the Xcode filename matches the actual version of that binary. It is the user's responsibility to get the names right.
diff --git a/plugins/xcode/_xcselv b/plugins/xcode/_xcselv
new file mode 100644
index 000000000..f9861d54b
--- /dev/null
+++ b/plugins/xcode/_xcselv
@@ -0,0 +1,19 @@
+#compdef xcselv
+#autoload
+
+function _xcselv_compl_list_versions() {
+ _omz_xcode_list_versions short
+}
+
+_arguments \
+ '(-l -L -p)-h[prints a help message]' \
+ '(-L -p -h)-l[lists installed Xcode versions]' \
+ '(-l -p -h)-L[lists installed Xcode versions (long form)]' \
+ '(-h -l -L)-p[prints active Xcode version]' \
+ && ret=0
+
+local _xcode_versions
+_xcode_versions=($(_xcselv_compl_list_versions))
+_describe -t _xcode_versions 'version' _xcode_versions
+
+return 1
diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
index 1d1205b80..b63a857a7 100644
--- a/plugins/xcode/xcode.plugin.zsh
+++ b/plugins/xcode/xcode.plugin.zsh
@@ -1,25 +1,185 @@
-#xc function courtesy of http://gist.github.com/subdigital/5420709
+alias xcb='xcodebuild'
+alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
+alias xcp='xcode-select --print-path'
+alias xcsel='sudo xcode-select --switch'
+
+# original author: @subdigital
+# source: http://gist.github.com/subdigital/5420709
function xc {
- xcode_proj=`ls | grep "\.xc" | sort -r | head -1`
- if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
- then
+ local xcode_proj
+ xcode_proj=(*.{xcworkspace,xcodeproj}(N))
+
+ if [[ ${#xcode_proj} -eq 0 ]]; then
echo "No xcworkspace/xcodeproj file found in the current directory."
+ return 1
else
- echo "Found $xcode_proj"
- open "$xcode_proj"
+ echo "Found ${xcode_proj[1]}"
+ open "${xcode_proj[1]}"
fi
}
-function xcsel {
- sudo xcode-select --switch "$*"
+# "XCode-SELect by Version" - select Xcode by just version number
+# Uses naming convention:
+# - different versions of Xcode are named Xcode-<version>.app or stored
+# in a folder named Xcode-<version>
+# - the special version name "default" refers to the "default" Xcode.app with no suffix
+function xcselv {
+ emulate -L zsh
+ if [[ $# == 0 ]]; then
+ echo "xcselv: error: no option or argument given" >&2
+ echo "xcselv: see 'xcselv -h' for help" >&2
+ return 1
+ elif [[ $1 == "-p" ]]; then
+ _omz_xcode_print_active_version
+ return
+ elif [[ $1 == "-l" ]]; then
+ _omz_xcode_list_versions
+ return
+ elif [[ $1 == "-L" ]]; then
+ _omz_xcode_list_versions short
+ return
+ elif [[ $1 == "-h" ]]; then
+ _omz_xcode_print_xcselv_usage
+ return 0
+ elif [[ $1 == -* && $1 != "-" ]]; then
+ echo "xcselv: error: unrecognized option: $1" >&2
+ echo "xcselv: see 'xcselv -h' for help" >&2
+ return 1
+ fi
+ # Main case: "xcselv <version>" to select a version
+ local version=$1
+ local -A xcode_versions
+ _omz_xcode_locate_versions
+ if [[ -z ${xcode_versions[$version]} ]]; then
+ echo "xcselv: error: Xcode version '$version' not found" >&2
+ return 1
+ fi
+ app="${xcode_versions[$version]}"
+ echo "selecting Xcode $version: $app"
+ xcsel "$app"
}
-alias xcb='xcodebuild'
-alias xcp='xcode-select --print-path'
-alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
+function _omz_xcode_print_xcselv_usage {
+ cat << EOF >&2
+Usage:
+ xcselv <version>
+ xcselv [options]
+
+Options:
+ <version> set the active Xcode version
+ -h print this help message and exit
+ -p print the active Xcode version
+ -l list installed Xcode versions (long human-readable form)
+ -L list installed Xcode versions (short form, version names only)
+EOF
+}
+
+# Parses the Xcode version from a filename based on our conventions
+# Only meaningful when called from other _omz_xcode functions
+function _omz_xcode_parse_versioned_file {
+ local file=$1
+ local basename=${app:t}
+ local dir=${app:h}
+ local parent=${dir:t}
+ #echo "parent=$parent basename=$basename verstr=$verstr ver=$ver" >&2
+ local verstr
+ if [[ $parent == Xcode* ]]; then
+ if [[ $basename == "Xcode.app" ]]; then
+ # "Xcode-<version>/Xcode.app" format
+ verstr=$parent
+ else
+ # Both file and parent dir are versioned. Reject.
+ return 1;
+ fi
+ elif [[ $basename == Xcode*.app ]]; then
+ # "Xcode-<version>.app" format
+ verstr=${basename:r}
+ else
+ # Invalid naming pattern
+ return 1;
+ fi
-if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then
- alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'
-else
- alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app'
-fi
+ local ver=${verstr#Xcode}
+ ver=${ver#[- ]}
+ if [[ -z $ver ]]; then
+ # Unversioned "default" installation location
+ ver="default"
+ fi
+ print -- "$ver"
+}
+
+# Print the active version, using xcselv's notion of versions
+function _omz_xcode_print_active_version {
+ emulate -L zsh
+ local -A xcode_versions
+ local versions version active_path
+ _omz_xcode_locate_versions
+ active_path=$(xcode-select -p)
+ active_path=${active_path%%/Contents/Developer*}
+ versions=(${(kni)xcode_versions})
+ for version ($versions); do
+ if [[ "${xcode_versions[$version]}" == $active_path ]]; then
+ printf "%s (%s)\n" $version $active_path
+ return
+ fi
+ done
+ printf "%s (%s)\n" "<unknown>" $active_path
+}
+
+# Locates all the installed versions of Xcode on this system, for this
+# plugin's internal use.
+# Populates the $xcode_versions associative array variable
+# Caller should local-ize $xcode_versions with `local -A xcode_versions`
+function _omz_xcode_locate_versions {
+ emulate -L zsh
+ local -a app_dirs
+ local app_dir apps app xcode_ver
+ # In increasing precedence order:
+ app_dirs=(/Applications $HOME/Applications)
+ for app_dir ($app_dirs); do
+ apps=( $app_dir/Xcode*.app(N) $app_dir/Xcode*/Xcode.app(N) )
+ for app ($apps); do
+ xcode_ver=$(_omz_xcode_parse_versioned_file $app)
+ if [[ $? != 0 ]]; then
+ continue
+ fi
+ xcode_versions[$xcode_ver]=$app
+ done
+ done
+}
+
+function _omz_xcode_list_versions {
+ emulate -L zsh
+ local -A xcode_versions
+ _omz_xcode_locate_versions
+ local width=1 width_i versions do_short=0
+ if [[ $1 == "short" ]]; then
+ do_short=1
+ fi
+ versions=(${(kni)xcode_versions})
+ for version ($versions); do
+ if [[ $#version > $width ]]; then
+ width=$#version;
+ fi
+ done
+ for version ($versions); do
+ if [[ $do_short == 1 ]]; then
+ printf "%s\n" $version
+ else
+ printf "%-${width}s -> %s\n" "$version" "${xcode_versions[$version]}"
+ fi
+ done
+}
+
+function simulator {
+ local devfolder
+ devfolder="$(xcode-select -p)"
+
+ # Xcode ≤ 5.x
+ if [[ -d "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app" ]]; then
+ open "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"
+ # Xcode ≥ 6.x
+ else
+ open "${devfolder}/Applications/iOS Simulator.app"
+ fi
+}