From 5fa4d9d7606057ccb8e39a452db9a656b5f3caed Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Tue, 31 May 2016 09:57:36 +0800 Subject: [PATCH 001/121] add alias gh=git help --- plugins/git/git.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index eb7bc80345efd..3187cab749fb5 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -137,6 +137,8 @@ compdef _git ggu=git-checkout alias ggpur='ggu' compdef _git ggpur=git-checkout +alias gh='git help' + alias gignore='git update-index --assume-unchanged' alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' From 909fcef0469a2706508c0197e14aa45654702044 Mon Sep 17 00:00:00 2001 From: hjpotter92 Date: Tue, 21 Jun 2016 00:45:55 +0530 Subject: [PATCH 002/121] Fix issue with `dash` as the default `/bin/sh` script executing program. (#5177) * `function` keyword removed * Fixup the `if` statement and operators --- plugins/emacs/emacsclient.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index d61ebb15b38d7..41682512ddd6e 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -1,6 +1,6 @@ #!/bin/sh -function _emacsfun +_emacsfun() { # get list of available X windows. x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` @@ -18,7 +18,8 @@ function _emacsfun # adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh # If the second argument is - then write stdin to a tempfile and open the # tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh) -if [[ $# -ge 2 ]] && [[ "$2" == - ]]; then +if [ "$#" -ge "2" -a "$2" = "-" ] +then tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)" cat - > "$tempfile" _emacsfun --no-wait $tempfile From 9a61336d33a8a6258c0fb838bfa3c9c488e7d898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 20 Jun 2016 22:19:02 +0200 Subject: [PATCH 003/121] Fix man-preview completion definition Related: #5179 --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index c66325cde46ce..4dbc7578790be 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -175,7 +175,7 @@ function quick-look() { function man-preview() { man -t "$@" | open -f -a Preview } -compdef man-preview=man +compdef _man man-preview function vncviewer() { open vnc://$@ From c62442f999854038e7d0911f60a4aff252913a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 21 Jun 2016 01:06:21 +0200 Subject: [PATCH 004/121] Fix gfg function completion definition Related: #5179 --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index eb7bc80345efd..c186a6e11f421 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -88,7 +88,7 @@ alias gdw='git diff --word-diff' alias gf='git fetch' alias gfa='git fetch --all --prune' function gfg() { git ls-files | grep $@ } -compdef gfg=grep +compdef _grep gfg alias gfo='git fetch origin' alias gg='git gui citool' From 7fabc8bca41d4ff7090325116a85513dac852236 Mon Sep 17 00:00:00 2001 From: Clemens Gruber Date: Tue, 21 Jun 2016 01:31:13 +0200 Subject: [PATCH 005/121] bundler plugin: Simplify retrieval of cpu count on OSX (#5180) Calling awk is not necessary here, sysctl has the -n flag to print the value. Signed-off-by: Clemens Gruber --- plugins/bundler/bundler.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 382a1a471cca4..c5284dbb19d68 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -58,7 +58,7 @@ bundle_install() { if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then if [[ "$OSTYPE" = darwin* ]] then - local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" + local cores_num="$(sysctl -n hw.ncpu)" else local cores_num="$(nproc)" fi From af1ee2b9940de7f758669575560d8e32b9975cba Mon Sep 17 00:00:00 2001 From: Henrik Johansson Date: Sun, 19 Jun 2016 10:52:17 +0200 Subject: [PATCH 006/121] Add plugin for Gb completion (http://getgb.io) --- plugins/getgb/getgb.plugin.zsh | 114 +++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 plugins/getgb/getgb.plugin.zsh diff --git a/plugins/getgb/getgb.plugin.zsh b/plugins/getgb/getgb.plugin.zsh new file mode 100644 index 0000000000000..9efb00c9898bb --- /dev/null +++ b/plugins/getgb/getgb.plugin.zsh @@ -0,0 +1,114 @@ +function _gb_commands() { + local ret=1 state + _arguments -C ':command:->command' '*::options:->options' && ret=0 + + case $state in + (command) + + local -a subcommands + subcommands=( + "build:build a package" + "doc:show documentation for a package or symbol" + "env:print project environment variables" + "generate:generate Go files by processing source" + "help:displays the help" + "info:info returns information about this project" + "list:list the packages named by the importpaths" + "test:test packages" + "vendor:manage your vendored dependencies" + ) + _describe -t subcommands 'gb subcommands' subcommands && ret=0 + ;; + + (options) + case $line[1] in + (build) + _arguments \ + -f'[ignore cached packages]' \ + -F'[do not cache packages]' \ + -q'[decreases verbosity]' \ + -P'[the number of build jobs to run in parallel]' \ + -R'[sets the base of the project root search path]' \ + -dotfile'[output a dot formatted file of the build steps]' \ + -ldflags'["flag list" arguments to pass to the linker]' \ + -gcflags'["arg list" arguments to pass to the compiler]' \ + -race'[enable data race detection]' \ + -tags'["tag list" additional build tags]' + ;; + (list) + _arguments \ + -f'[alternate format for the list, using the syntax of package template]' \ + -s'[read format template from STDIN]' \ + -json'[prints output in structured JSON format]' + ;; + (test) + _arguments \ + -v'[print output from test subprocess]' \ + -ldflags'["flag list" arguments to pass to the linker]' \ + -gcflags'["arg list" arguments to pass to the compiler]' \ + -race'[enable data race detection]' \ + -tags'["tag list" additional build tags]' + ;; + (vendor) + __gb-vendor + esac + ;; + esac + + return ret +} + +compdef _gb_commands gb + +__gb-vendor () +{ + local curcontext="$curcontext" state line + + _arguments -C ':command:->command' '*::options:->options' + + case $state in + (command) + + local -a subcommands + subcommands=( + 'delete:deletes a local dependency' + 'fetch:fetch a remote dependency' + 'list:lists dependencies, one per line' + 'purge:remove all unreferenced dependencies' + 'restore:restore dependencies from the manifest' + 'update:update a local dependency' + ) + _describe -t subcommands 'gb vendor subcommands' subcommands && ret=0 + ;; + + (options) + case $line[1] in + (delete) + _arguments \ + -all'[remove all dependencies]' + ;; + (fetch) + _arguments \ + -branch'[fetch from a particular branch]' \ + -no-recurse'[do not fetch recursively]' \ + -tag'[fetch the specified tag]' \ + -revision'[fetch the specific revision from the branch (if supplied)]' \ + -precaire'[allow the use of insecure protocols]' \ + ;; + (list) + _arguments \ + -f'[controls the template used for printing each manifest entry]' + ;; + (restore) + _arguments \ + -precaire'[allow the use of insecure protocols]' + ;; + (update) + _arguments \ + -all'[update all dependencies in the manifest or supply a given dependency]' \ + -precaire'[allow the use of insecure protocols]' + ;; + esac + ;; + esac +} From 57a689ffd5dd54852afeea38e5c401d5a29b4493 Mon Sep 17 00:00:00 2001 From: Henrik Johansson Date: Tue, 28 Jun 2016 21:25:51 +0200 Subject: [PATCH 007/121] Add README to gb plugin --- plugins/getgb/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 plugins/getgb/README.md diff --git a/plugins/getgb/README.md b/plugins/getgb/README.md new file mode 100644 index 0000000000000..b477b0f4ccd8c --- /dev/null +++ b/plugins/getgb/README.md @@ -0,0 +1,10 @@ +# *gb* plugin + +- aims to support completion for all *gb* commands +- also supports completion for *gb* plugins such as *vendor* + +See http://getgb.io for the full *gb* documentation + +## Caveats + +- The *git* plugin installs an alias *gb* that usually conflicts with the *gb* program From d0ea3f22b1099ce98e0fc02b6074d862478ae81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 2 Jul 2016 11:59:04 +0200 Subject: [PATCH 008/121] Add more information to the README --- plugins/getgb/README.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/getgb/README.md b/plugins/getgb/README.md index b477b0f4ccd8c..88881cb28d3ae 100644 --- a/plugins/getgb/README.md +++ b/plugins/getgb/README.md @@ -1,10 +1,21 @@ -# *gb* plugin +# `gb` plugin -- aims to support completion for all *gb* commands -- also supports completion for *gb* plugins such as *vendor* +> A project based build tool for the Go programming language. -See http://getgb.io for the full *gb* documentation +See https://getgb.io for the full `gb` documentation + +* * * * + +- Adds completion support for all `gb` commands. +- Also supports completion for the [`gb-vendor` plugin](https://godoc.org/github.com/constabulary/gb/cmd/gb-vendor). + +To use it, add `getgb` to your plugins array: +```sh +plugins=(... getgb) +``` ## Caveats -- The *git* plugin installs an alias *gb* that usually conflicts with the *gb* program +The `git` plugin defines an alias `gb` that usually conflicts with the `gb` program. +If you're having trouble with it, remove it by adding `unalias gb` at the end of your +zshrc file. From a29f8f76599e93653f006c2e074bd1dc47cc9b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 2 Jul 2016 16:24:02 +0200 Subject: [PATCH 009/121] Fix formatting of gb plugin completion --- plugins/getgb/getgb.plugin.zsh | 200 ++++++++++++++++----------------- 1 file changed, 97 insertions(+), 103 deletions(-) diff --git a/plugins/getgb/getgb.plugin.zsh b/plugins/getgb/getgb.plugin.zsh index 9efb00c9898bb..726f0a24fed69 100644 --- a/plugins/getgb/getgb.plugin.zsh +++ b/plugins/getgb/getgb.plugin.zsh @@ -1,114 +1,108 @@ -function _gb_commands() { - local ret=1 state - _arguments -C ':command:->command' '*::options:->options' && ret=0 +_gb () { + local ret=1 state + _arguments -C ':command:->command' '*::options:->options' && ret=0 - case $state in - (command) - - local -a subcommands - subcommands=( - "build:build a package" - "doc:show documentation for a package or symbol" - "env:print project environment variables" - "generate:generate Go files by processing source" - "help:displays the help" - "info:info returns information about this project" - "list:list the packages named by the importpaths" - "test:test packages" - "vendor:manage your vendored dependencies" - ) - _describe -t subcommands 'gb subcommands' subcommands && ret=0 - ;; - - (options) - case $line[1] in - (build) - _arguments \ - -f'[ignore cached packages]' \ - -F'[do not cache packages]' \ - -q'[decreases verbosity]' \ - -P'[the number of build jobs to run in parallel]' \ - -R'[sets the base of the project root search path]' \ - -dotfile'[output a dot formatted file of the build steps]' \ - -ldflags'["flag list" arguments to pass to the linker]' \ - -gcflags'["arg list" arguments to pass to the compiler]' \ - -race'[enable data race detection]' \ - -tags'["tag list" additional build tags]' - ;; - (list) - _arguments \ - -f'[alternate format for the list, using the syntax of package template]' \ - -s'[read format template from STDIN]' \ - -json'[prints output in structured JSON format]' - ;; - (test) - _arguments \ - -v'[print output from test subprocess]' \ - -ldflags'["flag list" arguments to pass to the linker]' \ - -gcflags'["arg list" arguments to pass to the compiler]' \ - -race'[enable data race detection]' \ - -tags'["tag list" additional build tags]' - ;; - (vendor) - __gb-vendor - esac - ;; - esac + case $state in + (command) + local -a subcommands + subcommands=( + "build:build a package" + "doc:show documentation for a package or symbol" + "env:print project environment variables" + "generate:generate Go files by processing source" + "help:displays the help" + "info:info returns information about this project" + "list:list the packages named by the importpaths" + "test:test packages" + "vendor:manage your vendored dependencies" + ) + _describe -t subcommands 'gb subcommands' subcommands && ret=0 + ;; + (options) + case $line[1] in + (build) + _arguments \ + -f'[ignore cached packages]' \ + -F'[do not cache packages]' \ + -q'[decreases verbosity]' \ + -P'[the number of build jobs to run in parallel]' \ + -R'[sets the base of the project root search path]' \ + -dotfile'[output a dot formatted file of the build steps]' \ + -ldflags'["flag list" arguments to pass to the linker]' \ + -gcflags'["arg list" arguments to pass to the compiler]' \ + -race'[enable data race detection]' \ + -tags'["tag list" additional build tags]' + ;; + (list) + _arguments \ + -f'[alternate format for the list, using the syntax of package template]' \ + -s'[read format template from STDIN]' \ + -json'[prints output in structured JSON format]' + ;; + (test) + _arguments \ + -v'[print output from test subprocess]' \ + -ldflags'["flag list" arguments to pass to the linker]' \ + -gcflags'["arg list" arguments to pass to the compiler]' \ + -race'[enable data race detection]' \ + -tags'["tag list" additional build tags]' + ;; + (vendor) + _gb-vendor + esac + ;; + esac - return ret + return ret } -compdef _gb_commands gb - -__gb-vendor () -{ - local curcontext="$curcontext" state line +compdef _gb gb - _arguments -C ':command:->command' '*::options:->options' +_gb-vendor () { + local curcontext="$curcontext" state line + _arguments -C ':command:->command' '*::options:->options' case $state in - (command) - - local -a subcommands - subcommands=( - 'delete:deletes a local dependency' - 'fetch:fetch a remote dependency' - 'list:lists dependencies, one per line' - 'purge:remove all unreferenced dependencies' - 'restore:restore dependencies from the manifest' - 'update:update a local dependency' - ) - _describe -t subcommands 'gb vendor subcommands' subcommands && ret=0 + (command) + local -a subcommands + subcommands=( + 'delete:deletes a local dependency' + 'fetch:fetch a remote dependency' + 'list:lists dependencies, one per line' + 'purge:remove all unreferenced dependencies' + 'restore:restore dependencies from the manifest' + 'update:update a local dependency' + ) + _describe -t subcommands 'gb vendor subcommands' subcommands && ret=0 ;; - - (options) - case $line[1] in - (delete) - _arguments \ - -all'[remove all dependencies]' - ;; - (fetch) - _arguments \ - -branch'[fetch from a particular branch]' \ - -no-recurse'[do not fetch recursively]' \ - -tag'[fetch the specified tag]' \ - -revision'[fetch the specific revision from the branch (if supplied)]' \ - -precaire'[allow the use of insecure protocols]' \ - ;; - (list) - _arguments \ - -f'[controls the template used for printing each manifest entry]' - ;; - (restore) - _arguments \ - -precaire'[allow the use of insecure protocols]' - ;; - (update) - _arguments \ - -all'[update all dependencies in the manifest or supply a given dependency]' \ - -precaire'[allow the use of insecure protocols]' - ;; - esac + (options) + case $line[1] in + (delete) + _arguments \ + -all'[remove all dependencies]' + ;; + (fetch) + _arguments \ + -branch'[fetch from a particular branch]' \ + -no-recurse'[do not fetch recursively]' \ + -tag'[fetch the specified tag]' \ + -revision'[fetch the specific revision from the branch (if supplied)]' \ + -precaire'[allow the use of insecure protocols]' \ + ;; + (list) + _arguments \ + -f'[controls the template used for printing each manifest entry]' + ;; + (restore) + _arguments \ + -precaire'[allow the use of insecure protocols]' + ;; + (update) + _arguments \ + -all'[update all dependencies in the manifest or supply a given dependency]' \ + -precaire'[allow the use of insecure protocols]' + ;; + esac ;; esac } From cab6359173fb99c832617a5aa24ec734586ff055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 3 Jul 2016 23:27:33 +0200 Subject: [PATCH 010/121] Rename gb completion file to more conventional _gb --- plugins/getgb/{getgb.plugin.zsh => _gb} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename plugins/getgb/{getgb.plugin.zsh => _gb} (99%) diff --git a/plugins/getgb/getgb.plugin.zsh b/plugins/getgb/_gb similarity index 99% rename from plugins/getgb/getgb.plugin.zsh rename to plugins/getgb/_gb index 726f0a24fed69..8148adf160403 100644 --- a/plugins/getgb/getgb.plugin.zsh +++ b/plugins/getgb/_gb @@ -1,3 +1,6 @@ +#compdef gb +#autoload + _gb () { local ret=1 state _arguments -C ':command:->command' '*::options:->options' && ret=0 @@ -56,8 +59,6 @@ _gb () { return ret } -compdef _gb gb - _gb-vendor () { local curcontext="$curcontext" state line _arguments -C ':command:->command' '*::options:->options' @@ -106,3 +107,5 @@ _gb-vendor () { ;; esac } + +_gb From dc0a884ea7b4298861cb081a4b76c9f0b42c7ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 3 Jul 2016 23:29:00 +0200 Subject: [PATCH 011/121] Rename getgb plugin to gb --- plugins/{getgb => gb}/README.md | 4 ++-- plugins/{getgb => gb}/_gb | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename plugins/{getgb => gb}/README.md (88%) rename plugins/{getgb => gb}/_gb (100%) diff --git a/plugins/getgb/README.md b/plugins/gb/README.md similarity index 88% rename from plugins/getgb/README.md rename to plugins/gb/README.md index 88881cb28d3ae..822c29aaa67be 100644 --- a/plugins/getgb/README.md +++ b/plugins/gb/README.md @@ -9,9 +9,9 @@ See https://getgb.io for the full `gb` documentation - Adds completion support for all `gb` commands. - Also supports completion for the [`gb-vendor` plugin](https://godoc.org/github.com/constabulary/gb/cmd/gb-vendor). -To use it, add `getgb` to your plugins array: +To use it, add `gb` to your plugins array: ```sh -plugins=(... getgb) +plugins=(... gb) ``` ## Caveats diff --git a/plugins/getgb/_gb b/plugins/gb/_gb similarity index 100% rename from plugins/getgb/_gb rename to plugins/gb/_gb From 96a2092e377139fbcd95d7b7ac703b740daa22f6 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 15 Jul 2016 02:05:39 -0700 Subject: [PATCH 012/121] lib/git.zsh: Added git_commits_behind function (#4450) * Added git_commits_behind function * Added 'command' to git_commits_behind function * git_commits_behind code review changes --- lib/git.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index 1c76d58829bae..c79cc0d8e38c2 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -83,6 +83,13 @@ function git_commits_ahead() { fi } +# Gets the number of commits behind remote +function git_commits_behind() { + if $(command git rev-parse --git-dir > /dev/null 2>&1); then + echo $(git rev-list --count HEAD..@{upstream}) + fi +} + # Outputs if current branch is ahead of remote function git_prompt_ahead() { if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then From bfbfef9fcf87cfb8ecab8b3ee13a27a9f7e392ae Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Fri, 15 Jul 2016 14:30:09 -0500 Subject: [PATCH 013/121] Cleans up phing plugin. --- plugins/phing/phing.plugin.zsh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/phing/phing.plugin.zsh b/plugins/phing/phing.plugin.zsh index 1f022047c1bbe..60f59c3b08e29 100644 --- a/plugins/phing/phing.plugin.zsh +++ b/plugins/phing/phing.plugin.zsh @@ -1,15 +1,6 @@ -_phing_does_target_list_need_generating () { - [ ! -f .phing_targets ] && return 0; - [ build.xml -nt .phing_targets ] && return 0; - return 1; -} - _phing () { if [ -f build.xml ]; then - if _phing_does_target_list_need_generating; then - phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets - fi - compadd `cat .phing_targets` + compadd $(phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}') fi } From c51823c04eee3889a17a957790ae5bf7f07fd5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Lenart?= Date: Tue, 16 Dec 2014 08:34:50 +0100 Subject: [PATCH 014/121] Remove warning lines from phing completion Remove "Warning:" lines from phing targets list. Warning lines are returned by phing when a target has no tasks or dependencies. # Conflicts: # plugins/phing/phing.plugin.zsh --- plugins/phing/phing.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/phing/phing.plugin.zsh b/plugins/phing/phing.plugin.zsh index 60f59c3b08e29..d5a2649bf22de 100644 --- a/plugins/phing/phing.plugin.zsh +++ b/plugins/phing/phing.plugin.zsh @@ -1,6 +1,6 @@ _phing () { if [ -f build.xml ]; then - compadd $(phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}') + compadd $(phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|grep -v "Warning:"|awk '{print $1}') fi } From eb244d9ec03a5f83102efa89d8d2231282f3c408 Mon Sep 17 00:00:00 2001 From: soredake Date: Tue, 19 Jul 2016 01:20:59 +0300 Subject: [PATCH 015/121] Update emacs plugin. (#5201) - Updated minimal version from 23 to 24. - Added new aliases that fix unexpected close with -nw option. - Removed some old aliases. - Fixed line that detects open frames. --- plugins/emacs/emacs.plugin.zsh | 7 +++---- plugins/emacs/emacsclient.sh | 12 ++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index a3f0085a826ba..c102a5a1e2816 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -10,7 +10,7 @@ # - Configuration changes made at runtime are applied to all frames. -if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then +if "$ZSH/tools/require_tool.sh" emacs 24 2>/dev/null ; then export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" # set EDITOR if not already defined. @@ -18,15 +18,14 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait" alias e=emacs + # open terminal emacsclient + alias te="$EMACS_PLUGIN_LAUNCHER -nw" # same than M-x eval but from outside Emacs. alias eeval="$EMACS_PLUGIN_LAUNCHER --eval" # create a new X frame alias eframe='emacsclient --alternate-editor "" --create-frame' - # to code all night long - alias emasc=emacs - alias emcas=emacs # Write to standard output the path to the file # opened in the current buffer. diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index 41682512ddd6e..26b28d495b6a6 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -2,15 +2,15 @@ _emacsfun() { - # get list of available X windows. - x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` + # get list of emacs frames. + frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'` - if [ -z "$x" ] || [ "$x" = "nil" ] ;then - # Create one if there is no X window yet. - emacsclient --alternate-editor "" --create-frame "$@" - else + if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then # prevent creating another X frame if there is at least one present. emacsclient --alternate-editor "" "$@" + else + # Create one if there is no X window yet. + emacsclient --alternate-editor "" --create-frame "$@" fi } From f4013053d302480b7663ad5c3a04d0442237a952 Mon Sep 17 00:00:00 2001 From: Julien Dubreuil Date: Tue, 19 Jul 2016 00:24:12 +0200 Subject: [PATCH 016/121] Updated _docker-compose to the latest version (from 0.1.0 to 1.5.0). (#5215) Also fixed formatting of markdown URL in README. --- plugins/docker-compose/README.md | 3 +- plugins/docker-compose/_docker-compose | 331 ++++++++++++++++++------- 2 files changed, 240 insertions(+), 94 deletions(-) diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index 567b821487af8..d3fcb29fef46c 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -1,5 +1,4 @@ # Docker-compose plugin for oh my zsh -A copy of the completion script from the [docker-compose](1) git repo. +A copy of the completion script from the [docker-compose](https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose) git repo. -[1]:[https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose] diff --git a/plugins/docker-compose/_docker-compose b/plugins/docker-compose/_docker-compose index 19c06675ad505..2947cef382438 100644 --- a/plugins/docker-compose/_docker-compose +++ b/plugins/docker-compose/_docker-compose @@ -7,7 +7,7 @@ # ------------------------------------------------------------------------- # Version # ------- -# 0.1.0 +# 1.5.0 # ------------------------------------------------------------------------- # Authors # ------- @@ -19,58 +19,69 @@ # * @felixr docker zsh completion script : https://github.com/felixr/docker-zsh-completion # ------------------------------------------------------------------------- -# For compatibility reasons, Compose and therefore its completion supports several -# stack compositon files as listed here, in descending priority. -# Support for these filenames might be dropped in some future version. -__docker-compose_compose_file() { - local file - for file in docker-compose.y{,a}ml fig.y{,a}ml ; do - [ -e $file ] && { - echo $file - return - } - done - echo docker-compose.yml +__docker-compose_q() { + docker-compose 2>/dev/null $compose_options "$@" } -# Extracts all service names from docker-compose.yml. -___docker-compose_all_services_in_compose_file() { +# All services defined in docker-compose.yml +__docker-compose_all_services_in_compose_file() { local already_selected local -a services - already_selected=$(echo ${words[@]} | tr " " "|") - awk -F: '/^[a-zA-Z0-9]/{print $1}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | grep -Ev "$already_selected" + already_selected=$(echo $words | tr " " "|") + __docker-compose_q config --services \ + | grep -Ev "^(${already_selected})$" } # All services, even those without an existing container __docker-compose_services_all() { - services=$(___docker-compose_all_services_in_compose_file) - _alternative "args:services:($services)" + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + services=$(__docker-compose_all_services_in_compose_file) + _alternative "args:services:($services)" && ret=0 + + return ret } # All services that have an entry with the given key in their docker-compose.yml section -___docker-compose_services_with_key() { +__docker-compose_services_with_key() { local already_selected local -a buildable - already_selected=$(echo ${words[@]} | tr " " "|") + already_selected=$(echo $words | tr " " "|") # flatten sections to one line, then filter lines containing the key and return section name. - awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | awk -F: -v key=": +$1:" '$0 ~ key {print $1}' 2>/dev/null | grep -Ev "$already_selected" + __docker-compose_q config \ + | sed -n -e '/^services:/,/^[^ ]/p' \ + | sed -n 's/^ //p' \ + | awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \ + | grep " \+$1:" \ + | cut -d: -f1 \ + | grep -Ev "^(${already_selected})$" } # All services that are defined by a Dockerfile reference __docker-compose_services_from_build() { - buildable=$(___docker-compose_services_with_key build) - _alternative "args:buildable services:($buildable)" + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + buildable=$(__docker-compose_services_with_key build) + _alternative "args:buildable services:($buildable)" && ret=0 + + return ret } # All services that are defined by an image __docker-compose_services_from_image() { - pullable=$(___docker-compose_services_with_key image) - _alternative "args:pullable services:($pullable)" + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + pullable=$(__docker-compose_services_with_key image) + _alternative "args:pullable services:($pullable)" && ret=0 + + return ret } __docker-compose_get_services() { - local kind expl - declare -a running stopped lines args services + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local kind + declare -a running paused stopped lines args services docker_status=$(docker ps > /dev/null 2>&1) if [ $? -ne 0 ]; then @@ -80,64 +91,78 @@ __docker-compose_get_services() { kind=$1 shift - [[ $kind = (stopped|all) ]] && args=($args -a) + [[ $kind =~ (stopped|all) ]] && args=($args -a) - lines=(${(f)"$(_call_program commands docker ps ${args})"}) - services=(${(f)"$(_call_program commands docker-compose 2>/dev/null ${compose_file:+-f $compose_file} ${compose_project:+-p $compose_project} ps -q)"}) + lines=(${(f)"$(_call_program commands docker $docker_options ps $args)"}) + services=(${(f)"$(_call_program commands docker-compose 2>/dev/null $compose_options ps -q)"}) # Parse header line to find columns local i=1 j=1 k header=${lines[1]} declare -A begin end - while (( $j < ${#header} - 1 )) { - i=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 1)) - j=$(( $i + ${${header[$i,-1]}[(i) ]} - 1)) - k=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 2)) - begin[${header[$i,$(($j-1))]}]=$i - end[${header[$i,$(($j-1))]}]=$k - } + while (( j < ${#header} - 1 )); do + i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) + j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) + k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) + begin[${header[$i,$((j-1))]}]=$i + end[${header[$i,$((j-1))]}]=$k + done lines=(${lines[2,-1]}) # Container ID local line s name local -a names for line in $lines; do - if [[ $services == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then + if [[ ${services[@]} == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}}) for name in $names; do s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}" - s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}" + s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}" if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then stopped=($stopped $s) else + if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = *\(Paused\)* ]]; then + paused=($paused $s) + fi running=($running $s) fi done fi done - [[ $kind = (running|all) ]] && _describe -t services-running "running services" running - [[ $kind = (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped + [[ $kind =~ (running|all) ]] && _describe -t services-running "running services" running "$@" && ret=0 + [[ $kind =~ (paused|all) ]] && _describe -t services-paused "paused services" paused "$@" && ret=0 + [[ $kind =~ (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped "$@" && ret=0 + + return ret +} + +__docker-compose_pausedservices() { + [[ $PREFIX = -* ]] && return 1 + __docker-compose_get_services paused "$@" } __docker-compose_stoppedservices() { + [[ $PREFIX = -* ]] && return 1 __docker-compose_get_services stopped "$@" } __docker-compose_runningservices() { + [[ $PREFIX = -* ]] && return 1 __docker-compose_get_services running "$@" } -__docker-compose_services () { +__docker-compose_services() { + [[ $PREFIX = -* ]] && return 1 __docker-compose_get_services all "$@" } __docker-compose_caching_policy() { - oldp=( "$1"(Nmh+1) ) # 1 hour + oldp=( "$1"(Nmh+1) ) # 1 hour (( $#oldp )) } -__docker-compose_commands () { +__docker-compose_commands() { local cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy @@ -151,110 +176,204 @@ __docker-compose_commands () { local -a lines lines=(${(f)"$(_call_program commands docker-compose 2>&1)"}) _docker_compose_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) - _store_cache docker_compose_subcommands _docker_compose_subcommands + (( $#_docker_compose_subcommands > 0 )) && _store_cache docker_compose_subcommands _docker_compose_subcommands fi _describe -t docker-compose-commands "docker-compose command" _docker_compose_subcommands } -__docker-compose_subcommand () { - local -a _command_args +__docker-compose_subcommand() { + local opts_help opts_force_recreate opts_no_recreate opts_no_build opts_remove_orphans opts_timeout opts_no_color opts_no_deps + + opts_help='(: -)--help[Print usage]' + opts_force_recreate="(--no-recreate)--force-recreate[Recreate containers even if their configuration and image haven't changed. Incompatible with --no-recreate.]" + opts_no_recreate="(--force-recreate)--no-recreate[If containers already exist, don't recreate them. Incompatible with --force-recreate.]" + opts_no_build="(--build)--no-build[Don't build an image, even if it's missing.]" + opts_remove_orphans="--remove-orphans[Remove containers for services not defined in the Compose file]" + opts_timeout=('(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: ") + opts_no_color='--no-color[Produce monochrome output.]' + opts_no_deps="--no-deps[Don't start linked services.]" + integer ret=1 + case "$words[1]" in (build) _arguments \ - '--no-cache[Do not use cache when building the image]' \ + $opts_help \ + '--force-rm[Always remove intermediate containers.]' \ + '--no-cache[Do not use cache when building the image.]' \ + '--pull[Always attempt to pull a newer version of the image.]' \ '*:services:__docker-compose_services_from_build' && ret=0 ;; + (bundle) + _arguments \ + $opts_help \ + '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to ".dab".]:file:_files' && ret=0 + ;; + (config) + _arguments \ + $opts_help \ + '(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \ + '--services[Print the service names, one per line.]' && ret=0 + ;; + (create) + _arguments \ + $opts_help \ + $opts_force_recreate \ + $opts_no_recreate \ + $opts_no_build \ + "(--no-build)--build[Build images before creating containers.]" \ + '*:services:__docker-compose_services_all' && ret=0 + ;; + (down) + _arguments \ + $opts_help \ + "--rmi[Remove images. Type must be one of: 'all': Remove all images used by any service. 'local': Remove only images that don't have a custom tag set by the \`image\` field.]:type:(all local)" \ + '(-v --volumes)'{-v,--volumes}"[Remove named volumes declared in the \`volumes\` section of the Compose file and anonymous volumes attached to containers.]" \ + $opts_remove_orphans && ret=0 + ;; + (events) + _arguments \ + $opts_help \ + '--json[Output events as a stream of json objects]' \ + '*:services:__docker-compose_services_all' && ret=0 + ;; + (exec) + _arguments \ + $opts_help \ + '-d[Detached mode: Run command in the background.]' \ + '--privileged[Give extended privileges to the process.]' \ + '--user=[Run the command as this user.]:username:_users' \ + '-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \ + '--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \ + '(-):running services:__docker-compose_runningservices' \ + '(-):command: _command_names -e' \ + '*::arguments: _normal' && ret=0 + ;; (help) _arguments ':subcommand:__docker-compose_commands' && ret=0 ;; (kill) _arguments \ + $opts_help \ '-s[SIGNAL to send to the container. Default signal is SIGKILL.]:signal:_signals' \ '*:running services:__docker-compose_runningservices' && ret=0 ;; (logs) _arguments \ - '--no-color[Produce monochrome output.]' \ + $opts_help \ + '(-f --follow)'{-f,--follow}'[Follow log output]' \ + $opts_no_color \ + '--tail=[Number of lines to show from the end of the logs for each container.]:number of lines: ' \ + '(-t --timestamps)'{-t,--timestamps}'[Show timestamps]' \ '*:services:__docker-compose_services_all' && ret=0 ;; - (migrate-to-labels) + (pause) _arguments \ - '(-):Recreate containers to add labels' && ret=0 + $opts_help \ + '*:running services:__docker-compose_runningservices' && ret=0 ;; (port) _arguments \ - '--protocol=-[tcp or udap (defaults to tcp)]:protocol:(tcp udp)' \ - '--index=-[index of the container if there are mutiple instances of a service (defaults to 1)]:index: ' \ + $opts_help \ + '--protocol=[tcp or udp \[default: tcp\]]:protocol:(tcp udp)' \ + '--index=[index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \ '1:running services:__docker-compose_runningservices' \ '2:port:_ports' && ret=0 ;; (ps) _arguments \ + $opts_help \ '-q[Only display IDs]' \ '*:services:__docker-compose_services_all' && ret=0 ;; (pull) _arguments \ - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ + $opts_help \ + '--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \ '*:services:__docker-compose_services_from_image' && ret=0 ;; + (push) + _arguments \ + $opts_help \ + '--ignore-push-failures[Push what it can and ignores images with push failures.]' \ + '*:services:__docker-compose_services' && ret=0 + ;; (rm) _arguments \ + $opts_help \ '(-f --force)'{-f,--force}"[Don't ask to confirm removal]" \ - '-v[Remove volumes associated with containers]' \ + '-v[Remove any anonymous volumes attached to containers]' \ '*:stopped services:__docker-compose_stoppedservices' && ret=0 ;; (run) _arguments \ - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ + $opts_help \ '-d[Detached mode: Run container in the background, print new container name.]' \ - '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \ '*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \ - '(-u --user)'{-u,--user=-}'[Run as specified username or uid]:username or uid:_users' \ - "--no-deps[Don't start linked services.]" \ + '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \ + '--name=[Assign a name to the container]:name: ' \ + $opts_no_deps \ + '(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \ '--rm[Remove container after run. Ignored in detached mode.]' \ "--service-ports[Run command with the service's ports enabled and mapped to the host.]" \ '-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \ + '(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \ + '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \ '(-):services:__docker-compose_services' \ '(-):command: _command_names -e' \ '*::arguments: _normal' && ret=0 ;; (scale) - _arguments '*:running services:__docker-compose_runningservices' && ret=0 + _arguments \ + $opts_help \ + $opts_timeout \ + '*:running services:__docker-compose_runningservices' && ret=0 ;; (start) - _arguments '*:stopped services:__docker-compose_stoppedservices' && ret=0 + _arguments \ + $opts_help \ + '*:stopped services:__docker-compose_stoppedservices' && ret=0 ;; (stop|restart) _arguments \ - '(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \ + $opts_help \ + $opts_timeout \ '*:running services:__docker-compose_runningservices' && ret=0 ;; + (unpause) + _arguments \ + $opts_help \ + '*:paused services:__docker-compose_pausedservices' && ret=0 + ;; (up) _arguments \ - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ - '-d[Detached mode: Run containers in the background, print new container names.]' \ - '--no-color[Produce monochrome output.]' \ - "--no-deps[Don't start linked services.]" \ - "--no-recreate[If containers already exist, don't recreate them.]" \ - "--no-build[Don't build an image, even if it's missing]" \ - '(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \ - "--x-smart-recreate[Only recreate containers whose configuration or image needs to be updated. (EXPERIMENTAL)]" \ + $opts_help \ + '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \ + $opts_no_color \ + $opts_no_deps \ + $opts_force_recreate \ + $opts_no_recreate \ + $opts_no_build \ + "(--no-build)--build[Build images before starting containers.]" \ + "(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \ + '(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \ + $opts_remove_orphans \ '*:services:__docker-compose_services_all' && ret=0 ;; (version) _arguments \ + $opts_help \ "--short[Shows only Compose's version number.]" && ret=0 ;; (*) - _message 'Unknown sub command' + _message 'Unknown sub command' && ret=1 + ;; esac return ret } -_docker-compose () { +_docker-compose() { # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`. # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. if [[ $service != docker-compose ]]; then @@ -262,34 +381,62 @@ _docker-compose () { return fi - local curcontext="$curcontext" state line ret=1 + local curcontext="$curcontext" state line + integer ret=1 typeset -A opt_args _arguments -C \ '(- :)'{-h,--help}'[Get help]' \ - '--verbose[Show more output]' \ - '(- :)'{-v,--version}'[Print version and exit]' \ '(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \ '(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \ + '--verbose[Show more output]' \ + '(- :)'{-v,--version}'[Print version and exit]' \ + '(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \ + '--tls[Use TLS; implied by --tlsverify]' \ + '--tlscacert=[Trust certs signed only by this CA]:ca path:' \ + '--tlscert=[Path to TLS certificate file]:client cert path:' \ + '--tlskey=[Path to TLS key file]:tls key path:' \ + '--tlsverify[Use TLS and verify the remote]' \ + "--skip-hostname-check[Don't check the daemon's hostname against the name specified in the client certificate (for example if your docker host is an IP address)]" \ '(-): :->command' \ '(-)*:: :->option-or-argument' && ret=0 - local counter=1 - #local compose_file compose_project - while [ $counter -lt ${#words[@]} ]; do - case "${words[$counter]}" in - -f|--file) - (( counter++ )) - compose_file="${words[$counter]}" - ;; - -p|--project-name) - (( counter++ )) - compose_project="${words[$counter]}" - ;; - *) - ;; - esac - (( counter++ )) + local -a relevant_compose_flags relevant_docker_flags compose_options docker_options + + relevant_compose_flags=( + "--file" "-f" + "--host" "-H" + "--project-name" "-p" + "--tls" + "--tlscacert" + "--tlscert" + "--tlskey" + "--tlsverify" + "--skip-hostname-check" + ) + + relevant_docker_flags=( + "--host" "-H" + "--tls" + "--tlscacert" + "--tlscert" + "--tlskey" + "--tlsverify" + ) + + for k in "${(@k)opt_args}"; do + if [[ -n "${relevant_docker_flags[(r)$k]}" ]]; then + docker_options+=$k + if [[ -n "$opt_args[$k]" ]]; then + docker_options+=$opt_args[$k] + fi + fi + if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then + compose_options+=$k + if [[ -n "$opt_args[$k]" ]]; then + compose_options+=$opt_args[$k] + fi + fi done case $state in From cc8285b1f708c33338d280bbb5481dc93bafa458 Mon Sep 17 00:00:00 2001 From: Adam Glenn Date: Tue, 19 Jul 2016 12:01:00 -0700 Subject: [PATCH 017/121] adding python virtualenv support to the prompt (#5031) adding python virtualenv support to muse theme --- themes/muse.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/muse.zsh-theme b/themes/muse.zsh-theme index 4bd8fb825e936..55a375747ed01 100644 --- a/themes/muse.zsh-theme +++ b/themes/muse.zsh-theme @@ -13,7 +13,7 @@ GIT_DIRTY_COLOR=$FG[133] GIT_CLEAN_COLOR=$FG[118] GIT_PROMPT_INFO=$FG[012] -PROMPT='%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%} %{$GIT_PROMPT_INFO%}$(git_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} ' +PROMPT='%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%} %{$GIT_PROMPT_INFO%}$(git_prompt_info) $(virtualenv_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} ' #RPS1="${return_code}" From a7e30b26baa94bac99d9d05cf642bd1942ae1787 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 22 Jul 2016 17:04:35 +0400 Subject: [PATCH 018/121] Fix hg call when missing on archlinux with command-not-found (#5218) --- themes/agnoster.zsh-theme | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 103041eeffff7..da1f9b6e6dfca 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -128,6 +128,7 @@ prompt_git() { } prompt_hg() { + (( $+commands[hg] )) || return local rev status if $(hg id >/dev/null 2>&1); then if $(hg prompt >/dev/null 2>&1); then From 61981951b1380c431e464a63d394ce890e751b97 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 1 Aug 2016 08:48:46 -0700 Subject: [PATCH 019/121] Updated git_commits_ahead function (#5247) * Function wasn't returning correct value * Updated underlying git command * Kept echo command from previous function for backwards compatibility * Kept function consistent with git_commits_behind --- lib/git.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index c79cc0d8e38c2..648a766b5b761 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -76,9 +76,8 @@ function git_current_branch() { # Gets the number of commits ahead from remote function git_commits_ahead() { - if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then - local COMMITS - COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') + if $(command git rev-parse --git-dir > /dev/null 2>&1); then + local COMMITS="$(git rev-list --count @{upstream}..HEAD)" echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi } From 508b80c1e131ffb5ca6a858345c27eb2400122c9 Mon Sep 17 00:00:00 2001 From: nklmish Date: Mon, 1 Aug 2016 18:05:01 +0200 Subject: [PATCH 020/121] support for startpage search engine in web-search plugin (#5245) --- plugins/web-search/web-search.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index d3bf97d75f206..3b5478ca2bba1 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -10,6 +10,7 @@ function web_search() { bing "https://www.bing.com/search?q=" yahoo "https://search.yahoo.com/search?p=" duckduckgo "https://www.duckduckgo.com/?q=" + startpage "https://www.startpage.com/do/search?q=" yandex "https://yandex.ru/yandsearch?text=" github "https://github.com/search?q=" baidu "https://www.baidu.com/s?wd=" @@ -41,6 +42,7 @@ alias bing='web_search bing' alias google='web_search google' alias yahoo='web_search yahoo' alias ddg='web_search duckduckgo' +alias sp='web_search startpage' alias yandex='web_search yandex' alias github='web_search github' alias baidu='web_search baidu' From f5537241a4fe7f48a5f7f49fff52db9f0247a5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Malard?= Date: Mon, 1 Aug 2016 18:16:54 +0200 Subject: [PATCH 021/121] Fix gbda alias to support `color.ui = always` + exclude dev branches (#4304) * Fix gbda alias to support git config color.ui = always * Update gbda alias to exclude develop and dev branches --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index c186a6e11f421..01c29e14ef4b6 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -46,7 +46,7 @@ alias gapa='git add --patch' alias gb='git branch' alias gba='git branch -a' -alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d' +alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' From 7654b16b3963844e5079a8935eb93f108c52f273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 7 Aug 2016 18:30:57 +0200 Subject: [PATCH 022/121] [git plugin] Fix indentation and organise aliases --- plugins/git/git.plugin.zsh | 67 ++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 01c29e14ef4b6..0cee136c2d72f 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -81,62 +81,73 @@ alias gd='git diff' alias gdca='git diff --cached' alias gdct='git describe --tags `git rev-list --tags --max-count=1`' alias gdt='git diff-tree --no-commit-id --name-only -r' +alias gdw='git diff --word-diff' + gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff -alias gdw='git diff --word-diff' alias gf='git fetch' alias gfa='git fetch --all --prune' +alias gfo='git fetch origin' + function gfg() { git ls-files | grep $@ } compdef _grep gfg -alias gfo='git fetch origin' alias gg='git gui citool' alias gga='git gui citool --amend' + ggf() { -[[ "$#" != 1 ]] && local b="$(git_current_branch)" -git push --force origin "${b:=$1}" + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git push --force origin "${b:=$1}" } compdef _git ggf=git-checkout + ggl() { -if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then -git pull origin "${*}" -else -[[ "$#" == 0 ]] && local b="$(git_current_branch)" -git pull origin "${b:=$1}" -fi + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then + git pull origin "${*}" + else + [[ "$#" == 0 ]] && local b="$(git_current_branch)" + git pull origin "${b:=$1}" + fi } compdef _git ggl=git-checkout -alias ggpull='git pull origin $(git_current_branch)' -compdef _git ggpull=git-checkout + ggp() { -if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then -git push origin "${*}" -else -[[ "$#" == 0 ]] && local b="$(git_current_branch)" -git push origin "${b:=$1}" -fi + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then + git push origin "${*}" + else + [[ "$#" == 0 ]] && local b="$(git_current_branch)" + git push origin "${b:=$1}" + fi } compdef _git ggp=git-checkout -alias ggpush='git push origin $(git_current_branch)' -compdef _git ggpush=git-checkout + ggpnp() { -if [[ "$#" == 0 ]]; then -ggl && ggp -else -ggl "${*}" && ggp "${*}" -fi + if [[ "$#" == 0 ]]; then + ggl && ggp + else + ggl "${*}" && ggp "${*}" + fi } compdef _git ggpnp=git-checkout -alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' + ggu() { -[[ "$#" != 1 ]] && local b="$(git_current_branch)" -git pull --rebase origin "${b:=$1}" + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git pull --rebase origin "${b:=$1}" } compdef _git ggu=git-checkout + alias ggpur='ggu' compdef _git ggpur=git-checkout +alias ggpull='git pull origin $(git_current_branch)' +compdef _git ggpull=git-checkout + +alias ggpush='git push origin $(git_current_branch)' +compdef _git ggpush=git-checkout + +alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' + alias gignore='git update-index --assume-unchanged' alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' From a7de0fabd7ebbf1776942a8c7fde8ee33ed681b0 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sun, 7 Aug 2016 18:36:44 +0100 Subject: [PATCH 023/121] nvm plugin improvements (#5265) * Export $NVM_DIR if it doesn't exist and use it when looking for nvm * Use $NVM_DIR when looking for nvm for completion * Use $NVM_DIR when looking for nvm in nvm_prompt_info --- lib/nvm.zsh | 2 +- plugins/nvm/_nvm | 2 +- plugins/nvm/nvm.plugin.zsh | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nvm.zsh b/lib/nvm.zsh index 61d997fc07806..4a8b6811e9c64 100644 --- a/lib/nvm.zsh +++ b/lib/nvm.zsh @@ -1,6 +1,6 @@ # get the node.js version function nvm_prompt_info() { - [ -f "$HOME/.nvm/nvm.sh" ] || return + [[ -f "$NVM_DIR/nvm.sh" ]] || return local nvm_prompt nvm_prompt=$(node -v 2>/dev/null) [[ "${nvm_prompt}x" == "x" ]] && return diff --git a/plugins/nvm/_nvm b/plugins/nvm/_nvm index a95c9e3753e5e..1414dcbb1782a 100644 --- a/plugins/nvm/_nvm +++ b/plugins/nvm/_nvm @@ -1,7 +1,7 @@ #compdef nvm #autoload -[[ -s ~/.nvm/nvm.sh ]] || return 0 +[[ -f "$NVM_DIR/nvm.sh" ]] || return 0 local -a _1st_arguments _1st_arguments=( diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 9709719fefb42..9dde3a266ae18 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -1,3 +1,5 @@ -# The addition 'nvm install' attempts in ~/.profile +# Set NVM_DIR if it isn't already defined +[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" -[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh +# Load nvm if it exists +[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" From 9772f8e10d07ce982a45fcce9b074e9084ad76cb Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Tue, 9 Aug 2016 02:39:11 +0200 Subject: [PATCH 024/121] Replace /bin/sh with sh for portability (#5291) This makes things work even on system lacking /bin/sh, such as on non-rooted Android systems. --- lib/functions.zsh | 4 ++-- tools/check_for_upgrade.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index f9d4a9717d7dd..9f11318d2c06c 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -3,11 +3,11 @@ function zsh_stats() { } function uninstall_oh_my_zsh() { - env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh + env ZSH=$ZSH sh $ZSH/tools/uninstall.sh } function upgrade_oh_my_zsh() { - env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh + env ZSH=$ZSH sh $ZSH/tools/upgrade.sh } function take() { diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 881bc6c499341..bd9aba8be1d90 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -11,7 +11,7 @@ function _update_zsh_update() { } function _upgrade_zsh() { - env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh + env ZSH=$ZSH sh $ZSH/tools/upgrade.sh # update the zsh file _update_zsh_update } From 4505a438e4829e0335484c08b71244378081d7b7 Mon Sep 17 00:00:00 2001 From: Dominic Motuka Date: Thu, 11 Aug 2016 03:14:52 +0300 Subject: [PATCH 025/121] update alias of get a list of packages installed locally (#5276) --- plugins/ubuntu/ubuntu.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index f08853643b514..d924f886137c7 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -63,7 +63,7 @@ alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ # Misc. ##################################################################### # print all installed packages -alias allpkgs='aptitude search -F "%p" --disable-columns ~i' +alias allpkgs='dpkg --get-selections | grep -v deinstall' # Create a basic .deb package alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' From a9428b137f14969bd44a5787c0080297d81ea0b7 Mon Sep 17 00:00:00 2001 From: Kyle Scully Date: Wed, 10 Aug 2016 17:28:56 -0700 Subject: [PATCH 026/121] added mix autocompletion support for phoenix (#4967) --- plugins/mix/_mix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/mix/_mix b/plugins/mix/_mix index 3b3887b1fc4d1..57fdf808a7222 100644 --- a/plugins/mix/_mix +++ b/plugins/mix/_mix @@ -38,6 +38,15 @@ _1st_arguments=( 'local.hex:Install hex locally' 'local.rebar:Install rebar locally' 'new:Create a new Elixir project' + 'phoenix.digest:Digests and compress static files' + 'phoenix.gen.channel:Generates a Phoenix channel' + 'phoenix.gen.html:Generates controller, model and views for an HTML based resource' + 'phoenix.gen.json:Generates a controller and model for a JSON based resource' + 'phoenix.gen.model:Generates an Ecto model' + 'phoenix.gen.secret:Generates a secret' + 'phoenix.new:Create a new Phoenix application' + 'phoenix.routes:Prints all routes' + 'phoenix.server:Starts applications and their servers' 'run:Run the given file or expression' "test:Run a project's tests" '--help:Describe available tasks' @@ -49,7 +58,7 @@ __task_list () local expl declare -a tasks - tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new run test) + tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server run test) _wanted tasks expl 'help' compadd $tasks } @@ -80,4 +89,3 @@ case $state in esac ;; esac - From c09323098acb03a0678f87036fad10bd99b283b2 Mon Sep 17 00:00:00 2001 From: Shiv Venkatasubrahmanyam Date: Wed, 10 Aug 2016 17:44:00 -0700 Subject: [PATCH 027/121] Add shrink-path plugin to shorten directory paths (e.g. ~/f/b/quux) (#5262) * Add shrink-path plugin to shorten directory paths (e.g. ~/f/b/quux) * Add a README --- plugins/shrink-path/README.md | 68 +++++++++++ plugins/shrink-path/shrink-path.plugin.zsh | 127 +++++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 plugins/shrink-path/README.md create mode 100644 plugins/shrink-path/shrink-path.plugin.zsh diff --git a/plugins/shrink-path/README.md b/plugins/shrink-path/README.md new file mode 100644 index 0000000000000..51fa8a0510c23 --- /dev/null +++ b/plugins/shrink-path/README.md @@ -0,0 +1,68 @@ +# A plugin to shrink directory paths for brevity and pretty-printing + + +## Examples + +For this directory tree: +``` + /home/ + me/ + foo/ + bar/ + quux/ + biz/ # The prefix b is ambiguous between bar and biz. +``` +here are the results of calling `shrink_path