From a93bb4e695b773db6c9fc4b6dac46809f14d7e89 Mon Sep 17 00:00:00 2001 From: kenleytomlin Date: Tue, 30 Aug 2016 08:54:47 +0100 Subject: [PATCH 001/121] Update the docker completion script with the official docker zsh completion script --- plugins/docker/_docker | 2413 ++++++++++++++++++++++++++++++++++------ 1 file changed, 2059 insertions(+), 354 deletions(-) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index a82a31ad..66dfeea9 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -1,439 +1,2144 @@ -#compdef docker +#compdef docker dockerd +# +# zsh completion for docker (http://docker.com) +# +# version: 0.3.0 +# github: https://github.com/felixr/docker-zsh-completion +# +# contributors: +# - Felix Riedel +# - Steve Durrheimer +# - Vincent Bernat +# +# license: +# +# Copyright (c) 2013, Felix Riedel +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# -# Docker autocompletion for oh-my-zsh -# Requires: Docker installed -# Author: Azaan (@aeonazaan) -# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ -# Paul van den Berg (@bergvandenp) for Docker v1.3+ +# Short-option stacking can be enabled with: +# zstyle ':completion:*:*:docker:*' option-stacking yes +# zstyle ':completion:*:*:docker-*:*' option-stacking yes +__docker_arguments() { + if zstyle -t ":completion:${curcontext}:" option-stacking; then + print -- -s + fi +} +__docker_get_containers() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local kind type line s + declare -a running stopped lines args names + + kind=$1; shift + type=$1; shift + [[ $kind = (stopped|all) ]] && args=($args -a) + + lines=(${(f)"$(_call_program commands docker $docker_options ps --format 'table' --no-trunc $args)"}) + + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + 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 + end[${header[$i,$((j-1))]}]=-1 # Last column, should go to the end of the line + lines=(${lines[2,-1]}) + + # Container ID + if [[ $type = (ids|all) ]]; then + for line in $lines; do + s="${${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}[0,12]}" + s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" + s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}" + if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then + stopped=($stopped $s) + else + running=($running $s) + fi + done + fi + + # Names: we only display the one without slash. All other names + # are generated and may clutter the completion. However, with + # Swarm, all names may be prefixed by the swarm node name. + if [[ $type = (names|all) ]]; then + for line in $lines; do + names=(${(ps:,:)${${line[${begin[NAMES]},${end[NAMES]}]}%% *}}) + # First step: find a common prefix and strip it (swarm node case) + (( ${#${(u)names%%/*}} == 1 )) && names=${names#${names[1]%%/*}/} + # Second step: only keep the first name without a / + s=${${names:#*/*}[1]} + # If no name, well give up. + (( $#s != 0 )) || continue + s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" + s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}" + if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then + stopped=($stopped $s) + else + running=($running $s) + fi + done + fi + + [[ $kind = (running|all) ]] && _describe -t containers-running "running containers" running "$@" && ret=0 + [[ $kind = (stopped|all) ]] && _describe -t containers-stopped "stopped containers" stopped "$@" && ret=0 + return ret +} + +__docker_stoppedcontainers() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_containers stopped all "$@" +} + +__docker_runningcontainers() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_containers running all "$@" +} -# ----- Helper functions -# Output a selectable list of all running docker containers __docker_containers() { - declare -a cont_cmd - cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) - if [[ 'X$cont_cmd' != 'X' ]] - _describe 'containers' cont_cmd + [[ $PREFIX = -* ]] && return 1 + __docker_get_containers all all "$@" } -# Output a selectable list of all containers, even not running -__docker_all_containers() { - declare -a cont_cmd - cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) - if [[ 'X$cont_cmd' != 'X' ]] - _describe 'containers' cont_cmd +__docker_containers_ids() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_containers all ids "$@" +} + +__docker_containers_names() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_containers all names "$@" +} + +__docker_complete_info_plugins() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + emulate -L zsh + setopt extendedglob + local -a plugins + plugins=(${(ps: :)${(M)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Plugins:}%%$'\n'^ *}}:# $1: *}## $1: }) + _describe -t plugins "$1 plugins" plugins && ret=0 + return ret } -# output a selectable list of all docker images __docker_images() { - declare -a img_cmd - img_cmd=($(docker images | awk 'NR>1{print $1}'| sed 's/:/\\:/g')) - _describe 'images' img_cmd + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a images + images=(${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}}) + _describe -t docker-images "images" images && ret=0 + __docker_repositories_with_tags && ret=0 + return ret } -# ----- Commands -# Seperate function for each command, makes extension easier later -# --------------------------- -__attach() { - _arguments \ - '--no-stdin[Do not attach STDIN]' \ - '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]' - __docker_containers +__docker_repositories() { + [[ $PREFIX = -* ]] && return 1 + declare -a repos + repos=(${${${(f)"$(_call_program commands docker $docker_options images)"}%% *}[2,-1]}) + repos=(${repos#}) + _describe -t docker-repos "repositories" repos } -__build() { - _arguments \ - '--no-cache[Do not use cache when building the image]' \ - '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \ - '--rm[Remove intermediate containers after a successful build]' \ - '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \ - '*:files:_files' +__docker_repositories_with_tags() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a repos onlyrepos matched + declare m + repos=(${${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/ ##/:::}%% *}) + repos=(${${repos%:::}#}) + # Check if we have a prefix-match for the current prefix. + onlyrepos=(${repos%::*}) + for m in $onlyrepos; do + [[ ${PREFIX##${~~m}} != ${PREFIX} ]] && { + # Yes, complete with tags + repos=(${${repos/:::/:}/:/\\:}) + _describe -t docker-repos-with-tags "repositories with tags" repos && ret=0 + return ret + } + done + # No, only complete repositories + onlyrepos=(${${repos%:::*}/:/\\:}) + _describe -t docker-repos "repositories" onlyrepos -qS : && ret=0 + + return ret } -__commit() { - _arguments \ - '(-a,--author=)'{-a,--author=}'[Author (e.g. "John Hannibal Smith ")]' \ - '(-c,--change=)'{-c,--change=}'[Apply Dockerfile instruction to the created image]' \ - '(-m,--message=)'{-m,--message=}'[Commit message]' \ - '(-p,--pause=)'{-p,--pause=}'[Pause container during commit]' \ +__docker_search() { + [[ $PREFIX = -* ]] && return 1 + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy + fi + + local searchterm cachename + searchterm="${words[$CURRENT]%/}" + cachename=_docker-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 docker $docker_options search $searchterm)"}%% *}[2,-1]}) + _store_cache ${cachename#_} result + fi + _wanted dockersearch expl 'available images' compadd -a result } -__cp() { - __docker_containers +__docker_get_log_options() { + [[ $PREFIX = -* ]] && return 1 + + integer ret=1 + local log_driver=${opt_args[--log-driver]:-"all"} + local -a awslogs_options fluentd_options gelf_options journald_options json_file_options syslog_options splunk_options + + awslogs_options=("awslogs-region" "awslogs-group" "awslogs-stream") + fluentd_options=("env" "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "labels" "tag") + gcplogs_options=("env" "gcp-log-cmd" "gcp-project" "labels") + gelf_options=("env" "gelf-address" "gelf-compression-level" "gelf-compression-type" "labels" "tag") + journald_options=("env" "labels" "tag") + json_file_options=("env" "labels" "max-file" "max-size") + syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") + splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") + + [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 + [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 + [[ $log_driver = (gcplogs|all) ]] && _describe -t gcplogs-options "gcplogs options" gcplogs_options "$@" && ret=0 + [[ $log_driver = (gelf|all) ]] && _describe -t gelf-options "gelf options" gelf_options "$@" && ret=0 + [[ $log_driver = (journald|all) ]] && _describe -t journald-options "journald options" journald_options "$@" && ret=0 + [[ $log_driver = (json-file|all) ]] && _describe -t json-file-options "json-file options" json_file_options "$@" && ret=0 + [[ $log_driver = (syslog|all) ]] && _describe -t syslog-options "syslog options" syslog_options "$@" && ret=0 + [[ $log_driver = (splunk|all) ]] && _describe -t splunk-options "splunk options" splunk_options "$@" && ret=0 + + return ret } -__create() { - _arguments \ - '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ - '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \ - '--add-host=[Add a custom host-to-IP mapping]' \ - '--cap-add=[Add Linux capabilities]' \ - '--cap-drop=[Drop Linux capabilities]' \ - '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \ - '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \ - '--cidfile=[Write the container ID to the file]' \ - '--device=[Add a host device to the container]' \ - '--dns=[Set custom dns servers]' \ - '--dns-search=[Set custom DNS search domains]' \ - '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ - '--env-file=[Read in a file of environment variables]' \ - '--entrypoint=[Overwrite the default entrypoint of the image]' \ - '--expose=[Expose a port from the container without publishing it to your host]' \ - '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ - '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ - '--ipc=[IPC namespace to use]' \ - '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \ - '--link=[Add link to another container (name:alias)]' \ - '--log-driver=[Logging driver for the container]' \ - '--lxc-conf=[Add custom LXC options]' \ - '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \ - '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: , where unit = b, k, m or g)]' \ - '--net=[Set the Network mode for the container]' \ - '--name=[Assign a name to the container]' \ - '--pid=[PID namespace to use]' \ - '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \ - '--privileged=[Give extended privileges to this container]' \ - '--restart=[Restart policy to apply when a container exits]' \ - '--security-opt=[Security Options]' \ - '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ - '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ - '(-u,--user=)'{-u,--user=}'[Username or UID]' \ - '--ulimit=[Ulimit options]' \ - '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \ - '--volumes-from=[Mount volumes from the specified container(s)]' \ - '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' - __docker_images +__docker_log_drivers() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + drivers=(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog) + _describe -t log-drivers "log drivers" drivers && ret=0 + return ret } -__diff() { - __docker_containers +__docker_log_options() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (syslog-format) + syslog_format_opts=('rfc3164' 'rfc5424' 'rfc5424micro') + _describe -t syslog-format-opts "Syslog format Options" syslog_format_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + __docker_get_log_options -qS "=" && ret=0 + fi + + return ret } -__events() { - _arguments \ - '--since=[Show previously created events and then stream.]' +__docker_complete_detach_keys() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + compset -P "*," + keys=(${:-{a-z}}) + ctrl_keys=(${:-ctrl-{{a-z},{@,'[','\\','^',']',_}}}) + _describe -t detach_keys "[a-z]" keys -qS "," && ret=0 + _describe -t detach_keys-ctrl "'ctrl-' + 'a-z @ [ \\\\ ] ^ _'" ctrl_keys -qS "," && ret=0 } -__export() { - __docker_containers +__docker_complete_pid() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local -a opts vopts + + opts=('host') + vopts=('container') + + if compset -P '*:'; then + case "${${words[-1]%:*}#*=}" in + (container) + __docker_runningcontainers && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t pid-value-opts "PID Options with value" vopts -qS ":" && ret=0 + _describe -t pid-opts "PID Options" opts && ret=0 + fi + + return ret } -__history() { - _arguments \ - '--no-trunc=[Don''t truncate output]' \ - '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]' - __docker_images +__docker_complete_runtimes() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + emulate -L zsh + setopt extendedglob + local -a runtimes_opts + runtimes_opts=(${(ps: :)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Runtimes: }%%$'\n'^ *}}}) + _describe -t runtimes-opts "runtimes options" runtimes_opts && ret=0 } -__images() { - _arguments \ - '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \ - '--no-trunc[Don''t truncate output]' \ - '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \ - '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \ - '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]' - __docker_images +__docker_complete_ps_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (ancestor) + __docker_images && ret=0 + ;; + (before|since) + __docker_containers && ret=0 + ;; + (id) + __docker_containers_ids && ret=0 + ;; + (name) + __docker_containers_names && ret=0 + ;; + (network) + __docker_networks && ret=0 + ;; + (status) + status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing') + _describe -t status-filter-opts "Status Filter Options" status_opts && ret=0 + ;; + (volume) + __docker_volumes && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('ancestor' 'before' 'exited' 'id' 'label' 'name' 'network' 'since' 'status' 'volume') + _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 + fi + + return ret } -__import() { - _arguments '*:files:_files' +__docker_complete_search_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a boolean_opts opts + + boolean_opts=('true' 'false') + opts=('is-automated' 'is-official' 'stars') + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (is-automated|is-official) + _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret } -__info() { - # no arguments +__docker_complete_images_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a boolean_opts opts + + boolean_opts=('true' 'false') + opts=('before' 'dangling' 'label' 'since') + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (before|since) + __docker_images && ret=0 + ;; + (dangling) + _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 + fi + + return ret } -__inspect() { - __docker_images - __docker_all_containers +__docker_complete_events_filter() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a opts + + opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'type' 'volume') + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (container) + __docker_containers && ret=0 + ;; + (daemon) + emulate -L zsh + setopt extendedglob + local -a daemon_opts + daemon_opts=( + ${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Name: }%%$'\n'^ *}} + ${${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'ID: }%%$'\n'^ *}}//:/\\:} + ) + _describe -t daemon-filter-opts "daemon filter options" daemon_opts && ret=0 + ;; + (event) + local -a event_opts + event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' + 'exec_start' 'export' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' + 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') + _describe -t event-filter-opts "event filter options" event_opts && ret=0 + ;; + (image) + __docker_images && ret=0 + ;; + (network) + __docker_networks && ret=0 + ;; + (type) + local -a type_opts + type_opts=('container' 'daemon' 'image' 'network' 'volume') + _describe -t type-filter-opts "type filter options" type_opts && ret=0 + ;; + (volume) + __docker_volumes && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret } -__kill() { - _arguments \ - '(-s,--signal=)'{-s,--signal=}'[KILL Signal]' - __docker_containers +# BO network + +__docker_network_complete_ls_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (driver) + __docker_complete_info_plugins Network && ret=0 + ;; + (id) + __docker_networks_ids && ret=0 + ;; + (name) + __docker_networks_names && ret=0 + ;; + (type) + type_opts=('builtin' 'custom') + _describe -t type-filter-opts "Type Filter Options" type_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('driver' 'id' 'label' 'name' 'type') + _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 + fi + + return ret } -__load() { - _arguments '*:files:_files' +__docker_get_networks() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local line s + declare -a lines networks + + type=$1; shift + + lines=(${(f)"$(_call_program commands docker $docker_options network ls)"}) + + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + 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 + end[${header[$i,$((j-1))]}]=-1 + lines=(${lines[2,-1]}) + + # Network ID + if [[ $type = (ids|all) ]]; then + for line in $lines; do + s="${line[${begin[NETWORK ID]},${end[NETWORK ID]}]%% ##}" + s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" + networks=($networks $s) + done + fi + + # Names + if [[ $type = (names|all) ]]; then + for line in $lines; do + s="${line[${begin[NAME]},${end[NAME]}]%% ##}" + s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" + networks=($networks $s) + done + fi + + _describe -t networks-list "networks" networks "$@" && ret=0 + return ret } -__login() { - _arguments \ - '(-e,--email=)'{-e,-email=}'[Email]' \ - '(-p,--password=)'{-p,-password=}'[Password]' \ - '(-u,--username=)'{-u,-username=}'[Username]' +__docker_networks() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_networks all "$@" } -__logs() { - _arguments \ - '(-f,--follow)'{-f,-follow}'[Follow log output]' - __docker_containers +__docker_networks_ids() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_networks ids "$@" } -__port() { - __docker_containers +__docker_networks_names() { + [[ $PREFIX = -* ]] && return 1 + __docker_get_networks names "$@" } -__top() { - __docker_containers +__docker_network_commands() { + local -a _docker_network_subcommands + _docker_network_subcommands=( + "connect:Connect a container to a network" + "create:Creates a new network with a name specified by the user" + "disconnect:Disconnects a container from a network" + "inspect:Displays detailed information on a network" + "ls:Lists all the networks created by the user" + "rm:Deletes one or more networks" + ) + _describe -t docker-network-commands "docker network command" _docker_network_subcommands } -__ps() { - _arguments \ - '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \ - '--before-id=[Show only container created before Id, include non-running ones.]' \ - '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \ - '-n=[Show n last created containers, include non-running ones. default=-1.]' \ - '--no-trunc[Don''t truncate output]' \ - '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \ - '(-s,--size)'{-s,--size}'[Display sizes]' \ - '--since-id=[Show only containers created since Id, include non-running ones.]' +__docker_network_subcommand() { + local -a _command_args opts_help + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + + case "$words[1]" in + (connect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*--alias=[Add network-scoped alias for the container]:alias: " \ + "($help)--ip=[Container IPv4 address]:IPv4: " \ + "($help)--ip6=[Container IPv6 address]:IPv6: " \ + "($help)*--link=[Add a link to another container]:link:->link" \ + "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " \ + "($help -)1:network:__docker_networks" \ + "($help -)2:containers:__docker_containers" && ret=0 + + case $state in + (link) + if compset -P "*:"; then + _wanted alias expl "Alias" compadd -E "" && ret=0 + else + __docker_runningcontainers -qS ":" && ret=0 + fi + ;; + esac + ;; + (create) + _arguments $(__docker_arguments) -A '-*' \ + $opts_help \ + "($help)*--aux-address[Auxiliary IPv4 or IPv6 addresses used by network driver]:key=IP: " \ + "($help -d --driver)"{-d=,--driver=}"[Driver to manage the Network]:driver:(null host bridge overlay)" \ + "($help)*--gateway=[IPv4 or IPv6 Gateway for the master subnet]:IP: " \ + "($help)--internal[Restricts external access to the network]" \ + "($help)*--ip-range=[Allocate container ip from a sub-range]:IP/mask: " \ + "($help)--ipam-driver=[IP Address Management Driver]:driver:(default)" \ + "($help)*--ipam-opt=[Custom IPAM plugin options]:opt=value: " \ + "($help)--ipv6[Enable IPv6 networking]" \ + "($help)*--label=[Set metadata on a network]:label=value: " \ + "($help)*"{-o=,--opt=}"[Driver specific options]:opt=value: " \ + "($help)*--subnet=[Subnet in CIDR format that represents a network segment]:IP/mask: " \ + "($help -)1:Network Name: " && ret=0 + ;; + (disconnect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)1:network:__docker_networks" \ + "($help -)2:containers:__docker_containers" && ret=0 + ;; + (inspect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ + "($help -)*:network:__docker_networks" && ret=0 + ;; + (ls) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--no-trunc[Do not truncate the output]" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)--format=[Pretty-print networks using a Go template]:template: " \ + "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 + case $state in + (filter-options) + __docker_network_complete_ls_filters && ret=0 + ;; + esac + ;; + (rm) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:network:__docker_networks" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0 + ;; + esac + + return ret } -__pull() { - _arguments \ - '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]' +# EO network + +# BO node + +__docker_node_complete_ls_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (id) + __docker_complete_nodes_ids && ret=0 + ;; + (membership) + membership_opts=('accepted' 'pending' 'rejected') + _describe -t membership-opts "membership options" membership_opts && ret=0 + ;; + (name) + __docker_complete_nodes_names && ret=0 + ;; + (role) + role_opts=('manager' 'worker') + _describe -t role-opts "role options" role_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('id' 'label' 'membership' 'name' 'role') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret } -__push() { - # no arguments +__docker_node_complete_ps_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (desired-state) + state_opts=('accepted' 'running') + _describe -t state-opts "desired state options" state_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('desired-state' 'id' 'label' 'name') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret } -__restart() { - _arguments \ - '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]' - __docker_containers +__docker_nodes() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local line s + declare -a lines nodes args + + type=$1; shift + filter=$1; shift + [[ $filter != "none" ]] && args=("-f $filter") + + lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"}) + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + 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 + end[${header[$i,$((j-1))]}]=-1 + lines=(${lines[2,-1]}) + + # Node ID + if [[ $type = (ids|all) ]]; then + for line in $lines; do + s="${line[${begin[ID]},${end[ID]}]%% ##}" + nodes=($nodes $s) + done + fi + + # Names + if [[ $type = (names|all) ]]; then + for line in $lines; do + s="${line[${begin[NAME]},${end[NAME]}]%% ##}" + nodes=($nodes $s) + done + fi + + _describe -t nodes-list "nodes" nodes "$@" && ret=0 + return ret } -__rm() { - _arguments \ - '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ - '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ - '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' - __docker_all_containers +__docker_complete_nodes() { + [[ $PREFIX = -* ]] && return 1 + __docker_nodes all none "$@" } -__rmi() { - _arguments \ - '(-f,--force=)'{-f,--force=}'[Force]' - __docker_images +__docker_complete_nodes_ids() { + [[ $PREFIX = -* ]] && return 1 + __docker_nodes ids none "$@" } -__run() { - _arguments \ - '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ - '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \ - '--add-host=[Add a custom host-to-IP mapping]' \ - '--cap-add=[Add Linux capabilities]' \ - '--cap-drop=[Drop Linux capabilities]' \ - '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \ - '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \ - '--cidfile=[Write the container ID to the file]' \ - '(-d,--detach=)'{-d,--detach=}'[Run container in the background, print new container id]' \ - '--device=[Add a host device to the container]' \ - '--dns=[Set custom dns servers]' \ - '--dns-search=[Set custom DNS search domains]' \ - '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ - '--env-file=[Read in a file of environment variables]' \ - '--entrypoint=[Overwrite the default entrypoint of the image]' \ - '--expose=[Expose a port from the container without publishing it to your host]' \ - '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ - '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ - '--ipc=[IPC namespace to use]' \ - '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \ - '--link=[Add link to another container (name:alias)]' \ - '--log-driver=[Logging driver for the container]' \ - '--lxc-conf=[Add custom LXC options]' \ - '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \ - '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: , where unit = b, k, m or g)]' \ - '--net=[Set the Network mode for the container]' \ - '--name=[Assign a name to the container]' \ - '--pid=[PID namespace to use]' \ - '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \ - '--privileged=[Give extended privileges to this container]' \ - '--restart=[Restart policy to apply when a container exits]' \ - '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \ - '--security-opt=[Security Options]' \ - '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ - '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ - '(-u,--user=)'{-u,--user=}'[Username or UID]' \ - '--ulimit=[Ulimit options]' \ - '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \ - '--volumes-from=[Mount volumes from the specified container(s)]' \ - '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' - __docker_images +__docker_complete_nodes_names() { + [[ $PREFIX = -* ]] && return 1 + __docker_nodes names none "$@" } -__search() { - _arguments \ - '--no-trunc=[Don''t truncate output]' \ - '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \ - '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]' +__docker_complete_pending_nodes() { + [[ $PREFIX = -* ]] && return 1 + __docker_nodes all "membership=pending" "$@" } -__save() { - __docker_images +__docker_complete_manager_nodes() { + [[ $PREFIX = -* ]] && return 1 + __docker_nodes all "role=manager" "$@" } -__start() { - _arguments \ - '(-a,--attach=)'{-a,--attach=}'[Attach container''s STDOUT/STDERR and forward all signals to the process]' \ - '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s STDIN]' - __docker_all_containers +__docker_complete_worker_nodes() { + [[ $PREFIX = -* ]] && return 1 + __docker_nodes all "role=worker" "$@" } -__stats() { - __docker_containers +__docker_node_commands() { + local -a _docker_node_subcommands + _docker_node_subcommands=( + "demote:Demote a node as manager in the swarm" + "inspect:Display detailed information on one or more nodes" + "ls:List nodes in the swarm" + "promote:Promote a node as manager in the swarm" + "rm:Remove one or more nodes from the swarm" + "ps:List tasks running on a node" + "update:Update a node" + ) + _describe -t docker-node-commands "docker node command" _docker_node_subcommands } -__stop() { - _arguments \ - '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]' - __docker_containers +__docker_node_subcommand() { + local -a _command_args opts_help + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + + case "$words[1]" in + (rm|remove) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--force[Force remove an active node]" \ + "($help -)*:node:__docker_complete_pending_nodes" && ret=0 + ;; + (demote) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:node:__docker_complete_manager_nodes" && ret=0 + ;; + (inspect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ + "($help)--pretty[Print the information in a human friendly format]" \ + "($help -)*:node:__docker_complete_nodes" && ret=0 + ;; + (ls|list) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 + case $state in + (filter-options) + __docker_node_complete_ls_filters && ret=0 + ;; + esac + ;; + (promote) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:node:__docker_complete_worker_nodes" && ret=0 + ;; + (ps) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Display all instances]" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)--no-resolve[Do not map IDs to Names]" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -)1:node:__docker_complete_nodes" && ret=0 + case $state in + (filter-options) + __docker_node_complete_ps_filters && ret=0 + ;; + esac + ;; + (update) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--availability=[Availability of the node]:availability:(active pause drain)" \ + "($help)*--label-add=[Add or update a node label]:key=value: " \ + "($help)*--label-rm=[Remove a node label if exists]:label: " \ + "($help)--role=[Role of the node]:role:(manager worker)" \ + "($help -)1:node:__docker_complete_nodes" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_node_commands" && ret=0 + ;; + esac + + return ret } -__tag() { - _arguments \ - '(-f,--force=)'{-f,--force=}'[Force]' - __docker_images +# EO node + +# BO plugin + +__docker_complete_plugins() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local line s + declare -a lines plugins + + lines=(${(f)"$(_call_program commands docker $docker_options plugin ls)"}) + + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + 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 + end[${header[$i,$((j-1))]}]=-1 + lines=(${lines[2,-1]}) + + # Name + for line in $lines; do + s="${line[${begin[NAME]},${end[NAME]}]%% ##}" + s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}" + plugins=($plugins $s) + done + + _describe -t plugins-list "plugins" plugins "$@" && ret=0 + return ret } -__version() { - # no arguments +__docker_plugin_commands() { + local -a _docker_plugin_subcommands + _docker_plugin_subcommands=( + "disable:Disable a plugin" + "enable:Enable a plugin" + "inspect:Return low-level information about a plugin" + "install:Install a plugin" + "ls:List plugins" + "push:Push a plugin" + "rm:Remove a plugin" + "set:Change settings for a plugin" + ) + _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands } -__wait() { - __docker_containers +__docker_plugin_subcommand() { + local -a _command_args opts_help + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + + case "$words[1]" in + (disable|enable|inspect|install|ls|push|rm) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)1:plugin:__docker_complete_plugins" && ret=0 + ;; + (set) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)1:plugin:__docker_complete_plugins" \ + "($help-)*:key=value: " && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0 + ;; + esac + + return ret } -__exec() { - _arguments \ - '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \ - '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ - '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]' - __docker_containers +# EO plugin + +# BO service + +__docker_service_complete_ls_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (id) + __docker_complete_services_ids && ret=0 + ;; + (name) + __docker_complete_services_names && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('id' 'label' 'name') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret } -# end commands --------- -# ---------------------- +__docker_service_complete_ps_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 -local -a _1st_arguments -_1st_arguments=( - "attach":"Attach to a running container" - "build":"Build a container from a Dockerfile" - "commit":"Create a new image from a container's changes" - "cp":"Copy files/folders from the containers filesystem to the host path" - "create":"Create new container without running it" - "diff":"Inspect changes on a container's filesystem" - "events":"Get real time events from the server" - "export":"Stream the contents of a container as a tar archive" - "history":"Show the history of an image" - "images":"List images" - "import":"Create a new filesystem image from the contents of a tarball" - "info":"Display system-wide information" - "inspect":"Return low-level information on a container" - "kill":"Kill a running container" - "load":"Load an image from a tar archive" - "login":"Register or Login to the docker registry server" - "logs":"Fetch the logs of a container" - "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT" - "ps":"List containers" - "pull":"Pull an image or a repository from the docker registry server" - "push":"Push an image or a repository to the docker registry server" - "restart":"Restart a running container" - "rm":"Remove one or more containers" - "rmi":"Remove one or more images" - "run":"Run a command in a new container" - "save":"Save an image to a tar archive" - "search":"Search for an image in the docker index" - "start":"Start a stopped container" - "stats":"Display a live stream of one or more containers' resource usage statistics" - "stop":"Stop a running container" - "tag":"Tag an image into a repository" - "top":"Lookup the running processes of a container" - "version":"Show the docker version information" - "wait":"Block until a container stops, then print its exit code" - "exec":"Run a task inside a running container" -) + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (desired-state) + state_opts=('accepted' 'running') + _describe -t state-opts "desired state options" state_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('desired-state' 'id' 'label' 'name') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi -_arguments '*:: :->command' + return ret +} -if (( CURRENT == 1 )); then - _describe -t commands "docker command" _1st_arguments - return -fi +__docker_services() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local line s + declare -a lines services -local -a _command_args -case "$words[1]" in - attach) - __attach ;; - build) - __build ;; - commit) - __commit ;; - cp) - __cp ;; - create) - __create ;; - diff) - __diff ;; - events) - __events ;; - export) - __export ;; - history) - __history ;; - images) - __images ;; - import) - __import ;; - info) - __info ;; - inspect) - __inspect ;; - kill) - __kill ;; - load) - __load ;; - login) - __login ;; - logs) - __logs ;; - port) - __port ;; - ps) - __ps ;; - pull) - __pull ;; - push) - __push ;; - restart) - __restart ;; - rm) - __rm ;; - rmi) - __rmi ;; - run) - __run ;; - save) - __save ;; - search) - __search ;; - stats) - __stats ;; - start) - __start ;; - stop) - __stop ;; - tag) - __tag ;; - top) - __top ;; - version) - __version ;; - wait) - __wait ;; - exec) - __exec ;; -esac + type=$1; shift + + lines=(${(f)"$(_call_program commands docker $docker_options service ls)"}) + + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + 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 + end[${header[$i,$((j-1))]}]=-1 + lines=(${lines[2,-1]}) + + # Service ID + if [[ $type = (ids|all) ]]; then + for line in $lines; do + s="${line[${begin[ID]},${end[ID]}]%% ##}" + s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}" + services=($services $s) + done + fi + + # Names + if [[ $type = (names|all) ]]; then + for line in $lines; do + s="${line[${begin[NAME]},${end[NAME]}]%% ##}" + s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}" + services=($services $s) + done + fi + + _describe -t services-list "services" services "$@" && ret=0 + return ret +} + +__docker_complete_services() { + [[ $PREFIX = -* ]] && return 1 + __docker_services all "$@" +} + +__docker_complete_services_ids() { + [[ $PREFIX = -* ]] && return 1 + __docker_services ids "$@" +} + +__docker_complete_services_names() { + [[ $PREFIX = -* ]] && return 1 + __docker_services names "$@" +} + +__docker_service_commands() { + local -a _docker_service_subcommands + _docker_service_subcommands=( + "create:Create a new service" + "inspect:Display detailed information on one or more services" + "ls:List services" + "rm:Remove one or more services" + "scale:Scale one or multiple services" + "ps:List the tasks of a service" + "update:Update a service" + ) + _describe -t docker-service-commands "docker service command" _docker_service_subcommands +} + +__docker_service_subcommand() { + local -a _command_args opts_help opts_create_update + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + opts_create_update=( + "($help)*--constraint=[Placement constraints]:constraint: " + "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" + "($help)*"{-e=,--env=}"[Set environment variables]:env: " + "($help)*--label=[Service labels]:label: " + "($help)--limit-cpu=[Limit CPUs]:value: " + "($help)--limit-memory=[Limit Memory]:value: " + "($help)--log-driver=[Logging driver for service]:logging driver:__docker_log_drivers" + "($help)*--log-opt=[Logging driver options]:log driver options:__docker_log_options" + "($help)*--mount=[Attach a mount to the service]:mount: " + "($help)--name=[Service name]:name: " + "($help)*--network=[Network attachments]:network: " + "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: " + "($help)--replicas=[Number of tasks]:replicas: " + "($help)--reserve-cpu=[Reserve CPUs]:value: " + "($help)--reserve-memory=[Reserve Memory]:value: " + "($help)--restart-condition=[Restart when condition is met]:mode:(any none on-failure)" + "($help)--restart-delay=[Delay between restart attempts]:delay: " + "($help)--restart-max-attempts=[Maximum number of restarts before giving up]:max-attempts: " + "($help)--restart-window=[Window used to evaluate the restart policy]:window: " + "($help)--stop-grace-period=[Time to wait before force killing a container]:grace period: " + "($help)--update-delay=[Delay between updates]:delay: " + "($help)--update-failure-action=[Action on update failure]:mode:(pause continue)" + "($help)--update-parallelism=[Maximum number of tasks updated simultaneously]:number: " + "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" + "($help)--with-registry-auth[Send registry authentication details to swarm agents]" + "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" + ) + + case "$words[1]" in + (create) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_create_update \ + "($help)*--container-label=[Container labels]:label: " \ + "($help)--mode=[Service Mode]:mode:(global replicated)" \ + "($help -): :__docker_images" \ + "($help -):command: _command_names -e" \ + "($help -)*::arguments: _normal" && ret=0 + ;; + (inspect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ + "($help)--pretty[Print the information in a human friendly format]" \ + "($help -)*:service:__docker_complete_services" && ret=0 + ;; + (ls|list) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:->filter-options" \ + "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 + case $state in + (filter-options) + __docker_service_complete_ls_filters && ret=0 + ;; + esac + ;; + (rm|remove) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:service:__docker_complete_services" && ret=0 + ;; + (scale) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:service:->values" && ret=0 + case $state in + (values) + if compset -P '*='; then + _message 'replicas' && ret=0 + else + __docker_complete_services -qS "=" + fi + ;; + esac + ;; + (ps) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Display all tasks]" \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)--no-resolve[Do not map IDs to Names]" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -)1:service:__docker_complete_services" && ret=0 + case $state in + (filter-options) + __docker_service_complete_ps_filters && ret=0 + ;; + esac + ;; + (update) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_create_update \ + "($help)--arg=[Service command args]:arguments: _normal" \ + "($help)*--container-label-add=[Add or update container labels]:label: " \ + "($help)*--container-label-rm=[Remove a container label by its key]:label: " \ + "($help)--image=[Service image tag]:image:__docker_repositories" \ + "($help -)1:service:__docker_complete_services" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_service_commands" && ret=0 + ;; + esac + + return ret +} + +# EO service + +# BO swarm + +__docker_swarm_commands() { + local -a _docker_swarm_subcommands + _docker_swarm_subcommands=( + "init:Initialize a swarm" + "join:Join a swarm as a node and/or manager" + "join-token:Manage join tokens" + "leave:Leave a swarm" + "update:Update the swarm" + ) + _describe -t docker-swarm-commands "docker swarm command" _docker_swarm_subcommands +} + +__docker_swarm_subcommand() { + local -a _command_args opts_help + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + + case "$words[1]" in + (init) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--advertise-addr[Advertised address]:ip\:port: " \ + "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \ + "($help)--force-new-cluster[Force create a new cluster from current state]" \ + "($help)--listen-addr=[Listen address]:ip\:port: " && ret=0 + ;; + (join) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--advertise-addr[Advertised address]:ip\:port: " \ + "($help)--listen-addr=[Listen address]:ip\:port: " \ + "($help)--token=[Token for entry into the swarm]:secret: " \ + "($help -):host\:port: " && ret=0 + ;; + (join-token) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -q --quiet)"{-q,--quiet}"[Only display token]" \ + "($help)--rotate[Rotate join token]" \ + "($help -):role:(manager worker)" && ret=0 + ;; + (leave) + _arguments $(__docker_arguments) \ + $opts_help && ret=0 + ;; + (update) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--cert-expiry=[Validity period for node certificates]:duration: " \ + "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \ + "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0 + ;; + esac + + return ret +} + +# EO swarm + +# BO volume + +__docker_volume_complete_ls_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (dangling) + dangling_opts=('true' 'false') + _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0 + ;; + (driver) + __docker_complete_info_plugins Volume && ret=0 + ;; + (name) + __docker_volumes && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('dangling' 'driver' 'label' 'name') + _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 + fi + + return ret +} + +__docker_volumes() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a lines volumes + + lines=(${(f)"$(_call_program commands docker $docker_options volume ls)"}) + + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + 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 + end[${header[$i,$((j-1))]}]=-1 + lines=(${lines[2,-1]}) + + # Names + local line s + for line in $lines; do + s="${line[${begin[VOLUME NAME]},${end[VOLUME NAME]}]%% ##}" + s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" + volumes=($volumes $s) + done + + _describe -t volumes-list "volumes" volumes && ret=0 + return ret +} + +__docker_volume_commands() { + local -a _docker_volume_subcommands + _docker_volume_subcommands=( + "create:Create a volume" + "inspect:Display detailed information on one or more volumes" + "ls:List volumes" + "rm:Remove one or more volumes" + ) + _describe -t docker-volume-commands "docker volume command" _docker_volume_subcommands +} + +__docker_volume_subcommand() { + local -a _command_args opts_help + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + + case "$words[1]" in + (create) + _arguments $(__docker_arguments) -A '-*' \ + $opts_help \ + "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \ + "($help)*--label=[Set metadata for a volume]:label=value: " \ + "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \ + "($help -)1:Volume name: " && ret=0 + ;; + (inspect) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ + "($help -)1:volume:__docker_volumes" && ret=0 + ;; + (ls) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)--format=[Pretty-print volumes using a Go template]:template: " \ + "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 + case $state in + (filter-options) + __docker_volume_complete_ls_filters && ret=0 + ;; + esac + ;; + (rm) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \ + "($help -):volume:__docker_volumes" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0 + ;; + esac + + return ret +} + +# EO volume + +__docker_caching_policy() { + oldp=( "$1"(Nmh+1) ) # 1 hour + (( $#oldp )) +} + +__docker_commands() { + local cache_policy + + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy + fi + + if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \ + && ! _retrieve_cache docker_subcommands; + then + local -a lines + lines=(${(f)"$(_call_program commands docker 2>&1)"}) + _docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) + _docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command') + (( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands + fi + _describe -t docker-commands "docker command" _docker_subcommands +} + +__docker_subcommand() { + local -a _command_args opts_help opts_build_create_run opts_build_create_run_update opts_create_run opts_create_run_update + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + opts_build_create_run=( + "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " + "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" + "($help)--disable-content-trust[Skip image verification]" + "($help)*--shm-size=[Size of '/dev/shm' (format is '')]:shm size: " + "($help)*--ulimit=[ulimit options]:ulimit: " + "($help)--userns=[Container user namespace]:user namespace:(host)" + ) + opts_build_create_run_update=( + "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" + "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " + "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " + "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " + "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " + "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " + "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " + ) + opts_create_run=( + "($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)" + "($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: " + "($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: " + "($help)*--cap-add=[Add Linux capabilities]:capability: " + "($help)*--cap-drop=[Drop Linux capabilities]:capability: " + "($help)--cidfile=[Write the container ID to the file]:CID file:_files" + "($help)*--device=[Add a host device to the container]:device:_files" + "($help)*--device-read-bps=[Limit the read rate (bytes per second) from a device]:device:IO rate: " + "($help)*--device-read-iops=[Limit the read rate (IO per second) from a device]:device:IO rate: " + "($help)*--device-write-bps=[Limit the write rate (bytes per second) to a device]:device:IO rate: " + "($help)*--device-write-iops=[Limit the write rate (IO per second) to a device]:device:IO rate: " + "($help)*--dns=[Custom DNS servers]:DNS server: " + "($help)*--dns-opt=[Custom DNS options]:DNS option: " + "($help)*--dns-search=[Custom DNS search domains]:DNS domains: " + "($help)*"{-e=,--env=}"[Environment variables]:environment variable: " + "($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: " + "($help)*--env-file=[Read environment variables from a file]:environment file:_files" + "($help)*--expose=[Expose a port from the container without publishing it]: " + "($help)*--group-add=[Add additional groups to run as]:group:_groups" + "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts" + "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" + "($help)--ip=[Container IPv4 address]:IPv4: " + "($help)--ip6=[Container IPv6 address]:IPv6: " + "($help)--ipc=[IPC namespace to use]:IPC namespace: " + "($help)*--link=[Add link to another container]:link:->link" + "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " + "($help)*"{-l=,--label=}"[Container metadata]:label: " + "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers" + "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options" + "($help)--mac-address=[Container MAC address]:MAC address: " + "($help)--name=[Container name]:name: " + "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" + "($help)*--network-alias=[Add network-scoped alias for the container]:alias: " + "($help)--oom-kill-disable[Disable OOM Killer]" + "($help)--oom-score-adj[Tune the host's OOM preferences for containers (accepts -1000 to 1000)]" + "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]" + "($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]" + "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports" + "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid" + "($help)--privileged[Give extended privileges to this container]" + "($help)--read-only[Mount the container's root filesystem as read only]" + "($help)*--security-opt=[Security options]:security option: " + "($help)*--sysctl=-[sysctl options]:sysctl: " + "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" + "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" + "($help)--tmpfs[mount tmpfs]" + "($help)*-v[Bind mount a volume]:volume: " + "($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)" + "($help)*--volumes-from=[Mount volumes from the specified container]:volume: " + "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" + ) + opts_create_run_update=( + "($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)" + "($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: " + "($help)--memory-reservation=[Memory soft limit]:Memory limit: " + "($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)" + ) + opts_attach_exec_run_start=( + "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys" + ) + + case "$words[1]" in + (attach) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_attach_exec_run_start \ + "($help)--no-stdin[Do not attach stdin]" \ + "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ + "($help -):containers:__docker_runningcontainers" && ret=0 + ;; + (build) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_build_create_run \ + $opts_build_create_run_update \ + "($help)*--build-arg[Build-time variables]:=: " \ + "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \ + "($help)--force-rm[Always remove intermediate containers]" \ + "($help)*--label=[Set metadata for an image]:label=value: " \ + "($help)--no-cache[Do not use cache when building the image]" \ + "($help)--pull[Attempt to pull a newer version of the image]" \ + "($help -q --quiet)"{-q,--quiet}"[Suppress verbose build output]" \ + "($help)--rm[Remove intermediate containers after a successful build]" \ + "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_repositories_with_tags" \ + "($help -):path or URL:_directories" && ret=0 + ;; + (commit) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --author)"{-a=,--author=}"[Author]:author: " \ + "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ + "($help -m --message)"{-m=,--message=}"[Commit message]:message: " \ + "($help -p --pause)"{-p,--pause}"[Pause container during commit]" \ + "($help -):container:__docker_containers" \ + "($help -): :__docker_repositories_with_tags" && ret=0 + ;; + (cp) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -L --follow-link)"{-L,--follow-link}"[Always follow symbol link]" \ + "($help -)1:container:->container" \ + "($help -)2:hostpath:_files" && ret=0 + case $state in + (container) + if compset -P "*:"; then + _files && ret=0 + else + __docker_containers -qS ":" && ret=0 + fi + ;; + esac + ;; + (create) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_build_create_run \ + $opts_build_create_run_update \ + $opts_create_run \ + $opts_create_run_update \ + "($help -): :__docker_images" \ + "($help -):command: _command_names -e" \ + "($help -)*::arguments: _normal" && ret=0 + + case $state in + (link) + if compset -P "*:"; then + _wanted alias expl "Alias" compadd -E "" && ret=0 + else + __docker_runningcontainers -qS ":" && ret=0 + fi + ;; + esac + + ;; + (daemon) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*--add-runtime=[Register an additional OCI compatible runtime]:runtime:__docker_complete_runtimes" \ + "($help)--api-cors-header=[CORS headers in the remote API]:CORS headers: " \ + "($help)*--authorization-plugin=[Authorization plugins to load]" \ + "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \ + "($help)--bip=[Network bridge IP]:IP address: " \ + "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \ + "($help)--config-file=[Path to daemon configuration file]:Config File:_files" \ + "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \ + "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ + "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \ + "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \ + "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \ + "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \ + "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \ + "($help)*--dns=[DNS server to use]:DNS: " \ + "($help)*--dns-search=[DNS search domains to use]:DNS search: " \ + "($help)*--dns-opt=[DNS options to use]:DNS option: " \ + "($help)*--default-ulimit=[Default ulimits for containers]:ulimit: " \ + "($help)--disable-legacy-registry[Disable contacting legacy registries]" \ + "($help)*--exec-opt=[Runtime execution options]:runtime execution options: " \ + "($help)--exec-root=[Root directory for execution state files]:path:_directories" \ + "($help)--fixed-cidr=[IPv4 subnet for fixed IPs]:IPv4 subnet: " \ + "($help)--fixed-cidr-v6=[IPv6 subnet for fixed IPs]:IPv6 subnet: " \ + "($help -G --group)"{-G=,--group=}"[Group for the unix socket]:group:_groups" \ + "($help -g --graph)"{-g=,--graph=}"[Root of the Docker runtime]:path:_directories" \ + "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ + "($help)--icc[Enable inter-container communication]" \ + "($help)*--insecure-registry=[Enable insecure registry communication]:registry: " \ + "($help)--ip=[Default IP when binding container ports]" \ + "($help)--ip-forward[Enable net.ipv4.ip_forward]" \ + "($help)--ip-masq[Enable IP masquerading]" \ + "($help)--iptables[Enable addition of iptables rules]" \ + "($help)--ipv6[Enable IPv6 networking]" \ + "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ + "($help)*--label=[Key=value labels]:label: " \ + "($help)--live-restore[Enable live restore of docker when containers are still running]" \ + "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers" \ + "($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_log_options" \ + "($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \ + "($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \ + "($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \ + "($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \ + "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \ + "($help)--raw-logs[Full timestamps without ANSI coloring]" \ + "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \ + "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \ + "($help)--selinux-enabled[Enable selinux support]" \ + "($help)*--storage-opt=[Storage driver options]:storage driver options: " \ + "($help)--tls[Use TLS]" \ + "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g \"*.(pem|crt)\"" \ + "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g \"*.(pem|crt)\"" \ + "($help)--tlskey=[Path to TLS key file]:Key file:_files -g \"*.(pem|key)\"" \ + "($help)--tlsverify[Use TLS and verify the remote]" \ + "($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \ + "($help)--userland-proxy[Use userland proxy for loopback traffic]" && ret=0 + + case $state in + (cluster-store) + if compset -P '*://'; then + _message 'host:port' && ret=0 + else + store=('consul' 'etcd' 'zk') + _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0 + fi + ;; + (cluster-store-options) + if compset -P '*='; then + _files && ret=0 + else + opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path') + _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0 + fi + ;; + (users-groups) + if compset -P '*:'; then + _groups && ret=0 + else + _describe -t userns-default "default Docker user management" '(default)' && ret=0 + _users && ret=0 + fi + ;; + esac + ;; + (diff) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:containers:__docker_containers" && ret=0 + ;; + (events) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \ + "($help)--since=[Events created since this timestamp]:timestamp: " \ + "($help)--until=[Events created until this timestamp]:timestamp: " && ret=0 + ;; + (exec) + local state + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_attach_exec_run_start \ + "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ + "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \ + "($help)--privileged[Give extended Linux capabilities to the command]" \ + "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \ + "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \ + "($help -):containers:__docker_runningcontainers" \ + "($help -)*::command:->anycommand" && ret=0 + + case $state in + (anycommand) + shift 1 words + (( CURRENT-- )) + _normal && ret=0 + ;; + esac + ;; + (export) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \ + "($help -)*:containers:__docker_containers" && ret=0 + ;; + (history) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -)*: :__docker_images" && ret=0 + ;; + (images) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Show all images]" \ + "($help)--digests[Show digests]" \ + "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ + "($help)--format[Pretty-print containers using a Go template]:template: " \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -): :__docker_repositories" && ret=0 + + case $state in + (filter-options) + __docker_complete_images_filters && ret=0 + ;; + esac + ;; + (import) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ + "($help -m --message)"{-m=,--message=}"[Commit message for imported image]:message: " \ + "($help -):URL:(- http:// file://)" \ + "($help -): :__docker_repositories_with_tags" && ret=0 + ;; + (info|version) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0 + ;; + (inspect) + local state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ + "($help -s --size)"{-s,--size}"[Display total file sizes if the type is container]" \ + "($help)--type=[Return JSON for specified type]:type:(image container)" \ + "($help -)*: :->values" && ret=0 + + case $state in + (values) + if [[ ${words[(r)--type=container]} == --type=container ]]; then + __docker_containers && ret=0 + elif [[ ${words[(r)--type=image]} == --type=image ]]; then + __docker_images && ret=0 + else + __docker_images && __docker_containers && ret=0 + fi + ;; + esac + ;; + (kill) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \ + "($help -)*:containers:__docker_runningcontainers" && ret=0 + ;; + (load) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -i --input)"{-i=,--input=}"[Read from tar archive file]:archive file:_files -g \"*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)\"" \ + "($help -q --quiet)"{-q,--quiet}"[Suppress the load output]" && ret=0 + ;; + (login) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -p --password)"{-p=,--password=}"[Password]:password: " \ + "($help -u --user)"{-u=,--user=}"[Username]:username: " \ + "($help -)1:server: " && ret=0 + ;; + (logout) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)1:server: " && ret=0 + ;; + (logs) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--details[Show extra details provided to logs]" \ + "($help -f --follow)"{-f,--follow}"[Follow log output]" \ + "($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \ + "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \ + "($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \ + "($help -)*:containers:__docker_containers" && ret=0 + ;; + (network) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_network_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_network_subcommand && ret=0 + ;; + esac + ;; + (node) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_node_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_node_subcommand && ret=0 + ;; + esac + ;; + (pause|unpause) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:containers:__docker_runningcontainers" && ret=0 + ;; + (plugin) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_plugin_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_plugin_subcommand && ret=0 + ;; + esac + ;; + (port) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)1:containers:__docker_runningcontainers" \ + "($help -)2:port:_ports" && ret=0 + ;; + (ps) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Show all containers]" \ + "($help)--before=[Show only container created before...]:containers:__docker_containers" \ + "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ + "($help)--format[Pretty-print containers using a Go template]:template: " \ + "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ + "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -s --size)"{-s,--size}"[Display total file sizes]" \ + "($help)--since=[Show only containers created since...]:containers:__docker_containers" && ret=0 + ;; + (pull) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all-tags)"{-a,--all-tags}"[Download all tagged images]" \ + "($help)--disable-content-trust[Skip image verification]" \ + "($help -):name:__docker_search" && ret=0 + ;; + (push) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--disable-content-trust[Skip image signing]" \ + "($help -): :__docker_images" && ret=0 + ;; + (rename) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -):old name:__docker_containers" \ + "($help -):new name: " && ret=0 + ;; + (restart|stop) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \ + "($help -)*:containers:__docker_runningcontainers" && ret=0 + ;; + (rm) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --force)"{-f,--force}"[Force removal]" \ + "($help -l --link)"{-l,--link}"[Remove the specified link and not the underlying container]" \ + "($help -v --volumes)"{-v,--volumes}"[Remove the volumes associated to the container]" \ + "($help -)*:containers:->values" && ret=0 + case $state in + (values) + if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then + __docker_containers && ret=0 + else + __docker_stoppedcontainers && ret=0 + fi + ;; + esac + ;; + (rmi) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -f --force)"{-f,--force}"[Force removal]" \ + "($help)--no-prune[Do not delete untagged parents]" \ + "($help -)*: :__docker_images" && ret=0 + ;; + (run) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_build_create_run \ + $opts_build_create_run_update \ + $opts_create_run \ + $opts_create_run_update \ + $opts_attach_exec_run_start \ + "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ + "($help)--health-cmd=[Command to run to check health]:command: " \ + "($help)--health-interval=[Time between running the check]:time: " \ + "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" \ + "($help)--health-timeout=[Maximum time to allow one check to run]:time: " \ + "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" \ + "($help)--rm[Remove intermediate containers when it exits]" \ + "($help)--runtime=[Name of the runtime to be used for that container]:runtime:__docker_complete_runtimes" \ + "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ + "($help)--stop-signal=[Signal to kill a container]:signal:_signals" \ + "($help)--storage-opt=[Storage driver options for the container]:storage options:->storage-opt" \ + "($help -): :__docker_images" \ + "($help -):command: _command_names -e" \ + "($help -)*::arguments: _normal" && ret=0 + + case $state in + (link) + if compset -P "*:"; then + _wanted alias expl "Alias" compadd -E "" && ret=0 + else + __docker_runningcontainers -qS ":" && ret=0 + fi + ;; + (storage-opt) + if compset -P "*="; then + _message "value" && ret=0 + else + opts=('size') + _describe -t filter-opts "storage options" opts -qS "=" && ret=0 + fi + ;; + esac + + ;; + (save) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -o --output)"{-o=,--output=}"[Write to file]:file:_files" \ + "($help -)*: :__docker_images" && ret=0 + ;; + (search) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ + "($help)--limit=[Maximum returned search results]:limit:(1 5 10 25 50)" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -):term: " && ret=0 + + case $state in + (filter-options) + __docker_complete_search_filters && ret=0 + ;; + esac + ;; + (service) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_service_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_service_subcommand && ret=0 + ;; + esac + ;; + (start) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_attach_exec_run_start \ + "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \ + "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \ + "($help -)*:containers:__docker_stoppedcontainers" && ret=0 + ;; + (stats) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ + "($help)--no-stream[Disable streaming stats and only pull the first result]" \ + "($help -)*:containers:__docker_runningcontainers" && ret=0 + ;; + (swarm) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_swarm_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_swarm_subcommand && ret=0 + ;; + esac + ;; + (tag) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -):source:__docker_images"\ + "($help -):destination:__docker_repositories_with_tags" && ret=0 + ;; + (top) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)1:containers:__docker_runningcontainers" \ + "($help -)*:: :->ps-arguments" && ret=0 + case $state in + (ps-arguments) + _ps && ret=0 + ;; + esac + + ;; + (update) + _arguments $(__docker_arguments) \ + $opts_help \ + $opts_create_run_update \ + $opts_build_create_run_update \ + "($help -)*: :->values" && ret=0 + + case $state in + (values) + if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then + __docker_stoppedcontainers && ret=0 + else + __docker_containers && ret=0 + fi + ;; + esac + ;; + (volume) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_volume_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_volume_subcommand && ret=0 + ;; + esac + ;; + (wait) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -)*:containers:__docker_runningcontainers" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0 + ;; + esac + + return ret +} + +_docker() { + # 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 ]]; then + _call_function - _$service + return + fi + + local curcontext="$curcontext" state line help="-h --help" + integer ret=1 + typeset -A opt_args + + _arguments $(__docker_arguments) -C \ + "(: -)"{-h,--help}"[Print usage]" \ + "($help)--config[Location of client config files]:path:_directories" \ + "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ + "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ + "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ + "($help)--tls[Use TLS]" \ + "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g "*.(pem|crt)"" \ + "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g "*.(pem|crt)"" \ + "($help)--tlskey=[Path to TLS key file]:Key file:_files -g "*.(pem|key)"" \ + "($help)--tlsverify[Use TLS and verify the remote]" \ + "($help)--userland-proxy[Use userland proxy for loopback traffic]" \ + "($help -v --version)"{-v,--version}"[Print version information and quit]" \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + local host=${opt_args[-H]}${opt_args[--host]} + local config=${opt_args[--config]} + local docker_options="${host:+--host $host} ${config:+--config $config}" + + case $state in + (command) + __docker_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-$words[1]: + __docker_subcommand && ret=0 + ;; + esac + + return ret +} + +_dockerd() { + integer ret=1 + words[1]='daemon' + __docker_subcommand && ret=0 + return ret +} + +_docker "$@" + +# 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 From 03e7f93ec796e68ac36d7b52a3b6885092b4bfa5 Mon Sep 17 00:00:00 2001 From: kenleytomlin Date: Tue, 30 Aug 2016 08:58:31 +0100 Subject: [PATCH 002/121] Update README --- plugins/docker/README.md | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/plugins/docker/README.md b/plugins/docker/README.md index 231a6dcf..1615f75f 100644 --- a/plugins/docker/README.md +++ b/plugins/docker/README.md @@ -1,19 +1,5 @@ ## Docker autocomplete plugin -- Adds autocomplete options for all docker commands. -- Will also show containerIDs and Image names where applicable - -####Shows help for all commands -![General Help](http://i.imgur.com/tUBO9jh.png "Help for all commands") - - -####Shows your downloaded images where applicable -![Images](http://i.imgur.com/R8ZsWO1.png "Images") - - -####Shows your running containers where applicable -![Containers](http://i.imgur.com/WQtbheg.png "Containers") - - - -Maintainer : Ahmed Azaan ([@aeonazaan](https://twitter.com/aeonazaan)) +A copy of the completion script from the +[docker](https://github.com/docker/docker/tree/master/contrib/completion/zsh) +git repo. From 9248052e917a1d9296d4b79fa229b081cefbc698 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:31:49 +0430 Subject: [PATCH 003/121] initial spotify control --- plugins/osx/osx.plugin.zsh | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a3e55097..948d69a2 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -261,6 +261,104 @@ EOF osascript -e "tell application \"iTunes\" to $opt" } +# Spotify control function +function spotify() { + showHelp () { + echo "Usage:"; + echo; + echo " $(basename "$0") "; + echo; + echo "Commands:"; + echo; + echo " play # Resumes playback where Spotify last left off."; + echo " pause # Pauses Spotify playback."; + echo " next # Skips to the next song in a playlist."; + echo " prev # Returns to the previous song in a playlist."; + echo " pos [time] # Jumps to a time (in secs) in the current song."; + echo " quit # Stops playback and quits Spotify."; + echo; + echo " vol [amount] # Sets the volume to an amount between 0 and 100."; + echo " vol show # Shows the current Spotify volume."; + echo; + echo " toggle shuffle # Toggles shuffle playback mode."; + echo " toggle repeat # Toggles repeat playback mode."; + } + + if [ $# = 0 ]; then + showHelp; + else + if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then + osascript -e 'tell application "Spotify" to activate' + sleep 2 + fi + fi + + while [ $# -gt 0 ]; do + arg=$1; + + case $arg in + "play" ) + echo "Playing Spotify."; + osascript -e 'tell application "Spotify" to play'; + break ;; + + "pause" ) + echo "Pausing Spotify."; + osascript -e 'tell application "Spotify" to pause'; + break ;; + + "quit" ) + echo "Quitting Spotify."; + osascript -e 'tell application "Spotify" to quit'; + exit 1 ;; + + "next" ) + echo "Going to next track." ; + osascript -e 'tell application "Spotify" to next track'; + break ;; + + "prev" ) + echo "Going to previous track."; + osascript -e 'tell application "Spotify" to previous track'; + break ;; + + "vol" ) + vol=$(osascript -e 'tell application "Spotify" to sound volume as integer'); + if [[ "$2" = "show" || "$2" = "" ]]; then + echo "Current Spotify volume level is $vol."; + break ; + elif [ "$2" -ge 0 ]; then + newvol=$2; + fi + + osascript -e "tell application \"Spotify\" to set sound volume to $newvol"; + break ;; + + "toggle" ) + if [ "$2" = "shuffle" ]; then + osascript -e 'tell application "Spotify" to set shuffling to not shuffling'; + curr=$(osascript -e 'tell application "Spotify" to shuffling'); + echo "Spotify shuffling set to $curr"; + elif [ "$2" = "repeat" ]; then + osascript -e 'tell application "Spotify" to set repeating to not repeating'; + curr=$(osascript -e 'tell application "Spotify" to repeating'); + echo "Spotify repeating set to $curr"; + fi + break ;; + + "pos" ) + echo "Adjusting Spotify play position." + osascript -e "tell application \"Spotify\" to set player position to $2"; + break;; + + -h|--help| *) + showHelp; + break ;; + esac + done +} + + # Show/hide hidden files in the Finder alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" From 8f47c96453a229ad5488bbd1e4ee8b7c522b6a15 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:37:53 +0430 Subject: [PATCH 004/121] volume up/down added --- plugins/osx/osx.plugin.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 948d69a2..386507db 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -327,6 +327,22 @@ function spotify() { if [[ "$2" = "show" || "$2" = "" ]]; then echo "Current Spotify volume level is $vol."; break ; + elif [ "$2" = "up" ]; then + if [ "$vol" -le 90 ]; then + newvol=$(( vol+10 )); + echo "Increasing Spotify volume to $newvol."; + else + newvol=100; + echo "Spotify volume level is at max."; + fi + elif [ "$2" = "down" ]; then + if [ "$vol" -ge 10 ]; then + newvol=$(( vol-10 )); + echo "Reducing Spotify volume to $newvol."; + else + newvol=0; + echo "Spotify volume level is at min."; + fi elif [ "$2" -ge 0 ]; then newvol=$2; fi From 92586e38c72a4a3a112a5c2b13cca6fc250e7447 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:50:53 +0430 Subject: [PATCH 005/121] add info, share and status option --- plugins/osx/osx.plugin.zsh | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 386507db..dc68916b 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -263,6 +263,7 @@ EOF # Spotify control function function spotify() { + showHelp () { echo "Usage:"; echo; @@ -277,13 +278,35 @@ function spotify() { echo " pos [time] # Jumps to a time (in secs) in the current song."; echo " quit # Stops playback and quits Spotify."; echo; + echo " vol up # Increases the volume by 10%."; + echo " vol down # Decreases the volume by 10%."; echo " vol [amount] # Sets the volume to an amount between 0 and 100."; echo " vol show # Shows the current Spotify volume."; echo; + echo " status # Shows the current player status."; + echo " share # Copies the current song URL to the clipboard." + echo " info # Shows Full Information about song that is playing."; + echo; echo " toggle shuffle # Toggles shuffle playback mode."; echo " toggle repeat # Toggles repeat playback mode."; } + showStatus () { + state=$(osascript -e 'tell application "Spotify" to player state as string'); + echo "Spotify is currently $state."; + if [ "$state" = "playing" ]; then + artist=$(osascript -e 'tell application "Spotify" to artist of current track as string'); + album=$(osascript -e 'tell application "Spotify" to album of current track as string'); + track=$(osascript -e 'tell application "Spotify" to name of current track as string'); + duration=$(osascript -e 'tell application "Spotify" to duration of current track as string'); + duration=$(echo "scale=2; $duration / 60 / 1000" | bc); + position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); + position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); + + echo "$reset""Artist: $artist\nAlbum: $album\nTrack: $track \nPosition: $position / $duration"; + fi + } + if [ $# = 0 ]; then showHelp; else @@ -367,6 +390,51 @@ function spotify() { osascript -e "tell application \"Spotify\" to set player position to $2"; break;; + "status" ) + showStatus; + break ;; + + "info" ) + info=$(osascript -e 'tell application "Spotify" + set tM to round (duration of current track / 60) rounding down + set tS to duration of current track mod 60 + set pos to player position as text + set myTime to tM as text & "min " & tS as text & "s" + set nM to round (player position / 60) rounding down + set nS to round (player position mod 60) rounding down + set nowAt to nM as text & "min " & nS as text & "s" + set info to "" & "\nArtist: " & artist of current track + set info to info & "\nTrack: " & name of current track + set info to info & "\nAlbum Artist: " & album artist of current track + set info to info & "\nAlbum: " & album of current track + set info to info & "\nSeconds: " & duration of current track + set info to info & "\nSeconds played: " & pos + set info to info & "\nDuration: " & mytime + set info to info & "\nNow at: " & nowAt + set info to info & "\nPlayed Count: " & played count of current track + set info to info & "\nTrack Number: " & track number of current track + set info to info & "\nPopularity: " & popularity of current track + set info to info & "\nId: " & id of current track + set info to info & "\nSpotify URL: " & spotify url of current track + set info to info & "\nArtwork: " & artwork of current track + set info to info & "\nPlayer: " & player state + set info to info & "\nVolume: " & sound volume + set info to info & "\nShuffle: " & shuffling + set info to info & "\nRepeating: " & repeating + end tell + return info') + echo "$info"; + break ;; + + "share" ) + url=$(osascript -e 'tell application "Spotify" to spotify url of current track'); + remove='spotify:track:' + url=${url#$remove} + url="http://open.spotify.com/track/$url" + echo "Share URL: $url"; + echo -n "$url" | pbcopy + break;; + -h|--help| *) showHelp; break ;; From 2a5321f4e69b55f626c94993a40b1dee6a73c26f Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:56:21 +0430 Subject: [PATCH 006/121] add color echo --- plugins/osx/osx.plugin.zsh | 43 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index dc68916b..19acd3dd 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -263,7 +263,7 @@ EOF # Spotify control function function spotify() { - + showHelp () { echo "Usage:"; echo; @@ -291,9 +291,16 @@ function spotify() { echo " toggle repeat # Toggles repeat playback mode."; } + cecho(){ + bold=$(tput bold); + green=$(tput setaf 2); + reset=$(tput sgr0); + echo "$bold$green$1$reset"; + } + showStatus () { state=$(osascript -e 'tell application "Spotify" to player state as string'); - echo "Spotify is currently $state."; + cecho "Spotify is currently $state."; if [ "$state" = "playing" ]; then artist=$(osascript -e 'tell application "Spotify" to artist of current track as string'); album=$(osascript -e 'tell application "Spotify" to album of current track as string'); @@ -307,6 +314,8 @@ function spotify() { fi } + + if [ $# = 0 ]; then showHelp; else @@ -321,50 +330,50 @@ function spotify() { case $arg in "play" ) - echo "Playing Spotify."; + cecho "Playing Spotify."; osascript -e 'tell application "Spotify" to play'; break ;; "pause" ) - echo "Pausing Spotify."; + cecho "Pausing Spotify."; osascript -e 'tell application "Spotify" to pause'; break ;; "quit" ) - echo "Quitting Spotify."; + cecho "Quitting Spotify."; osascript -e 'tell application "Spotify" to quit'; exit 1 ;; "next" ) - echo "Going to next track." ; + cecho "Going to next track." ; osascript -e 'tell application "Spotify" to next track'; break ;; "prev" ) - echo "Going to previous track."; + cecho "Going to previous track."; osascript -e 'tell application "Spotify" to previous track'; break ;; "vol" ) vol=$(osascript -e 'tell application "Spotify" to sound volume as integer'); if [[ "$2" = "show" || "$2" = "" ]]; then - echo "Current Spotify volume level is $vol."; + cecho "Current Spotify volume level is $vol."; break ; elif [ "$2" = "up" ]; then if [ "$vol" -le 90 ]; then newvol=$(( vol+10 )); - echo "Increasing Spotify volume to $newvol."; + cecho "Increasing Spotify volume to $newvol."; else newvol=100; - echo "Spotify volume level is at max."; + cecho "Spotify volume level is at max."; fi elif [ "$2" = "down" ]; then if [ "$vol" -ge 10 ]; then newvol=$(( vol-10 )); - echo "Reducing Spotify volume to $newvol."; + cecho "Reducing Spotify volume to $newvol."; else newvol=0; - echo "Spotify volume level is at min."; + cecho "Spotify volume level is at min."; fi elif [ "$2" -ge 0 ]; then newvol=$2; @@ -377,16 +386,16 @@ function spotify() { if [ "$2" = "shuffle" ]; then osascript -e 'tell application "Spotify" to set shuffling to not shuffling'; curr=$(osascript -e 'tell application "Spotify" to shuffling'); - echo "Spotify shuffling set to $curr"; + cecho "Spotify shuffling set to $curr"; elif [ "$2" = "repeat" ]; then osascript -e 'tell application "Spotify" to set repeating to not repeating'; curr=$(osascript -e 'tell application "Spotify" to repeating'); - echo "Spotify repeating set to $curr"; + cecho "Spotify repeating set to $curr"; fi break ;; "pos" ) - echo "Adjusting Spotify play position." + cecho "Adjusting Spotify play position." osascript -e "tell application \"Spotify\" to set player position to $2"; break;; @@ -431,8 +440,8 @@ function spotify() { remove='spotify:track:' url=${url#$remove} url="http://open.spotify.com/track/$url" - echo "Share URL: $url"; - echo -n "$url" | pbcopy + cecho "Share URL: $url"; + cecho -n "$url" | pbcopy break;; -h|--help| *) From 96d57dc33ec7ce473a7ce06d7c0166eabd14e1c8 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:58:15 +0430 Subject: [PATCH 007/121] change pause to play/pause --- plugins/osx/osx.plugin.zsh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 19acd3dd..058576f0 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -335,8 +335,14 @@ function spotify() { break ;; "pause" ) - cecho "Pausing Spotify."; - osascript -e 'tell application "Spotify" to pause'; + state=$(osascript -e 'tell application "Spotify" to player state as string'); + if [ "$state" = "playing" ]; then + cecho "Pausing Spotify."; + else + cecho "Playing Spotify."; + fi + + osascript -e 'tell application "Spotify" to playpause'; break ;; "quit" ) From 3b2f827d5b37d51bdd0c165dc2b66501704990c4 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:12:13 +0430 Subject: [PATCH 008/121] add Search Option for album,artist and tracks --- plugins/osx/osx.plugin.zsh | 42 +++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 058576f0..03174063 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -330,9 +330,49 @@ function spotify() { case $arg in "play" ) + if [ $# != 1 ]; then + # There are additional arguments, so find out how many + array=( $@ ); + len=${#array[@]}; + SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search" + SPOTIFY_PLAY_URI=""; + + searchAndPlay() { + type="$1" + Q="$2" + + cecho "Searching ${type}s for: $Q"; + + SPOTIFY_PLAY_URI=$( \ + curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=$type&limit=1&offset=0" -H "Accept: application/json" \ + | grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1 + ) + } + + case $2 in + "album" | "artist" | "track" ) + _args=${array[*]:2:$len}; + searchAndPlay "$2" "$_args";; + + * ) + _args=${array[*]:1:$len}; + searchAndPlay track "$_args";; + esac + + if [ "$SPOTIFY_PLAY_URI" != "" ]; then + cecho "Playing ($Q Search) -> Spotify URL: $"; + + osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\""; + + else + cecho "No results when searching for $Q"; + fi + else + # play is the only param cecho "Playing Spotify."; osascript -e 'tell application "Spotify" to play'; - break ;; + fi + break ;; "pause" ) state=$(osascript -e 'tell application "Spotify" to player state as string'); From b808555678ea6a960d3ab31f1bdce4bd18ab0a10 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:18:22 +0430 Subject: [PATCH 009/121] add search option for playlist --- plugins/osx/osx.plugin.zsh | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 03174063..4ba2026c 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -350,6 +350,29 @@ function spotify() { } case $2 in + "list" ) + _args=${array[*]:2:$len}; + Q=$_args; + + cecho "Searching playlists for: $Q"; + + results=$( \ + curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" \ + | grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \ + ) + + count=$( \ + echo "$results" | grep -c "spotify:user" \ + ) + + if [ "$count" -gt 0 ]; then + random=$(( RANDOM % count)); + + SPOTIFY_PLAY_URI=$( \ + echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \ + ) + fi;; + "album" | "artist" | "track" ) _args=${array[*]:2:$len}; searchAndPlay "$2" "$_args";; @@ -367,12 +390,12 @@ function spotify() { else cecho "No results when searching for $Q"; fi - else - # play is the only param - cecho "Playing Spotify."; - osascript -e 'tell application "Spotify" to play'; - fi - break ;; + else + # play is the only param + cecho "Playing Spotify."; + osascript -e 'tell application "Spotify" to play'; + fi + break ;; "pause" ) state=$(osascript -e 'tell application "Spotify" to player state as string'); From 6cbba3353f20174c1cd55246507182dfab65ed97 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:35:29 +0430 Subject: [PATCH 010/121] fix showStatus output --- 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 4ba2026c..84eec9ee 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -310,7 +310,7 @@ function spotify() { position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); - echo "$reset""Artist: $artist\nAlbum: $album\nTrack: $track \nPosition: $position / $duration"; + printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; fi } From d099022e440a72b1352ac09773a1863d9833dbb1 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:41:54 +0430 Subject: [PATCH 011/121] complete help --- plugins/osx/osx.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 84eec9ee..d75e3d2d 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -272,6 +272,10 @@ function spotify() { echo "Commands:"; echo; echo " play # Resumes playback where Spotify last left off."; + echo " play [song name] # Finds a song by name and plays it."; + echo " play album [album name] # Finds an album by name and plays it."; + echo " play artist [artist name] # Finds an artist by name and plays it."; + echo " play list [playlist name] # Finds a playlist by name and plays it."; echo " pause # Pauses Spotify playback."; echo " next # Skips to the next song in a playlist."; echo " prev # Returns to the previous song in a playlist."; From f820345afa9d500f0ff6b1ad1c45d4d37ef7d88a Mon Sep 17 00:00:00 2001 From: mahi97 Date: Thu, 1 Sep 2016 01:52:04 +0430 Subject: [PATCH 012/121] readme updated --- plugins/osx/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/osx/README.md b/plugins/osx/README.md index 0fcd23dd..b77daecc 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -30,3 +30,4 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) | `showfiles` | Show hidden files | | `hidefiles` | Hide the hidden files | | `itunes` | Control iTunes. User `itunes -h` for usage details | +| `spotify` | Control Spotify and search by artist, album, track and etc.| From d6e032035cde237f09306ea6670a22e5994c38f4 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Thu, 1 Sep 2016 01:52:43 +0430 Subject: [PATCH 013/121] seach show Url of song --- 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 d75e3d2d..aa6a256c 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -387,7 +387,7 @@ function spotify() { esac if [ "$SPOTIFY_PLAY_URI" != "" ]; then - cecho "Playing ($Q Search) -> Spotify URL: $"; + cecho "Playing ($Q Search) -> Spotify URL: $SPOTIFY_PLAY_URI"; osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\""; From e96b12666af48a1a8fb881ed8f7151374603c941 Mon Sep 17 00:00:00 2001 From: "Alexander J. Dita" Date: Sat, 3 Sep 2016 10:49:20 -0700 Subject: [PATCH 014/121] Fixed typo (#5369) Coffee was missing an F --- plugins/coffee/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/coffee/README.md b/plugins/coffee/README.md index 432ce341..d6cd074d 100644 --- a/plugins/coffee/README.md +++ b/plugins/coffee/README.md @@ -1,7 +1,7 @@ ## Coffeescript Plugin This plugin provides aliases for quickly compiling and previewing your -cofeescript code. +coffeescript code. When writing Coffeescript it's very common to want to preview the output of a certain snippet of code, either because you want to test the output or because From 0c60f421cbbdf673fada8fc6e795d069d1ae972e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20G=C3=BCntner?= Date: Wed, 27 Jul 2016 12:04:47 +0200 Subject: [PATCH 015/121] ssh-agent: Use /usr/bin/env to find ssh-add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is important when ssh-add is not inside /usr/bin e.g. on NixOS. Signed-off-by: Maximilian Güntner --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index b77b9ee7..24b6fd9d 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -45,7 +45,7 @@ function _plugin__start_agent() zstyle -a :omz:plugins:ssh-agent identities identities echo starting ssh-agent... - /usr/bin/ssh-add $HOME/.ssh/${^identities} + /usr/bin/env ssh-add $HOME/.ssh/${^identities} } # Get the filename to store/lookup the environment from From 81e73e3d18ebf83d32e9c5e0edc2a26556066955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 21 Aug 2016 00:12:39 +0200 Subject: [PATCH 016/121] Delete useless `/usr/bin/env` in ssh-agent --- plugins/ssh-agent/ssh-agent.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 24b6fd9d..6fdeb272 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -37,7 +37,7 @@ function _plugin__start_agent() zstyle -s :omz:plugins:ssh-agent lifetime lifetime # start ssh-agent and setup environment - /usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! ${_plugin__ssh_env} + ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! ${_plugin__ssh_env} chmod 600 ${_plugin__ssh_env} . ${_plugin__ssh_env} > /dev/null @@ -45,7 +45,7 @@ function _plugin__start_agent() zstyle -a :omz:plugins:ssh-agent identities identities echo starting ssh-agent... - /usr/bin/env ssh-add $HOME/.ssh/${^identities} + ssh-add $HOME/.ssh/${^identities} } # Get the filename to store/lookup the environment from From b60acddefe4cb18267e84b6cdd4314e82352be2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 21 Aug 2016 00:19:59 +0200 Subject: [PATCH 017/121] Extract comments into README for ssh-agent plugin --- plugins/ssh-agent/README.md | 38 ++++++++++++++++++++++++++ plugins/ssh-agent/ssh-agent.plugin.zsh | 30 -------------------- 2 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 plugins/ssh-agent/README.md diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md new file mode 100644 index 00000000..00af42f0 --- /dev/null +++ b/plugins/ssh-agent/README.md @@ -0,0 +1,38 @@ +# ssh-agent plugin + +This plugin starts automatically `ssh-agent` to set up and load whichever +credentials you want for ssh connections. + +To enable it, add `ssh-agent` to your plugins: + +```zsh +plugins=(... ssh-agent) +``` + +## Instructions + +To enable **agent forwarding support** add the following to your zshrc file: + +```zsh +zstyle :omz:plugins:ssh-agent agent-forwarding on +``` + +To **load multiple identities** use the `identities` style, For example: + +```zsh +zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github +``` + +To **set the maximum lifetime of the identities**, use the `lifetime` style. +The lifetime may be specified in seconds or as described in sshd_config(5) +(see _TIME FORMATS_). If left unspecified, the default lifetime is forever. + +```zsh +zstyle :omz:plugins:ssh-agent lifetime 4h +``` + +## Credits + +Based on code from Joseph M. Reagle: http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html + +Agent-forwarding support based on ideas from Florent Thoumie and Jonas Pfenniger diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 6fdeb272..81f27ca0 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,32 +1,3 @@ -# -# INSTRUCTIONS -# -# To enable agent forwarding support add the following to -# your .zshrc file: -# -# zstyle :omz:plugins:ssh-agent agent-forwarding on -# -# To load multiple identities use the identities style, For -# example: -# -# zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github -# -# To set the maximum lifetime of the identities, use the -# lifetime style. The lifetime may be specified in seconds -# or as described in sshd_config(5) (see TIME FORMATS) -# If left unspecified, the default lifetime is forever. -# -# zstyle :omz:plugins:ssh-agent lifetime 4h -# -# CREDITS -# -# Based on code from Joseph M. Reagle -# http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html -# -# Agent forwarding support based on ideas from -# Florent Thoumie and Jonas Pfenniger -# - local _plugin__ssh_env local _plugin__forwarding @@ -76,4 +47,3 @@ fi unfunction _plugin__start_agent unset _plugin__forwarding unset _plugin__ssh_env - From cb0833ac1360984c74f40ccabdec323bb6bbc31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 21 Aug 2016 01:08:34 +0200 Subject: [PATCH 018/121] Clean up formatting of ssh-agent plugin --- plugins/ssh-agent/ssh-agent.plugin.zsh | 63 ++++++++++++-------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 81f27ca0..a427b80a 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,49 +1,42 @@ -local _plugin__ssh_env -local _plugin__forwarding +typeset _agent_forwarding _ssh_env_cache -function _plugin__start_agent() -{ - local -a identities - local lifetime - zstyle -s :omz:plugins:ssh-agent lifetime lifetime +function _start_agent() { + local lifetime + local -a identities - # start ssh-agent and setup environment - ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! ${_plugin__ssh_env} - chmod 600 ${_plugin__ssh_env} - . ${_plugin__ssh_env} > /dev/null + # start ssh-agent and setup environment + zstyle -s :omz:plugins:ssh-agent lifetime lifetime - # load identies - zstyle -a :omz:plugins:ssh-agent identities identities - echo starting ssh-agent... + ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache + chmod 600 $_ssh_env_cache + . $_ssh_env_cache > /dev/null - ssh-add $HOME/.ssh/${^identities} + # load identies + zstyle -a :omz:plugins:ssh-agent identities identities + + echo starting ssh-agent... + ssh-add $HOME/.ssh/${^identities} } # Get the filename to store/lookup the environment from -if (( $+commands[scutil] )); then - # It's OS X! - _plugin__ssh_env="$HOME/.ssh/environment-$(scutil --get ComputerName)" -else - _plugin__ssh_env="$HOME/.ssh/environment-$HOST" -fi +_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" # test if agent-forwarding is enabled -zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding -if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then - # Add a nifty symlink for screen/tmux if agent forwarding - [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen +zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding -elif [ -f "${_plugin__ssh_env}" ]; then - # Source SSH settings, if applicable - . ${_plugin__ssh_env} > /dev/null - ps x | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || { - _plugin__start_agent; - } +if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then + # Add a nifty symlink for screen/tmux if agent forwarding + [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen +elif [[ -f "$_ssh_env_cache" ]]; then + # Source SSH settings, if applicable + . $_ssh_env_cache > /dev/null + ps x | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null || { + _start_agent + } else - _plugin__start_agent; + _start_agent fi # tidy up after ourselves -unfunction _plugin__start_agent -unset _plugin__forwarding -unset _plugin__ssh_env +unset _agent_forwarding _ssh_env_cache +unfunction _start_agent From 142ad842d706e16317bcc8b44ef1b19d625d1fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 21 Aug 2016 02:21:47 +0200 Subject: [PATCH 019/121] Simplify PID check of current ssh-agent --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index a427b80a..e6bc9c4e 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -30,7 +30,7 @@ if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then elif [[ -f "$_ssh_env_cache" ]]; then # Source SSH settings, if applicable . $_ssh_env_cache > /dev/null - ps x | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null || { + ps -o cmd -p $SSH_AGENT_PID | grep -q ssh-agent || { _start_agent } else From 53c3567cc395127d6ba90b8a010e8f7a48a16713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 30 Sep 2014 11:33:42 +0200 Subject: [PATCH 020/121] Force ssh-agent output to use bourne-style syntax On systems where the shell cannot be changed because of a strict security policy, ssh-agent will use the syntax of whatever the default $SHELL is. For instance, if the default shell is tcsh, ssh-agent will use the c-shell style (setenv). This change forces ssh-agent to use bourne-style syntax since that has to be later interpreted by zsh. Consequently, the environment file will contain `export' statements from now on (instead of `setenv'). --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index e6bc9c4e..a84aac58 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -7,7 +7,7 @@ function _start_agent() { # start ssh-agent and setup environment zstyle -s :omz:plugins:ssh-agent lifetime lifetime - ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache + ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache chmod 600 $_ssh_env_cache . $_ssh_env_cache > /dev/null From 7d5bb2a34dd221174c85b826a71d874da3ffc0ec Mon Sep 17 00:00:00 2001 From: jarhat Date: Sun, 4 Sep 2016 19:51:42 +0200 Subject: [PATCH 021/121] archlinux: yasu now working - only one dash needed (#5373) --- plugins/archlinux/archlinux.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 9c8c984b..1637e856 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -9,7 +9,7 @@ else alias yaconf='yaourt -C' alias yaupg='yaourt -Syua' - alias yasu='yaourt --Syua --no-confirm' + alias yasu='yaourt -Syua --noconfirm' alias yain='yaourt -S' alias yains='yaourt -U' alias yare='yaourt -R' From 973a4e646c09b69e7d491d530826778f0d9d7e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 5 Sep 2016 08:31:20 +0200 Subject: [PATCH 022/121] ssh-agent: fix non-standard process check w/ pgrep Confirmed to work on MacOS, OpenBSD, Solaris and busybox. --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index a84aac58..b668fa3b 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -30,7 +30,7 @@ if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then elif [[ -f "$_ssh_env_cache" ]]; then # Source SSH settings, if applicable . $_ssh_env_cache > /dev/null - ps -o cmd -p $SSH_AGENT_PID | grep -q ssh-agent || { + pgrep ssh-agent | grep -q $SSH_AGENT_PID || { _start_agent } else From 298b63513dbbc94f750433e79750d07d96c87d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 5 Sep 2016 10:54:15 +0200 Subject: [PATCH 023/121] git plugin: remove `format:' from --pretty flag Changes gke, glol and glola aliases. Fixes #5362 --- plugins/git/git.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index ef7cb94b..6197c234 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -161,7 +161,7 @@ compdef git-svn-dcommit-push=git alias gk='\gitk --all --branches' compdef _git gk='gitk' -alias gke='\gitk --all $(git log -g --pretty=format:%h)' +alias gke='\gitk --all $(git log -g --pretty=%h)' compdef _git gke='gitk' alias gl='git pull' @@ -171,8 +171,8 @@ alias glgg='git log --graph' alias glgga='git log --graph --decorate --all' alias glgm='git log --graph --max-count=10' alias glo='git log --oneline --decorate' -alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" -alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" +alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" +alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" alias glog='git log --oneline --decorate --graph' alias gloga='git log --oneline --decorate --graph --all' alias glp="_git_log_prettily" From 71201ffd67da9bb8a60d998ebce4dfe7e1039c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 5 Sep 2016 11:22:48 +0200 Subject: [PATCH 024/121] git: output nothing when no commits ahead or behind This fixes old git_commits_ahead behavior and changes git_commits_behind to have the same behavior. Fixes #5355 --- lib/git.zsh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 648a766b..b9069ff1 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -76,16 +76,21 @@ function git_current_branch() { # Gets the number of commits ahead from remote function git_commits_ahead() { - 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" + if command git rev-parse --git-dir &>/dev/null; then + local commits="$(git rev-list --count @{upstream}..HEAD)" + if [[ "$commits" != 0 ]]; then + echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" + fi 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}) + if command git rev-parse --git-dir &>/dev/null; then + local commits="$(git rev-list --count HEAD..@{upstream})" + if [[ "$commits" != 0 ]]; then + echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" + fi fi } From 7c630309cc3a2267f3a08eaf1c408ee4069ee5a7 Mon Sep 17 00:00:00 2001 From: Roman Kapitonov Date: Wed, 2 Sep 2015 20:29:17 +0300 Subject: [PATCH 025/121] Add ability to autocomplete services for brew-services. --- plugins/brew/_brew | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/plugins/brew/_brew b/plugins/brew/_brew index 1f24bd67..19cfb22c 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -33,6 +33,10 @@ _brew_outdated_formulae() { outdated_formulae=(`brew outdated`) } +_brew_installed_services() { + installed_services=(`brew services list | awk '{print $1}' | tail -n+2`) +} + local -a _1st_arguments _1st_arguments=( 'audit:check formulae for Homebrew coding style' @@ -64,6 +68,7 @@ _1st_arguments=( 'prune:remove dead links' 'remove:remove a formula' 'search:search for a formula (/regex/ or string)' + 'services:manage services' 'switch:switch between different versions of a formula' 'tap:tap a new formula repository from GitHub, or list existing taps' 'tap-info:information about a tap' @@ -82,7 +87,7 @@ _1st_arguments=( ) local expl -local -a formulae installed_formulae installed_taps official_taps outdated_formulae +local -a formulae installed_formulae installed_taps official_taps outdated_formulae installed_services _arguments \ '(-v)-v[verbose]' \ @@ -142,4 +147,28 @@ case "$words[1]" in upgrade) _brew_outdated_formulae _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; + services) + _arguments -C \ + '1: :->command' \ + '2: :->service' && return 0 + + local -a commands + + commands=( + 'cleanup:Get rid of stale services and unused plists' + 'list:List all services managed by brew services' + 'restart:Gracefully restart selected service' + 'start:Start selected service' + 'stop:Stop selected service' + ) + + case $state in + command) + _describe -t commands 'Action' commands + ;; + service) + _brew_installed_services + _describe -t subcommands 'Services' installed_services + ;; + esac esac From e726af8f837a5bf0229f90081a63bb5e410ba836 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 7 Sep 2016 12:56:19 +0100 Subject: [PATCH 026/121] add firewalld aliases --- plugins/firewalld/firewalld.plugin.zsh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 plugins/firewalld/firewalld.plugin.zsh diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh new file mode 100644 index 00000000..52c5229a --- /dev/null +++ b/plugins/firewalld/firewalld.plugin.zsh @@ -0,0 +1,17 @@ +alias fw="firewall-cmd" +alias fwp="firewall-cmd --permanent" +alias fwr="firewall-cmd --reload" +alias fwrp="firewall-cmd --runtime-to-permanent" + +function fwl () { + # converts output to zsh array () + # @f flag split on new line + zones=("${(@f)$(firewall-cmd --get-active-zones | grep -v interfaces)}") + + for i in $zones; do + firewall-cmd --zone $i --list-all + done + + echo 'Direct Rules:' + firewall-cmd --direct --get-all-rules +} From 27fff27253ec7f631f3f9e51f0a9f37214d67f17 Mon Sep 17 00:00:00 2001 From: Yuichi Tanikawa Date: Thu, 8 Sep 2016 07:23:04 +0900 Subject: [PATCH 027/121] Fix git_prompt_status() not showing ahead/behind/diverged status correctly (#5388) --- lib/git.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index b9069ff1..f7eccb81 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -165,13 +165,13 @@ function git_prompt_status() { if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi - if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then + if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" fi - if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then + if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" fi - if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then + if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" fi echo $STATUS From e12f8e64ea1fe2871296f8acf541446a56cf5994 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 8 Sep 2016 00:05:43 +0100 Subject: [PATCH 028/121] sudo firewall-cmd calls --- plugins/firewalld/firewalld.plugin.zsh | 14 +++++++------- plugins/firewalld/readme.md | 0 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 plugins/firewalld/readme.md diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh index 52c5229a..bfbf6f48 100644 --- a/plugins/firewalld/firewalld.plugin.zsh +++ b/plugins/firewalld/firewalld.plugin.zsh @@ -1,17 +1,17 @@ -alias fw="firewall-cmd" -alias fwp="firewall-cmd --permanent" -alias fwr="firewall-cmd --reload" -alias fwrp="firewall-cmd --runtime-to-permanent" +alias fw="sudo firewall-cmd" +alias fwp="sudo firewall-cmd --permanent" +alias fwr="sudo firewall-cmd --reload" +alias fwrp="sudo firewall-cmd --runtime-to-permanent" function fwl () { # converts output to zsh array () # @f flag split on new line - zones=("${(@f)$(firewall-cmd --get-active-zones | grep -v interfaces)}") + zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v interfaces)}") for i in $zones; do - firewall-cmd --zone $i --list-all + sudo firewall-cmd --zone $i --list-all done echo 'Direct Rules:' - firewall-cmd --direct --get-all-rules + sudo firewall-cmd --direct --get-all-rules } diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md new file mode 100644 index 00000000..e69de29b From a64d018a9d483e0535d6d77d10c9ff2771d0cb41 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 8 Sep 2016 00:18:26 +0100 Subject: [PATCH 029/121] add readme --- plugins/firewalld/readme.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md index e69de29b..611ad6de 100644 --- a/plugins/firewalld/readme.md +++ b/plugins/firewalld/readme.md @@ -0,0 +1,22 @@ +# FirewallD Plugin + +This plugin adds some aliases and functions for FirewallD using the `firewalld-cmd` command. To use it, add firewalld to your plugins array. + +``` +plugins=(... firewalld) +``` + +## Aliases + +| Alias | Command | Description | +| :---- | :----------------------------------- | :--------------------------- | +| fw | `firewall-cmd` | Shorthand | +| fwr | `firewall-cmd --reload` | Reload current configuration | +| fwp | `firewall-cmd --permanent` | Create permanent rule | +| fwrp | `firewall-cmd --runtime-to-permanent` | Save current configuration | + +## Functions + +| Function | Description | +| :------- | :--------------------------------------------------------- | +| fwl | Lists configuration from all active zones and direct rules | From db31d5157669b77b016a105dfdc53db9160a53d0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 8 Sep 2016 00:27:46 +0100 Subject: [PATCH 030/121] corrected alias documentation --- plugins/firewalld/readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md index 611ad6de..8b5bc74d 100644 --- a/plugins/firewalld/readme.md +++ b/plugins/firewalld/readme.md @@ -2,18 +2,18 @@ This plugin adds some aliases and functions for FirewallD using the `firewalld-cmd` command. To use it, add firewalld to your plugins array. -``` +```zsh plugins=(... firewalld) ``` ## Aliases -| Alias | Command | Description | -| :---- | :----------------------------------- | :--------------------------- | -| fw | `firewall-cmd` | Shorthand | -| fwr | `firewall-cmd --reload` | Reload current configuration | -| fwp | `firewall-cmd --permanent` | Create permanent rule | -| fwrp | `firewall-cmd --runtime-to-permanent` | Save current configuration | +| Alias | Command | Description | +| :---- | :----------------------------------------- | :--------------------------- | +| fw | `sudo firewall-cmd` | Shorthand | +| fwr | `sudo firewall-cmd --reload` | Reload current configuration | +| fwp | `sudo firewall-cmd --permanent` | Create permanent rule | +| fwrp | `sudo firewall-cmd --runtime-to-permanent` | Save current configuration | ## Functions From 2a44527ac3eea1e87b518f69956f3a2bde669dac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 10 Sep 2016 00:21:11 +0200 Subject: [PATCH 031/121] npm: quiet error output of npm completion --- plugins/npm/npm.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 30b91ec9..fd2703ce 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -2,7 +2,8 @@ __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" if [[ ! -f $__NPM_COMPLETION_FILE ]]; then - npm completion >! $__NPM_COMPLETION_FILE || rm -f $__NPM_COMPLETION_FILE + npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null + [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE fi source $__NPM_COMPLETION_FILE From 76924b7f5fbcfc808b00c76df13dd176a46cda6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 10 Sep 2016 00:21:38 +0200 Subject: [PATCH 032/121] npm: only source npm completion cache if file exists --- plugins/npm/npm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index fd2703ce..b5166b51 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -6,7 +6,7 @@ [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE fi - source $__NPM_COMPLETION_FILE + [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE } # Install dependencies globally From b70842bae4346c793e4932d467dd566baeee7d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 10 Sep 2016 00:23:16 +0200 Subject: [PATCH 033/121] npm: unset NPM_COMPLETION_FILE variable --- plugins/npm/npm.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index b5166b51..02e4f3e9 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -7,6 +7,8 @@ fi [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE + + unset __NPM_COMPLETION_FILE } # Install dependencies globally From 3ad92a57f194f2a00a0a4c3e3241ce494e791c02 Mon Sep 17 00:00:00 2001 From: Douglas Drumond Date: Mon, 12 Sep 2016 12:34:52 -0300 Subject: [PATCH 034/121] Add ctrl-r, ctrl-a and ctrl-e support in vi-mode (#4994) * Add ctrl-r support in vi-mode to perform backward search in history * Add ctrl-a support to move to bol in vi-mode * Add ctrl-e support to move to eol in vi-mode Signed-off-by: Douglas Drumond --- plugins/vi-mode/vi-mode.plugin.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 0e2af5dc..dee694b9 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -28,6 +28,13 @@ bindkey '^?' backward-delete-char bindkey '^h' backward-delete-char bindkey '^w' backward-kill-word +# allow ctrl-r to perform backward search in history +bindkey '^r' history-incremental-search-backward + +# allow ctrl-a and ctrl-e to move to beginning/end of line +bindkey '^a' beginning-of-line +bindkey '^e' end-of-line + # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}" From 0c85da3c74fccae3cb2bbe41e1b71ad6c8dca21f Mon Sep 17 00:00:00 2001 From: Ryan Smith Date: Mon, 12 Sep 2016 08:46:10 -0700 Subject: [PATCH 035/121] Add file completions for lein (#5380) --- plugins/lein/lein.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/lein/lein.plugin.zsh b/plugins/lein/lein.plugin.zsh index 11c92979..f4e50b44 100644 --- a/plugins/lein/lein.plugin.zsh +++ b/plugins/lein/lein.plugin.zsh @@ -33,6 +33,8 @@ function _lein_commands() { "version:print leiningen's version" ) _describe -t subcommands 'leiningen subcommands' subcommands && ret=0 + ;; + *) _files esac return ret From 3705d47bb3f3229234cba992320eadc97a221caf Mon Sep 17 00:00:00 2001 From: Trevor Rosen Date: Mon, 12 Sep 2016 10:55:48 -0500 Subject: [PATCH 036/121] Fix iTerm crash on window re-size (#5211) --- plugins/vi-mode/vi-mode.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index dee694b9..82a2f304 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -6,7 +6,7 @@ function zle-keymap-select() { # Ensure that the prompt is redrawn when the terminal size changes. TRAPWINCH() { - zle && { zle reset-prompt; zle -R } + zle && zle -R } zle -N zle-keymap-select From 1d8047e0f87a0a9ff7f6fb99d159ecd3a4be17b9 Mon Sep 17 00:00:00 2001 From: Ivo Bathke Date: Wed, 14 Sep 2016 09:49:50 +0200 Subject: [PATCH 037/121] Readded docker-compose aliases (#5412) Removed by mistake in 0950f9c. --- plugins/docker-compose/docker-compose.plugin.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 plugins/docker-compose/docker-compose.plugin.zsh diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh new file mode 100644 index 00000000..351e7782 --- /dev/null +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -0,0 +1,13 @@ +# Authors: +# https://github.com/tristola +# +# Docker-compose related zsh aliases + +# Aliases ################################################################### + +alias dcup='docker-compose up' +alias dcb='docker-compose build' +alias dcrm='docker-compose rm' +alias dcps='docker-compose ps' +alias dcstop='docker-compose stop' +alias dcrestart='docker-compose restart' From ce4d8a5cadcccd79909d97e42099540cfa50b9c3 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Wed, 14 Sep 2016 11:10:14 +0200 Subject: [PATCH 038/121] Add -DskipITs and completion for -Dit.test mvn plugin (#3641) * Adds -DskipITs to auto completion list * Adds integration test completion --- plugins/mvn/mvn.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 068963ac..d290c98e 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -172,7 +172,7 @@ function listMavenCompletions { gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test # options - -Dmaven.test.skip=true -DskipTests -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true + -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true # arguments -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X @@ -181,6 +181,7 @@ function listMavenCompletions { archetype:generate generate-sources cobertura:cobertura -Dtest= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi` + -Dit.test= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi` ); } From 59c66dbfc2b4749c3311550fa605e1e4fcf9496c Mon Sep 17 00:00:00 2001 From: Reed Riley Date: Wed, 14 Sep 2016 20:01:10 -0400 Subject: [PATCH 039/121] Fix battery plugin when acpi writes to stderr (#5413) * Fix battery plugin when acpi writes to stderr * Make stderr redirection in battery plugin more idiomatic --- plugins/battery/battery.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 014bb15d..0bb9e77f 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -67,12 +67,12 @@ if [[ "$OSTYPE" = darwin* ]] ; then elif [[ $(uname) == "Linux" ]] ; then function battery_is_charging() { - ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] + ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] } function battery_pct() { if (( $+commands[acpi] )) ; then - echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" + echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" fi } @@ -85,14 +85,14 @@ elif [[ $(uname) == "Linux" ]] ; then } function battery_time_remaining() { - if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - echo $(acpi | cut -f3 -d ',') + if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then + echo $(acpi 2>/dev/null | cut -f3 -d ',') fi } function battery_pct_prompt() { b=$(battery_pct_remaining) - if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then + if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then if [ $b -gt 50 ] ; then color='green' elif [ $b -gt 20 ] ; then From e46843685c1f337e1266a51c9cae1889c4ae9eba Mon Sep 17 00:00:00 2001 From: Erik Zivkovic Date: Thu, 15 Sep 2016 12:16:46 +0200 Subject: [PATCH 040/121] Improve gradle plugin task parsing (#5230) * Improve gradle plugin task parsing Added _gradle and _gradlew as symbolic links to gradle.plugin.zsh, otherwise the plugin was not properly loaded. Output from `gradlew tasks --all` is now parsed in two levels, first we find segments between `------...` and a newline. Second, all those lines are parsed and cleaned using awk and added to .gradletasknamecache. Tested on gradle 2.13, and gradlew 2.14. * Remove .gradletasknamecache before regenerating it Remove the .gradletasknamecache file to avoid having an unnecessary newline at the top of the file when regenerating it. * Improve gradle task parsing by writing .gradletasknamecache atomically Previously the .gradletasknamecache file was written line by line inside a parsing loop, which could cause errors such as half-written cache files if the process was aborted. This also removes the need of deleting the .gradletasknamecache file before parsing. --- plugins/gradle/_gradle | 1 + plugins/gradle/_gradlew | 1 + plugins/gradle/gradle.plugin.zsh | 33 ++++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 120000 plugins/gradle/_gradle create mode 120000 plugins/gradle/_gradlew diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle new file mode 120000 index 00000000..80723f2f --- /dev/null +++ b/plugins/gradle/_gradle @@ -0,0 +1 @@ +gradle.plugin.zsh \ No newline at end of file diff --git a/plugins/gradle/_gradlew b/plugins/gradle/_gradlew new file mode 120000 index 00000000..80723f2f --- /dev/null +++ b/plugins/gradle/_gradlew @@ -0,0 +1 @@ +gradle.plugin.zsh \ No newline at end of file diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index a908eaea..b2015a35 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -60,6 +60,35 @@ _gradle_does_task_list_need_generating () { [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache ]] } +############## +# Parse the tasks from `gradle(w) tasks --all` into .gradletasknamecache +# All lines in the output from gradle(w) that are between /^-+$/ and /^\s*$/ +# are considered to be tasks. If and when gradle adds support for listing tasks +# for programmatic parsing, this method can be deprecated. +############## +_gradle_parse_tasks () { + lines_might_be_tasks=false + task_name_buffer="" + while read -r line; do + if [[ $line =~ ^-+$ ]]; then + lines_might_be_tasks=true + # Empty buffer, because it contains items that are not tasks + task_name_buffer="" + elif [[ $line =~ ^\s*$ ]]; then + if [[ "$lines_might_be_tasks" = true ]]; then + # If a newline is found, send the buffer to .gradletasknamecache + while read -r task; do + echo $task | awk '/[a-zA-Z0-9:-]+/ {print $1}' + done <<< "$task_name_buffer" + # Empty buffer, because we are done with the tasks + task_name_buffer="" + fi + lines_might_be_tasks=false + elif [[ "$lines_might_be_tasks" = true ]]; then + task_name_buffer="${task_name_buffer}\n${line}" + fi + done <<< "$1" +} ############################################################################## # Discover the gradle tasks by running "gradle tasks --all" @@ -68,7 +97,7 @@ _gradle_tasks () { if [[ -f build.gradle ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then - gradle tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache + _gradle_parse_tasks "$(gradle tasks --all)" > .gradletasknamecache fi compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache) fi @@ -78,7 +107,7 @@ _gradlew_tasks () { if [[ -f build.gradle ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then - ./gradlew tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache + _gradle_parse_tasks "$(./gradlew tasks --all)" > .gradletasknamecache fi compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache) fi From 84449fc8e0923b611d1314813b8bfe4d96072b2c Mon Sep 17 00:00:00 2001 From: Joshua McKinney Date: Sat, 17 Sep 2016 04:43:40 -0500 Subject: [PATCH 041/121] Deprecating brew cask plugin (#5191) The good completion is now part of Homebrew so this one will always be outdated. See https://github.com/Homebrew/brew/pull/407 and https://github.com/Homebrew/brew/pull/936. --- plugins/brew-cask/brew-cask.plugin.zsh | 84 -------------------------- 1 file changed, 84 deletions(-) delete mode 100644 plugins/brew-cask/brew-cask.plugin.zsh diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh deleted file mode 100644 index 91ce0f49..00000000 --- a/plugins/brew-cask/brew-cask.plugin.zsh +++ /dev/null @@ -1,84 +0,0 @@ -# Autocompletion for homebrew-cask. -# -# This script intercepts calls to the brew plugin and adds autocompletion -# for the cask subcommand. -# -# Author: https://github.com/pstadler - -compdef _brew-cask brew - -_brew-cask() -{ - local curcontext="$curcontext" state line - typeset -A opt_args - - _arguments -C \ - ':command:->command' \ - ':subcmd:->subcmd' \ - '*::options:->options' - - case $state in - (command) - __call_original_brew - cask_commands=( - 'cask:manage casks' - ) - _describe -t commands 'brew cask command' cask_commands ;; - - (subcmd) - case "$line[1]" in - cask) - if (( CURRENT == 3 )); then - local -a subcommands - subcommands=( - "alfred:used to modify Alfred's scope to include the Caskroom" - 'audit:verifies installability of casks' - 'checklinks:checks for bad cask links' - 'cleanup:cleans up cached downloads' - 'create:creates a cask of the given name and opens it in an editor' - 'doctor:checks for configuration issues' - 'edit:edits the cask of the given name' - 'fetch:downloads Cask resources to local cache' - 'home:opens the homepage of the cask of the given name' - 'info:displays information about the cask of the given name' - 'install:installs the cask of the given name' - 'list:with no args, lists installed casks; given installed casks, lists installed files' - 'search:searches all known casks' - 'uninstall:uninstalls the cask of the given name' - "update:a synonym for 'brew update'" - ) - _describe -t commands "brew cask subcommand" subcommands - fi ;; - - *) - __call_original_brew ;; - esac ;; - - (options) - local -a casks installed_casks - local expl - case "$line[2]" in - list|uninstall) - __brew_installed_casks - _wanted installed_casks expl 'installed casks' compadd -a installed_casks ;; - audit|edit|home|info|install) - __brew_all_casks - _wanted casks expl 'all casks' compadd -a casks ;; - esac ;; - esac -} - -__brew_all_casks() { - casks=(`brew cask search`) -} - -__brew_installed_casks() { - installed_casks=(`brew cask list`) -} - -__call_original_brew() -{ - local ret=1 - _call_function ret _brew - compdef _brew-cask brew -} From 5cf9263907b74d33ac0c85a8cb99f736bb63982e Mon Sep 17 00:00:00 2001 From: Joshua McKinney Date: Mon, 27 Jun 2016 15:19:19 -0500 Subject: [PATCH 042/121] Remove _brew zsh completion (#5190) Removing as this is now installed as part of homebrew automatically and this version is out of date. See https://github.com/Homebrew/brew/blob/master/share/zsh/site-functions/_brew --- plugins/brew/_brew | 174 --------------------------------------------- 1 file changed, 174 deletions(-) delete mode 100644 plugins/brew/_brew diff --git a/plugins/brew/_brew b/plugins/brew/_brew deleted file mode 100644 index 19cfb22c..00000000 --- a/plugins/brew/_brew +++ /dev/null @@ -1,174 +0,0 @@ -#compdef brew -#autoload - -# imported from https://github.com/Homebrew/homebrew/blob/29f73d2212c2b202fe25f69dcbf440d8391fa4c9/Library/Contributions/brew_zsh_completion.zsh - -# Brew ZSH completion function -# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions) -# and rename it _brew -# -# altered from _fink - -_brew_all_formulae() { - formulae=(`brew search`) -} - -_brew_installed_formulae() { - installed_formulae=(`brew list`) -} - -_brew_installed_taps() { - installed_taps=(`brew tap`) -} - -_brew_official_taps() { - official_taps=(`brew tap --list-official`) -} - -_brew_pinned_taps() { - pinned_taps=(`brew tap --list-pinned`) -} - -_brew_outdated_formulae() { - outdated_formulae=(`brew outdated`) -} - -_brew_installed_services() { - installed_services=(`brew services list | awk '{print $1}' | tail -n+2`) -} - -local -a _1st_arguments -_1st_arguments=( - 'audit:check formulae for Homebrew coding style' - 'cat:display formula file for a formula' - 'cleanup:uninstall unused and old versions of packages' - 'commands:show a list of commands' - 'config:show homebrew and system configuration' - 'create:create a new formula' - 'deps:list dependencies and dependants of a formula' - 'desc:display a description of a formula' - 'doctor:audits your installation for common issues' - 'edit:edit a formula' - 'fetch:download formula resources to the cache' - 'gist-logs:generate a gist of the full build logs' - 'home:visit the homepage of a formula or the brew project' - 'info:information about a formula' - 'install:install a formula' - 'reinstall:install a formula anew; re-using its current options' - 'leaves:show installed formulae that are not dependencies of another installed formula' - 'link:link a formula' - 'linkapps:symlink .app bundles provided by formulae into /Applications' - 'list:list files in a formula or not-installed formulae' - 'log:git commit log for a formula' - 'missing:check all installed formuale for missing dependencies.' - 'migrate:migrate renamed formula to new name' - 'outdated:list formulae for which a newer version is available' - 'pin:pin specified formulae' - 'postinstall:perform post_install for a given formula' - 'prune:remove dead links' - 'remove:remove a formula' - 'search:search for a formula (/regex/ or string)' - 'services:manage services' - 'switch:switch between different versions of a formula' - 'tap:tap a new formula repository from GitHub, or list existing taps' - 'tap-info:information about a tap' - 'tap-pin:pin a tap' - 'tap-unpin:unpin a tap' - 'test-bot:test a formula and build a bottle' - 'uninstall:uninstall a formula' - 'unlink:unlink a formula' - 'unlinkapps:remove symlinked .app bundles provided by formulae from /Applications' - 'unpin:unpin specified formulae' - 'untap:remove a tapped repository' - 'update:fetch latest version of Homebrew and all formulae' - 'upgrade:upgrade outdated formulae' - 'uses:show formulae which depend on a formula' - `brew commands --quiet --include-aliases` -) - -local expl -local -a formulae installed_formulae installed_taps official_taps outdated_formulae installed_services - -_arguments \ - '(-v)-v[verbose]' \ - '(--cellar)--cellar[brew cellar]' \ - '(--env)--env[brew environment]' \ - '(--repository)--repository[brew repository]' \ - '(--version)--version[version information]' \ - '(--prefix)--prefix[where brew lives on this system]' \ - '(--cache)--cache[brew cache]' \ - '*:: :->subcmds' && return 0 - -if (( CURRENT == 1 )); then - _describe -t commands "brew subcommand" _1st_arguments - return -fi - -case "$words[1]" in - install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|desc|edit|options|switch) - _brew_all_formulae - _wanted formulae expl 'all formulae' compadd -a formulae ;; - linkapps|unlinkapps) - _arguments \ - '(--local)--local[operate on ~/Applications instead of /Applications]' \ - '1: :->forms' && return 0 - - if [[ "$state" == forms ]]; then - _brew_installed_formulae - _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae - fi ;; - list|ls) - _arguments \ - '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ - '(--pinned)--pinned[list all versions of pinned formulae]' \ - '(--versions)--versions[list all installed versions of a formula]' \ - '1: :->forms' && return 0 - - if [[ "$state" == forms ]]; then - _brew_installed_formulae - _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae - fi ;; - remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin) - _brew_installed_formulae - _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; - search|-S) - _arguments \ - '(--macports)--macports[search the macports repository]' \ - '(--fink)--fink[search the fink repository]' ;; - untap|tap-info|tap-pin) - _brew_installed_taps - _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; - tap) - _brew_official_taps - _wanted official_taps expl 'official taps' compadd -a official_taps ;; - tap-unpin) - _brew_pinned_taps - _wanted pinned_taps expl 'pinned taps' compadd -a pinned_taps ;; - upgrade) - _brew_outdated_formulae - _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; - services) - _arguments -C \ - '1: :->command' \ - '2: :->service' && return 0 - - local -a commands - - commands=( - 'cleanup:Get rid of stale services and unused plists' - 'list:List all services managed by brew services' - 'restart:Gracefully restart selected service' - 'start:Start selected service' - 'stop:Stop selected service' - ) - - case $state in - command) - _describe -t commands 'Action' commands - ;; - service) - _brew_installed_services - _describe -t subcommands 'Services' installed_services - ;; - esac -esac From 5bd9500bf4e68bf185db77ad4ecbb728a5b81c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 17 Sep 2016 13:01:10 +0200 Subject: [PATCH 043/121] ssh-agent: check ssh-agent process w/ ps again The alternative is using tools that aren't available everywhere. The latest report is that cygwin/msys2 doesn't have pgrep. Fixes #5418. --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index b668fa3b..20f97c6f 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -30,7 +30,7 @@ if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then elif [[ -f "$_ssh_env_cache" ]]; then # Source SSH settings, if applicable . $_ssh_env_cache > /dev/null - pgrep ssh-agent | grep -q $SSH_AGENT_PID || { + ps x | grep ssh-agent | grep -q $SSH_AGENT_PID || { _start_agent } else From abe834d28ddb6c5d0d98addf7a77551b3e007cd5 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Mon, 19 Sep 2016 19:40:38 -0700 Subject: [PATCH 044/121] Adding a link to Planet Argon who manages the site/project/shop --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5f152e4d..581625fe 100644 --- a/README.md +++ b/README.md @@ -211,3 +211,9 @@ We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of- ## License Oh My Zsh is released under the [MIT license](LICENSE.txt). + +## About Planet Argon + +![Planet Argon](http://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg) + +Oh My Zsh started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). From 89048668bdf4231b27e8249352087d1ccb46d447 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Mon, 19 Sep 2016 19:41:59 -0700 Subject: [PATCH 045/121] Forgot a word in the footer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 581625fe..aab1af9f 100644 --- a/README.md +++ b/README.md @@ -216,4 +216,4 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt). ![Planet Argon](http://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg) -Oh My Zsh started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). +Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). From e9793fc1995254172338bc53082d704b22d31a0d Mon Sep 17 00:00:00 2001 From: Luis Ferrer-Labarca Date: Mon, 19 Sep 2016 22:50:16 -0400 Subject: [PATCH 046/121] Added 'gbd' alias for 'git branch -d' (#5417) --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6197c234..25da0350 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -46,6 +46,7 @@ alias gapa='git add --patch' alias gb='git branch' alias gba='git branch -a' +alias gbd='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' From 836fe3138552defff447ebd50271225d29bae91c Mon Sep 17 00:00:00 2001 From: Mohnish G J Date: Tue, 20 Sep 2016 08:21:50 +0530 Subject: [PATCH 047/121] Add an alias for Rails console sandbox (#5316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The command ‘rails console —sandbox’ loads our Rails application, connects to the database and automatically starts a database transaction. All database operations performed within this console session are rolled back upon leaving the console. Reference - https://www.codeschool.com/blog/2014/06/17/rails-console-sandbox/ --- plugins/rails/rails.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index e532639b..c8974b5f 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -36,6 +36,7 @@ alias -g RET='RAILS_ENV=test' # Rails aliases alias rc='rails console' +alias rcs='rails console --sandbox' alias rd='rails destroy' alias rdb='rails dbconsole' alias rg='rails generate' From 63d300edb04e1c2c2eea888f3085836bc9b580f7 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Rahimi Date: Tue, 20 Sep 2016 07:26:12 +0430 Subject: [PATCH 048/121] Spotify Controller (#5356) * initial spotify control * volume up/down added * add info, share and status option * add color echo * change pause to play/pause * add Search Option for album,artist and tracks * add search option for playlist * fix showStatus output * complete help * readme updated * seach show Url of song --- plugins/osx/README.md | 1 + plugins/osx/osx.plugin.zsh | 264 +++++++++++++++++++++++++++++++++++++ 2 files changed, 265 insertions(+) diff --git a/plugins/osx/README.md b/plugins/osx/README.md index 0fcd23dd..b77daecc 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -30,3 +30,4 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) | `showfiles` | Show hidden files | | `hidefiles` | Hide the hidden files | | `itunes` | Control iTunes. User `itunes -h` for usage details | +| `spotify` | Control Spotify and search by artist, album, track and etc.| diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a3e55097..aa6a256c 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -261,6 +261,270 @@ EOF osascript -e "tell application \"iTunes\" to $opt" } +# Spotify control function +function spotify() { + + showHelp () { + echo "Usage:"; + echo; + echo " $(basename "$0") "; + echo; + echo "Commands:"; + echo; + echo " play # Resumes playback where Spotify last left off."; + echo " play [song name] # Finds a song by name and plays it."; + echo " play album [album name] # Finds an album by name and plays it."; + echo " play artist [artist name] # Finds an artist by name and plays it."; + echo " play list [playlist name] # Finds a playlist by name and plays it."; + echo " pause # Pauses Spotify playback."; + echo " next # Skips to the next song in a playlist."; + echo " prev # Returns to the previous song in a playlist."; + echo " pos [time] # Jumps to a time (in secs) in the current song."; + echo " quit # Stops playback and quits Spotify."; + echo; + echo " vol up # Increases the volume by 10%."; + echo " vol down # Decreases the volume by 10%."; + echo " vol [amount] # Sets the volume to an amount between 0 and 100."; + echo " vol show # Shows the current Spotify volume."; + echo; + echo " status # Shows the current player status."; + echo " share # Copies the current song URL to the clipboard." + echo " info # Shows Full Information about song that is playing."; + echo; + echo " toggle shuffle # Toggles shuffle playback mode."; + echo " toggle repeat # Toggles repeat playback mode."; + } + + cecho(){ + bold=$(tput bold); + green=$(tput setaf 2); + reset=$(tput sgr0); + echo "$bold$green$1$reset"; + } + + showStatus () { + state=$(osascript -e 'tell application "Spotify" to player state as string'); + cecho "Spotify is currently $state."; + if [ "$state" = "playing" ]; then + artist=$(osascript -e 'tell application "Spotify" to artist of current track as string'); + album=$(osascript -e 'tell application "Spotify" to album of current track as string'); + track=$(osascript -e 'tell application "Spotify" to name of current track as string'); + duration=$(osascript -e 'tell application "Spotify" to duration of current track as string'); + duration=$(echo "scale=2; $duration / 60 / 1000" | bc); + position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); + position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); + + printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; + fi + } + + + + if [ $# = 0 ]; then + showHelp; + else + if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then + osascript -e 'tell application "Spotify" to activate' + sleep 2 + fi + fi + + while [ $# -gt 0 ]; do + arg=$1; + + case $arg in + "play" ) + if [ $# != 1 ]; then + # There are additional arguments, so find out how many + array=( $@ ); + len=${#array[@]}; + SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search" + SPOTIFY_PLAY_URI=""; + + searchAndPlay() { + type="$1" + Q="$2" + + cecho "Searching ${type}s for: $Q"; + + SPOTIFY_PLAY_URI=$( \ + curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=$type&limit=1&offset=0" -H "Accept: application/json" \ + | grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1 + ) + } + + case $2 in + "list" ) + _args=${array[*]:2:$len}; + Q=$_args; + + cecho "Searching playlists for: $Q"; + + results=$( \ + curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" \ + | grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \ + ) + + count=$( \ + echo "$results" | grep -c "spotify:user" \ + ) + + if [ "$count" -gt 0 ]; then + random=$(( RANDOM % count)); + + SPOTIFY_PLAY_URI=$( \ + echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \ + ) + fi;; + + "album" | "artist" | "track" ) + _args=${array[*]:2:$len}; + searchAndPlay "$2" "$_args";; + + * ) + _args=${array[*]:1:$len}; + searchAndPlay track "$_args";; + esac + + if [ "$SPOTIFY_PLAY_URI" != "" ]; then + cecho "Playing ($Q Search) -> Spotify URL: $SPOTIFY_PLAY_URI"; + + osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\""; + + else + cecho "No results when searching for $Q"; + fi + else + # play is the only param + cecho "Playing Spotify."; + osascript -e 'tell application "Spotify" to play'; + fi + break ;; + + "pause" ) + state=$(osascript -e 'tell application "Spotify" to player state as string'); + if [ "$state" = "playing" ]; then + cecho "Pausing Spotify."; + else + cecho "Playing Spotify."; + fi + + osascript -e 'tell application "Spotify" to playpause'; + break ;; + + "quit" ) + cecho "Quitting Spotify."; + osascript -e 'tell application "Spotify" to quit'; + exit 1 ;; + + "next" ) + cecho "Going to next track." ; + osascript -e 'tell application "Spotify" to next track'; + break ;; + + "prev" ) + cecho "Going to previous track."; + osascript -e 'tell application "Spotify" to previous track'; + break ;; + + "vol" ) + vol=$(osascript -e 'tell application "Spotify" to sound volume as integer'); + if [[ "$2" = "show" || "$2" = "" ]]; then + cecho "Current Spotify volume level is $vol."; + break ; + elif [ "$2" = "up" ]; then + if [ "$vol" -le 90 ]; then + newvol=$(( vol+10 )); + cecho "Increasing Spotify volume to $newvol."; + else + newvol=100; + cecho "Spotify volume level is at max."; + fi + elif [ "$2" = "down" ]; then + if [ "$vol" -ge 10 ]; then + newvol=$(( vol-10 )); + cecho "Reducing Spotify volume to $newvol."; + else + newvol=0; + cecho "Spotify volume level is at min."; + fi + elif [ "$2" -ge 0 ]; then + newvol=$2; + fi + + osascript -e "tell application \"Spotify\" to set sound volume to $newvol"; + break ;; + + "toggle" ) + if [ "$2" = "shuffle" ]; then + osascript -e 'tell application "Spotify" to set shuffling to not shuffling'; + curr=$(osascript -e 'tell application "Spotify" to shuffling'); + cecho "Spotify shuffling set to $curr"; + elif [ "$2" = "repeat" ]; then + osascript -e 'tell application "Spotify" to set repeating to not repeating'; + curr=$(osascript -e 'tell application "Spotify" to repeating'); + cecho "Spotify repeating set to $curr"; + fi + break ;; + + "pos" ) + cecho "Adjusting Spotify play position." + osascript -e "tell application \"Spotify\" to set player position to $2"; + break;; + + "status" ) + showStatus; + break ;; + + "info" ) + info=$(osascript -e 'tell application "Spotify" + set tM to round (duration of current track / 60) rounding down + set tS to duration of current track mod 60 + set pos to player position as text + set myTime to tM as text & "min " & tS as text & "s" + set nM to round (player position / 60) rounding down + set nS to round (player position mod 60) rounding down + set nowAt to nM as text & "min " & nS as text & "s" + set info to "" & "\nArtist: " & artist of current track + set info to info & "\nTrack: " & name of current track + set info to info & "\nAlbum Artist: " & album artist of current track + set info to info & "\nAlbum: " & album of current track + set info to info & "\nSeconds: " & duration of current track + set info to info & "\nSeconds played: " & pos + set info to info & "\nDuration: " & mytime + set info to info & "\nNow at: " & nowAt + set info to info & "\nPlayed Count: " & played count of current track + set info to info & "\nTrack Number: " & track number of current track + set info to info & "\nPopularity: " & popularity of current track + set info to info & "\nId: " & id of current track + set info to info & "\nSpotify URL: " & spotify url of current track + set info to info & "\nArtwork: " & artwork of current track + set info to info & "\nPlayer: " & player state + set info to info & "\nVolume: " & sound volume + set info to info & "\nShuffle: " & shuffling + set info to info & "\nRepeating: " & repeating + end tell + return info') + echo "$info"; + break ;; + + "share" ) + url=$(osascript -e 'tell application "Spotify" to spotify url of current track'); + remove='spotify:track:' + url=${url#$remove} + url="http://open.spotify.com/track/$url" + cecho "Share URL: $url"; + cecho -n "$url" | pbcopy + break;; + + -h|--help| *) + showHelp; + break ;; + esac + done +} + + # Show/hide hidden files in the Finder alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" From cb60cfc7bdc7745dd48afe265df3a13f9cd3e54d Mon Sep 17 00:00:00 2001 From: Ariel Rivas Date: Mon, 19 Sep 2016 23:57:51 -0300 Subject: [PATCH 049/121] Avoid unnecesary processing... (#5352) by discarding directories or files with permissions already correctly set --- plugins/perms/perms.plugin.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh index 81f56d57..7cdebab7 100644 --- a/plugins/perms/perms.plugin.zsh +++ b/plugins/perms/perms.plugin.zsh @@ -6,10 +6,10 @@ ### Aliases # Set all files' permissions to 644 recursively in a directory -alias set644='find . -type f -print0 | xargs -0 chmod 644' +alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644' # Set all directories' permissions to 755 recursively in a directory -alias set755='find . -type d -print0 | xargs -0 chmod 755' +alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755' ### Functions @@ -63,14 +63,14 @@ EOF exit_status=0; if [[ $use_slow == true ]]; then # Process directories first so non-traversable ones are fixed as we go - find "$target" -type d -exec chmod $chmod_opts 755 {} \; + find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \; if [[ $? != 0 ]]; then exit_status=$?; fi - find "$target" -type f -exec chmod $chmod_opts 644 {} \; + find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \; if [[ $? != 0 ]]; then exit_status=$?; fi else - find "$target" -type d -print0 | xargs -0 chmod $chmod_opts 755 + find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755 if [[ $? != 0 ]]; then exit_status=$?; fi - find "$target" -type f -print0 | xargs -0 chmod $chmod_opts 644 + find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644 if [[ $? != 0 ]]; then exit_status=$?; fi fi echo "Complete" From 83765bf3f7c5e92c9141a03d9791638f7eb68277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20R=C3=ADos?= Date: Tue, 20 Sep 2016 04:58:45 +0200 Subject: [PATCH 050/121] missing listing and versions (#5341) versions is missing list is missing --- plugins/npm/npm.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 02e4f3e9..43aedc36 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -32,6 +32,12 @@ alias npmE='PATH="$(npm bin)":"$PATH"' # Check which npm modules are outdated alias npmO="npm outdated" +# Check package versions +alias npmV="npm -v" + +# List packages +alias npmL="npm list" + # Run npm start alias npmst="npm start" From fb8953d525ddd3ed01db02a266b284bd9fa5fbd2 Mon Sep 17 00:00:00 2001 From: Matt Nichols Date: Mon, 19 Sep 2016 21:00:16 -0600 Subject: [PATCH 051/121] Fix peepcode theme ruby prompt info (#5339) The ruby prompt info was not interpolating properly. Switching to use ruby_prompt_info helper. This addresses the issue. --- themes/peepcode.zsh-theme | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/themes/peepcode.zsh-theme b/themes/peepcode.zsh-theme index 9dc58294..b6dfa687 100644 --- a/themes/peepcode.zsh-theme +++ b/themes/peepcode.zsh-theme @@ -41,10 +41,4 @@ PROMPT=' %~ ${smiley} %{$reset_color%}' -if [[ -d ~/.rvm ]] && [[ -e ~/.rvm/bin/rvm-prompt ]]; then - rvm_prompt='$(~/.rvm/bin/rvm-prompt)' -else - rvm_prompt='' -fi - -RPROMPT='%{$fg[white]%} $rvm_prompt$(git_prompt)%{$reset_color%}' +RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}' From d1ce70f68540bdf6a7f27ab9879e8222d0e7a604 Mon Sep 17 00:00:00 2001 From: grindhold Date: Tue, 20 Sep 2016 05:00:42 +0200 Subject: [PATCH 052/121] added support for bazaar in agnoster theme (#5016) the agnoster theme is now able to render basic information if the user is currently residing inside a bazaar folder. if so, it will render a green promt segment with "bzr" and the current revision number in it. if there are untracked files, the bar will be rendered in yellow. if there are changes to already tracked files, a + character will be printed. --- themes/agnoster.zsh-theme | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index da1f9b6e..e1a294ee 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -127,6 +127,27 @@ prompt_git() { fi } +prompt_bzr() { + if (bzr status >/dev/null 2>&1); then + status_mod=`bzr status | head -n1 | grep "modified" | wc -m` + status_all=`bzr status | head -n1 | wc -m` + revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` + if [[ $status_mod -gt 0 ]] ; then + prompt_segment yellow black + echo -n "bzr@"$revision "✚ " + else + if [[ $status_all -gt 0 ]] ; then + prompt_segment yellow black + echo -n "bzr@"$revision + + else + prompt_segment green black + echo -n "bzr@"$revision + fi + fi + fi +} + prompt_hg() { (( $+commands[hg] )) || return local rev status @@ -198,6 +219,7 @@ build_prompt() { prompt_context prompt_dir prompt_git + prompt_bzr prompt_hg prompt_end } From 9d91e92f26e3cb2d89eb43065ad960e4a344d52c Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Tue, 20 Sep 2016 14:40:07 -0400 Subject: [PATCH 053/121] Update docker completion to match docker upstream (#5060) See https://github.com/docker/docker/blob/master/contrib/completion/zsh/_docker Signed-off-by: Brian Goff --- plugins/docker/_docker | 58 ++++++++++-------------------------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 66dfeea9..55437924 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -138,7 +138,7 @@ __docker_containers_names() { __docker_get_containers all names "$@" } -__docker_complete_info_plugins() { +__docker_plugins() { [[ $PREFIX = -* ]] && return 1 integer ret=1 emulate -L zsh @@ -228,7 +228,7 @@ __docker_get_log_options() { journald_options=("env" "labels" "tag") json_file_options=("env" "labels" "max-file" "max-size") syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") - splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") + splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "tag") [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 @@ -340,7 +340,7 @@ __docker_complete_ps_filters() { __docker_networks && ret=0 ;; (status) - status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing') + status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running') _describe -t status-filter-opts "Status Filter Options" status_opts && ret=0 ;; (volume) @@ -463,8 +463,6 @@ __docker_complete_events_filter() { return ret } -# BO network - __docker_network_complete_ls_filters() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -472,7 +470,7 @@ __docker_network_complete_ls_filters() { if compset -P '*='; then case "${${words[-1]%=*}#*=}" in (driver) - __docker_complete_info_plugins Network && ret=0 + __docker_plugins Network && ret=0 ;; (id) __docker_networks_ids && ret=0 @@ -631,7 +629,6 @@ __docker_network_subcommand() { $opts_help \ "($help)--no-trunc[Do not truncate the output]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ - "($help)--format=[Pretty-print networks using a Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 case $state in (filter-options) @@ -652,8 +649,6 @@ __docker_network_subcommand() { return ret } -# EO network - # BO node __docker_node_complete_ls_filters() { @@ -721,6 +716,7 @@ __docker_nodes() { [[ $filter != "none" ]] && args=("-f $filter") lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"}) + # Parse header line to find columns local i=1 j=1 k header=${lines[1]} declare -A begin end @@ -846,7 +842,6 @@ __docker_node_subcommand() { "($help -a --all)"{-a,--all}"[Display all instances]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)--no-resolve[Do not map IDs to Names]" \ - "($help)--no-trunc[Do not truncate output]" \ "($help -)1:node:__docker_complete_nodes" && ret=0 case $state in (filter-options) @@ -1162,7 +1157,6 @@ __docker_service_subcommand() { "($help -a --all)"{-a,--all}"[Display all tasks]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)--no-resolve[Do not map IDs to Names]" \ - "($help)--no-trunc[Do not truncate output]" \ "($help -)1:service:__docker_complete_services" && ret=0 case $state in (filter-options) @@ -1256,8 +1250,6 @@ __docker_swarm_subcommand() { # EO swarm -# BO volume - __docker_volume_complete_ls_filters() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -1269,7 +1261,7 @@ __docker_volume_complete_ls_filters() { _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0 ;; (driver) - __docker_complete_info_plugins Volume && ret=0 + __docker_plugins Volume && ret=0 ;; (name) __docker_volumes && ret=0 @@ -1279,7 +1271,7 @@ __docker_volume_complete_ls_filters() { ;; esac else - opts=('dangling' 'driver' 'label' 'name') + opts=('dangling' 'driver' 'name') _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 fi @@ -1338,12 +1330,12 @@ __docker_volume_subcommand() { case "$words[1]" in (create) - _arguments $(__docker_arguments) -A '-*' \ + _arguments $(__docker_arguments) \ $opts_help \ "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \ "($help)*--label=[Set metadata for a volume]:label=value: " \ - "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \ - "($help -)1:Volume name: " && ret=0 + "($help)--name=[Volume name]" \ + "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " && ret=0 ;; (inspect) _arguments $(__docker_arguments) \ @@ -1355,7 +1347,6 @@ __docker_volume_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ - "($help)--format=[Pretty-print volumes using a Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 case $state in (filter-options) @@ -1366,7 +1357,6 @@ __docker_volume_subcommand() { (rm) _arguments $(__docker_arguments) \ $opts_help \ - "($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \ "($help -):volume:__docker_volumes" && ret=0 ;; (help) @@ -1377,8 +1367,6 @@ __docker_volume_subcommand() { return ret } -# EO volume - __docker_caching_policy() { oldp=( "$1"(Nmh+1) ) # 1 hour (( $#oldp )) @@ -1701,7 +1689,7 @@ __docker_subcommand() { "($help -a --all)"{-a,--all}"[Show all images]" \ "($help)--digests[Show digests]" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ - "($help)--format[Pretty-print containers using a Go template]:template: " \ + "($help)--format[Pretty-print containers using a Go template]:format: " \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ "($help -): :__docker_repositories" && ret=0 @@ -1722,8 +1710,7 @@ __docker_subcommand() { ;; (info|version) _arguments $(__docker_arguments) \ - $opts_help \ - "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0 + $opts_help && ret=0 ;; (inspect) local state @@ -1819,23 +1806,6 @@ __docker_subcommand() { $opts_help \ "($help -)*:containers:__docker_runningcontainers" && ret=0 ;; - (plugin) - local curcontext="$curcontext" state - _arguments $(__docker_arguments) \ - $opts_help \ - "($help -): :->command" \ - "($help -)*:: :->option-or-argument" && ret=0 - - case $state in - (command) - __docker_plugin_commands && ret=0 - ;; - (option-or-argument) - curcontext=${curcontext%:*:*}:docker-${words[-1]}: - __docker_plugin_subcommand && ret=0 - ;; - esac - ;; (port) _arguments $(__docker_arguments) \ $opts_help \ @@ -1848,9 +1818,9 @@ __docker_subcommand() { "($help -a --all)"{-a,--all}"[Show all containers]" \ "($help)--before=[Show only container created before...]:containers:__docker_containers" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ - "($help)--format[Pretty-print containers using a Go template]:template: " \ + "($help)--format[Pretty-print containers using a Go template]:format: " \ "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ - "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ + "($help)-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)" \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ "($help -s --size)"{-s,--size}"[Display total file sizes]" \ From f39dcfda8d287bdfeda2bc1e0a7ab3785c6e4a73 Mon Sep 17 00:00:00 2001 From: Zach Himsel Date: Tue, 20 Sep 2016 10:40:54 -0600 Subject: [PATCH 054/121] Update docker completion from upstream (#5426) https://github.com/docker/docker/blob/be9e3f59e625a7be05f21a23f6debfb3f6728573/contrib/completion/zsh/_docker --- plugins/docker/_docker | 67 +++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 55437924..1366fd61 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -138,7 +138,7 @@ __docker_containers_names() { __docker_get_containers all names "$@" } -__docker_plugins() { +__docker_complete_info_plugins() { [[ $PREFIX = -* ]] && return 1 integer ret=1 emulate -L zsh @@ -228,7 +228,7 @@ __docker_get_log_options() { journald_options=("env" "labels" "tag") json_file_options=("env" "labels" "max-file" "max-size") syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") - splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "tag") + splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 @@ -340,7 +340,7 @@ __docker_complete_ps_filters() { __docker_networks && ret=0 ;; (status) - status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running') + status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing') _describe -t status-filter-opts "Status Filter Options" status_opts && ret=0 ;; (volume) @@ -434,7 +434,7 @@ __docker_complete_events_filter() { (event) local -a event_opts event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' - 'exec_start' 'export' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' + 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') _describe -t event-filter-opts "event filter options" event_opts && ret=0 ;; @@ -463,6 +463,8 @@ __docker_complete_events_filter() { return ret } +# BO network + __docker_network_complete_ls_filters() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -470,7 +472,7 @@ __docker_network_complete_ls_filters() { if compset -P '*='; then case "${${words[-1]%=*}#*=}" in (driver) - __docker_plugins Network && ret=0 + __docker_complete_info_plugins Network && ret=0 ;; (id) __docker_networks_ids && ret=0 @@ -629,6 +631,7 @@ __docker_network_subcommand() { $opts_help \ "($help)--no-trunc[Do not truncate the output]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)--format=[Pretty-print networks using a Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 case $state in (filter-options) @@ -649,6 +652,8 @@ __docker_network_subcommand() { return ret } +# EO network + # BO node __docker_node_complete_ls_filters() { @@ -716,7 +721,6 @@ __docker_nodes() { [[ $filter != "none" ]] && args=("-f $filter") lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"}) - # Parse header line to find columns local i=1 j=1 k header=${lines[1]} declare -A begin end @@ -788,7 +792,7 @@ __docker_node_commands() { "ls:List nodes in the swarm" "promote:Promote a node as manager in the swarm" "rm:Remove one or more nodes from the swarm" - "ps:List tasks running on a node" + "ps:List tasks running on a node, defaults to current node" "update:Update a node" ) _describe -t docker-node-commands "docker node command" _docker_node_subcommands @@ -842,6 +846,7 @@ __docker_node_subcommand() { "($help -a --all)"{-a,--all}"[Display all instances]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)--no-resolve[Do not map IDs to Names]" \ + "($help)--no-trunc[Do not truncate output]" \ "($help -)1:node:__docker_complete_nodes" && ret=0 case $state in (filter-options) @@ -1078,6 +1083,7 @@ __docker_service_subcommand() { "($help)*--constraint=[Placement constraints]:constraint: " "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" "($help)*"{-e=,--env=}"[Set environment variables]:env: " + "($help)*--group-add=[Add additional user groups to the container]:group:_groups" "($help)*--label=[Service labels]:label: " "($help)--limit-cpu=[Limit CPUs]:value: " "($help)--limit-memory=[Limit Memory]:value: " @@ -1157,6 +1163,7 @@ __docker_service_subcommand() { "($help -a --all)"{-a,--all}"[Display all tasks]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)--no-resolve[Do not map IDs to Names]" \ + "($help)--no-trunc[Do not truncate output]" \ "($help -)1:service:__docker_complete_services" && ret=0 case $state in (filter-options) @@ -1171,6 +1178,7 @@ __docker_service_subcommand() { "($help)--arg=[Service command args]:arguments: _normal" \ "($help)*--container-label-add=[Add or update container labels]:label: " \ "($help)*--container-label-rm=[Remove a container label by its key]:label: " \ + "($help)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \ "($help)--image=[Service image tag]:image:__docker_repositories" \ "($help -)1:service:__docker_complete_services" && ret=0 ;; @@ -1250,6 +1258,8 @@ __docker_swarm_subcommand() { # EO swarm +# BO volume + __docker_volume_complete_ls_filters() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -1261,7 +1271,7 @@ __docker_volume_complete_ls_filters() { _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0 ;; (driver) - __docker_plugins Volume && ret=0 + __docker_complete_info_plugins Volume && ret=0 ;; (name) __docker_volumes && ret=0 @@ -1271,7 +1281,7 @@ __docker_volume_complete_ls_filters() { ;; esac else - opts=('dangling' 'driver' 'name') + opts=('dangling' 'driver' 'label' 'name') _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 fi @@ -1330,12 +1340,12 @@ __docker_volume_subcommand() { case "$words[1]" in (create) - _arguments $(__docker_arguments) \ + _arguments $(__docker_arguments) -A '-*' \ $opts_help \ "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \ "($help)*--label=[Set metadata for a volume]:label=value: " \ - "($help)--name=[Volume name]" \ - "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " && ret=0 + "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \ + "($help -)1:Volume name: " && ret=0 ;; (inspect) _arguments $(__docker_arguments) \ @@ -1347,6 +1357,7 @@ __docker_volume_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ + "($help)--format=[Pretty-print volumes using a Go template]:template: " \ "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 case $state in (filter-options) @@ -1357,6 +1368,7 @@ __docker_volume_subcommand() { (rm) _arguments $(__docker_arguments) \ $opts_help \ + "($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \ "($help -):volume:__docker_volumes" && ret=0 ;; (help) @@ -1367,6 +1379,8 @@ __docker_volume_subcommand() { return ret } +# EO volume + __docker_caching_policy() { oldp=( "$1"(Nmh+1) ) # 1 hour (( $#oldp )) @@ -1646,7 +1660,8 @@ __docker_subcommand() { $opts_help \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \ "($help)--since=[Events created since this timestamp]:timestamp: " \ - "($help)--until=[Events created until this timestamp]:timestamp: " && ret=0 + "($help)--until=[Events created until this timestamp]:timestamp: " \ + "($help)--format=[Format the output using the given go template]:template: " && ret=0 ;; (exec) local state @@ -1689,7 +1704,7 @@ __docker_subcommand() { "($help -a --all)"{-a,--all}"[Show all images]" \ "($help)--digests[Show digests]" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ - "($help)--format[Pretty-print containers using a Go template]:format: " \ + "($help)--format[Pretty-print images using a Go template]:template: " \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ "($help -): :__docker_repositories" && ret=0 @@ -1710,7 +1725,8 @@ __docker_subcommand() { ;; (info|version) _arguments $(__docker_arguments) \ - $opts_help && ret=0 + $opts_help \ + "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0 ;; (inspect) local state @@ -1806,6 +1822,23 @@ __docker_subcommand() { $opts_help \ "($help -)*:containers:__docker_runningcontainers" && ret=0 ;; + (plugin) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_plugin_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_plugin_subcommand && ret=0 + ;; + esac + ;; (port) _arguments $(__docker_arguments) \ $opts_help \ @@ -1818,9 +1851,9 @@ __docker_subcommand() { "($help -a --all)"{-a,--all}"[Show all containers]" \ "($help)--before=[Show only container created before...]:containers:__docker_containers" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ - "($help)--format[Pretty-print containers using a Go template]:format: " \ + "($help)--format[Pretty-print containers using a Go template]:template: " \ "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ - "($help)-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)" \ + "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ "($help -s --size)"{-s,--size}"[Display total file sizes]" \ From 7e5483d672aab9764231d9a569b6c7451474eecb Mon Sep 17 00:00:00 2001 From: Dawnflash Lightstring Date: Wed, 21 Sep 2016 12:20:08 +0200 Subject: [PATCH 055/121] Add check for git and bzr to agnoster theme Plugin command-not-found on Arch Linux returns 0 if git or bzr is found in repos, hence outputting unwanted pkgfile output. Checking if the commands exist first fixes all such issues. --- themes/agnoster.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index e1a294ee..07546fd3 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -86,7 +86,7 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { - + (( $+commands[git] )) || return local PL_BRANCH_CHAR () { local LC_ALL="" LC_CTYPE="en_US.UTF-8" @@ -128,6 +128,7 @@ prompt_git() { } prompt_bzr() { + (( $+commands[bzr] )) || return if (bzr status >/dev/null 2>&1); then status_mod=`bzr status | head -n1 | grep "modified" | wc -m` status_all=`bzr status | head -n1 | wc -m` From 973c92cd91d595fde37a4dbd5a6389072654252f Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Wed, 21 Sep 2016 11:55:58 -0400 Subject: [PATCH 056/121] Adds option for directory to Xcode xc function. (#5253) --- plugins/xcode/README.md | 2 +- plugins/xcode/xcode.plugin.zsh | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index 15e65785..c12ce047 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -26,7 +26,7 @@ plugins=(... xcode) ### `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. +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. You can also specify a directory to look in for the Xcode files. Returns 1 if it didn't find any relevant files. ### `simulator` diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 0a2fa083..f711c39f 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -7,10 +7,19 @@ alias xcsel='sudo xcode-select --switch' # source: http://gist.github.com/subdigital/5420709 function xc { local xcode_proj - xcode_proj=(*.{xcworkspace,xcodeproj}(N)) + if [[ $# == 0 ]]; then + xcode_proj=(*.{xcworkspace,xcodeproj}(N)) + else + xcode_proj=($1/*.{xcworkspace,xcodeproj}(N)) + fi + if [[ ${#xcode_proj} -eq 0 ]]; then - echo "No xcworkspace/xcodeproj file found in the current directory." + if [[ $# == 0 ]]; then + echo "No xcworkspace/xcodeproj file found in the current directory." + else + echo "No xcworkspace/xcodeproj file found in $1." + fi return 1 else echo "Found ${xcode_proj[1]}" From bd599066d763a0792b6c6b1654f098f3ca6e1df7 Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Fri, 12 Aug 2016 20:50:57 +0200 Subject: [PATCH 057/121] Added angular-cli (ng) completion. --- plugins/ng/ng.plugin.zsh | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 plugins/ng/ng.plugin.zsh diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh new file mode 100644 index 00000000..8e9b4ab1 --- /dev/null +++ b/plugins/ng/ng.plugin.zsh @@ -0,0 +1,73 @@ + +ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get h help i init install lint make-this-awesome new s serve server set t test v version -h --help' + +_ng_completion () { + local words cword opts + read -Ac words + read -cn cword + let cword-=1 + + case $words[cword] in + addon ) + opts='-b --blueprint -d -dir --directory --dry-run -sb --skip-bower -sg --skip-git -sn --skip-npm -v --verbose' + ;; + + asset-sizes ) + opts='-o --output-path' + ;; + + i | install) + opts='' + ;; + + b | build ) + opts='--environment --output-path --suppress-sizes --watch --watcher -dev -e -prod' + ;; + + d | destroy ) + opts='--dry-run --verbose --pod --classic --dummy --in-repo --in-repo-addon -d -v -p -c -dum -id -ir' + ;; + + g | generate ) + opts='component directive pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + ;; + + h | help | -h | --help) + opts='--json --verbose -v' + ;; + + init ) + opts='--blueprint --dry-run --link-cli --mobile --name --prefix --skip-bower --skip-npm --source-dir --style --verbose -b -d -lc -n -p -sb -sd -sn -v' + ;; + + new ) + opts='--blueprint --directory --dry-run --link-cli --mobile --prefix --skip-bower --skip-git --skip-npm --source-dir --style --verbose -b -d -dir -lc -p -sb -sd -sg -sn -v' + ;; + + s | serve | server ) + opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-host --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -w' + ;; + + set ) + opts='--global -g' + ;; + + t | test ) + opts='--browsers --colors --config-file --environment --filter --host --launch --log-level --module --path --port --query --reporter --server --silent --test-page --test-port --watch -H -c -cf -e -f -m -r -s -tp -w' + ;; + + v | version ) + opts='--verbose' + ;; + + ng | *) + opts=$ng_opts + ;; + esac + + setopt shwordsplit + reply=($opts) + unset shwordsplit +} + +compctl -K _ng_completion ng From a748f513a6270fafca8328d614c7200a6f1e7484 Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Fri, 12 Aug 2016 21:01:51 +0200 Subject: [PATCH 058/121] The argument completion also has no extra options. --- plugins/ng/ng.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh index 8e9b4ab1..ce34c8b5 100644 --- a/plugins/ng/ng.plugin.zsh +++ b/plugins/ng/ng.plugin.zsh @@ -16,7 +16,7 @@ _ng_completion () { opts='-o --output-path' ;; - i | install) + completion | i | install) opts='' ;; From 3da2f7ea6a5aa6ea312846e070b534df5aa78baf Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Fri, 12 Aug 2016 23:43:19 +0200 Subject: [PATCH 059/121] Updated options for generate. Added gh-pages:deploy / github-pages:deploy. --- plugins/ng/ng.plugin.zsh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh index ce34c8b5..2488bc23 100644 --- a/plugins/ng/ng.plugin.zsh +++ b/plugins/ng/ng.plugin.zsh @@ -1,5 +1,5 @@ -ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get h help i init install lint make-this-awesome new s serve server set t test v version -h --help' +ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version -h --help' _ng_completion () { local words cword opts @@ -16,12 +16,8 @@ _ng_completion () { opts='-o --output-path' ;; - completion | i | install) - opts='' - ;; - b | build ) - opts='--environment --output-path --suppress-sizes --watch --watcher -dev -e -prod' + opts='--environment --output-path --suppress-sizes --target --watch --watcher -dev -e -prod' ;; d | destroy ) @@ -29,7 +25,11 @@ _ng_completion () { ;; g | generate ) - opts='component directive pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + opts='class component directive enum module pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + ;; + + gh-pages:deploy | github-pages:deploy ) + opts='--environment --gh-token --gh-username --skip-build --user-page --message' ;; h | help | -h | --help) @@ -45,7 +45,7 @@ _ng_completion () { ;; s | serve | server ) - opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-host --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -w' + opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --target --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -t -w' ;; set ) @@ -60,9 +60,13 @@ _ng_completion () { opts='--verbose' ;; - ng | *) + ng ) opts=$ng_opts ;; + + * ) + opts='' + ;; esac setopt shwordsplit From 34bc556bd3500da316e020fb2cec3ba8dc6115ab Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Mon, 15 Aug 2016 15:27:38 +0200 Subject: [PATCH 060/121] Added README.md --- plugins/ng/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 plugins/ng/README.md diff --git a/plugins/ng/README.md b/plugins/ng/README.md new file mode 100644 index 00000000..86ad6404 --- /dev/null +++ b/plugins/ng/README.md @@ -0,0 +1,37 @@ +## NG Plugin + +This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng) + adds completion support for Angular's CLI (named ng). + +Ng is hosted on [ng home](https://github.com/catull/angular-cli) + +It is used to generate Angular 2 app "stubs", build those apps, configure them, +test them, lint them etc. + +Ahem, "stubs" is not what Angular engineers refer to the items ng can generate +for you. + +"Stubs" can be any one of: +- class +- component +- directive +- enum +- module +- pipe +- route +- service + +At the moment, `ng completion` creates a very rough completion for Zsh and +Bash. + +It is missing most of the options and a few arguments. +In future, this plugin may be shortened to simply being + +```zsh +eval `ng completion` +``` + +There is hope this materialises in the 21st century. + +### CONTRIBUTOR + - Carlo Dapor ([catull](https://github.com/catull)) From 904d0ccef9a3508df61f9b0bb784d8b59d5e8bb2 Mon Sep 17 00:00:00 2001 From: Shang Yehua Date: Tue, 6 Sep 2016 11:10:42 +0800 Subject: [PATCH 061/121] Add some prompts for "install:install-file" (#5376) Add "-DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile=" to options for "install:install-file" for when you need install a local jar file. Closes #5376. --- plugins/mvn/mvn.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index d290c98e..625aad94 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -172,7 +172,7 @@ function listMavenCompletions { gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test # options - -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true + -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile= # arguments -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X From 0d897cca7499a4dd46536acbd999723fd0ca2b5d Mon Sep 17 00:00:00 2001 From: Gravemind Date: Thu, 22 Sep 2016 00:30:35 +0200 Subject: [PATCH 062/121] Fix hyphen and underscore filename completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This deletes the previous hack that allowed completing files with the extension: e.g. `abcd.z` to `abcdefg.z`. It is still possible to use `abcd[TAB].z`, and hyphens or underscores are very much more important than this other trick. Source: https://github.com/robbyrussell/oh-my-zsh/issues/1398#issuecomment-169163149 Signed-off-by: Marc Cornellà --- lib/completion.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index f5b29247..85c89216 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -12,14 +12,14 @@ zmodload -i zsh/complist ## case-insensitive (all),partial-word and then substring completion if [ "x$CASE_SENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' unset CASE_SENSITIVE else if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' unset HYPHEN_INSENSITIVE else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' fi fi From 4e12024b0b883f31ab80a749d7ad6fadcee96904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 22 Sep 2016 00:40:00 +0200 Subject: [PATCH 063/121] Fix styling of lib/completion.zsh --- lib/completion.zsh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index 85c89216..bbd02165 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -1,4 +1,7 @@ # fixme - the load process here seems a bit bizarre +zmodload -i zsh/complist + +WORDCHARS='' unsetopt menu_complete # do not autoselect the first completion entry unsetopt flowcontrol @@ -6,32 +9,26 @@ setopt auto_menu # show completion menu on succesive tab press setopt complete_in_word setopt always_to_end -WORDCHARS='' +# should this be in keybindings? +bindkey -M menuselect '^o' accept-and-infer-next-history +zstyle ':completion:*:*:*:*:*' menu select -zmodload -i zsh/complist - -## case-insensitive (all),partial-word and then substring completion -if [ "x$CASE_SENSITIVE" = "xtrue" ]; then +# case insensitive (all), partial-word and substring completion +if [[ "$CASE_SENSITIVE" = true ]]; then zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' - unset CASE_SENSITIVE else - if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then + if [[ "$HYPHEN_INSENSITIVE" = true ]]; then zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' - unset HYPHEN_INSENSITIVE else zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' fi fi +unset CASE_SENSITIVE HYPHEN_INSENSITIVE zstyle ':completion:*' list-colors '' - -# should this be in keybindings? -bindkey -M menuselect '^o' accept-and-infer-next-history - -zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -if [ "$OSTYPE[0,7]" = "solaris" ] -then + +if [[ "$OSTYPE" = solaris* ]]; then zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" else zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" From 1b7fc2f3aca32ba8713be0e27305c5cf578033f6 Mon Sep 17 00:00:00 2001 From: Brad Urani Date: Thu, 22 Sep 2016 10:41:30 -0700 Subject: [PATCH 064/121] Add copybuffer function and keybinding (#5431) * Add copybuffer function and keybinding: binds ctrl-o to copy the command line buffer to the system clipboard. * Add README --- plugins/copybuffer/README.md | 11 +++++++++++ plugins/copybuffer/copybuffer.plugin.zsh | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 plugins/copybuffer/README.md create mode 100644 plugins/copybuffer/copybuffer.plugin.zsh diff --git a/plugins/copybuffer/README.md b/plugins/copybuffer/README.md new file mode 100644 index 00000000..da138bdb --- /dev/null +++ b/plugins/copybuffer/README.md @@ -0,0 +1,11 @@ +# `copybuffer` plugin + +This plugin binds the ctrl-o keyboard shortcut to a command that copies the text +that is currently typed in the command line ($BUFFER) to the system clipboard. + +This is useful if you type a command - and before you hit enter to execute it - want +to copy it maybe so you can paste it into a script, gist or whatnot. + +```zsh +plugins=(... copybuffer) +``` diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh new file mode 100644 index 00000000..cc205d40 --- /dev/null +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -0,0 +1,14 @@ +# copy the active line from the command line buffer +# onto the system clipboard (requires clipcopy plugin) + +copybuffer () { + if which clipcopy &>/dev/null; then + echo $BUFFER | clipcopy + else + echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." + fi +} + +zle -N copybuffer + +bindkey "^O" copybuffer From 57fcee0f1c520a7c5e3aa5e2bde974154cdaf0c3 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sat, 24 Sep 2016 16:06:44 -0700 Subject: [PATCH 065/121] README copy updates --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aab1af9f..6da73189 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ Oh My Zsh

-Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again. +Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. -__Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able to take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. +That sounds boring. Let's try this again. + +__Oh My Zsh is a way of life!__ + +Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_ + +Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. @@ -202,7 +208,10 @@ Thank you so much! ## Follow Us -We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. +We're on the social medias. + +* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. +* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook. ## Merchandise From 798c38dd1a70637cd17c26879be83e7f25a3ee53 Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Tue, 27 Sep 2016 15:18:23 +0300 Subject: [PATCH 066/121] globalias fix #4834 --- plugins/globalias/globalias.plugin.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plugins/globalias/globalias.plugin.zsh diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh new file mode 100644 index 00000000..95a0e307 --- /dev/null +++ b/plugins/globalias/globalias.plugin.zsh @@ -0,0 +1,11 @@ +globalias() { + zle _expand_alias + zle expand-word + zle self-insert +} +zle -N globalias +bindkey -e " " globalias +bindkey -v " " globalias +bindkey -e "^ " magic-space # control-space to bypass completion +bindkey -v "^ " magic-space +bindkey -M isearch " " magic-space # normal space during searches From 65874f2b2201c2e55d410ab322dc20394a587b83 Mon Sep 17 00:00:00 2001 From: Leif Ringstad Date: Wed, 28 Sep 2016 14:47:00 +0200 Subject: [PATCH 067/121] Add more docker compose aliases (#5422) Adds the following aliases: ```zsh alias dco='docker-compose' alias dcr='docker-compose run' alias dce='docker-compose exec' ``` And sorts the aliases similar to `docker-compose help` order --- plugins/docker-compose/docker-compose.plugin.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 351e7782..9f2457fc 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -5,9 +5,16 @@ # Aliases ################################################################### -alias dcup='docker-compose up' +# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator' +# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html + +alias dco='docker-compose' + alias dcb='docker-compose build' -alias dcrm='docker-compose rm' +alias dce='docker-compose exec' alias dcps='docker-compose ps' -alias dcstop='docker-compose stop' alias dcrestart='docker-compose restart' +alias dcrm='docker-compose rm' +alias dcr='docker-compose run' +alias dcstop='docker-compose stop' +alias dcup='docker-compose up' From ac8915d43f0e8de9294c8552dc338ecc9993acd2 Mon Sep 17 00:00:00 2001 From: Diego Said Anaya Mancilla Date: Wed, 28 Sep 2016 14:28:53 -0500 Subject: [PATCH 068/121] Update pip plugin to last stable release (#5472) Update pip plugin to last stable release --- plugins/pip/_pip | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/plugins/pip/_pip b/plugins/pip/_pip index cb155e5f..732ffabe 100644 --- a/plugins/pip/_pip +++ b/plugins/pip/_pip @@ -1,7 +1,8 @@ #compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4 #autoload -# pip zsh completion, based on homebrew completion +# pip zsh completion, based on last stable release (pip8) +# homebrew completion and backwards compatibility _pip_all() { # we cache the list of packages (originally from the macports plugin) @@ -17,30 +18,43 @@ _pip_installed() { local -a _1st_arguments _1st_arguments=( - 'bundle:create pybundles (archives containing multiple packages)' - 'freeze:output all currently installed packages (exact versions) to stdout' - 'help:show available commands' - 'show:show information about installed packages' 'install:install packages' - 'search:search PyPI' + 'download:download packages' 'uninstall:uninstall packages' - 'unzip:unzip individual packages' - 'zip:zip individual packages' + 'freeze:output all currently installed packages (exact versions) to stdout' + 'list:list installed packages' + 'show:show information about installed packages' + 'search:search PyPI' + 'wheel:build individual wheel archives for your requirements and dependencies' + 'hash:compute a hash of a local package archive' + 'help:show available commands' + 'bundle:create pybundles (archives containing multiple packages)(deprecated)' + 'unzip:unzip individual packages(deprecated)' + 'zip:zip individual packages(deprecated)' ) local expl local -a all_pkgs installed_pkgs _arguments \ - '(--version)--version[show version number of program and exit]' \ '(-h --help)'{-h,--help}'[show help]' \ - '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \ - '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \ + '(--isolated)--isolated[run pip in isolated mode, ignores environment variables and user configuration]' \ '(-v --verbose)'{-v,--verbose}'[give more output]' \ + '(-V --version)'{-V,--version}'[show version number of program and exit]' \ '(-q --quiet)'{-q,--quiet}'[give less output]' \ '(--log)--log[log file location]' \ '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \ + '(--retries)--retries[max number of retries per connection (default 5 times)]' \ '(--timeout)--timeout[socket timeout (default 15s)]' \ + '(--exists-action)--exists-action[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]' \ + '(--trusted-host)--trusted-host[mark this host as trusted]' \ + '(--cert)--cert[path to alternate CA bundle]' \ + '(--client-cert)--client-cert[path to SSL client certificate]' \ + '(--cache-dir)--cache-dir[store the cache data in specified directory]' \ + '(--no-cache-dir)--no-cache-dir[disable de cache]' \ + '(--disable-pip-version-check)--disable-pip-version-check[do not check periodically for new pip version downloads]' \ + '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in (deprecated)]' \ + '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv (deprecated)]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then @@ -56,7 +70,7 @@ case "$words[1]" in _arguments \ '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;; install) - _arguments \ + _arguments \ '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \ '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \ '(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \ From 10ffa4fe992e56a93396ed8914eba74821bb2cca Mon Sep 17 00:00:00 2001 From: Christian Ferbar Date: Tue, 27 Sep 2016 12:27:37 +0200 Subject: [PATCH 069/121] Add README to svn plugin --- plugins/svn/README.md | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/svn/README.md diff --git a/plugins/svn/README.md b/plugins/svn/README.md new file mode 100644 index 00000000..b8eff70f --- /dev/null +++ b/plugins/svn/README.md @@ -0,0 +1,64 @@ +# `svn` plugin + +This plugin adds some utility functions to display additional information regarding your current +svn repsitiory. See http://subversion.apache.org/ for the full svn documentation. + +## Functions + +| Command | Description | +|:-----------------------|:----------------------------------------| +|svn_prompt_info | prompt for some themes | +|in_svn | within svn directory | +|svn_get_repo_name | | +|svn_get_branch_name | branch name (see caveats) | +|svn_get_rev_nr | revision number | +|svn_dirty | changes in this subversion repo | + +## Caveats + +The plugin expects the first directory to be the current branch / tag / trunk. So, it returns +the first path element if you don't use branches. + +## Usage + +To use it, add `svn` to your plugins array: +```sh +plugins=(... svn) +``` + +### Agnoster theme git-like prompt + +Enable the svn plugin and add the followind lines to your ```~/.zshrc``` + +```shell +prompt_svn() { + local rev branch + if in_svn; then + rev=$(svn_get_rev_nr) + branch=$(svn_get_branch_name) + if [ `svn_dirty_choose_pwd 1 0` -eq 1 ]; then + prompt_segment yellow black + echo -n "$rev@$branch" + echo -n "±" + else + prompt_segment green black + echo -n "$rev@$branch" + fi + fi +} +``` + +override the agnoster build_prompt() function: + +```shell +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_svn + prompt_end +} +``` + From 364019a3c9c4ef08d2d7f0752c0ac008293d62df Mon Sep 17 00:00:00 2001 From: Christian Ferbar Date: Tue, 27 Sep 2016 12:29:25 +0200 Subject: [PATCH 070/121] Add localization workaround to svn plugin --- plugins/svn/svn.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 816055af..e95ee9d9 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -25,14 +25,14 @@ function in_svn() { function svn_get_repo_name() { if in_svn; then - svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT - svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" + LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT + LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p" fi } function svn_get_branch_name() { local _DISPLAY=$( - svn info 2> /dev/null | \ + LANG=C svn info 2> /dev/null | \ awk -F/ \ '/^URL:/ { \ for (i=0; i<=NF; i++) { \ @@ -54,13 +54,13 @@ function svn_get_branch_name() { function svn_get_rev_nr() { if in_svn; then - svn info 2> /dev/null | sed -n 's/Revision:\ //p' + LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p' fi } function svn_dirty_choose() { if in_svn; then - local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` + local root=`LANG=C 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 From f573247a59773f47b1741967335ec6c495bcf4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 29 Sep 2016 13:56:16 +0200 Subject: [PATCH 071/121] Clean up svn README --- plugins/svn/README.md | 103 ++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/plugins/svn/README.md b/plugins/svn/README.md index b8eff70f..1f7b70c8 100644 --- a/plugins/svn/README.md +++ b/plugins/svn/README.md @@ -1,64 +1,67 @@ # `svn` plugin This plugin adds some utility functions to display additional information regarding your current -svn repsitiory. See http://subversion.apache.org/ for the full svn documentation. - -## Functions - -| Command | Description | -|:-----------------------|:----------------------------------------| -|svn_prompt_info | prompt for some themes | -|in_svn | within svn directory | -|svn_get_repo_name | | -|svn_get_branch_name | branch name (see caveats) | -|svn_get_rev_nr | revision number | -|svn_dirty | changes in this subversion repo | - -## Caveats - -The plugin expects the first directory to be the current branch / tag / trunk. So, it returns -the first path element if you don't use branches. - -## Usage +svn repository. See http://subversion.apache.org/ for the full svn documentation. To use it, add `svn` to your plugins array: -```sh + +```zsh plugins=(... svn) ``` -### Agnoster theme git-like prompt +## Functions -Enable the svn plugin and add the followind lines to your ```~/.zshrc``` +| Command | Description | +|:----------------------|:--------------------------------------------| +| `svn_prompt_info` | Shows svn prompt in themes | +| `in_svn` | Checks if we're in an svn repository | +| `svn_get_repo_name` | Get repository name | +| `svn_get_branch_name` | Get branch name (see [caveats](#caveats)) | +| `svn_get_rev_nr` | Get revision number | +| `svn_dirty` | Checks if there are changes in the svn repo | -```shell -prompt_svn() { - local rev branch - if in_svn; then - rev=$(svn_get_rev_nr) - branch=$(svn_get_branch_name) - if [ `svn_dirty_choose_pwd 1 0` -eq 1 ]; then - prompt_segment yellow black - echo -n "$rev@$branch" - echo -n "±" - else - prompt_segment green black - echo -n "$rev@$branch" +## Caveats + +The plugin expects the first directory to be the current branch / tag / trunk. So it returns +the first path element if you don't use branches. + +## Usage on themes + +To use this in the `agnoster` theme follow these instructions: + +1. Enable the svn plugin + +2. Add the following lines to your `zshrc` file: + + ```shell + prompt_svn() { + local rev branch + if in_svn; then + rev=$(svn_get_rev_nr) + branch=$(svn_get_branch_name) + if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then + prompt_segment yellow black + echo -n "$rev@$branch" + echo -n "±" + else + prompt_segment green black + echo -n "$rev@$branch" + fi fi - fi -} -``` + } + ``` -override the agnoster build_prompt() function: +3. Override the agnoster `build_prompt()` function: -```shell -build_prompt() { - RETVAL=$? - prompt_status - prompt_context - prompt_dir - prompt_git - prompt_svn - prompt_end -} -``` + ```zsh + build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_svn + prompt_end + } + ``` From e6df0e036e39bcc2c20d7feaef1749d3c4f2768f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 29 Sep 2016 14:03:09 +0200 Subject: [PATCH 072/121] Clean up and refactor code in svn plugin --- plugins/svn/svn.plugin.zsh | 58 ++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index e95ee9d9..fbc9ee53 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -1,9 +1,7 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 -# -function svn_prompt_info() { +svn_prompt_info() { local _DISPLAY if in_svn; then - if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then + if [[ "$SVN_SHOW_BRANCH" = true ]]; then unset SVN_SHOW_BRANCH _DISPLAY=$(svn_get_branch_name) else @@ -16,21 +14,18 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S } -function in_svn() { - if $(svn info >/dev/null 2>&1); then - return 0 - fi - return 1 +in_svn() { + svn info >/dev/null 2>&1 } -function svn_get_repo_name() { +svn_get_repo_name() { if in_svn; then LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p" fi } -function svn_get_branch_name() { +svn_get_branch_name() { local _DISPLAY=$( LANG=C svn info 2> /dev/null | \ awk -F/ \ @@ -44,41 +39,28 @@ function svn_get_branch_name() { } \ }' ) - - if [ "x$_DISPLAY" = "x" ]; then + + if [[ -z "$_DISPLAY" ]]; then svn_get_repo_name else echo $_DISPLAY fi } -function svn_get_rev_nr() { +svn_get_rev_nr() { if in_svn; then LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p' fi } -function svn_dirty_choose() { - if in_svn; then - local root=`LANG=C 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 - else - # Otherwise, no lines were found, or an error occurred. Return clean. - echo $2 - fi - fi -} - -function svn_dirty() { +svn_dirty() { svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN } -function svn_dirty_choose_pwd () { +svn_dirty_choose() { if in_svn; then - local root=$PWD - if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then + local root=$(LANG=C 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 else @@ -88,8 +70,18 @@ function svn_dirty_choose_pwd () { fi } -function svn_dirty_pwd () { +svn_dirty_pwd () { svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD } - +svn_dirty_choose_pwd () { + if in_svn; then + if svn status "$PWD" 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 + else + # Otherwise, no lines were found, or an error occurred. Return clean. + echo $2 + fi + fi +} From 09d95251a7176e0c4b2a71837b7356980fe738e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 29 Sep 2016 13:19:47 +0200 Subject: [PATCH 073/121] extract: fix styling --- plugins/extract/_extract | 2 - plugins/extract/extract.plugin.zsh | 149 ++++++++++++++--------------- 2 files changed, 71 insertions(+), 80 deletions(-) diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 387b344b..a73c892d 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -4,5 +4,3 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0 - - diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 5d0809e9..081d5168 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,80 +1,73 @@ -# ------------------------------------------------------------------------------ -# FILE: extract.plugin.zsh -# DESCRIPTION: oh-my-zsh plugin file. -# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) -# VERSION: 1.0.1 -# ------------------------------------------------------------------------------ - - -function extract() { - local remove_archive - local success - local file_name - local extract_dir - - if (( $# == 0 )); then - echo "Usage: extract [-option] [file ...]" - echo - echo Options: - echo " -r, --remove Remove archive." - echo - echo "Report bugs to ." - fi - - remove_archive=1 - if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then - remove_archive=0 - shift - fi - - while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then - echo "extract: '$1' is not a valid file" 1>&2 - shift - continue - fi - - success=0 - file_name="$( basename "$1" )" - extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" - case "$1" in - (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; - (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ - && tar --xz -xvf "$1" \ - || xzcat "$1" | tar xvf - ;; - (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ - && tar --lzma -xvf "$1" \ - || lzcat "$1" | tar xvf - ;; - (*.tar) tar xvf "$1" ;; - (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;; - (*.bz2) bunzip2 "$1" ;; - (*.xz) unxz "$1" ;; - (*.lzma) unlzma "$1" ;; - (*.Z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; - (*.rar) unrar x -ad "$1" ;; - (*.7z) 7za x "$1" ;; - (*.deb) - mkdir -p "$extract_dir/control" - mkdir -p "$extract_dir/data" - cd "$extract_dir"; ar vx "../${1}" > /dev/null - cd control; tar xzvf ../control.tar.gz - cd ../data; tar xzvf ../data.tar.gz - cd ..; rm *.tar.gz debian-binary - cd .. - ;; - (*) - echo "extract: '$1' cannot be extracted" 1>&2 - success=1 - ;; - esac - - (( success = $success > 0 ? $success : $? )) - (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" - shift - done -} - alias x=extract +extract() { + local remove_archive + local success + local file_name + local extract_dir + + if (( $# == 0 )); then + cat <<-'EOF' >&2 + Usage: extract [-option] [file ...] + + Options: + -r, --remove Remove archive. + EOF + fi + + remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi + + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi + + success=0 + file_name="$( basename "$1" )" + extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" + case "$1" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$1" \ + || xzcat "$1" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$1" \ + || lzcat "$1" | tar xvf - ;; + (*.tar) tar xvf "$1" ;; + (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; + (*.bz2) bunzip2 "$1" ;; + (*.xz) unxz "$1" ;; + (*.lzma) unlzma "$1" ;; + (*.Z) uncompress "$1" ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; + (*.rar) unrar x -ad "$1" ;; + (*.7z) 7za x "$1" ;; + (*.deb) + mkdir -p "$extract_dir/control" + mkdir -p "$extract_dir/data" + cd "$extract_dir"; ar vx "../${1}" > /dev/null + cd control; tar xzvf ../control.tar.gz + cd ../data; tar xzvf ../data.tar.gz + cd ..; rm *.tar.gz debian-binary + cd .. + ;; + (*) + echo "extract: '$1' cannot be extracted" >&2 + success=1 + ;; + esac + + (( success = $success > 0 ? $success : $? )) + (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + shift + done +} From f12cb5a697ca45b3ef8acda24cef72fe041addb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 29 Sep 2016 13:20:26 +0200 Subject: [PATCH 074/121] extract: fix extraction of deb packages with data.tar.xz --- plugins/extract/extract.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 081d5168..24b16517 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -56,8 +56,8 @@ extract() { mkdir -p "$extract_dir/data" cd "$extract_dir"; ar vx "../${1}" > /dev/null cd control; tar xzvf ../control.tar.gz - cd ../data; tar xzvf ../data.tar.gz - cd ..; rm *.tar.gz debian-binary + cd ../data; extract ../data.tar.* + cd ..; rm *.tar.* debian-binary cd .. ;; (*) From 68425c266a5107e50a2897b7d7cfc0ccb9fb753c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 29 Sep 2016 13:26:50 +0200 Subject: [PATCH 075/121] extract: replace basename&sed w/ zsh variable expansion syntax `${var:t:h}` uses: - `${var:t}` which acts as `basename`. - `${var:r}` which removes the extension. See http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers --- plugins/extract/extract.plugin.zsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 24b16517..c524bf8f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -3,7 +3,6 @@ alias x=extract extract() { local remove_archive local success - local file_name local extract_dir if (( $# == 0 )); then @@ -29,8 +28,7 @@ extract() { fi success=0 - file_name="$( basename "$1" )" - extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" + extract_dir="${1:t:r}" case "$1" in (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; From b5dc976d236e8f8d276aa0aeff49980bfccb0532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 29 Sep 2016 13:38:01 +0200 Subject: [PATCH 076/121] extract: add file extensions to extract completion --- plugins/extract/_extract | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/extract/_extract b/plugins/extract/_extract index a73c892d..172425d2 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,4 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0 + "*::archive file:_files -g '(#i)*.(7z|Z|apk|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|xpi|xz|zip)(-.)'" \ + && return 0 From bac896fca7b1af1e4237e96c58a0c13b8ff2d0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 30 Sep 2016 00:37:14 +0200 Subject: [PATCH 077/121] extract: add README --- plugins/extract/README.md | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 plugins/extract/README.md diff --git a/plugins/extract/README.md b/plugins/extract/README.md new file mode 100644 index 00000000..c6bdd36d --- /dev/null +++ b/plugins/extract/README.md @@ -0,0 +1,46 @@ +# extract plugin + +This plugin defines a function called `extract` that extracts the archive file +you pass it, and it supports a wide variety of archive filetypes. + +This way you don't have to know what specific command extracts a file, you just +do `extract ` and the function takes care of the rest. + +To use it, add `extract` to the plugins array in your zshrc file: + +```zsh +plugins=(... extract) +``` + +## Supported file extensions + +| Extension | Description | +|:------------------|:-------------------------------------| +| `7z` | 7zip file | +| `Z` | Z archive (LZW) | +| `apk` | Android app file | +| `bz2` | Bzip2 file | +| `deb` | Debian package | +| `gz` | Gzip file | +| `ipsw` | iOS firmware file | +| `jar` | Java Archive | +| `lzma` | LZMA archive | +| `rar` | WinRAR archive | +| `sublime-package` | Sublime Text package | +| `tar` | Tarball | +| `tar.bz2` | Tarball with bzip2 compression | +| `tar.gz` | Tarball with gzip compression | +| `tar.xz` | Tarball with lzma2 compression | +| `tar.zma` | Tarball with lzma compression | +| `tbz` | Tarball with bzip compression | +| `tbz2` | Tarball with bzip2 compression | +| `tgz` | Tarball with gzip compression | +| `tlz` | Tarball with lzma compression | +| `txz` | Tarball with lzma2 compression | +| `war` | Web Application archive (Java-based) | +| `xpi` | Mozilla XPI module file | +| `xz` | LZMA2 archive | +| `zip` | Zip archive | + +See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for +more information regarding archive formats. From c713407f90e7024507c7fc621440cb171108e7f4 Mon Sep 17 00:00:00 2001 From: Allan Lewis Date: Fri, 30 Sep 2016 12:45:28 +0100 Subject: [PATCH 078/121] git.plugin.zsh: Don't run Git hooks when making a WIP commit (#4751) When making a WIP commit, we generally just want to save the state of the current branch temporarily, maybe because we want to push our work for backup purposes, or change branch to work on something else. Therefore, it's generally undesirable to run Git hooks, which might do things like run linters, because we probably don't care if our WIP has lint errors. --- 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 25da0350..ea9ff826 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -236,4 +236,4 @@ alias gupv='git pull --rebase -v' alias glum='git pull upstream master' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"' +alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip--"' From 3de0235ad26d4584727f4cce17c09f1b4ae6cee5 Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Fri, 30 Sep 2016 19:54:27 +0200 Subject: [PATCH 079/121] Add missing newline to end of `spotify status` output (#5480) --- plugins/osx/osx.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index aa6a256c..d7baa119 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -314,7 +314,7 @@ function spotify() { position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); - printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; + printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s\n" "$artist" "$album" "$track" "$position" "$duration"; fi } @@ -412,17 +412,17 @@ function spotify() { osascript -e 'tell application "Spotify" to playpause'; break ;; - "quit" ) + "quit" ) cecho "Quitting Spotify."; osascript -e 'tell application "Spotify" to quit'; exit 1 ;; - "next" ) + "next" ) cecho "Going to next track." ; osascript -e 'tell application "Spotify" to next track'; break ;; - "prev" ) + "prev" ) cecho "Going to previous track."; osascript -e 'tell application "Spotify" to previous track'; break ;; From 8ea56633a40411d1b43127b9cd88e8851edaf922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 28 Sep 2016 18:23:15 +0200 Subject: [PATCH 080/121] last-working-dir: clean up source --- .../last-working-dir.plugin.zsh | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index c458464c..c5278d64 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -1,26 +1,21 @@ -#!/usr/bin/env zsh -# Keeps track of the last used working directory and automatically jumps -# into it for new shells. - -# Flag indicating if we've previously jumped to last directory. +# Flag indicating if we've previously jumped to last directory typeset -g ZSH_LAST_WORKING_DIRECTORY -mkdir -p $ZSH_CACHE_DIR -cache_file="$ZSH_CACHE_DIR/last-working-dir" -# Updates the last directory once directory is changed. +# Updates the last directory once directory is changed chpwd_functions+=(chpwd_last_working_dir) -function chpwd_last_working_dir() { - # Use >| in case noclobber is set to avoid "file exists" error +chpwd_last_working_dir() { + local cache_file="$ZSH_CACHE_DIR/last-working-dir" pwd >| "$cache_file" } -# Changes directory to the last working directory. -function lwd() { - [[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`" +# Changes directory to the last working directory +lwd() { + local cache_file="$ZSH_CACHE_DIR/last-working-dir" + [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")" } -# Automatically jump to last working directory unless this isn't the first time -# this plugin has been loaded. +# Automatically jump to last working directory unless this +# isn't the first time this plugin has been loaded. if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true fi From fb6738a7e1d476ec9a74b0e8a04f5252f9de91fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 28 Sep 2016 18:30:46 +0200 Subject: [PATCH 081/121] last-working-dir: don't jump if not in $HOME --- plugins/last-working-dir/last-working-dir.plugin.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index c5278d64..e882b288 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -14,8 +14,10 @@ lwd() { [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")" } -# Automatically jump to last working directory unless this -# isn't the first time this plugin has been loaded. -if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then - lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true -fi +# Jump to last directory automatically unless: +# - this isn't the first time the plugin is loaded +# - it's not in $HOME directory +[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return +[[ "$PWD" != "$HOME" ]] && return + +lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true From c488ab15f3293c3870f66fe84fc7ee71a182f214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 28 Sep 2016 18:23:28 +0200 Subject: [PATCH 082/121] last-working-dir: add README --- plugins/last-working-dir/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/last-working-dir/README.md diff --git a/plugins/last-working-dir/README.md b/plugins/last-working-dir/README.md new file mode 100644 index 00000000..4cc4acab --- /dev/null +++ b/plugins/last-working-dir/README.md @@ -0,0 +1,9 @@ +# last-working-dir plugin + +Keeps track of the last used working directory and automatically jumps into it +for new shells, unless: + +- The plugin is already loaded. +- The current `$PWD` is not `$HOME`. + +Adds `lwd` function to jump to the last working directory. From 06d52a60389a85107ed8cc2e302a1e66f719f738 Mon Sep 17 00:00:00 2001 From: FireWave Date: Fri, 30 Sep 2016 14:12:03 -0400 Subject: [PATCH 083/121] Change confusing 12h-time without AM/PM to system-localized time --- themes/xiong-chiamiov-plus.zsh-theme | 2 +- themes/xiong-chiamiov.zsh-theme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/xiong-chiamiov-plus.zsh-theme b/themes/xiong-chiamiov-plus.zsh-theme index 095dae29..26cc3848 100644 --- a/themes/xiong-chiamiov-plus.zsh-theme +++ b/themes/xiong-chiamiov-plus.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%c"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/themes/xiong-chiamiov.zsh-theme b/themes/xiong-chiamiov.zsh-theme index 7c4c2e4f..9cf17f47 100644 --- a/themes/xiong-chiamiov.zsh-theme +++ b/themes/xiong-chiamiov.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%c"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' From 9263e9ca59a65cad53d1cf0581c2af344984c2af Mon Sep 17 00:00:00 2001 From: Adrian Petrescu Date: Fri, 30 Sep 2016 17:39:32 -0400 Subject: [PATCH 084/121] Add /usr/local/bin to autoenv search path (#5481) The current list of directories to search for autoenv on misses the default location on Ubuntu systems if you just do a normal `pip install autoenv` - [it will place](https://github.com/kennethreitz/autoenv/blob/master/setup.py#L16) `activate.sh` in `/usr/local/bin` unless you manually override the `--prefix` or something. The `/usr/local/opt/autoenv` is fine for macOS/homebrew installations but it would be nice not to have to manually patch on Linux :) --- plugins/autoenv/autoenv.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index ea2e56dd..af58ee77 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,7 +1,7 @@ # Activates autoenv or reports its failure () { if ! type autoenv_init >/dev/null; then - for d (~/.autoenv /usr/local/opt/autoenv); do + for d (~/.autoenv /usr/local/opt/autoenv /usr/local/bin); do if [[ -e $d/activate.sh ]]; then autoenv_dir=$d break From d186bc30d071559a36bb190a3c3b329b882ec183 Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Sun, 2 Oct 2016 16:34:54 +0200 Subject: [PATCH 085/121] Add aliases for docker-compose logs (#5475) --- plugins/docker-compose/docker-compose.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 9f2457fc..7e330701 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -18,3 +18,5 @@ alias dcrm='docker-compose rm' alias dcr='docker-compose run' alias dcstop='docker-compose stop' alias dcup='docker-compose up' +alias dcl='docker-compose logs' +alias dclf='docker-compose logs -f' From eaf18167bbf3ee30157728ec50850db73ada3455 Mon Sep 17 00:00:00 2001 From: Juraj Fiala Date: Tue, 18 Aug 2015 21:37:09 +0200 Subject: [PATCH 086/121] Added pacaur aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes most of its contents: it just leaves the contribution signature. The rest is obsolete and superseeded by #5460, but the contribution is still valuable. Related: #4263. Signed-off-by: Marc Cornellà --- plugins/archlinux/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index 785538a5..f32d91f7 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -67,3 +67,4 @@ - Martin Putniorz - mputniorz@gmail.com - MatthR3D - matthr3d@gmail.com - ornicar - thibault.duplessis@gmail.com +- Juraj Fiala - doctorjellyface@riseup.net From 485dd2b73671c257571601dda44e5fd94067271f Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Mon, 26 Sep 2016 23:17:18 -0700 Subject: [PATCH 087/121] Add pacaur compatibility to archlinux plugin + refactor --- plugins/archlinux/archlinux.plugin.zsh | 51 +++++++++++++++++++++----- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 1637e856..2e55d1b8 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -1,12 +1,4 @@ -if ! (( $+commands[yaourt] )); then - upgrade() { - sudo pacman -Syu - } -else - upgrade () { - yaourt -Syu - } - +if (( $+commands[yaourt] )); then alias yaconf='yaourt -C' alias yaupg='yaourt -Syua' alias yasu='yaourt -Syua --noconfirm' @@ -35,6 +27,47 @@ else fi fi +if (( $+commands[pacaur] )); then + alias paupg='pacaur -Syua' + alias pasu='pacaur -Syua --noconfirm' + alias pain='pacaur -S' + alias pains='pacaur -U' + alias pare='pacaur -R' + alias parem='pacaur -Rns' + alias parep='pacaur -Si' + alias pareps='pacaur -Ss' + alias paloc='pacaur -Qi' + alias palocs='pacaur -Qs' + alias palst='pacaur -Qe' + alias paorph='pacaur -Qtd' + alias painsd='pacaur -S --asdeps' + alias pamir='pacaur -Syy' + + if (( $+commands[abs] && $+commands[aur] )); then + alias paupd='pacaur -Sy && sudo abs && sudo aur' + elif (( $+commands[abs] )); then + alias paupd='pacaur -Sy && sudo abs' + elif (( $+commands[aur] )); then + alias paupd='pacaur -Sy && sudo aur' + else + alias paupd='pacaur -Sy' + fi +fi + +if (( $+commands[pacaur] )); then + upgrade() { + pacaur -Syu + } +elif (( $+commands[yaourt] )); then + upgrade() { + yaourt -Syu + } +else + upgrade() { + pacman -Syu + } +fi + # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips alias pacupg='sudo pacman -Syu' alias pacin='sudo pacman -S' From e418a2bb92f6b26773d9e55115803a7137c90eec Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Sun, 2 Oct 2016 14:28:39 -0700 Subject: [PATCH 088/121] Updated README of the archlinux plugin --- plugins/archlinux/README.md | 25 +++++++++++++++++++++++++ plugins/archlinux/archlinux.plugin.zsh | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index f32d91f7..73a5037b 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -27,6 +27,30 @@ | yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation | | upgrade | yaourt -Syu | Sync with repositories before upgrading packages | +### PACAUR + +| Alias | Command | Description | +|---------|------------------------------------|---------------------------------------------------------------------| +| pain | pacaur -S | Install packages from the repositories | +| pains | pacaur -U | Install a package from a local file | +| painsd | pacaur -S --asdeps | Install packages as dependencies of another package | +| paloc | pacaur -Qi | Display information about a package in the local database | +| palocs | pacaur -Qs | Search for packages in the local database | +| palst | pacaur -Qe | List installed packages including from AUR (tagged as "local") | +| pamir | pacaur -Syy | Force refresh of all package lists after updating mirrorlist | +| paorph | pacaur -Qtd | Remove orphans using pacaur | +| pare | pacaur -R | Remove packages, keeping its settings and dependencies | +| parem | pacaur -Rns | Remove packages, including its settings and unneeded dependencies | +| parep | pacaur -Si | Display information about a package in the repositories | +| pareps | pacaur -Ss | Search for packages in the repositories | +| paupd | pacaur -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases | +| paupd | pacaur -Sy && sudo abs | Update and refresh the local package and ABS databases | +| paupd | pacaur -Sy && sudo aur | Update and refresh the local package and AUR databases | +| paupd | pacaur -Sy | Update and refresh the local package database | +| paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) | +| pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation | +| upgrade | pacaur -Syu + #### PACMAN | Alias | Command | Description | @@ -68,3 +92,4 @@ - MatthR3D - matthr3d@gmail.com - ornicar - thibault.duplessis@gmail.com - Juraj Fiala - doctorjellyface@riseup.net +- Majora320 (Moses Miller) - Majora320@gmail.com diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 2e55d1b8..3156e949 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -64,7 +64,7 @@ elif (( $+commands[yaourt] )); then } else upgrade() { - pacman -Syu + sudo pacman -Syu } fi From cd44246415d557bc9ba8d7c74acdcc0a44d10e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 3 Oct 2016 01:04:16 +0200 Subject: [PATCH 089/121] Fix small copy-editing mistake in archlinux README --- plugins/archlinux/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index 73a5037b..16f09941 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -49,7 +49,7 @@ | paupd | pacaur -Sy | Update and refresh the local package database | | paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) | | pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation | -| upgrade | pacaur -Syu +| upgrade | pacaur -Syu | Sync with repositories before upgrading packages | #### PACMAN From 6d975f72589dbb6e44084841cddf9ea153990eb8 Mon Sep 17 00:00:00 2001 From: savimat Date: Mon, 3 Oct 2016 09:11:26 +1000 Subject: [PATCH 090/121] Add alias for signed git commit with message (#5390) Signed-off-by: Mat Munn --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index ea9ff826..28fb253d 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -65,6 +65,7 @@ alias gca!='git commit -v -a --amend' alias gcan!='git commit -v -a --no-edit --amend' alias gcans!='git commit -v -a -s --no-edit --amend' alias gcam='git commit -a -m' +alias gcsm='git commit -s -m' alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recursive' From 40bfe5a4124be7b5983756cc81b54a4a4d5846e6 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 26 Sep 2016 21:41:42 +0200 Subject: [PATCH 091/121] Implement a locking mechanism to avoid multiple update prompts (fixes #3766) --- tools/check_for_upgrade.sh | 43 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index bd9aba8b..d1b174c6 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -29,31 +29,36 @@ fi # Cancel upgrade if git is unavailable on the system whence git >/dev/null || return 0 -if [ -f ~/.zsh-update ] +if mkdir "$ZSH/log/update.lock" 2>/dev/null then - . ~/.zsh-update - - if [[ -z "$LAST_EPOCH" ]]; then - _update_zsh_update && return 0; - fi - - epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target ] + if [ -f ~/.zsh-update ] then - if [ "$DISABLE_UPDATE_PROMPT" = "true" ] + . ~/.zsh-update + + if [[ -z "$LAST_EPOCH" ]]; then + _update_zsh_update && return 0; + fi + + epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) + if [ $epoch_diff -gt $epoch_target ] then - _upgrade_zsh - else - echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c" - read line - if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then + if [ "$DISABLE_UPDATE_PROMPT" = "true" ] + then _upgrade_zsh else - _update_zsh_update + echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c" + read line + if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then + _upgrade_zsh + else + _update_zsh_update + fi fi fi + else + # create the zsh file + _update_zsh_update fi -else - # create the zsh file - _update_zsh_update + + rm -r $ZSH/log/update.lock fi From 4fa6be02300ff1bbf3772be0c8f7993a46c3769e Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 3 Oct 2016 11:52:25 +0200 Subject: [PATCH 092/121] Use rmdir instead of rm -r --- tools/check_for_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index d1b174c6..3c9a4e4c 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -60,5 +60,5 @@ then _update_zsh_update fi - rm -r $ZSH/log/update.lock + rmdir $ZSH/log/update.lock fi From 1f64fa92f524d47a87320a4baf9d9883fd23ab5e Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 3 Oct 2016 11:58:15 +0200 Subject: [PATCH 093/121] Convert "if then" statements to "if; then" one-liners --- tools/check_for_upgrade.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 3c9a4e4c..a57f6da0 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -29,10 +29,8 @@ fi # Cancel upgrade if git is unavailable on the system whence git >/dev/null || return 0 -if mkdir "$ZSH/log/update.lock" 2>/dev/null -then - if [ -f ~/.zsh-update ] - then +if mkdir "$ZSH/log/update.lock" 2>/dev/null; then + if [ -f ~/.zsh-update ]; then . ~/.zsh-update if [[ -z "$LAST_EPOCH" ]]; then @@ -40,10 +38,8 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target ] - then - if [ "$DISABLE_UPDATE_PROMPT" = "true" ] - then + if [ $epoch_diff -gt $epoch_target ]; then + if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then _upgrade_zsh else echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c" From 0887a7eb504debd8714bb914b99a2d6343f6b131 Mon Sep 17 00:00:00 2001 From: Henrik Johansson Date: Fri, 8 Aug 2014 14:09:07 +0200 Subject: [PATCH 094/121] Added simple support for Cargo - the Rust build system --- plugins/cargo/cargo.plugin.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/cargo/cargo.plugin.zsh diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh new file mode 100644 index 00000000..e1dc953d --- /dev/null +++ b/plugins/cargo/cargo.plugin.zsh @@ -0,0 +1,22 @@ +function _cargo_commands() { + local ret=1 state + _arguments ':subcommand:->subcommand' && ret=0 + + case $state in + subcommand) + subcommands=( + "build:Build the current project" + "clean:Clean up after a build" + "help:Help about available commands" + "new:Create a new project" + "test:Run the tests" + "update:Updates list of known packages" + "run:Builds and runs the currecnt project" + ) + _describe -t subcommands 'cargo subcommands' subcommands && ret=0 + esac + + return ret +} + +compdef _cargo_commands cargo From 9d35d3a5d5db6e3b5aa3935bdb3660b607bf599d Mon Sep 17 00:00:00 2001 From: FireWave Date: Mon, 3 Oct 2016 14:58:51 -0400 Subject: [PATCH 095/121] Revert "Change confusing 12h-time without AM/PM to system-localized time" This reverts commit 06d52a60389a85107ed8cc2e302a1e66f719f738. --- themes/xiong-chiamiov-plus.zsh-theme | 2 +- themes/xiong-chiamiov.zsh-theme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/xiong-chiamiov-plus.zsh-theme b/themes/xiong-chiamiov-plus.zsh-theme index 26cc3848..095dae29 100644 --- a/themes/xiong-chiamiov-plus.zsh-theme +++ b/themes/xiong-chiamiov-plus.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%c"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/themes/xiong-chiamiov.zsh-theme b/themes/xiong-chiamiov.zsh-theme index 9cf17f47..7c4c2e4f 100644 --- a/themes/xiong-chiamiov.zsh-theme +++ b/themes/xiong-chiamiov.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%c"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' From fe605e142fdaaec6282764c8fe88af27241338f3 Mon Sep 17 00:00:00 2001 From: FireWave Date: Mon, 3 Oct 2016 15:00:39 -0400 Subject: [PATCH 096/121] Change confusing 12h without AM/PM to a clean 24h display. It was not possible to simply add AM/PM since strftime return blank for %p %P --- themes/xiong-chiamiov-plus.zsh-theme | 2 +- themes/xiong-chiamiov.zsh-theme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/xiong-chiamiov-plus.zsh-theme b/themes/xiong-chiamiov-plus.zsh-theme index 095dae29..5fb4fe6f 100644 --- a/themes/xiong-chiamiov-plus.zsh-theme +++ b/themes/xiong-chiamiov-plus.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/themes/xiong-chiamiov.zsh-theme b/themes/xiong-chiamiov.zsh-theme index 7c4c2e4f..0ed335fb 100644 --- a/themes/xiong-chiamiov.zsh-theme +++ b/themes/xiong-chiamiov.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' From 6b7003c3efcabe5ce185d5c2a1a8b708d92dfb82 Mon Sep 17 00:00:00 2001 From: Laurent Commarieu Date: Mon, 26 Sep 2016 15:26:38 +0200 Subject: [PATCH 097/121] feat(plugin): add nomad --- plugins/nomad/README.md | 11 +++++++++ plugins/nomad/_nomad | 51 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 plugins/nomad/README.md create mode 100644 plugins/nomad/_nomad diff --git a/plugins/nomad/README.md b/plugins/nomad/README.md new file mode 100644 index 00000000..ff07e917 --- /dev/null +++ b/plugins/nomad/README.md @@ -0,0 +1,11 @@ +## About + +Plugin for Nomad, a tool from Hashicorp for easily deploy applications at any scale. + +### Requirements + + * [Nomad](https://nomadproject.io/) + +### Usage + + * Type `nomad` into your prompt and hit `TAB` to see available completion options diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad new file mode 100644 index 00000000..25169f39 --- /dev/null +++ b/plugins/nomad/_nomad @@ -0,0 +1,51 @@ +#compdef nomad + +local -a _nomad_cmds +_nomad_cmds=( + 'agent:Runs a Nomad agent' + 'agent-info:Display status information about the local agent' + 'alloc-status:Display allocation status information and metadata' + 'client-config:View or modify client configuration details' + 'eval-status:Display evaluation status and placement failure reasons' + 'fs:Inspect the contents of an allocation directory' + 'init:Create an example job file' + 'inspect:Inspect a submitted job' + 'logs:Streams the logs of a task.' + 'node-drain:Toggle drain mode on a given node' + 'node-status:Display status information about nodes' + 'plan:Dry-run a job update to determine its effects' + 'run:Run a new job or update an existing' + 'server-force-leave:Force a server into the left state' + 'server-join:Join server nodes together' + 'server-members:Display a list of known servers and their' + 'status:Display status information about jobs' + 'stop:Stop a running job' + 'validate:Checks if a given job specification is valid' + 'version:Prints the Nomad version' +) + + +__allocstatus() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-short[Display short output. Shows only the most recent task event.]' \ + '-stats[Display detailed resource usage statistics.]' \ + '-verbose[Show full information.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "nomad command" _nomad_cmds + return +fi + +local -a _command_args +case "$words[1]" in + alloc-status) + __allocstatus ;; +esac From dfd7bf9f4141fe6d2ec9cd067b01ad9920e80a24 Mon Sep 17 00:00:00 2001 From: Laurent Commarieu Date: Mon, 3 Oct 2016 21:11:54 +0200 Subject: [PATCH 098/121] feat(nomad): add common commands and new readme --- plugins/nomad/README.md | 16 ++++--- plugins/nomad/_nomad | 104 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 7 deletions(-) diff --git a/plugins/nomad/README.md b/plugins/nomad/README.md index ff07e917..04b36168 100644 --- a/plugins/nomad/README.md +++ b/plugins/nomad/README.md @@ -1,11 +1,15 @@ -## About +# Nomad -Plugin for Nomad, a tool from Hashicorp for easily deploy applications at any scale. +The `nomad` plugin provides a simple autocompletion for [Nomad](https://nomadproject.io/), a tool from Hashicorp for easily deploy applications at any scale. -### Requirements +## Usage - * [Nomad](https://nomadproject.io/) +1. Enable the `nomad` plugin: -### Usage + ```zsh + plugins=(... nomad) + ``` - * Type `nomad` into your prompt and hit `TAB` to see available completion options +2. Install [Nomad](https://nomadproject.io/) + +3. Type `nomad` into your prompt and hit `TAB` to see available completion options. diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad index 25169f39..1c935a02 100644 --- a/plugins/nomad/_nomad +++ b/plugins/nomad/_nomad @@ -24,7 +24,6 @@ _nomad_cmds=( 'version:Prints the Nomad version' ) - __allocstatus() { _arguments \ '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ @@ -37,6 +36,93 @@ __allocstatus() { '-t[Format and display allocation using a Go template.]' } +__evalstatus() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-monitor[Monitor an outstanding evaluation.]' \ + '-verbose[Show full information.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__inspect() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__logs() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-stderr[ Display stderr logs.]' \ + '-job[ Use a random allocation from the specified job ID.]' \ + '-verbose[Show full information.]' \ + '-f[Causes the output to not stop when the end of the logs are reached, but rather to wait for additional output.]' \ + '-tail[Show the logs contents with offsets relative to the end of the logs. If no offset is given, -n is defaulted to 10.]' \ + '-n[Sets the tail location in best-efforted number of lines relative to the end of the logs.]' \ + '-c[Sets the tail location in number of bytes relative to the end of the logs.]' +} + +__nodestatus() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-self[Query the status of the local node.]' \ + '-allocs[ Display a count of running allocations for each node.]' \ + '-short[Display short output. Shows only the most recent task event.]' \ + '-stats[Display detailed resource usage statistics.]' \ + '-verbose[Show full information.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__plan() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]' +} + +__run() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \ + '-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \ + '-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \ + '-verbose[Show full information.]' +} + +__status() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-short[Display short output. Shows only the most recent task event.]' \ + '-evals[Display the evaluations associated with the job.]' \ + '-verbose[Show full information.]' +} + +__stop() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-detach[Return immediately instead of entering monitor mode. After the deregister command is submitted, a new evaluation ID is printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \ + '-yes[Automatic yes to prompts.]' \ + '-verbose[Show full information.]' +} + _arguments '*:: :->command' if (( CURRENT == 1 )); then @@ -48,4 +134,20 @@ local -a _command_args case "$words[1]" in alloc-status) __allocstatus ;; + eval-status) + __evalstatus ;; + inspect) + __inspect ;; + logs) + __logs ;; + node-status) + __nodestatus ;; + plan) + __plan ;; + run) + __run ;; + status) + __status ;; + stop) + __stop ;; esac From 915b0e46f275d19e66f8ad7762edc4fcb28967e6 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Tue, 14 Jun 2016 10:53:58 +0200 Subject: [PATCH 099/121] Add completion for cargo, the rust build tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy of the official repository: https://github.com/rust-lang/cargo/tree/master/src/etc Signed-off-by: Marc Cornellà --- plugins/cargo/_cargo | 497 +++++++++++++++++++++++++++++++++ plugins/cargo/cargo.plugin.zsh | 22 -- 2 files changed, 497 insertions(+), 22 deletions(-) create mode 100644 plugins/cargo/_cargo delete mode 100644 plugins/cargo/cargo.plugin.zsh diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo new file mode 100644 index 00000000..17585920 --- /dev/null +++ b/plugins/cargo/_cargo @@ -0,0 +1,497 @@ +#compdef cargo + +typeset -A opt_args +autoload -U regexp-replace + +_cargo() { + +_arguments \ + '(- 1 *)'{-h,--help}'[show help message]' \ + '(- 1 *)'--list'[list installed commands]' \ + '(- 1 *)'{-v,--verbose}'[use verbose output]' \ + '(- 1 *)'--color'[colorization option]' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '1: :_cargo_cmds' \ + '*:: :->args' + +case $state in + args) + case $words[1] in + bench) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-default-features[do not build the default features]' \ + '--no-run[compile but do not run]' \ + '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + build) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-default-features[do not build the default features]' \ + '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \ + '--release=[build in release mode]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + clean) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[whether or not to clean release artifacts]' \ + '--target=[target triple(default:all)]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + doc) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-deps[do not build docs for dependencies]' \ + '--no-default-features[do not build the default features]' \ + '--open[open docs in browser after the build]' \ + '(-p, --package)'{-p,--package}'=[package to document]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[build for the target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + fetch) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + generate-lockfile) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + git-checkout) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + 'q(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--reference=[REF]' \ + '--url=[URL]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + help) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '*: :_cargo_cmds' \ + ;; + + init) + _arguments \ + '--bin[use binary template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--name=[set the resulting package name]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + install) + _arguments \ + '--bin=[only install the specified binary]' \ + '--branch=[branch to use when installing from git]' \ + '--color=:colorization option:(auto always never)' \ + '--debug[build in debug mode instead of release mode]' \ + '--example[install the specified example instead of binaries]' \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '--git=[URL from which to install the crate]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--no-default-features[do not build the default features]' \ + '--path=[local filesystem path to crate to install]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--rev=[specific commit to use when installing from git]' \ + '--root=[directory to install packages into]' \ + '--tag=[tag to use when installing from git]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--vers=[version to install from crates.io]' \ + ;; + + locate-project) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + ;; + + login) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--host=[Host to set the token for]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + metadata) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + "--no-deps[output information only about the root package and don't fetch dependencies]" \ + '--no-default-features[do not include the default feature]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '--format-version=[format version(default: 1)]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + new) + _arguments \ + '--bin[use binary template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--name=[set the resulting package name]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + owner) + _arguments \ + '(-a, --add)'{-a,--add}'[add owner LOGIN]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--index[registry index]' \ + '(-l, --list)'{-l,--list}'[list owners of a crate]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \ + '--token[API token to use when authenticating]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + package) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-l, --list)'{-l,--list}'[print files included in a package without making one]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-metadata[ignore warnings about a lack of human-usable metadata]' \ + '--no-verify[do not build to verify contents]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + pkgid) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + publish) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--host=[Host to set the token for]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-verify[Do not verify tarball until before publish]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--token[token to use when uploading]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + read-manifest) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + run) + _arguments \ + '--example=[name of the bin target]' \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--bin=[name of the bin target]' \ + '--no-default-features[do not build the default features]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release=[build in release mode]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + '*: :_normal' \ + ;; + + rustc) + _arguments \ + '--color=:colorization option:(auto always never)' \ + '--features=[features to compile for the package]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to the manifest to fetch dependencies for]' \ + '--no-default-features[do not compile default features for the package]' \ + '(-p, --package)'{-p,--package}'=[profile to compile for]' \ + '--profile=[profile to build the selected target for]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[target triple which compiles will be for]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + "${command_scope_spec[@]}" \ + ;; + + rustdoc) + _arguments \ + '--color=:colorization option:(auto always never)' \ + '--features=[space-separated list of features to also build]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to the manifest to document]' \ + '--no-default-features[do not build the `default` feature]' \ + '--open[open the docs in a browser after the operation]' \ + '(-p, --package)'{-p,--package}'=[package to document]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[build for the target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + "${command_scope_spec[@]}" \ + ;; + + search) + _arguments \ + '--color=:colorization option:(auto always never)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--host=[host of a registry to search in]' \ + '--limit=[limit the number of results]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + ;; + + test) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--test=[test name]: :_test_names' \ + '--no-default-features[do not build the default features]' \ + '--no-fail-fast[run all tests regardless of failure]' \ + '--no-run[compile but do not run]' \ + '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + '1: :_test_names' \ + ;; + + uninstall) + _arguments \ + '--bin=[only uninstall the binary NAME]' \ + '--color=:colorization option:(auto always never)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \ + '--root=[directory to uninstall packages from]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + ;; + + update) + _arguments \ + '--aggressive=[force dependency update]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \ + '--precise=[update single dependency to PRECISE]: :' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + verify-project) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + version) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + yank) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--index[registry index]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--token[API token to use when authenticating]' \ + '--undo[undo a yank, putting a version back into the index]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + '--vers[yank version]' \ + ;; + esac + ;; +esac +} + +_cargo_cmds(){ +local -a commands;commands=( +'bench:execute all benchmarks of a local package' +'build:compile the current project' +'clean:remove generated artifacts' +'doc:build package documentation' +'fetch:fetch package dependencies' +'generate-lockfile:create lockfile' +'git-checkout:git checkout' +'help:get help for commands' +'init:create new project in current directory' +'install:install a Rust binary' +'locate-project:print "Cargo.toml" location' +'login:login to remote server' +'metadata:the metadata for a project in json' +'new:create a new project' +'owner:manage the owners of a crate on the registry' +'package:assemble local package into a distributable tarball' +'pkgid:print a fully qualified package specification' +'publish:upload package to the registry' +'read-manifest:print manifest in JSON format' +'run:run the main binary of the local package' +'rustc:compile a package and all of its dependencies' +'rustdoc:build documentation for a package' +'search:search packages on crates.io' +'test:execute all unit and tests of a local package' +'uninstall:remove a Rust binary' +'update:update dependencies' +'verify-project:check Cargo.toml' +'version:show version information' +'yank:remove pushed file from index' +) +_describe 'command' commands + +} + + +#FIXME: Disabled until fixed +#gets package names from the manifest file +_get_package_names() +{ +} + +#TODO:see if it makes sense to have 'locate-project' to have non-json output. +#strips package name from json stuff +_locate_manifest(){ +local manifest=`cargo locate-project 2>/dev/null` +regexp-replace manifest '\{"root":"|"\}' '' +echo $manifest +} + +# Extracts the values of "name" from the array given in $1 and shows them as +# command line options for completion +_get_names_from_array() +{ + local -a filelist; + local manifest=$(_locate_manifest) + if [[ -z $manifest ]]; then + return 0 + fi + + local last_line + local -a names; + local in_block=false + local block_name=$1 + names=() + while read line + do + if [[ $last_line == "[[$block_name]]" ]]; then + in_block=true + else + if [[ $last_line =~ '.*\[\[.*' ]]; then + in_block=false + fi + fi + + if [[ $in_block == true ]]; then + if [[ $line =~ '.*name.*=' ]]; then + regexp-replace line '^.*name *= *|"' "" + names+=$line + fi + fi + + last_line=$line + done < $manifest + _describe $block_name names + +} + +#Gets the test names from the manifest file +_test_names() +{ + _get_names_from_array "test" +} + +#Gets the bench names from the manifest file +_benchmark_names() +{ + _get_names_from_array "bench" +} + +# These flags are mutally exclusive specifiers for the scope of a command; as +# they are used in multiple places without change, they are expanded into the +# appropriate command's `_arguments` where appropriate. +set command_scope_spec +command_scope_spec=( + '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names' + '(--bench --bin --test --lib)--example=[example name]' + '(--bench --example --test --lib)--bin=[binary name]' + '(--bench --bin --example --test)--lib=[library name]' + '(--bench --bin --example --lib)--test=[test name]' +) + + +_cargo diff --git a/plugins/cargo/cargo.plugin.zsh b/plugins/cargo/cargo.plugin.zsh deleted file mode 100644 index e1dc953d..00000000 --- a/plugins/cargo/cargo.plugin.zsh +++ /dev/null @@ -1,22 +0,0 @@ -function _cargo_commands() { - local ret=1 state - _arguments ':subcommand:->subcommand' && ret=0 - - case $state in - subcommand) - subcommands=( - "build:Build the current project" - "clean:Clean up after a build" - "help:Help about available commands" - "new:Create a new project" - "test:Run the tests" - "update:Updates list of known packages" - "run:Builds and runs the currecnt project" - ) - _describe -t subcommands 'cargo subcommands' subcommands && ret=0 - esac - - return ret -} - -compdef _cargo_commands cargo From 16bd691b3bd5ca9319e677b66096337e9bac1795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 00:17:38 +0200 Subject: [PATCH 100/121] Add README for the cargo plugin --- plugins/cargo/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plugins/cargo/README.md diff --git a/plugins/cargo/README.md b/plugins/cargo/README.md new file mode 100644 index 00000000..5fa688d2 --- /dev/null +++ b/plugins/cargo/README.md @@ -0,0 +1,11 @@ +# cargo + +This plugin adds completion for the Rust build tool [`cargo`](https://github.com/rust-lang/cargo). + +To use it, add `cargo` to the plugins array in your zshrc file: + +```zsh +plugins=(... cargo) +``` + +Updated on October 4th, 2016. From 2a0223370a2e5bae604344a735ad7b53f30b0cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ordon?= Date: Mon, 3 Oct 2016 23:37:35 +0100 Subject: [PATCH 101/121] Add an alias for React Native Link command (#5491) --- plugins/react-native/react-native.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/react-native/react-native.plugin.zsh b/plugins/react-native/react-native.plugin.zsh index 7323f1d2..9463a98b 100644 --- a/plugins/react-native/react-native.plugin.zsh +++ b/plugins/react-native/react-native.plugin.zsh @@ -3,4 +3,5 @@ alias rnios4s='react-native run-ios --simulator "iPhone 4s"' alias rnios5='react-native run-ios --simulator "iPhone 5"' alias rnios5s='react-native run-ios --simulator "iPhone 5s"' alias rnios='react-native run-ios' +alias rnlink='react-native link' From d57f36dab82b332be6fd7362c0916b226709834b Mon Sep 17 00:00:00 2001 From: Mats Faugli Date: Tue, 4 Oct 2016 00:47:59 +0200 Subject: [PATCH 102/121] Add jgitflow maven goals (#5489) --- plugins/mvn/mvn.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 625aad94..04bd186a 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -110,6 +110,8 @@ function listMavenCompletions { help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system # release release:clean release:prepare release:rollback release:perform release:stage release:branch release:update-versions + # jgitflow + jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number # repository repository:bundle-create repository:bundle-pack # source From 81981ef248e6e05d11affd4fca40bcfb98306b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:03:16 +0200 Subject: [PATCH 103/121] Fix cp plugin completion and refactor (#5427) * cp plugin: change cpv to function so that completion works * cp plugin: show numbers in units of 1024 (K,M,G,T) Use `-h` level (3): output numbers in units of 1024. See the manpage of rsync for more information. * cp plugin: add a README file * cp plugin: recurse directories * cp plugin: remove `--` to separate files from options This has some undesired effects, like having `cpv --help` be a file not found error. Use `--` yourself if you need it (which you generally don't): ```zsh cpv -- -some-file-with-hyphens.txt /tmp ``` Added this same info to the README. --- plugins/cp/README.md | 32 ++++++++++++++++++++++++++++++++ plugins/cp/cp.plugin.zsh | 18 ++++-------------- 2 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 plugins/cp/README.md diff --git a/plugins/cp/README.md b/plugins/cp/README.md new file mode 100644 index 00000000..e8a9b6cc --- /dev/null +++ b/plugins/cp/README.md @@ -0,0 +1,32 @@ +# cp plugin + +This plugin defines a `cpv` function that uses `rsync` so that you +get the features and security of this command. + +To enable, add `cp` to your `plugins` array in your zshrc file: + +```zsh +plugins=(... cp) +``` + +## Description + +The enabled options for rsync are: + +- `-p`: preserves permissions. + +- `-o`: preserves owner. + +* `-g`: preserves group. + +* `-b`: make a backup of the original file instead of overwriting it, if it exists. + +* `-r`: recurse directories. + +* `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T). + +* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync". + +* `-e /dev/null`: only work on local files (disable remote shells). + +* `--progress`: display progress. diff --git a/plugins/cp/cp.plugin.zsh b/plugins/cp/cp.plugin.zsh index 7355a999..fe6ea87a 100644 --- a/plugins/cp/cp.plugin.zsh +++ b/plugins/cp/cp.plugin.zsh @@ -1,14 +1,4 @@ -#Show progress while file is copying - -# Rsync options are: -# -p - preserve permissions -# -o - preserve owner -# -g - preserve group -# -h - output in human-readable format -# --progress - display progress -# -b - instead of just overwriting an existing file, save the original -# --backup-dir=/tmp/rsync - move backup copies to "/tmp/rsync" -# -e /dev/null - only work on local files -# -- - everything after this is an argument, even if it looks like an option - -alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --" +cpv() { + rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@" +} +compdef _files cpv From efa7c7b7ff72953368dfaba979e3014826bf1837 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Sun, 2 Oct 2016 19:15:57 -0700 Subject: [PATCH 104/121] set better default colors for GNU ls instead of none. GNU coreutils ship a color setup command by default which can be used to set a good default color theme for ls: https://www.gnu.org/software/coreutils/manual/html_node/dircolors-invocation.html --- lib/theme-and-appearance.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 5c5bb0e6..585f872e 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -5,7 +5,7 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors if [ "$DISABLE_LS_COLORS" != "true" ] then - # Find the option for using colors in ls, depending on the version: Linux or BSD + # Find the option for using colors in ls, depending on the version: GNU or BSD if [[ "$(uname -s)" == "NetBSD" ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G @@ -18,6 +18,8 @@ then gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else + # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. + type dircolors >/dev/null 2>&1 && eval "$(dircolors)" ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi fi From 6c08286c8e0ca4d2b48679d2692f0ce4ac443f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:25:07 +0200 Subject: [PATCH 105/121] Use `$commands[]` to check for command existence --- lib/theme-and-appearance.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 585f872e..43e245e1 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -19,7 +19,8 @@ then colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. - type dircolors >/dev/null 2>&1 && eval "$(dircolors)" + (( $+commands[dircolors] )) && eval "$(dircolors)" + ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi fi From 6304a789ab280e4a6e984faedd4b046f703327e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:25:36 +0200 Subject: [PATCH 106/121] Only set default LS_COLORS if not set before Also, force the use of Bourne-style shell syntax with `dircolors -b`. --- lib/theme-and-appearance.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 43e245e1..621cd067 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -19,7 +19,9 @@ then colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. - (( $+commands[dircolors] )) && eval "$(dircolors)" + if [[ -z "$LS_COLORS" ]]; then + (( $+commands[dircolors] )) && eval "$(dircolors -b)" + fi ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi From c2e3a410ea7975f72bf7f0d5b4550ac4375b1e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 01:24:48 +0200 Subject: [PATCH 107/121] Fix style of theme-and-appearance.zsh --- lib/theme-and-appearance.zsh | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 621cd067..a3bb2467 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,41 +1,37 @@ # ls colors autoload -U colors && colors -export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors -if [ "$DISABLE_LS_COLORS" != "true" ] -then - # Find the option for using colors in ls, depending on the version: GNU or BSD +export LSCOLORS="Gxfxcxdxbxegedabagacad" + +if [[ "$DISABLE_LS_COLORS" != "true" ]]; then + # Find the option for using colors in ls, depending on the version if [[ "$(uname -s)" == "NetBSD" ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G - gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' + gls --color -d . &>/dev/null && alias ls='gls --color=tty' elif [[ "$(uname -s)" == "OpenBSD" ]]; then # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # with color and multibyte support) are available from ports. "colorls" # will be installed on purpose and can't be pulled in by installing # coreutils, so prefer it to "gls". - gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' - colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' + gls --color -d . &>/dev/null && alias ls='gls --color=tty' + colorls -G -d . &>/dev/null && alias ls='colorls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. if [[ -z "$LS_COLORS" ]]; then (( $+commands[dircolors] )) && eval "$(dircolors -b)" fi - ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' + ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G' fi fi setopt auto_cd setopt multios +setopt prompt_subst -if [[ x$WINDOW != x ]] -then - SCREEN_NO="%B$WINDOW%b " -else - SCREEN_NO="" -fi +[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO="" # Apply theming defaults PS1="%n@%m:%~%# " @@ -45,6 +41,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean - -# Setup the prompt with pretty colors -setopt prompt_subst From 86126233bb5bb99ced64b95c16a4e4ed776fd8de Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Tue, 4 Oct 2016 12:21:18 +0300 Subject: [PATCH 108/121] specify globalias modes --- plugins/globalias/globalias.plugin.zsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh index 95a0e307..bac657c4 100644 --- a/plugins/globalias/globalias.plugin.zsh +++ b/plugins/globalias/globalias.plugin.zsh @@ -4,8 +4,11 @@ globalias() { zle self-insert } zle -N globalias -bindkey -e " " globalias -bindkey -v " " globalias -bindkey -e "^ " magic-space # control-space to bypass completion -bindkey -v "^ " magic-space -bindkey -M isearch " " magic-space # normal space during searches + +# space expands all global aliases +bindkey -M emacs " " globalias +bindkey -M viins " " globalias + +# control-space to make a normal space +bindkey -M emacs "^ " magic-space +bindkey -M viins "^ " magic-space From 75f87dd24ec60bd243ffbe7c9dbd1daec5b51ae2 Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Tue, 4 Oct 2016 14:03:37 +0300 Subject: [PATCH 109/121] README for globalias --- plugins/globalias/README.md | 37 ++++++++++++++++++++++++++ plugins/globalias/globalias.plugin.zsh | 3 +++ 2 files changed, 40 insertions(+) create mode 100644 plugins/globalias/README.md diff --git a/plugins/globalias/README.md b/plugins/globalias/README.md new file mode 100644 index 00000000..db2e5bee --- /dev/null +++ b/plugins/globalias/README.md @@ -0,0 +1,37 @@ +#Globalias + + +Expands all globes, backtick expressions and aliases(including global). + +``` +$ touch {1..10} +#expands to +$ touch 1 2 3 4 5 6 7 8 9 10 + +$ mkdir "`date -R`" +#expands to +$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300 + +#.zshrc: +alias -g G="| grep --color=auto -P" +alias l='ls --color=auto -lah' + +$ lG +#expands to +$ ls --color=auto -lah | grep --color=auto -P + +ls **/*.json +#expands to +ls folder/file.json anotherfolder/another.json +``` + +####Returns autocompletion to your custom aliases: +``` +#.zsrc +alias S="sudo systemctl" + +$ S +#expands to: +sudo systemctl s +#trigger autocompletion +``` diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh index bac657c4..bf4cfc03 100644 --- a/plugins/globalias/globalias.plugin.zsh +++ b/plugins/globalias/globalias.plugin.zsh @@ -12,3 +12,6 @@ bindkey -M viins " " globalias # control-space to make a normal space bindkey -M emacs "^ " magic-space bindkey -M viins "^ " magic-space + +# normal space during searches +bindkey -M isearch " " magic-space From 6eaa868cd9ad8447973a53f09453121d58366a6a Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Tue, 4 Oct 2016 14:05:41 +0300 Subject: [PATCH 110/121] fix comment --- plugins/globalias/globalias.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh index bf4cfc03..9602a960 100644 --- a/plugins/globalias/globalias.plugin.zsh +++ b/plugins/globalias/globalias.plugin.zsh @@ -5,7 +5,7 @@ globalias() { } zle -N globalias -# space expands all global aliases +# space expands all aliases, including global bindkey -M emacs " " globalias bindkey -M viins " " globalias From f701b4de0fb55b71e2cfb17522a08fba741ff170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 13:55:11 +0200 Subject: [PATCH 111/121] Fix formatting and usage section Also: - Changes `globes` (which doesn't exist) to `glob expressions`. - Delete the `trigger autocompletion to your current aliases` use case, since that's not really implemented. --- plugins/globalias/README.md | 55 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/plugins/globalias/README.md b/plugins/globalias/README.md index db2e5bee..ba9888cc 100644 --- a/plugins/globalias/README.md +++ b/plugins/globalias/README.md @@ -1,37 +1,62 @@ -#Globalias +# Globalias plugin +Expands all glob expressions, subcommands and aliases (including global). -Expands all globes, backtick expressions and aliases(including global). +Idea from: http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html. + +## Usage + +Add `globalias` to the plugins array in your zshrc file: + +```zsh +plugins=(... globalias) +``` + +Then just press `SPACE` to trigger the expansion of a command you've written. + +If you only want to insert a space without expanding the command line, press +`CTRL`+`SPACE`. + +## Examples + +#### Glob expressions ``` $ touch {1..10} -#expands to +# expands to $ touch 1 2 3 4 5 6 7 8 9 10 +$ ls **/*.json +# expands to +$ ls folder/file.json anotherfolder/another.json +``` + +#### Subcommands + +``` $ mkdir "`date -R`" -#expands to +# expands to $ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300 -#.zshrc: +``` + +#### Aliases + +``` +# .zshrc: alias -g G="| grep --color=auto -P" alias l='ls --color=auto -lah' $ lG -#expands to +# expands to $ ls --color=auto -lah | grep --color=auto -P - -ls **/*.json -#expands to -ls folder/file.json anotherfolder/another.json ``` -####Returns autocompletion to your custom aliases: ``` -#.zsrc +# .zsrc: alias S="sudo systemctl" $ S -#expands to: -sudo systemctl s -#trigger autocompletion +# expands to: +$ sudo systemctl ``` From 3cc61701bd7fd0a3fa6cb3c70f2b927a1e51970a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 13:56:25 +0200 Subject: [PATCH 112/121] Update per-directory-history plugin to latest version (#5493) Latest version: February 17, 2016 - dd81201 --- plugins/per-directory-history/README.md | 5 ++--- .../per-directory-history/per-directory-history.zsh | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md index d8ff93dc..196f74e6 100644 --- a/plugins/per-directory-history/README.md +++ b/plugins/per-directory-history/README.md @@ -27,9 +27,8 @@ Usage 2. The default mode if per directory history, interact with your history as normal. 3. Press ^G (the Control and G keys simultaneously) to toggle between local - and global histories. - - + and global histories. If you would prefer a different shortcut to toggle + set the PER_DIRECTORY_HISTORY_TOGGLE environment variable. ------------------------------------------------------------------------------- Configuration diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh index bdee341b..1242dc42 100644 --- a/plugins/per-directory-history/per-directory-history.zsh +++ b/plugins/per-directory-history/per-directory-history.zsh @@ -30,7 +30,7 @@ # ################################################################################ # -# Copyright (c) 2012 Jim Hester +# Copyright (c) 2014 Jim Hester # # This software is provided 'as-is', without any express or implied warranty. # In no event will the authors be held liable for any damages arising from the @@ -57,6 +57,7 @@ #------------------------------------------------------------------------------- [[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" +[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G' #------------------------------------------------------------------------------- # toggle global/directory history used for searching - ctrl-G by default @@ -76,7 +77,7 @@ function per-directory-history-toggle-history() { autoload per-directory-history-toggle-history zle -N per-directory-history-toggle-history -bindkey '^G' per-directory-history-toggle-history +bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history #------------------------------------------------------------------------------- # implementation details @@ -108,7 +109,7 @@ function _per-directory-history-change-directory() { } function _per-directory-history-addhistory() { - print -Sr -- ${1%%$'\n'} + print -Sr -- "${1%%$'\n'}" fc -p $_per_directory_history_directory } @@ -140,8 +141,9 @@ function _per-directory-history-set-global-history() { #add functions to the exec list for chpwd and zshaddhistory -chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") -zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") +autoload -U add-zsh-hook +add-zsh-hook chpwd _per-directory-history-change-directory +add-zsh-hook zshaddhistory _per-directory-history-addhistory #start in directory mode mkdir -p ${_per_directory_history_directory:h} From 7f9b7733507d57a6cd4f38d0c0db830647c1940d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Oct 2016 17:23:20 +0200 Subject: [PATCH 113/121] Fix compdef commands in git plugin The command `compdef command=git` returns an error in some cases, the appropriate command is `compdef _git command`. Fixes #5442 --- plugins/git/git.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 28fb253d..178f1deb 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -76,7 +76,7 @@ alias gcd='git checkout develop' alias gcmsg='git commit -m' alias gco='git checkout' alias gcount='git shortlog -sn' -compdef gcount=git +compdef _git gcount alias gcp='git cherry-pick' alias gcpa='git cherry-pick --abort' alias gcpc='git cherry-pick --continue' @@ -159,7 +159,7 @@ alias ghh='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' -compdef git-svn-dcommit-push=git +compdef _git git-svn-dcommit-push=git alias gk='\gitk --all --branches' compdef _git gk='gitk' From d69f2850afc189310b40141c839480b42f71775c Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 7 Oct 2016 23:54:54 +0200 Subject: [PATCH 114/121] Add non 0 exit code for missing jump targets (#5500) This allows for the user to combine the jump command with something else. In my example cd and jump are now combined like this: ```bash jumpcd() { jump $1 > /dev/null || cd $1 } alias cd="jumpcd" ``` --- plugins/jump/jump.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index e58e7373..86d9553a 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -9,7 +9,7 @@ export MARKPATH=$HOME/.marks jump() { - cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" + cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} } mark() { From cd37d19ddaf9cc5acbf443f93f88ca355f74090d Mon Sep 17 00:00:00 2001 From: Florian Boulay Date: Sat, 8 Oct 2016 08:26:10 +0200 Subject: [PATCH 115/121] Add m4a format in the common aliases plugin (#5502) The m4a file format can be opened in the command line with mplayer --- plugins/common-aliases/common-aliases.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index c7aafd8b..128db6e5 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -63,7 +63,7 @@ if is-at-least 4.2.0; then _image_fts=(jpg jpeg png gif mng tiff tif xpm) for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done - _media_fts=(ape avi flv mkv mov mp3 mpeg mpg ogg ogm rm wav webm) + _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) for ft in $_media_fts ; do alias -s $ft=mplayer ; done #read documents From 3be4108d722269720c71138a211dd744ade66f5d Mon Sep 17 00:00:00 2001 From: Michel Filipe Date: Sun, 9 Oct 2016 14:36:47 -0300 Subject: [PATCH 116/121] remove duplicate alias (#5508) Removing one "apt-get autoremove" alias because it is duplicated. --- plugins/ubuntu/ubuntu.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index d924f886..ffde284f 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -29,7 +29,6 @@ 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 @@ -44,7 +43,6 @@ 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' From 98cd3973d23dfb83aa60f5d11bbb31e2dc714fad Mon Sep 17 00:00:00 2001 From: Hong Date: Mon, 10 Oct 2016 11:40:17 -0700 Subject: [PATCH 117/121] Take advantage of LS_COLORS for the color of completion if GNU ls is used. (#5510) --- lib/theme-and-appearance.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index a3bb2467..12bcd284 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -24,6 +24,9 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then fi ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G' + + # Take advantage of $LS_COLORS for completion as well. + zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" fi fi From a56eac7a71a774a4d97bb9456f36b8eb495329d5 Mon Sep 17 00:00:00 2001 From: Hong Date: Mon, 10 Oct 2016 13:24:30 -0700 Subject: [PATCH 118/121] Use OSTYPE instead of uname whenever possible for better speed. (#5496) --- lib/theme-and-appearance.zsh | 4 ++-- plugins/battery/battery.plugin.zsh | 2 +- plugins/gitfast/git-completion.bash | 2 +- plugins/sublime/sublime.plugin.zsh | 2 +- plugins/zsh-navigation-tools/_n-kill | 4 ++-- plugins/zsh-navigation-tools/n-kill | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 12bcd284..039a59d2 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -6,11 +6,11 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" if [[ "$DISABLE_LS_COLORS" != "true" ]]; then # Find the option for using colors in ls, depending on the version - if [[ "$(uname -s)" == "NetBSD" ]]; then + if [[ "$OSTYPE" == netbsd* ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null && alias ls='gls --color=tty' - elif [[ "$(uname -s)" == "OpenBSD" ]]; then + elif [[ "$OSTYPE" == openbsd* ]]; then # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # with color and multibyte support) are available from ports. "colorls" # will be installed on purpose and can't be pulled in by installing diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 0bb9e77f..da229cf3 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -64,7 +64,7 @@ if [[ "$OSTYPE" = darwin* ]] ; then [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] } -elif [[ $(uname) == "Linux" ]] ; then +elif [[ "$OSTYPE" = linux* ]] ; then function battery_is_charging() { ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash index e3918c87..8ce6b5c5 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -2771,6 +2771,6 @@ __git_complete gitk __gitk_main # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # -if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +if [[ "$OSTYPE" = cygwin* ]]; then __git_complete git.exe __git_main fi diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 75a39eab..f84b7032 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -1,4 +1,4 @@ -if [[ $('uname') == 'Linux' ]]; then +if [[ "$OSTYPE" == linux* ]]; then local _sublime_linux_paths > /dev/null 2>&1 _sublime_linux_paths=( "$HOME/bin/sublime_text" diff --git a/plugins/zsh-navigation-tools/_n-kill b/plugins/zsh-navigation-tools/_n-kill index 8a4ec9da..6f5d4797 100644 --- a/plugins/zsh-navigation-tools/_n-kill +++ b/plugins/zsh-navigation-tools/_n-kill @@ -10,8 +10,8 @@ integer cygwin=0 local IFS=" " -case "$(uname)" in - CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;; +case "$OSTYPE" in + cygwin*) list=( `command ps -Wa` ); cygwin=1 ;; *) list=( `command ps -o pid,uid,command -A` ) ;; esac diff --git a/plugins/zsh-navigation-tools/n-kill b/plugins/zsh-navigation-tools/n-kill index 0d10565e..76050f96 100644 --- a/plugins/zsh-navigation-tools/n-kill +++ b/plugins/zsh-navigation-tools/n-kill @@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 ) type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 } -case "$(uname)" in - CYGWIN*) list=( `command ps -Wa` ) ;; +case "$OSTYPE" in + cygwin*) list=( `command ps -Wa` ) ;; *) list=( `command ps -o pid,uid,command -A` ) ;; esac From f7d4f985ac391e4532a5e6331e0c296fad4a913c Mon Sep 17 00:00:00 2001 From: Hong Date: Mon, 10 Oct 2016 14:01:37 -0700 Subject: [PATCH 119/121] Use $+commands to check the existence of a command in clipboard.zsh. (#5519) --- lib/clipboard.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index b663800a..2c93d1bb 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -31,13 +31,13 @@ function clipcopy() { cat $file > /dev/clipboard fi else - if which xclip &>/dev/null; then + if (( $+commands[xclip] )); then if [[ -z $file ]]; then xclip -in -selection clipboard else xclip -in -selection clipboard $file fi - elif which xsel &>/dev/null; then + elif (( $+commands[xsel] )); then if [[ -z $file ]]; then xsel --clipboard --input else @@ -74,9 +74,9 @@ function clippaste() { elif [[ $OSTYPE == cygwin* ]]; then cat /dev/clipboard else - if which xclip &>/dev/null; then + if (( $+commands[xclip] )); then xclip -out -selection clipboard - elif which xsel &>/dev/null; then + elif (( $+commands[xsel] )); then xsel --clipboard --output else print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 From 628d0bb10664453fe55c1e725ab89fa42dc4ab0a Mon Sep 17 00:00:00 2001 From: rossmcf Date: Mon, 10 Oct 2016 15:42:55 +0100 Subject: [PATCH 120/121] Fix ls colouring for Darwin. (#5516) --- lib/theme-and-appearance.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 039a59d2..0fd3c44d 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -6,7 +6,7 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" if [[ "$DISABLE_LS_COLORS" != "true" ]]; then # Find the option for using colors in ls, depending on the version - if [[ "$OSTYPE" == netbsd* ]]; then + if [[ "$OSTYPE" == netbsd* ]] || [[ "$OSTYPE" == darwin* ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null && alias ls='gls --color=tty' From c24dfa1ab4abb1f28fad7666f3bc24f3abced801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 11 Oct 2016 09:24:43 +0200 Subject: [PATCH 121/121] Fix ls coloring in MacOS if gls is not installed Fixes #5520. --- lib/theme-and-appearance.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 0fd3c44d..467b770d 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -6,7 +6,7 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" if [[ "$DISABLE_LS_COLORS" != "true" ]]; then # Find the option for using colors in ls, depending on the version - if [[ "$OSTYPE" == netbsd* ]] || [[ "$OSTYPE" == darwin* ]]; then + if [[ "$OSTYPE" == netbsd* ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null && alias ls='gls --color=tty' @@ -17,6 +17,8 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then # coreutils, so prefer it to "gls". gls --color -d . &>/dev/null && alias ls='gls --color=tty' colorls -G -d . &>/dev/null && alias ls='colorls -G' + elif [[ "$OSTYPE" == darwin* ]]; then + gls --color -d . &>/dev/null && alias ls='gls --color=tty' || alias ls='ls -G' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. if [[ -z "$LS_COLORS" ]]; then